public ODatabase<ORecord> begin() { return database.begin(); }
@Override public ODatabase<ORecord> begin(OTransaction iTx) throws OTransactionException { checkOpenness(); internal.begin(iTx); return this; }
@Override public ODatabase<ORecord> begin(OTransaction.TXTYPE iStatus) { checkOpenness(); internal.begin(iStatus); return this; }
@Override public ODatabase<ORecord> begin() { checkOpenness(); internal.begin(); return this; }
@Override protected void onValidateModelObjects() { super.onValidateModelObjects(); if(isTransactionActive) OrientDbWebSession.get().getDatabase().begin(); }
@Override protected void onValidateModelObjects() { super.onValidateModelObjects(); if(isTransactionActive) OrientDbWebSession.get().getDatabase().begin(); }
/** * Delete the current vertex. */ public boolean result(final Object iRecord) { final OIdentifiable id = (OIdentifiable) iRecord; if (id.getIdentity().isValid()) { final ODocument record = id.getRecord(); ODatabaseDocumentInternal db = getDatabase(); final OVertex v = toVertex(record); if (v != null) { v.delete(); if (!txAlreadyBegun && batch > 0 && removed % batch == 0) { db.commit(); db.begin(); } if (returning.equalsIgnoreCase("BEFORE")) allDeletedRecords.add(record); removed++; } } return true; }
private void ensureTransaction() { final boolean txBegun = getDatabase().getTransaction().isActive(); if (!txBegun) { getDatabase().begin(); getDatabase().getTransaction().setUsingLog(settings.isUseLog()); } }
@Override public void begin() { makeActive(); // XXX: Under some circumstances, auto started transactions are committed outside of the graph using the // underlying database and later restarted using the graph. So we have to check the status of the // database transaction to support this behaviour. if (isAutoStartTx() && getDatabase().getTransaction().isActive()) throw new OTransactionException("A mixture of auto started and manually started transactions is not allowed. " + "Disable auto transactions for the graph before starting a manual transaction."); getDatabase().begin(); getDatabase().getTransaction().setUsingLog(settings.isUseLog()); }
@Override protected void autoStartTransaction() { final boolean txBegun = getDatabase().getTransaction().isActive(); if (!isAutoStartTx()) { if (isRequireTransaction() && !txBegun) throw new OTransactionException("Transaction required to change the Graph"); return; } if (!txBegun) { getDatabase().begin(); getDatabase().getTransaction().setUsingLog(settings.isUseLog()); } }
/** * Delete the current edge. */ public boolean result(final Object iRecord) { final OIdentifiable id = (OIdentifiable) iRecord; if (compiledFilter != null) { // ADDITIONAL FILTERING if (!(Boolean) compiledFilter.evaluate(id.getRecord(), null, context)) return true; } if (id.getIdentity().isValid()) { final OEdge e = toEdge(id); if (e != null) { e.delete(); if (!txAlreadyBegun && batch > 0 && (removed + 1) % batch == 0) { getDatabase().commit(); getDatabase().begin(); } removed++; } } return true; }
@ConsoleCommand(description = "Begins a transaction. All the changes will remain local") public void begin() throws IOException { checkForDatabase(); if (currentDatabase.getTransaction().isActive()) { message("\nError: an active transaction is currently open (id=" + currentDatabase.getTransaction().getId() + "). Commit or rollback before starting a new one."); return; } if (currentDatabase.getStorage().isRemote()) { message( "\nWARNING - Transactions are not supported from console in remote, please use an sql script: \neg.\n\nscript sql\nbegin;\n<your commands here>\ncommit;\nend\n\n"); return; } currentDatabase.begin(); message("\nTransaction " + currentDatabase.getTransaction().getId() + " is running"); }
@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(); }
@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(); }
@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; } }
@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; } }