Package org.openxri.store

Examples of org.openxri.store.StoreException


      this.initSessionFactory();
    } catch (Exception ex) {

      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot initialize Hibernate");
    }

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


    this.initSessionFactory();

    if (this.sessionFactory != null && ! this.sessionFactory.isClosed()) return(this.sessionFactory);

    throw new StoreException(StoreException.KEY_DBERR, "Database not available.");
  }
View Full Code Here

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

      session.getTransaction().rollback();
      log.error(ex);
      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot list root authorities.");
    }

    // build result list

    Authority[] result = new ArrayList<Authority> (authorities).toArray(new Authority[authorities.size()]);
View Full Code Here

    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

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.