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:org.freebxml.omar.server.persistence.rdb.AuditableEventDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {// w ww.j av a 2s. c om if (!(obj instanceof AuditableEvent)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.AuditableEventExpected", new Object[] { obj })); } AuditableEvent ae = (AuditableEvent) obj; super.loadObject(obj, rs); //TODO: Fix so requestId is properly supported String requestId = rs.getString("requestId"); if (requestId == null) { requestId = "Unknown"; } ae.setRequestId(requestId); String eventType = rs.getString("eventType"); ae.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); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(timeStamp.getTime()); ae.setTimestamp(cal); String userId = rs.getString("user_"); ObjectRef ref = bu.rimFac.createObjectRef(); ref.setId(userId); context.getObjectRefs().add(ref); ae.setUser(userId); AffectedObjectDAO affectedDAO = new AffectedObjectDAO(context); affectedDAO.setParent(ae); List affectedObjects = affectedDAO.getByParent(); ObjectRefListType orefList = BindingUtility.getInstance().rimFac.createObjectRefListType(); orefList.getObjectRef().addAll(affectedObjects); ae.setAffectedObjects(orefList); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } catch (JAXBException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:org.freebxml.omar.server.persistence.rdb.ClassificationDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/*from w ww . j av a 2 s . c om*/ if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.Classification)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ClassificationExpected", new Object[] { obj })); } Classification cl = (Classification) obj; super.loadObject(cl, rs); ObjectRef or = null; String classificationNodeId = rs.getString("classificationNode"); if (classificationNodeId != null) { or = bu.rimFac.createObjectRef(); or.setId(classificationNodeId); context.getObjectRefs().add(or); cl.setClassificationNode(classificationNodeId); } String classificationSchemeId = rs.getString("classificationScheme"); if (classificationSchemeId != null) { or = bu.rimFac.createObjectRef(); or.setId(classificationSchemeId); context.getObjectRefs().add(or); cl.setClassificationScheme(classificationSchemeId); } String classifiedObjectId = rs.getString("classifiedObject"); or = bu.rimFac.createObjectRef(); or.setId(classifiedObjectId); context.getObjectRefs().add(or); cl.setClassifiedObject(classifiedObjectId); String nodeRep = rs.getString("nodeRepresentation"); cl.setNodeRepresentation(nodeRep); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } catch (JAXBException j) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), j); throw new RegistryException(j); } }
From source file:org.freebxml.omar.server.persistence.rdb.ClassificationNodeDAO.java
/** * Generate the path for the specified ClassificationNode. The path starts with a slash, followed * by the id of its ClassificationScheme, if any, which is followed by codes * of the intermidate ClassificationNodes and ends with the code of this * ClassificationNode. If any of the ClassificationNode does not have code, * empty string is appended for that ClassificationNode. * <br>//www.j a va 2s .com */ public String generatePath(ClassificationNodeType node) throws RegistryException { String path = null; String parentId = node.getParent(); RegistryObjectType _parent = null; try { if (parentId == null) { //It is possible for a ClassificationNode to have nu parent scheme //in this case the path is just "/<id of node>" path = "/" + node.getId(); } else { /* * Build the path of the ClassificationNode in the form of * /.../.../.. . It is composed of ClassificationScheme 's id as root and * then the codes of enclosing ClassificationNodes */ if (_parent == null) { //Try and get _parent from request _parent = (RegistryObjectType) context.getSubmittedObjectsMap().get(parentId); if (_parent == null) { //Try and get parent from database PersistenceManager pm = PersistenceManagerFactory.getInstance().getPersistenceManager(); ObjectRefType parentRef = bu.rimFac.createObjectRef(); parentRef.setId(parentId); _parent = pm.getRegistryObject(context, parentRef); if (_parent == null) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.couldNotFindParent", new Object[] { parentId, node.getId(), node.getCode() })); } } } String parentPath = null; if (_parent instanceof ClassificationSchemeType) { parentPath = null; } else if (_parent instanceof ClassificationNodeType) { parentPath = ((ClassificationNodeType) _parent).getPath(); } else { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.ClassificationNodeNotMatch", new Object[] { node.getId(), node.getCode(), _parent.getClass().getName() })); } if (parentPath == null) { if (_parent instanceof ClassificationSchemeType) { parentPath = "/" + _parent.getId(); } else if (_parent instanceof ClassificationNodeType) { parentPath = generatePath((ClassificationNodeType) _parent); ((ClassificationNodeType) _parent).setPath(parentPath); } } String code = node.getCode(); if (code == null) { String msg = ServerResourceBundle.getInstance().getString("message.ClassificationNodeNotMatch", new Object[] { node.getId() }); if (codeCannotBeNull) { throw new RegistryException(msg); } else { log.warn(msg); } } path = parentPath + "/" + code; node.setPath(path); } } catch (javax.xml.bind.JAXBException e) { throw new RegistryException(e); } return path; }
From source file:org.freebxml.omar.server.persistence.rdb.ClassificationNodeDAO.java
protected String checkClassificationNodeReferences(java.sql.Connection conn, String nodeId) throws RegistryException { String referencingNodeId = null; PreparedStatement stmt = null; try {//from ww w .jav a2s . c o m String sql = "SELECT id FROM ClassificationNode WHERE " + "parent=? AND parent IS NOT NULL"; stmt = context.getConnection().prepareStatement(sql); stmt.setString(1, nodeId); ResultSet rs = stmt.executeQuery(); log.trace("SQL = " + sql); // HIEOS/BHT: (DEBUG) if (rs.next()) { referencingNodeId = rs.getString(1); } return referencingNodeId; } catch (SQLException e) { throw new RegistryException(e); } finally { closeStatement(stmt); } }
From source file:org.freebxml.omar.server.persistence.rdb.ClassificationNodeDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {//w w w. ja v a 2 s . co m if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.ClassificationNode)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ClassificationNodeExpected", new Object[] { obj })); } ClassificationNode node = (ClassificationNode) obj; super.loadObject(obj, rs); String code = rs.getString("code"); node.setCode(code); String parent = rs.getString("parent"); if (parent != null) { ObjectRef or = bu.rimFac.createObjectRef(); or.setId(parent); context.getObjectRefs().add(or); node.setParent(parent); } String path = rs.getString("path"); node.setPath(path); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } catch (JAXBException j) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), j); throw new RegistryException(j); } }
From source file:org.freebxml.omar.server.persistence.rdb.ClassificationSchemeDAO.java
protected String checkClassificationReferences(java.sql.Connection conn, String schemeId) throws RegistryException { String classId = null;/* ww w.j av a2s. c o m*/ PreparedStatement stmt = null; try { String sql = "SELECT id FROM Classification WHERE " + "classificationScheme=? AND classificationScheme IS NOT NULL"; stmt = context.getConnection().prepareStatement(sql); stmt.setString(1, schemeId); log.trace("SQL = " + sql); // HIEOS/BHT: (DEBUG) ResultSet rs = stmt.executeQuery(); if (rs.next()) { classId = rs.getString(1); } return classId; } catch (SQLException e) { throw new RegistryException(e); } finally { closeStatement(stmt); } }
From source file:org.freebxml.omar.server.persistence.rdb.ClassificationSchemeDAO.java
protected String checkClassificationNodeReferences(java.sql.Connection conn, String schemeId) throws RegistryException { String nodeId = null;//www . j a va 2s . 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); log.trace("SQL = " + sql); // HIEOS/BHT: (DEBUG) 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:org.freebxml.omar.server.persistence.rdb.ClassificationSchemeDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {//from w ww . ja va 2 s . c om if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.ClassificationScheme)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ClassficationSchemeExpected", new Object[] { obj })); } ClassificationScheme scheme = (ClassificationScheme) obj; super.loadObject(scheme, rs); String isInternal = rs.getString("isInternal"); if (isInternal.equals("T")) { scheme.setIsInternal(true); } else { scheme.setIsInternal(false); } String nodeType = rs.getString("nodeType"); scheme.setNodeType(nodeType); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:org.freebxml.omar.server.persistence.rdb.EmailAddressDAO.java
public void insert(List users) throws RegistryException { // log.info(ServerResourceBundle.getInstance().getString("message.InsertingEmailAddresss", new Object[]{new Integer(emailAddresss.size())})); if (users.size() == 0) { return;//from w ww. j a v a2s . co m } Statement stmt = null; try { Iterator usersIter = users.iterator(); stmt = context.getConnection().createStatement(); while (usersIter.hasNext()) { UserType user = (UserType) usersIter.next(); if (log.isDebugEnabled()) { try { StringWriter writer = new StringWriter(); bu.rimFac.createMarshaller().marshal(user, writer); log.debug("Inserting user: " + writer.getBuffer().toString()); } catch (Exception e) { log.debug("Failed to marshal user: ", e); } } String parentId = user.getId(); List emails = user.getEmailAddress(); Iterator emailsIter = emails.iterator(); while (emailsIter.hasNext()) { //Log.print(Log.TRACE, 8, "\tDATABASE EVENT: storing EmailAddress " ); Object obj = emailsIter.next(); EmailAddressType emailAddress = (EmailAddressType) obj; String address = emailAddress.getAddress(); String type = emailAddress.getType(); if (type != null) { type = "'" + type + "'"; } String str = "INSERT INTO " + getTableName() + " VALUES( " + "'" + address + "', " + type + ", " + "'" + parentId + "' )"; log.trace("SQL = " + str); stmt.addBatch(str); } } if (users.size() > 0) { stmt.executeBatch(); } } catch (SQLException e) { RegistryException exception = new RegistryException(e); throw exception; } finally { closeStatement(stmt); } }
From source file:org.freebxml.omar.server.persistence.rdb.EmailAddressDAO.java
/** * Does a bulk insert of a Collection of objects that match the type for this persister. * *///from w w w . j a v a 2 s. c o m 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("SQL = " + str); stmt.addBatch(str); } if (emailAddresss.size() > 0) { stmt.executeBatch(); } } catch (SQLException e) { RegistryException exception = new RegistryException(e); throw exception; } finally { closeStatement(stmt); } }