Package org.openxri.store

Examples of org.openxri.store.StoreException


    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


    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 services

    Collection<Service> services;

    try {

      reattach(session, authority);
      services = ((DbAuthority) authority).getServices();
      Hibernate.initialize(services);
      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.");
    return(services.toArray(new Service[services.size()]));
  }
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.");

    // find subsegments with the same parent authority and authority as us

    List<DbSubSegment> localSubSegments;

    try {

      DbAuthority parentAuthority = ((DbSubSegment) subSegment).getParent();
      DbAuthority authority = ((DbSubSegment) subSegment).getAuthority();

      localSubSegments = DbSubSegment.AllByParentAndAuthority(session, parentAuthority, authority);
    } catch (Exception ex) {

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

    // build result list

    List<LocalID> result = new ArrayList<LocalID> (localSubSegments.size() - 1);
View Full Code Here

      authority = DbAuthority.ByNamespace(session, namespace);

      if (authority == null) {

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

      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.ByAuthorityId(session, authorityId);

      if (authority == null) {

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

      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 parent authority

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

    // find subsegment

    DbSubSegment subSegment;

    try {

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

      if (subSegment == null) {

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

      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.");

    // get parent authority

    DbAuthority parentAuthority;

    try {

      reattach(session, subSegment);
      parentAuthority = ((DbSubSegment)subSegment).getParent();
      Hibernate.initialize(parentAuthority);

      if (parentAuthority == null) {

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

      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.");

    // get authority

    DbAuthority authority;

    try {

      reattach(session, subSegment);
      authority = ((DbSubSegment)subSegment).getAuthority();
      Hibernate.initialize(authority);

      if (authority == null) {

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

      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.getTransaction().commit();
    } catch (Exception ex) {

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

    // build result list

    Authority[] result = new ArrayList<Authority> (authorities).toArray(new Authority[authorities.size()]);
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.");
    }

    // build result list

    SubSegment[] result = new ArrayList<SubSegment> (subSegments).toArray(new SubSegment[subSegments.size()]);
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.