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.security.authorization.RegistryPolicyFinderModule.java
/** * Loads a policy from the DataHandler, using the specified * <code>PolicyFinder</code> to help with instantiating PolicySets. * * @param DataHandler the DataHandler to load the policy from * @param finder a PolicyFinder used to help in instantiating PolicySets * @param handler an error handler used to print warnings and errors * during parsing/*from w ww. j a v a 2 s . c o m*/ * * @return a policy associated with the specified DataHandler * * @throws RegistryException exception thrown if there is a problem reading the DataHandler's input stream */ private static AbstractPolicy loadPolicy(DataHandler dh, PolicyFinder finder) throws RegistryException { AbstractPolicy policy = null; try { // create the factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(true); DocumentBuilder db = null; // set the factory to work the way the system requires // we're not doing any validation factory.setNamespaceAware(false); factory.setValidating(false); db = factory.newDocumentBuilder(); // try to load the policy file Document doc = db.parse(dh.getInputStream()); // handle the policy, if it's a known type Element root = doc.getDocumentElement(); String name = root.getTagName(); if (name.equals("Policy")) { policy = Policy.getInstance(root); } else if (name.equals("PolicySet")) { policy = PolicySet.getInstance(root, finder); } else { // this isn't a root type that we know how to handle throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.unknownRootDocumentType", new Object[] { name })); } } catch (Exception e) { log.error(ServerResourceBundle.getInstance().getString("message.FailedToLoadPolicy"), e); throw new RegistryException(e); } return policy; }
From source file:it.cnr.icar.eric.server.persistence.rdb.PostalAddressDAO.java
/** * Does a bulk update of a Collection of objects that match the type for this persister. * *///from www . j av a 2s . c o m public void update(String parentId, List<?> postalAddresss) throws RegistryException { Statement stmt = null; log.debug(ServerResourceBundle.getInstance().getString("message.UpdatingPostalAddresss", new Object[] { new Integer(postalAddresss.size()) })); try { stmt = context.getConnection().createStatement(); Iterator<?> iter = postalAddresss.iterator(); while (iter.hasNext()) { PostalAddressType postalAddress = (PostalAddressType) iter.next(); String city = postalAddress.getCity(); if (city != null) { city = "'" + city + "'"; } String country = postalAddress.getCountry(); if (country != null) { country = "'" + country + "'"; } String postalCode = postalAddress.getPostalCode(); if (postalCode != null) { postalCode = "'" + postalCode + "'"; } String state = postalAddress.getStateOrProvince(); if (state != null) { state = "'" + state + "'"; } String street = postalAddress.getStreet(); if (street != null) { street = "'" + street + "'"; } String streetNum = postalAddress.getStreetNumber(); if (streetNum != null) { streetNum = "'" + streetNum + "'"; } String str = "UPDATE PostalAddress " + "SET city = " + city + ", " + "SET country = " + country + ", " + "SET postalCode = " + postalCode + ", " + "SET state = " + state + ", " + "SET street = " + street + ", " + "SET streetNum = " + streetNum + " " + " WHERE parent = '" + parentId + "' "; log.trace("stmt = " + str); stmt.addBatch(str); } stmt.executeBatch(); } catch (SQLException e) { RegistryException exception = new RegistryException(e); throw exception; } finally { closeStatement(stmt); } }
From source file:it.cnr.icar.eric.server.interfaces.rest.QueryManagerURLHandler.java
/** * Process the QueryManager POST request and sends the response back to the client * *//*ww w . j a va 2 s .c o m*/ void processPostRequest() throws IOException, RegistryException, InvalidRequestException, UnimplementedException, ObjectNotFoundException { try { PrintWriter out = response.getWriter(); String xmlAdhocQueryRequest = request.getParameter("xmldoc"); String message = xmlAdhocQueryRequest; //TODO: consider using unmarshall directly from BindingUtility StreamSource messageSS = new StreamSource(new StringReader(message)); Unmarshaller unmarshaller = bu.getJAXBContext().createUnmarshaller(); AdhocQueryRequest req = (AdhocQueryRequest) unmarshaller.unmarshal(messageSS); ServerRequestContext context = new ServerRequestContext("QueryManagerURLHandler.processPostRequest", req); context.setUser(currentUser); RegistryResponseType regResponse = QueryManagerFactory.getInstance().getQueryManager() .submitAdhocQuery(context); // Marshaller marshaller = bu.rsFac.createMarshaller(); Marshaller marshaller = bu.getJAXBContext().createMarshaller(); marshaller.marshal(regResponse, out); out.close(); } catch (JAXBException ex) { log.error(ex.toString(), ex); throw new RegistryException(ex); } }
From source file:it.cnr.icar.eric.server.repository.filesystem.FileSystemRepositoryManager.java
public RepositoryItem getRepositoryItem(it.cnr.icar.eric.server.repository.RepositoryItemKey key) throws RegistryException { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.unimplemented")); }
From source file:it.cnr.icar.eric.server.persistence.rdb.PostalAddressDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/*ww w. j a v a2 s . c o m*/ if (!(obj instanceof PostalAddressType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.PostalAddressTypeExpected", new Object[] { obj })); } PostalAddressType addr = (PostalAddressType) obj; String city = rs.getString("city"); addr.setCity(city); String country = rs.getString("country"); addr.setCountry(country); String postalCode = rs.getString("postalCode"); addr.setPostalCode(postalCode); String stateOrProvince = rs.getString("state"); addr.setStateOrProvince(stateOrProvince); String street = rs.getString("street"); addr.setStreet(street); String streetNumber = rs.getString("streetNumber"); addr.setStreetNumber(streetNumber); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.cache.ClassificationSchemeCache.java
protected void updateCacheEntry(ServerRequestContext context, RegistryObjectType ro) throws RegistryException { // ??? i18n// w w w . j a va2 s.c om throw new RegistryException("Internal error. Unimplemented function should not have been called."); /* * RegistryObjectType scheme = null; ClassificationSchemeType * schemeParent = null; ClassificationNodeType nodeParent = null; if (ro * instanceof ClassificationSchemeType) { scheme = ro; } else if (ro * instanceof ClassificationNodeType) { scheme = * ((ClassificationNodeType)ro).; children = * nodeParent.getClassificationNode(); } */ }
From source file:it.cnr.icar.eric.server.persistence.rdb.SlotDAO.java
public void deleteByParentIdAndSlots(String parentId, List<?> slots) throws RegistryException { Statement stmt = null;//from w ww. j av a 2 s . c o m try { stmt = context.getConnection().createStatement(); String str = "DELETE from " + getTableName() + " WHERE parent = '" + parentId + "' AND ("; Iterator<?> iter = slots.iterator(); while (iter.hasNext()) { SlotType1 slot = (SlotType1) iter.next(); String slotName = slot.getName(); if (iter.hasNext()) { str = str + "name_ = '" + Utility.escapeSQLChars(slotName) + "' OR "; } else { str = str + "name_ = '" + Utility.escapeSQLChars(slotName) + "' )"; } } log.trace("stmt = " + str); stmt.execute(str); int updateCount = stmt.getUpdateCount(); if (updateCount < slots.size()) { throw new SlotNotExistException(parentId); } } catch (SQLException e) { RegistryException exception = new RegistryException(e); throw exception; } finally { closeStatement(stmt); } }
From source file:it.cnr.icar.eric.server.query.ReferenceResolverImpl.java
private Collection<?> getAssociatedObjects(ServerRequestContext serverContext, RegistryObjectType ro, int depth, Map<?, ?> idMap, Collection<?> refObjs) throws RegistryException { log.trace("start: getAssociatedObjects"); Collection<?> results = new ArrayList<Object>(); try {/*ww w . jav a 2 s .c o m*/ String id = ro.getId(); String sqlQuery = getSQLStringForGettingAssociatedObjects(ro); List<String> queryParams = new ArrayList<String>(); queryParams.add(id.toUpperCase()); ResponseOptionType ebResponseOptionType = BindingUtility.getInstance().queryFac .createResponseOptionType(); ebResponseOptionType.setReturnComposedObjects(true); ebResponseOptionType.setReturnType(ReturnType.LEAF_CLASS); ArrayList<Object> objectRefs = new ArrayList<Object>(); List<?> queryResults = PersistenceManagerFactory.getInstance().getPersistenceManager().executeSQLQuery( serverContext, sqlQuery, queryParams, ebResponseOptionType, "RegistryObject", objectRefs); if (queryResults != null) { results = queryResults; } } catch (Throwable t) { throw new RegistryException(t); } log.trace("end: getAssociatedObjects"); return results; }
From source file:it.cnr.icar.eric.server.persistence.rdb.AbstractDAO.java
/** * @see it.cnr.icar.eric.server.persistence.rdb.OMARDAO#insert(org.oasis.ebxml.registry.bindings.rim.UserType, java.sql.Connection, java.util.List, java.util.HashMap) */// w ww . j ava 2 s .c o m @SuppressWarnings("unchecked") public void insert(@SuppressWarnings("rawtypes") List objects) throws RegistryException { //Return immediatley if no objects to insert if (objects.size() == 0) { return; } //First process any objects that may already exists in persistence layer objects = processExistingObjects(objects); //Return immediately if no objects to insert if (objects.size() == 0) { return; } log.trace(ServerResourceBundle.getInstance().getString("message.InsertingRowsInTable", new Object[] { new Integer(objects.size()), getTableName() })); action = DAO_ACTION_INSERT; Statement stmt = null; try { stmt = context.getConnection().createStatement(); Iterator<ExtrinsicObjectType> iter = objects.iterator(); while (iter.hasNext()) { Object obj = iter.next(); String str = getSQLStatementFragment(obj); log.trace("stmt = " + str); stmt.addBatch(str); prepareToInsert(obj); } long startTime = System.currentTimeMillis(); log.trace("AbstractDAO.insert: doing executeBatch"); @SuppressWarnings("unused") int[] updateCounts = stmt.executeBatch(); long endTime = System.currentTimeMillis(); log.trace("AbstractDAO.insert: done executeBatch elapedTimeMillis=" + (endTime - startTime)); iter = objects.iterator(); while (iter.hasNext()) { Object obj = iter.next(); onInsert(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.security.authorization.RegistryAttributeFinderModule.java
/** * Gets the Set of id Strings for all the nodes that classify the specified object * within specified ClassificationScheme *//* www . jav a 2 s . co m*/ private Set<AttributeValue> getClassificationNodePaths(ServerRequestContext requestContext, Object obj, String schemeId) throws RegistryException { HashSet<AttributeValue> nodePaths = new HashSet<AttributeValue>(); try { if (obj instanceof RegistryObjectType) { RegistryObjectType ebRegistryObjectType = (RegistryObjectType) obj; List<ClassificationType> classifications = ebRegistryObjectType.getClassification(); Iterator<ClassificationType> iter = classifications.iterator(); while (iter.hasNext()) { ClassificationType ebClassificationType = iter.next(); String classificationNodeId = bu.getObjectId(ebClassificationType.getClassificationNode()); ClassificationNodeType ebClassificationNodeType = (ClassificationNodeType) (QueryManagerFactory .getInstance().getQueryManager() .getRegistryObject(requestContext, classificationNodeId)); String path = ebClassificationNodeType.getPath(); if (path.startsWith("/" + schemeId + "/")) { nodePaths.add(new StringAttribute(path)); } } } } catch (JAXRException e) { throw new RegistryException(e); } finally { requestContext.rollback(); } return nodePaths; }