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.query.CompressContentQueryFilterPlugin.java
protected void addRepositoryItemToZipFile(RepositoryItem ri, ZipOutputStream zos, ServerRequestContext context, ExtrinsicObjectType eo, Collection<String> exportedIds, int depth) throws RegistryException { try {/*from w w w .ja v a 2s . c om*/ @SuppressWarnings("unused") String objectType = eo.getObjectType(); if (!exportedIds.contains(eo.getId())) { String zipEntryValue = getZipEntryValue(eo, context); internalAddRepositoryItemToZipFile(ri, zos, zipEntryValue); exportedIds.add(eo.getId()); // Resolve all dependent imported files using imports assoc resolveImportedExtrinsicObjects(zos, context, eo, exportedIds, depth); // Check if EO is an element contained in a different EO ExtrinsicObjectType eot = getContainedExtrinsicObject(eo, context); if (eot != null) { resolveImportedExtrinsicObjects(zos, context, eot, exportedIds, depth); } } } catch (RegistryException re) { throw re; } catch (Throwable t) { throw new RegistryException(t); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.AbstractDAO.java
/** * @see it.cnr.icar.eric.server.persistence.rdb.OMARDAO#update(org.oasis.ebxml.registry.bindings.rim.UserType, java.sql.Connection, java.util.List, java.util.HashMap) */// w w w . j a v a 2s . co m public void update(@SuppressWarnings("rawtypes") List objects) throws RegistryException { //Return immediatley if no objects to insert if (objects.size() == 0) { return; } log.trace(ServerResourceBundle.getInstance().getString("message.UpdatingRowsInTable", new Object[] { new Integer(objects.size()), getTableName() })); action = DAO_ACTION_UPDATE; Statement stmt = null; try { stmt = context.getConnection().createStatement(); Iterator<?> iter = objects.iterator(); while (iter.hasNext()) { Object obj = iter.next(); prepareToUpdate(obj); String str = getSQLStatementFragment(obj); log.trace("stmt = " + str); stmt.addBatch(str); } @SuppressWarnings("unused") int[] updateCounts = stmt.executeBatch(); iter = objects.iterator(); while (iter.hasNext()) { Object obj = iter.next(); onUpdate(obj); } } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } finally { closeStatement(stmt); } }
From source file:it.cnr.icar.eric.server.repository.hibernate.HibernateRepositoryManager.java
/** * Delete the repository item./*from ww w. ja va2 s .c om*/ * @param key Unique key for repository item * @throws RegistryException if the item does not exist */ public void delete(RepositoryItemKey key) throws RegistryException { Transaction tx = null; String lid = key.getLid(); String versionName = key.getVersionName(); try { SessionContext sc = hu.getSessionContext(); Session s = sc.getSession(); tx = s.beginTransaction(); if (log.isDebugEnabled()) { String message = "Deleting repository item: lid='" + lid + "' versionName='" + versionName + "'"; log.debug(message); } // if item does not exist, 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 }; int deleted = s.delete(findByID, params, types); if (deleted == 0) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.RepositoryItemDoesNotExist", new Object[] { lid, versionName })); } tx.commit(); } catch (RegistryException e) { tryRollback(tx); throw e; } catch (Exception e) { String msg = ServerResourceBundle.getInstance().getString("message.FailedToDeleteRepositoryItem", new Object[] { lid, versionName }); log.error(e, e); tryRollback(tx); throw new RegistryException(ServerResourceBundle.getInstance().getString("message.seeLogsForDetails", new Object[] { msg })); } finally { tryClose(); } }
From source file:it.cnr.icar.eric.server.query.QueryManagerImpl.java
/** * submitAdhocQuery/*from w w w . ja v a 2 s . c o m*/ */ @SuppressWarnings({ "static-access", "unchecked" }) public AdhocQueryResponse submitAdhocQuery(RequestContext context) throws RegistryException { AdhocQueryResponse ebAdhocQueryResponse = null; context = ServerRequestContext.convert(context); AdhocQueryRequest ebAdhocQueryRequest = (AdhocQueryRequest) ((ServerRequestContext) context) .getCurrentRegistryRequest(); ResponseOptionType ebResponseOptionType = ebAdhocQueryRequest.getResponseOption(); ReturnType returnType = ebResponseOptionType.getReturnType(); UserType user = ((ServerRequestContext) context).getUser(); // The result of the query RegistryObjectListType ebRegistryObjectListType = null; try { ebAdhocQueryResponse = null; // Process request for the case where it is a parameterized // invocation of a stored query processForParameterizedQuery((ServerRequestContext) context); // TODO: May need a better way than checking // getSpecialQueryResults() to know if specialQuery was called. if (((ServerRequestContext) context).getSpecialQueryResults() != null) { ebAdhocQueryResponse = processForSpecialQueryResults((ServerRequestContext) context); } else { // Check if it is a federated query and process it using // FederatedQueryManager if so. boolean isFederated = ebAdhocQueryRequest.isFederated(); if (isFederated) { // Initialize lazily. Otherwise we have an infinite create // loop if (fqm == null) { fqm = FederatedQueryManager.getInstance(); } ebAdhocQueryResponse = fqm.submitAdhocQuery((ServerRequestContext) context); } else { int startIndex = ebAdhocQueryRequest.getStartIndex().intValue(); int maxResults = ebAdhocQueryRequest.getMaxResults().intValue(); IterativeQueryParams paramHolder = new IterativeQueryParams(startIndex, maxResults); org.oasis.ebxml.registry.bindings.rim.AdhocQueryType adhocQuery = ebAdhocQueryRequest .getAdhocQuery(); QueryExpressionType queryExp = adhocQuery.getQueryExpression(); String queryLang = queryExp.getQueryLanguage(); if (queryLang.equals(BindingUtility.CANONICAL_QUERY_LANGUAGE_ID_SQL_92)) { String queryStr = (String) queryExp.getContent().get(0); queryStr = replaceSpecialVariables(user, queryStr); ebRegistryObjectListType = sqlQueryProcessor.executeQuery((ServerRequestContext) context, user, queryStr, ebResponseOptionType, paramHolder); processDepthParameter((ServerRequestContext) context); ebAdhocQueryResponse = BindingUtility.getInstance().queryFac.createAdhocQueryResponse(); ebAdhocQueryResponse.setRegistryObjectList(ebRegistryObjectListType); ebAdhocQueryResponse.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); ebAdhocQueryResponse.setStartIndex(BigInteger.valueOf(paramHolder.startIndex)); ebAdhocQueryResponse.setTotalResultCount(BigInteger.valueOf(paramHolder.totalResultCount)); } else if (queryLang.equals(BindingUtility.CANONICAL_QUERY_LANGUAGE_ID_ebRSFilterQuery)) { String queryStr = (String) queryExp.getContent().get(0); Unmarshaller unmarshaller = BindingUtility.getInstance().getJAXBContext() .createUnmarshaller(); JAXBElement<FilterQueryType> ebFilterQuery = (JAXBElement<FilterQueryType>) unmarshaller .unmarshal(new StreamSource(new StringReader(queryStr))); // take ComplexType from Element FilterQueryType filterQuery = ebFilterQuery.getValue(); // FilterQueryType filterQuery = (FilterQueryType) queryExp.getContent().get(0); ebRegistryObjectListType = filterQueryProcessor.executeQuery( ((ServerRequestContext) context), user, filterQuery, ebResponseOptionType, paramHolder); ebAdhocQueryResponse = BindingUtility.getInstance().queryFac.createAdhocQueryResponse(); ebAdhocQueryResponse.setRegistryObjectList(ebRegistryObjectListType); ebAdhocQueryResponse.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); ebAdhocQueryResponse.setStartIndex(BigInteger.valueOf(paramHolder.startIndex)); ebAdhocQueryResponse.setTotalResultCount(BigInteger.valueOf(paramHolder.totalResultCount)); } else { throw new UnsupportedCapabilityException( "Unsupported Query Language: ClassificationNode id: " + queryLang); } } } // fetch child objects if (fetchChildObjsSrv) { HashMap<String, Object> slotsMap = bu.getSlotsFromRequest(ebAdhocQueryRequest); boolean fetchChildObjsClt = Boolean .valueOf((String) slotsMap.get(CanonicalConstants.CANONICAL_SLOT_GET_CHILD_OBJECTS)) .booleanValue(); if (fetchChildObjsClt) { fetchChildObjects(ebAdhocQueryResponse.getRegistryObjectList().getIdentifiable(), (ServerRequestContext) context, ebResponseOptionType); } } // Add repositoryItems to repositoryItemMap if so requested in // responseOption if (returnType == returnType.LEAF_CLASS_WITH_REPOSITORY_ITEM) { addRepositoryItems(ebAdhocQueryResponse.getRegistryObjectList().getIdentifiable(), context); } if (!bypassCMS) { // Now perform any Role-Based Content Filtering on query results ((ServerRequestContext) context).getQueryResults().clear(); ((ServerRequestContext) context).getQueryResults() .addAll(ebAdhocQueryResponse.getRegistryObjectList().getIdentifiable()); cmsm.invokeServices(((ServerRequestContext) context)); ebAdhocQueryResponse.getRegistryObjectList().getIdentifiable().clear(); ebAdhocQueryResponse.getRegistryObjectList().getIdentifiable() .addAll(((ServerRequestContext) context).getQueryResults()); ((ServerRequestContext) context).getQueryResults().clear(); } } catch (RegistryException e) { ((ServerRequestContext) context).rollback(); throw e; } catch (Exception e) { ((ServerRequestContext) context).rollback(); throw new RegistryException(e); } removeObjectsDeniedAccess(((ServerRequestContext) context), ebAdhocQueryResponse.getRegistryObjectList().getIdentifiable()); if (isQueryFilterRequestBeingMade((ServerRequestContext) context)) { // Handle filter query requests processForQueryFilterPlugins((ServerRequestContext) context); // Filter queries produce special query results ebAdhocQueryResponse = processForSpecialQueryResults((ServerRequestContext) context); } ((ServerRequestContext) context).commit(); ebAdhocQueryResponse.setRequestId(ebAdhocQueryRequest.getId()); return ebAdhocQueryResponse; }
From source file:it.cnr.icar.eric.common.SOAPMessenger.java
/** * Convert SOAPFault back to RegistryException (if possible) * @param fault SOAPFault//from ww w . ja va2 s . c om * @return RegistryException */ RegistryException createRegistryException(SOAPFault fault) { RegistryException result = null; //is this message too generic? String unknownError = resourceBundle.getString("message.unknown"); if (log.isDebugEnabled()) { log.debug(fault.toString()); } String exceptionName = null; if (fault.getFaultCode().startsWith(BindingUtility.SOAP_FAULT_PREFIX)) { // Old style faultcode value, skip prefix and colon exceptionName = fault.getFaultCode().substring(BindingUtility.SOAP_FAULT_PREFIX.length() + 1); } else if ( // TODO: SAAJ 1.3 has introduced preferred QName interfaces fault.getFaultCodeAsName().getURI().equals(BindingUtility.SOAP_FAULT_PREFIX)) { // New style exceptionName = fault.getFaultCodeAsName().getLocalName(); } if (null == exceptionName) { // not a recognized ebXML fault result = new RegistryException(unknownError); } else { // ebXML fault String exceptionMessage = fault.getFaultString(); unknownError = resourceBundle.getString("message.exception", new String[] { exceptionName, exceptionMessage }); /* Detail detail = fault.getDetail(); Iterator iter = detail.getDetailEntries(); int i=0; while (iter.hasNext()) { DetailEntry detailEntry = (DetailEntry)iter.next(); unknownError += " detailEntry[" + i++ + "] = " + detailEntry.toString(); } **/ //TODO: get and reconstruct Stacktrace try { Class<?> exceptionClass = null; //exceptionClass = Class.forName("it.cnr.icar.eric.common.exceptions." + exceptionName); exceptionClass = Class.forName(exceptionName); if (RegistryException.class.isAssignableFrom(exceptionClass)) { //Exception is a RegistryException. Reconstitute it as a RegistryException // NPE has null message.. if (exceptionMessage != null) { @SuppressWarnings("rawtypes") Class[] parameterDefinition = { String.class }; Constructor<?> exceptionConstructor = exceptionClass.getConstructor(parameterDefinition); Object[] parameters = { exceptionMessage }; result = (RegistryException) exceptionConstructor.newInstance(parameters); } else { @SuppressWarnings("rawtypes") Class[] parameterDefinition = {}; Constructor<?> exceptionConstructor = exceptionClass.getConstructor(parameterDefinition); Object[] parameters = {}; result = (RegistryException) exceptionConstructor.newInstance(parameters); } } else { //Exception is not a RegistryException. //Make it a RegistryException with exceptionMessage //In future make it a nested Throwable of a RegistryException // NPE has null message.. result = new RegistryException(unknownError); } } catch (ClassNotFoundException e) { //could happen with non-eric server? result = new RegistryException(unknownError, e); } catch (NoSuchMethodException e) { //should not happen result = new RegistryException(unknownError, e); } catch (IllegalAccessException e) { //happens when? result = new RegistryException(unknownError, e); } catch (InvocationTargetException e) { //happens when? result = new RegistryException(unknownError, e); } catch (InstantiationException e) { //happens when trying to instantiate Interface result = new RegistryException(unknownError, e); } } return result; }
From source file:it.cnr.icar.eric.server.lcm.versioning.VersionProcessor.java
/** * Creates a new version of the RepositoryItem associated with specified ExtrinsicObject. * Note that when the RepositoryItem is versioned its ExtrinsicObject must also be versioned. * *///from www.ja v a2 s .c om public RepositoryItem createRepositoryItemVersion(ExtrinsicObjectType eo) throws RegistryException { RepositoryItem riNew = null; try { ExtrinsicObjectType eoNew = (ExtrinsicObjectType) createRegistryObjectVersion(eo); String latestContentVersionName = rm.getLatestVersionName(context, eo.getLid()); String nextContentVersionName = nextVersion(latestContentVersionName); VersionInfoType nextContentVersionInfo = bu.rimFac.createVersionInfoType(); nextContentVersionInfo.setVersionName(nextContentVersionName); //Set the contentComment from the submitted object's contentVersionInfo VersionInfoType submittedContentVersionInfo = eo.getContentVersionInfo(); if (submittedContentVersionInfo != null) { nextContentVersionInfo.setComment(submittedContentVersionInfo.getComment()); } //Update the eo contentVersionName to match newContentVersionName eoNew.setContentVersionInfo(nextContentVersionInfo); RepositoryItem riOld = (RepositoryItem) context.getRepositoryItemsMap().get(eo.getId()); riNew = (RepositoryItem) riOld.clone(); //A new version must have a unique id that matches its new ExtrinsicObject eoNew riNew.setId(eoNew.getId()); //Now remeber in context.newRIVersionMap fro later replacement //Should we be using old or new eo.getId(). //Maybe we dont need newRIVersionMap and newROVersionMap //Lets see how to just use existing idMap and other structures. context.getNewRIVersionMap().put((RepositoryItem) context.getRepositoryItemsMap().get(eo.getId()), riNew); } catch (CloneNotSupportedException e) { //This cannot happen throw new RegistryException(e); } return riNew; }
From source file:it.cnr.icar.eric.server.interfaces.rest.URLHandler.java
/** * Get the User object that is associated with a Slot named * 'urn:oasis:names:tc:ebxml-regrep:3.0:rim:User:principalName' whose value * matches the principal name specified. If no User is found, return * <code>null</code>.//from w w w . ja va2 s. co m * <p/> * This method must query the persitance manager directly so as to avoid the * authorization restrictions imposed by the QueryManager. * * @param principalName * @throws JAXRException * @return */ protected UserType findUserByPrincipalName(String principalName) throws RegistryException { UserType user = null; ServerRequestContext context = null; try { context = new ServerRequestContext("URLHandler.findUserByPrincipalName", null); String sqlQuery = "SELECT u.* " + "FROM user_ u, slot s " + "WHERE u.id = s.parent AND s.name_='" + BindingUtility.CANONICAL_PRINCIPAL_NAME_URI + "' AND value='" + principalName + "'"; ResponseOptionType ebResponseOptionType = BindingUtility.getInstance().queryFac .createResponseOptionType(); ebResponseOptionType.setReturnComposedObjects(true); ebResponseOptionType.setReturnType(ReturnType.LEAF_CLASS); ArrayList<Object> objectRefs = new ArrayList<Object>(); PersistenceManager pm = PersistenceManagerFactory.getInstance().getPersistenceManager(); Iterator<IdentifiableType> results = pm .executeSQLQuery(context, sqlQuery, ebResponseOptionType, "RegistryObject", objectRefs) .iterator(); while (results.hasNext()) { user = (UserType) results.next(); break; } } catch (RegistryException re) { context.rollback(); throw re; } catch (Exception e) { context.rollback(); throw new RegistryException(e); } context.commit(); return user; }
From source file:it.cnr.icar.eric.server.persistence.rdb.AbstractDAO.java
/** * Return the id for the repository item used to hold information that * could not fit in a db column and therefor "spilled over" into a repository item. * The returned id is then stored instead of the content that "spilled over" into * the repository item.// w w w.jav a2 s . c o m * * @param parentId the id of the parent object whose column data is being "spilled over" * @param columnInfo contains information on the table and column whose data is being spilledOver. Format SHOULD be tableName:columnName) * * @return the id of the "spill over" repository item */ String getSpillOverRepositoryItemId(String parentId, String columnInfo) throws RegistryException { String spillOverId = null; if ((columnInfo == null) || (columnInfo.length() == 0)) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.error.columnInfoUnspecified")); } else if (!columnInfo.endsWith(":")) { columnInfo += ":"; } spillOverId = "urn:freebxml:registry:spillOverId:" + columnInfo + parentId; if (!it.cnr.icar.eric.common.Utility.getInstance().isValidRegistryId(spillOverId)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.error.spillOverIdTooLong", new Object[] { parentId })); } return spillOverId; }
From source file:it.cnr.icar.eric.server.query.CompressContentQueryFilterPlugin.java
protected String getZipEntryValue(ExtrinsicObjectType eo, ServerRequestContext serverContext) throws RegistryException { StringBuffer zipEntryValue = new StringBuffer(); try {// w w w .j a v a 2 s .c om String id = eo.getId(); id = Utility.makeValidFileName(id); zipEntryValue.append(id); String queryId = CanonicalConstants.CANONICAL_QUERY_GetRegistryPackagesByMemberId; resolveHasMemberAssociations(serverContext, queryId, id, zipEntryValue); } catch (Throwable t) { throw new RegistryException(t); } return zipEntryValue.toString(); }
From source file:it.cnr.icar.eric.server.persistence.rdb.SQLPersistenceManagerImpl.java
public void releaseConnection(ServerRequestContext context, Connection connection) throws RegistryException { if (log.isTraceEnabled()) { log.debug("SQLPersistenceManagerImpl.releaseConnection"); numConnectionsOpen--;/*from ww w . ja v a 2 s. co m*/ log.debug("Number of connections open:" + numConnectionsOpen); } try { if (connection != null) { if (!connection.isClosed() && ((!useConnectionPool) || (ds != null))) { connection.close(); } else if (useConnectionPool) { connectionPool.freeConnection(connection); } } } catch (Exception e) { throw new RegistryException(e); } }