Examples of StageException


Examples of org.openxri.exceptions.StageException

  }

  public void init() throws Exception {

    String elementName = this.properties.getProperty(PROPERTIES_KEY_ELEMENTNAME);
    if (elementName == null) throw new StageException("Required property " + PROPERTIES_KEY_ELEMENTNAME + " not found.");
    this.elementName = elementName;

    String elementValue = this.properties.getProperty(PROPERTIES_KEY_ELEMENTVALUE, DEFAULT_ELEMENTVALUE);
    this.elementValue = elementValue;
View Full Code Here

Examples of org.openxri.exceptions.StageException

    this.attributeValues = attributeValues.toArray(new String[attributeValues.size()]);
  }

  public XRD execute(Store store, XRD xrd, XRISegment segment, Authority parentAuthority, String subSegmentName, Authority authority, boolean isCreate) throws StageException {

    if (! (store instanceof StoreAttributable)) throw new StageException("Cannot use this store implementation.");
    StoreAttributable storeAttributable = (StoreAttributable) store;

    Element xrdElement = xrd.getDOM();
    Document document = xrdElement.getOwnerDocument();

    // create new element

    Element element = document.createElement(this.elementName);

    if (this.elementValue != null) {

      Text text = document.createTextNode(this.elementValue);
      element.appendChild(text);
    }

    for (int i=0; i<this.attributeNames.length; i++) {

      Attr attr = document.createAttribute(this.attributeNames[i]);
      attr.setNodeValue(this.attributeValues[i]);
    }

    // insert element into XRD

    try {
     
      xrdElement.appendChild(element);
      xrd = new XRD(xrdElement, false);
    } catch (Exception ex) {
     
      throw new StageException("Unable to parse modified XRD.", ex);
    }

    // done

    return(xrd);
View Full Code Here

Examples of org.openxri.exceptions.StageException

  }

  public XRD execute(Store store, XRD xrd, XRISegment segment, Authority parentAuthority, String subSegmentName, Authority authority, boolean isCreate) throws StageException {

    if (! (store instanceof StoreAttributable)) throw new StageException("Cannot use this store implementation.");
    StoreAttributable storeAttributable = (StoreAttributable) store;

    // can only create a ProviderID if the parent authority has a CanonicalID

    if (parentAuthority == null) return(xrd);
View Full Code Here

Examples of org.openxri.exceptions.StageException

      try {

        store.registerSubsegment(parentAuthority, localCanonicalIDString, authority);
      } catch (StoreException ex) {

        throw new StageException("Cannot register subsegment for CanonicalID.");
      }
    }

    // done
View Full Code Here

Examples of org.openxri.exceptions.StageException

  }

  public void init() throws Exception {

    String value = this.properties.getProperty(PROPERTIES_KEY_ATTRIBUTES);
    if (value == null) throw new StageException("Required property " + PROPERTIES_KEY_ATTRIBUTES + " not found.");

    this.attributes = value.split("[ ,;:]");
  }
View Full Code Here

Examples of org.openxri.exceptions.StageException

    this.attributes = value.split("[ ,;:]");
  }

  public XRD execute(Store store, XRD xrd, XRISegment segment, Authority parentAuthority, String subSegmentName, Authority authority, boolean isCreate) throws StageException {

    if (! (store instanceof StoreAttributable)) throw new StageException("Cannot use this store implementation.");
    StoreAttributable storeAttributable = (StoreAttributable) store;

    // copy all attributes from the parent authority to the child authority

    for (String attribute : this.attributes) {

      try {

        Map<String, String> attributes = storeAttributable.getAuthorityAttributes(parentAuthority);
        storeAttributable.setAuthorityAttributes(authority, attributes);
      } catch (StoreException ex) {

        throw new StageException("Cannot set attribute for authority.");
      }
    }

    // done
View Full Code Here

Examples of org.openxri.exceptions.StageException

    this.excludeSelf = Boolean.parseBoolean(excludeSelf);
  }

  public XRD execute(Store store, XRD xrd, XRISegment segment, Authority parentAuthority, String subSegmentName, Authority authority, boolean isCreate) throws StageException {

    if (! (store instanceof StoreBetterLookup)) throw new StageException("Cannot use this store implementation.");
    StoreBetterLookup storeBetterLookup = (StoreBetterLookup) store;

    if (parentAuthority == null) return(xrd);

    // get all subsegments with the given parent authority and authority

    SubSegment[] localSubSegments;

    try {

      localSubSegments = storeBetterLookup.getSynonymSubSegments(parentAuthority, authority);
    } catch (StoreException ex) {

      throw new StageException("Cannot access store.", ex);
    }

    // for every subsegment, add a LocalID to the XRD

    for (SubSegment localSubSegment : localSubSegments) {
View Full Code Here

Examples of org.openxri.exceptions.StageException

        children = ((StoreBetterLookup) store).getAuthorityChildSubSegments(authority);
        if (children.length < 1) return(xrd);
      } catch (StoreException ex) {

        throw new StageException("Cannot access store to check for child subsegments.", ex);
      }
    }

    // use the XRD's CanonicalID as the provider ID for the authority resolution service endpoint

    CanonicalID canonicalID = xrd.getCanonicalID();
    String canonicalIDString = null;

    if (canonicalID != null) {

      canonicalIDString = canonicalID.getValue();
    }

    // find out what to use as the namespace for further subsegments

    String namespace = null;

    if (canonicalIDString != null) {

      namespace = canonicalIDString;
    } else if (store instanceof StoreBetterLookup) {

      String qxris[];

      try {

        qxris = ((StoreBetterLookup) store).getAuthorityQxris(authority);
      } catch (StoreException ex) {

        throw new StageException("Cannot read subsegment XRI from store.", ex);
      }

      if (qxris.length > 0) namespace = qxris[0];
    }

    if (namespace == null) {

      throw new StageException("Cannot determine namespace for authority resolution SEP.");
    }

    // create HTTP and HTTPS <URI> elements for the authority resolution service endpoint

    Vector<URI> uris = new Vector<URI> ();

    if (this.httpURI != null) {

      StringBuffer uri = new StringBuffer(this.httpURI);
      this.uriMapper.completeURI(uri, namespace);

      try {

        uris.add(new URI(uri.toString()));
      } catch (URISyntaxException ex) {

        throw new StageException("Invalid URI: " + uri.toString());
      }
    }

    if (this.httpsURI != null) {

      StringBuffer uri = new StringBuffer(this.httpsURI);
      this.uriMapper.completeURI(uri, namespace);

      try {

        uris.add(new URI(uri.toString()));
      } catch (URISyntaxException ex) {

        throw new StageException("Invalid URI: " + uri.toString());
      }
    }

    // create authority resolution service endpoint and add it to the XRD
