Import SSJS script library using DXL in a database

[亡魂溺海] 提交于 2019-12-23 19:16:12

问题


We need to import a SSJS library in a database using DXL. For this we have written a Java Agent and its code goes something like this:

import lotus.domino.*;
public class JavaAgent extends AgentBase {
    private DxlImporter importer = null;
    public void NotesMain() {
        try {
            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();

            String filename = "C:\\tempssjslib.xml";

            Stream stream = session.createStream();
            if (stream.open(filename) & (stream.getBytes() > 0)) {
                Database importdb = session.getCurrentDatabase();
                importer = session.createDxlImporter();
                importer.setReplaceDbProperties(true);
                importer.setReplicaRequiredForReplaceOrUpdate(false);
                importer.setAclImportOption(DxlImporter.DXLIMPORTOPTION_REPLACE_ELSE_IGNORE);
                importer.setDesignImportOption(DxlImporter.DXLIMPORTOPTION_REPLACE_ELSE_CREATE);
                importer.importDxl(stream, importdb);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } 
        finally {
            try {
                System.out.println(importer.getLog());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

The file C:\tempssjslib.xml contains a SSJS library which I created in Domino Designer and then exported using "Tools > DXL Utilities > Exporter" (for testing purpose). But when I run this agent library does not get imported in the database. There is no error in DxlImporter.getLog() also.

I tried similar procedure with XPages, Form, LotusScript script library and was successfully able to import them. But the same agent is not able to import SSJS library.

Is there something that I have missed in the code? Can we import SSJS library in database using DXL?


回答1:


It looks like the exporter tool (or maybe even the DXLexporter) is not exporting all needed fields. If you manually add this inside the dxl file, just before the item name='$ServerJavaScriptLibrary'... line, it will succesfully import it.

<item name='$Flags'><text>.5834Q</text></item>
<item name='$TITLE'><text>...name of the SSJS library...</text></item>



回答2:


If you print the imported note id and analyze that in an appropriate tool (Ytria or Notespeek) you'll see that the problem is with $Flags field.

I created a test SSJS library and $Flags field contains ".5834Q". But the imported one has "34Q" only.

I don't have the exact reference for those flags but it may be a good start. Manually overwriting this field works successfully but this flag may contain some valuable information.

It seems like a bug to me.

In addition YTria tool has a good reference about $flags field content.




回答3:


Make your live easier and use the Import/Export plug-in found on OpenNTF: http://www.openntf.org/blogs/openntf.nsf/d6plinks/NHEF-7YAAF6 It has an ANT API, so you can automate operations. Needs Domino Designer, so it might not fit your use case. Alternatively (haven't checked): Did you have a look if webDAV exposes the script libraries?



来源:https://stackoverflow.com/questions/9891295/import-ssjs-script-library-using-dxl-in-a-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!