use of org.openntf.nsfodp.commons.h.StdNames.DFLAGPAT_SACTIONS_DESIGN in project org.openntf.nsfodp by OpenNTF.
the class ODPCompiler method compileLotusScript.
private void compileLotusScript(NDatabase database, List<Integer> noteIds, boolean retry) {
if (!noteIds.isEmpty()) {
try {
// $NON-NLS-1$
Class.forName("lotus.domino.websvc.client.Stub");
} catch (ClassNotFoundException e) {
subTask(Messages.ODPCompiler_webServiceNotFound1);
subTask(Messages.ODPCompiler_webServiceNotFound2);
return;
}
subTask(Messages.ODPCompiler_compilingLotusScript);
// In lieu of a dependency graph, just keep bashing at the list until it's done
Queue<Integer> remaining = new ArrayDeque<>(noteIds);
Map<Integer, String> titles = new HashMap<>();
for (int i = 0; i < noteIds.size(); i++) {
Queue<Integer> nextPass = new ArrayDeque<>();
Integer noteId;
while ((noteId = remaining.poll()) != null) {
String title = null;
try (NNote note = database.getNoteByID(noteId)) {
// Check to see if this is the Shared Actions note, which we should skip to avoid trouble
if ((note.getNoteClassValue() & NsfNote.NOTE_CLASS_NONPRIV) == NsfNote.NOTE_CLASS_FORM) {
String flags = note.getAsString(StdNames.DESIGN_FLAGS, ' ');
if (NSFODPUtil.matchesFlagsPattern(flags, DFLAGPAT_SACTIONS_DESIGN)) {
continue;
}
}
// $NON-NLS-1$
title = note.get("$TITLE", String.class);
titles.put(noteId, title);
note.compileLotusScript();
note.sign();
note.save();
} catch (NLotusScriptCompilationException err) {
nextPass.add(noteId);
// $NON-NLS-1$
titles.put(noteId, title + " - " + err);
} catch (NDominoException err) {
if (err.getStatus() == 12051) {
// Same as above, but not encapsulated
// $NON-NLS-1$
titles.put(noteId, title + " - " + err);
nextPass.add(noteId);
} else if (err.getStatus() == 0x222) {
// Note item not found - occurs for non-LS elements
} else {
throw err;
}
}
}
remaining = nextPass;
if (nextPass.isEmpty()) {
break;
}
}
if (!retry && !remaining.isEmpty()) {
String notes = remaining.stream().map(// $NON-NLS-1$ //$NON-NLS-2$
noteId -> "Note ID " + noteId + ": " + titles.get(noteId)).collect(// $NON-NLS-1$
Collectors.joining("\n"));
throw new RuntimeException(MessageFormat.format(Messages.ODPCompiler_unableToCompileLotusScript, notes));
}
}
}
Aggregations