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.cms.ContentFilteringServiceManager.java
/** * Invokes appropriate Content Management Services for the * in the <code>RegistryObject</code>. * * @param ro a <code>RegistryObject</code> value * @param ri a <code>RepositoryItem</code> value *///from ww w . j av a2 s .c o m public boolean invokeServiceForObject(ServiceInvocationInfo sii, RegistryObjectType ro, RepositoryItem ri, ServerRequestContext context) throws RegistryException { RegistryRequestType request = context.getCurrentRegistryRequest(); //Filter services only apply to AdhocQueryRequests if (!(request instanceof AdhocQueryRequest)) { return false; } try { ContentManagementService cms = (ContentManagementService) sii.getConstructor() .newInstance((java.lang.Object[]) null); ServiceOutput so = null; //Note that ri will be null for ExternalLink ro. so = cms.invoke(context, new ServiceInput(ro, ri), sii.getService(), sii.getInvocationController(), context.getUser()); if (!(so.getOutput() instanceof ServerRequestContext)) { throw new InvalidConfigurationException(ServerResourceBundle.getInstance().getString( "message.FilteringServiceInstanceShouldReturnRequestContext", new Object[] { so.getOutput().getClass().getName() })); } @SuppressWarnings("unused") ServerRequestContext outputContext = (ServerRequestContext) so.getOutput(); } catch (RegistryException re) { log.error(re, re); throw re; } catch (Exception e) { log.error(e, e); throw new RegistryException(e); } return true; }
From source file:it.cnr.icar.eric.server.cache.ClassificationSchemeCache.java
private Cache getPathToNodeCache() throws RegistryException { // Use lazy instantiation if (pathToNodeCache == null) { String cacheName = ClassificationSchemeCache.class.getName() + ".pathToNodeCache"; pathToNodeCache = cacheMgr.getCache(cacheName); if (pathToNodeCache == null) { try { cacheMgr.addCache(cacheName); } catch (Throwable t) { throw new RegistryException(t); }/*from w ww.j a va2s .c om*/ pathToNodeCache = cacheMgr.getCache(cacheName); } } return pathToNodeCache; }
From source file:it.cnr.icar.eric.server.interfaces.rest.UserDefinedURLHandler.java
/** * Attempt to get a RepositoryItem by its URI. * *//*from w w w. j a v a 2s . co m*/ private List<?> getRepositoryItemByURI() throws IOException, RegistryException, ObjectNotFoundException { List<?> results = null; String pathInfo = request.getPathInfo(); //If path begins with a '/' then we also need to check for same patch but without leading '/' //because zip files with relative entry paths when cataloged do not have the leading '/' String pathInfo2 = new String(pathInfo); if (pathInfo2.charAt(0) == '/') { pathInfo2 = pathInfo2.substring(1); } try { ExtrinsicObjectType ro = null; String queryString = "SELECT eo.* FROM ExtrinsicObject eo, Slot s " + "WHERE (s.value='" + pathInfo + "' OR s.value='" + pathInfo2 + "') AND " + "s.name_='" + BindingUtility.CANONICAL_SLOT_CONTENT_LOCATOR + "' AND s.parent=eo.id"; results = submitQueryAs(queryString, currentUser); if (results.size() == 0) { throw new ObjectNotFoundException(ServerResourceBundle.getInstance() .getString("message.noRepositoryItemFound", new Object[] { pathInfo })); } else if (results.size() == 1) { ro = (ExtrinsicObjectType) results.get(0); writeRepositoryItem(ro); } else { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.duplicateRegistryObjects", new Object[] { pathInfo })); } } catch (NullPointerException e) { e.printStackTrace(); throw new RegistryException( it.cnr.icar.eric.server.common.Utility.getInstance().getStackTraceFromThrowable(e)); } return results; }
From source file:it.cnr.icar.eric.server.cms.AbstractContentManagementService.java
/** * Gets the <code>RegistryObjectType</code> as a stream of XML markup. * * @param ebRegistryObjectType an <code>RegistryObjectType</code> value * @return a <code>StreamSource</code> value * @exception RegistryException if an error occurs *//* w w w . ja v a2 s . c o m*/ protected StreamSource getAsStreamSource(RegistryObjectType ebRegistryObjectType) throws RegistryException { log.debug("getAsStreamSource(RegistryObjectType) entered"); StreamSource src = null; try { StringWriter sw = new StringWriter(); Marshaller marshaller = bu.getJAXBContext().createMarshaller(); /* * marshal JAXBElement Identifiable */ JAXBElement<IdentifiableType> ebIdentifiable = bu.rimFac.createIdentifiable(ebRegistryObjectType); marshaller.marshal(ebIdentifiable, 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; }
From source file:it.cnr.icar.eric.server.persistence.rdb.ClassificationDAO.java
protected void loadObject(Object obj, ResultSet resultSet) throws RegistryException { try {// ww w. ja va 2 s . co m if (!(obj instanceof ClassificationType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ClassificationExpected", new Object[] { obj })); } ClassificationType ebClassificationType = (ClassificationType) obj; super.loadObject(ebClassificationType, resultSet); ObjectRefType ebObjectRefType = null; String classificationNodeId = resultSet.getString("classificationNode"); if (classificationNodeId != null) { ebObjectRefType = bu.rimFac.createObjectRefType(); ebObjectRefType.setId(classificationNodeId); context.getObjectRefs().add(ebObjectRefType); ebClassificationType.setClassificationNode(classificationNodeId); } String classificationSchemeId = resultSet.getString("classificationScheme"); if (classificationSchemeId != null) { ebObjectRefType = bu.rimFac.createObjectRefType(); ebObjectRefType.setId(classificationSchemeId); context.getObjectRefs().add(ebObjectRefType); ebClassificationType.setClassificationScheme(classificationSchemeId); } String classifiedObjectId = resultSet.getString("classifiedObject"); ebObjectRefType = bu.rimFac.createObjectRefType(); ebObjectRefType.setId(classifiedObjectId); context.getObjectRefs().add(ebObjectRefType); ebClassificationType.setClassifiedObject(classifiedObjectId); String nodeRep = resultSet.getString("nodeRepresentation"); ebClassificationType.setNodeRepresentation(nodeRep); } 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.ExternalIdentifierDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {//from w w w .ja va 2 s . c o m if (!(obj instanceof ExternalIdentifierType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ExternalIdentifierTypeExpected", new Object[] { obj })); } ExternalIdentifierType ebExternalIdentifierType = (ExternalIdentifierType) obj; super.loadObject(obj, rs); String schemeId = rs.getString("identificationScheme"); if (schemeId != null) { ObjectRefType ebObjectRefType = bu.rimFac.createObjectRefType(); ebObjectRefType.setId(schemeId); context.getObjectRefs().add(ebObjectRefType); } ebExternalIdentifierType.setIdentificationScheme(schemeId); String registryObjectId = rs.getString("registryObject"); if (registryObjectId != null) { ObjectRefType ebObjectRefType = bu.rimFac.createObjectRefType(); context.getObjectRefs().add(ebObjectRefType); ebObjectRefType.setId(registryObjectId); ebExternalIdentifierType.setRegistryObject(registryObjectId); } String value = rs.getString("value"); ebExternalIdentifierType.setValue(value); } 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.RegistryDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {//from w w w .j a va 2 s . c o m if (!(obj instanceof RegistryType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.RegistryTypeExpected", new Object[] { obj })); } RegistryType ebRegistryType = (RegistryType) obj; super.loadObject(obj, rs); String catalogingSyncLatencyString = rs.getString("catalogingSyncLatency"); Duration catalogingSyncLatency = DatatypeFactory.newInstance().newDuration(catalogingSyncLatencyString); ebRegistryType.setCatalogingLatency(catalogingSyncLatency); String conformanceProfile = rs.getString("conformanceProfile"); ebRegistryType.setConformanceProfile(conformanceProfile); String operator = rs.getString("operator"); ebRegistryType.setOperator(operator); String replicationSyncLatencyString = rs.getString("replicationSyncLatency"); Duration replicationSyncLatency = DatatypeFactory.newInstance() .newDuration(replicationSyncLatencyString); ebRegistryType.setReplicationSyncLatency(replicationSyncLatency); String specificationVersion = rs.getString("specificationVersion"); ebRegistryType.setSpecificationVersion(specificationVersion); } 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.persistence.rdb.ExternalLinkDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/* w w w .j ava 2 s. co m*/ if (!(obj instanceof ExternalLinkType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ExternalLinkTypeExpected", new Object[] { obj })); } ExternalLinkType ebExternalLinkType = (ExternalLinkType) obj; super.loadObject(obj, rs); String externalURI = rs.getString("externalURI"); ebExternalLinkType.setExternalURI(externalURI); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.common.RepositoryItemImpl.java
/** * Packages the RepositoryItem as a MimeMultiPart and returns it * * @deprecated sigElement/multipart attachment is not used anymore. *///from w ww. j a v a 2 s.c o m public MimeMultipart getMimeMultipart() throws RegistryException { MimeMultipart mp = null; try { //Create a multipart with two bodyparts //First bodypart is an XMLDSIG and second is the attached file mp = new MimeMultipart(); //The signature part ByteArrayOutputStream os = new ByteArrayOutputStream(); TransformerFactory tf = TransformerFactory.newInstance(); Transformer trans = tf.newTransformer(); trans.transform(new DOMSource(sigElement), new StreamResult(os)); MimeBodyPart bp1 = new MimeBodyPart(); bp1.addHeader("Content-ID", "payload1"); bp1.setText(os.toString(), "utf-8"); mp.addBodyPart(bp1); //The payload part MimeBodyPart bp2 = new MimeBodyPart(); bp2.setDataHandler(handler); bp2.addHeader("Content-Type", handler.getContentType()); bp2.addHeader("Content-ID", "payload2"); mp.addBodyPart(bp2); } catch (MessagingException e) { throw new RegistryException(e); } catch (TransformerException e) { throw new RegistryException(e); } return mp; }
From source file:it.cnr.icar.eric.server.persistence.rdb.SpecificationLinkDAO.java
/** * Returns the SQL fragment string needed by insert or update statements * within insert or update method of sub-classes. This is done to avoid code * duplication./*from w ww. j av a 2 s. c om*/ */ protected String getSQLStatementFragment(Object ro) throws RegistryException { SpecificationLinkType specLink = (SpecificationLinkType) ro; String stmtFragment = null; String serviceBinding = specLink.getServiceBinding(); if (serviceBinding == null) { if (parent != null) { serviceBinding = ((ServiceBindingType) parent).getId(); } else { throw new RegistryException(ServerResourceBundle.getInstance().getString( "message.specificationLinkHasNoParentServiceBinding", new Object[] { specLink.getId() })); } } String specificationObject = specLink.getSpecificationObject(); if (specificationObject == null) { throw new RegistryException(ServerResourceBundle.getInstance().getString( "message.specificationLinkHasNoPreentSpecificationLink", new Object[] { specLink.getId() })); } if (action == DAO_ACTION_INSERT) { stmtFragment = "INSERT INTO SpecificationLink " + super.getSQLStatementFragment(ro) + ", '" + serviceBinding + "', '" + specificationObject + "' ) "; } else if (action == DAO_ACTION_UPDATE) { stmtFragment = "UPDATE SpecificationLink SET " + super.getSQLStatementFragment(ro) + ", serviceBinding='" + serviceBinding + "', specificationObject='" + specificationObject + "' WHERE id = '" + ((RegistryObjectType) ro).getId() + "' "; } else if (action == DAO_ACTION_DELETE) { stmtFragment = super.getSQLStatementFragment(ro); } return stmtFragment; }