List of usage examples for javax.xml.registry RegistryException RegistryException
public RegistryException(Throwable cause)
JAXRException
object initialized with the given Throwable
object. From source file:it.cnr.icar.eric.server.interfaces.soap.RegistrySAMLServlet.java
/** * This method is a copy of the respective method from RegistrySOAPServlet. *///w w w. j a v a 2s . c o m private RepositoryItem processIncomingAttachment(AttachmentPart ap) throws RegistryException { RepositoryItem ri = null; try { // ContentId is the id of the repositoryItem String id = WSS4JSecurityUtilSAML.convertContentIdToUUID(ap.getContentId()); if (log.isInfoEnabled()) { log.info(ServerResourceBundle.getInstance().getString("message.ProcessingAttachmentWithContentId", new Object[] { id })); } if (log.isDebugEnabled()) { log.debug("Processing attachment (RepositoryItem):\n" + ap.getContent().toString()); } DataHandler dh = ap.getDataHandler(); ri = new RepositoryItemImpl(id, dh); } catch (SOAPException e) { RegistryException toThrow = new RegistryException(e); toThrow.initCause(e); throw toThrow; } return ri; }
From source file:it.cnr.icar.eric.server.query.CompressContentQueryFilterPlugin.java
protected void resolveImportedExtrinsicObjects(ZipOutputStream zos, ServerRequestContext context, ExtrinsicObjectType targetEO, Collection<String> exportedIds, int depth) throws RegistryException { try {//ww w . ja v a 2s . c om Collection<ExtrinsicObjectType> eos = getAllImportedEOs(targetEO, context, depth); Iterator<ExtrinsicObjectType> eoItr = eos.iterator(); while (eoItr.hasNext()) { ExtrinsicObjectType importedEO = eoItr.next(); String importedEOId = importedEO.getId(); // Check for duplicate entries if (!exportedIds.contains(importedEOId)) { // Second: resolve RP hasMember associations. String zipEntryValue = getZipEntryValue(importedEO, context); RepositoryItem importedRI = null; try { importedRI = RepositoryManagerFactory.getInstance().getRepositoryManager() .getRepositoryItem(importedEOId); } catch (RepositoryItemNotFoundException ex) { // This is possible. The targetEO may have references to other EOs // with no RI. Continue processing. importedRI = null; } if (importedRI != null) { internalAddRepositoryItemToZipFile(importedRI, zos, zipEntryValue); exportedIds.add(importedEO.getId()); // Resolve imports of child EOs resolveImportedExtrinsicObjects(zos, context, importedEO, exportedIds, depth); } } } } catch (Throwable t) { throw new RegistryException(t); } }
From source file:it.cnr.icar.eric.server.security.authentication.AuthenticationServiceImpl.java
/** * Gets the User that is associated with the specified certificate. * /* w w w . j ava2 s. c o m*/ * @throws UserNotFoundException * when no matching User is found */ public UserType getUserFromCertificate(X509Certificate cert) throws RegistryException { UserType user = null; if (cert == null) { boolean noRegRequired = Boolean.valueOf( CommonProperties.getInstance().getProperty("eric.common.noUserRegistrationRequired", "false")) .booleanValue(); if (noRegRequired) { return registryOperator; } else { return registryGuest; } } // The registry expects the KeyInfo to either have the PublicKey or the // DN from the public key // In case of DN the registry can lookup the public key based on the DN @SuppressWarnings("unused") java.security.PublicKey publicKey = null; String alias = null; try { // lots of trace if (log.isTraceEnabled()) { log.trace("getUserFromCertificate cert:\n" + cert); StringBuffer storedCerts = new StringBuffer("Stored certificates:"); Enumeration<String> aliases = getKeyStore().aliases(); while (aliases.hasMoreElements()) { X509Certificate storedCert = (X509Certificate) getKeyStore() .getCertificate(aliases.nextElement()); storedCerts.append("\n").append(storedCert).append("\n--------"); } log.trace(storedCerts.toString()); } else if (log.isDebugEnabled()) { log.debug("getUserFromCertificate cert:\n" + cert); } alias = getKeyStore().getCertificateAlias(cert); if (alias == null) { if (log.isDebugEnabled()) { log.debug("Unknown certificate: " + cert.getSubjectDN().getName()); } throw new UserNotFoundException(cert.getSubjectDN().getName()); } if (log.isDebugEnabled()) { log.debug("Alias found for certificate:: " + alias); } } catch (KeyStoreException e) { throw new RegistryException(e); } user = getUserFromAlias(alias); return user; }
From source file:it.cnr.icar.eric.server.repository.hibernate.HibernateRepositoryManager.java
/** * Determines if RepositoryItem exists for specified key. * * @return true if a RepositoryItem exists for specified key, false otherwise * @param key The RepositoryItemKey.// w w w .j a va 2 s. c o m **/ public boolean itemExists(RepositoryItemKey key) throws RegistryException { boolean found = false; Transaction tx = null; String lid = key.getLid(); String versionName = key.getVersionName(); try { SessionContext sc = hu.getSessionContext(); Session s = sc.getSession(); //Need to call clear otherwise we get a cached ReposiytoryItemBean where the txn has committed //and Blob cannot be read any more. This will be better fixed when we pass ServerRequestContext //to each rm interface method and leverage leave txn management to ServerRequestContext. //See patch submitted for Sun Bug 6444810 on 6/28/2006 s.clear(); tx = s.beginTransaction(); // if item does not exists, error String findByID = "from RepositoryItemBean as rib where rib.key.lid = ? AND rib.key.versionName = ? "; Object[] params = { lid, versionName }; Type[] types = { Hibernate.STRING, Hibernate.STRING }; List<?> results = s.find(findByID, params, types); if (!results.isEmpty()) { found = true; } tx.commit(); } catch (Exception e) { String msg = ServerResourceBundle.getInstance().getString("message.FailedToSearchRepositoryItem", new Object[] { lid, versionName }); log.error(e, e); tryRollback(tx); throw new RegistryException(ServerResourceBundle.getInstance().getString("message.seeLogsForDetails", new Object[] { msg })); } finally { tryClose(); } return found; }
From source file:it.cnr.icar.eric.server.persistence.rdb.RegistryObjectDAO.java
/** * Sort registryObjectIds by their objectType. * //from w w w .jav a2s .c o m * @return The HashMap storing the objectType String as keys and List of ids * as values. For ExtrinsicObject, the objectType key is stored as * "ExtrinsicObject" rather than the objectType of the repository * items. */ public HashMap<String, List<String>> sortIdsByObjectType(List<?> registryObjectIds) throws RegistryException { HashMap<String, List<String>> map = new HashMap<String, List<String>>(); Statement stmt = null; try { if (registryObjectIds.size() > 0) { stmt = context.getConnection().createStatement(); StringBuffer str = new StringBuffer( "SELECT id, objectType FROM " + getTableName() + " WHERE id IN ( "); Iterator<?> iter = registryObjectIds.iterator(); while (iter.hasNext()) { String id = (String) iter.next(); str.append("'"); str.append(id); if (iter.hasNext()) { str.append("', "); } else { str.append("' )"); } } log.trace(ServerResourceBundle.getInstance().getString("message.stmtEquals", new Object[] { str })); ResultSet rs = stmt.executeQuery(str.toString()); ArrayList<String> adhocQuerysIds = new ArrayList<String>(); ArrayList<String> associationsIds = new ArrayList<String>(); ArrayList<String> auditableEventsIds = new ArrayList<String>(); ArrayList<String> classificationsIds = new ArrayList<String>(); ArrayList<String> classificationSchemesIds = new ArrayList<String>(); ArrayList<String> classificationNodesIds = new ArrayList<String>(); ArrayList<String> externalIdentifiersIds = new ArrayList<String>(); ArrayList<String> externalLinksIds = new ArrayList<String>(); ArrayList<String> extrinsicObjectsIds = new ArrayList<String>(); ArrayList<String> federationsIds = new ArrayList<String>(); ArrayList<String> organizationsIds = new ArrayList<String>(); ArrayList<String> registrysIds = new ArrayList<String>(); ArrayList<String> registryPackagesIds = new ArrayList<String>(); ArrayList<String> serviceBindingsIds = new ArrayList<String>(); ArrayList<String> servicesIds = new ArrayList<String>(); ArrayList<String> specificationLinksIds = new ArrayList<String>(); ArrayList<String> subscriptionsIds = new ArrayList<String>(); ArrayList<String> usersIds = new ArrayList<String>(); while (rs.next()) { String id = rs.getString(1); String objectType = rs.getString(2); // log.info(ServerResourceBundle.getInstance().getString("message.objectType!!!!!!!", // new Object[]{objectType})); if (objectType.equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_AdhocQuery)) { adhocQuerysIds.add(id); } else if (objectType.equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Association)) { associationsIds.add(id); } else if (objectType .equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_AuditableEvent)) { auditableEventsIds.add(id); } else if (objectType .equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Classification)) { classificationsIds.add(id); } else if (objectType .equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ClassificationScheme)) { classificationSchemesIds.add(id); } else if (objectType .equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ClassificationNode)) { classificationNodesIds.add(id); } else if (objectType .equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ExternalIdentifier)) { externalIdentifiersIds.add(id); } else if (objectType.equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ExternalLink)) { externalLinksIds.add(id); } else if (objectType.equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Federation)) { federationsIds.add(id); } else if (objectType.equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Organization)) { organizationsIds.add(id); } else if (objectType.equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Registry)) { registrysIds.add(id); } else if (objectType .equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_RegistryPackage)) { registryPackagesIds.add(id); } else if (objectType .equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ServiceBinding)) { serviceBindingsIds.add(id); } else if (objectType.equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Service)) { servicesIds.add(id); } else if (objectType .equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_SpecificationLink)) { specificationLinksIds.add(id); } else if (objectType.equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Subscription)) { subscriptionsIds.add(id); } else if (objectType.equalsIgnoreCase(BindingUtility.CANONICAL_OBJECT_TYPE_ID_User)) { usersIds.add(id); } else { // TODO: Fix dangerous assumption that is is an // ExtrinsicObject // Need to compare if objectType is a subType of // ExtrinsicObject or not extrinsicObjectsIds.add(id); } } // end looping ResultSet // Now put the List of id of varios RO type into the HashMap if (adhocQuerysIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_AdhocQuery, adhocQuerysIds); } if (associationsIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Association, associationsIds); } if (auditableEventsIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_AuditableEvent, auditableEventsIds); } if (classificationsIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Classification, classificationsIds); } if (classificationSchemesIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ClassificationScheme, classificationSchemesIds); } if (classificationNodesIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ClassificationNode, classificationNodesIds); } if (externalIdentifiersIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ExternalIdentifier, externalIdentifiersIds); } if (externalLinksIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ExternalLink, externalLinksIds); } if (federationsIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Federation, federationsIds); } if (organizationsIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Organization, organizationsIds); } if (registrysIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Registry, registrysIds); } if (registryPackagesIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_RegistryPackage, registryPackagesIds); } if (serviceBindingsIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ServiceBinding, serviceBindingsIds); } if (servicesIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Service, servicesIds); } if (specificationLinksIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_SpecificationLink, specificationLinksIds); } if (subscriptionsIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Subscription, subscriptionsIds); } if (usersIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_User, usersIds); } if (extrinsicObjectsIds.size() > 0) { map.put(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ExtrinsicObject, extrinsicObjectsIds); } } // end if checking the size of registryObjectsIds } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } finally { closeStatement(stmt); } return map; }
From source file:it.cnr.icar.eric.server.persistence.rdb.AbstractDAO.java
/** * Executes a Select statment that has an IN clause while * taking care to execute it in chunks to avoid scalability limits * in some databases (Oracle 10g limits terms in IN clause to 1000) * * Note: Caller is responsible for closing statement associated with each resultSet * in resultSets. //from w w w . j a va 2 s . co m * * @param selectStmtTemplate a string representing the SELECT statment in a parameterized format consistent withebRR parameterized queries. * @return a List of Objects */ public List<ResultSet> executeBufferedSelectWithINClause(String selectStmtTemplate, List<?> terms, int termLimit) throws RegistryException { ArrayList<ResultSet> resultSets = new ArrayList<ResultSet>(); if (terms.size() == 0) { return resultSets; } Iterator<?> iter = terms.iterator(); try { //We need to count the number of terms in "IN" list. //We need to split the SQL Strings into chunks if there are too many terms. //Reason is that some database such as Oracle, do not allow the IN list is too long int termCounter = 0; StringBuffer inTerms = new StringBuffer(); while (iter.hasNext()) { String term = (String) iter.next(); if (iter.hasNext() && (termCounter < termLimit)) { inTerms.append("'" + term + "',"); } else { inTerms.append("'" + term + "' "); String sql = selectStmtTemplate.replaceAll("\\$InClauseTerms", inTerms.toString()); // xxx 120216 pa allow scrollable resultset for jump to end with rs.last() Statement stmt = context.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet rs = stmt.executeQuery(sql); resultSets.add(rs); termCounter = 0; inTerms = new StringBuffer(); } termCounter++; } } catch (SQLException e) { throw new RegistryException(e); } return resultSets; }
From source file:it.cnr.icar.eric.server.interfaces.rest.URLHandler.java
void writeRegistryObject(RegistryObjectType ebRegistryObjectType) throws IOException, RegistryException, ObjectNotFoundException { PrintWriter out = null;// w w w .j a v a 2s . c om try { log.info(ServerResourceBundle.getInstance().getString("message.FoundRegistryObjectWithId", new Object[] { ebRegistryObjectType.getId() })); response.setContentType("text/xml; charset=UTF-8"); out = response.getWriter(); // Marshaller marshaller = bu.rimFac.createMarshaller(); Marshaller marshaller = bu.getJAXBContext().createMarshaller(); JAXBElement<RegistryObjectType> ebRegistryObject = bu.rimFac.createRegistryObject(ebRegistryObjectType); marshaller.marshal(ebRegistryObject, out); } catch (JAXBException e) { throw new RegistryException(e); } finally { // silent procedure if (out != null) { out.close(); } } }
From source file:it.cnr.icar.eric.server.persistence.rdb.RegistryObjectDAO.java
/** * Return true if the RegistryObject exist */// w w w . j av a 2s . c om public boolean registryObjectExist(String id) throws RegistryException { PreparedStatement stmt = null; try { String sql = "SELECT id from RegistryObject where id=?"; stmt = context.getConnection().prepareStatement(sql); stmt.setString(1, id); ResultSet rs = stmt.executeQuery(); boolean result = false; if (rs.next()) { result = true; } return result; } catch (SQLException e) { throw new RegistryException(e); } finally { closeStatement(stmt); } }
From source file:it.cnr.icar.eric.server.lcm.versioning.VersionProcessor.java
@SuppressWarnings("static-access") public RegistryObjectType createRegistryObjectVersion(RegistryObjectType ebRegistryObjectType) throws RegistryException { RegistryObjectType ebRegistryObjectTypeNew = null; try {/*from w w w . j ava 2 s .co m*/ Utility util = Utility.getInstance(); RegistryObjectType lastVersion = getLatestVersionOfRegistryObject(ebRegistryObjectType); String nextVersion = null; if (lastVersion == null) { nextVersion = "1.1"; } else { nextVersion = nextVersion(lastVersion.getVersionInfo().getVersionName()); } ebRegistryObjectTypeNew = bu.cloneRegistryObject(ebRegistryObjectType); VersionInfoType nextVersionInfo = bu.rimFac.createVersionInfoType(); nextVersionInfo.setVersionName(nextVersion); //Set the comment from the request comment (per the spec) if (!context.getRegistryRequestStack().empty()) { nextVersionInfo.setComment(context.getCurrentRegistryRequest().getComment()); } ebRegistryObjectTypeNew.setVersionInfo(nextVersionInfo); //A new version must have a unique id String id = ebRegistryObjectType.getId(); String lid = ebRegistryObjectType.getLid(); String idNew = id; //Only change id if it already exists in versions //Need to preserve client supplied id in the case where lid is an //existing lid but id is new if (isIdInVersions(id)) { //Make id of next version be lid with ":nextVersion" as suffix, if this id is already in use in a version idNew = lid + ":" + nextVersion; //Utility.getInstance().createId(); ebRegistryObjectTypeNew.setId(idNew); //Add entry to idMap so old id and refs to it are mapped to idNew context.getIdMap().put(id, idNew); } //Add entry to context.newROVersionMap for later replacement context.getNewROVersionMap().put(ebRegistryObjectType, ebRegistryObjectTypeNew); //Assign new ids to all composed RegistryObjects within roNew Set<RegistryObjectType> composedObjects = bu.getComposedRegistryObjects(ebRegistryObjectTypeNew, -1); Iterator<RegistryObjectType> iter = composedObjects.iterator(); while (iter.hasNext()) { RegistryObjectType composedObject = iter.next(); //check for composed object if exist change the id and lid and //also update the idMap. if (objectExists(composedObject.getId())) { String oldId = composedObject.getId(); String newId = oldId + ":" + nextVersion; composedObject.setId(newId); composedObject.setLid(newId); context.getIdMap().put(oldId, newId); } String composedId = composedObject.getId(); String composedLid = composedObject.getLid(); String composedIdNew = composedId; if (!util.isValidRegistryId(composedId)) { // Replace the id if it's not a valid ID already composedIdNew = util.createId(); composedObject.setId(composedIdNew); // Add entry to idMap so old composedId and refs to it are mapped to composedIdNew context.getIdMap().put(composedId, composedIdNew); } if (composedLid == null || composedLid.trim().length() == 0) { composedObject.setLid(composedIdNew); } // Set the parent id of this composed object to point to the new parent bu.setParentIdForComposedObject(composedObject, idNew); } } catch (JAXRException e) { throw new RegistryException(e); } return ebRegistryObjectTypeNew; }
From source file:it.cnr.icar.eric.server.cms.CMSManagerImpl.java
/** * Gets the <code>ExtrinsicObjectType</code> as a stream of XML markup. * * @param eo an <code>ExtrinsicObjectType</code> value * @return a <code>StreamSource</code> value * @exception RegistryException if an error occurs *///w ww. j a v a 2 s .co m protected static StreamSource getAsStreamSource(ExtrinsicObjectType eo) throws RegistryException { log.trace("getAsStreamSource(ExtrinsicObjectType ) entered"); StreamSource src = null; try { StringWriter sw = new StringWriter(); Marshaller marshaller = bu.getJAXBContext().createMarshaller(); marshaller.marshal(eo, sw); StringReader reader = new StringReader(sw.toString()); src = new StreamSource(reader); } // these Exceptions should already be caught by Binding catch (JAXBException e) { throw new RegistryException(e); } return src; }