Search in sources :

Example 1 with DominoException

use of com.darwino.domino.napi.DominoException in project org.openntf.nsfodp by OpenNTF.

the class DarwinoNDatabase method eachDesignNote.

@Override
public void eachDesignNote(BiConsumer<Integer, NNote> consumer) {
    NSFSEARCHPROC proc = new NSFSEARCHPROC() {

        @Override
        public short callback(long searchMatchPtr, long summaryBufferPtr) throws DominoException {
            SEARCH_MATCH searchMatch = new SEARCH_MATCH();
            C.memcpy(searchMatch.getDataPtr(), 0, searchMatchPtr, 0, SEARCH_MATCH.sizeOf);
            short noteClass = searchMatch.getNoteClass();
            int noteId = searchMatch.getId().getNoteId();
            byte retFlags = searchMatch.getSERetFlags();
            boolean deleted = (noteClass & DominoAPI.NOTE_CLASS_NOTIFYDELETION) != 0;
            // The use of "since" means that non-matching notes will be returned; check this flag to make sure
            boolean isSearchMatch = (retFlags & DominoAPI.SE_FMATCH) != 0;
            if (isSearchMatch && !deleted) {
                try (NNote note = getNoteByID(noteId)) {
                    consumer.accept(noteId, note);
                }
            }
            return DominoAPI.NOERROR;
        }
    };
    try {
        // $NON-NLS-1$
        database.search("@All", proc, (short) 0, DominoAPI.NOTE_CLASS_ALLNONDATA, null, null);
    } catch (DominoException e) {
        throw new NDominoException(e.getStatus(), e);
    } catch (FormulaException e) {
        throw new NDominoException(0, e);
    }
}
Also used : NNote(org.openntf.nsfodp.commons.odp.notesapi.NNote) NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException) NSFSEARCHPROC(com.darwino.domino.napi.proc.NSFSEARCHPROC) SEARCH_MATCH(com.darwino.domino.napi.struct.SEARCH_MATCH) FormulaException(com.darwino.domino.napi.wrap.FormulaException) DominoException(com.darwino.domino.napi.DominoException) NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException)

Example 2 with DominoException

use of com.darwino.domino.napi.DominoException in project org.openntf.nsfodp by OpenNTF.

the class DarwinoNotesAPI method createDXLExporter.

@Override
public NDXLExporter createDXLExporter() {
    try {
        NSFDXLExporter exporter = session.createDXLExporter();
        exporter.setExportCharset(DXL_EXPORT_CHARSET.Utf8);
        exporter.setOutputDoctype(false);
        return new DarwinoNDXLExporter(exporter);
    } catch (DominoException e) {
        throw new NDominoException(e.getStatus(), e);
    }
}
Also used : NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException) NSFDXLExporter(com.darwino.domino.napi.wrap.NSFDXLExporter) DominoException(com.darwino.domino.napi.DominoException) NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException)

Example 3 with DominoException

use of com.darwino.domino.napi.DominoException in project org.openntf.nsfodp by OpenNTF.

the class DarwinoNDXLExporter method export.

@Override
public void export(NNote note, OutputStream os) {
    try {
        NSFNote n = ((DarwinoNNote) note).getNSFNote();
        this.exporter.export(n, os);
    } catch (DominoException e) {
        throw new NDominoException(e.getStatus(), e);
    }
}
Also used : NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException) NSFNote(com.darwino.domino.napi.wrap.NSFNote) DominoException(com.darwino.domino.napi.DominoException) NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException)

Example 4 with DominoException

use of com.darwino.domino.napi.DominoException in project openliberty-domino by OpenNTF.

the class RuntimeActivator method start.

