Package org.openxri.xml

Examples of org.openxri.xml.Service


            {
              Ref[] refs = new Ref[0];
                Service[] services = new Service[0];

                // IIOP-safe authority
                Service oSubAuth = new Service();

                moAdmin.registerSubsegment(
                    oAuth, "*free", refs, services,
                    oSubAuth);
            }
            catch (StoreException oEx)
            {
                oEx.printStackTrace();
                fail(
                    "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                    oEx.getExMessage() + "'.");
            }

        } // if(bIIOPFailure)

        bIIOPFailure = false;

        ///
        // Register a duplicate subsegment
        ///
        try
        {
          Ref[] refs = new Ref[0];
            Service[] services = new Service[0];

            // IIOP-safe authority
            Service oSubAuth = new Service();

            moAdmin.registerSubsegment(
                oAuth, "*foo", refs, services,
                oSubAuth);
            fail("Expected exception, but received none.");
        }
        catch (StoreException oEx)
        {
            assertEquals(StoreException.KEY_DUPNAME, oEx.getExKey());
        }

        ///
        // NEW Retrieve a descriptor
        ///
        try
        {
            String sDescriptor =
                moAdmin.lookup(oAuth, "*foo", false)
                       .getXRD().toString();
            assertNotNull(sDescriptor);
            assertTrue(sDescriptor.length() > 0);

            // XXX is the value correct?
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Lookup a subsegment
        ///
       
        try {
         
          oSubSegment = moAdmin.findSubSegment(oAuth, "*foo");
        } catch (StoreException oEx)
            {
                oEx.printStackTrace();
                fail(
                    "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                    oEx.getExMessage() + "'.");
            }
       
        ///
        // Release a subsegment
        ///
        try
        {
            moAdmin.releaseSubsegment(oSubSegment);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Re-Release a subsegment
        ///
        try
        {
            moAdmin.releaseSubsegment(oSubSegment);
            fail("Expected exception, but received none.");
        }
        catch (StoreException oEx)
        {
            assertEquals(StoreException.KEY_NOTFOUND, oEx.getExKey());
        }

        ///
        // NEW Retrieve a deleted descriptor
        ///
        try
        {
            String sDescriptor =
                moAdmin.lookup(oAuth, "*foo", false)
                       .getXRD().toString();
            assertNull(sDescriptor);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Re-Register a subsegment
        ///
        try
        {
          Ref[] refs = new Ref[0];
            Service[] services = new Service[0];

            // IIOP-safe authority
            Service oSubAuth = new Service();

            moAdmin.registerSubsegment(
                oAuth, "*foo", refs, services,
                oSubAuth);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // NEW Retrieve a re-registered descriptor
        ///
        try
        {
            String sDescriptor =
                moAdmin.lookup(oAuth, "*foo", false)
                       .getXRD().toString();
            assertNotNull(sDescriptor);
            assertTrue(sDescriptor.length() > 0);

            // XXX is the value correct?
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Register a local authority
        ///
        try
        {
          Ref[] refs = new Ref[0];
            Service[] services = new Service[0];

            SubSegment subSegment =
                moAdmin.registerLocalAuthority(
                    oAuth, "*boo", refs, services);

            assertNotNull(subSegment);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Delete a namespace (root authority)
        ///
        try
        {
            moAdmin.deleteRootAuthority("SomeNS");
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Delete an authority
        ///
        try
        {
            moAdmin.deleteAuthority(oAuth);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // Re-Delete an authority
        ///
        try
        {
            moAdmin.deleteAuthority(oAuth);
        }
        catch (StoreException oEx)
        {
            fail("Received unexpected exception " + oEx.getExMessage());
        }

        ///
        // Retrieve the list of namespaces (no leftovers)
        ///
        try
        {
            assertEquals(0, moAdmin.listRootAuthorities().length);
        }
        catch (StoreException oEx)
        {
            oEx.printStackTrace();
            fail(
                "Caught unexpected exception '" + oEx.getExKey() + "' '" +
                oEx.getExMessage() + "'.");
        }

        ///
        // One last, comprehensive test
        ///
        Authority oDefaultAuth = null;
        Authority oHostIDAuth = null;
        try
        {
          Ref[] oRefs = new Ref[1];
            Service[] oServices = new Service[1];

            oRefs[0] = new Ref();
            oRefs[0].setValue("http://www.myresolver.com/resolve?1234");
           
            // IIOP-safe Service structure
            oServices[0] = new Service();
            oServices[0].setType("xri:@epok/tdx/xrixns");
            oServices[0].setMediaType("text/xml");
            oServices[0].addURI("xri://@!42!3");

            oHostIDAuth = moAdmin.createRootAuthority("hostid");
            oDefaultAuth = moAdmin.createRootAuthority("default");

            SubSegment subSegment =
                moAdmin.registerLocalAuthority(
                    oDefaultAuth, "*email", oRefs, oServices
                    );

            // IIOP-safe Authority
            Service oEmptyAuth = new Service();

            moAdmin.registerSubsegment(
                oDefaultAuth, "*chetan", new Ref[0], new Service[0],
                oEmptyAuth);

View Full Code Here


            }

            Iterator it = services.iterator();
            while (it.hasNext())
            {
                Service srv = (Service)it.next();
                Iterator itURI = srv.getPrioritizedURIs().iterator();
                SEPUri sepURI;
                while (itURI.hasNext())
                {
                    sepURI = (SEPUri) itURI.next();
                    try
View Full Code Here

    // extract the host from the claimed id - this is the canonicalID
    // we expect in the site's XRD
    IdpIdentifier host = new IdpIdentifier(claimedId.getUrl().getHost());

    // find the <Service> element with type '.../describedby'
    Service service = getServiceForType(siteXrd.getXrd(), URI_TEMPLATE_TYPE);
    if (service == null) {
      throw new DiscoveryException("could not find service of type " +
          URI_TEMPLATE_TYPE + " in XRDS at location " +
          claimedId.getIdentifier());
    }
View Full Code Here

TOP

Related Classes of org.openxri.xml.Service

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.