Example usage for javax.xml.registry JAXRException JAXRException

List of usage examples for javax.xml.registry JAXRException JAXRException

Introduction

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

Prototype

public JAXRException(Throwable cause) 

Source Link

Document

Constructs a JAXRException object initialized with the given Throwable object.

Usage

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

public BulkResponse findConcepts(Collection findQualifiers, Collection namePatterns, Collection classifications,
        Collection externalIdentifiers, Collection externalLinks) throws JAXRException {
    LinkedHashSet<Concept> col = new LinkedHashSet<Concept>();

    //Lets ask the uddi registry if it has the TModels
    IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
    FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
    Iterator iter = null;/*from   w  w w. java 2 s  .  c  o  m*/
    if (namePatterns != null)
        iter = namePatterns.iterator();
    while (iter.hasNext()) {
        String namestr = (String) iter.next();
        try {
            TModelList list = registry.findTModel(namestr,
                    ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications),
                    ScoutJaxrUddiV3Helper.getIdentifierBagFromExternalIdentifiers(externalIdentifiers),
                    juddiFindQualifiers, 10);

            if (list != null && list.getTModelInfos() != null) {
                List<TModelInfo> tmodelInfoList = list.getTModelInfos().getTModelInfo();
                if (tmodelInfoList != null) {
                    for (TModelInfo info : tmodelInfoList) {
                        col.add(ScoutUddiV3JaxrHelper.getConcept(info,
                                this.registryService.getBusinessLifeCycleManager()));
                    }
                }
            }
        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    }

    return new BulkResponseImpl(col);
}

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

public BulkResponse findServiceBindings(Key serviceKey, Collection findQualifiers, Collection classifications,
        Collection specifications) throws JAXRException {
    BulkResponseImpl blkRes = new BulkResponseImpl();

    IRegistryV3 iRegistry = (IRegistryV3) registryService.getRegistry();
    FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);

    try {// w w w .jav a  2 s  .  c om

        BindingDetail bindingDetail = iRegistry.findBinding(serviceKey.getId(),
                ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications),
                ScoutJaxrUddiV3Helper.getTModelBagFromSpecifications(specifications), juddiFindQualifiers,
                registryService.getMaxRows());

        /*
         * now convert  from jUDDI ServiceInfo objects to JAXR Services
         */
        if (bindingDetail != null) {

            List<BindingTemplate> bindingTemplateList = bindingDetail.getBindingTemplate();
            BindingTemplate[] bindarr = new BindingTemplate[bindingTemplateList.size()];
            bindingTemplateList.toArray(bindarr);

            LinkedHashSet<ServiceBinding> col = new LinkedHashSet<ServiceBinding>();

            for (int i = 0; bindarr != null && i < bindarr.length; i++) {
                BindingTemplate si = bindarr[i];
                ServiceBinding sb = ScoutUddiV3JaxrHelper.getServiceBinding(si,
                        registryService.getBusinessLifeCycleManager());
                col.add(sb);
                //Fill the Service object by making a call to registry
                Service s = (Service) getRegistryObject(serviceKey.getId(), LifeCycleManager.SERVICE);
                ((ServiceBindingImpl) sb).setService(s);
            }

            blkRes.setCollection(col);
        }
    } catch (RegistryV3Exception e) {
        throw new JAXRException(e.getLocalizedMessage());
    }

    return blkRes;
}

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

/**
 * Finds all Service objects that match all of the criteria specified by
 * the parameters of this call.  This is a logical AND operation between
 * all non-null parameters/*from  w  w w .j  a  va2s  .  c  o  m*/
 *
 * TODO - support findQualifiers, classifications and specifications
 *
 * @param orgKey
 * @param findQualifiers
 * @param namePatterns
 * @param classifications
 * @param specificationa
 * @return BulkResponse
 * @throws JAXRException
 */
public BulkResponse findServices(Key orgKey, Collection findQualifiers, Collection namePatterns,
        Collection classifications, Collection specificationa) throws JAXRException {
    BulkResponseImpl blkRes = new BulkResponseImpl();

    IRegistryV3 iRegistry = (IRegistryV3) registryService.getRegistry();
    FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
    Name[] juddiNames = mapNamePatterns(namePatterns);

    try {
        /*
         * hit the registry.  The key is not required for UDDI2
         */

        String id = null;

        if (orgKey != null) {
            id = orgKey.getId();
        }

        ServiceList serviceList = iRegistry.findService(id, juddiNames,
                ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications), null,
                juddiFindQualifiers, registryService.getMaxRows());

        /*
         * now convert  from jUDDI ServiceInfo objects to JAXR Services
         */
        if (serviceList != null) {

            ServiceInfos serviceInfos = serviceList.getServiceInfos();
            LinkedHashSet<Service> col = new LinkedHashSet<Service>();

            if (serviceInfos != null && serviceInfos.getServiceInfo() != null) {
                for (ServiceInfo si : serviceInfos.getServiceInfo()) {
                    Service srv = (Service) getRegistryObject(si.getServiceKey(), LifeCycleManager.SERVICE);
                    col.add(srv);
                }

            }
            blkRes.setCollection(col);
        }
    } catch (RegistryV3Exception e) {
        throw new JAXRException(e.getLocalizedMessage());
    }

    return blkRes;
}

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

