Java Code Examples for lotus.domino.NotesException#printStackTrace()

The following examples show how to use lotus.domino.NotesException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DominoJUnitRunner.java    From org.openntf.domino with Apache License 2.0 6 votes vote down vote up
@Override
protected void startUp() {
	NotesThread.sinitThread();
	try {
		// keep alive one session over all test cases - this will improve execution speed
		mastersession = lotus.domino.NotesFactory.createSession();
		TestEnv.setup(mastersession);
	} catch (NotesException ne) {
		ne.printStackTrace();
	}
	LogManager.getLogManager().reset();
	// RPr: Did not figure out, how to set up a proper SM
	//		if (System.getSecurityManager() == null) {
	//			new lotus.notes.AgentSecurityManager();
	//			ownSM = true;
	//		}
	if (!Factory.isStarted()) {

		Factory.startup();
		DominoExecutor executor = new DominoExecutor(50);
		Xots.start(executor);
		factoryShutdown = true;
	}
}
 
Example 2
Source File: DominoJUnitRunner.java    From org.openntf.domino with Apache License 2.0 6 votes vote down vote up
@Override
protected void tearDown() {
	try {
		if (mastersession != null)
			mastersession.recycle();
	} catch (NotesException e) {
		e.printStackTrace();
	}
	if (factoryShutdown) {
		Xots.stop(120); // 10 minutes should be enough for tests
		Factory.shutdown();
	}
	//		if (ownSM) {
	//			AccessController.doPrivileged(new PrivilegedAction<Object>() {
	//
	//				@Override
	//				public Object run() {
	//					System.setSecurityManager(null);
	//					return null;
	//				}
	//			});
	//		}
	NotesThread.stermThread();
}
 
Example 3
Source File: DesignClassTest.java    From org.openntf.domino with Apache License 2.0 6 votes vote down vote up
@Test
public void testDXLImport() throws NotesException {
	lotus.domino.Session session = lotus.domino.NotesFactory.createSession(); //Factory.getSession(SessionType.CURRENT);
	lotus.domino.Database db = session.getDatabase("", "D:/Daten/notesdaten_9/empty2.nsf");
	lotus.domino.Stream stream = session.createStream();
	stream.open("d:/daten/form_dxl.txt", "UTF-8");
	lotus.domino.DxlImporter importer = session.createDxlImporter();
	importer.setDesignImportOption(6);
	importer.setCompileLotusScript(false);
	importer.setExitOnFirstFatalError(false);
	importer.setReplicaRequiredForReplaceOrUpdate(false);

	String dxl = stream.readText();
	stream.close();
	System.out.println("Importing....");
	try {
		importer.importDxl(dxl, db);
		System.out.println(importer.getFirstImportedNoteID());
	} catch (NotesException e) {
		e.printStackTrace();
		System.err.println(importer.getLog());
	}

}
 
Example 4
Source File: DbHandleTest.java    From org.openntf.domino with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
	Factory.enableCounters(true, false);
	try {
		Session sess = Factory.getSession(SessionType.CURRENT);
		lotus.domino.Session s = sess.getFactory().toLotus(sess);
		lotus.domino.Database d1 = s.getDatabase("", "");
		lotus.domino.Database d2 = s.getDatabase("", "");
		//System.out.println("d1.cppId: " + Base.getLotusId(d1));
		//System.out.println("d2.cppId: " + Base.getLotusId(d2));

		d1.openWithFailover("", "names.nsf");
		d2.openWithFailover("", "names.nsf");
		//System.out.println("d1.cppId: " + Base.getLotusId(d1));
		//System.out.println("d2.cppId: " + Base.getLotusId(d2));

		System.out.println("D1:" + d1.getFilePath());
		d1.recycle();
		System.out.println("D2:" + d2.getFilePath());
		d2.recycle();
	} catch (NotesException e) {
		e.printStackTrace();
	}
}
 
