Java Code Examples for com.orientechnologies.orient.core.db.ODatabaseDocumentInternal#begin()
The following examples show how to use
com.orientechnologies.orient.core.db.ODatabaseDocumentInternal#begin() .
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: OrientDbWebSession.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override public boolean authenticate(String username, String password) { ODatabaseDocumentInternal currentDB = getDatabase(); try { boolean inTransaction = currentDB.getTransaction().isActive(); IOrientDbSettings settings = OrientDbWebApplication.get().getOrientDbSettings(); ODatabaseDocumentInternal newDB = settings.getDatabasePoolFactory().get(settings.getDBUrl(), username, password).acquire(); if(newDB!=currentDB) { currentDB.activateOnCurrentThread(); currentDB.commit(); currentDB.close(); newDB.activateOnCurrentThread(); } setUser(username, password); userModel.setObject(newDB.getUser().getDocument()); // user = newDB.getMetadata().getSecurity().getUser(username); // newDB.setUser(user); if(inTransaction && !newDB.getTransaction().isActive()) newDB.begin(); return true; } catch (OSecurityAccessException e) { currentDB.activateOnCurrentThread(); return false; } }
Example 2
Source File: TransactionRequestCycleListener.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override public void start(RequestCycle cycle) { OrientDbWebSession session = OrientDbWebSession.get(); ODatabaseDocumentInternal db = session.getDatabase(); //It's required to have ability to check security rights locally OSecurityUser oUser = session.getUser(); OSecurityUser dbUser = db.getUser(); if(oUser!=null && oUser.getDocument()!=null && oUser.getDocument().getIdentity()!=null && (!oUser.getDocument().getIdentity().isValid() || dbUser==null || !Objects.equal(dbUser.getName(), oUser.getName()))) { db.setUser(db.getMetadata().getSecurity().getUser(oUser.getName())); } db.begin(); }