Package org.openxri.resolve.exception

Examples of org.openxri.resolve.exception.PartialResolutionException


    } catch (java.net.URISyntaxException oEx) {
      XRD err = createErrorXRD(qxri.getAuthorityPath().toURINormalForm(),
          Status.INVALID_INPUT,
          "Unable to construct URI to access proxy resolution service");
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    } catch (UnsupportedEncodingException e) {
      // thrown from URLEncoder.encode() - this should never happen since the
      // US-ASCII encoding should be supported on every computer or so we hope :)
      XRD err = createErrorXRD(qxri.getAuthorityPath().toURINormalForm(),
          Status.INVALID_INPUT, "Charset not supported");
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    } catch (Exception e) {
      XRD err = createErrorXRD(qxri.getAuthorityPath().toURINormalForm(),
          Status.PERM_FAIL,
          "Unexpected error while constructing proxy URI: "
              + e.getMessage());
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }

    InputStream in = null;
    try {
      // try to get the data from it
      in = getDataFromURI(newURI, qxri.toURINormalForm(), flags, state);
      XRDS xrds = readXRDS(in);
      XRD finalXRD = xrds.getFinalXRD();

      String code = finalXRD.getStatusCode();
      if ((flags.isRefs() && !code.equals(Status.SUCCESS) && !code
          .equals(Status.REF_NOT_FOLLOWED))
          || !code.equals(Status.SUCCESS)) {
        // got either a non-SUCCESS code or
        // followRefs is on but we got non-SUCCESS and non-REF_NOT_FOLLOWED
        throw new PartialResolutionException(xrds);
      }
      return xrds;
    } catch (PartialResolutionException e) {
      // re-throw
      throw e;
    } catch (Exception e) {
      XRD err = createErrorXRD(qxri.getAuthorityPath().toURINormalForm(),
          Status.PERM_FAIL, "Error fetching XRDS from proxy: "
              + e.getMessage());
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }
  }
View Full Code Here


        // fall through to continue to the next
      }
    }
   
    log.info("processRedirects - exhausted list of Redirects. Throwing PRE");
    throw new PartialResolutionException(xrdsOut);
  }
View Full Code Here

      if (stat == null)
        throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Missing ServerStatus or Status element in 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);
      }

      if (flags.isCid()) {
        Status parentStatus = parent.getStatus();
        Status s = xrd.getStatus();
View Full Code Here

    if (xrdsOut == null) { // no appropriate URI found
      xrdsOut = new XRDS();
      String code = flags.isHttps()? Status.TRUSTED_RES_ERROR : Status.AUTH_RES_ERROR;
      xrdsOut.add(createErrorXRD(query, code, "No URI found for authority resolution"));
    }
    throw new PartialResolutionException(xrdsOut);
  }
View Full Code Here

        xrdsOut.add(finalXRD);
      } else {
        finalXRD.setStatus(new Status(Status.LIMIT_EXCEEDED,
            "Maximum of authority resolution requests exceeded"));
      }
      throw new PartialResolutionException(xrdsOut);
    }
   
  }
View Full Code Here

  private PartialResolutionException
  makeResolutionException(XRDS targetXRDS, String query, String status, String message)
  {
    XRD x = createErrorXRD(query, status, message);
    targetXRDS.add(x);
    return new PartialResolutionException(targetXRDS);
  }
View Full Code Here

      }
      catch (PartialResolutionException e) {
        log.trace("got PRE: " + e.getPartialXRDS());
        log.trace("xrdsOut.n = " + xrdsOut.getNumChildren() + ", partialXRDS.n=" + e.getPartialXRDS().getNumChildren());
        xrdsOut.add(e.getPartialXRDS());
        throw new PartialResolutionException(xrdsOut);       
      }
     
      //// add the subsegments
      xrdsOut.addAll(tmpXRDS);
     
      //// replace parent XRD
      parent = tmpXRDS.getFinalXRD();
     
      for (int k = 0; k < tmpXRDS.getNumChildren(); k++) {
        XRISubSegment subseg = remainingSegment.getSubSegmentAt(k);
        parentXRI = parentXRI + subseg;
      }
     
      remainingSegment = remainingSegment.getRemainder(tmpXRDS.getNumChildren());

      tmpXRDS = null;     
      try {
        if (parent.getNumRedirects() > 0) {
          log.debug("resolveAuthSegment - processing Redirect(s)");
          tmpXRDS = processRedirects(qxri, parent, currentFlags, state);
          xrdsOut.addAll(tmpXRDS);
          // replace parent
          parent = tmpXRDS.getFinalXRD();
        }
        else if (parent.getNumRefs() > 0) {
          if (!currentFlags.isRefs()) {
            throw makeResolutionException(
              xrdsOut,
              query,
              Status.REF_NOT_FOLLOWED,
              "Ref not followed");
          }
          log.debug("resolveAuthSegment - processing Ref(s)");
          tmpXRDS = processRefs(parent, currentFlags, state);
          xrdsOut.addAll(tmpXRDS);
          // replace parent
          parent = tmpXRDS.getFinalXRD();
        }       
      }
      catch (PartialResolutionException e) {
        xrdsOut.addAll(e.getPartialXRDS());
        log.debug("resolveAuthSegment - got PRE while processing Ref or Redirect");
        throw new PartialResolutionException(xrdsOut);
      }
    }
   
    log.debug("resolveAuthSegment - successfully resolved all subsegments");
    if (parent.getStatus().getCID().equals(Status.CID_VERIFIED)
View Full Code Here

        break;
      }
      catch (PartialResolutionException e) {
        xrdsOut.add(e.getPartialXRDS());
        if (!it.hasNext()) // last ref, throw the exception (otherwise, continue)
          throw new PartialResolutionException(xrdsOut);
      }
    }
    return xrdsOut;
  }
View Full Code Here

    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);
    if (srv.getNumRedirects() > 0) {
View Full Code Here

        xrdsOut.add(tmpXRDS);
       
        // fall through to continue to the next
      }
    }
    throw new PartialResolutionException(xrdsOut);
  }
View Full Code Here

TOP

Related Classes of org.openxri.resolve.exception.PartialResolutionException

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.