Package org.openxri.store

Examples of org.openxri.store.StoreException


    try {

      if (DbAuthority.ByNamespace(session, namespace) != null) {

        throw new StoreException(StoreException.KEY_DUPNAME, "Root authority exists already.");
      }

      authority = new DbAuthority();
      authority.setAuthorityId(authorityId);
      authority.setNamespace(namespace);
      authority.setLocalAuthService(Boolean.TRUE);

      session.save(authority);
      session.flush();
      session.getTransaction().commit();
    } catch (StoreException ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw(ex);
    } catch (Exception ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
    }

    // done

    log.trace("Done.");
View Full Code Here


      authority = DbAuthority.ByNamespace(session, namespace);

      if (authority == null) {

        throw new StoreException(StoreException.KEY_NOTFOUND, "Root authority does not exist.");
      }

      session.delete(authority);
      session.getTransaction().commit();
    } catch (StoreException ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw(ex);
    } catch (Exception ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
    }

    log.trace("Done.");
  }
View Full Code Here

      session.getTransaction().commit();
    } catch (Exception ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
    }

    // done

    log.trace("Done.");
View Full Code Here

    Session session = this.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    // check authority

    if (! (authority instanceof DbAuthority)) throw new StoreException(StoreException.KEY_NOTFOUND, "Authority is not from this store.");

    // delete authority

    try {

      session.delete(authority);
      session.getTransaction().commit();
    } catch (Exception ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
    }

    log.trace("Done.");
  }
View Full Code Here

    Session session = this.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    // check parent authority

    if (! (parentAuthority instanceof DbAuthority)) throw new StoreException(StoreException.KEY_NOTFOUND, "Parent authority is not from this store.");

    // create authority

    DbAuthority authority;
    String authorityId = this.getUUID();

    try {

      authority = DbAuthority.ByAuthorityId(session, authorityId);

      if (authority != null) {

        throw new StoreException(StoreException.KEY_DUPNAME, "Authority exists already.");
      }

      authority = new DbAuthority();
      authority.setAuthorityId(authorityId);
      authority.setLocalAuthService(localAuthService);
      for (Service service : services) authority.getServices().add(service);
      for (Ref ref : refs) authority.getRefs().add(ref);

      session.save(authority);
    } catch (StoreException ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw ex;
    } catch (Exception ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
    }

    // create subsegment with this authority

    DbSubSegment subSegment;

    try {

      subSegment = DbSubSegment.ByParentAndName(session, (DbAuthority) parentAuthority, subSegmentName);

      if (subSegment != null) {

        throw new StoreException(StoreException.KEY_DUPNAME, "Subsegment exists already.");
      }

      subSegment = new DbSubSegment();
      subSegment.setParent((DbAuthorityparentAuthority);
      subSegment.setName(subSegmentName);
      subSegment.setAuthority(authority);

      reattach(session, parentAuthority);

      ((DbAuthority) parentAuthority).getChildren().add(subSegment);
      authority.getSubSegments().add(subSegment);

      session.save(subSegment);
      session.flush();
      session.getTransaction().commit();
    } catch (StoreException ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw ex;
    } catch (Exception ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
    }

    // done

    log.trace("Done.");
View Full Code Here

    Session session = this.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    // check authority and parent authority

    if (! (parentAuthority instanceof DbAuthority)) throw new StoreException(StoreException.KEY_NOTFOUND, "Parent authority is not from this store.");
    if (! (authority instanceof DbAuthority)) throw new StoreException(StoreException.KEY_NOTFOUND, "Authority is not from this store.");

    // create subsegment with this authority

    DbSubSegment subSegment;

    try {

      subSegment = DbSubSegment.ByParentAndName(session, (DbAuthority) parentAuthority, subSegmentName);

      if (subSegment != null) {

        throw new StoreException(StoreException.KEY_DUPNAME, "Subsegment exists already.");
      }

      if (authority.equals(parentAuthority)) authority = parentAuthority;

      subSegment = new DbSubSegment();
      subSegment.setParent((DbAuthority) parentAuthority);
      subSegment.setName(subSegmentName);
      subSegment.setAuthority((DbAuthority) authority);

      reattach(session, parentAuthority);
      reattach(session, authority);

      ((DbAuthority) parentAuthority).getChildren().add(subSegment);
      ((DbAuthority) authority).getSubSegments().add(subSegment);

      session.save(subSegment);
      session.flush();
      session.getTransaction().commit();
    } catch (StoreException ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw ex;
    } catch (Exception ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
    }

    // done

    log.trace("Done.");
View Full Code Here

    Session session = this.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    // check subsegment

    if (! (subSegment instanceof DbSubSegment)) throw new StoreException(StoreException.KEY_NOTFOUND, "Subsegment is not from this store.");

    // delete subsegment

    try {

      session.delete(subSegment);
      session.getTransaction().commit();
    } catch (Exception ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
    }

    log.trace("Done.");
  }
View Full Code Here

    String authorityId = this.getUUID();
    File authorityDir = this.getAuthorityDir(authorityId);

    if (authorityDir.exists()) {

      throw new StoreException(StoreException.KEY_DUPNAME, "Authority exists already.");
    }

    FileAuthority authority = new FileAuthority(authorityDir);

    try {

      authority.internalSetAuthorityId(authorityId);
      authority.internalSetNamespace(null);
      authority.internalSetLocalAuthService(Boolean.TRUE);
    } catch (IOException ex) {

      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot create rootauthority.");
    }

    // done

    return(authority);
View Full Code Here

    Session session = this.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    // check authority

    if (! (authority instanceof DbAuthority)) throw new StoreException(StoreException.KEY_NOTFOUND, "Authority is not from this store.");

    // read refs

    Collection<Ref> refs;

    try {

      reattach(session, authority);
      refs = ((DbAuthority) authority).getRefs();
      Hibernate.initialize(refs);
      session.getTransaction().commit();
    } catch (Exception ex) {

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot access database.");
    }

    // done

    log.trace("Done.");
View Full Code Here

    String authorityId = this.getUUID();
    File authorityDir = this.getAuthorityDir(authorityId);

    if (authorityDir.exists()) {

      throw new StoreException(StoreException.KEY_DUPNAME, "Root authority exists already.");
    }

    FileAuthority authority = new FileAuthority(authorityDir);

    try {

      authority.internalSetAuthorityId(authorityId);
      authority.internalSetNamespace(namespace);
      authority.internalSetLocalAuthService(Boolean.TRUE);
    } catch (IOException ex) {

      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot create root authority.");
    }

    // create namespace

    File namespaceFile = this.getNamespaceFile(namespace);

    if (namespaceFile.exists()) {

      throw new StoreException(StoreException.KEY_DUPNAME, "Namespace exists already.");
    }

    try {

      FileStore.writeLine(namespaceFile, authorityId);
    } catch (IOException ex) {

      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot create namespace.");
    }

    // done

    return(authority);
View Full Code Here

TOP

Related Classes of org.openxri.store.StoreException

Copyright © 2018 www.massapicom. 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.