Package org.openxri.xml

Examples of org.openxri.xml.Status


    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


  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

    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

            // if we got the nonexistent "command" return a not found
            if (uri.getPath().indexOf("!nonexistent") >= 0)
            {
                XRD xrd = new XRD();
                xrd.setQuery("!nonexistent");
                xrd.setStatus(new Status(Status.AUTH_RES_NOT_FOUND));
                XRDS xrds = new XRDS();
                xrds.add(xrd);
                return new ByteArrayInputStream(xrds.toString().getBytes());
            }

            XRDS oDescs = new XRDS();

            // just the same response always
            XRD oFoo = new XRD();
            oFoo.setQuery("!foo");
            oFoo.setStatus(new Status(Status.SUCCESS));
            oDescs.add(oFoo);

            XRD oBar = new XRD();
            oBar.setQuery("!bar");
            oBar.setStatus(new Status(Status.SUCCESS));
            oDescs.add(oBar);

            if (uri.getPath().indexOf("!baz") > 0) {
              XRD baz = new XRD();
              baz.setQuery("!baz");
              baz.setStatus(new Status(Status.AUTH_RES_NOT_FOUND, "Not found"));
                oDescs.add(baz);
            }
            return new ByteArrayInputStream(oDescs.toString().getBytes());

        } // getDataFromURI()
View Full Code Here

    if (this.code == null || this.text == null) throw new StageException("Not initialized.");

    // add a <Status> tag to the XRD

    xrd.setStatus(new Status(this.code, this.text));

    // done

    return(xrd);
  }
View Full Code Here

      // System.out.println(xrds);

      assertTrue("Expected 5 XRDs", xrds.getNumChildren() == 5);
      assertTrue("subseg[3] should be *0003-badcid", xrds.getDescriptorAt(3).getQuery().equals("*0003-badcid"));
     
      Status s3 = xrds.getDescriptorAt(3).getStatus();
      assertTrue("subseg[3].status.cid should be 'failed'", s3.getCID().equals("failed"));
     
      Status s4 = xrds.getDescriptorAt(4).getStatus();
      assertTrue("subseg[4].status.cid should be 'failed'", s4.getCID().equals("failed"));

     
     
      qxri = "=openxri*test*live.unit.tests*0001-simple";
      xri = XRI.fromIRINormalForm(qxri);
View Full Code Here

    Resolver resolver = new Resolver();

    // configure roots
    XRD eqRoot = createAuthRoot("http://equal.xri.net/");
    eqRoot.setCanonicalID(new CanonicalID("="));
    Status eqRootStatus = new Status(Status.SUCCESS);
    eqRootStatus.setCID(Status.CID_VERIFIED);
    eqRoot.setStatus(eqRootStatus);
    resolver.setAuthority("=", eqRoot);

    XRD atRoot = createAuthRoot("http://at.xri.net/");
    atRoot.setCanonicalID(new CanonicalID("@"));
    Status atRootStatus = new Status(Status.SUCCESS);
    atRootStatus.setCID(Status.CID_VERIFIED);
    atRoot.setStatus(atRootStatus);
    resolver.setAuthority("@", atRoot);

    return resolver;
  }
View Full Code Here

            // if we got the nonexistent "command" return a not found
            if (uri.getPath().indexOf("!nonexistent") >= 0)
            {
                XRD xrd = new XRD();
                xrd.setQuery("!nonexistent");
                xrd.setStatus(new Status(Status.AUTH_RES_NOT_FOUND));
                XRDS xrds = new XRDS();
                xrds.add(xrd);
                return new ResolvedHttpResponse(new ByteArrayInputStream(xrds.toString().getBytes()));
            }

            XRDS oDescs = new XRDS();

            // just the same response always
            XRD oFoo = new XRD();
            oFoo.setQuery("!foo");
            oFoo.setStatus(new Status(Status.SUCCESS));
            oDescs.add(oFoo);

            XRD oBar = new XRD();
            oBar.setQuery("!bar");
            oBar.setStatus(new Status(Status.SUCCESS));
            oDescs.add(oBar);

            if (uri.getPath().indexOf("!baz") > 0) {
              XRD baz = new XRD();
              baz.setQuery("!baz");
              baz.setStatus(new Status(Status.AUTH_RES_NOT_FOUND, "Not found"));
                oDescs.add(baz);
            }
            return new ResolvedHttpResponse(new ByteArrayInputStream(oDescs.toString().getBytes()));

        } // getDataFromURI()
View Full Code Here

  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

        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

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.