Example 5
Source File: Factory.java    From org.openntf.domino with Apache License 2.0 6 votes vote down vote up
public static void startup() {
	synchronized (Factory.class) {

		NotesThread.sinitThread();
		try {
			lotus.domino.Session sess = lotus.domino.NotesFactory.createSession();
			try {
				startup(sess);
			} finally {
				sess.recycle();
			}
		} catch (NotesException e) {
			e.printStackTrace();
		} finally {
			NotesThread.stermThread();
		}
	}
}
 
Example 6
Source File: Connect17Standard.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void run() {
	org.openntf.domino.Session sess = Factory.getSession(SessionType.NATIVE);
	try {
		TreeSet<String> names = new TreeSet<String>();
		Session session = TypeUtils.toLotus(sess);
		// Point to ExtLib demo, create a view called AllContactsByState
		// Copy AllContacts but adding a categorised column for State
		Database extLib = session.getDatabase(session.getServerName(), "odademo/oda_1.nsf");
		View states = extLib.getView("AllStates");
		states.setAutoUpdate(false);
		ViewEntry entState = states.getAllEntries().getFirstEntry();
		View byState = extLib.getView("AllContactsByState");
		byState.setAutoUpdate(false);
		Vector<String> key = new Vector<String>();
		Vector<String> stateVals = entState.getColumnValues();
		key.add(stateVals.get(0));
		ViewEntryCollection ec = byState.getAllEntriesByKey(key, true);
		ViewEntry ent = ec.getFirstEntry();
		while (null != ent) {
			Vector<Object> vals = ent.getColumnValues();
			names.add((String) vals.get(7));

			ViewEntry tmpEnt = ec.getNextEntry();
			ent.recycle(vals);
			ent.recycle();
			ent = tmpEnt;
		}
		System.out.println(names.toString());
	} catch (NotesException e) {
		e.printStackTrace();
	}
}
 
Example 7
Source File: LogReader.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
/**
 * Whether or not the effective user of the Session has access to read logs
 * 
 * @param session
 *            Session (remember you can use sessionAsSigner / sessionAsSignerWithFullAccess)
 * @return boolean whether user has access
 * @since org.openntf.domino.xsp 2.5.0
 */
private boolean canReadLogs(final lotus.domino.Session session) {
	boolean result = false;
	try {
		String username = session.getEffectiveUserName();
		DominoServer server = new DominoServer();
		result = server.checkServerAccess(username, ServerAccess.PROG_UNRESTRICTED);
		result = result || server.checkServerAccess(username, ServerAccess.VIEW_ONLY_ADMIN);
	} catch (NotesException ne) {
		ne.printStackTrace();
	}
	return result;
}
 
Example 8
Source File: NotesJUnitRunner.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
protected void startUp() {
	NotesThread.sinitThread();
	try {
		// keep alive one session over all test cases - this will improve execution speed
		mastersession = lotus.domino.NotesFactory.createSession();
		TestEnv.setup(mastersession);
	} catch (NotesException ne) {
		ne.printStackTrace();
	}

}
 
Example 9
Source File: NotesJUnitRunner.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
protected void tearDown() {
	try {
		if (mastersession != null)
			mastersession.recycle();
	} catch (NotesException e) {
		e.printStackTrace();
	}
	NotesThread.stermThread();
}
 
Example 10
Source File: NotesJUnitRunner.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
protected void beforeTest(final FrameworkMethod method) {
	try {
		String runAs = getRunAs(method);
		if (runAs == null) {
			TestEnv.session = lotus.domino.local.Session.createSession();
		} else {
			TestEnv.session = lotus.domino.local.Session.createSessionWithTokenEx(runAs);
		}
		assertNotNull(TestEnv.session);
		String db = getDatabase(method);
		if (db != null) {
			String server = "";
			String dbpath = db;
			int sep;
			if ((sep = db.indexOf("!!")) > -1) {
				server = db.substring(0, sep);
				dbpath = db.substring(sep + 2);
			}
			TestEnv.database = TestEnv.session.getDatabase(server, dbpath);
			assertNotNull(TestEnv.database);
		}

	} catch (NotesException ne) {
		ne.printStackTrace();
		fail(ne.toString());
	}
}
 
