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.cache.ObjectCache.java
/** * Returns a RegistryObject of type 'objectType' with specified id. * * @param context ServerRequestContext w/in which dB queries should occur * @param id a URN that identifies the desired object * @param objectType the desired object type (string name) * @return RegistryObject/*from w ww . j a v a 2s . c o m*/ * @throws ObjectNotFoundException if (id,objectType) not found. * @throws RegistryException if other RegistryException happens. */ public RegistryObjectType getRegistryObject(ServerRequestContext context, String id, String objectType) throws RegistryException { RegistryObjectType ro = null; primeCacheOnFirstUse(context); try { Element elem = internalCache.get(id); if (elem == null) { //Cache miss. Get from registry //log.trace("ObjectCache: cache miss for id: " + id); ro = getRegistryObjectInternal(context, id, objectType); if (ro == null) { throw new ObjectNotFoundException(id, objectType); } else { putRegistryObject(ro); } } else { //log.trace("ObjectCache: cache hit for id: " + id); ro = (RegistryObjectType) elem.getValue(); } } catch (CacheException e) { throw new RegistryException(e); } return ro; }
From source file:it.cnr.icar.eric.server.cache.ClassificationSchemeCache.java
/** * Gets all schemes. Note that descendent nodes of schemes up to the depth * level that is configured for the cache may also be loaded into the object * cache.//from www. j a v a 2 s.c o m */ public List<?> getAllClassificationSchemes(ServerRequestContext context) throws RegistryException { List<?> result = null; try { primeCacheOnFirstUse(context); synchronized (internalCache) { if (cacheIsPrimed) { result = getAllClassificationSchemesFromCache(); } } // If not, we mostly update the cache outside the lock. if (null == result) { result = updateScheme(context, "%", true /* false */); } } catch (CacheException e) { throw new RegistryException(e); } return result; }
From source file:it.cnr.icar.eric.server.repository.AbstractRepositoryManager.java
/** * Return a List of non-existent repository items * @param ids The List of repository items keys. *///from w ww . ja v a 2 s. c om public List<String> itemsExist(List<String> ids) throws RegistryException { try { List<String> notFound = new ArrayList<String>(); if (ids.size() == 0) { return notFound; } Iterator<String> iter = ids.iterator(); while (iter.hasNext()) { String id = iter.next(); try { @SuppressWarnings("unused") RepositoryItem ri = getRepositoryItem(id); } catch (RepositoryItemNotFoundException e) { notFound.add(id); } catch (ObjectNotFoundException e) { notFound.add(id); } } return notFound; } catch (Exception e) { String msg = ServerResourceBundle.getInstance() .getString("message.FailedToVerifyRepositoryItemExistence"); log.error(e, e); throw new RegistryException(ServerResourceBundle.getInstance().getString("message.seeLogsForDetails", new Object[] { msg })); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.IdentifiableDAO.java
/** * Returns List of ids of non-existent Identifiable. *//*from ww w . j ava2 s . c o m*/ public List<String> identifiablesExist(List<?> ids, String tableName) throws RegistryException { List<String> notExistIdList = new ArrayList<String>(); if (ids.size() == 0) { return notExistIdList; } Iterator<?> iter = ids.iterator(); Statement stmt = null; try { stmt = context.getConnection().createStatement(); StringBuffer sql = new StringBuffer("SELECT id FROM " + tableName + " WHERE id IN ("); List<String> existingIdList = new ArrayList<String>(); /* We need to count the number of item in "IN" list. We need to split the a single SQL Strings if it is too long. Some database such as Oracle, does not allow the IN list is too long*/ int listCounter = 0; while (iter.hasNext()) { String id = (String) iter.next(); if (iter.hasNext() && (listCounter < identifiableExistsBatchCount)) { sql.append("'" + id + "',"); } else { sql.append("'" + id + "')"); //log.info("!!!!!!!!!!!!!!!!!!!" + sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString()); while (rs.next()) { existingIdList.add(rs.getString("id")); } sql = new StringBuffer("SELECT id FROM " + tableName + " WHERE id IN ("); listCounter = 0; } listCounter++; } for (int i = 0; i < ids.size(); i++) { String id = (String) ids.get(i); if (!existingIdList.contains(id)) { notExistIdList.add(id); } } } catch (SQLException e) { throw new RegistryException(e); } finally { closeStatement(stmt); } return notExistIdList; }
From source file:it.cnr.icar.eric.server.lcm.versioning.VersionProcessor.java
public void checkRegistryObjectLid(RegistryObjectType ro) throws RegistryException { String id = ro.getId();/* w w w. j a v a 2 s.c om*/ String lid = ro.getLid(); String existingObjectLid = context.getIdToLidMap().get(id); //Assign lid if not specified, validate lid if specified if (existingObjectLid != null) { if (lid == null) { ro.setLid(existingObjectLid); } else { //Validate that lid matches existing objects lid if (!lid.equals(existingObjectLid)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.idDoesNotMatch", new Object[] { lid, existingObjectLid, id })); } } } else { checkRegistryObjectLidOnNewObject(ro); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.IdentifiableDAO.java
protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {//from w w w .ja v a2 s . c o m if (!(obj instanceof IdentifiableType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.IdentifiableTypeExpected", new Object[] { obj })); } IdentifiableType ident = (IdentifiableType) obj; SlotDAO slotDAO = new SlotDAO(context); slotDAO.setParent(ident); String id = rs.getString("id"); ident.setId(id); String home = rs.getString("home"); if (home != null) { ident.setHome(home); } boolean returnComposedObjects = context.getResponseOption().isReturnComposedObjects(); if (returnComposedObjects) { List<SlotType1> slots = slotDAO.getSlotsByParent(id); ident.getSlot().addAll(slots); } } 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.AbstractDAO.java
/** * Does a bulk delete of objects based upon parent set for this DAO * *//*from ww w. j a v a 2 s .c om*/ public void deleteByParent() throws RegistryException { PreparedStatement stmt = null; try { if (!hasComposedObject()) { //Do simple deletion if there are no composed objects for this type String str = "DELETE from " + getTableName() + " WHERE " + getParentAttribute() + " = ? "; log.trace("stmt = " + str); stmt = context.getConnection().prepareStatement(str); stmt.setString(1, getParentId()); stmt.execute(); } else { //If there are composed objects for this type then //we must first fetch the objects and then use the //delete(List objects) method so that composed objects //are deleted. List<Object> objects = getByParent(); delete(objects); } } catch (SQLException e) { RegistryException exception = new RegistryException(e); throw exception; } catch (JAXRException e) { RegistryException exception = new RegistryException(e); throw exception; } finally { closeStatement(stmt); } }
From source file:it.cnr.icar.eric.server.security.authentication.AuthenticationServiceImpl.java
/** * Get the keystore whose path is specified by * {@link #getKeyStoreFileName()}. Note that all the methods that access the * keystore MUST access the keystore via this method. Do not access the * keystore directly by accessing the keystore field. Otherwise the checking * the write lock to keystore will be bypassed. */// w w w . j a v a 2s . c o m public KeyStore getKeyStore() throws RegistryException { synchronized (keyStoreWriteLock) { if (keyStore == null) { java.io.FileInputStream fis = null; try { String keystoreType = RegistryProperties.getInstance().getProperty("eric.security.keystoreType", "JKS"); keyStore = KeyStore.getInstance(keystoreType); String keystoreFile = getKeyStoreFileName(); fis = new java.io.FileInputStream(keystoreFile); String keystorePass = getKeyStorePassword(); keyStore.load(fis, keystorePass.toCharArray()); } catch (java.security.cert.CertificateException e) { throw new RegistryException(e); } catch (KeyStoreException e) { throw new RegistryException(e); } catch (NoSuchAlgorithmException e) { throw new RegistryException(e); } catch (java.io.FileNotFoundException e) { throw new RegistryException(e); } catch (IOException e) { throw new RegistryException(e); } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { e.printStackTrace(); } } } } return keyStore; } }
From source file:it.cnr.icar.eric.server.repository.filesystem.FileSystemRepositoryManager.java
/** * Delete the repository item./*from w ww .j av a 2 s .com*/ * @param id It should be the UUID. It will remove "urn:uuid:". * @throws RegistryException if the item does not exist */ public void delete(String id) throws RegistryException { // Strip off the "urn:uuid:" id = Utility.getInstance().stripId(id); String path = getRepositoryItemPath(id); log.debug("path = " + path); //RepositoryItem file File riFile = new File(path); //RepositoryItem XML signature file File riSigFile = new File(path + ".sig"); if (!riFile.exists()) { String errmsg = ServerResourceBundle.getInstance().getString("message.RepositoryItemDoesNotExist", new Object[] { id }); log.error(errmsg); throw new RegistryException(errmsg); } boolean deletedOK = riFile.delete(); if (riSigFile.exists()) { deletedOK = riSigFile.delete(); if (!deletedOK) { //log error String errmsg = ServerResourceBundle.getInstance().getString("message.CannotDeletePayloadSignature", new Object[] { id }); log.error(errmsg); } } if (deletedOK) { String msg = "deleted OK"; log.debug(msg); } else { String msg = ServerResourceBundle.getInstance().getString("message.deletedNOK"); log.error(msg); } }
From source file:it.cnr.icar.eric.server.persistence.rdb.PostalAddressDAO.java
/** * Does a bulk insert of a Collection of objects that match the type for this persister. * *///from w w w .j ava 2s . c o 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("stmt = " + str); stmt.addBatch(str); } if (postalAddresss.size() > 0) { stmt.executeBatch(); } } catch (SQLException e) { RegistryException exception = new RegistryException(e); throw exception; } finally { closeStatement(stmt); } }