use of lotus.domino.Session in project org.openntf.domino by OpenNTF.
the class DominoRunner method run.
@Override
public void run() {
try {
System.out.println("Starting NotesRunner");
Session session = NotesFactory.createSession();
sessionid.set(getLotusId(session));
Database db = session.getDatabase("", "log.nsf");
getLotusId(db);
Name name = null;
int i = 0;
try {
for (i = 0; i <= 100000; i++) {
name = session.createName(UUID.randomUUID().toString());
getLotusId(name);
DateTime dt = session.createDateTime(new Date());
getLotusId(dt);
DateTime end = session.createDateTime(new Date());
getLotusId(end);
DateRange dr = session.createDateRange(dt, end);
getLotusId(dr);
Document doc = db.createDocument();
getLotusId(doc);
Item i1 = doc.replaceItemValue("Foo", dr);
getLotusId(i1);
Item i2 = doc.replaceItemValue("Bar", dr.getText());
getLotusId(i2);
Item i3 = doc.replaceItemValue("Blah", dr.getStartDateTime().getLocalTime());
getLotusId(i3);
lotus.domino.ColorObject color = session.createColorObject();
getLotusId(color);
color.setRGB(128, 128, 128);
Item i4 = doc.replaceItemValue("color", color.getNotesColor());
getLotusId(i4);
i1.recycle();
i2.recycle();
i3.recycle();
i4.recycle();
DateTime create = doc.getCreated();
getLotusId(create);
String lc = create.getLocalTime();
if (i % 10000 == 0) {
System.out.println(Thread.currentThread().getName() + " Name " + i + " is " + name.getCommon() + " " + "Local time is " + lc + " " + dr.getText());
}
dr.recycle();
doc.recycle();
dt.recycle();
end.recycle();
create.recycle();
color.recycle();
if (name != null)
name.recycle();
}
} catch (Throwable t) {
t.printStackTrace();
System.out.println("Exception at loop point " + i);
}
session.recycle();
} catch (Throwable t) {
t.printStackTrace();
}
System.out.println("FINI!");
}
use of lotus.domino.Session in project org.openntf.domino by OpenNTF.
the class OpenntfNABNamePickerData method getSessionAddressBooks.
/**
* Compose the list of all the address books, once for ever...
*
* Beyond the cache, this guarantees that the NAB are always retrieved in the same order.
*
* The list has to be cached at the session level, as different users can have different ACLs for the databases.
*
* @return NabDb[] Array of address books
* @throws NotesException
*/
private NABDb[] getSessionAddressBooks() throws NotesException {
Map<String, Object> sc = ExtLibUtil.getSessionScope();
NABDb[] addressBooks = sc != null ? (NABDb[]) sc.get(KEY_NABS) : null;
if (addressBooks == null) {
// Try with the current user
Session session = ExtLibUtil.getCurrentSession();
addressBooks = getSessionAddressBooks(session);
if (addressBooks != null && addressBooks.length > 0) {
if (sc != null) {
sc.put(KEY_NABS, addressBooks);
}
} else {
// No NAB is avail - we don't throw a signal from here as it forces authentication
// as soon as the page is displayed (the control asks for the NAB when rendering)
// throw new NoAccessSignal();
}
}
return addressBooks;
}
use of lotus.domino.Session in project org.openntf.nsfodp by OpenNTF.
the class ReplaceDesignTaskLocal method run.
@Override
public void run() {
monitor.setTaskName(Messages.ReplaceDesignTaskLocal_label);
try {
Session session = NotesFactory.createSession();
try {
// $NON-NLS-1$
String command = StringUtil.format("load convert -d \"{0}\" * \"{1}\"", targetDbName, templatePath.toAbsolutePath().toString());
// $NON-NLS-1$
session.sendConsoleCommand("", command);
monitor.done();
} finally {
session.recycle();
}
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
use of lotus.domino.Session in project org.openntf.nsfodp by OpenNTF.
the class ReplaceDesignTaskTest method run.
@Override
public IStatus run(IProgressMonitor monitor) {
try {
Session session = NotesFactory.createSession();
try {
Database sourceDb = getDatabase(session, sourcePath);
Database targetDb = getDatabase(session, targetPath);
// Delete elements from the target database
// Ignore elements having "prohibit design..." property or Master Template defined
NoteCollection targetNoteColl = targetDb.createNoteCollection(true);
targetNoteColl.selectAllAdminNotes(false);
targetNoteColl.selectAllDataNotes(false);
targetNoteColl.setSelectIcon(false);
targetNoteColl.setSelectHelpAbout(false);
targetNoteColl.setSelectHelpIndex(false);
targetNoteColl.setSelectHelpUsing(false);
// Select notes without "prohibit design" or master templates
// $NON-NLS-1$
targetNoteColl.setSelectionFormula(" !(@IsAvailable($Class) | @Contains($Flags; 'P')) ");
// Remove selected notes
targetNoteColl.buildCollection();
String noteId = targetNoteColl.getFirstNoteID();
while (StringUtil.isNotEmpty(noteId)) {
Document note = targetDb.getDocumentByID(noteId);
// System.out.println(Messages.getString("ReplaceDesignTaskTest.consoleRemoving", noteId, note.getItemValueString("$TITLE"))); //$NON-NLS-1$ //$NON-NLS-2$
note.remove(true);
noteId = targetNoteColl.getNextNoteID(noteId);
}
// Check for Help About and Help Using
boolean isHelpAbout = false, isHelpUsing = false;
targetNoteColl.selectAllNotes(false);
targetNoteColl.clearCollection();
targetNoteColl.setSelectHelpAbout(true);
targetNoteColl.buildCollection();
if (targetNoteColl.getCount() > 0) {
noteId = targetNoteColl.getFirstNoteID();
Document helpAbout = targetDb.getDocumentByID(noteId);
if (helpAbout.getItemValueString("$Flags").contains("R")) {
// $NON-NLS-1$ //$NON-NLS-2$
// System.out.println(Messages.getString("ReplaceDesignTaskTest.consoleRemovingHelpAbout")); //$NON-NLS-1$
helpAbout.remove(true);
isHelpAbout = true;
}
}
targetNoteColl.selectAllNotes(false);
targetNoteColl.clearCollection();
targetNoteColl.setSelectHelpUsing(true);
targetNoteColl.buildCollection();
if (targetNoteColl.getCount() > 0) {
noteId = targetNoteColl.getFirstNoteID();
Document helpUsing = targetDb.getDocumentByID(noteId);
if (helpUsing.getItemValueString("$Flags").contains("R")) {
// $NON-NLS-1$ //$NON-NLS-2$
// System.out.println(Messages.getString("ReplaceDesignTaskTest.consoleRemovingHelpUsing")); //$NON-NLS-1$
helpUsing.remove(true);
isHelpUsing = true;
}
}
// Set "More Fields" option
targetDb.setOption(Database.DBOPT_MOREFIELDS, true);
// Copy all design elements from source DB to target DB except Help About and Help Using
NoteCollection sourceNoteColl = sourceDb.createNoteCollection(true);
sourceNoteColl.selectAllAdminNotes(false);
sourceNoteColl.selectAllDataNotes(false);
sourceNoteColl.setSelectIcon(false);
sourceNoteColl.setSelectHelpAbout(isHelpAbout);
sourceNoteColl.setSelectHelpUsing(isHelpUsing);
return Status.OK_STATUS;
} finally {
session.recycle();
}
} catch (Exception e) {
return new Status(IStatus.ERROR, Messages.ReplaceDesignTaskTest_errorReplacingDesign, e.toString(), e);
}
}
Aggregations