3
votes

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?

3

3 Answers

1
votes

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>
1
votes

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.

1
votes

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?