Examples of ODatabaseRecordTx


Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

  }

  public  Tokens getTokens() throws UnsupportedSocialNetworkException{
    //since this method can be called by the /callback endpoint that does not open a DB connection, we need to manage it here
    if (BBConfiguration.getSocialMock())  return new Tokens("fake_token","fake_secret");
    ODatabaseRecordTx db=null;
    try {
      db = DbHelper.getOrOpenConnection(BBConfiguration.getAPPCODE(), BBConfiguration.getBaasBoxUsername(), BBConfiguration.getBaasBoxPassword());   
      String keyFormat = socialNetwork.toUpperCase()+"_TOKEN";
      String token = (String)Cache.get(keyFormat);
      if(token ==null){
        token = SocialLoginConfiguration.valueOf(keyFormat).getValueAsString();
        Cache.set(keyFormat,token,0);
      }
      keyFormat =  socialNetwork.toUpperCase()+"_SECRET";
      String secret =  (String)Cache.get(keyFormat);;
      if(secret ==null){
        secret = SocialLoginConfiguration.valueOf(keyFormat).getValueAsString();
        Cache.set(keyFormat,secret,0);
      }
      if(secret==null || token == null){
        throw new UnsupportedSocialNetworkException("Social login for "+socialNetwork+" is not enabled.Please add app token and secret to configuration");
      }
      return new Tokens(token,secret);
    } catch (InvalidAppCodeException e) {
      //a very strange thing happened here!
      throw new RuntimeException(e);
    }finally{
      if (db!=null && !db.isClosed()) db.close();
    }
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    if (role==null){
      Logger.warn("role is null! Grant command skipped");
      return document;
    }
    ODatabaseRecordTx db = DbHelper.getConnection();
    db.getMetadata().getSecurity().allowIdentity(document, permission.toString(), role.getDocument().getIdentity());
/*
    Set<ORID> set = document.field(  permission.toString(), OType.LINKSET );
    if (set==null) set = new HashSet<ORID>();
    set.add( role.getDocument().getIdentity() );
    document.field( permission.toString(), set, OType.LINKSET );
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

  }
 
  public static ODocument grant(ODocument document, Permissions permission,
      OUser user) {
    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    ODatabaseRecordTx db = DbHelper.getConnection();
    db.getMetadata().getSecurity().allowIdentity(document, permission.toString(), user.getDocument().getIdentity());
/*
    Set<ORID> set = document.field(  permission.toString(), OType.LINKSET );
    if (set==null) set = new HashSet<ORID>();
    set.add( user.getDocument().getIdentity() );
    document.field( permission.toString(), set, OType.LINKSET );
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

  }
 
  public static ODocument revoke(ODocument document, Permissions permission,
      ORole role) {
    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    ODatabaseRecordTx db = DbHelper.getConnection();
    db.getMetadata().getSecurity().disallowIdentity(document, permission.toString(), role.getDocument().getIdentity());
    /*
    Set<ORID> set = document.field(  permission.toString(), OType.LINKSET );
    if (set==null) return document;
    set.remove( role.getDocument().getIdentity() );
    document.field( permission.toString(), set, OType.LINKSET );
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

  }
 
  public static ODocument revoke(ODocument document, Permissions permission,
      OUser user) {
    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    ODatabaseRecordTx db = DbHelper.getConnection();
    db.getMetadata().getSecurity().disallowIdentity(document, permission.toString(), user.getDocument().getIdentity());
/*
    Set<ORID> set = document.field(  permission.toString(), OType.LINKSET );
    if (set==null) return document;
    set.remove( user.getDocument().getIdentity() );
    document.field( permission.toString(), set, OType.LINKSET );
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

  public static String currentUsername(){
    return username.get();
  }
 
  public static boolean isInTransaction(){
     ODatabaseRecordTx db = getConnection();
     return db.getTransaction().isActive();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

     return db.getTransaction().isActive();
  }

  public static void requestTransaction(){
    if (Logger.isDebugEnabled()) Logger.debug("Request Transaction: transaction count -before-: " + tranCount.get());
    ODatabaseRecordTx db = getConnection();
    if (!isInTransaction()){
      if (Logger.isTraceEnabled()) Logger.trace("Begin transaction");
      db.begin();
    }
    tranCount.set(tranCount.get().intValue()+1);
    if (Logger.isDebugEnabled()) Logger.debug("Request Transaction: transaction count -after-: " + tranCount.get());
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

    if (Logger.isDebugEnabled()) Logger.debug("Request Transaction: transaction count -after-: " + tranCount.get());
  }

  public static void commitTransaction(){
    if (Logger.isDebugEnabled()) Logger.debug("Commit Transaction: transaction count -before-: " + tranCount.get());
    ODatabaseRecordTx db = getConnection();
    if (isInTransaction()){

      if (Logger.isDebugEnabled()) Logger.debug("Commit transaction");
      tranCount.set(tranCount.get().intValue()-1);
      if (tranCount.get()<0) throw new RuntimeException("Commit without transaction!");
      if (tranCount.get()==0) {
        db.commit();
        db.getTransaction().close();
     
    }else throw new NoTransactionException("There is no open transaction to commit");
    if (Logger.isDebugEnabled()) Logger.debug("Commit Transaction: transaction count -after-: " + tranCount.get());

  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

  }

  public static void rollbackTransaction(){
    if (Logger.isDebugEnabled()) Logger.debug("Rollback Transaction: transaction count -before-: " + tranCount.get());
    ODatabaseRecordTx db = getConnection();
    if (isInTransaction()){
      if (Logger.isDebugEnabled()) Logger.debug("Rollback transaction");
      db.getTransaction().rollback();
      db.getTransaction().close();
      tranCount.set(0);
    }
    if (Logger.isDebugEnabled()) Logger.debug("Rollback Transaction: transaction count -after-: " + tranCount.get());
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecordTx

   * @param criteria the criteria to apply in the 'where' clause of the select
   * @return an OCommandRequest object ready to be passed to the {@link #selectCommandExecute(com.orientechnologies.orient.core.command.OCommandRequest, Object[])} (OCommandRequest, String[])} method
   * @throws SqlInjectionException If the query is not a select statement
   */
  public static OCommandRequest selectCommandBuilder(String from, boolean count, QueryParams criteria) throws SqlInjectionException{
    ODatabaseRecordTx db =  DbHelper.getConnection();
    OCommandRequest command = db.command(new OSQLSynchQuery<ODocument>(
        selectQueryBuilder(from, count, criteria)
        ));
    if (!command.isIdempotent()) throw new SqlInjectionException();
    if (Logger.isDebugEnabled()) Logger.debug("commandBuilder: ");
    if (Logger.isDebugEnabled()) Logger.debug("  " + criteria.toString());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.