public RegistryObject getRegistryObject(String id, String objectType) throws JAXRException {
    IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
    BusinessLifeCycleManager lcm = registryService.getBusinessLifeCycleManager();

    if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType)) {

        try {//from  w ww . ja  va 2s. com

            TModelDetail tmodeldetail = registry.getTModelDetail(id);
            Concept c = ScoutUddiV3JaxrHelper.getConcept(tmodeldetail, lcm);

            /*
             * now turn into a concrete ClassificationScheme
             */

            ClassificationScheme scheme = new ClassificationSchemeImpl(lcm);

            scheme.setName(c.getName());
            scheme.setDescription(c.getDescription());
            scheme.setKey(c.getKey());

            return scheme;
        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType)) {
        try {
            BusinessDetail orgdetail = registry.getBusinessDetail(id);
            return ScoutUddiV3JaxrHelper.getOrganization(orgdetail, lcm);
        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }

    } else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType)) {

        try {
            TModelDetail tmodeldetail = registry.getTModelDetail(id);
            return ScoutUddiV3JaxrHelper.getConcept(tmodeldetail, lcm);
        } catch (RegistryV3Exception e) {
            throw new JAXRException(e.getLocalizedMessage());
        }
    } else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) {

        try {
            ServiceDetail sd = registry.getServiceDetail(id);
            if (sd != null && sd.getBusinessService() != null) {
                for (BusinessService businessService : sd.getBusinessService()) {
                    Service service = getServiceFromBusinessService(businessService, lcm);
                    return service;
                }
            }
        } catch (RegistryV3Exception e) {
            throw new RuntimeException(e);
        }
    }

    return null;
}

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;/*from  w ww  .  j a 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  www . j a 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);
    }

}

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

/**
  * Get the Auth Token from the registry
  *//from   w w w.j  a  v  a 2  s  .  c o m
  * @param connection
  * @param ireg
  * @return auth token
  * @throws JAXRException
  */
private AuthToken getAuthToken(ConnectionImpl connection, IRegistryV3 ireg) throws JAXRException {
    Set creds = connection.getCredentials();
    Iterator it = creds.iterator();
    String username = "", pwd = "";
    while (it.hasNext()) {
        PasswordAuthentication pass = (PasswordAuthentication) it.next();
        username = pass.getUserName();
        pwd = new String(pass.getPassword());
    }

    if (AuthTokenV3Singleton.getToken(username) != null) {
        return (AuthToken) AuthTokenV3Singleton.getToken(username);
    }

    AuthToken token = null;
    try {
        token = ireg.getAuthToken(username, pwd);
    } catch (Exception e) {
        throw new JAXRException(e);
    }
    AuthTokenV3Singleton.addAuthToken(username, token);

    return token;
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

public static BusinessService getBusinessServiceFromJAXRService(Service service) throws JAXRException {
    BusinessService bs = objectFactory.createBusinessService();
    try {/*w ww.  j av  a2  s.com*/
        InternationalString iname = service.getName();

        addNames(bs.getName(), iname);

        InternationalString idesc = service.getDescription();

        addDescriptions(bs.getDescription(), idesc);

        Organization o = service.getProvidingOrganization();

        /*
         * there may not always be a key...
         */
        if (o != null) {
            Key k = o.getKey();

            if (k != null && k.getId() != null) {
                bs.setBusinessKey(k.getId());
            }

        } else {
            /*
             * gmj - I *think* this is the right thing to do
             */
            throw new JAXRException("Service has no associated organization");
        }

        if (service.getKey() != null && service.getKey().getId() != null) {
            bs.setServiceKey(service.getKey().getId());
        } else {
            bs.setServiceKey("");
        }

        CategoryBag catBag = getCategoryBagFromClassifications(service.getClassifications());
        if (catBag != null) {
            bs.setCategoryBag(catBag);
        }

        //Add the ServiceBinding information
        BindingTemplates bt = getBindingTemplates(service.getServiceBindings());
        if (bt != null) {
            bs.setBindingTemplates(bt);
        }

        log.debug("BusinessService=" + bs.toString());
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return bs;
}

From source file:org.freebxml.omar.common.BindingUtility.java

public String getObjectTypeId(String rimClassName) throws JAXRException {
    String objectTypeId = null;/*from   w w  w . ja  v a  2  s . c  om*/

    try {
        Class clazz = this.getClass();
        Field field = clazz.getField("CANONICAL_OBJECT_TYPE_ID_" + rimClassName);
        Object obj = field.get(this);
        objectTypeId = (String) obj;
    } catch (NoSuchFieldException e) {
        throw new JAXRException(e);
    } catch (SecurityException e) {
        throw new JAXRException(e);
    } catch (IllegalAccessException e) {
        throw new JAXRException(e);
    }

    return objectTypeId;
}

From source file:org.freebxml.omar.common.BindingUtility.java

/**
 * Get separate List of RegistryObjects and ObjectRefs.
 * Does not get composed objects./*from   w  ww . j av a 2s  .  c  o m*/
 */
public void getObjectRefsAndRegistryObjects(RegistryObjectListType objs, Map objectsMap, Map orefMap)
        throws JAXRException {

    if (objs != null) {
        List identifiables = objs.getIdentifiable();
        Iterator iter = identifiables.iterator();

        while (iter.hasNext()) {
            Object obj = iter.next();

            if (obj instanceof IdentifiableType) {
                IdentifiableType identifiable = (IdentifiableType) obj;

                if (identifiable instanceof RegistryObjectType) {
                    objectsMap.put(identifiable.getId(), identifiable);
                } else if (identifiable instanceof ObjectRefType) {
                    orefMap.put(identifiable.getId(), identifiable);
                }
            } else {
                throw new JAXRException("Excpecting an IdentifiableType, got:" + obj);
            }
        }
    }

}