Example usage for javax.xml.registry LifeCycleManager ORGANIZATION

List of usage examples for javax.xml.registry LifeCycleManager ORGANIZATION

Introduction

In this page you can find the example usage for javax.xml.registry LifeCycleManager ORGANIZATION.

Prototype

String ORGANIZATION

To view the source code for javax.xml.registry LifeCycleManager ORGANIZATION.

Click Source Link

Document

Constant representing the javax.xml.registry.infomodel.Organization interface.

Usage

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

public BulkResponse getRegistryObjects(Collection objectKeys, String objectType) throws JAXRException {
    IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
    //Convert into a vector of strings
    String[] keys = new String[objectKeys.size()];
    int currLoc = 0;
    for (Key key : (Collection<Key>) objectKeys) {
        String keyString = key.getId();
        keys[currLoc++] = keyString;//  w ww.  ja  va 2 s  .  co  m
    }
    LinkedHashSet<RegistryObject> col = new LinkedHashSet<RegistryObject>();
    LifeCycleManager lcm = registryService.getLifeCycleManagerImpl();

    if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType)) {
        try {
            TModelDetail tmodeldetail = registry.getTModelDetail(keys);
            List<TModel> tmodelList = tmodeldetail.getTModel();

            for (TModel tModel : tmodelList) {
                col.add(ScoutUddiV3JaxrHelper.getConcept(tModel, lcm));
            }

        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType)) {
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);

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

            if (ri != null) {
                BusinessInfos infos = ri.getBusinessInfos();
                if (infos != null) {
                    for (String key : keys) {
                        BusinessDetail detail = registry.getBusinessDetail(key);
                        col.add(((BusinessLifeCycleManagerV3Impl) registryService.getLifeCycleManagerImpl())
                                .createOrganization(detail));
                    }
                }
            }
        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType)) {
        try {
            TModelDetail tmodeldetail = registry.getTModelDetail(keys);
            List<TModel> tmodelList = tmodeldetail.getTModel();

            for (TModel tmodel : tmodelList) {
                col.add(ScoutUddiV3JaxrHelper.getConcept(tmodel, lcm));
            }

        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) {

        try {
            ServiceDetail serviceDetail = registry.getServiceDetail(keys);

            if (serviceDetail != null) {
                List<BusinessService> bizServiceList = serviceDetail.getBusinessService();

                for (BusinessService businessService : bizServiceList) {

                    Service service = getServiceFromBusinessService(businessService, lcm);

                    col.add(service);
                }
            }
        } catch (RegistryV3Exception e) {
            throw new JAXRException(e);
        }
    } else {
        throw new JAXRException("Unsupported type " + objectType + " for getRegistryObjects() in Apache Scout");
    }

    return new BulkResponseImpl(col);

}

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

public BulkResponse getRegistryObjects(String id) throws JAXRException {
    if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(id)) {
        IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);
        LinkedHashSet<Organization> orgs = null;
        try {/*from  w  w  w. ja va 2  s.c o  m*/
            RegisteredInfo ri = null;
            try {
                ri = registry.getRegisteredInfo(auth.getAuthInfo());
            } catch (RegistryV3Exception rve) {
                String username = getUsernameFromCredentials(con.getCredentials());
                if (AuthTokenV3Singleton.getToken(username) != null) {
                    AuthTokenV3Singleton.deleteAuthToken(username);
                }
                auth = getAuthToken(con, registry);
                ri = registry.getRegisteredInfo(auth.getAuthInfo());
            }

            if (ri != null && ri.getBusinessInfos() != null) {
                List<BusinessInfo> bizInfoList = ri.getBusinessInfos().getBusinessInfo();
                orgs = new LinkedHashSet<Organization>();
                for (BusinessInfo businessInfo : bizInfoList) {
                    BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
                    orgs.add(((BusinessLifeCycleManagerV3Impl) registryService.getLifeCycleManagerImpl())
                            .createOrganization(detail));
                }
            }

        } catch (RegistryV3Exception re) {
            throw new JAXRException(re);
        }
        return new BulkResponseImpl(orgs);
    } else if (LifeCycleManager.SERVICE.equalsIgnoreCase(id)) {
        List<String> a = new ArrayList<String>();
        a.add("%");

        BulkResponse br = this.findServices(null, null, a, null, null);

        return br;
    } else {
        throw new JAXRException("Unsupported type for getRegistryObjects() :" + id);
    }

}