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.InternationalStringDAO.java
public void insert(String parentId, InternationalStringType is) throws RegistryException { PreparedStatement pstmt = null; try {//from w ww . jav a2 s .c om String str = "INSERT INTO " + getTableName() + " VALUES(?, " + // charsetName "?," + // lang "?, " + // value "?)"; // parentId pstmt = context.getConnection().prepareStatement(str); if (is != null) { Iterator<LocalizedStringType> lsItems = is.getLocalizedString().iterator(); while (lsItems.hasNext()) { LocalizedStringType ebLocalizedStringType = lsItems.next(); @SuppressWarnings("unused") String charset = ebLocalizedStringType.getCharset(); String lang = ebLocalizedStringType.getLang(); String value = ebLocalizedStringType.getValue(); String charsetName = ebLocalizedStringType.getCharset(); if (value != null && value.length() > 0) { pstmt.setString(1, charsetName); pstmt.setString(2, lang); pstmt.setString(3, value); pstmt.setString(4, parentId); log.trace("stmt = " + pstmt.toString()); pstmt.addBatch(); } } } if (is != null) { @SuppressWarnings("unused") int[] updateCounts = pstmt.executeBatch(); } } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } finally { closeStatement(pstmt); } }
From source file:it.cnr.icar.eric.server.interfaces.rest.UserDefinedURLHandler.java
/** * Attempt to get a RegistryObject by its URI. * *//*from w w w. ja va 2 s.c o m*/ private List<?> getRegistryObjectByURI() throws IOException, RegistryException, ObjectNotFoundException { List<?> results = null; @SuppressWarnings("unused") Locale locale = request.getLocale(); String pathInfo = request.getPathInfo(); try { RegistryObjectType ro = null; String queryString = "SELECT ro.* FROM RegistryObject ro, Slot s " + "WHERE s.value='" + pathInfo + "' AND " + "s.name_='" + BindingUtility.CANONICAL_SLOT_LOCATOR + "' AND s.parent=ro.id"; results = submitQueryAs(queryString, currentUser); if (results.size() == 0) { throw new ObjectNotFoundException(ServerResourceBundle.getInstance() .getString("message.noRegistryObjectFound", new Object[] { pathInfo })); } else if (results.size() == 1) { ro = (RegistryObjectType) results.get(0); writeRegistryObject(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)); } if ((results == null) || (results.size() == 0)) { throw new ObjectNotFoundException(ServerResourceBundle.getInstance() .getString("message.noRegistryObjectFound", new Object[] { pathInfo })); } return results; }
From source file:it.cnr.icar.eric.server.persistence.rdb.ClassificationSchemeDAO.java
protected String checkClassificationNodeReferences(java.sql.Connection conn, String schemeId) throws RegistryException { String nodeId = null;/*from w ww . j a va 2 s. c o m*/ PreparedStatement stmt = null; try { String sql = "SELECT id FROM ClassificationNode WHERE parent=? AND parent IS NOT NULL"; stmt = context.getConnection().prepareStatement(sql); stmt.setString(1, schemeId); ResultSet rs = stmt.executeQuery(); if (rs.next()) { nodeId = rs.getString(1); } return nodeId; } catch (SQLException e) { throw new RegistryException(e); } finally { closeStatement(stmt); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.SubscriptionDAO.java
@SuppressWarnings("unchecked") protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/*from ww w .ja va 2 s .com*/ if (!(obj instanceof SubscriptionType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.SubscriptionTypeExpected", new Object[] { obj })); } SubscriptionType ebSubscriptionType = (SubscriptionType) obj; super.loadObject(obj, rs); String selector = rs.getString("selector"); ebSubscriptionType.setSelector(selector); // Need to work around a bug in PostgreSQL and loading of // ClassificationScheme data from NIST tests try { Timestamp endTimestamp = rs.getTimestamp("endTime"); if (endTimestamp != null) { // Calendar calendar = Calendar.getInstance(); // calendar.setTimeInMillis(endTime.getTime()); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(endTimestamp.getTime()); XMLGregorianCalendar endTime = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); ebSubscriptionType.setEndTime(endTime); } } catch (StringIndexOutOfBoundsException e) { String id = rs.getString("id"); log.error(ServerResourceBundle.getInstance().getString("message.SubscriptionDAOId", new Object[] { id }), e); } String notificationIntervalString = rs.getString("notificationInterval"); if (notificationIntervalString != null) { Duration notificationInterval = DatatypeFactory.newInstance() .newDuration(notificationIntervalString); ebSubscriptionType.setNotificationInterval(notificationInterval); } // Need to work around a bug in PostgreSQL and loading of // ClassificationScheme data from NIST tests try { Timestamp startTimestamp = rs.getTimestamp("startTime"); if (startTimestamp != null) { // Calendar calendar = Calendar.getInstance(); // calendar.setTimeInMillis(startTime.getTime()); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(startTimestamp.getTime()); XMLGregorianCalendar startTime = DatatypeFactory.newInstance() .newXMLGregorianCalendar(new GregorianCalendar()); ebSubscriptionType.setStartTime(startTime); } } catch (StringIndexOutOfBoundsException e) { String id = rs.getString("id"); log.error(ServerResourceBundle.getInstance().getString("message.SubscriptionDAOId", new Object[] { id }), e); } NotifyActionDAO notifyActionDAO = new NotifyActionDAO(context); notifyActionDAO.setParent(ebSubscriptionType); @SuppressWarnings("rawtypes") List notifyActions = notifyActionDAO.getByParent(); if (notifyActions != null) { bu.getActionTypeListFromElements(ebSubscriptionType.getAction()).addAll(notifyActions); } } 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.security.authentication.AuthenticationServiceImpl.java
private void loadPublicKeyToCertMap() throws RegistryException { try {/*from w ww . ja v a 2 s . c om*/ KeyStore store = getKeyStore(); for (Enumeration<String> e = store.aliases(); e.hasMoreElements();) { String alias = e.nextElement(); X509Certificate cert = (X509Certificate) store.getCertificate(alias); PublicKey publicKey = cert.getPublicKey(); publicKeyToCertMap.put(publicKey, cert); } } catch (KeyStoreException e) { throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.cms.CanonicalXMLCatalogingService.java
public ServiceOutput invoke(ServerRequestContext context, ServiceInput input, ServiceType service, InvocationController invocationController, UserType user) throws RegistryException { if (log.isTraceEnabled()) { log.trace("CanonicalXMLCatalogingService.invoke()"); }//from ww w . j a v a2 s .c o m ServiceOutput so = new ServiceOutput(); so.setOutput(context); RepositoryItem repositoryItem = input.getRepositoryItem(); // The RI is optional per the [ebRS] spec. Return empty ServiceOutput. if (repositoryItem != null) { @SuppressWarnings("unused") String roId = input.getRegistryObject().getId(); ServerRequestContext outputContext = null; try { outputContext = context; // new RequestContext(null); StreamSource inputSrc = getAsStreamSource((ExtrinsicObjectType) input.getRegistryObject()); StreamSource invocationControlFileSrc = rm.getAsStreamSource(invocationController.getEoId()); // dumpStream(invocationControlFileSrc); TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = initTransformer(tFactory, invocationControlFileSrc); // Use CatalogingService URIResolver to resolve RIs submitted in // the // ServiceInput object transformer.setURIResolver(getURIResolver(context)); // Set respository item as parameter transformer.setParameter("repositoryItem", input.getRegistryObject().getId()); // Create the output file with catalogedMetadata File outputFile = File.createTempFile("CanonicalXMLCatalogingService_OutputFile", ".xml"); outputFile.deleteOnExit(); log.debug("Tempfile= " + outputFile.getAbsolutePath()); StreamResult sr = new StreamResult(outputFile); transformer.transform(inputSrc, sr); @SuppressWarnings("unchecked") JAXBElement<RegistryObjectListType> ebRegistryObjectList = (JAXBElement<RegistryObjectListType>) bu .getJAXBContext().createUnmarshaller().unmarshal(outputFile); // take ComplexType from Element RegistryObjectListType catalogedMetadata = ebRegistryObjectList.getValue(); // RegistryObjectListType catalogedMetadata = (RegistryObjectListType) bu.getJAXBContext() // .createUnmarshaller().unmarshal(outputFile); // 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()); } catch (Exception e) { if (outputContext != context) { outputContext.rollback(); } throw new RegistryException(e); } so.setOutput(outputContext); // Setting this error list is redundant, but Content Validation // Services // currently output a Boolean and a RegistryErrorList, so using // same mechanism to report errors from Content Cataloging Services. so.setErrorList(outputContext.getErrorList()); if (outputContext != context) { outputContext.commit(); } } return so; }
From source file:it.cnr.icar.eric.server.persistence.rdb.ExtrinsicObjectDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {// www .j av a 2 s. c o m if (!(obj instanceof ExtrinsicObjectType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ExtrinsicObjectExpected", new Object[] { obj })); } ExtrinsicObjectType ebExtrinsicObjectType = (ExtrinsicObjectType) obj; super.loadObject(obj, rs); String isOpaque = rs.getString("isOpaque"); if (isOpaque.equals("T")) { ebExtrinsicObjectType.setIsOpaque(true); } else { ebExtrinsicObjectType.setIsOpaque(false); } String mimeType = rs.getString("mimeType"); ebExtrinsicObjectType.setMimeType(mimeType); //Now set contentVersionInfo if either contentComment and contentVersionName are non-null //Make sure to not set contentVersionInfo if both contentComment and contentVersionName are null VersionInfoType contentVersionInfo = BindingUtility.getInstance().rimFac.createVersionInfoType(); String contentVersionName = rs.getString("contentVersionName"); String contentComment = rs.getString("contentVersionComment"); if ((contentVersionName != null) || (contentComment != null)) { if (contentVersionName != null) { contentVersionInfo.setVersionName(contentVersionName); } if (contentComment != null) { contentVersionInfo.setComment(contentComment); } ebExtrinsicObjectType.setContentVersionInfo(contentVersionInfo); } } 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.ClassificationSchemeDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/*from w w w. j av a 2s.c o m*/ if (!(obj instanceof ClassificationSchemeType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ClassficationSchemeExpected", new Object[] { obj })); } ClassificationSchemeType ebClassificationSchemeType = (ClassificationSchemeType) obj; super.loadObject(ebClassificationSchemeType, rs); String isInternal = rs.getString("isInternal"); if (isInternal.equals("T")) { ebClassificationSchemeType.setIsInternal(true); } else { ebClassificationSchemeType.setIsInternal(false); } String nodeType = rs.getString("nodeType"); ebClassificationSchemeType.setNodeType(nodeType); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.cms.ContentValidationServiceImpl.java
public ServiceOutput invoke(ServerRequestContext context, ServiceInput input, ServiceType service, InvocationController invocationController, UserType user) throws RegistryException { System.err.println("ContentValidationServiceImpl.invoke():: input: " + input + "; Service: " + service + "; invocationController: " + invocationController + "; user: " + user); List<ServiceBindingType> serviceBindings = service.getServiceBinding(); Iterator<ServiceBindingType> debugIter = serviceBindings.iterator(); while (debugIter.hasNext()) { ServiceBindingType binding = debugIter.next(); System.err.println("URL: " + binding.getAccessURI()); }/*from www . ja va 2 s .com*/ String accessURI = selectAccessURI(service); SOAPElement responseElement; Object responseObj; try { ValidateContentRequest ebValidateContentRequest = bu.cmsFac.createValidateContentRequest(); RegistryObjectListType ebRegistryObjectListType = bu.rimFac.createRegistryObjectListType(); JAXBElement<RegistryObjectType> ebRegistryObject = bu.rimFac .createRegistryObject(input.getRegistryObject()); ebRegistryObjectListType.getIdentifiable().add(ebRegistryObject); ebValidateContentRequest.setOriginalContent(ebRegistryObjectListType); System.err.println("InvocationControlFile class: " + qm.getRegistryObject(context, invocationController.getEoId()).getClass().getName()); // FIXME: Adding existing ExtrinsicObjects with 'request.getInvocationControlFile().add()' gives incorrect serialization. ExtrinsicObjectType icfEOT = bu.rimFac.createExtrinsicObjectType(); icfEOT.setId(invocationController.getEoId()); ebValidateContentRequest.getInvocationControlFile().add(icfEOT); System.out.println("\n\nOriginalContent:"); printNodeToConsole(bu.getSOAPElementFromBindingObject(input.getRegistryObject())); ArrayList<AttachmentPart> attachments = new ArrayList<AttachmentPart>(); // RepositoryItem for input to be validated. attachments.add(getRepositoryItemAsAttachmentPart(input.getRegistryObject().getId())); // RepositoryItem for InvocationControlFile. attachments.add(getRepositoryItemAsAttachmentPart(invocationController.getEoId())); ContentValidationServiceSOAPService soapService = new ContentValidationServiceSOAPService_Impl(); ContentValidationServicePortType_Stub stub = (ContentValidationServicePortType_Stub) soapService .getContentValidationServicePort(); stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, accessURI); stub._setProperty(com.sun.xml.rpc.client.StubPropertyConstants.SET_ATTACHMENT_PROPERTY, attachments); responseElement = stub.validateContent(bu.getSOAPElementFromBindingObject(ebValidateContentRequest)); responseObj = bu.getBindingObjectFromSOAPElement(responseElement); } catch (Exception e) { throw new RegistryException(e); } if (!(responseObj instanceof ValidateContentResponse)) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.ValidationContentResponseExpected", new Object[] { responseElement.getElementName().getQualifiedName() })); } ValidateContentResponse ebValidateContentResponse = (ValidateContentResponse) responseObj; String status = ebValidateContentResponse.getStatus(); System.err.println("Status: " + status); if (log.isDebugEnabled()) { log.debug("Status: " + status); } ServiceOutput output = new ServiceOutput(); output.setErrorList(ebValidateContentResponse.getRegistryErrorList()); if (status.equals(CanonicalSchemes.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success)) { output.setOutput(Boolean.TRUE); } else if (status.equals(CanonicalSchemes.CANONICAL_RESPONSE_STATUS_TYPE_ID_Failure)) { output.setOutput(Boolean.FALSE); } else { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ResponseStatusTypeExpected", new Object[] { status })); } return output; }
From source file:it.cnr.icar.eric.server.persistence.rdb.EmailAddressDAO.java
/** * Does a bulk insert of a Collection of objects that match the type for this persister. * */// w w w . j a va 2 s. c om public void insert(String parentId, List<?> emailAddresss) throws RegistryException { log.debug(ServerResourceBundle.getInstance().getString("message.InsertingEmailAddresss", new Object[] { new Integer(emailAddresss.size()) })); if (emailAddresss.size() == 0) { return; } Statement stmt = null; try { stmt = context.getConnection().createStatement(); Iterator<?> iter = emailAddresss.iterator(); while (iter.hasNext()) { EmailAddressType emailAddress = (EmailAddressType) iter.next(); //Log.print(Log.TRACE, 8, "\tDATABASE EVENT: storing EmailAddress " ); String address = emailAddress.getAddress(); String type = emailAddress.getType(); if (type != null) { type = "'" + type + "'"; } String str = "INSERT INTO EmailAddress " + "VALUES( " + "'" + address + "', " + type + ", " + "'" + parentId + "' )"; log.trace("stmt = " + str); stmt.addBatch(str); } if (emailAddresss.size() > 0) { stmt.executeBatch(); } } catch (SQLException e) { RegistryException exception = new RegistryException(e); throw exception; } finally { closeStatement(stmt); } }