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.InternationalStringDAO.java
public void insert(String parentId, InternationalStringType is) throws RegistryException { PreparedStatement pstmt = null; try {/*from w w w.java2 s . c om*/ String str = "INSERT INTO " + getTableName() + " VALUES(?, " + // charsetName "?," + // lang "?, " + // value "?)"; // parentId pstmt = context.getConnection().prepareStatement(str); if (is != null) { Iterator lsItems = is.getLocalizedString().iterator(); while (lsItems.hasNext()) { LocalizedString ls = (LocalizedString) lsItems.next(); String charset = ls.getCharset(); String lang = ls.getLang(); String value = ls.getValue(); String charsetName = ls.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("SQL = " + str); // HIEOS/BHT: DEBUG (fix) pstmt.addBatch(); } } } if (is != null) { 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:org.freebxml.omar.server.persistence.rdb.NotifyActionDAO.java
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 org.oasis.ebxml.registry.bindings.rim.NotifyAction)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.NotifyActionTypeExpected", new Object[] { obj })); } NotifyAction notifyAction = (NotifyAction) obj; String notificationOption = rs.getString("notificationOption"); if (notificationOption != null) { notifyAction.setNotificationOption(notificationOption); } String endPoint = rs.getString("endPoint"); notifyAction.setEndPoint(endPoint); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:org.freebxml.omar.server.persistence.rdb.ObjectRefDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/*from ww w. j a va2s .co m*/ if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.ObjectRef)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.ObjectRefTypeExpected", new Object[] { obj })); } ObjectRef objectRef = (ObjectRef) obj; String id = rs.getString("id"); objectRef.setId(id); String home = rs.getString("home"); if (home != null) { objectRef.setHome(home); } } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:org.freebxml.omar.server.persistence.rdb.OrganizationDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/*w ww . j a v a 2s. c o m*/ if (!(obj instanceof Organization)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.OrganizationExpected", new Object[] { obj })); } Organization org = (Organization) obj; super.loadObject(obj, rs); String parentId = rs.getString("parent"); if (parentId != null) { ObjectRef or = bu.rimFac.createObjectRef(); or.setId(parentId); context.getObjectRefs().add(or); org.setParent(parentId); } String primaryContactId = rs.getString("primaryContact"); ObjectRef or = bu.rimFac.createObjectRef(); or.setId(primaryContactId); context.getObjectRefs().add(or); org.setPrimaryContact(primaryContactId); PostalAddressDAO postalAddressDAO = new PostalAddressDAO(context); postalAddressDAO.setParent(org); List addresses = postalAddressDAO.getByParent(); if ((addresses != null) && (addresses.size() > 0)) { org.getAddress().addAll(addresses); } TelephoneNumberDAO telephoneNumberDAO = new TelephoneNumberDAO(context); telephoneNumberDAO.setParent(org); List phones = telephoneNumberDAO.getByParent(); if (phones != null) { org.getTelephoneNumber().addAll(phones); } EmailAddressDAO emailAddressDAO = new EmailAddressDAO(context); emailAddressDAO.setParent(org); List emails = emailAddressDAO.getByParent(); if (emails != null) { org.getEmailAddress().addAll(emails); } } 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.PersonDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {// ww w . j a v a2 s . c o m if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.PersonType)) { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.PersonExpected", new Object[] { obj })); } PersonType person = (PersonType) obj; super.loadObject(obj, rs); String firstName = rs.getString("personName_firstName"); String middleName = rs.getString("personName_middleName"); String lastName = rs.getString("personName_lastName"); PersonNameType pn = bu.rimFac.createPersonName(); pn.setFirstName(firstName); pn.setMiddleName(middleName); pn.setLastName(lastName); person.setPersonName(pn); PostalAddressDAO postalAddressDAO = new PostalAddressDAO(context); postalAddressDAO.setParent(person); List addresses = postalAddressDAO.getByParent(); if (addresses != null) { person.getAddress().addAll(addresses); } TelephoneNumberDAO telephoneNumberDAO = new TelephoneNumberDAO(context); telephoneNumberDAO.setParent(person); List phones = telephoneNumberDAO.getByParent(); if (phones != null) { person.getTelephoneNumber().addAll(phones); } EmailAddressDAO emailAddressDAO = new EmailAddressDAO(context); emailAddressDAO.setParent(person); List emails = emailAddressDAO.getByParent(); if (emails != null) { person.getEmailAddress().addAll(emails); } } 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.PostalAddressDAO.java
/** * @param registryObjects is a List of Organizations or Users * @throws RegistryException if the RegistryObject is not Organization or User, * or it has SQLException when inserting their PostalAddress *//*from w w w.j a va 2 s . c o m*/ public void insert(List registryObjects) throws RegistryException { Statement stmt = null; if (registryObjects.size() == 0) { return; } try { /* String sqlStr = "INSERT INTO " + getTableName() + " VALUES( " + "?, " + // city "?, " + // country "?, " + // postalCode "?, " + // state "?, " + // street "?, " + // streetNum "?)"; // Parent id PreparedStatement pstmt = context.getConnection().prepareStatement(sqlStr); */ stmt = context.getConnection().createStatement(); Iterator rosIter = registryObjects.iterator(); while (rosIter.hasNext()) { Object ro = rosIter.next(); String parentId = null; PostalAddressType postalAddress = null; if (ro instanceof OrganizationType) { OrganizationType org = (OrganizationType) ro; postalAddress = (PostalAddressType) org.getAddress().get(0); parentId = org.getId(); } else if (ro instanceof UserType) { UserType user = (UserType) ro; //TODO: Save extra addresses, if required postalAddress = (PostalAddressType) user.getAddress().get(0); parentId = user.getId(); } else { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.incorrectRegistryObject")); } /* stmt.setString(1, postalAddress.getCity()); stmt.setString(2, postalAddress.getCountry()); stmt.setString(3, postalAddress.getPostalCode()); stmt.setString(4, postalAddress.getStateOrProvince()); stmt.setString(5, postalAddress.getStreet()); stmt.setString(6, postalAddress.getStreetNumber()); stmt.setString(7, org.getId()); stmt.addBatch();*/ 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 = "INSERT INTO PostalAddress " + "VALUES( " + city + ", " + country + ", " + postalCode + ", " + state + ", " + street + ", " + streetNum + ", " + "'" + parentId + "' )"; log.trace("SQL = " + str); stmt.addBatch(str); } // end looping all Organizations if (registryObjects.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.PostalAddressDAO.java
/** * Does a bulk insert of a Collection of objects that match the type for this persister. * *///from www.j a va 2 s.co m public void insert(String parentId, List postalAddresss) throws RegistryException { Statement stmt = null; log.debug(ServerResourceBundle.getInstance().getString("message.InsertingPostalAddresss", new Object[] { new Integer(postalAddresss.size()) })); if (postalAddresss.size() == 0) { return; } try { stmt = context.getConnection().createStatement(); Iterator iter = postalAddresss.iterator(); while (iter.hasNext()) { PostalAddressType postalAddress = (PostalAddressType) iter.next(); //Log.print(Log.TRACE, 8, "\tDATABASE EVENT: storing PostalAddress " ); 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 = "INSERT INTO PostalAddress " + "VALUES( " + city + ", " + country + ", " + postalCode + ", " + state + ", " + street + ", " + streetNum + ", " + "'" + parentId + "' )"; log.trace("SQL = " + str); stmt.addBatch(str); } if (postalAddresss.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.PostalAddressDAO.java
/** * Does a bulk update of a Collection of objects that match the type for this persister. * *///from w ww . j a va2s . c om 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("SQL = " + str); stmt.addBatch(str); } stmt.executeBatch(); } catch (SQLException e) { RegistryException exception = new RegistryException(e); throw exception; } finally { closeStatement(stmt); } }
From source file:org.freebxml.omar.server.persistence.rdb.RegistryDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {/*from w w w .jav a 2 s . c om*/ if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.Registry)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.RegistryTypeExpected", new Object[] { obj })); } Registry registry = (Registry) obj; super.loadObject(obj, rs); String catalogingSyncLatency = rs.getString("catalogingSyncLatency"); registry.setCatalogingLatency(catalogingSyncLatency); String conformanceProfile = rs.getString("conformanceProfile"); registry.setConformanceProfile(conformanceProfile); String operator = rs.getString("operator"); registry.setOperator(operator); String replicationSyncLatency = rs.getString("replicationSyncLatency"); registry.setReplicationSyncLatency(replicationSyncLatency); String specificationVersion = rs.getString("specificationVersion"); registry.setSpecificationVersion(specificationVersion); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } }
From source file:org.freebxml.omar.server.persistence.rdb.RegistryObjectDAO.java
/** * Get the objectType for specified object. * If it is an ExtrinsicObject or ExternalLink then get it from the object. * Otherwise ignore the value in the object and get from * the DAO the hardwired value.//from w ww. j a v a2 s . c o m */ protected String getObjectType(RegistryObjectType ro) throws RegistryException { String objectType = null; try { String roClassName = ro.getClass().getName(); String rimName = roClassName.substring(roClassName.lastIndexOf('.') + 1, roClassName.length() - 4); Field field = CanonicalSchemes.class.getDeclaredField("CANONICAL_OBJECT_TYPE_ID_" + rimName); objectType = field.get(null).toString(); } catch (Exception e) { throw new RegistryException(e); } //TODO Get object type from leaf DAO if not ExtrinsicObject if ((ro instanceof ExtrinsicObjectType) || (ro instanceof ExternalLinkType)) { String _objectType = ro.getObjectType(); if (_objectType != null) { objectType = _objectType; } //Make sure that objectType is a ref to a ObjectType ClassificationNode context.checkClassificationNodeRefConstraint(objectType, bu.CANONICAL_CLASSIFICATION_SCHEME_ID_ObjectType, "objectType"); } return objectType; }