@Override
public void start(BundleContext context) throws Exception {
    if (log.isLoggable(Level.INFO)) {
        // $NON-NLS-1$
        log.info(Messages.getString("RuntimeActivator.initializingRuntime"));
    }
    AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
        // $NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("notesruntime.init", "true");
        return null;
    });
    // $NON-NLS-1$
    String notesProgramDir = System.getenv("Notes_ExecDirectory");
    if (StringUtil.isNotEmpty(notesProgramDir)) {
        // Attempt to load lsxbe and jnotes
        // $NON-NLS-1$
        String lsxbeFileName = System.mapLibraryName("lsxbe");
        Path lsxbe = Paths.get(notesProgramDir).resolve(lsxbeFileName);
        if (Files.isRegularFile(lsxbe)) {
            System.load(lsxbe.toString());
        }
        // $NON-NLS-1$
        String jnotesFileName = System.mapLibraryName("jnotes");
        Path jnotes = Paths.get(notesProgramDir).resolve(jnotesFileName);
        if (Files.isRegularFile(jnotes)) {
            System.load(jnotes.toString());
        }
    }
    notesExecutor.submit(() -> {
        try {
            // $NON-NLS-1$
            String notesIniPath = System.getenv("NotesINI");
            if (StringUtil.isNotEmpty(notesProgramDir)) {
                String[] initArgs = new String[] { notesProgramDir, // $NON-NLS-1$ //$NON-NLS-2$
                StringUtil.isEmpty(notesIniPath) ? "" : ("=" + notesIniPath) };
                if (log.isLoggable(Level.INFO)) {
                    // $NON-NLS-1$
                    log.info(StringUtil.format(Messages.getString("RuntimeActivator.initializingRuntimeWithArgs"), Arrays.toString(initArgs)));
                }
                try {
                    DominoAPI.get().NotesInitExtended(initArgs);
                } catch (DominoException e) {
                    throw new RuntimeException(e);
                }
            } else {
                // For Windows specifically and Domino generally
                DominoAPI.get().NotesInit();
            }
            DominoAPI.get().NotesInitThread();
            DominoAPI.get().HTMLProcessInitialize();
            try {
                while (true) {
                    TimeUnit.DAYS.sleep(1);
                }
            } catch (InterruptedException e) {
            // Expected on shutdown
            } finally {
                DominoAPI.get().HTMLProcessTerminate();
                DominoAPI.get().NotesTermThread();
                DominoAPI.get().NotesTerm();
                if (log.isLoggable(Level.INFO)) {
                    // $NON-NLS-1$
                    log.info(Messages.getString("RuntimeActivator.terminatedRuntime"));
                }
            }
        } catch (DominoException e) {
            e.printStackTrace();
        }
    });
}
Also used : Path(java.nio.file.Path) DominoException(com.darwino.domino.napi.DominoException)

Example 5 with DominoException

use of com.darwino.domino.napi.DominoException in project org.openntf.nsfodp by OpenNTF.

the class DarwinoNCompositeData method writeJavaScriptLibraryData.

@Override
public void writeJavaScriptLibraryData(OutputStream os) throws IOException {
    try {
        // TODO figure out why the Darwino implementation chops data
        // https://github.com/OpenNTF/org.openntf.nsfodp/issues/271
        // this.data.writeJavaScriptLibraryData(os);
        long dbHandle = this.note.getParent().getHandle();
        NotesSession notesSession = new NotesSession();
        try {
            NotesDatabase notesDatabase = notesSession.getDatabase((int) dbHandle);
            NotesNote notesNote = notesDatabase.openNote(this.note.getNoteID(), 0);
            FileAccess.readFileContent(notesNote, os);
        } finally {
            notesSession.recycle();
        }
    } catch (NotesAPIException e) {
        throw new NDominoException(e.getNativeErrorCode(), e);
    } catch (DominoException e) {
        throw new NDominoException(e.getStatus(), e);
    }
}
Also used : NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException) NotesNote(com.ibm.designer.domino.napi.NotesNote) NotesDatabase(com.ibm.designer.domino.napi.NotesDatabase) NotesSession(com.ibm.designer.domino.napi.NotesSession) NotesAPIException(com.ibm.designer.domino.napi.NotesAPIException) DominoException(com.darwino.domino.napi.DominoException) NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException)

Aggregations

DominoException (com.darwino.domino.napi.DominoException)7 NDominoException (org.openntf.nsfodp.commons.odp.notesapi.NDominoException)6 NSFSEARCHPROC (com.darwino.domino.napi.proc.NSFSEARCHPROC)1 SEARCH_MATCH (com.darwino.domino.napi.struct.SEARCH_MATCH)1 FormulaException (com.darwino.domino.napi.wrap.FormulaException)1 NSFDXLExporter (com.darwino.domino.napi.wrap.NSFDXLExporter)1 NSFDXLImporter (com.darwino.domino.napi.wrap.NSFDXLImporter)1 NSFDatabase (com.darwino.domino.napi.wrap.NSFDatabase)1 NSFNote (com.darwino.domino.napi.wrap.NSFNote)1 NSFNoteIDCollection (com.darwino.domino.napi.wrap.NSFNoteIDCollection)1 NotesAPIException (com.ibm.designer.domino.napi.NotesAPIException)1 NotesDatabase (com.ibm.designer.domino.napi.NotesDatabase)1 NotesNote (com.ibm.designer.domino.napi.NotesNote)1 NotesSession (com.ibm.designer.domino.napi.NotesSession)1 Path (java.nio.file.Path)1 NNote (org.openntf.nsfodp.commons.odp.notesapi.NNote)1