List of usage examples for javax.xml.registry BulkResponse getExceptions
Collection getExceptions() throws JAXRException;
From source file:it.cnr.icar.eric.client.ui.swing.RegistryObjectsTableModel.java
@SuppressWarnings("unchecked") void update(BulkResponse response) { Collection<Object> registryObjects = new ArrayList<Object>(); try {// w ww . j a v a 2 s .c o m // check for errors Collection<?> exceptions = response.getExceptions(); if (exceptions != null) { String errMsg = resourceBundle.getString("error.registryRequest"); Iterator<?> iter = exceptions.iterator(); Exception exception = null; while (iter.hasNext()) { exception = (Exception) iter.next(); RegistryBrowser.displayError(errMsg, exception); } } // check for objects // collection may be empty if there were errors registryObjects.addAll(response.getCollection()); //Get the most specific object type that is common to all RegistryObjects Concept commonObjectType = UIUtility.getInstance().getCommonObjectType(registryObjects); //Dynamically update model configuration basd upon objectType updateConfiguration(commonObjectType); } catch (JAXRException e) { RegistryBrowser.displayError(e); } if (registryObjects.isEmpty()) { JOptionPane.showMessageDialog(null, resourceBundle.getString("message.noObjects"), resourceBundle.getString("title.registryBrowser.java"), JOptionPane.INFORMATION_MESSAGE); } setRegistryObjects(registryObjects); }
From source file:it.cnr.icar.eric.client.ui.thin.jsf.ClassSchemeGraphBean.java
@SuppressWarnings({ "static-access", "unchecked" }) public Collection<?> getClassSchemes() { Collection<?> classSchemes = null; try {//from w w w. ja v a2s .c o m HashMap<String, String> queryParams = new HashMap<String, String>(); queryParams.put(BindingUtility.getInstance().CANONICAL_SLOT_QUERY_ID, BindingUtility.getInstance().CANONICAL_QUERY_GetClassificationSchemesById); Query query = ((DeclarativeQueryManagerImpl) dqm).createQuery(Query.QUERY_TYPE_SQL); BulkResponse bResponse = ((DeclarativeQueryManagerImpl) dqm).executeQuery(query, queryParams); Collection<?> exceptions = bResponse.getExceptions(); //TO DO: forward exceptions to an error JSP if (exceptions != null) { Iterator<?> iter = exceptions.iterator(); Exception exception = null; @SuppressWarnings("unused") StringBuffer sb2 = new StringBuffer(WebUIResourceBundle.getInstance().getString("errorExecQuery")); while (iter.hasNext()) { exception = (Exception) iter.next(); } log.error("\n" + exception.getMessage()); } // Filter hidden schemes here. classSchemes = filterHiddenSchemes(bResponse.getCollection()); } catch (Throwable t) { log.error(t.getMessage()); } return classSchemes; }
From source file:JAXRPublishHelloOrg.java
/** * Creates an organization, its classification, and its * services, and saves it to the registry. *//from w w w . j a v a 2s . co m * @param username the username for the registry * @param password the password for the registry */ public void executePublish(String uuidString, String username, String password) { RegistryService rs = null; BusinessLifeCycleManager blcm = null; BusinessQueryManager bqm = 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 life cycle 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"); ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); // Create organization name and description InternationalString s = blcm.createInternationalString(bundle.getString("wsdlorg.name")); Organization org = blcm.createOrganization(s); s = blcm.createInternationalString(bundle.getString("wsdlorg.description")); org.setDescription(s); // Create primary contact, set name User primaryContact = blcm.createUser(); PersonName pName = blcm.createPersonName(bundle.getString("wsdlorg.person.name")); primaryContact.setPersonName(pName); s = blcm.createInternationalString(bundle.getString("wsdlorg.person.description")); primaryContact.setDescription(s); // Set primary contact phone number TelephoneNumber tNum = blcm.createTelephoneNumber(); tNum.setNumber(bundle.getString("wsdlorg.phone")); Collection<TelephoneNumber> phoneNums = new ArrayList<TelephoneNumber>(); phoneNums.add(tNum); primaryContact.setTelephoneNumbers(phoneNums); // Set primary contact email address EmailAddress emailAddress = blcm.createEmailAddress(bundle.getString("wsdlorg.email.address")); Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>(); emailAddresses.add(emailAddress); primaryContact.setEmailAddresses(emailAddresses); // Set primary contact for organization org.setPrimaryContact(primaryContact); // Create services and service Collection<Service> services = new ArrayList<Service>(); s = blcm.createInternationalString(bundle.getString("wsdlorg.svc.name")); Service service = blcm.createService(s); s = blcm.createInternationalString(bundle.getString("wsdlorg.svc.description")); service.setDescription(s); // Create service bindings Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>(); ServiceBinding binding = blcm.createServiceBinding(); s = blcm.createInternationalString(bundle.getString("wsdlorg.svcbnd.description")); binding.setDescription(s); binding.setAccessURI(bundle.getString("wsdlorg.svcbnd.uri")); /* * 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); /* * 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"); // Define classifications Collection<Classification> classifications = new ArrayList<Classification>(); classifications.add(wsdlSpecClassification); // Find the concept by its UUID Concept specConcept = (Concept) bqm.getRegistryObject(uuidString, LifeCycleManager.CONCEPT); // If we found the concept, we can save the organization if (specConcept != null) { String name = getName(specConcept); Collection links = specConcept.getExternalLinks(); System.out.println("\nSpecification Concept:\n\tName: " + name + "\n\tKey: " + getKey(specConcept)); if (links.size() > 0) { ExternalLink link = (ExternalLink) links.iterator().next(); System.out.println("\tURL of WSDL document: '" + link.getExternalURI() + "'"); } // Now set the specification link for the service binding SpecificationLink specLink = blcm.createSpecificationLink(); specLink.setSpecificationObject(specConcept); binding.addSpecificationLink(specLink); serviceBindings.add(binding); // Add service bindings to service service.addServiceBindings(serviceBindings); // Add service to services, then add services to organization services.add(service); org.addServices(services); // Add organization and submit to registry // Retrieve key if successful Collection<Organization> orgs = new ArrayList<Organization>(); orgs.add(org); BulkResponse response = blcm.saveOrganizations(orgs); Collection exceptions = response.getExceptions(); if (exceptions == null) { System.out.println("Organization saved"); Collection keys = response.getCollection(); for (Object k : keys) { Key orgKey = (Key) k; String id = orgKey.getId(); System.out.println("Organization key is " + id); } } else { for (Object e : exceptions) { Exception exception = (Exception) e; System.err.println("Exception on save: " + exception.toString()); } } } else { System.out.println("Specified concept not found, " + "organization not saved"); } } 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.jsf.ExplorerGraphBean.java
private boolean hasChildren(String id) throws JAXRException { boolean hasChildren = false; String queryString = "SELECT child.* FROM RegistryPackage child, RegistryPackage parent, Association ass WHERE (parent.id = '" + id + "') AND (ass.associationType='" + CanonicalSchemes.CANONICAL_ASSOCIATION_TYPE_ID_HasMember + "' AND ass.sourceObject = parent.id AND ass.targetObject = child.id) "; Query query = dqm.createQuery(Query.QUERY_TYPE_SQL, queryString); BulkResponse bResponse = dqm.executeQuery(query); Collection<?> exceptions = bResponse.getExceptions(); //TO DO: forward exceptions to an error JSP handleExceptions(exceptions);/*from www . java2 s . c o m*/ Collection<?> registryObjects = bResponse.getCollection(); if (id.equals(CanonicalConstants.CANONICAL_USERDATA_FOLDER_ID)) { hasChildren = true; } else { hasChildren = (registryObjects != null && registryObjects.size() > 0); } return hasChildren; }
From source file:it.cnr.icar.eric.client.ui.thin.jsf.ExplorerGraphBean.java
private void loadChildRegistryPackages(RegistryObjectNode parentNode) throws JAXRException { String id = parentNode.getId(); String queryString = "SELECT child.* FROM RegistryPackage child, RegistryPackage parent, Association ass WHERE (parent.id = '" + id + "') AND (ass.associationType='" + CanonicalSchemes.CANONICAL_ASSOCIATION_TYPE_ID_HasMember + "' AND ass.sourceObject = parent.id AND ass.targetObject = child.id) "; Query query = dqm.createQuery(Query.QUERY_TYPE_SQL, queryString); BulkResponse bResponse = dqm.executeQuery(query); Collection<?> exceptions = bResponse.getExceptions(); //TO DO: forward exceptions to an error JSP handleExceptions(exceptions);/*from www . j av a 2s. c om*/ Collection<?> registryObjects = bResponse.getCollection(); Node node = null; Iterator<?> itr = registryObjects.iterator(); while (itr.hasNext()) { RegistryPackage childPackage = (RegistryPackage) itr.next(); node = new RegistryObjectNode(childPackage); node.setHasChild(hasChildren(node.getId())); parentNode.addChild(node); } if (node != null) { node.setLast(true); if (node.getPath().equalsIgnoreCase(pathOfSelectedNode)) { node.setSelected(true); } } }
From source file:it.cnr.icar.eric.client.ui.thin.jsf.ExplorerGraphBean.java
public void loadRegistryObjects(RegistryObjectNode parentNode) throws JAXRException, Exception { SearchPanelBean.getInstance().doClear(); @SuppressWarnings("unused") int childCount = parentNode.getChildCount(); String queryString = null;/* ww w . j av a2 s . c o m*/ if (parentNode.getRegistryObject() instanceof RegistryPackage) { if ((parentNode).getRegistryObjectType() == null) { // If the registry object type is null, it means we need to look // for child RegistryPackages. Note: this is a lower priority // candidate for server side caching String id = parentNode.getId(); queryString = "SELECT ro.* FROM RegistryObject ro, RegistryPackage p, Association ass WHERE (p.id = '" + id + "') AND (ass.associationType='" + CanonicalSchemes.CANONICAL_ASSOCIATION_TYPE_ID_HasMember + "' AND ass.sourceObject = p.id AND ass.targetObject = ro.id) "; } else { // If the registry object type is not null, it means we need to look // query for all ROs with the type contained in the parent node String type = (parentNode).getRegistryObjectType().getPath(); queryString = "SELECT ro.* FROM RegistryObject ro WHERE " + "objecttype IN " + "(SELECT id FROM ClassificationNode WHERE path LIKE '" + type + "' OR path LIKE '" + type + "/%')"; } Query query = dqm.createQuery(Query.QUERY_TYPE_SQL, queryString); int maxResults = RegistryObjectCollectionBean.getInstance().getScrollerBean() .getNumberOfSearchResults(); maxResults = maxResults * 10; IterativeQueryParams iqParams = new IterativeQueryParams(0, maxResults); BulkResponse bResponse = ((DeclarativeQueryManagerImpl) dqm).executeQuery(query, null, iqParams); Collection<?> exceptions = bResponse.getExceptions(); //TO DO: forward exceptions to an error JSP handleExceptions(exceptions); RegistryObjectCollectionBean.getInstance().handleRegistryObjects(bResponse); } else { String id = parentNode.getId(); RegistryObject ro = null; if ((parentNode).getRegistryObject() instanceof ClassificationScheme) { ro = dqm.getRegistryObject(id, "ClassificationScheme"); } else if ((parentNode).getRegistryObject() instanceof Concept) { ro = dqm.getRegistryObject(id, "ClassificationNode"); } else { ro = dqm.getRegistryObject(id); } Collection<RegistryObject> ros = new ArrayList<RegistryObject>(); ros.add(ro); RegistryObjectCollectionBean.getInstance().handleRegistryObjects(ros); } RegistryObjectCollectionBean.getInstance().setNode(parentNode); }
From source file:it.cnr.icar.eric.client.xml.registry.infomodel.ExtrinsicObjectImpl.java
public void removeRepositoryItem() throws javax.xml.registry.JAXRException { //TODO: mark object as dirty and remove RepositoryItem only on save // For now, removin repositoryItem from server immediatelly! BulkResponse resp = lcm.deleteObjects(Collections.singletonList(getKey()), null, BindingUtility.CANONICAL_DELETION_SCOPE_TYPE_ID_DeleteRepositoryItemOnly); if (BulkResponse.STATUS_SUCCESS == resp.getStatus()) { // This should be defined in JAXR 2.0 spec this.mimeType = null; this.repositoryItem = null; } else {/*from w w w .j a v a 2 s . c o m*/ Exception e = (Exception) resp.getExceptions().iterator().next(); throw new JAXRException(i18nUtil.getString("repositoryitem.removefailed", new String[] { getId() }), e); } }
From source file:it.cnr.icar.eric.client.ui.thin.RegistrationInfoBean.java
public String doRegister() { log.trace("doRegister started"); String result = "unknown"; FacesContext context = FacesContext.getCurrentInstance(); if (!doCheckAuthDetails()) { return result; }//w ww . j ava 2 s . com try { User user = (User) RegistryObjectCollectionBean.getInstance().getCurrentRegistryObjectBean() .getRegistryObject(); Collection<?> emails = user.getEmailAddresses(); ArrayList<EmailAddress> newList = new ArrayList<EmailAddress>(); Iterator<?> iters = emails.iterator(); while (iters.hasNext()) { EmailAddress email = (EmailAddress) iters.next(); if (null != email.getAddress() && email.getAddress().length() > 0) { newList.add(email); } } user.setEmailAddresses(newList); List<User> users = new ArrayList<User>(); users.add(user); BusinessLifeCycleManagerImpl blcm = RegistryBrowser.getBLCM(); handleAuth(); log.trace("calling saveObjects()"); BulkResponse resp = blcm.saveObjects(users); log.trace("saveObjects() returned"); if ((resp != null) && (resp.getStatus() != JAXRResponse.STATUS_SUCCESS)) { Collection<?> exceptions = resp.getExceptions(); if (exceptions != null && !exceptions.isEmpty()) { String msg = WebUIResourceBundle.getInstance().getString("errorRegistrationNeeded"); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); log.error(msg); Iterator<?> iter = exceptions.iterator(); while (iter.hasNext()) { Exception e = (Exception) iter.next(); OutputExceptions.error(log, e); } } else { String msg = WebUIResourceBundle.getInstance().getString("registrationFailed"); context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); log.error(WebUIResourceBundle.getInstance().getString("message.RegistrationFailed")); } result = "error"; } else { // ??? Is (null == resp) really success? result = "registered"; doNext(); } } catch (Throwable t) { OutputExceptions.error(log, WebUIResourceBundle.getInstance().getString("message.RegistrationFailed"), WebUIResourceBundle.getInstance().getString("registrationFailed"), t); result = "error"; } finally { try { RegistryBrowser.getInstance().clearCredentials(); } catch (Throwable t) { // User doesn't need to hear about a cleanup problem OutputExceptions.logWarning(log, WebUIResourceBundle.getInstance().getString("message.couldNotClearCredentials"), t); } } return result; }
From source file:it.cnr.icar.eric.client.xml.registry.infomodel.RegistryObjectImpl.java
/** * @return First exception in BulkResponse if there is one else null *//* w w w . j a v a2s . com*/ RegistryException getBulkResponseException(BulkResponse response) throws JAXRException { Collection<?> exceptions = response.getExceptions(); if (exceptions != null) { return (RegistryException) exceptions.iterator().next(); } return null; }
From source file:JAXRSaveClassificationScheme.java
/** * Creates a classification scheme and saves it to the * registry.//from w w w . ja v a 2 s. c o m * * @param username the username for the registry * @param password the password for the registry */ public void executePublish(String username, String password) { RegistryService rs = null; BusinessLifeCycleManager blcm = null; BusinessQueryManager bqm = null; try { rs = connection.getRegistryService(); blcm = rs.getBusinessLifeCycleManager(); bqm = rs.getBusinessQueryManager(); System.out.println("Got registry service, query " + "manager, and life cycle 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"); ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); // Create classification scheme InternationalString sn = blcm.createInternationalString(bundle.getString("postal.scheme.name")); InternationalString sd = blcm.createInternationalString(bundle.getString("postal.scheme.description")); ClassificationScheme postalScheme = blcm.createClassificationScheme(sn, sd); /* * 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); if (uddiOrgTypes != null) { InternationalString cn = blcm .createInternationalString(bundle.getString("postal.classification.name")); Classification classification = blcm.createClassification(uddiOrgTypes, cn, bundle.getString("postal.classification.value")); postalScheme.addClassification(classification); /* * Set link to location of postal scheme (fictitious) * so others can look it up. If the URI were valid, we * could use the createExternalLink method. */ ExternalLink externalLink = (ExternalLink) blcm.createObject(LifeCycleManager.EXTERNAL_LINK); externalLink.setValidateURI(false); externalLink.setExternalURI(bundle.getString("postal.scheme.link")); InternationalString is = blcm.createInternationalString(bundle.getString("postal.scheme.linkdesc")); externalLink.setDescription(is); postalScheme.addExternalLink(externalLink); // Add scheme and save it to registry // Retrieve key if successful Collection<ClassificationScheme> schemes = new ArrayList<ClassificationScheme>(); schemes.add(postalScheme); BulkResponse br = blcm.saveClassificationSchemes(schemes); if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) { System.out.println("Saved PostalAddress " + "ClassificationScheme"); Collection schemeKeys = br.getCollection(); for (Object k : schemeKeys) { Key key = (Key) k; System.out.println("The postalScheme key is " + key.getId()); System.out.println( "Use this key as the scheme uuid " + "in the postalconcepts.xml file\n and as the " + "argument to JAXRPublishPostal and " + "JAXRQueryPostal"); } } else { Collection exceptions = br.getExceptions(); for (Object e : exceptions) { Exception exception = (Exception) e; System.err.println("Exception on save: " + exception.toString()); } } } else { System.out.println("uddi-org:types not found. Unable to " + "save PostalAddress scheme."); } } catch (JAXRException jaxe) { jaxe.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }