Example usage for javax.xml.registry BulkResponse getCollection

List of usage examples for javax.xml.registry BulkResponse getCollection

Introduction

In this page you can find the example usage for javax.xml.registry BulkResponse getCollection.

Prototype

Collection getCollection() throws JAXRException;

Source Link

Document

Get the Collection of objects returned as a response of a bulk operation.

Usage

From source file:org.apache.ws.scout.registry.BusinessQueryManagerImpl.java

public BulkResponse findCallerAssociations(Collection findQualifiers, Boolean confirmedByCaller,
        Boolean confirmedByOtherParty, Collection associationTypes) throws JAXRException {
    //TODO: Currently we just return all the Association objects owned by the caller
    IRegistry registry = (IRegistry) registryService.getRegistry();
    try {/*from  w  w  w .j a  v a  2  s .  c o m*/
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);

        AssertionStatusReport report = null;
        String confirm = "";
        boolean caller = confirmedByCaller.booleanValue();
        boolean other = confirmedByOtherParty.booleanValue();

        if (caller && other)
            confirm = Constants.COMPLETION_STATUS_COMPLETE;
        else if (!caller && other)
            confirm = Constants.COMPLETION_STATUS_FROMKEY_INCOMPLETE;
        else if (caller && !other)
            confirm = Constants.COMPLETION_STATUS_TOKEY_INCOMPLETE;

        report = null;
        try {
            report = registry.getAssertionStatusReport(auth.getAuthInfo(), confirm);
        } catch (RegistryException rve) {
            String username = getUsernameFromCredentials(con.getCredentials());
            if (AuthTokenSingleton.getToken(username) != null) {
                AuthTokenSingleton.deleteAuthToken(username);
            }
            auth = getAuthToken(con, registry);
            report = registry.getAssertionStatusReport(auth.getAuthInfo(), confirm);
        }

        List<AssertionStatusItem> assertionStatusItemList = report.getAssertionStatusItem();
        LinkedHashSet<Association> col = new LinkedHashSet<Association>();
        for (AssertionStatusItem asi : assertionStatusItemList) {
            String sourceKey = asi.getFromKey();
            String targetKey = asi.getToKey();
            Collection<Key> orgcol = new ArrayList<Key>();
            orgcol.add(new KeyImpl(sourceKey));
            orgcol.add(new KeyImpl(targetKey));
            BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
            Association asso = ScoutUddiJaxrHelper.getAssociation(bl.getCollection(),
                    registryService.getBusinessLifeCycleManager());
            //Set Confirmation
            ((AssociationImpl) asso).setConfirmedBySourceOwner(caller);
            ((AssociationImpl) asso).setConfirmedByTargetOwner(other);

            if (confirm != Constants.COMPLETION_STATUS_COMPLETE)
                ((AssociationImpl) asso).setConfirmed(false);

            Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
            KeyedReference keyr = asi.getKeyedReference();
            c.setKey(new KeyImpl(keyr.getTModelKey()));
            c.setName(new InternationalStringImpl(keyr.getKeyName()));
            c.setValue(keyr.getKeyValue());
            asso.setKey(new KeyImpl(keyr.getTModelKey())); //TODO:Validate this
            asso.setAssociationType(c);
            col.add(asso);
        }

        return new BulkResponseImpl(col);
    } catch (RegistryException e) {
        throw new JAXRException(e);
    }
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerImpl.java

/**
 * Gets the RegistryObjects owned by the caller. The objects
 * are returned as their concrete type (e.g. Organization, User etc.)
 *
 *  TODO - need to figure out what the set are.  This is just to get some
 *  basic functionality/*w ww.j av  a 2  s.  c o m*/
 *
 * @return BulkResponse
 * @throws JAXRException
 */
