List of usage examples for javax.xml.registry BulkResponse getCollection
Collection getCollection() throws JAXRException;
From source file:JAXRGetMyObjects.java
/** * Searches for objects owned by the user and * displays data about them./*from w w w .j ava2s. co m*/ * * @param username the username for the registry * @param password the password for the registry */ public void executeQuery(String username, String password) { RegistryService rs = null; BusinessQueryManager bqm = null; try { // Get registry service and query manager rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); System.out.println("Got registry service and " + "query manager"); // Get authorization from the registry PasswordAuthentication passwdAuth = new PasswordAuthentication(username, password.toCharArray()); HashSet<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>(); creds.add(passwdAuth); connection.setCredentials(creds); System.out.println("Established security credentials"); // Get all objects owned by me BulkResponse response = bqm.getRegistryObjects(); Collection objects = response.getCollection(); // Display information on the objects found if (objects.isEmpty()) { System.out.println("No objects found"); } else { for (Object o : objects) { RegistryObject obj = (RegistryObject) o; System.out.println("Object key id: " + getKey(obj)); System.out.println("Object name is: " + getName(obj)); System.out.println("Object description is: " + getDescription(obj)); // Print spacer between objects System.out.println(" --- "); } } } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:it.cnr.icar.eric.client.ui.thin.security.SecurityUtil.java
/** * * @param principalName//from w w w. ja v a 2 s . c om * @throws JAXRException * @return */ public User findUserByPrincipalName(Connection connection, String principalName) throws JAXRException { User user = null; DeclarativeQueryManager dqm = connection.getRegistryService().getDeclarativeQueryManager(); String queryString = "SELECT * " + "FROM user_ u, slot s " + "WHERE u.id = s.parent AND s.name_='" + CanonicalConstants.CANONICAL_PRINCIPAL_NAME_URI + "' AND value='" + principalName + "'"; Query query = dqm.createQuery(Query.QUERY_TYPE_SQL, queryString); BulkResponse br = dqm.executeQuery(query); Iterator<?> results = br.getCollection().iterator(); while (results.hasNext()) { user = (User) results.next(); break; } return user; }
From source file:it.cnr.icar.eric.client.ui.swing.JAXRClient.java
/** * Find classification schemes//www.j av a2 s. co m * * @return DOCUMENT ME! */ @SuppressWarnings({ "static-access", "rawtypes" }) Collection<?> getClassificationSchemes() { Collection<?> schemes = null; String errMsg = "Error getting ClassificationSchemes"; try { Map<String, String> queryParams = new HashMap<String, String>(); queryParams.put(BindingUtility.getInstance().CANONICAL_SLOT_QUERY_ID, BindingUtility.getInstance().CANONICAL_QUERY_GetClassificationSchemesById); Query query = getDeclarativeQueryManager().createQuery(Query.QUERY_TYPE_SQL); BulkResponse response = getDeclarativeQueryManager().executeQuery(query, queryParams); checkBulkResponse(response); schemes = response.getCollection(); } catch (JAXRException e) { RegistryBrowser.displayError(errMsg, e); schemes = new ArrayList(); } return schemes; }
From source file:JAXRQuery.java
/** * Searches for organizations containing a string and * displays data about them.//w w w.j a v a 2 s. c o m * * @param qString the string argument */ public void executeQuery(String qString) { RegistryService rs = null; BusinessQueryManager bqm = null; try { // Get registry service and query manager rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); System.out.println("Got registry service and query manager"); // Define find qualifiers and name patterns Collection<String> findQualifiers = new ArrayList<String>(); findQualifiers.add(SORT_BY_NAME_DESC); Collection<String> namePatterns = new ArrayList<String>(); namePatterns.add("%" + qString + "%"); // Find orgs with names that contain qString BulkResponse response = bqm.findOrganizations(findQualifiers, namePatterns, null, null, null, null); Collection orgs = response.getCollection(); // Display information about the organizations found int numOrgs = 0; if (orgs.isEmpty()) { System.out.println("No organizations found"); } else { for (Object o : orgs) { numOrgs++; Organization org = (Organization) o; System.out.println("Org name: " + getName(org)); System.out.println("Org description: " + getDescription(org)); System.out.println("Org key id: " + getKey(org)); // Display primary contact information User pc = org.getPrimaryContact(); if (pc != null) { PersonName pcName = pc.getPersonName(); System.out.println(" Contact name: " + pcName.getFullName()); Collection phNums = pc.getTelephoneNumbers(null); for (Object n : phNums) { TelephoneNumber num = (TelephoneNumber) n; System.out.println(" Phone number: " + num.getNumber()); } Collection eAddrs = pc.getEmailAddresses(); for (Object a : eAddrs) { EmailAddress eAd = (EmailAddress) a; System.out.println(" Email address: " + eAd.getAddress()); } } // Display service and binding information Collection services = org.getServices(); for (Object s : services) { Service svc = (Service) s; System.out.println(" Service name: " + getName(svc)); System.out.println(" Service description: " + getDescription(svc)); Collection serviceBindings = svc.getServiceBindings(); for (Object b : serviceBindings) { ServiceBinding sb = (ServiceBinding) b; System.out.println(" Binding description: " + getDescription(sb)); System.out.println(" Access URI: " + sb.getAccessURI()); } } // Print spacer between organizations System.out.println(" --- "); } } System.out.println("Found " + numOrgs + " organization(s)"); } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:JAXRQueryByNAICSClassification.java
/** * Searches for organizations corresponding to an NAICS * classification and displays data about them. *//* w w w.java 2 s . co m*/ public void executeQuery() { RegistryService rs = null; BusinessQueryManager bqm = null; BusinessLifeCycleManager blcm = null; try { // Get registry service and managers rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); blcm = rs.getBusinessLifeCycleManager(); System.out.println("Got registry service, query " + "manager, and lifecycle manager"); ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); // Find using an NAICS classification // Set classification scheme to NAICS, using // well-known UUID of ntis-gov:naics:1997 String uuid_naics = "uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"; ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(uuid_naics, LifeCycleManager.CLASSIFICATION_SCHEME); Collection<Classification> classifications = new ArrayList<Classification>(); if (cScheme != null) { // Create and add classification InternationalString sn = blcm.createInternationalString(bundle.getString("classification.name")); Classification classification = blcm.createClassification(cScheme, sn, bundle.getString("classification.value")); classifications.add(classification); } else { System.out.println("Classification scheme not found"); } BulkResponse response = bqm.findOrganizations(null, null, classifications, null, null, null); Collection orgs = response.getCollection(); // Display information about the organizations found int numOrgs = 0; if (orgs.isEmpty()) { System.out.println("No organizations found"); } else { for (Object o : orgs) { numOrgs++; Organization org = (Organization) o; System.out.println("Org name: " + getName(org)); System.out.println("Org description: " + getDescription(org)); System.out.println("Org key id: " + getKey(org)); // Display primary contact information User pc = org.getPrimaryContact(); if (pc != null) { PersonName pcName = pc.getPersonName(); System.out.println(" Contact name: " + pcName.getFullName()); Collection phNums = pc.getTelephoneNumbers(null); for (Object n : phNums) { TelephoneNumber num = (TelephoneNumber) n; System.out.println(" Phone number: " + num.getNumber()); } Collection eAddrs = pc.getEmailAddresses(); for (Object a : eAddrs) { EmailAddress eAd = (EmailAddress) a; System.out.println(" Email Address: " + eAd.getAddress()); } } // Display classifications Collection classList = org.getClassifications(); for (Object cl : classList) { Classification c = (Classification) cl; System.out.println(" Classification name: " + getName(c)); System.out.println(" Classification value: " + c.getValue()); ClassificationScheme sch = c.getClassificationScheme(); System.out.println(" Classification scheme key: " + getKey(sch)); } // Print spacer between organizations System.out.println(" --- "); } } System.out.println("Found " + numOrgs + " organization(s)"); } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:JAXRQueryByWSDLClassification.java
/** * Searches for organizations using a WSDL * classification and displays data about them. */* w w w. j av a 2 s . c o m*/ * @param qString the string argument */ public void executeQuery(String qString) { RegistryService rs = null; BusinessQueryManager bqm = null; BusinessLifeCycleManager blcm = null; try { // Get registry service and managers rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); blcm = rs.getBusinessLifeCycleManager(); System.out.println("Got registry service, query " + "manager, and lifecycle manager"); ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); /* * Find the uddi-org:types classification scheme defined * by the UDDI specification, using well-known key id. */ String uuid_types = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4"; ClassificationScheme uddiOrgTypes = (ClassificationScheme) bqm.getRegistryObject(uuid_types, LifeCycleManager.CLASSIFICATION_SCHEME); // Define name pattern Collection<String> namePatterns = new ArrayList<String>(); namePatterns.add("%" + qString + "%"); /* * Create a classification, specifying the scheme * and the taxonomy name and value defined for WSDL * documents by the UDDI specification. */ Classification wsdlSpecClassification = blcm.createClassification(uddiOrgTypes, blcm.createInternationalString("wsdlSpec"), "wsdlSpec"); Collection<Classification> classifications = new ArrayList<Classification>(); classifications.add(wsdlSpecClassification); // Find concepts BulkResponse br = bqm.findConcepts(null, namePatterns, classifications, null, null); Collection specConcepts = br.getCollection(); // Display information about the concepts found int numConcepts = 0; if (specConcepts.isEmpty()) { System.out.println("No WSDL specification concepts found"); } else { for (Object sc : specConcepts) { numConcepts++; Concept concept = (Concept) sc; String name = getName(concept); Collection links = concept.getExternalLinks(); System.out.println("\nSpecification Concept:\n\tName: " + name + "\n\tKey: " + getKey(concept) + "\n\tDescription: " + getDescription(concept)); if (links.size() > 0) { ExternalLink link = (ExternalLink) links.iterator().next(); System.out.println("\tURL of WSDL document: '" + link.getExternalURI() + "'"); } // Find organizations that use this concept Collection<Concept> specConcepts1 = new ArrayList<Concept>(); specConcepts1.add(concept); br = bqm.findOrganizations(null, null, null, specConcepts1, null, null); Collection orgs = br.getCollection(); // Display information about organizations if (!(orgs.isEmpty())) { System.out.println("Organizations using the '" + name + "' WSDL Specification:"); } else { System.out.println("No Organizations using the '" + name + "' WSDL Specification"); } for (Object o : orgs) { Organization org = (Organization) o; System.out.println("\tName: " + getName(org) + "\n\tKey: " + getKey(org) + "\n\tDescription: " + getDescription(org)); } } } System.out.println("Found " + numConcepts + " concepts"); } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:it.cnr.icar.eric.client.ui.thin.ExportBean.java
/** * This method is used to export a collection of selected objects from * the search results table.//w w w. jav a2 s. co m * * @return java.lang.String * Return status string: used by JSF for page navigation */ @SuppressWarnings("unchecked") public String doExport() { String status = "failure"; // Reset the zipFileName class member variable zipFileName = null; try { // Execute a compressed content filter query to get a zip file of content ArrayList<String> filterQueryIds = new ArrayList<String>(); filterQueryIds.add(BindingUtility.FREEBXML_REGISTRY_FILTER_QUERY_COMPRESSCONTENT); queryParams.put("$queryFilterIds", filterQueryIds); queryParams.put(CanonicalConstants.CANONICAL_SEARCH_DEPTH_PARAMETER, SearchPanelBean.getInstance().getSearchDepth()); Iterator<RegistryObjectBean> beanItr = getAllSelectedRegistryObjectBeans().iterator(); List<String> ids = new ArrayList<String>(); while (beanItr.hasNext()) { RegistryObjectBean rob = beanItr.next(); if (rob.getObjectType().equalsIgnoreCase("ExtrinsicObject")) { ids.add(rob.getId()); } } // Execute an arbitrary query with selected ids String queryId = CanonicalConstants.CANONICAL_QUERY_ArbitraryQuery; String sqlString = getExportSQLString(ids); queryParams.put(CanonicalConstants.CANONICAL_SLOT_QUERY_ID, queryId); queryParams.put("$query", sqlString); Query query = RegistryBrowser.getDQM().createQuery(Query.QUERY_TYPE_SQL); BulkResponse bResponse = RegistryBrowser.getDQM().executeQuery(query, queryParams); Collection<?> registryObjects = bResponse.getCollection(); // There should just be one EO containing the zip file Iterator<?> roItr = registryObjects.iterator(); if (roItr.hasNext()) { Object obj = roItr.next(); if (obj instanceof ExtrinsicObjectImpl) { ExtrinsicObjectImpl eo = (ExtrinsicObjectImpl) obj; // Get the zip filename and set it to this.zipFileName Slot filenameSlot = eo .getSlot(BindingUtility.FREEBXML_REGISTRY_FILTER_QUERY_COMPRESSCONTENT_FILENAME); if (filenameSlot != null) { Iterator<?> filenameItr = filenameSlot.getValues().iterator(); if (filenameItr.hasNext()) { zipFileName = (String) filenameItr.next(); } } status = "success"; } else { String msg = WebUIResourceBundle.getInstance().getString("message.ExpectedExtrinsicObject", new Object[] { obj }); RegistryObjectCollectionBean.getInstance().append(msg); status = "showExportPage"; } } else { String msg = WebUIResourceBundle.getInstance().getString("message.extrinsicObjectWithNoRI"); RegistryObjectCollectionBean.getInstance().append(msg); status = "showExportPage"; } } catch (Throwable t) { OutputExceptions.error(log, t); } finally { try { queryParams.clear(); } catch (Throwable t) { OutputExceptions.warn(log, t); } } return status; }
From source file:it.cnr.icar.eric.client.xml.registry.RegistryFacadeImpl.java
/** * Get the specified artifacts from Service Registry. * // w w w.ja v a 2 s.c om * @see [WSPROF] ebXML Registry Profile for Web Services: http://www.oasis-open.org/committees/document.php?document_id=14756 * @param queryId Identifies the discovery query that is preconfigured registry * @param queryParams key is a parameter name String (e.g. $service.name), value is a parameter value String as described by [WSPROF] * @return Set of javax.xml.registry.infomodel.RegistryObject. * * @throws JAXRException an exception thrown by JAXR Provider. */ @SuppressWarnings("static-access") public Collection<?> executeQuery(String queryId, Map<String, String> queryParams) throws JAXRException { if (getDeclarativeQueryManager() == null) { throw new JAXRException("setEndpoint MUST be called before setCredentials is called."); } Collection<?> registryObjects = null; queryParams.put(BindingUtility.getInstance().CANONICAL_SLOT_QUERY_ID, queryId); Query query = (getDeclarativeQueryManager()).createQuery(Query.QUERY_TYPE_SQL); BulkResponse bResponse = getDeclarativeQueryManager().executeQuery(query, queryParams); registryObjects = bResponse.getCollection(); return registryObjects; }
From source file:JAXRDeleteConcept.java
/** * Removes the organization with the specified key value. */*from w w w . j a v a2s. co m*/ * @param key the Key of the organization * @param username the username for the registry * @param password the password for the registry */ public void executeRemove(Key key, String username, String password) { BusinessLifeCycleManager blcm = null; try { blcm = rs.getBusinessLifeCycleManager(); // Get authorization from the registry PasswordAuthentication passwdAuth = new PasswordAuthentication(username, password.toCharArray()); HashSet<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>(); creds.add(passwdAuth); connection.setCredentials(creds); System.out.println("Established security credentials"); String id = key.getId(); System.out.println("Deleting concept with id " + id); Collection<Key> keys = new ArrayList<Key>(); keys.add(key); BulkResponse response = blcm.deleteConcepts(keys); Collection exceptions = response.getExceptions(); if (exceptions == null) { System.out.println("Concept deleted"); Collection retKeys = response.getCollection(); for (Object k : retKeys) { Key concKey = (Key) k; id = concKey.getId(); System.out.println("Concept key was " + id); } } else { for (Object e : exceptions) { Exception exception = (Exception) e; System.err.println("Exception on delete: " + exception.toString()); } } } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:JAXRDelete.java
/** * Removes the organization with the specified key value. *//www. j a v a 2s. c o m * @param key the Key of the organization * @param username the username for the registry * @param password the password for the registry */ public void executeRemove(Key key, String username, String password) { BusinessLifeCycleManager blcm = null; try { blcm = rs.getBusinessLifeCycleManager(); // Get authorization from the registry PasswordAuthentication passwdAuth = new PasswordAuthentication(username, password.toCharArray()); HashSet<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>(); creds.add(passwdAuth); connection.setCredentials(creds); System.out.println("Established security credentials"); String id = key.getId(); System.out.println("Deleting organization with id " + id); Collection<Key> keys = new ArrayList<Key>(); keys.add(key); BulkResponse response = blcm.deleteOrganizations(keys); Collection exceptions = response.getExceptions(); if (exceptions == null) { System.out.println("Organization deleted"); Collection retKeys = response.getCollection(); for (Object k : retKeys) { Key orgKey = (Key) k; id = orgKey.getId(); System.out.println("Organization key was " + id); } } else { for (Object e : exceptions) { Exception exception = (Exception) e; System.err.println("Exception on delete: " + exception.toString()); } } } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }