Example usage for javax.xml.registry.infomodel Association setKey

List of usage examples for javax.xml.registry.infomodel Association setKey

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel Association setKey.

Prototype

void setKey(Key key) throws JAXRException;

Source Link

Document

Sets the key representing the universally unique ID (UUID) for this object.

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 ava2 s  .  c om
        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.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 {// w w w  .  ja  v a 2 s. c om
        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);
    }
}