Package org.openxri.xml

Examples of org.openxri.xml.XRD


          String constructedURI = constructURI(uri, r.getAppend(), qxri);
          uri = new URI(constructedURI);
        }
      } catch (URISyntaxException e) {
        XRDS tmpXRDS = new XRDS();
        XRD err = createErrorXRD(r.getValue(), Status.INVALID_REDIRECT, "Invalid Redirect URI");
        tmpXRDS.add(err);
        xrdsOut.add(tmpXRDS);
        continue;
      }
     
      try {
        XRDS tmpXRDS = fetchRedirectXRDS(uri, parent, qxri, flags, state);
        xrdsOut.add(tmpXRDS);
       
        XRD finalXRD = tmpXRDS.getFinalXRD();
        tmpXRDS = new XRDS();
        List services = selectServiceFromXRD(tmpXRDS, finalXRD, qxri, sepType, sepMediaType, flags, state);
        xrdsOut.addAll(tmpXRDS);
        return services; // we're done!
      } catch (XRIResolutionException e) {
        XRDS tmpXRDS = new XRDS();
        XRD err = createErrorXRD(uri.toString(), Status.REDIRECT_ERROR, "Error fetching XRDS: " + e.getMessage());
        tmpXRDS.add(err);
        xrdsOut.add(tmpXRDS);
       
        // fall through to continue to the next
      }
View Full Code Here


      }
     
      if (!tmpXRDS.isXRDAt(0))
        throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Authority XRDS document should not contain XRDS element");

      XRD xrd = tmpXRDS.getDescriptorAt(0);
      xrdsOut.add(xrd);


      ServerStatus sstat = xrd.getServerStatus();
      Status stat;
      if (sstat == null) {
        // compatibility: if no ServerStatus, look for Status
        stat = xrd.getStatus();
      }
      else {
        stat = new Status(sstat.getCode(), sstat.getText());
        xrd.setStatus(stat);
      }
     
      if (stat == null)
        throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Missing ServerStatus or Status element in Redirect XRD");

      if (!stat.getCode().equals(Status.SUCCESS)) {
        throw new PartialResolutionException(xrdsOut);
      }

      // check the basic properties of the descriptor
      if (!xrd.isValid()) {       
        xrd.setStatus(new Status(Status.UNEXPECTED_RESPONSE, "XRD is not valid (stale?)"));
        throw new PartialResolutionException(xrdsOut);
      }
     
      String err = verifyRedirectXRD(xrd, parent);
      if (err != null) {
        xrd.setStatus(new Status(Status.REDIRECT_VERIFY_FAILED, err));
        throw new PartialResolutionException(xrdsOut);
      }
     
      // copy parent Status cid attribute if present
      stat.setCID(xrd.getCanonicalID() == null? Status.CID_ABSENT : parent.getStatus().getCID());
     
      // copy parent Status ceid attribute (without checking if present since it is supposed to be "off" for
      // non-final XRD, and we don't know whether this is a final XRD.)
      stat.setCEID(parent.getStatus().getCEID());
     
      try {
        if (xrd.getNumRedirects() > 0) {
          log.info("fetchRedirectXRDS - XRD at URI(" + uri + ") contains Redirect(s), following..");
          tmpXRDS = processRedirects(qxri, xrd, flags, state);
          xrdsOut.addAll(tmpXRDS);
        }
        else if (xrd.getNumRefs() > 0) {
          if (!flags.isRefs()) {
            throw makeResolutionException(
              xrdsOut,
              query,
              Status.REF_NOT_FOLLOWED,
View Full Code Here

        "MaxRequests", "10"));
    int maxTotalBytes = Integer.parseInt(properties.getProperty(
        "MaxTotalBytes", "1048576")); // 1Mb
    int maxBytesPerRequest = Integer.parseInt(properties.getProperty(
        "MaxBytesPerRequest", "512000")); // 500Kb
    XRD equalsAuthority = XRD.parseXRD(properties
        .getProperty("EqualsAuthority"), false);
    XRD atAuthority = XRD.parseXRD(properties.getProperty("AtAuthority"),
        false);
    XRD bangAuthority = XRD.parseXRD(properties
        .getProperty("BangAuthority"), false);
    String supports = properties.getProperty("SupportedResMediaTypes");
 
    this.setMaxFollowRedirects(maxFollowRedirects);
    this.setMaxFollowRefs(maxFollowRefs);
View Full Code Here

    this.setAuthority("@", atAuthority);
    this.setAuthority("!", bangAuthority);
  }

  public XRD createErrorXRD(String query, String code, String msg) {
    XRD err = new XRD();
    err.setQuery(query);
    Status stat = new Status(code, msg);
    err.setStatus(stat);
    return err;
  }
View Full Code Here

  private XRI parseAbsoluteQXRIOrError(String qxri)
      throws PartialResolutionException {
    try {
      XRI xri = new XRI(qxri);
      if (xri.isRelative()) {
        XRD err = createErrorXRD(qxri, Status.INVALID_QXRI,
            "QXRI is not absolute.");
        throw new PartialResolutionException(err);
      }
      return xri;
    } catch (XRIParseException e) {
      XRD err = createErrorXRD(qxri, Status.INVALID_QXRI,
          "QXRI parse error: " + e.getMessage());
      throw new PartialResolutionException(err);
    } catch (Exception e) {
      XRD err = createErrorXRD(qxri, Status.PERM_FAIL,
          "Unexpected error while parsing input: " + e.getMessage());
      throw new PartialResolutionException(err);
    }
  }
View Full Code Here

      try {

        // create a fresh XRD

        XRD xrd = new XRD();

        // give subclasses a chance to init the XRD

        ret = this.initXRD(
            xrd,
View Full Code Here

      try {

        // create a fresh XRD

        XRD xrd = new XRD();

        // using the parent authority and subsegment name, find the subsegment and the authority we are describing now
        // we must be prepared to have null values here, since not all pipeline configurations
        // may use objects from the store
View Full Code Here

      try {

        // create a fresh XRD

        XRD xrd = new XRD();

        // get the current authority from the list

        Authority authority = authorities[i];
View Full Code Here

   * Methods for creating a "not found" and a "exception" XRD.
   */

  public static XRD makeNotFoundXrd(String subSegmentName) {

    XRD xrd = new XRD();

    xrd.setQuery(subSegmentName);
    xrd.setStatus(new Status(Status.QUERY_NOT_FOUND, "No descriptor found for this query."));
    xrd.setServerStatus(new ServerStatus(Status.QUERY_NOT_FOUND, "No descriptor found for this query."));

    return(xrd);
  }
View Full Code Here

    return(xrd);
  }

  public static XRD makeExceptionXrd(String subSegmentName, Exception ex) {

    XRD xrd = new XRD();

    String text = ex.getMessage();
    if (text == null || text.trim().equals("")) text = "An internal error occurred: " + ex.getClass().getName();

    xrd.setQuery(subSegmentName);
    xrd.setStatus(new Status(Status.TEMPORARY_FAIL, text));
    xrd.setServerStatus(new ServerStatus(Status.TEMPORARY_FAIL, text));

    return(xrd);
  }
View Full Code Here

TOP

Related Classes of org.openxri.xml.XRD

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.