Examples of ODatabaseRecordTx


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

import com.orientechnologies.orient.core.record.impl.ODocument;

@SuppressWarnings("unchecked")
public class ODatabaseDocumentTx extends ODatabaseRecordWrapperAbstract<ODatabaseRecordTx> implements ODatabaseDocument {
  public ODatabaseDocumentTx(final String iURL) {
    super(new ODatabaseRecordTx(iURL, ODocument.RECORD_TYPE));
  }
View Full Code Here

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

import com.orientechnologies.orient.core.record.impl.ODocument;

@SuppressWarnings("unchecked")
public class ODatabaseDocumentTx extends ODatabaseRecordWrapperAbstract<ODatabaseRecordTx> implements ODatabaseDocument {
  public ODatabaseDocumentTx(final String iURL) {
    super(new ODatabaseRecordTx(iURL, ODocument.class));
  }
View Full Code Here

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

import com.orientechnologies.orient.core.record.impl.ODocument;

@SuppressWarnings("unchecked")
public class ODatabaseDocumentTx extends ODatabaseRecordWrapperAbstract<ODatabaseRecordTx> implements ODatabaseDocument {
  public ODatabaseDocumentTx(final String iURL) {
    super(new ODatabaseRecordTx(iURL, ODocument.class));
  }
View Full Code Here

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

        if (Logger.isDebugEnabled()) Logger.debug("ConnectToDB for resource " + Http.Context.current().request());
    String username=(String) Http.Context.current().args.get("username");
    String password=(String)Http.Context.current().args.get("password");
    String appcode=(String)Http.Context.current().args.get("appcode");
    ODatabaseRecordTx database = null;
    F.Promise<SimpleResult> result=null;
    try{
      //close an eventually  'ghost'  connection left open in this thread
      //(this may happen in case of Promise usage)
      DbHelper.close(DbHelper.getConnection());
View Full Code Here

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

            JsonNode appUsersAttributes,boolean generated) throws InvalidJsonException,UserAlreadyExistsException{
     
      if (StringUtils.isEmpty(username)) throw new IllegalArgumentException("username cannot be null or empty");
      if (StringUtils.isEmpty(password)) throw new IllegalArgumentException("password cannot be null or empty");
     
      ODatabaseRecordTx db =  DbHelper.getConnection();
      ODocument profile=null;
      UserDao dao = UserDao.getInstance();
      try{
          //because we have to create an OUser record and a User Object, we need a transaction
     
View Full Code Here

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

      throw e;
    }
  }//updateProfile with role

  public static void changePasswordCurrentUser(String newPassword) throws OpenTransactionException {
    ODatabaseRecordTx db = DbHelper.getConnection();
    String username=db.getUser().getName();
    db = DbHelper.reconnectAsAdmin();
    db.getMetadata().getSecurity().getUser(username).setPassword(newPassword).save();
    //DbHelper.removeConnectionFromPool();
  }
View Full Code Here

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

    db.getMetadata().getSecurity().getUser(username).setPassword(newPassword).save();
    //DbHelper.removeConnectionFromPool();
  }
 
  public static void changePassword(String username, String newPassword) throws SqlInjectionException, UserNotFoundException, OpenTransactionException {
    ODatabaseRecordTx db=DbHelper.getConnection();
    db = DbHelper.reconnectAsAdmin();
    UserDao udao=UserDao.getInstance();
    ODocument user = udao.getByUserName(username);
    if(user==null){
      if (Logger.isDebugEnabled()) Logger.debug("User " + username + " does not exist");
      throw new UserNotFoundException("User " + username + " does not exist");
    }
    db.getMetadata().getSecurity().getUser(username).setPassword(newPassword).save();
  }
View Full Code Here

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

          assertTrue(status==200);
          File folder =  Play.application().getFile("certificates");
          assertTrue(folder.exists());
          File certificate = Play.application().getFile("certificates/TestFakeCertificate.p12");
          assertTrue(certificate.exists());
          ODatabaseRecordTx db = null;
          try {
            db = DbHelper.open("1234567890", "admin", "admin");
          } catch (InvalidAppCodeException e) {
            fail();
          }
          ODatabaseRecordThreadLocal.INSTANCE.set(db);
          ConfigurationFileContainer cfc = Push.PROFILE1_SANDBOX_IOS_CERTIFICATE.getValueAsFileContainer();
          assertNotNull(cfc);
          assertNotNull(cfc.getName());
          assertNotNull(cfc.getContent());
          assertEquals("TestFakeCertificate.p12",cfc.getName());
          String content = new String(cfc.getContent());
          assertTrue(content.indexOf("I am a fake certificate")>-1);
          certificate.delete();
          folder.delete();
          db.close();
        }
          }
    );
  }
