Package org.openxri.store

Examples of org.openxri.store.StoreException


    String authorityId = ((FileAuthority)authority).getAuthorityId();
    File authorityDir = this.getAuthorityDir(authorityId);

    if (! authorityDir.exists()) {

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

    try {

      FileStore.deleteDir(authorityDir);
    } catch (Exception ex) {

      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot delete authority.");
    }
  }
View Full Code Here


    File namespaceFile = this.getNamespaceFile(namespace);
    String authorityId;

    if (! namespaceFile.exists()) {

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

    try {

      authorityId = FileStore.readLine(namespaceFile);
    } catch (Exception ex) {

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

    // delete authority

    File authorityDir = this.getAuthorityDir(authorityId);

    if (! authorityDir.exists()) {

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

    try {

      FileStore.deleteDir(authorityDir);
    } catch (Exception ex) {

      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot delete 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 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

      try {

        authorityId = FileStore.readLine(namespaceFile);
      } catch (Exception ex) {

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

      File authorityDir = this.getAuthorityDir(authorityId);

      if (! authorityDir.exists()) {

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

      FileAuthority authority = new FileAuthority(authorityDir);

      authorities.add(authority);
View Full Code Here

    String parentAuthorityId = parent.getAuthorityId();
    File parentAuthorityDir = this.getAuthorityDir(parentAuthorityId);

    if (! parentAuthorityDir.exists()) {

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

    // create alias subsegment

    File subSegmentDir = this.getSubSegmentDir(parentAuthorityDir, subSegmentName);

    if (subSegmentDir.exists()) {

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

    FileSubSegment subSegment = new FileSubSegment(subSegmentDir);

    try {

      subSegment.internalSetName(subSegmentName);
      subSegment.internalSetAuthorityId(authority.getAuthorityId());
      subSegment.internalSetParentAuthorityId(parent.getAuthorityId());
    } catch (IOException ex) {

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

    // done

    return(subSegment);
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

    String parentAuthorityId = parent.getAuthorityId();
    File parentAuthorityDir = this.getAuthorityDir(parentAuthorityId);

    if (! parentAuthorityDir.exists()) {

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

    // create new authority

    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(localAuthService);
      authority.internalSetRefs(refs);
      authority.internalSetServices(services);
    } catch (IOException ex) {

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

    // create subsegment

    File subSegmentDir = this.getSubSegmentDir(parentAuthorityDir, subSegmentName);

    if (subSegmentDir.exists()) {

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

    FileSubSegment subSegment = new FileSubSegment(subSegmentDir);

    try {

      subSegment.internalSetName(subSegmentName);
      subSegment.internalSetAuthorityId(authority.getAuthorityId());
      subSegment.internalSetParentAuthorityId(parent.getAuthorityId());
    } catch (IOException ex) {

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

    // done

    return(subSegment);
View Full Code Here

    String authorityId = ((FileSubSegment)subSegment).getAuthorityId();
    File authorityDir = this.getAuthorityDir(authorityId);

    if (! authorityDir.exists()) {

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

    // get subsegment dir

    String subSegmentName = subSegment.getName();
    File subSegmentDir = this.getSubSegmentDir(authorityDir, subSegmentName);

    if (! subSegmentDir.exists()) {

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

    // delete it

    try {

      FileStore.deleteDir(subSegmentDir);
    } catch (Exception ex) {

      throw new StoreException(ex, StoreException.KEY_DBERR, "Cannot delete subsegment.");
    }
  }
View Full Code Here

    File authorityDir = this.getAuthorityDir(authorityId);

    if (! authorityDir.exists()) {

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

    FileAuthority authority = new FileAuthority(authorityDir);

    // 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.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

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.