View Full Code Here

Examples of org.openxri.exceptions.StageException

  }

  public XRD execute(Store store, XRD xrd, XRISegment segment, Authority parentAuthority, String subSegmentName, Authority authority, boolean isCreate) throws StageException {

    if (! (store instanceof StoreAttributable)) throw new StageException("Cannot use this store implementation.");
    StoreAttributable storeAttributable = (StoreAttributable) store;

    // can only create a CanonicalID if the parent authority has one

    if (parentAuthority == null) return(xrd);
    if (parentAuthority.getXrd().getNumCanonicalids() < 1) return(xrd);

    // special case: if the new subsegment already is an i-number, we don't generate anything
   
    boolean isINumber = false;
   
    if (subSegmentName.startsWith("!")) isINumber = true;

    // create a new CanonicalID (read from authority attribute, increment by 1, write back as authority attribute)

    String canonicalIDString = null;
    int canonicalIDValue = -1;

    if (! isINumber) {

      try {
 
        canonicalIDString = storeAttributable.getAuthorityAttributes(parentAuthority).get(ATTRIBUTES_KEY_LAST_CANONICALID);
        canonicalIDValue = Integer.parseInt(canonicalIDString);
        canonicalIDValue++;
      } catch (StoreException ex) {
 
        throw new StageException("Cannot read authority attribute from store.", ex);
      } catch (NullPointerException ex) {    // if the attribute does not yet exist on that authority
 
        canonicalIDValue = 0;
      } catch (NumberFormatException ex) {  // if the attribute did not contain a valid integer value
 
        canonicalIDValue = 0;
      }
    }

    String localCanonicalIDString = isINumber ? subSegmentName : ("!" + Integer.toString(canonicalIDValue));
    canonicalIDString = parentAuthority.getXrd().getCanonicalidAt(0).getValue() + localCanonicalIDString;

    CanonicalID canonicalID = new CanonicalID(canonicalIDString);

    // write incremented authority attribute back to store
   
    if (! isINumber) {
   
      try {
 
        Map<String, String> attributes = storeAttributable.getAuthorityAttributes(parentAuthority);
        attributes.put(ATTRIBUTES_KEY_LAST_CANONICALID, Integer.toString(canonicalIDValue));
 
        storeAttributable.setAuthorityAttributes(parentAuthority, attributes);
      } catch (StoreException ex) {
 
        throw new StageException("Cannot write authority attribute to store.", ex);
      }
    }

    // put the CanonicalID into the XRD

    xrd.addCanonicalID(canonicalID);

    // if this is a CREATE pipeline, put the new CanonicalID into the store as a subsegment, so it can be resolved properly

    if (isCreate && ! isINumber) {

      try {

        store.registerSubsegment(parentAuthority, localCanonicalIDString, authority);
      } catch (StoreException ex) {

        throw new StageException("Cannot register subsegment for CanonicalID.");
      }
    }

    // done
View Full Code Here

Examples of org.openxri.exceptions.StageException

  }

  public void init() throws Exception {

    String elementName = this.properties.getProperty(PROPERTIES_KEY_ELEMENTNAME);
    if (elementName == null) throw new StageException("Required property " + PROPERTIES_KEY_ELEMENTNAME + " not found.");
    this.elementName = elementName;

    String elementNamespace = this.properties.getProperty(PROPERTIES_KEY_ELEMENTNAMESPACE, DEFAULT_ELEMENTNAMESPACE);
    this.elementNamespace = elementNamespace;
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.