View Full Code Here

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

    @Override
    public void onStart(Application app) {
     debug("Global.onStart() called");
      //Orient.instance().shutdown();

      ODatabaseRecordTx db =null;
      try{
        if (justCreated){
          try {
            //we MUST use admin/admin because the db was just created
            db = DbHelper.open( BBConfiguration.getAPPCODE(),"admin", "admin");
            DbHelper.setupDb();
            info("Initializing session manager");
            ISessionTokenProvider stp = SessionTokenProvider.getSessionTokenProvider();
            stp.setTimeout(com.baasbox.configuration.Application.SESSION_TOKENS_TIMEOUT.getValueAsInteger()*1000);
          }catch (Throwable e){
          error("!! Error initializing BaasBox!", e);
          error(ExceptionUtils.getFullStackTrace(e));
          throw e;
          } finally {
            if (db!=null && !db.isClosed()) db.close();
          }
          justCreated=false;
        }
      }catch (Throwable e){
        error("!! Error initializing BaasBox!", e);
        error("Abnormal BaasBox termination.");
        System.exit(-1);
      }
      info("Updating default users passwords...");
      try {
        db = DbHelper.open( BBConfiguration.getAPPCODE(), BBConfiguration.getBaasBoxAdminUsername(), BBConfiguration.getBaasBoxAdminPassword());
        DbHelper.evolveDB(db);
      DbHelper.updateDefaultUsers();
     
      String bbid=Internal.INSTALLATION_ID.getValueAsString();
      if (bbid==null) throw new Exception ("Unique id not found! Hint: could the DB be corrupted?");
      info ("BaasBox unique id is " + bbid);
    } catch (Exception e) {
        error("!! Error initializing BaasBox!", e);
        error("Abnormal BaasBox termination.");
        System.exit(-1);
    } finally {
        if (db!=null && !db.isClosed()) db.close();
      }
     
      try{
        db = DbHelper.open( BBConfiguration.getAPPCODE(), BBConfiguration.getBaasBoxAdminUsername(), BBConfiguration.getBaasBoxAdminPassword());
        IosCertificateHandler.init();
      }catch (Exception e) {
        error("!! Error initializing BaasBox!", e);
        error("Abnormal BaasBox termination.");
        System.exit(-1);
    } finally {
        if (db!=null && !db.isClosed()) db.close();
      }
      info ("...done");
     
      overrideSettings();
     
View Full Code Here

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

         loginData=body.get("login_data")[0];
       if (Logger.isDebugEnabled()) Logger.debug("LoginData" + loginData);

      /* other useful parameter to receive and to store...*/         
      //validate user credentials
      ODatabaseRecordTx db=null;
      String user = null;
      try{
       db = DbHelper.open(appcode,username, password);
       user =  prepareResponseToJson(UserService.getCurrentUser());
       
      
       if (loginData!=null){
         JsonNode loginInfo=null;
         try{
           loginInfo = Json.parse(loginData);
         }catch(Exception e){
           if (Logger.isDebugEnabled()) Logger.debug ("Error parsong login_data field");
           if (Logger.isDebugEnabled()) Logger.debug (ExceptionUtils.getFullStackTrace(e));
           return badRequest("login_data field is not a valid json string");
         }
         Iterator<Entry<String, JsonNode>> it =loginInfo.fields();
         HashMap<String, Object> data = new HashMap<String, Object>();
         while (it.hasNext()){
           Entry<String, JsonNode> element = it.next();
           String key=element.getKey();
           Object value=element.getValue().asText();
           data.put(key,value);
         }
         UserService.registerDevice(data);
       }
      }catch (OSecurityAccessException e){
        if (Logger.isDebugEnabled()) Logger.debug("UserLogin: " +  e.getMessage());
        return unauthorized("user " + username + " unauthorized");
      } catch (InvalidAppCodeException e) {
        if (Logger.isDebugEnabled()) Logger.debug("UserLogin: " + e.getMessage());
        return badRequest("user " + username + " unauthorized");
      }finally{
        if (db!=null && !db.isClosed()) db.close();
      }
      ImmutableMap<SessionKeys, ? extends Object> sessionObject = SessionTokenProvider.getSessionTokenProvider().setSession(appcode, username, password);
      response().setHeader(SessionKeys.TOKEN.toString(), (String) sessionObject.get(SessionKeys.TOKEN));
     
      ObjectMapper mapper = new ObjectMapper();
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.