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);
}
}
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);
}
}
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);
}
}
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();
}
});
}
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);
}
}
Aggregations