Search in sources :

Example 1 with AdministrationProcess

use of lotus.domino.AdministrationProcess in project org.openntf.nsfodp by OpenNTF.

the class DeployNSFTask method run.

@Override
public void run() {
    try {
        Session session = NotesFactory.createSession();
        try {
            String server, filePath;
            // $NON-NLS-1$
            int bangIndex = destPath.indexOf("!!");
            if (bangIndex > -1) {
                server = destPath.substring(0, bangIndex);
                filePath = destPath.substring(bangIndex + 2);
            } else {
                // $NON-NLS-1$
                server = "";
                filePath = destPath;
            }
            Database dest = session.getDatabase(server, filePath, true);
            if (dest.isOpen() && !replaceDesign) {
                throw new IllegalStateException(MessageFormat.format(Messages.DeployNSFTask_dbExists, destPath));
            }
            if (dest.isOpen()) {
                // Then do a replace design
                ReplaceDesignTaskLocal task = new ReplaceDesignTaskLocal(filePath, nsfFile, new NullProgressMonitor());
                DominoThreadFactory.getExecutor().submit(task).get();
            } else {
                // $NON-NLS-1$
                Database source = session.getDatabase("", nsfFile.toAbsolutePath().toString());
                dest = source.createFromTemplate(server, filePath, false);
            }
            if (this.signDatabase) {
                AdministrationProcess adminp = session.createAdministrationProcess(server);
                adminp.signDatabaseWithServerID(server, filePath);
                // $NON-NLS-1$
                session.sendConsoleCommand(server, "tell adminp p im");
            }
        } finally {
            session.recycle();
        }
    } catch (NotesException | ExecutionException | InterruptedException ne) {
        throw new RuntimeException(Messages.DeployNSFTask_exceptionDeploying, ne);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) NotesException(lotus.domino.NotesException) Database(lotus.domino.Database) AdministrationProcess(lotus.domino.AdministrationProcess) ExecutionException(java.util.concurrent.ExecutionException) Session(lotus.domino.Session)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)1 AdministrationProcess (lotus.domino.AdministrationProcess)1 Database (lotus.domino.Database)1 NotesException (lotus.domino.NotesException)1 Session (lotus.domino.Session)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1