import lotus.domino.*;
public class JavaAgent extends AgentBase {
static DxlImporter importer = null;
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
// Get current database
Database db = agentContext.getCurrentDatabase();
// Get DXL file
String filename = "c:¥¥dxl¥¥exporteddb.dxl";
Stream stream = session.createStream();
if (stream.open(filename) & (stream.getBytes() >0)) {
// Create new database - replace if it already exists
Database newdb = session.getDatabase(null, "imported");
if (newdb.isOpen())
newdb.remove();
DbDirectory dbdir = session.getDbDirectory(null);
newdb = dbdir.createDatabase("imported", true);
newdb.setTitle("Imported");
// Import DXL from file to new database
importer = session.createDxlImporter();
importer.setReplaceDbProperties(true);
importer.setReplicaRequiredForReplaceOrUpdate(false);
importer.setAclImportOption(
DxlImporter.DXLIMPORTOPTION_REPLACE_ELSE_IGNORE);
importer.setDesignImportOption(
DxlImporter.DXLIMPORTOPTION_CREATE);
importer.importDxl(stream, newdb);
}
else
System.out.println(filename + " does not exist or is empty");
} catch(Exception e) {
e.printStackTrace();
} finally {
// Print importer log
try {
System.out.println(importer.getLog());
} catch(Exception e) {e.printStackTrace();}
}
}
}
DXLExporter クラスの例により生成されたファイルは、このコードを使用して呼び出されます。
import lotus.domino.*;
public class JavaAgent extends AgentBase {
static DxlImporter importer = null;
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
// Get current database
Database db = agentContext.getCurrentDatabase();
// Create new database - replace if it already exists
Database newdb = session.getDatabase(null, "imported");
if (newdb.isOpen())
newdb.remove();
DbDirectory dbdir = session.getDbDirectory(null);
newdb = dbdir.createDatabase("imported", true);
newdb.setTitle("Imported");
// Export current database and import into new database
importer = session.createDxlImporter();
importer.setReplaceDbProperties(true);
importer.setReplicaRequiredForReplaceOrUpdate(false);
importer.setAclImportOption(
DxlImporter.DXLIMPORTOPTION_REPLACE_ELSE_IGNORE);
importer.setDesignImportOption(
DxlImporter.DXLIMPORTOPTION_CREATE);
DxlExporter exporter = session.createDxlExporter();
importer.importDxl(exporter.exportDxl(db), newdb);
} catch(Exception e) {
e.printStackTrace();
} finally {
// Print importer log
try {
System.out.println(importer.getLog());
} catch(Exception e) {e.printStackTrace();}
}
}
}