Exemple #1
0
 /*
 ****************************************************************************
 * stuff()
 ****************************************************************************
 */
 /**
  * Adds the descriptors associated with an authority to the cache
  * @param oAuth - The Authority whose descriptors to store
  * @param oDescriptors - The descriptors of the subsegments in oAuth
  */
 public void stuff(XRIAuthority oAuth, XRDS oDescriptors)
 {
     for (int i = 0; i < oDescriptors.getNumChildren(); i++) {
         stuff(oAuth, oDescriptors.getDescriptorAt(i), i);
     }
 }
Exemple #2
0
            //    throws XRIResolutionException
            protected InputStream getDataFromURI(URI oURI, string query, ResolverFlags flags, ResolverState state)
            {
                // the path better be empty
                if ((oURI.getPath() != null) && (oURI.getPath().Length > 0))
                return null;

                XRD oDesc = new XRD();
                XRI oExternal = new XRI("xri://@foo");
                oDesc.addRef(new Ref(oExternal.toString()));
                XRDS oDescs = new XRDS();
                oDescs.add(oDesc);

                state.pushResolved(oURI.toString(), flags.toString(), oDesc.toString(), oURI);

                return new ByteArrayInputStream(oDescs.toString().getBytes());
            }
Exemple #3
0
            //throws XRIResolutionException
            /*
            ************************************************************************
            * getDataFromURI()
            ************************************************************************
            */
            /**
            *
            */
            protected InputStream getDataFromURI(URI uri, String query, ResolverFlags flags, ResolverState state)
            {
                // 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());
            }
Exemple #4
0
    } // addXRIDescriptor()

    /*
    ****************************************************************************
    * addXRIDescriptors()
    ****************************************************************************
    */ /**
    * Adds the specified XRI Descriptors to the chain
    */
    public void addXRIDescriptors(XRDS oDescriptors)
    {
        for (int i = 0; i < oDescriptors.getNumChildren(); i++)
        {
            addXRIDescriptor(oDescriptors.getDescriptorAt(i));
        }

    } // addXRIDescriptors()