Package org.openxri

Examples of org.openxri.GCSAuthority


        dummyService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none");
        dummyService.addType(Tags.SERVICE_AUTH_RES);
        dummyService.addURI("http://www.example.com/xri/resolve?id=1");
        oDummy.addService(dummyService);

        GCSAuthority oAuth = new GCSAuthority("@");
        oCache.stuff(oAuth, oDesc);
        assertTrue("Initial cache incorrect", oCache.getNumNodes() == 1);

        oCache.stuff(
            (XRIAuthority) AuthorityPath.buildAuthorityPath("@!a!b!foo"), oDummy);
View Full Code Here


        atAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none");
        atAuthService.addType(Tags.SERVICE_AUTH_RES);
        atAuthService.addURI("http://gcs.epok.net/xri/resolve?ns=at");
        oDesc.addService(atAuthService);

        GCSAuthority oAuth = new GCSAuthority("@");
        oCache.stuff(oAuth, oDesc);
        assertTrue("Initial cache incorrect", oCache.getNumNodes() == 1);

        oCache.setMaxSize(5);
View Full Code Here

      ServerException ex2 = new ServerInternalException("Unsupported encoding in namespace: " + ex.getMessage(), ex);
      log.warn(ex2);
      throw ex2;
    }

    XRIAuthority authorityPath = new GCSAuthority(utf8Namespace);

    Authority namespaceAuthority;

    try {
View Full Code Here

      ServerException ex2 = new ServerInternalException("Unsupported encoding in namespace: " + ex.getMessage(), ex);
      log.warn(ex2);
      throw ex2;
    }

    XRIAuthority authorityPath = new GCSAuthority(utf8Namespace);

    Authority parentAuthority;

    try {
View Full Code Here

    XRD xrd;

    // Let's say we want to resolve @free*earth*moon

    xri = new XRI("@free*earth*moon");
    GCSAuthority xriAuthority = (GCSAuthority) xri.getAuthorityPath();

    // We initialize the store by creating a root subsegment with an empty XRD (i.e. an entry point)

    SubSegment storeSubSegment = store.createRootSubSegment(xriAuthority.getGCSRoot(), new XRD());
    Authority storeAuthority = store.getSubSegmentAuthority(storeSubSegment);

    // We iterate through all subsegments of the XRI that we were given to resolve.

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

      XRISubSegment subSegment = xriAuthority.getSubSegmentAt(i);

      // Somehow we obtain an XRD for this subsegment

      xrd = magicXriResolution(subSegment);

      // Now we cache the XRD we just got. We do this by creating a new subsegment in the store.

      storeSubSegment = store.registerSubsegment(storeAuthority, subSegment.toString(), xrd);
      storeAuthority = store.getSubSegmentAuthority(storeSubSegment);
    }

    // Let's say a while later we want to resolve @free*earth*moon again... We find it in the store, yay!!!

    xri = new XRI("@free*earth*moon");
    xriAuthority = (GCSAuthority) xri.getAuthorityPath();

    storeAuthority = store.localLookup(xriAuthority);
    assertNotNull(storeAuthority);

    xrd = storeAuthority.getXrd();
    assertNotNull(xrd);

    assertEquals(xrd.getQuery(), "*moon");

    // We could also read the cache step by step, if we want to get the XRD for every subsegment.

    storeSubSegment = store.findRootSubSegment(xriAuthority.getGCSRoot());
    storeAuthority = store.getSubSegmentAuthority(storeSubSegment);

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

      XRISubSegment subSegment = xriAuthority.getSubSegmentAt(i);

      // Find the authority in the store for the current subsegment

      storeSubSegment = store.findSubSegment(storeAuthority, subSegment.toString());
      storeAuthority = store.getSubSegmentAuthority(storeSubSegment);
View Full Code Here

     * @param oDesc The descriptor for the "@" Authority
     * @deprecated
     */
    public void setAtAuthority(XRD oDesc)
    {
      GCSAuthority oAuth = new GCSAuthority("@");
      set(oAuth, oDesc);
     
    }
View Full Code Here

     * Sets the XRD for the "=" Authority.
     * @param oDesc The descriptor for the "=" Authority
     */
    public void setEqualsAuthority(XRD oDesc)
    {
      GCSAuthority oAuth = new GCSAuthority("=");
      set(oAuth, oDesc);
     
    }
View Full Code Here

    dummyService.addType(Tags.SERVICE_AUTH_RES);
    dummyService.addURI("http://www.example.com/xri/resolve?id=1");
    xrd1.addService(dummyService);

    try {
      GCSAuthority auth = new GCSAuthority("@");
      cache.put(auth.toString(), false, false, xrd.toString().getBytes("UTF-8"), 1000);
      assertTrue("Initial cache incorrect", cache.getSize() == 1);

      cache.put(
          AuthorityPath.buildAuthorityPath("@!a!b!foo").toString(), false, false, xrd1.toString().getBytes("UTF-8"), 1000);
      assertTrue("Cache size incorrect", cache.getSize() == 2);
View Full Code Here

    atAuthService.addType(Tags.SERVICE_AUTH_RES);
    atAuthService.addURI("http://gcs.epok.net/xri/resolve?ns=at");
    xrd.addService(atAuthService);

    try {
      GCSAuthority auth = new GCSAuthority("@");
      cache.put(auth.toString(), false, false, xrd.toString().getBytes("UTF-8"), 1000);
      assertTrue("Initial cache incorrect", cache.getSize() == 1);
    } catch (UnsupportedEncodingException e) {
      assertTrue("Unexpected exception" + e, false);
    }
View Full Code Here

      ServerException ex2 = new ServerInternalException("Unsupported encoding in namespace: " + ex.getMessage(), ex);
      log.warn("", ex2);
      throw ex2;
    }

    XRIAuthority authorityPath = new GCSAuthority(utf8Namespace);

    Authority namespaceAuthority;
    setParentQueryName(utf8Namespace);

    try {
View Full Code Here

TOP

Related Classes of org.openxri.GCSAuthority

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.