public BulkResponse getRegistryObjects() throws JAXRException {
    String types[] = { LifeCycleManager.ORGANIZATION, LifeCycleManager.SERVICE };

    LinkedHashSet<Object> c = new LinkedHashSet<Object>();

    for (int i = 0; i < types.length; i++) {
        try {
            BulkResponse bk = getRegistryObjects(types[i]);

            if (bk.getCollection() != null) {
                c.addAll(bk.getCollection());
            }
        } catch (JAXRException e) {
            log.debug("ignore - just a problem with that type? " + e.getMessage(), e);
        }
    }

    return new BulkResponseImpl(c);
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerV3Impl.java

public BulkResponse findAssociations(Collection findQualifiers, String sourceObjectId, String targetObjectId,
        Collection associationTypes) throws JAXRException {
    //TODO: Currently we just return all the Association objects owned by the caller
    IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
    try {//from w w w  . j a  v  a2 s .c o m
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);
        PublisherAssertions result = null;
        try {
            result = registry.getPublisherAssertions(auth.getAuthInfo());
        } catch (RegistryV3Exception rve) {
            String username = getUsernameFromCredentials(con.getCredentials());
            if (AuthTokenV3Singleton.getToken(username) != null) {
                AuthTokenV3Singleton.deleteAuthToken(username);
            }
            auth = getAuthToken(con, registry);
            result = registry.getPublisherAssertions(auth.getAuthInfo());
        }

        List<PublisherAssertion> publisherAssertionList = result.getPublisherAssertion();
        LinkedHashSet<Association> col = new LinkedHashSet<Association>();
        for (PublisherAssertion pas : publisherAssertionList) {
            String sourceKey = pas.getFromKey();
            String targetKey = pas.getToKey();
            Collection<Key> orgcol = new ArrayList<Key>();
            orgcol.add(new KeyImpl(sourceKey));
            orgcol.add(new KeyImpl(targetKey));
            BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
            Association asso = ScoutUddiV3JaxrHelper.getAssociation(bl.getCollection(),
                    registryService.getBusinessLifeCycleManager());
            KeyedReference keyr = pas.getKeyedReference();
            Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
            c.setName(new InternationalStringImpl(keyr.getKeyName()));
            c.setKey(new KeyImpl(keyr.getTModelKey()));
            c.setValue(keyr.getKeyValue());
            asso.setAssociationType(c);
            col.add(asso);
        }
        return new BulkResponseImpl(col);
    } catch (RegistryV3Exception e) {
        throw new JAXRException(e);
    }
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerV3Impl.java

public BulkResponse findCallerAssociations(Collection findQualifiers, Boolean confirmedByCaller,
        Boolean confirmedByOtherParty, Collection associationTypes) throws JAXRException {
    //TODO: Currently we just return all the Association objects owned by the caller
    IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
    try {/*from   w  w w.  j a v  a  2  s  .  com*/
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);

        AssertionStatusReport report = null;
        String confirm = "";
        boolean caller = confirmedByCaller.booleanValue();
        boolean other = confirmedByOtherParty.booleanValue();

        if (caller && other)
            confirm = Constants.COMPLETION_STATUS_COMPLETE;
        else if (!caller && other)
            confirm = Constants.COMPLETION_STATUS_FROMKEY_INCOMPLETE;
        else if (caller && !other)
            confirm = Constants.COMPLETION_STATUS_TOKEY_INCOMPLETE;

        try {
            report = registry.getAssertionStatusReport(auth.getAuthInfo(), confirm);
        } catch (RegistryV3Exception rve) {
            String username = getUsernameFromCredentials(con.getCredentials());
            if (AuthTokenV3Singleton.getToken(username) != null) {
                AuthTokenV3Singleton.deleteAuthToken(username);
            }
            auth = getAuthToken(con, registry);
            report = registry.getAssertionStatusReport(auth.getAuthInfo(), confirm);
        }

        List<AssertionStatusItem> assertionStatusItemList = report.getAssertionStatusItem();
        LinkedHashSet<Association> col = new LinkedHashSet<Association>();
        for (AssertionStatusItem asi : assertionStatusItemList) {
            String sourceKey = asi.getFromKey();
            String targetKey = asi.getToKey();
            Collection<Key> orgcol = new ArrayList<Key>();
            orgcol.add(new KeyImpl(sourceKey));
            orgcol.add(new KeyImpl(targetKey));
            BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
            Association asso = ScoutUddiV3JaxrHelper.getAssociation(bl.getCollection(),
                    registryService.getBusinessLifeCycleManager());
            //Set Confirmation
            ((AssociationImpl) asso).setConfirmedBySourceOwner(caller);
            ((AssociationImpl) asso).setConfirmedByTargetOwner(other);

            if (confirm != Constants.COMPLETION_STATUS_COMPLETE)
                ((AssociationImpl) asso).setConfirmed(false);

            Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
            KeyedReference keyr = asi.getKeyedReference();
            c.setKey(new KeyImpl(keyr.getTModelKey()));
            c.setName(new InternationalStringImpl(keyr.getKeyName()));
            c.setValue(keyr.getKeyValue());
            asso.setKey(new KeyImpl(keyr.getTModelKey())); //TODO:Validate this
            asso.setAssociationType(c);
            col.add(asso);
        }

        return new BulkResponseImpl(col);
    } catch (RegistryV3Exception e) {
        throw new JAXRException(e);
    }
}