Example 11
Source File: DominoJUnitRunner.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
protected void beforeTest(final FrameworkMethod method) {
	try {
		String runAs = getRunAs(method);
		String db = getDatabase(method);
		Factory.initThread(Factory.STRICT_THREAD_CONFIG);
		if (runAs == null) {
			Factory.setSessionFactory(new NativeSessionFactory(db), SessionType.CURRENT);
			Factory.setSessionFactory(new SessionFullAccessFactory(db), SessionType.CURRENT_FULL_ACCESS);

		} else {
			Factory.setSessionFactory(new NamedSessionFactory(db, runAs), SessionType.CURRENT);
			Factory.setSessionFactory(new SessionFullAccessFactory(db, runAs), SessionType.CURRENT_FULL_ACCESS);
		}

		TestEnv.session = Factory.getSession(SessionType.CURRENT);
		TestEnv.database = TestEnv.session.getCurrentDatabase();
		if (db != null) {
			assertNotNull(TestEnv.database);
		}

		if (isRunLegacy(method)) {
			WrapperFactory wf = Factory.getWrapperFactory();
			TestEnv.session = wf.toLotus(TestEnv.session);
			TestEnv.database = wf.toLotus(TestEnv.database);
		}

	} catch (NotesException ne) {
		ne.printStackTrace();
		fail(ne.toString());
	}
}
 
Example 12
Source File: MIMEHeader.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
private void initialize(final lotus.domino.MIMEHeader header) {
	try {
		headerName_ = header.getHeaderName();
	} catch (NotesException ne) {
		ne.printStackTrace();
	}
}
 
Example 13
Source File: Session.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public String getEnvironmentString(final String vname, final boolean isSystem) {
	try {
		return getDelegate().getEnvironmentString(vname, isSystem);
	} catch (NotesException e) {
		e.printStackTrace();
		return null;
	}
}
 
Example 14
Source File: Session.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public Object getEnvironmentValue(final String vname, final boolean isSystem) {
	try {
		return getDelegate().getEnvironmentValue(vname, isSystem);
	} catch (NotesException e) {
		e.printStackTrace();
		return null;
	}
}
 
Example 15
Source File: View.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void initialize(final lotus.domino.View delegate) {
	try {
		aliases_ = delegate.getAliases();
		name_ = delegate.getName();
		universalId_ = delegate.getUniversalID();
	} catch (NotesException e) {
		e.printStackTrace();
	}
}
 
Example 16
Source File: MemberDataProvider.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
private MemberData getData(PersonImpl person) {
	String id = person.getId();
	MemberData data = (MemberData) getProperties(id, MemberData.class);
	if (data == null) {
		synchronized (getSyncObject()) {
			data = (MemberData) getProperties(id, MemberData.class);
			if (null == data) {
				data = new MemberData();
				try {
					View vw = getView();
					if (null != vw) {
						ViewEntry vwe = vw.getEntryByKey(person.getId());
						if (null != vwe) {
							Vector<?> cvs = vwe.getColumnValues();
							if (!cvs.isEmpty()) {
								// get the thumbnameUrl column value...
								String thumbnailUrl = (String) cvs.get(5);
								if (!thumbnailUrl.equals("")) {
									// get the doc unid...
									String docUnid = (String) cvs.get(4);
									data.thumbnailUrl = IMAGE_URL + docUnid + "/$file/" + thumbnailUrl;
								} else {
									data.thumbnailUrl = NO_IMAGE_URL;
								}

								// get the email column value...
								String internetEmail = (String) cvs.get(1);
								if (!internetEmail.equals("")) {
									data.internetEmail = internetEmail;
								} else {
									// default to the abbreviated name column value...
									data.internetEmail = (String) cvs.get(0);
								}
							}
						}else{
							data.thumbnailUrl = NO_IMAGE_URL;
						}
					}
				} catch (NotesException e) {
					e.printStackTrace();
				}
				addProperties(id, data);
			}
		}
	}
	return data;
}