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.persistence.rdb.IdentifiableDAO.java
/** * Check whether the object exists in the specified table. *///from w w w .j a va 2s . c o m public boolean identifiableExist(String id, String tableName) throws RegistryException { PreparedStatement stmt = null; try { stmt = context.getConnection().prepareStatement("SELECT id FROM " + tableName + " WHERE id=?"); 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.persistence.rdb.SpecificationLinkDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { if (!(obj instanceof SpecificationLinkType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.SpecificationLinkExpected", new Object[] { obj })); }//from w w w .j a va 2 s .c om SpecificationLinkType ebSpecificationLinkType = (SpecificationLinkType) obj; super.loadObject(ebSpecificationLinkType, rs); try { String specificationObjectId = rs.getString("specificationObject"); ebSpecificationLinkType.setSpecificationObject(specificationObjectId); ObjectRefType ebObjectRefType = bu.rimFac.createObjectRefType(); ebObjectRefType.setId(specificationObjectId); context.getObjectRefs().add(ebObjectRefType); String serviceBindingId = rs.getString("serviceBinding"); if (serviceBindingId != null) { ObjectRefType ebServiceBindingObjectRefType = bu.rimFac.createObjectRefType(); context.getObjectRefs().add(ebServiceBindingObjectRefType); ebServiceBindingObjectRefType.setId(serviceBindingId); ebSpecificationLinkType.setServiceBinding(serviceBindingId); } String specLinkId = rs.getString("id"); if (specLinkId != null) { UsageDescriptionDAO usageDescriptionDAO = new UsageDescriptionDAO(context); usageDescriptionDAO.setParent(specLinkId); InternationalStringType usagesDescription = usageDescriptionDAO .getUsageDescriptionByParent(specLinkId); if (usagesDescription != null) { ebSpecificationLinkType.setUsageDescription(usagesDescription); } UsageParameterDAO usageParameterDAO = new UsageParameterDAO(context); usageParameterDAO.setParent(specLinkId); List<String> usageParameters = usageParameterDAO.getUsageParametersByParent(specLinkId); if (usageParameters != null) { Iterator<String> iter = usageParameters.iterator(); while (iter.hasNext()) { String usageParam = iter.next(); ebSpecificationLinkType.getUsageParameter().add(usageParam); } } } } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.cms.ContentCatalogingServiceImpl.java
public ServiceOutput invoke(ServerRequestContext context, ServiceInput input, ServiceType service, InvocationController invocationController, UserType user) throws RegistryException { if (log.isDebugEnabled()) { log.debug("ContentCatalogingServiceImpl.invoke():: input: " + input + "; Service: " + service + "; invocationController: " + invocationController + "; user: " + user); }// ww w.j av a 2 s. c om String accessURI = selectAccessURI(service); SOAPElement responseElement; Object responseObj; ServiceOutput output = new ServiceOutput(); ServerRequestContext outputContext = null; try { outputContext = context; //new RequestContext(null); CatalogContentRequest ebCatalogContentRequest = bu.cmsFac.createCatalogContentRequest(); RegistryObjectListType ebRegistryObjectListType = bu.rimFac.createRegistryObjectListType(); // create element JAXBElement<RegistryObjectType> ebRegistryObject = bu.rimFac .createRegistryObject(input.getRegistryObject()); // add element ebRegistryObjectListType.getIdentifiable().add(ebRegistryObject); ebCatalogContentRequest.setOriginalContent(ebRegistryObjectListType); System.err.println("InvocationControlFile class: " + qm.getRegistryObject(outputContext, invocationController.getEoId()).getClass().getName()); ExtrinsicObjectType icfEOT = bu.rimFac.createExtrinsicObjectType(); icfEOT.setId(invocationController.getEoId()); ebCatalogContentRequest.getInvocationControlFile().add(icfEOT); if (log.isDebugEnabled()) { log.debug("\n\nOriginalContent:"); printNodeToConsole(bu.getSOAPElementFromBindingObject(input.getRegistryObject())); } Collection<AttachmentPart> attachments = new ArrayList<AttachmentPart>(); // RepositoryItem for input to be cataloged. attachments.add(getRepositoryItemAsAttachmentPart(input.getRegistryObject().getId())); // RepositoryItem for InvocationControlFile. attachments.add(getRepositoryItemAsAttachmentPart(invocationController.getEoId())); ContentCatalogingServiceSOAPService soapService = new ContentCatalogingServiceSOAPService_Impl(); ContentCatalogingServicePortType_Stub stub = (ContentCatalogingServicePortType_Stub) soapService .getContentCatalogingServicePort(); stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, accessURI); stub._setProperty(com.sun.xml.rpc.client.StubPropertyConstants.SET_ATTACHMENT_PROPERTY, attachments); responseElement = stub.catalogContent(bu.getSOAPElementFromBindingObject(ebCatalogContentRequest)); responseObj = bu.getBindingObjectFromSOAPElement(responseElement); if (!(responseObj instanceof CatalogContentResponse)) { throw new RegistryException(ServerResourceBundle.getInstance().getString( "message.WrongResponseReceivedFromCatalogingService", new Object[] { responseElement.getElementName().getQualifiedName() })); } CatalogContentResponse ebCatalogContentResponse = (CatalogContentResponse) responseObj; String status = ebCatalogContentResponse.getStatus(); if (log.isDebugEnabled()) { log.debug("Status: " + status); } RegistryObjectListType catalogedMetadata = ebCatalogContentResponse.getCatalogedContent(); // TODO: User should refer to "Service object for the // Content Management Service that generated the // Cataloged Content." outputContext.setUser(user); bu.getObjectRefsAndRegistryObjects(catalogedMetadata, outputContext.getTopLevelRegistryObjectTypeMap(), outputContext.getObjectRefTypeMap()); outputContext.getRepositoryItemsMap().putAll(getRepositoryItems(stub)); output.setOutput(outputContext); output.setErrorList(ebCatalogContentResponse.getRegistryErrorList()); } catch (Exception e) { e.printStackTrace(); if (outputContext != context) { outputContext.rollback(); } throw new RegistryException(e); } if (outputContext != context) { outputContext.commit(); } return output; }
From source file:it.cnr.icar.eric.server.persistence.rdb.SlotDAO.java
/** * Get the List of the names of a Slots that already exist in database * @param parentId the id of the parent of those slots *//*from w ww . j a va2s. c om*/ public List<String> slotsExist(String parentId, List<?> slots) throws RegistryException { Statement stmt = null; List<String> slotsNames = new ArrayList<String>(); if (slots.size() > 0) { try { Iterator<?> slotsIter = slots.iterator(); String names = ""; while (slotsIter.hasNext()) { names += ("'" + Utility.escapeSQLChars(((SlotType1) slotsIter.next()).getName()) + "'"); if (slotsIter.hasNext()) { names += ","; } } String sql = "SELECT name_ FROM " + getTableName() + " WHERE" + " parent=" + "'" + parentId + "'" + " AND " + " name_ IN (" + names + ")"; //log.trace("stmt= '" + sql + "'"); stmt = context.getConnection().createStatement(); ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { slotsNames.add(rs.getString(1)); } return slotsNames; } catch (SQLException e) { throw new RegistryException(e); } finally { closeStatement(stmt); } } else { return slotsNames; } }
From source file:it.cnr.icar.eric.server.persistence.rdb.AdhocQueryDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/* ww w . j av a 2s. c om*/ //TODO: Add support for filter query type later if (!(obj instanceof AdhocQueryType)) { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.SQLQueryExpected", new Object[] { obj })); } AdhocQueryType ebAdhocQueryType = (AdhocQueryType) obj; super.loadObject(obj, rs); String query = rs.getString("query"); //Check if query is actually a ref to a query stored in a repository item //If so we needs to dereference it to get actual query string if (query.startsWith("urn:freebxml:registry:spillOverId:")) { //query is actually in a repository item and this is just the id of that repository item //Fetch the actual query by dereferencing this id try { query = unmarshallFromRepositoryItem(query); //We escape single quotes in the query with another single quote when storing as VARCHAR. //JDBC strips the first single quote on read from VARCHAR column //When reading from content of a RepositoryItem replace "''" with "'" query = query.replaceAll("''", "'"); } catch (Exception e) { //throw new RegistryException(e); log.error(e, e); } } String queryLang = rs.getString("queryLanguage"); QueryExpressionType ebQueryExpressionType = bu.rimFac.createQueryExpressionType(); ebQueryExpressionType.setQueryLanguage(queryLang); ebQueryExpressionType.getContent().add(query); ebAdhocQueryType.setQueryExpression(ebQueryExpressionType); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.AuditableEventDAO.java
@SuppressWarnings({ "rawtypes", "unchecked" }) protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {//from w w w. j a v a 2 s .c om if (!(obj instanceof AuditableEventType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.AuditableEventExpected", new Object[] { obj })); } AuditableEventType ebAuditableEventType = (AuditableEventType) obj; super.loadObject(obj, rs); //TODO: Fix so requestId is properly supported String requestId = rs.getString("requestId"); if (requestId == null) { requestId = "Unknown"; } ebAuditableEventType.setRequestId(requestId); String eventType = rs.getString("eventType"); ebAuditableEventType.setEventType(eventType); //Workaround for bug in PostgreSQL 7.2.2 JDBC driver //java.sql.Timestamp timeStamp = rs.getTimestamp("timeStamp_"); --old String timestampStr = rs.getString("timeStamp_").substring(0, 19); Timestamp timeStamp = Timestamp.valueOf(timestampStr); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(timeStamp); XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); ebAuditableEventType.setTimestamp(cal); String userId = rs.getString("user_"); ObjectRefType ebObjectRefType = bu.rimFac.createObjectRefType(); ebObjectRefType.setId(userId); context.getObjectRefs().add(ebObjectRefType); ebAuditableEventType.setUser(userId); AffectedObjectDAO affectedDAO = new AffectedObjectDAO(context); affectedDAO.setParent(ebAuditableEventType); List affectedObjects = affectedDAO.getByParent(); ObjectRefListType orefList = BindingUtility.getInstance().rimFac.createObjectRefListType(); orefList.getObjectRef().addAll(affectedObjects); ebAuditableEventType.setAffectedObjects(orefList); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } catch (DatatypeConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:it.cnr.icar.eric.server.cache.AbstractCache.java
@SuppressWarnings("static-access") protected RegistryObjectType getRegistryObjectInternal(ServerRequestContext context, String id, String typeName) throws RegistryException { RegistryObjectType ro = null;//from w w w .j ava2s . com typeName = bu.mapJAXRNameToEbXMLName(typeName); String tableName = Utility.getInstance().mapTableName(typeName); try { if (id != null) { String sqlQuery = "Select * from " + tableName + " WHERE UPPER(id) = ?"; ArrayList<String> queryParams = new ArrayList<String>(); queryParams.add(id.toUpperCase()); List<?> results = executeQueryInternal(context, sqlQuery, queryParams, tableName); if (results.size() > 0) { ro = (RegistryObjectType) results.get(0); } else { ro = null; } } } catch (RegistryException e) { throw e; } catch (Exception e) { //e.printStackTrace(); throw new RegistryException(e); } return ro; }
From source file:it.cnr.icar.eric.server.cms.CanonicalXMLFilteringService.java
/** * Runs XSLT based upon specified inputs and returns the outputfile. * * TODO: Need some refactoring to make this reusable throughout OMAR * particularly in CanonicalXMLCatalogingService. *///www . j a v a 2 s . co m protected static File runXSLT(StreamSource input, StreamSource xslt, URIResolver resolver, HashMap<String, String> params) throws RegistryException { File outputFile = null; try { //dumpStream(xslt); TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = initTransformer(tFactory, xslt); // Use FilteringService URIResolver to resolve RIs submitted in the // ServiceInput object transformer.setURIResolver(resolver); //Set respository item as parameter //Create the output file with the filtered RegistryObject Metadata outputFile = File.createTempFile("CanonicalXMLFilteringService_Output", ".xml"); outputFile.deleteOnExit(); log.debug("outputFile= " + outputFile.getAbsolutePath()); Iterator<String> iter = params.keySet().iterator(); while (iter.hasNext()) { String key = iter.next(); Object value = params.get(key); transformer.setParameter(key, value); } StreamResult sr = new StreamResult(outputFile); transformer.transform(input, sr); } catch (Exception e) { throw new RegistryException(e); } return outputFile; }
From source file:it.cnr.icar.eric.server.query.federation.FederatedQueryProcessor.java
/** * Submits an AdhocQueryRequest to all Registries thare are members of specified federation. * * @param user/*from w w w. j a v a 2s. c o m*/ * @param adhocQueryRequest the request sent to every registry ias a parrallel distrubuted query. */ public AdhocQueryResponse submitAdhocQuery(final ServerRequestContext context) throws RegistryException { this.adhocQueryRequest = (AdhocQueryRequest) context.getCurrentRegistryRequest(); try { //Reset federated flag before doing federated query to avoid infinite loop adhocQueryRequest.setFederated(false); //Reset federation flag before doing federated query to avoid potential //for implementations to interpret non-null values as implying federated query adhocQueryRequest.setFederation(null); // Create a barrier for all worker threads log.trace("Dispatching federated query to " + members.size() + " member registries."); CyclicBarrier barrier = new CyclicBarrier(members.size(), new Runnable() { public void run() { retrieveResults(context); } }); ThreadGroup threadGroup = new ThreadGroup("federatedQuery"); // Send a request to all destinations Iterator<RegistryType> i = members.iterator(); while (i.hasNext()) { RegistryType registry = i.next(); FederatedQueryWorker worker = new FederatedQueryWorker(barrier, registry, TIMEOUT_CONSTANT, context.getUser(), adhocQueryRequest); workers.add(worker); //Thread thread = new Thread(threadGroup, worker); Thread thread = new Thread(threadGroup, worker, "Federated_Query_" + registry.getId()); threads.add(thread); log.trace("Dispatching query to registry with id: " + registry.getId() + " name: " + bu.getInternationalStringAsString(registry.getName())); thread.start(); } Iterator<Thread> i1 = threads.iterator(); while (i1.hasNext()) { Thread thread = i1.next(); // Wait until all threads have finished. // CAVEAT: The timeouts will add up, max. waiting time is (number of threads) * (timeout) try { thread.join(TIMEOUT_CONSTANT); } catch (InterruptedException e) { //TODO: Try to kill the thread somehow } } } catch (JAXRException e) { //This exception is thrown potentially (unlikely) by bu.getInternationalStringAsString throw new RegistryException(e); } return getUnifiedResponse(); }
From source file:it.cnr.icar.eric.server.cache.ObjectCache.java
void putRegistryObjects(List<?> registryObjects) throws RegistryException { Iterator<?> iter = registryObjects.iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj != null) { if (obj instanceof RegistryObjectType) { RegistryObjectType ro = (RegistryObjectType) obj; putRegistryObject(ro);//from w ww. j a v a 2 s. com } else { throw new RegistryException(CommonResourceBundle.getInstance().getString( "message.unexpectedObjectType", new Object[] { obj.getClass(), "RegistryObject" })); } } } }