Package org.openxri.xml

Examples of org.openxri.xml.XRD


      SubSegment subSegment;
      Authority authority;
     
      try {

        XRD xrd = new XRD();
       
        subSegment = openXRIStore.registerSubsegment(
            this.parentAuthority,
            this.name,
            xrd);
View Full Code Here


    @Override
    protected void onSubmit() {

      final Store openXRIStore = ((OpenXRIAdminApplication) this.getApplication()).getOpenXRIStore();

      XRD xrd = new XRD();
      Authority authority;
     
      try {

        authority = openXRIStore.createAuthority(xrd);
View Full Code Here

      XRDS xrds = resolveViaProxy(qxri, null, null, false, flags, state);
      return xrds.getFinalXRD();
    }

    XRDS xrds = resolveAuthority(qxri, flags, state);
    XRD finalXRD = xrds.getFinalXRD();
    if (flags.isUric()) {
      constructURIinXRD(finalXRD, qxri);
    }
    return finalXRD;
  }
View Full Code Here

  }

  public void testCache() throws Exception {

    XRI xri;
    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);

      assertNotNull(storeAuthority);
      xrd = storeAuthority.getXrd();
      assertNotNull(xrd);
      assertEquals(xrd.getQuery(), subSegment.toString());
    }
  }
View Full Code Here

  /**
   * This helper method simulates the actual resolution process. It returns an XRD for a subsegment.
   */
  public static XRD magicXriResolution(XRISubSegment subSegment) {

    XRD xrd;

    xrd = new XRD();
    xrd.setQuery(subSegment.toString());
    xrd.setExpires(new Date(new Date().getTime() + 3600000));

    return(xrd);
  }
View Full Code Here

      throw new StoreInternalException(ex, "Cannot access database.");
    }

    // run XRD through the CREATE pipeline

    XRD newXRD;

    try {

      if (createPipeline != null) {
View Full Code Here

      throw new StoreInternalException(ex, "Cannot access database.");
    }

    // run XRD through the CREATE pipeline

    XRD newXRD;

    try {

      if (createPipeline != null) {
View Full Code Here

      throw new StoreInternalException(ex, "Cannot access database.");
    }

    // run XRD through the CREATE pipeline

    XRD newXRD;

    try {

      if (createPipeline != null) {
View Full Code Here

    if (proxyURI != null)
      return resolveViaProxy(qxri, sepType, sepMediaType, true, flags, state);

    XRDS xrds = resolveAuthority(qxri, flags, state);
    XRD finalXRD = xrds.getFinalXRD();

    selectServiceFromXRD(xrds, finalXRD, qxri, sepType, sepMediaType, flags, state);
    if (flags.isUric()) {
      constructURIinXRD(xrds.getFinalXRD(), qxri);     
    }
View Full Code Here

    log.trace("resolveSEPToURIList('" + qxri + "', sepType=" + sepType
        + ", sepMediaType=" + sepMediaType + ", flags: " + flags + ")");

    // no need to do uric
    flags.setUric(false);
    XRD xrd = resolveSEPToXRD(qxri, sepType, sepMediaType, flags, state);
    if (xrd == null)
      return new ArrayList();

    if (xrd.getSelectedServices().getList().size() < 1) {
      log.error("SEP Selection succeeded but no Service found!?");
      return new ArrayList();
    }

    Service topService = (Service) xrd.getSelectedServices().getList().get(0);

    ArrayList urisOut = new ArrayList();
    ArrayList uris = topService.getPrioritizedURIs();
    for (int i = 0; uris != null && i < uris.size(); i++) {
      SEPUri uri = (SEPUri) uris.get(i);
View Full Code Here

TOP

Related Classes of org.openxri.xml.XRD

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.