Examples of XRDS


Examples of org.openxri.xml.XRDS

  {
    if (soLog.isDebugEnabled()) soLog.debug("lookupByAuthority(" + parent.getAuthorityId() + "," + segment.toString() + ")");

    // the big goal is to make an XRDS, consisting of one or more XRDs

    XRDS xrds = new XRDS();
    boolean ret;

    // give subclasses a chance to init the XRDS before we begin

    ret = this.initXRDS(
        xrds,
        segment,
        bSigned);

    // if a subclass returned true, it doesnt want us to do any more work

    if (ret == true) {
     
      soLog.debug("Subclass handled XRDS completely. Returning it without any more work.");
      return(xrds);
    }

    // generate XRDs for all subsegments in the request

    for (int i=0; i<segment.getNumSubSegments(); i++) {

      String subSegmentName = segment.getSubSegmentAt(i).toString();

      try {

        // create a new XRD

        XRD xrd = new XRD();

        // give subclasses a chance to init the XRD

        ret = this.initXRD(
            xrd,
            parent,
            subSegmentName,
            bSigned);

        // if a subclass returned true, it doesnt want us to do any more work

        if (ret == true) {

          soLog.debug("Subclass handled XRD completely. Returning it without any more work.");
          xrds.add(xrd);
          break;
        }

        // give authority handlers a chance to init it, if there are any for the current parent authority

        List authorityHandlers = new ArrayList();

        if (moAuthorityHandlers.get(parent.getAuthorityId()) != null)
          authorityHandlers.addAll((List) moAuthorityHandlers.get(parent.getAuthorityId()));

        for (Iterator ii = authorityHandlers.iterator(); ii.hasNext(); ) {

          if (ret == true) break;

          AuthorityHandler authorityHandler = (AuthorityHandler) ii.next();

          ret = authorityHandler.initXRD(
              xrd,
              parent,
              subSegmentName,
              bSigned);
        }

        // if an authority handler returned true, it doesnt want us to do any more work

        if (ret == true) {

          soLog.debug("Authority Handler handled XRD completely. Returning it without any more work.");
          xrds.add(xrd);
          break;
        }

        // using the parent authority and subsegment name, find the authority we are describing now

        SubSegment subSegment = moStore.findSubSegment(parent, subSegmentName);
        if (subSegment == null) {

          soLog.warn("Cannot find subsegment: " + subSegmentName);
          return(null);
        }

        Authority authority = moStore.getSubSegmentAuthority(subSegment);

        // look up Refs and Services from the store, as well as LocalIDs if the store supports it

        Ref[] refs = moStore.getAuthorityRefs(authority);
        Service[] services = moStore.getAuthorityServices(authority);
        LocalID[] localIds;

        if (moStore instanceof StoreBetterLookup) {

          localIds = ((StoreBetterLookup) moStore).getSubSegmentLocalIds(subSegment);
        } else {

          localIds = new LocalID[0];
        }

        // fill it with information we got from the store

        for (int ii=0; ii<refs.length; ii++) xrd.addRef(refs[ii]);
        for (int ii=0; ii<services.length; ii++) xrd.addService(services[ii]);
        for (int ii=0; ii<localIds.length; ii++) xrd.addLocalID(localIds[ii]);

        // do we want a local authority resolution service for this authority?
        // this piece of information comes from the store, but we actually create
        // the service, since this requires knowledge of the server configuration

        if (authority.getLocalAuthService().equals(Boolean.TRUE)) {

          URI[] uris;

          try {

            uris = new URI[2];
            uris[0] = fillURI(authority.getAuthorityId(), "http");
            uris[1] = fillURI(authority.getAuthorityId(), "https");
          } catch(URISyntaxException ex) {

            throw new ServerException("Invalid URI for authority resolution service.", ex);
          }

          xrd.addService(new AuthorityResolutionService(uris, authority.getAuthorityId()));
        }

        // let our subclasses finish the XRD before we append it to the XRDS

        this.finishXRD(
            xrd,
            parent,
            subSegment,
            authority,
            bSigned);

        // let authority handlers finish the XRD, if there are any for this authority

        for (Iterator ii = authorityHandlers.iterator(); ii.hasNext(); ) {

          AuthorityHandler authorityHandler = (AuthorityHandler) ii.next();

          authorityHandler.finishXRD(
              xrd,
              parent,
              subSegment,
              authority,
              bSigned);
        }

        // append XRD to the XRDS

        xrds.add(xrd);

        // authority becomes the parent authority for the next subsegment

        parent = authority;
      }
View Full Code Here

Examples of org.openxri.xml.XRDS

      Server openXRIServer = ((OpenXRIAdminApplication) Application.get()).getOpenXRIServer();

      try {

        XRDS xrds = openXRIServer.lookupByNamespace(
            this.rootSubSegment.getName(),
            this.query,
            this.signed.booleanValue());

        if (xrds == null) throw new ServerNotFoundException();
View Full Code Here

Examples of org.openxri.xml.XRDS

      Server openXRIServer = ((OpenXRIAdminApplication) Application.get()).getOpenXRIServer();

      try {

        XRDS xrds = openXRIServer.lookupSelfDescribing(
            this.rootSubSegment.getName(),
            this.signed.booleanValue());

        if (xrds == null) throw new ServerNotFoundException();
       
View Full Code Here

Examples of org.openxri.xml.XRDS

        }

        String content = null;
        try
        {
          XRDS xrds = moResolver.resolveAuthToXRDS(oXRI, new TrustType(), true);
          content = xrds.toString();
        }
        catch (Exception e)
        {
          if (e instanceof PartialResolutionException) {
            content = ((PartialResolutionException)e).getPartialXRDS().toString();
View Full Code Here

Examples of org.openxri.xml.XRDS

      return;
    }

    // let the server do the lookup and create a complete XRD/XRDS descriptor

    XRDS descriptor = null;

    try {

      if (namespace != null) {

        if (soLog.isDebugEnabled()) soLog.debug("Looking up authority by namespace.");

        descriptor = moServer.lookupByNamespace(namespace, segment, bSigned);
      } else if (authorityId != null) {

        if (soLog.isDebugEnabled()) soLog.debug("Looking up authority by ID.");

        descriptor = moServer.lookupById(authorityId, segment, bSigned);
      }
    } catch(ServerException ex) {

      soLog.warn("Problem during resolution.", ex);
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      return;
    }

    // hopefully we got a result

    if (descriptor != null) {

      if (soLog.isDebugEnabled()) soLog.debug("Resolution successful. Sending descriptor.");
      response.setStatus(HttpServletResponse.SC_OK);
      response.setContentType(Tags.CONTENT_TYPE_XRDS);
      response.getWriter().write(descriptor.toString());
      return;
    } else {

      if (soLog.isDebugEnabled()) soLog.debug("Resolution unsuccessful. Sending 404.");
      response.sendError(HttpServletResponse.SC_NOT_FOUND);
View Full Code Here

Examples of org.openxri.xml.XRDS

        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");
          canonicalID = null;
View Full Code Here

Examples of org.openxri.xml.XRDS

        }
      }
    }

    // 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);
        }
        else if (resMediaType.isType(MimeType.XRDS_XML)) {
          xrds = resolver.resolveSEPToXRDS(oXRI, trustType, serviceType, serviceMediaType, refs);
          sendResponse(response, isDumbBrowser, resMediaType.getType(), xrds.toString(), trustType);
        }
        else if (resMediaType.isType(MimeType.XRD_XML)) {
          xrd = resolver.resolveSEPToXRD(oXRI, trustType, serviceType, serviceMediaType, refs);
          sendResponse(response, isDumbBrowser, resMediaType.getType(), xrd.toResultString(), trustType);
        }
        else {
          // else - we should have taken care of it in checkSupportedMediaTypes
          log.error("processProxyRequest - should not reach here (sep=true)");
        }
      }
      else {
        //// authority resolution only
        if(resMediaType == null) {
          resMediaType = new MimeType(MimeType.XRDS_XML);
        }

        if (resMediaType.isType(MimeType.XRDS_XML)) {
          xrds = resolver.resolveAuthToXRDS(oXRI, trustType, refs);
          sendResponse(response, isDumbBrowser, resMediaType.getType(), xrds.toString(), trustType);
          return;
        }
        else if (resMediaType.isType(MimeType.XRD_XML)) {
          xrd = resolver.resolveAuthToXRD(oXRI, trustType, refs);
          sendResponse(response, isDumbBrowser, resMediaType.getType(), xrd.toString(), trustType);
View Full Code Here

Examples of org.openxri.xml.XRDS

        catch (XRIParseException E)
        {
            // ok
        }
        catch (PartialResolutionException e) {
          XRDS xrds = e.getPartialXRDS();
          assertTrue("Should have exactly one error XRD", xrds.getNumChildren() != 1);
        }
        catch (Exception E)
        {
            assertTrue("Expected XRIParseException. But got " + E, false);
        }
View Full Code Here

Examples of org.openxri.xml.XRDS

  {
    if (soLog.isDebugEnabled()) soLog.debug("lookupByAuthority(" + parent.getAuthorityId() + "," + segment.toString() + ")");

    // the big goal is to make an XRDS, consisting of one or more XRDs

    XRDS xrds = new XRDS();
    boolean ret;

    // give subclasses a chance to init the XRDS before we begin

    ret = this.initXRDS(
        xrds,
        segment,
        bSigned);

    // if a subclass returned true, it doesnt want us to do any more work

    if (ret == true) {

      soLog.debug("Subclass handled XRDS completely. Returning it without any more work.");
      return(xrds);
    }

    // generate XRDs for all subsegments in the request

    for (int i=0; i<segment.getNumSubSegments(); i++) {

      String subSegmentName = segment.getSubSegmentAt(i).toString();

      try {

        // create a new XRD

        XRD xrd = new XRD();

        // give subclasses a chance to init the XRD

        ret = this.initXRD(
            xrd,
            parent,
            subSegmentName,
            bSigned);

        // if a subclass returned true, it doesnt want us to do any more work

        if (ret == true) {

          soLog.debug("Subclass handled XRD completely. Returning it without any more work.");
          xrds.add(xrd);
          break;
        }

        // give authority handlers a chance to init it, if there are any for the current parent authority

        List authorityHandlers = new ArrayList();

        if (moAuthorityHandlers.get(parent.getAuthorityId()) != null)
          authorityHandlers.addAll((List) moAuthorityHandlers.get(parent.getAuthorityId()));

        for (Iterator ii = authorityHandlers.iterator(); ii.hasNext(); ) {

          if (ret == true) break;

          AuthorityHandler authorityHandler = (AuthorityHandler) ii.next();

          ret = authorityHandler.initXRD(
              xrd,
              parent,
              subSegmentName,
              bSigned);
        }

        // if an authority handler returned true, it doesnt want us to do any more work

        if (ret == true) {

          soLog.debug("Authority Handler handled XRD completely. Returning it without any more work.");
          xrds.add(xrd);
          break;
        }

        // using the parent authority and subsegment name, find the authority we are describing now

        SubSegment subSegment;
       
        try {

          subSegment = moStore.findSubSegment(parent, subSegmentName);
          if (subSegment == null) throw new StoreNotFoundException("Null value returned.");
        } catch (StoreNotFoundException ex) {

          ServerNotFoundException ex2 = new ServerNotFoundException("Cannot find subsegment: " + subSegmentName, ex);
          soLog.warn(ex2);
          throw ex2;
        }

        Authority authority = moStore.getSubSegmentAuthority(subSegment);

        // look up Refs and Services from the store, as well as LocalIDs if the store supports it

        Ref[] refs = moStore.getAuthorityRefs(authority);
        Service[] services = moStore.getAuthorityServices(authority);
        LocalID[] localIds;

        if (moStore instanceof StoreBetterLookup) {

          localIds = ((StoreBetterLookup) moStore).getSubSegmentLocalIds(subSegment);
        } else {

          localIds = new LocalID[0];
        }

        // fill it with information we got from the store

        for (int ii=0; ii<refs.length; ii++) xrd.addRef(refs[ii]);
        for (int ii=0; ii<services.length; ii++) xrd.addService(services[ii]);
        for (int ii=0; ii<localIds.length; ii++) xrd.addLocalID(localIds[ii]);

        // do we want a local authority resolution service for this authority?
        // this piece of information comes from the store, but we actually create
        // the service, since this requires knowledge of the server configuration

        if (authority.getLocalAuthService().equals(Boolean.TRUE)) {

          URI[] uris;

          try {

            uris = new URI[2];
            uris[0] = fillURI(authority.getAuthorityId(), "http");
            uris[1] = fillURI(authority.getAuthorityId(), "https");
          } catch(URISyntaxException ex) {

            throw new ServerInternalException("Invalid URI for authority resolution service.", ex);
          }

          xrd.addService(new AuthorityResolutionService(uris, authority.getAuthorityId()));
        }

        // let our subclasses finish the XRD before we append it to the XRDS

        this.finishXRD(
            xrd,
            parent,
            subSegment,
            authority,
            bSigned);

        // let authority handlers finish the XRD, if there are any for this authority

        for (Iterator ii = authorityHandlers.iterator(); ii.hasNext(); ) {

          AuthorityHandler authorityHandler = (AuthorityHandler) ii.next();

          authorityHandler.finishXRD(
              xrd,
              parent,
              subSegment,
              authority,
              bSigned);
        }

        // append XRD to the XRDS

        xrds.add(xrd);

        // authority becomes the parent authority for the next subsegment

        parent = authority;
      } catch (StoreException oEx) {
View Full Code Here

Examples of org.openxri.xml.XRDS

  }

  public PartialResolutionException(XRD xrd)
  {
    super(xrd.getStatus().getText());
    this.xrds = new XRDS();
    this.xrds.add(xrd);
  }
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.