Examples of XRI


Examples of org.openxri.XRI

    // resolve the XRI

    try {

      xrd = resolver.resolveAuthToXRD(new XRI(resolveXri), resolverFlags, new ResolverState());
    } catch (PartialResolutionException ex) {

      log.error("Problem while resolving " + resolveXri + ": " + ex.getMessage(), ex);
      sendResponse(response, HttpServletResponse.SC_NOT_FOUND);
      return;
View Full Code Here

Examples of org.openxri.XRI

    // resolve the XRI

    try {

      uris = resolver.resolveSEPToURIList(new XRI(xri), null, null, resolverFlags, new ResolverState());
    } catch (PartialResolutionException ex) {

      log.error("Problem while resolving " + xri + ": " + ex.getMessage(), ex);
      sendResponse(response, HttpServletResponse.SC_NOT_FOUND);
      return;
View Full Code Here

Examples of org.openxri.XRI

        {
            sendNotFound(oResp);
            return;
        }

        XRI oXRI = null;
        try
        {
            oXRI = new XRI(sXRI);
        }
        catch (XRIParseException oEx)
        {
            // log and send a 404
            soLog.warn("Error constructing XRI: " + sXRI + ", " + oEx);
View Full Code Here

Examples of org.openxri.XRI

          log.debug("processProxyRequest - sXRI is null or empty");
            sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "INVALID_QXRI(code=211): null or empty", null);
            return;
        }

        XRI oXRI = null;
        try {
            oXRI = XRI.fromURINormalForm(qxri);
        }
        catch (XRIParseException oEx) {
            // log and send a 404
            log.warn("Error constructing XRI: " + qxri + ", " + oEx);
            sendResponse(response,HTTP_ERROR_CONTENT_TYPE, "INVALID_QXRI(code=211): "+oEx.getMessage(),null);
            return;
        }


      // defaults if resolution media type is null
      TrustType trustType = new TrustType();
      boolean refs = true;
      boolean sep = true;

      String tempStr = null;
      if(resMediaType != null) {
        tempStr = resMediaType.getParam(MimeType.PARAM_REFS);
        if(tempStr != null && tempStr.equals("false"))
          refs = false;
       
        tempStr = resMediaType.getParam(MimeType.PARAM_SEP);
        if(tempStr != null && tempStr.equals("false"))
          sep = false;
       
        tempStr = resMediaType.getParam(MimeType.PARAM_TRUST);
        if (tempStr != null) {
          try {
            trustType.setType(tempStr);
          }
          catch (IllegalTrustTypeException e) {
            sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "INVALID_RESOLUTION_MEDAIA_TYPE(code=212): " + resMediaType, null);
            return;
          }
        }
      }
       
        // set the request preferences on the resolver before querying.
        XRDS xrds = null;
        XRD xrd = null;
        try
        {
          if (sep) {
            if (resMediaType == null) {
              // see section 7.6 for special redirect rule
                 ArrayList uris = resolver.resolveSEPToURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
              if (uris == null || uris.size() == 0) {
                sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
                return;
              }
              String s = (String) uris.get(0);
             
              log.trace("Sending redirect to '" + s + "'");
             
              response.sendRedirect(s);
             }
            else if (resMediaType.isType(MimeType.URI_LIST)) {
              String  text = resolver.resolveSEPToTextURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
              if (text.length() <= 0)
                sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
              else
                sendResponse(response, resMediaType.getType(), text, null);
             }
View Full Code Here

Examples of org.openxri.XRI

      Authority authority;

      try {

        XRI xri = new XRI(this.xri);
        XRIAuthority xriAuthority = ((XRIAuthority) xri.getAuthorityPath());

        authority = ((StoreBetterLookup) openXRIStore).localLookup(xriAuthority);

        if (authority == null) throw new StoreNotFoundException();
      } catch (StoreNotFoundException ex) {
View Full Code Here

Examples of org.openxri.XRI

    @Override
    protected void onSubmit() {

      try {

        new XRI(this.xri);
      } catch (Exception ex) {

        BasePage.log.error(ex);
        BasePage.this.error(BasePage.this.getString("parsefail") + ex.getLocalizedMessage());
        return;
View Full Code Here

Examples of org.openxri.XRI

        try {

          authority = openXRIStore.getSubSegmentAuthority(rootSubSegment);

          XRDS xrds = resolver.resolveAuthority(new XRI(this.namespace), new ResolverFlags(), new ResolverState());
          XRD xrd = (xrds != null) ? xrds.getFinalXRD() : null;
          canonicalID = (xrd != null) ? xrd.getCanonicalID() : null;
        } catch (Exception ex) {

          log.warn("Cannot find corresponding i-number");
View Full Code Here

Examples of org.openxri.XRI

      log.debug("processProxyRequest - sXRI is null or empty");
      sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "INVALID_QXRI(code=211): null or empty", null);
      return;
    }

    XRI oXRI = null;
    try {
      oXRI = XRI.fromURINormalForm(qxri);
    }
    catch (XRIParseException oEx) {
      // log and send a 404
      log.warn("Error constructing XRI: " + qxri + ", " + oEx);
      sendResponse(response,HTTP_ERROR_CONTENT_TYPE, "INVALID_QXRI(code=211): "+oEx.getMessage(),null);
      return;
    }


    // defaults if resolution media type is null
    TrustType trustType = new TrustType();
    boolean refs = true;
    boolean sep = true;

    String tempStr = null;
    if(resMediaType != null) {
      tempStr = resMediaType.getParam(MimeType.PARAM_REFS);
      if(tempStr != null && tempStr.equals("false"))
        refs = false;

      tempStr = resMediaType.getParam(MimeType.PARAM_SEP);
      if(tempStr != null && tempStr.equals("false"))
        sep = false;

      tempStr = resMediaType.getParam(MimeType.PARAM_TRUST);
      if (tempStr != null) {
        try {
          trustType.setType(tempStr);
        }
        catch (IllegalTrustTypeException e) {
          sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "INVALID_RESOLUTION_MEDAIA_TYPE(code=212): " + resMediaType, null);
          return;
        }
      }
    }

    // set the request preferences on the resolver before querying.
    XRDS xrds = null;
    XRD xrd = null;
    try
    {
      if (sep) {
        if (resMediaType == null) {
          // see section 7.6 for special redirect rule
          ArrayList uris = resolver.resolveSEPToURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
          if (uris == null || uris.size() == 0) {
            sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
            return;
          }
          String s = (String) uris.get(0);

          log.trace("Sending redirect to '" + s + "'");

          response.sendRedirect(s);
        }
        else if (resMediaType.isType(MimeType.URI_LIST)) {
          String  text = resolver.resolveSEPToTextURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
          if (text.length() <= 0)
            sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
          else
            sendResponse(response, resMediaType.getType(), text, null);
        }
View Full Code Here

Examples of org.openxri.XRI

        // try to resolve a xri without setting up global authority
        //
        try
        {
            String sXRI = "xri://@foo";
            oResolver.resolveAuthToXRDS(new XRI(sXRI), new TrustType(), true);
            assertTrue(
                "Did not get expected PartialResolutionException", false);
        }
        catch (PartialResolutionException E)
        {
View Full Code Here

Examples of org.openxri.XRI

        //
        try
        {
            String sXRI = "xri://@gates*com";
            XRD oDesc =
                oResolver.resolveAuthToXRD(new XRI(sXRI), new TrustType(), false);
            assertTrue("Thought " + sXRI + " did not exist.", oDesc == null);
        }
        catch (PartialResolutionException e) {
          // ok
        }
        catch (Exception E)
        {
            E.printStackTrace();
            assertTrue("Unexpected " + E, false);
        }

        //
        // resolve existing xri
        //
        try
        {
            String sXRI = "xri://@foo";
            XRD oDesc =
                oResolver.resolveAuthToXRD(new XRI(sXRI), new TrustType(), false);
            assertTrue("Thought " + sXRI + " exists.", oDesc != null);
            assertTrue("Invalid XRD Query", oDesc.getQuery().equals("*foo"));
        }
        catch (Exception E)
        {
            E.printStackTrace();
            assertTrue("Unexpected " + E, false);
        }

        //
        // resolve nonexistent segment
        //
        try
        {
            String sXRI = "xri://@foo*bar";
            XRD oDesc =
                oResolver.resolveAuthToXRD(new XRI(sXRI), new TrustType(), false);
            assertTrue("Expected PartialResolutionException but not thrown", false);
        }
        catch (PartialResolutionException e) {
          // ok
        }
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.