import static com.softwareag.centrasite.api.csom.constants.MessageConstants.REG_OBJECT_PROPERTY_FAILURE; import static com.softwareag.centrasite.commons.util.RegistryUtil.getAsCollection; import static com.softwareag.centrasite.commons.util.RegistryUtil.isNotEmpty; import java.net.PasswordAuthentication; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Properties; import javax.xml.registry.BulkResponse; import javax.xml.registry.BusinessQueryManager; import javax.xml.registry.Connection; import javax.xml.registry.ConnectionFactory; import javax.xml.registry.JAXRException; import javax.xml.registry.RegistryService; import javax.xml.registry.infomodel.Association; import javax.xml.registry.infomodel.Concept; import javax.xml.registry.infomodel.RegistryObject; import javax.xml.registry.infomodel.Service; import javax.xml.registry.infomodel.ServiceBinding; import com.centrasite.jaxr.infomodel.Constants; import com.softwareag.centrasite.api.common.constants.CSOMConstants; import com.softwareag.centrasite.api.common.exception.CLLException; import com.softwareag.centrasite.api.csom.CentraSiteObject; import com.softwareag.centrasite.api.csom.CentraSiteObjectManager; import com.softwareag.centrasite.api.csom.CentraSiteRegistryObject; import com.softwareag.centrasite.api.csom.User; import com.softwareag.centrasite.api.service.CentraSiteService; import com.softwareag.centrasite.api.service.CentraSiteServiceFactory; import com.softwareag.centrasite.api.session.CentraSiteSession; import com.softwareag.centrasite.api.session.impl.CentraSiteSessionImpl; public class JAXRConnectionTest { private static String accessURI; public static void main(String[] args) throws JAXRException, CLLException { System.setProperty("javax.xml.registry.ConnectionFactoryClass", "com.centrasite.jaxr.ConnectionFactoryImpl"); ConnectionFactory connFactory = ConnectionFactory.newInstance(); Properties p = new Properties(); p.setProperty("javax.xml.registry.queryManagerURL", "http://localhost:53307/CentraSite/CentraSite"); p.setProperty("com.centrasite.jaxr.BrowserBehaviour", "yes"); connFactory.setProperties(p); Connection connection = connFactory.createConnection(); HashSet credentials = new HashSet(1); //Your UserName and Password goes here credentials.add(new PasswordAuthentication("", "".toCharArray())); connection.setCredentials(credentials); System.out.println("connection created"); RegistryService regService = connection.getRegistryService(); BusinessQueryManager bqManager = regService.getBusinessQueryManager(); // Service Type asset id which you like to get details. RegistryObject registryObject = bqManager.getRegistryObject("uddi:3f04f0fe-14bf-11ea-9f43-d998ed8a6438"); //Your UserName and Password goes here PasswordAuthentication authentication = new PasswordAuthentication("", "".toCharArray()); Collection authenticationCollection = new HashSet<>(); authenticationCollection.add(authentication); CentraSiteSession centraSiteSession = null; System.setProperty("com.softwareag.centrasite.api.configuration.basedir", "C:/SoftwareAGCentra/CentraSite/cast/cswebapps/BusinessUI"); try { CentraSiteService centraSiteService = CentraSiteServiceFactory.getInstance().createService(); centraSiteSession = centraSiteService.createSession(authenticationCollection); CentraSiteObjectManager centraSiteObjectManager = centraSiteSession.getCentraSiteObjectManager(); CentraSiteRegistryObject csro = (CentraSiteRegistryObject) centraSiteObjectManager .getObject(registryObject.getKey().getId()); // will list all watchers of the asset getSubscribers(csro); // will list all consumers of the asset getConsumers(csro, centraSiteObjectManager); // Technical Details is a Attribute Profile. So getting values by Attribute // Name. getTechnicalDetails(csro); // Provider Overview shows endpoints. Endpoints has to be formed by us. This // implementation will give us endpoints for only Service Type. getProviderOview(registryObject, centraSiteSession); // Consumer Overview shows API Keys, Virtual Service List with WSDL URL for // Service Type. getConsumerOverview(csro, centraSiteSession); } catch (CLLException e) { e.printStackTrace(); } finally { connection.close(); } } private static void getConsumers(CentraSiteRegistryObject csro, CentraSiteObjectManager centraSiteObjectManager) throws CLLException { Collection consumers = csro.getConsumers(); for (CentraSiteObject consumer : consumers) { CentraSiteRegistryObject consumerObj = (CentraSiteRegistryObject) centraSiteObjectManager .getObject(consumer.getId()); System.out.println(consumerObj.getName()); } } private static void getSubscribers(CentraSiteRegistryObject csro) throws CLLException { Collection subscribers = csro.getSubscribers(); for (User user : subscribers) { System.out.println(user.getName()); } } private static void getTechnicalDetails(CentraSiteRegistryObject csro) throws CLLException { Collection valuesWSDL = csro.getAttributeValue("WSDL URL"); System.out.println(valuesWSDL); Collection namespaces = csro.getAttributeValue("Namespace"); System.out.println(namespaces); Collection localNames = csro.getAttributeValue("Local-Name"); System.out.println(localNames); Collection operations = csro.getAttributeValue("Operations"); System.out.println(operations); } private static void getProviderOview(RegistryObject registryObject, CentraSiteSession centraSiteSession) throws JAXRException { if (registryObject instanceof Service) { Service service = (Service) registryObject; Iterator itr = service.getServiceBindings().iterator(); while (itr.hasNext()) { ServiceBinding serviceBinding = itr.next(); String bindingName = serviceBinding.getName().getValue(); String accessURI = serviceBinding.getAccessURI(); System.out.println(bindingName + " " + accessURI); } } } public static void getConsumerOverview(CentraSiteRegistryObject asset, CentraSiteSession centraSiteSession) throws CLLException { BusinessQueryManager bqm = ((CentraSiteSessionImpl) centraSiteSession).getBusinessQueryManager(); CentraSiteObjectManager centraSiteObjectManager = centraSiteSession.getCentraSiteObjectManager(); try { Concept contains = (Concept) bqm.getRegistryObject(Constants.ASSOCIATION_TYPE_KEY_Contains); BulkResponse assoResp = bqm.findAssociations(null, null, asset.getId(), getAsCollection(contains)); Collection associations = assoResp.getCollection(); if (isNotEmpty(associations)) { for (Association association : associations) { String aliasId = association.getSourceObject().getKey().getId(); CentraSiteRegistryObject alias = (CentraSiteRegistryObject) centraSiteObjectManager .getObject(aliasId); System.out.println(alias.getName() + " " + alias.getDisplayVersion()); List accessURIs = new ArrayList(alias.getAttributeValue("Access URIs")); System.out.println(accessURIs); String assetType = asset.getType().getId(); if (assetType.equals(CSOMConstants.OBJECT_TYPE_KEY_Service)) { Collection attributeValue = alias.getAttributeValue("Consumer Service WSDL"); System.out.println(attributeValue); } } } } catch (JAXRException e) { throw CLLException.createCLLException(REG_OBJECT_PROPERTY_FAILURE, e, "Aliases"); } } }