Package org.openxri.xml

Examples of org.openxri.xml.Status


    // find services
    List selectedSvcs = selectServices(xrd.getServices(), sepType, path, sepMediaType, flags);
    xrd.setSelectedServices(selectedSvcs);
    if (selectedSvcs.size() == 0) {
      Status s = xrd.getStatus();
      s.setCode(Status.SEP_NOT_FOUND);
      s.setText("Requested service endpoint not found");
      throw new PartialResolutionException(xrdsOut);
    }

    // check if first Service has Redirect of Ref
    Service srv = (Service)selectedSvcs.get(0);
View Full Code Here


      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);
View Full Code Here

  }

  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

      boolean bSigned)
  throws ServerException {

    // add status, query and provider ID to the XRD

    xrd.setStatus(new Status(Status.SUCCESS));
    xrd.setQuery(subSegmentName);
    xrd.setProviderID(parent.getAuthorityId());

    // add expiration information to the XRD
View Full Code Here

    }
    response.setStatus(HttpServletResponse.SC_OK);
    XRD xrd = partialXRDS.getFinalXRD();
    String errMsg = "";
    if (xrd != null) {
      Status stat = xrd.getStatus();
      errMsg = "Error code: " + stat.getCode() + " - " + stat.getText();
    }

    if (resMediaType == null) {
      sendResponse(response, HTTP_ERROR_CONTENT_TYPE, errMsg, null);
    }
View Full Code Here

    }
    response.setStatus(HttpServletResponse.SC_OK);
    XRD xrd = partialXRDS.getFinalXRD();
    String errMsg = "";
    if (xrd != null) {
      Status stat = xrd.getStatus();
      errMsg = "Error code: " + stat.getCode() + " - " + stat.getText();
    }

    if (resMediaType == null) {
      sendError(request, response, qxri, Integer.parseInt(xrd.getStatus().getCode()), errMsg, pre);
    }
View Full Code Here

    response.setStatus(HttpServletResponse.SC_OK);
    XRD xrd = partialXRDS.getFinalXRD();
    String errMsg = "";
    if (xrd != null) {
      Status stat = xrd.getStatus();
      errMsg = "Error code: " + stat.getCode() + " - " + stat.getText();
    }

    if (resMediaType == null) {
      sendResponse(response, HTTP_ERROR_CONTENT_TYPE, errMsg, null);
    }
View Full Code Here

        if (finalXRD == null) {
          finalXRD = createErrorXRD(segment.toURINormalForm(true), Status.LIMIT_EXCEEDED, "Maximum of authority resolution requests exceeded");
          xrdsOut.add(finalXRD);
        }
        else {
          finalXRD.setStatus(new Status(Status.LIMIT_EXCEEDED, "Maximum of authority resolution requests exceeded"));
        }
        throw new PartialResolutionException(xrdsOut);       
      }
     
      ///// Try each URI in each selected service in turn
      Exception savedException = null;
      Iterator srvIterator = selectedServices.iterator();
      while (srvIterator.hasNext()) {
        Service srv = (Service)srvIterator.next();
       
        Iterator uriIterator = srv.getPrioritizedURIs().iterator();
          ///// try each selected service URI in turn (skip only if nothing was read)
          while (uriIterator.hasNext()) {
            SEPUri sepURI = (SEPUri)uriIterator.next();
            URI uri = sepURI.getURI();
           
            log.trace("resolveAuthSegment - trying URI='" + uri + "'");

            // skip non-HTTPS URIs if HTTPS was requested
            if (trustType.isHTTPS() && !uri.getScheme().equals(HTTPS)) {
              log.trace("resolveAuthSegment - skipping non HTTPS URI");
              continue;
            }
           
            URI newURI;
                try
                {
                    newURI = constructAuthResURI(uri.toString(), segment.toURINormalForm(true));               
                    log.trace("resolveAuthSegment - newURI = " + newURI);
                }
                catch (java.net.URISyntaxException oEx)
                {
                    // oops! invalid authority URI
                  savedException = new InvalidAuthorityURIException(
                        "Could not create URI to access based on " + uri +
                        ".  Trying to resolve " + segment, oEx);
                  continue; // try next URI
                }

                XRDS newXRDS = null;
                // now that we've constructed the new URI, try to return the stream from it
                try {
                  InputStream in = getDataFromURI(segment.toString(), newURI, trustType, state);
                    newXRDS = readXRDS(in);
                    log.debug("Got XRDS = " + newXRDS.toString());
                }
                catch (Exception e) {
                  log.trace("resolveAuthSegment - bad URI");
                  savedException = e;
                  continue;
                }
               
                // set ourselves up for the next multi-pass
                for (int d = 0; d < newXRDS.getNumChildren() && d < segment.getNumSubSegments(); d++)
                {
                    XRD xrd = newXRDS.getDescriptorAt(d);
                   
                    // status is not success
                    Status stat = xrd.getStatus();
                    if (stat == null) {
                      xrd = createErrorXRD(segment.getSubSegmentAt(d).toString(),
                        Status.UNEXPECTED_XRD, "Status code was missing in original XRD");
                    }
                   
View Full Code Here

      ArrayList selectedSvcs = selectServices(xrd.getServices(), sepType, path, sepMediaType);
      if (selectedSvcs.size() == 0) {
        // do reference processing
        ArrayList refs = xrd.getPrioritizedRefs();
        if (refs.size() == 0) {
          Status s = new Status(Status.SEP_NOT_FOUND, "Requested service endpoint not found.");
          xrdsOut.getFinalXRD().setStatus(s);
          throw new PartialResolutionException(xrdsOut);
        }
       
        if (maxFollowRefs >= 0 && state.getNumRefsFollowed() >= maxFollowRefs) {
          Status s = new Status(Status.LIMIT_EXCEEDED, "Maximum number of references exceeded");
          xrdsOut.getFinalXRD().setStatus(s);
          throw new PartialResolutionException(xrdsOut);         
        }

        // we have some references, let's process it
        for (int i = 0; i < refs.size(); i++) {
          Ref r = (Ref)refs.get(i);
          XRI refXRI = null;
          try {
            refXRI = new XRI(r.getValue());
          }
          catch (XRIParseException e) {
            log.warn("resolveAuthSegment - Invalid ref encountered: " + e.getMessage());
           
            // bail out if this is the last segment
            if (i == refs.size()) {
                Status s = new Status(Status.SEP_NOT_FOUND, "Invalid ref encountered: " + e.getMessage());
                xrdsOut.getFinalXRD().setStatus(s);
                throw new PartialResolutionException(xrdsOut);
            }
            else // try next one
              continue;
View Full Code Here

 
  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

TOP

Related Classes of org.openxri.xml.Status

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.