Author: glandais Date: 2008-02-15 16:25:18 +0000 (Fri, 15 Feb 2008) New Revision: 1006 Added: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerException.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerSecurityException.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerTechnicalException.java Removed: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageSecurityException.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageTechnicalException.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerException.java Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationService.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceHelper.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceClient.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceHelper.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceServer.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java trunk/simexplorer-is/simexplorer-is-service/src/resources/i18n/simexplorer-is-service-en_GB.properties trunk/simexplorer-is/simexplorer-is-service/src/resources/i18n/simexplorer-is-service-fr_FR.properties trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityEqualsTestCase.java trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityTestCase.java trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceLocalVersions.java trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/attachment/ContentType.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/BaseEntityFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/CodeFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ComponentFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ConstantFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ConstantValueFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ExplorationApplicationFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ExplorationDataFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/LoggableElementFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/MetaDataFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/RepositoryFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ResultFactory.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/StorageServiceHelper.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java trunk/simexplorer-is/simexplorer-is-swing/src/resources/i18n/simexplorer-is-swing-en_GB.properties trunk/simexplorer-is/simexplorer-is-swing/src/resources/i18n/simexplorer-is-swing-fr_FR.properties trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementMetadata.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementRights.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupEdit.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupList.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserEdit.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserList.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/GroupValueEncoder.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/UserValueEncoder.java Log: Modified exception mechanism Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationService.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationService.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationService.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -17,6 +17,7 @@ * ##% */ package fr.cemagref.simexplorer.is.service; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.Group; import fr.cemagref.simexplorer.is.security.entities.Permission; import fr.cemagref.simexplorer.is.security.entities.User; @@ -33,20 +34,20 @@ * @param login the login * @param password the password * @return the string - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public String loginUser(String login, String password) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Request account. * * @param login the login * @param mail the mail - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public void requestAccount(String login, String mail) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Save user. @@ -55,20 +56,20 @@ * @param login the login * @param mail the mail * @return the user - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public User saveUser(String token, String login, String mail) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Reset password. * * @param token the token * @param login the login - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public void resetPassword(String token, String login) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Change password. @@ -78,11 +79,11 @@ * @param password * the password * - * @throws SimExplorerServiceException + * @throws SimExplorerException * the sim explorer service exception */ // public void changePassword(String token, String password) -// throws SimExplorerServiceException; +// throws SimExplorerException; /** * Gets the user. @@ -90,10 +91,10 @@ * @param token the token * @param id the id * @return the user - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public User getUser(String token, Integer id) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Gets the user. @@ -101,10 +102,10 @@ * @param token the token * @param login the login * @return the user - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public User getUser(String token, String login) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Update user. @@ -112,29 +113,29 @@ * @param token the token * @param user the user * @return the user - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public User updateUser(String token, User user) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Delete user. * * @param token the token * @param id the id - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public void deleteUser(String token, Integer id) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Gets the users. * * @param token the token * @return the users - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public User[] getUsers(String token) throws SimExplorerServiceException; + public User[] getUsers(String token) throws SimExplorerException; /** * Gets the users of group. @@ -142,10 +143,10 @@ * @param token the token * @param group the group * @return the users of group - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public User[] getUsersOfGroup(String token, Group group) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Sets the users of group. @@ -153,10 +154,10 @@ * @param token the token * @param group the group * @param usersInGroup the users in group - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public void setUsersOfGroup(String token, Group group, - Integer[] usersInGroup) throws SimExplorerServiceException; + Integer[] usersInGroup) throws SimExplorerException; /** * Sets the groups of group. @@ -164,10 +165,10 @@ * @param token the token * @param group the group * @param groupsIds the groups ids - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public void setGroupsOfGroup(String token, Group group, Integer[] groupsIds) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Gets the groups of user. @@ -175,10 +176,10 @@ * @param token the token * @param user the user * @return the groups of user - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public Group[] getGroupsOfUser(String token, User user) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Gets the groups of group. @@ -186,10 +187,10 @@ * @param token the token * @param group the group * @return the groups of group - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public Group[] getGroupsOfGroup(String token, Group group) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Sets the groups of user. @@ -197,10 +198,10 @@ * @param token the token * @param user the user * @param groupsIds the groups ids - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public void setGroupsOfUser(String token, User user, Integer[] groupsIds) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Save group. @@ -208,10 +209,10 @@ * @param token the token * @param name the name * @return the group - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public Group saveGroup(String token, String name) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Gets the group. @@ -219,10 +220,10 @@ * @param token the token * @param id the id * @return the group - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public Group getGroup(String token, Integer id) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Gets the group. @@ -230,10 +231,10 @@ * @param token the token * @param name the name * @return the group - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public Group getGroup(String token, String name) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Update group. @@ -241,29 +242,29 @@ * @param token the token * @param group the group * @return the group - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public Group updateGroup(String token, Group group) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Delete group. * * @param token the token * @param id the id - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public void deleteGroup(String token, Integer id) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Gets the groups. * * @param token the token * @return the groups - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public Group[] getGroups(String token) throws SimExplorerServiceException; + public Group[] getGroups(String token) throws SimExplorerException; /** * Gets the groups owned by. @@ -271,19 +272,19 @@ * @param token the token * @param user the user * @return the groups owned by - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public Group[] getGroupsOwnedBy(String token, User user) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Gets the logged user. * * @param token the token * @return the logged user - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public User getLoggedUser(String token) throws SimExplorerServiceException; + public User getLoggedUser(String token) throws SimExplorerException; /** * Gets the permissions. Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceHelper.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceHelper.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceHelper.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -20,6 +20,9 @@ import org.codelutin.util.ConverterUtil; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; + import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -38,14 +41,14 @@ * * @return the string * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public static String computeHash(char[] clearString) throws SimExplorerServiceException { + public static String computeHash(char[] clearString) throws SimExplorerException { MessageDigest messageDigest; try { messageDigest = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { - throw new SimExplorerServiceException(e); + throw new SimExplorerTechnicalException(e); } messageDigest.reset(); byte[] bytes = ConverterUtil.convert(clearString); Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -42,6 +42,10 @@ import org.codelutin.i18n.I18n; import org.jboss.annotation.ejb.RemoteBinding; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerBusinessException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerSecurityException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; import fr.cemagref.simexplorer.is.storage.util.Config; import fr.cemagref.simexplorer.is.security.dao.DaoSecurity; import fr.cemagref.simexplorer.is.security.entities.Group; @@ -111,10 +115,10 @@ * @param mailFrom the mail from * @param mailRecipient the mail recipient * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ private void sendMail(String mailFrom, String mailRecipient, String subject, String content) - throws SimExplorerServiceException { + throws SimExplorerException { try { javax.mail.Session mailSession = (javax.mail.Session) new InitialContext().lookup("java:/Mail"); javax.mail.Message msg = new MimeMessage(mailSession); @@ -127,9 +131,9 @@ msg.setSentDate(new java.util.Date()); Transport.send(msg); } catch (MessagingException e) { - throw new SimExplorerServiceException(e); + throw new SimExplorerTechnicalException(e); } catch (NamingException e) { - throw new SimExplorerServiceException(e); + throw new SimExplorerTechnicalException(e); } } @@ -139,7 +143,7 @@ * @return the string */ private char[] generatePassword() { - //TODO ne plus utiliser un String + // TODO ne plus utiliser un String return RandomStringUtils.randomAlphanumeric(10).toCharArray(); } @@ -151,9 +155,9 @@ * * @return true, if successful * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private boolean canAdminGroup(String token, Integer id) throws SimExplorerServiceException { + private boolean canAdminGroup(String token, Integer id) throws SimExplorerException { User loggedUser = getLoggedUser(token); if (loggedUser != null) { if (loggedUser.isSuperAdmin()) { @@ -195,9 +199,9 @@ * * @return true, if successful * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private boolean canAdminUser(String token, Integer id) throws SimExplorerServiceException { + private boolean canAdminUser(String token, Integer id) throws SimExplorerException { User loggedUser = getLoggedUser(token); if (loggedUser != null) { if (loggedUser.isSuperAdmin()) { @@ -241,9 +245,9 @@ * @param id the id * * @return true, if successful - * @throws SimExplorerServiceException + * @throws SimExplorerException */ - private boolean canDeleteGroup(String token, Integer id) throws SimExplorerServiceException { + private boolean canDeleteGroup(String token, Integer id) throws SimExplorerException { return canAdminGroup(token, id); } @@ -260,11 +264,11 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#deleteGroup(java.lang.String, java.lang.Integer) */ - public void deleteGroup(String token, Integer id) throws SimExplorerServiceException { + public void deleteGroup(String token, Integer id) throws SimExplorerException { if (canDeleteGroup(token, id)) { deleteGroupImpl(token, id); } else { - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } } @@ -276,9 +280,9 @@ * * @return true, if successful * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private boolean canDeleteUser(String token, Integer id) throws SimExplorerServiceException { + private boolean canDeleteUser(String token, Integer id) throws SimExplorerException { return canAdminUser(token, id); } @@ -295,11 +299,11 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#deleteUser(java.lang.String, java.lang.Integer) */ - public void deleteUser(String token, Integer id) throws SimExplorerServiceException { + public void deleteUser(String token, Integer id) throws SimExplorerException { if (canDeleteUser(token, id)) { deleteUserImpl(token, id); } else { - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } } @@ -309,9 +313,9 @@ * @param token the token * * @return true, if successful - * @throws SimExplorerServiceException + * @throws SimExplorerException */ - private boolean canViewElements(String token) throws SimExplorerServiceException { + private boolean canViewElements(String token) throws SimExplorerException { User loggedUser = getLoggedUser(token); // boolean canView = loggedUser.isAdmin() || loggedUser.isSuperAdmin(); // return canView; @@ -321,45 +325,45 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroup(java.lang.String, java.lang.Integer) */ - public Group getGroup(String token, Integer id) throws SimExplorerServiceException { + public Group getGroup(String token, Integer id) throws SimExplorerException { if (canViewElements(token)) { Group group = dao.getGroup(id); return group; } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroup(java.lang.String, java.lang.String) */ - public Group getGroup(String token, String name) throws SimExplorerServiceException { + public Group getGroup(String token, String name) throws SimExplorerException { if (canViewElements(token)) { Group group = dao.getGroup(name); return group; } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUser(java.lang.String, java.lang.Integer) */ - public User getUser(String token, Integer id) throws SimExplorerServiceException { + public User getUser(String token, Integer id) throws SimExplorerException { if (canViewElements(token)) { User user = dao.getUser(id); return user; } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUser(java.lang.String, java.lang.String) */ - public User getUser(String token, String login) throws SimExplorerServiceException { + public User getUser(String token, String login) throws SimExplorerException { if (canViewElements(token)) { User user = dao.getUser(login); return user; } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /** @@ -369,9 +373,9 @@ * * @return true, if successful * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private boolean canSaveElement(String token) throws SimExplorerServiceException { + private boolean canSaveElement(String token) throws SimExplorerException { User loggedUser = getLoggedUser(token); boolean canView = loggedUser.isAdmin() || loggedUser.isSuperAdmin(); return canView; @@ -380,11 +384,11 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#saveGroup(java.lang.String, java.lang.String) */ - public Group saveGroup(String token, String name) throws SimExplorerServiceException { + public Group saveGroup(String token, String name) throws SimExplorerException { if (canSaveElement(token)) { Group oldGroup = dao.getGroup(name); if (oldGroup != null) { - throw new SimExplorerServiceException(_("simexplorer.service.business.groupexist")); + throw new SimExplorerBusinessException(_("simexplorer.service.business.groupexist")); } Group group = new Group(); @@ -394,17 +398,17 @@ group = getGroup(token, group.getId()); return group; } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#saveUser(java.lang.String, java.lang.String, java.lang.String) */ - public User saveUser(String token, String login, String mail) throws SimExplorerServiceException { + public User saveUser(String token, String login, String mail) throws SimExplorerException { if (canSaveElement(token)) { User oldUser = dao.getUser(login); if (oldUser != null) { - throw new SimExplorerServiceException(_("simexplorer.service.business.userexist")); + throw new SimExplorerBusinessException(_("simexplorer.service.business.userexist")); } User user = new User(); @@ -416,14 +420,14 @@ String passwordHash = AuthenticationServiceHelper.computeHash(password); user.setPasswordHash(passwordHash); // reset array - Arrays.fill(password,(char)0); + Arrays.fill(password, (char) 0); user.setAdmin(false); user.setSuperAdmin(false); dao.saveUser(user); user = getUser(token, user.getId()); return user; } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /** @@ -434,20 +438,20 @@ * * @return true, if successful * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private boolean canUpdateGroup(String token, Integer id) throws SimExplorerServiceException { + private boolean canUpdateGroup(String token, Integer id) throws SimExplorerException { return canAdminGroup(token, id); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#updateGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group) */ - public Group updateGroup(String token, Group group) throws SimExplorerServiceException { + public Group updateGroup(String token, Group group) throws SimExplorerException { if (canUpdateGroup(token, group.getId())) { return dao.updateGroup(group); } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /** @@ -458,9 +462,9 @@ * * @return true, if successful * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private boolean canUpdateUser(String token, User user) throws SimExplorerServiceException { + private boolean canUpdateUser(String token, User user) throws SimExplorerException { if (canAdminUser(token, user.getId())) { if (getLoggedUser(token).isSuperAdmin()) { return true; @@ -476,17 +480,17 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#updateUser(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User) */ - public User updateUser(String token, User user) throws SimExplorerServiceException { + public User updateUser(String token, User user) throws SimExplorerException { if (canUpdateUser(token, user)) { return dao.updateUser(user); } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getLoggedUser(java.lang.String) */ - public User getLoggedUser(String token) throws SimExplorerServiceException { + public User getLoggedUser(String token) throws SimExplorerException { if (token == null || token.equals("")) { return null; } @@ -495,15 +499,15 @@ if (loggedUser != null) { return loggedUser; } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /** * Check super admin. * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private void checkSuperAdmin() throws SimExplorerServiceException { + private void checkSuperAdmin() throws SimExplorerException { if (dao.getUser("superadmin") == null) { User user = new User(); user.setLogin("superadmin"); @@ -520,7 +524,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#loginUser(java.lang.String, java.lang.String) */ - public String loginUser(String login, String password) throws SimExplorerServiceException { + public String loginUser(String login, String password) throws SimExplorerException { if (!superAdminCheck) { I18n.initISO88591("fr", "FR"); checkSuperAdmin(); @@ -528,7 +532,7 @@ } String token = null; // le password est deja haché - //User loggedUser = dao.loginUser(login, AuthenticationServiceHelper.computeHash(password)); + // User loggedUser = dao.loginUser(login, AuthenticationServiceHelper.computeHash(password)); User loggedUser = dao.loginUser(login, password); if (loggedUser != null) { // FIXME delete previous tokens @@ -547,7 +551,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#requestAccount(java.lang.String, java.lang.String) */ - public void requestAccount(String login, String mail) throws SimExplorerServiceException { + public void requestAccount(String login, String mail) throws SimExplorerException { User superadmin = dao.getUser("superadmin"); sendMail(Config.getProperties().getProperty("simexplorer.adminmail"), superadmin.getMail(), _("simexplorer.service.mail.subject"), getMailContentRequestAccount(login, mail)); @@ -557,7 +561,7 @@ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#changePassword(java.lang.String, java.lang.String) */ // public void changePassword(String token, String password) - // throws SimExplorerServiceException { + // throws SimExplorerException { // User user = getLoggedUser(token); // String passwordHash = computeHash(password); // user.setPasswordHash(passwordHash); @@ -566,70 +570,70 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#resetPassword(java.lang.String, java.lang.String) */ - public void resetPassword(String token, String login) throws SimExplorerServiceException { + public void resetPassword(String token, String login) throws SimExplorerException { User user = getUser(token, login); if (canAdminUser(token, user.getId())) { char[] password = generatePassword(); sendMail(Config.getProperties().getProperty("simexplorer.adminmail"), user.getMail(), _("simexplorer.service.mail.subject"), getMailContentWithPassword(login, password)); String passwordHash = AuthenticationServiceHelper.computeHash(password); - // reset char[] - Arrays.fill(password,(char)0); + // reset char[] + Arrays.fill(password, (char) 0); user.setPasswordHash(passwordHash); dao.updateUser(user); } else { - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroups(java.lang.String) */ - public Group[] getGroups(String token) throws SimExplorerServiceException { + public Group[] getGroups(String token) throws SimExplorerException { if (canViewElements(token)) { List<Group> groups = dao.getGroups(); return groups.toArray(new Group[groups.size()]); } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroupsOwnedBy(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User) */ - public Group[] getGroupsOwnedBy(String token, User user) throws SimExplorerServiceException { + public Group[] getGroupsOwnedBy(String token, User user) throws SimExplorerException { if (canViewElements(token)) { List<Group> list = dao.getGroupsOwnedBy(user); return list.toArray(new Group[list.size()]); } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUsers(java.lang.String) */ - public User[] getUsers(String token) throws SimExplorerServiceException { + public User[] getUsers(String token) throws SimExplorerException { if (canViewElements(token)) { List<User> users = dao.getUsers(); return users.toArray(new User[users.size()]); } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUsersOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group) */ - public User[] getUsersOfGroup(String token, Group group) throws SimExplorerServiceException { + public User[] getUsersOfGroup(String token, Group group) throws SimExplorerException { if (canViewElements(token)) { List<User> usersOfGroup = dao.getUsersOfGroup(group); return usersOfGroup.toArray(new User[usersOfGroup.size()]); } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setUsersOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group, java.lang.Integer[]) */ - public void setUsersOfGroup(String token, Group group, Integer[] usersInGroup) throws SimExplorerServiceException { + public void setUsersOfGroup(String token, Group group, Integer[] usersInGroup) throws SimExplorerException { if (canUpdateGroup(token, group.getId())) { List<Integer> newUsers = new ArrayList<Integer>(); newUsers.addAll(Arrays.asList(usersInGroup)); @@ -666,14 +670,14 @@ dao.updateUser(user); } } else { - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setGroupsOfUser(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User, java.lang.Integer[]) */ - public void setGroupsOfUser(String token, User user, Integer[] groupsIds) throws SimExplorerServiceException { + public void setGroupsOfUser(String token, User user, Integer[] groupsIds) throws SimExplorerException { if (canUpdateUser(token, user)) { User realUser = dao.getUser(user.getId()); realUser.getGroups().clear(); @@ -683,36 +687,36 @@ } dao.updateUser(realUser); } else { - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroupsOfUser(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User) */ - public Group[] getGroupsOfUser(String token, User user) throws SimExplorerServiceException { + public Group[] getGroupsOfUser(String token, User user) throws SimExplorerException { if (canViewElements(token)) { List<Group> list = dao.getGroupsOfUser(user); return list.toArray(new Group[list.size()]); } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroupsOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group) */ - public Group[] getGroupsOfGroup(String token, Group group) throws SimExplorerServiceException { + public Group[] getGroupsOfGroup(String token, Group group) throws SimExplorerException { if (canViewElements(token)) { List<Group> groupsOfGroup = dao.getGroupsOfGroup(group); return groupsOfGroup.toArray(new Group[groupsOfGroup.size()]); } - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setGroupsOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group, java.lang.Integer[]) */ - public void setGroupsOfGroup(String token, Group group, Integer[] groupsIds) throws SimExplorerServiceException { + public void setGroupsOfGroup(String token, Group group, Integer[] groupsIds) throws SimExplorerException { if (canUpdateGroup(token, group.getId())) { Group realGroup = dao.getGroup(group.getId()); realGroup.getGroups().clear(); @@ -722,7 +726,7 @@ } dao.updateGroup(realGroup); } else { - throw new SimExplorerServiceException(_("simexplorer.service.security.norights")); + throw new SimExplorerSecurityException(); } } Deleted: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -1,69 +0,0 @@ -/* -* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, -* Tony Chemit, Gabriel Landais -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.service; - -/** - * Exception de base pour toute erreur rencontrée dans un service. - * - * @author chemit - */ -public class SimExplorerServiceException extends Exception { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1054522404126322604L; - - /** - * Instantiates a new sim explorer service exception. - */ - public SimExplorerServiceException() { - super(); - } - - /** - * Instantiates a new sim explorer service exception. - * - * @param cause - * the cause - */ - public SimExplorerServiceException(Throwable cause) { - super(cause); - } - - /** - * Instantiates a new sim explorer service exception. - * - * @param message - * the message - */ - public SimExplorerServiceException(String message) { - super(message); - } - - /** - * Instantiates a new sim explorer service exception. - * - * @param message - * the message - * @param cause - * the cause - */ - public SimExplorerServiceException(String message, Throwable cause) { - super(message, cause); - } -} Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -28,6 +28,7 @@ import fr.cemagref.simexplorer.is.entities.data.LoggableElement; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * Service interface. @@ -45,9 +46,9 @@ * * @return Token as logon evidence * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - String loginUser(String login, String password) throws SimExplorerServiceException; + String loginUser(String login, String password) throws SimExplorerException; /** * Save an element. @@ -57,9 +58,9 @@ * * @return Metadata of element imported * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - MetaData saveElement(String token, SerializableInputStream zipStream) throws SimExplorerServiceException; + MetaData saveElement(String token, SerializableInputStream zipStream) throws SimExplorerException; /** * Save an element. @@ -70,10 +71,10 @@ * * @return Metadata of element saved * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ MetaData saveElement(String token, SerializableInputStream xmlStream, - Map<Attachment, SerializableInputStream> attachmentsStream) throws SimExplorerServiceException; + Map<Attachment, SerializableInputStream> attachmentsStream) throws SimExplorerException; /** * Update. @@ -84,10 +85,10 @@ * @param updatedElement the updated element * @param justRemoveLatest just remove latest, if true, updatedElement has to be null * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ void update(String token, String uuid, Version version, MetaData updatedElement, boolean justRemoveLatest) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Retrieve metadata (latest version). @@ -97,9 +98,9 @@ * * @return the metadata * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - MetaData getMetadata(String token, String uuid) throws SimExplorerServiceException; + MetaData getMetadata(String token, String uuid) throws SimExplorerException; /** * Retrieve metadata. @@ -110,9 +111,9 @@ * * @return the metadata * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - MetaData getMetadata(String token, String uuid, String version) throws SimExplorerServiceException; + MetaData getMetadata(String token, String uuid, String version) throws SimExplorerException; /** * Gets the metadatas used by the element. @@ -123,9 +124,9 @@ * * @return the metadatas used * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - MetaData[] getMetadatasUsed(String token, String uuid, String version) throws SimExplorerServiceException; + MetaData[] getMetadatasUsed(String token, String uuid, String version) throws SimExplorerException; /** * Gets the metadatas using the element. @@ -136,9 +137,9 @@ * * @return the metadatas using * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - MetaData[] getMetadatasUsing(String token, String uuid, String version) throws SimExplorerServiceException; + MetaData[] getMetadatasUsing(String token, String uuid, String version) throws SimExplorerException; /** * Export XML of element to a stream. @@ -149,9 +150,9 @@ * * @return RMIIO stream with data * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - InputStream retrieveElementXML(String token, String uuid, String version) throws SimExplorerServiceException; + InputStream retrieveElementXML(String token, String uuid, String version) throws SimExplorerException; /** * Export full element to a stream as a zip. @@ -162,9 +163,9 @@ * * @return the input stream * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - InputStream retrieveElementFull(String token, String uuid, String version) throws SimExplorerServiceException; + InputStream retrieveElementFull(String token, String uuid, String version) throws SimExplorerException; /** * Retrieve data related to an entity. @@ -176,10 +177,10 @@ * * @return the input stream * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ InputStream retrieveElementData(String token, String uuid, String version, Attachment attachment) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Retrieve number of elements matching query. @@ -190,9 +191,9 @@ * * @return the int * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerServiceException; + int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException; /** * Find elements matching query. @@ -206,10 +207,10 @@ * * @return the meta data[] * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, int dateOrder) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Retrieve number of applications. @@ -219,9 +220,9 @@ * * @return the int * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - int findApplicationsCount(String token, boolean onlyLatest) throws SimExplorerServiceException; + int findApplicationsCount(String token, boolean onlyLatest) throws SimExplorerException; /** * Get a list of applications. @@ -234,10 +235,10 @@ * * @return the meta data[] * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ MetaData[] findApplications(String token, boolean onlyLatest, int start, int count, int dateOrder) - throws SimExplorerServiceException; + throws SimExplorerException; /** * Fully load an element. @@ -248,9 +249,9 @@ * * @return the element * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - LoggableElement getLoggableElement(String token, String uuid, String version) throws SimExplorerServiceException; + LoggableElement getLoggableElement(String token, String uuid, String version) throws SimExplorerException; /** * Get all version of an element. @@ -260,9 +261,9 @@ * * @return the versions * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - Version[] getVersions(String token, String uuid) throws SimExplorerServiceException; + Version[] getVersions(String token, String uuid) throws SimExplorerException; /** * Delete element. @@ -271,9 +272,9 @@ * @param uuid the uuid * @param version the version * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - void deleteElement(String token, String uuid, String version) throws SimExplorerServiceException; + void deleteElement(String token, String uuid, String version) throws SimExplorerException; /** * Delete element. @@ -281,8 +282,8 @@ * @param token the token * @param uuid the uuid * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - void deleteElement(String token, String uuid) throws SimExplorerServiceException; + void deleteElement(String token, String uuid) throws SimExplorerException; } Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceClient.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceClient.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceClient.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -18,9 +18,9 @@ package fr.cemagref.simexplorer.is.service; import static org.codelutin.i18n.I18n._; - import fr.cemagref.simexplorer.is.entities.metadata.Version; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerBusinessException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.storage.engine.StorageEngine; import fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl; @@ -36,8 +36,8 @@ * @see fr.cemagref.simexplorer.is.service.StorageService#loginUser(java.lang.String, java.lang.String) */ public String loginUser(String login, String password) - throws SimExplorerServiceException { - throw new SimExplorerServiceException( + throws SimExplorerException { + throw new SimExplorerBusinessException( _("simexplorer.service.nologonlocal")); } @@ -46,7 +46,7 @@ */ @Override protected StorageEngine getStorageEngine() - throws SimExplorerStorageException { + throws SimExplorerException { if (storageEngine == null) { storageEngine = new StorageEngineImpl(); storageEngine.open(); Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -19,6 +19,7 @@ import static org.codelutin.i18n.I18n._; +import java.io.IOException; import java.io.InputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; @@ -45,10 +46,12 @@ import fr.cemagref.simexplorer.is.entities.data.LoggableElement; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerBusinessException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; import fr.cemagref.simexplorer.is.factories.BaseEntityFactory; import fr.cemagref.simexplorer.is.factories.MetaDataFactory; import fr.cemagref.simexplorer.is.factories.XmlConstants; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; import fr.cemagref.simexplorer.is.storage.engine.StorageEngine; /** @@ -64,9 +67,9 @@ * * @return the storage engine * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - protected abstract StorageEngine getStorageEngine() throws SimExplorerStorageException; + protected abstract StorageEngine getStorageEngine() throws SimExplorerException; /** * Increment version. @@ -80,114 +83,76 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#getMetadata(java.lang.String, java.lang.String) */ - public MetaData getMetadata(String token, String uuid) throws SimExplorerServiceException { - try { - return getStorageEngine().getMetadata(token, uuid); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + public MetaData getMetadata(String token, String uuid) throws SimExplorerException { + return getStorageEngine().getMetadata(token, uuid); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#getMetadata(java.lang.String, java.lang.String, java.lang.String) */ - public MetaData getMetadata(String token, String uuid, String version) throws SimExplorerServiceException { - try { - return getStorageEngine().getMetadata(token, uuid, new Version(version)); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + public MetaData getMetadata(String token, String uuid, String version) throws SimExplorerException { + return getStorageEngine().getMetadata(token, uuid, new Version(version)); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#getMetadatasUsed(java.lang.String, java.lang.String, java.lang.String) */ @Override - public MetaData[] getMetadatasUsed(String token, String uuid, String version) throws SimExplorerServiceException { - try { - return getStorageEngine().getMetadatasUsed(token, uuid, new Version(version)); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + public MetaData[] getMetadatasUsed(String token, String uuid, String version) throws SimExplorerException { + return getStorageEngine().getMetadatasUsed(token, uuid, new Version(version)); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#getMetadatasUsing(java.lang.String, java.lang.String, java.lang.String) */ @Override - public MetaData[] getMetadatasUsing(String token, String uuid, String version) throws SimExplorerServiceException { - try { - return getStorageEngine().getMetadatasUsing(token, uuid, new Version(version)); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + public MetaData[] getMetadatasUsing(String token, String uuid, String version) throws SimExplorerException { + return getStorageEngine().getMetadatasUsing(token, uuid, new Version(version)); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#findFullText(java.lang.String, java.lang.String, boolean, int, int, int) */ public MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, - int dateOrder) throws SimExplorerServiceException { - try { - return getStorageEngine().findFullText(token, query, onlyLatest, indexStart, count, dateOrder); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + int dateOrder) throws SimExplorerException { + return getStorageEngine().findFullText(token, query, onlyLatest, indexStart, count, dateOrder); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#findFullTextCount(java.lang.String, java.lang.String, boolean) */ - public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerServiceException { - try { - return getStorageEngine().findFullTextCount(token, query, onlyLatest); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException { + return getStorageEngine().findFullTextCount(token, query, onlyLatest); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#findApplicationsCount(java.lang.String, boolean) */ - public int findApplicationsCount(String token, boolean onlyLatest) throws SimExplorerServiceException { - try { - return getStorageEngine().findElementsByTypeCount(token, VALUE_METADATA_TYPE_EA, onlyLatest); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + public int findApplicationsCount(String token, boolean onlyLatest) throws SimExplorerException { + return getStorageEngine().findElementsByTypeCount(token, VALUE_METADATA_TYPE_EA, onlyLatest); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#findApplications(java.lang.String, boolean, int, int, int) */ public MetaData[] findApplications(String token, boolean onlyLatest, int start, int count, int dateOrder) - throws SimExplorerServiceException { - try { - return getStorageEngine().findElementsByType(token, VALUE_METADATA_TYPE_EA, onlyLatest, start, count, - dateOrder); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + throws SimExplorerException { + return getStorageEngine() + .findElementsByType(token, VALUE_METADATA_TYPE_EA, onlyLatest, start, count, dateOrder); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#getLoggableElement(java.lang.String, java.lang.String, java.lang.String) */ - public LoggableElement getLoggableElement(String token, String uuid, String version) - throws SimExplorerServiceException { + public LoggableElement getLoggableElement(String token, String uuid, String version) throws SimExplorerException { MetaData mde = getMetadata(token, uuid, version); - try { - LoggableElement le; - BaseEntityFactory<? extends DataEntity> factory = BaseEntityFactory.getFactory(LoggableElement.class - .getPackage().getName() - + DOT + mde.getType()); - le = (LoggableElement) factory.loadElement(getStorageEngine().retrieveData(token, mde, getXMLAttachment())); + LoggableElement le; + BaseEntityFactory<? extends DataEntity> factory; + factory = BaseEntityFactory.getFactory(LoggableElement.class.getPackage().getName() + DOT + mde.getType()); + le = (LoggableElement) factory.loadElement(getStorageEngine().retrieveData(token, mde, getXMLAttachment())); - return le; - } catch (Exception e) { - throw new SimExplorerServiceException(e); - } + return le; } /** @@ -198,58 +163,69 @@ * * @return the meta data * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public MetaData saveElement(String token, SerializableInputStream zipStream) throws SimExplorerServiceException { + public MetaData saveElement(String token, SerializableInputStream zipStream) throws SimExplorerException { String xmlFile = null; Map<Attachment, String> attachments = new HashMap<Attachment, String>(); ZipInputStream zis = new ZipInputStream(zipStream); + ZipEntry entry; try { - ZipEntry entry; - while ((entry = zis.getNextEntry()) != null) { - if (!entry.isDirectory()) { - String entryName = entry.getName(); - if (entryName.equals(FILE_XML)) { - xmlFile = getStorageEngine().storeTempData(zis); - } else { - if (entryName.startsWith(FILE_DATA_PREFIX)) { - String fileName = entryName.replace(FILE_DATA_PREFIX + FOLDER_SEPARATOR, ""); + entry = zis.getNextEntry(); + } catch (IOException e) { + throw new SimExplorerTechnicalException(e); + } - String zipMD5 = Attachment.getHashFromUniqueId(fileName); - fileName = Attachment.getFileNameFromUniqueId(fileName); + while (entry != null) { + if (!entry.isDirectory()) { + String entryName = entry.getName(); + if (entryName.equals(FILE_XML)) { + xmlFile = getStorageEngine().storeTempData(zis); + } else { + if (entryName.startsWith(FILE_DATA_PREFIX)) { + String fileName = entryName.replace(FILE_DATA_PREFIX + FOLDER_SEPARATOR, ""); - MD5InputStream md5Stream = new MD5InputStream(zis); - String idFile = getStorageEngine().storeTempData(md5Stream); + String zipMD5 = Attachment.getHashFromUniqueId(fileName); + fileName = Attachment.getFileNameFromUniqueId(fileName); - String localMD5 = MD5.asHex(md5Stream.hash()); + MD5InputStream md5Stream = new MD5InputStream(zis); + String idFile = getStorageEngine().storeTempData(md5Stream); - if (!localMD5.equals(zipMD5)) { + String localMD5 = MD5.asHex(md5Stream.hash()); - throw new SimExplorerServiceException(_("simexplorer.service.invalidhash")); + if (!localMD5.equals(zipMD5)) { + throw new SimExplorerBusinessException(_("simexplorer.service.invalidhash")); - } - - Attachment attachment = new Attachment(); - attachment.setFileName(fileName); - attachment.setDataHash(localMD5); - attachments.put(attachment, idFile); } + Attachment attachment = new Attachment(); + attachment.setFileName(fileName); + attachment.setDataHash(localMD5); + attachments.put(attachment, idFile); } } } - - Document document = BaseEntityFactory.getXMLBuilder().parse(getStorageEngine().retrieveTempData(xmlFile)); - MetaData elementSaved = saveElement(token, document, getFirstElement(document), attachments); - getStorageEngine().deleteTempData(xmlFile); - for (Map.Entry<Attachment, String> tmpId : attachments.entrySet()) { - getStorageEngine().deleteTempData(tmpId.getValue()); + try { + entry = zis.getNextEntry(); + } catch (IOException e) { + throw new SimExplorerTechnicalException(e); } - return elementSaved; + + } + Document document; + InputStream xmlData = getStorageEngine().retrieveTempData(xmlFile); + try { + document = BaseEntityFactory.getXMLBuilder().parse(xmlData); } catch (Exception e) { - throw new SimExplorerServiceException(e); + throw new SimExplorerTechnicalException(e); } + MetaData elementSaved = saveElement(token, document, getFirstElement(document), attachments); + getStorageEngine().deleteTempData(xmlFile); + for (Map.Entry<Attachment, String> tmpId : attachments.entrySet()) { + getStorageEngine().deleteTempData(tmpId.getValue()); + } + return elementSaved; } /** @@ -261,28 +237,30 @@ * * @return the meta data * - * @throws SimExplorerServiceException the exception + * @throws SimExplorerException the exception */ public MetaData saveElement(String token, SerializableInputStream xmlFile, - Map<Attachment, SerializableInputStream> attachments) throws SimExplorerServiceException { - try { - // Store temporary data - String idxml = getStorageEngine().storeTempData(xmlFile); - Map<Attachment, String> idsattachment = new HashMap<Attachment, String>(); - for (Map.Entry<Attachment, SerializableInputStream> entry : attachments.entrySet()) { - String idattachment = getStorageEngine().storeTempData(entry.getValue()); - idsattachment.put(entry.getKey(), idattachment); - } - Document document = BaseEntityFactory.getXMLBuilder().parse(getStorageEngine().retrieveTempData(idxml)); - MetaData elementSaved = saveElement(token, document, getFirstElement(document), idsattachment); - getStorageEngine().deleteTempData(idxml); - for (Map.Entry<Attachment, String> tmpId : idsattachment.entrySet()) { - getStorageEngine().deleteTempData(tmpId.getValue()); - } - return elementSaved; + Map<Attachment, SerializableInputStream> attachments) throws SimExplorerException { + // Store temporary data + String idxml = getStorageEngine().storeTempData(xmlFile); + Map<Attachment, String> idsattachment = new HashMap<Attachment, String>(); + for (Map.Entry<Attachment, SerializableInputStream> entry : attachments.entrySet()) { + String idattachment = getStorageEngine().storeTempData(entry.getValue()); + idsattachment.put(entry.getKey(), idattachment); + } + Document document; + InputStream xmlData = getStorageEngine().retrieveTempData(idxml); + try { + document = BaseEntityFactory.getXMLBuilder().parse(xmlData); } catch (Exception e) { - throw new SimExplorerServiceException(e); + throw new SimExplorerTechnicalException(e); } + MetaData elementSaved = saveElement(token, document, getFirstElement(document), idsattachment); + getStorageEngine().deleteTempData(idxml); + for (Map.Entry<Attachment, String> tmpId : idsattachment.entrySet()) { + getStorageEngine().deleteTempData(tmpId.getValue()); + } + return elementSaved; } /** @@ -295,18 +273,20 @@ * * @return the input stream * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public InputStream retrieveElementData(String token, String uuid, String version, Attachment attachment) - throws SimExplorerServiceException { - try { - MetaData mde = getMetadata(token, uuid, version); - InputStream stream = getStorageEngine().retrieveData(token, mde, attachment); + throws SimExplorerException { + MetaData mde = getMetadata(token, uuid, version); + InputStream stream = getStorageEngine().retrieveData(token, mde, attachment); - return new SerializableInputStream(stream); - } catch (Exception e) { - throw new SimExplorerServiceException(e); + SerializableInputStream serializableInputStream; + try { + serializableInputStream = new SerializableInputStream(stream); + } catch (IOException e) { + throw new SimExplorerTechnicalException(e); } + return serializableInputStream; } /** @@ -318,17 +298,18 @@ * * @return the input stream * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public InputStream retrieveElementXML(String token, String uuid, String version) throws SimExplorerServiceException { + public InputStream retrieveElementXML(String token, String uuid, String version) throws SimExplorerException { MetaData mde = getMetadata(token, uuid, version); + InputStream xmlStream = getStorageEngine().retrieveData(token, mde, getXMLAttachment()); + SerializableInputStream serializableInputStream; try { - InputStream xmlStream = getStorageEngine().retrieveData(token, mde, getXMLAttachment()); - return new SerializableInputStream(xmlStream); - } catch (Exception e) { - throw new SimExplorerServiceException(e); + serializableInputStream = new SerializableInputStream(xmlStream); + } catch (IOException e) { + throw new SimExplorerTechnicalException(e); } - + return serializableInputStream; } /** @@ -340,123 +321,108 @@ * * @return the input stream * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public InputStream retrieveElementFull(String token, String uuid, String version) - throws SimExplorerServiceException { + public InputStream retrieveElementFull(String token, String uuid, String version) throws SimExplorerException { LoggableElement element = getLoggableElement(token, uuid, version); MetaData mde = element.getMetaData(); - try { - PipedOutputStream pipedOut = new PipedOutputStream(); - Map<String, InputStream> files = new HashMap<String, InputStream>(); + PipedOutputStream pipedOut = new PipedOutputStream(); + Map<String, InputStream> files = new HashMap<String, InputStream>(); - files.put(FILE_XML, getStorageEngine().retrieveData(token, mde, getXMLAttachment())); - List<LoggableElement> children = element.getChildren(); - for (LoggableElement loggableElement : children) { - MetaData thisMde = loggableElement.getMetaData(); - List<Attachment> attachments = loggableElement.getMetaData().getAttachments(); - for (Attachment attachment : attachments) { - files.put(FILE_DATA_PREFIX + FOLDER_SEPARATOR + attachment.getUniqueId(), getStorageEngine() - .retrieveData(token, thisMde, attachment)); - } + files.put(FILE_XML, getStorageEngine().retrieveData(token, mde, getXMLAttachment())); + List<LoggableElement> children = element.getChildren(); + for (LoggableElement loggableElement : children) { + MetaData thisMde = loggableElement.getMetaData(); + List<Attachment> attachments = loggableElement.getMetaData().getAttachments(); + for (Attachment attachment : attachments) { + files.put(FILE_DATA_PREFIX + FOLDER_SEPARATOR + attachment.getUniqueId(), getStorageEngine() + .retrieveData(token, thisMde, attachment)); } + } + SerializableInputStream serializableInputStream; + try { PipedInputStream pipedIn = new PipedInputStream(pipedOut); ZipStreamEncoder zse = new ZipStreamEncoder(files, pipedOut); zse.start(); - return new SerializableInputStream(pipedIn); - } catch (Exception e) { - throw new SimExplorerServiceException(e); + serializableInputStream = new SerializableInputStream(pipedIn); + } catch (IOException e) { + throw new SimExplorerTechnicalException(e); } - + return serializableInputStream; } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#update(java.lang.String, java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version, fr.cemagref.simexplorer.is.entities.metadata.MetaData, boolean) */ public void update(String token, String uuid, Version version, MetaData updatedElement, boolean justRemoveLatest) - throws SimExplorerServiceException { + throws SimExplorerException { Map<Attachment, InputStream> attachments = new HashMap<Attachment, InputStream>(); - try { - MetaData elementToUpdate; + MetaData elementToUpdate; - MetaData currentMetaData = getStorageEngine().getMetadata(token, uuid, version); - - if (justRemoveLatest) { - currentMetaData.setLatest(false); - elementToUpdate = currentMetaData; - } else { - elementToUpdate = updatedElement; - } + MetaData currentMetaData = getStorageEngine().getMetadata(token, uuid, version); - InputStream currentXml = getStorageEngine().retrieveData(token, currentMetaData, getXMLAttachment()); + if (justRemoveLatest) { + currentMetaData.setLatest(false); + elementToUpdate = currentMetaData; + } else { + elementToUpdate = updatedElement; + } + InputStream currentXml = getStorageEngine().retrieveData(token, currentMetaData, getXMLAttachment()); + + InputStream newXml = null; MetaDataFactory<MetaData> mdeFactory = MetaDataFactory.getFactory(MetaData.class); - InputStream newXml = mdeFactory.modifyMedataElementStream(currentXml, elementToUpdate); + newXml = mdeFactory.modifyMedataElementStream(currentXml, elementToUpdate); - attachments.put(getXMLAttachment(), newXml); + attachments.put(getXMLAttachment(), newXml); - List<Attachment> realAttachments = currentMetaData.getAttachments(); - for (Attachment attachment : realAttachments) { - attachments.put(attachment, getStorageEngine().retrieveData(token, currentMetaData, attachment)); - } + List<Attachment> realAttachments = currentMetaData.getAttachments(); + for (Attachment attachment : realAttachments) { + attachments.put(attachment, getStorageEngine().retrieveData(token, currentMetaData, attachment)); + } - if (justRemoveLatest) { - getStorageEngine().deleteElement(token, uuid, version); - } else { - getStorageEngine().duplicateElementHierarchy(token, currentMetaData, elementToUpdate); - } - getStorageEngine().saveElement(token, elementToUpdate, attachments); - getStorageEngine().commit(); - } catch (Exception e) { - throw new SimExplorerServiceException(e); + if (justRemoveLatest) { + getStorageEngine().deleteElement(token, uuid, version); + } else { + getStorageEngine().duplicateElementHierarchy(token, currentMetaData, elementToUpdate); } + getStorageEngine().saveElement(token, elementToUpdate, attachments); + getStorageEngine().commit(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#getVersions(java.lang.String, java.lang.String) */ - public Version[] getVersions(String token, String uuid) throws SimExplorerServiceException { - try { - Set<MetaData> versions = getStorageEngine().getElementVersions(token, uuid); - Version[] result = new Version[versions.size()]; - int i = 0; - for (MetaData metaData : versions) { - result[i] = metaData.getVersion(); - i++; - } - return result; - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); + public Version[] getVersions(String token, String uuid) throws SimExplorerException { + Set<MetaData> versions = getStorageEngine().getElementVersions(token, uuid); + Version[] result = new Version[versions.size()]; + int i = 0; + for (MetaData metaData : versions) { + result[i] = metaData.getVersion(); + i++; } + return result; } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#deleteElement(java.lang.String, java.lang.String, java.lang.String) */ - public void deleteElement(String token, String uuid, String version) throws SimExplorerServiceException { - try { - // FIXME - getStorageEngine().deleteElement(token, uuid, new Version(version)); - getStorageEngine().commit(); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + public void deleteElement(String token, String uuid, String version) throws SimExplorerException { + // FIXME + getStorageEngine().deleteElement(token, uuid, new Version(version)); + getStorageEngine().commit(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#deleteElement(java.lang.String, java.lang.String) */ - public void deleteElement(String token, String uuid) throws SimExplorerServiceException { - try { - // FIXME - getStorageEngine().deleteElements(token, uuid); - getStorageEngine().commit(); - } catch (SimExplorerStorageException e) { - throw new SimExplorerServiceException(e); - } + public void deleteElement(String token, String uuid) throws SimExplorerException { + // FIXME + getStorageEngine().deleteElements(token, uuid); + getStorageEngine().commit(); } /** @@ -467,10 +433,10 @@ * @param document the document * @param xmlNode the xml node * - * @throws Exception the exception + * @throws SimExplorerException the exception */ protected void processVersionRules(String token, MetaData metaData, Document document, Element xmlNode) - throws Exception { + throws SimExplorerException { // This one will always be the latest metaData.setLatest(true); @@ -500,11 +466,11 @@ metaData.setParentVersionUuid(previousVersion.getUuid()); metaData.setParentVersionVersion(previousVersion.getVersion().toString()); - // get metadata factory - MetaDataFactory<MetaData> mdeFactory = MetaDataFactory.getFactory(MetaData.class); + // get metadata factory + MetaDataFactory<MetaData> mdeFactory = MetaDataFactory.getFactory(MetaData.class); - // Update XML with version updated - mdeFactory.replaceMetadataInXML(document, xmlNode, metaData); + // Update XML with version updated + mdeFactory.replaceMetadataInXML(document, xmlNode, metaData); } } @@ -550,9 +516,9 @@ * * @return true, if successful * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - private boolean notExists(String token, MetaData metaData) throws Exception { + private boolean notExists(String token, MetaData metaData) throws SimExplorerException { MetaData previousVersion = getStorageEngine().getMetadata(token, metaData.getUuid()); // Check if previous is not null and both hash are equals @@ -569,7 +535,12 @@ if (getStorageEngine().canCreateSubVersion(token, metaData.getUuid())) { // trying to save a version with same hash but in superior version // so we will copy versionToUpgrade to metaData.getVersion() - Version versionToUpgrade = previousVersion.getVersion().clone(); + Version versionToUpgrade; + try { + versionToUpgrade = previousVersion.getVersion().clone(); + } catch (CloneNotSupportedException e) { + throw new SimExplorerTechnicalException(e); + } // set previous as not being the latest one update(token, previousVersion.getUuid(), previousVersion.getVersion(), null, true); @@ -604,16 +575,17 @@ * * @return the meta data * - * @throws Exception the exception + * @throws SimExplorerException the exception */ private MetaData saveElement(String token, Document document, Element xmlNode, Map<Attachment, String> idsattachment) - throws Exception { - // Load metadata xml - MetaDataFactory<MetaData> mdeFactory = MetaDataFactory.getFactory(MetaData.class); - MetaData metaData = mdeFactory.loadElementFromParentXML(xmlNode); + throws SimExplorerException { + MetaData metaData; + // Load metadata xml + MetaDataFactory<MetaData> mdeFactory = MetaDataFactory.getFactory(MetaData.class); + metaData = mdeFactory.loadElementFromParentXML(xmlNode); - // Compute element hash - metaData.setHash(mdeFactory.computeHash(xmlNode)); + // Compute element hash + metaData.setHash(mdeFactory.computeHash(xmlNode)); if (notExists(token, metaData)) { @@ -637,14 +609,14 @@ // Prepare saving Map<Attachment, InputStream> attachments = new HashMap<Attachment, InputStream>(); - attachments.put(getXMLAttachment(), BaseEntityFactory.serializeElement(xmlNode)); + attachments.put(getXMLAttachment(), BaseEntityFactory.serializeElement(xmlNode)); List<Attachment> realAttachments = metaData.getAttachments(); for (Attachment attachment : realAttachments) { String idAttachment = idsattachment.get(attachment); // Check hash of attachments if (idAttachment == null) { - throw new SimExplorerServiceException(_("simexplorer.service.attachmentnotfund")); + throw new SimExplorerBusinessException(_("simexplorer.service.attachmentnotfund")); } attachments.put(attachment, getStorageEngine().retrieveTempData(idAttachment)); } @@ -668,12 +640,13 @@ * @param node the node * @param parent the parent * - * @throws Exception the exception + * @throws SimExplorerException the exception */ private void saveSubElements(String token, MetaData parent, Document document, Element node, String entitiesNode, - String entityNode, Map<Attachment, String> idsattachment) throws Exception { + String entityNode, Map<Attachment, String> idsattachment) throws SimExplorerException { - BaseEntityFactory<MetaData> elementFactory = MetaDataFactory.getFactory(MetaData.class); + BaseEntityFactory<MetaData> elementFactory; + elementFactory = MetaDataFactory.getFactory(MetaData.class); // Elements Element entitiesElement = elementFactory.getXMLElementByTagName(node, entitiesNode); Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceHelper.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceHelper.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceHelper.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -24,6 +24,8 @@ import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; public class StorageServiceHelper { @@ -40,10 +42,10 @@ * * @return the version * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ public static MetaData exportElementTo(String token, StorageService fromService, StorageService toService, - String uuid, String version) throws SimExplorerServiceException { + String uuid, String version) throws SimExplorerException { // Extract element from source service InputStream fromElement = fromService.retrieveElementFull(token, uuid, version); // Store element in remote service @@ -51,7 +53,7 @@ try { toElement = toService.saveElement(token, new SerializableInputStream(fromElement)); } catch (IOException e) { - throw new SimExplorerServiceException(e); + throw new SimExplorerTechnicalException(e); } // fromElement has to be updated Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceServer.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceServer.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceServer.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -17,21 +17,14 @@ * ##% */ package fr.cemagref.simexplorer.is.service; -import java.io.InputStream; -import java.rmi.RemoteException; - import javax.ejb.EJB; import javax.ejb.Remote; import javax.ejb.Stateless; import org.jboss.annotation.ejb.RemoteBinding; -import com.healthmarketscience.rmiio.RemoteInputStreamServer; -import com.healthmarketscience.rmiio.SimpleRemoteInputStream; - -import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.storage.engine.StorageEngine; /** @@ -53,7 +46,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#loginUser(java.lang.String, java.lang.String) */ - public String loginUser(String login, String password) throws SimExplorerServiceException { + public String loginUser(String login, String password) throws SimExplorerException { String token = authenticationService.loginUser(login, password); return token; } @@ -62,7 +55,7 @@ * @see fr.cemagref.simexplorer.is.service.StorageServiceCommon#getStorageEngine() */ @Override - protected StorageEngine getStorageEngine() throws SimExplorerStorageException { + protected StorageEngine getStorageEngine() throws SimExplorerException { storageEngine.open(); return storageEngine; } Deleted: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageSecurityException.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageSecurityException.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageSecurityException.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -1,65 +0,0 @@ -/* -* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.storage; - -/** - * The Class SimExplorerStorageSecurityException. - */ -public class SimExplorerStorageSecurityException extends SimExplorerStorageException { - - /** - * - */ - private static final long serialVersionUID = 862842493087651110L; - - /** - * Instantiates a new sim explorer storage security exception. - */ - public SimExplorerStorageSecurityException() { - super(); - } - - /** - * Instantiates a new sim explorer storage security exception. - * - * @param message the message - */ - public SimExplorerStorageSecurityException(String message) { - super(message); - } - - /** - * Instantiates a new sim explorer storage security exception. - * - * @param cause the cause - */ - public SimExplorerStorageSecurityException(Throwable cause) { - super(cause); - } - - /** - * Instantiates a new sim explorer storage security exception. - * - * @param message the message - * @param cause the cause - */ - public SimExplorerStorageSecurityException(String message, Throwable cause) { - super(message, cause); - } - -} Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -17,8 +17,6 @@ * ##% */ package fr.cemagref.simexplorer.is.storage.engine; -import static org.codelutin.i18n.I18n._; - import java.io.InputStream; import java.util.List; import java.util.Map; @@ -30,10 +28,10 @@ import fr.cemagref.simexplorer.is.attachment.Attachment; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerSecurityException; import fr.cemagref.simexplorer.is.security.credentials.CredentialManager; import fr.cemagref.simexplorer.is.security.entities.Permission; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageSecurityException; /** * The Class StorageEngineSecuImpl. @@ -50,13 +48,13 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#deleteElement(java.lang.String, java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) */ @Override - public void deleteElement(String token, String uuid, Version version) throws SimExplorerStorageException { + public void deleteElement(String token, String uuid, Version version) throws SimExplorerException { Permission permission = credentialManager.getPermission(token, uuid); // TODO check candelete = canadmin if (permission.isCanAdmin()) { super.deleteElement(token, uuid, version); } else { - throw new SimExplorerStorageSecurityException(); + throw new SimExplorerSecurityException(); } } @@ -64,13 +62,13 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#deleteElements(java.lang.String, java.lang.String) */ @Override - public void deleteElements(String token, String uuid) throws SimExplorerStorageException { + public void deleteElements(String token, String uuid) throws SimExplorerException { Permission permission = credentialManager.getPermission(token, uuid); // TODO check candelete = canadmin if (permission.isCanAdmin()) { super.deleteElements(token, uuid); } else { - throw new SimExplorerStorageSecurityException(); + throw new SimExplorerSecurityException(); } } @@ -79,7 +77,7 @@ */ @Override public MetaData[] findElementsByType(String token, String type, boolean onlyLatest, int start, int count, - int dateOrder) throws SimExplorerStorageException { + int dateOrder) throws SimExplorerException { MetaData[] list; list = super.findElementsByType(token, type, onlyLatest, start, count, dateOrder); // TODO how to filter without losing pagination? @@ -91,7 +89,7 @@ */ @Override public int findElementsByTypeCount(String token, String type, boolean onlyLatest) - throws SimExplorerStorageException { + throws SimExplorerException { // TODO how to filter without losing pagination? return super.findElementsByTypeCount(token, type, onlyLatest); } @@ -101,7 +99,7 @@ */ @Override public MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, - int dateOrder) throws SimExplorerStorageException { + int dateOrder) throws SimExplorerException { // TODO how to filter without losing pagination? return super.findFullText(token, query, onlyLatest, indexStart, count, dateOrder); } @@ -110,7 +108,7 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#findFullTextCount(java.lang.String, java.lang.String, boolean) */ @Override - public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerStorageException { + public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException { // TODO how to filter without losing pagination? return super.findFullTextCount(token, query, onlyLatest); } @@ -119,13 +117,13 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#getMetadata(java.lang.String, java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) */ @Override - public MetaData getMetadata(String token, String uuid, Version version) throws SimExplorerStorageException { + public MetaData getMetadata(String token, String uuid, Version version) throws SimExplorerException { MetaData mde; Permission permission = credentialManager.getPermission(token, uuid); if (permission.isCanRead()) { mde = super.getMetadata(token, uuid, version); } else { - throw new SimExplorerStorageSecurityException(); + throw new SimExplorerSecurityException(); } return mde; } @@ -134,13 +132,13 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#getMetadata(java.lang.String, java.lang.String) */ @Override - public MetaData getMetadata(String token, String uuid) throws SimExplorerStorageException { + public MetaData getMetadata(String token, String uuid) throws SimExplorerException { MetaData mde; Permission permission = credentialManager.getPermission(token, uuid); if (permission.isCanRead()) { mde = super.getMetadata(token, uuid); } else { - throw new SimExplorerStorageSecurityException(); + throw new SimExplorerSecurityException(); } return mde; } @@ -149,13 +147,13 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#getVersions(java.lang.String, java.lang.String) */ @Override - public List<Version> getVersions(String token, String uuid) throws SimExplorerStorageException { + public List<Version> getVersions(String token, String uuid) throws SimExplorerException { List<Version> versions; Permission permission = credentialManager.getPermission(token, uuid); if (permission.isCanRead()) { versions = super.getVersions(token, uuid); } else { - throw new SimExplorerStorageSecurityException(); + throw new SimExplorerSecurityException(); } return versions; } @@ -165,13 +163,13 @@ */ @Override public InputStream retrieveData(String token, MetaData entity, Attachment attachment) - throws SimExplorerStorageException { + throws SimExplorerException { InputStream stream; Permission permission = credentialManager.getPermission(token, entity.getUuid()); if (permission.isCanRead()) { stream = super.retrieveData(token, entity, attachment); } else { - throw new SimExplorerStorageSecurityException(); + throw new SimExplorerSecurityException(); } return stream; } @@ -180,7 +178,7 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#canCreateSubVersion(java.lang.String, java.lang.String) */ @Override - public boolean canCreateSubVersion(String token, String uuid) throws SimExplorerStorageException { + public boolean canCreateSubVersion(String token, String uuid) throws SimExplorerException { Permission permission = credentialManager.getPermission(token, uuid); if (permission.isCanWrite()) { return true; @@ -193,13 +191,13 @@ */ @Override public void saveElement(String token, MetaData element, Map<Attachment, InputStream> attachments) - throws SimExplorerStorageException { + throws SimExplorerException { Permission permission = credentialManager.getPermission(token, element.getUuid()); if (permission.isCanWrite()) { super.saveElement(token, element, attachments); credentialManager.saveElement(token, element.getUuid()); } else { - throw new SimExplorerStorageSecurityException(); + throw new SimExplorerSecurityException(); } } Modified: trunk/simexplorer-is/simexplorer-is-service/src/resources/i18n/simexplorer-is-service-en_GB.properties =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/resources/i18n/simexplorer-is-service-en_GB.properties 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/resources/i18n/simexplorer-is-service-en_GB.properties 2008-02-15 16:25:18 UTC (rev 1006) @@ -11,4 +11,3 @@ simexplorer.service.mail.requestheader=Account request simexplorer.service.mail.subject=Simexplorer IS web message simexplorer.service.nologonlocal=Local logon is non sense -simexplorer.service.security.norights=Not enough rights to perform that action Modified: trunk/simexplorer-is/simexplorer-is-service/src/resources/i18n/simexplorer-is-service-fr_FR.properties =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/resources/i18n/simexplorer-is-service-fr_FR.properties 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/resources/i18n/simexplorer-is-service-fr_FR.properties 2008-02-15 16:25:18 UTC (rev 1006) @@ -11,4 +11,3 @@ simexplorer.service.mail.requestheader=Demande de compte simexplorer.service.mail.subject=Simexplorer IS message web simexplorer.service.nologonlocal=Login local incoh\u00E9rent -simexplorer.service.security.norights=Pas assez de droit pour r\u00E9aliser cette action Modified: trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityEqualsTestCase.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityEqualsTestCase.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityEqualsTestCase.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -23,6 +23,7 @@ import javax.naming.InitialContext; import junit.framework.TestCase; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.User; /** @@ -54,10 +55,10 @@ /** * Test hash code. * - * @throws SimExplorerServiceException + * @throws SimExplorerException * the sim explorer service exception */ - public void testHashCode() throws SimExplorerServiceException { + public void testHashCode() throws SimExplorerException { String token = authenticationService .loginUser("superadmin", "password"); User[] users1 = authenticationService.getUsers(token); Modified: trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityTestCase.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityTestCase.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityTestCase.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -23,6 +23,7 @@ import javax.naming.InitialContext; import junit.framework.TestCase; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.Group; import fr.cemagref.simexplorer.is.security.entities.User; @@ -55,10 +56,10 @@ /** * Test security entities. * - * @throws SimExplorerServiceException + * @throws SimExplorerException * the sim explorer service exception */ - public void testSecurityEntities() throws SimExplorerServiceException { + public void testSecurityEntities() throws SimExplorerException { /* User user = authenticationService.getUser("user3"); Group[] groups = authenticationService.getGroupsOfUser(user); Modified: trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceLocalVersions.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceLocalVersions.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceLocalVersions.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -40,6 +40,7 @@ import fr.cemagref.simexplorer.is.entities.data.Library; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.factories.BaseEntityFactory; import fr.cemagref.simexplorer.is.factories.MetaDataFactory; import fr.cemagref.simexplorer.is.factories.XmlConstants; @@ -120,7 +121,7 @@ return storageService.saveElement(token, xmlStream, realAttachments); } - private void listExisting(String uuid) throws SimExplorerServiceException { + private void listExisting(String uuid) throws SimExplorerException { if (uuid != null) { Version[] versions = storageService.getVersions(token, uuid); System.out.println("Versions of uuid " + uuid + ":"); Modified: trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -23,6 +23,7 @@ import javax.naming.InitialContext; import junit.framework.TestCase; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.service.StorageService; /** @@ -58,7 +59,7 @@ try { String token = storageService.loginUser("superadmin", "password"); System.out.println(token); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { fail(); } } Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/attachment/ContentType.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/attachment/ContentType.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/attachment/ContentType.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -20,6 +20,8 @@ import java.io.InputStream; import java.io.Reader; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; + /** * Content handler. * @@ -35,10 +37,10 @@ * * @return Indexable text * - * @throws Exception + * @throws SimExplorerException * the exception */ - public abstract Reader renderToText(InputStream is) throws Exception; + public abstract Reader renderToText(InputStream is) throws SimExplorerException; /** * Gets the mime type. Added: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerException.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerException.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerException.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -0,0 +1,69 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.exceptions; + +/** + * Exception de base pour toute erreur rencontrée dans un service. + * + * @author chemit + */ +public class SimExplorerException extends Exception { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 1054522404126322604L; + + /** + * Instantiates a new sim explorer service exception. + */ + public SimExplorerException() { + super(); + } + + /** + * Instantiates a new sim explorer service exception. + * + * @param cause + * the cause + */ + public SimExplorerException(Throwable cause) { + super(cause); + } + + /** + * Instantiates a new sim explorer service exception. + * + * @param message + * the message + */ + public SimExplorerException(String message) { + super(message); + } + + /** + * Instantiates a new sim explorer service exception. + * + * @param message + * the message + * @param cause + * the cause + */ + public SimExplorerException(String message, Throwable cause) { + super(message, cause); + } +} Added: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerSecurityException.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerSecurityException.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerSecurityException.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -0,0 +1,66 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.exceptions; + + +/** + * The Class SimExplorerSecurityException. + */ +public class SimExplorerSecurityException extends SimExplorerBusinessException { + + /** + * + */ + private static final long serialVersionUID = 862842493087651110L; + + /** + * Instantiates a new sim explorer storage security exception. + */ + public SimExplorerSecurityException() { + super(); + } + + /** + * Instantiates a new sim explorer storage security exception. + * + * @param message the message + */ + public SimExplorerSecurityException(String message) { + super(message); + } + + /** + * Instantiates a new sim explorer storage security exception. + * + * @param cause the cause + */ + public SimExplorerSecurityException(Throwable cause) { + super(cause); + } + + /** + * Instantiates a new sim explorer storage security exception. + * + * @param message the message + * @param cause the cause + */ + public SimExplorerSecurityException(String message, Throwable cause) { + super(message, cause); + } + +} Added: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerTechnicalException.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerTechnicalException.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/exceptions/SimExplorerTechnicalException.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -0,0 +1,62 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.exceptions; + +/** + * The Class SimExplorerTechnicalException. + */ +public class SimExplorerTechnicalException extends SimExplorerException { + + private static final long serialVersionUID = 7182289381405452276L; + + /** + * Instantiates a new sim explorer storage technical exception. + */ + public SimExplorerTechnicalException() { + super(); + } + + /** + * Instantiates a new sim explorer storage technical exception. + * + * @param message the message + */ + public SimExplorerTechnicalException(String message) { + super(message); + } + + /** + * Instantiates a new sim explorer storage technical exception. + * + * @param cause the cause + */ + public SimExplorerTechnicalException(Throwable cause) { + super(cause); + } + + /** + * Instantiates a new sim explorer storage technical exception. + * + * @param message the message + * @param cause the cause + */ + public SimExplorerTechnicalException(String message, Throwable cause) { + super(message, cause); + } + +} Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/BaseEntityFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/BaseEntityFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/BaseEntityFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -20,29 +20,14 @@ import java.io.InputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import javax.xml.crypto.dom.DOMStructure; -import javax.xml.crypto.dsig.CanonicalizationMethod; -import javax.xml.crypto.dsig.DigestMethod; -import javax.xml.crypto.dsig.Reference; -import javax.xml.crypto.dsig.SignatureMethod; -import javax.xml.crypto.dsig.SignedInfo; -import javax.xml.crypto.dsig.XMLSignature; -import javax.xml.crypto.dsig.XMLSignatureFactory; -import javax.xml.crypto.dsig.dom.DOMSignContext; -import javax.xml.crypto.dsig.keyinfo.KeyInfo; -import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory; -import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.dom.DOMSource; import org.w3c.dom.Document; @@ -53,6 +38,8 @@ import fr.cemagref.simexplorer.is.entities.BaseEntity; import fr.cemagref.simexplorer.is.entities.data.DataEntity; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; /** * A factory for creating BaseEntity objects. @@ -80,19 +67,24 @@ * * @return Factory * - * @throws Exception the exception + * @throws SimExplorerException the exception */ @SuppressWarnings("unchecked") - public static <E extends DataEntity> BaseEntityFactory<E> getFactory(Class entityClass) throws Exception { + public static <E extends DataEntity> BaseEntityFactory<E> getFactory(Class entityClass) throws SimExplorerException { BaseEntityFactory<E> result = (BaseEntityFactory<E>) factories.get(entityClass.getSimpleName()); if (result == null) { String elementFactoryClassName = BaseEntityFactory.class.getPackage().getName() + "." + entityClass.getSimpleName() + FACTORY_SUFFIX; - Class<? extends BaseEntityFactory<E>> factoryClass = (Class<? extends BaseEntityFactory<E>>) Class.forName( - elementFactoryClassName).asSubclass(BaseEntityFactory.class); + Class<? extends BaseEntityFactory<E>> factoryClass; + try { + factoryClass = (Class<? extends BaseEntityFactory<E>>) Class.forName(elementFactoryClassName) + .asSubclass(BaseEntityFactory.class); + result = factoryClass.newInstance(); + } catch (Exception e) { + throw new SimExplorerTechnicalException(e); + } - result = factoryClass.newInstance(); factories.put(entityClass.getSimpleName(), result); } return result; @@ -105,10 +97,16 @@ * * @return the factory * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public static BaseEntityFactory<? extends DataEntity> getFactory(String entityClassName) throws Exception { - Class<? extends DataEntity> entityClass = Class.forName(entityClassName).asSubclass(DataEntity.class); + public static BaseEntityFactory<? extends DataEntity> getFactory(String entityClassName) + throws SimExplorerException { + Class<? extends DataEntity> entityClass; + try { + entityClass = Class.forName(entityClassName).asSubclass(DataEntity.class); + } catch (ClassNotFoundException e) { + throw new SimExplorerTechnicalException(e); + } return getFactory(entityClass); } @@ -116,10 +114,10 @@ * Retrieve an instance of document builder. * * @return XML document builder + * @throws ParserConfigurationException * - * @throws Exception the exception */ - public static synchronized DocumentBuilder getXMLBuilder() throws Exception { + public static synchronized DocumentBuilder getXMLBuilder() throws ParserConfigurationException { if (documentBuilder == null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); documentBuilder = factory.newDocumentBuilder(); @@ -146,9 +144,9 @@ * * @return the E * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public E loadElement(Element xmlElement) throws Exception { + public E loadElement(Element xmlElement) throws SimExplorerException { E element = createInstance(); return element; } @@ -160,11 +158,16 @@ * * @return the E * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public E loadElement(InputStream stream) throws Exception { - Document document = getXMLBuilder().parse(stream); - Element rootElement = (Element) document.getFirstChild(); + public E loadElement(InputStream stream) throws SimExplorerException { + Element rootElement; + try { + Document document = getXMLBuilder().parse(stream); + rootElement = (Element) document.getFirstChild(); + } catch (Exception e) { + throw new SimExplorerTechnicalException(e); + } E element = loadElement(rootElement); return element; } @@ -176,9 +179,9 @@ * @param xmlElement XML node storing the element (not null) * @param element Element to save * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public abstract void saveElement(Document document, Element xmlElement, E element) throws Exception; + public abstract void saveElement(Document document, Element xmlElement, E element) throws SimExplorerException; /** * Save an element to a XML stream. @@ -188,28 +191,36 @@ * * @return the input stream * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public InputStream saveElement(String rootNodeName, E element) throws Exception { - org.w3c.dom.Document xmlDocument = getXMLBuilder().newDocument(); - // DOM properties - xmlDocument.setXmlVersion("1.0"); - xmlDocument.setXmlStandalone(true); - // DOM tree - Element rootNode = xmlDocument.createElement(rootNodeName); - + public InputStream saveElement(String rootNodeName, E element) throws SimExplorerException { + Document xmlDocument; + Element rootNode; + try { + xmlDocument = getXMLBuilder().newDocument(); + // DOM properties + xmlDocument.setXmlVersion("1.0"); + xmlDocument.setXmlStandalone(true); + // DOM tree + rootNode = xmlDocument.createElement(rootNodeName); + } catch (Exception e) { + throw new SimExplorerTechnicalException(e); + } saveElement(xmlDocument, rootNode, element); + try { + xmlDocument.appendChild(rootNode); + DOMSource domSource = new DOMSource(xmlDocument); - xmlDocument.appendChild(rootNode); - DOMSource domSource = new DOMSource(xmlDocument); + PipedOutputStream os = new PipedOutputStream(); + PipedInputStream is = new PipedInputStream(os); - PipedOutputStream os = new PipedOutputStream(); - PipedInputStream is = new PipedInputStream(os); + XMLStreamEncoder xse = new XMLStreamEncoder(domSource, os); + xse.start(); - XMLStreamEncoder xse = new XMLStreamEncoder(domSource, os); - xse.start(); - - return is; + return is; + } catch (Exception e) { + throw new SimExplorerTechnicalException(e); + } } /* @@ -229,10 +240,10 @@ * * @return the set< t> * - * @throws Exception the exception + * @throws SimExplorerException the exception */ public <T extends DataEntity> Set<T> loadCollection(String tagSetName, String tagName, Class<T> clazz, - Element xmlElement, DataEntity parentData) throws Exception { + Element xmlElement, DataEntity parentData) throws SimExplorerException { Set<T> entities = new HashSet<T>(); // Retrieve XML node containing the collection @@ -266,10 +277,10 @@ * @param document the document * @param xmlElement the xml element * - * @throws Exception the exception + * @throws SimExplorerException the exception */ public <T extends DataEntity> void saveCollection(Set<T> entities, String tagSetName, String tagName, - Class<T> clazz, Document document, Element xmlElement) throws Exception { + Class<T> clazz, Document document, Element xmlElement) throws SimExplorerException { if (entities != null && entities.size() > 0) { Element xmlCollection = document.createElement(tagSetName); BaseEntityFactory<T> elementFactory = getFactory(clazz); @@ -289,24 +300,28 @@ * * @return the input stream * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public static InputStream serializeElement(Node node) throws Exception { - Document xmlDocument = getXMLBuilder().newDocument(); - // DOM properties - xmlDocument.setXmlVersion("1.0"); - xmlDocument.setXmlStandalone(true); - // DOM tree - xmlDocument.appendChild(xmlDocument.importNode(node, true)); - DOMSource domSource = new DOMSource(xmlDocument); + public static InputStream serializeElement(Node node) throws SimExplorerException { + try { + Document xmlDocument = getXMLBuilder().newDocument(); + // DOM properties + xmlDocument.setXmlVersion("1.0"); + xmlDocument.setXmlStandalone(true); + // DOM tree + xmlDocument.appendChild(xmlDocument.importNode(node, true)); + DOMSource domSource = new DOMSource(xmlDocument); - PipedOutputStream os = new PipedOutputStream(); - PipedInputStream is = new PipedInputStream(os); + PipedOutputStream os = new PipedOutputStream(); + PipedInputStream is = new PipedInputStream(os); - XMLStreamEncoder xse = new XMLStreamEncoder(domSource, os); - xse.start(); + XMLStreamEncoder xse = new XMLStreamEncoder(domSource, os); + xse.start(); - return is; + return is; + } catch (Exception e) { + throw new SimExplorerTechnicalException(e); + } } /* Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/CodeFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/CodeFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/CodeFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -21,6 +21,7 @@ import org.w3c.dom.Element; import fr.cemagref.simexplorer.is.entities.data.Code; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * A factory for creating Code objects. @@ -40,7 +41,7 @@ * @see fr.cemagref.simexplorer.is.factories.BaseEntityFactory#loadElement(org.w3c.dom.Element) */ @Override - public Code loadElement(Element xmlElement) throws Exception { + public Code loadElement(Element xmlElement) throws SimExplorerException { Code code = super.loadElement(xmlElement); code.setLanguage(getXMLProperty(xmlElement, KEY_CODE_LANGUAGE)); code.setCode(getXMLProperty(xmlElement, KEY_CODE_CODE)); @@ -52,7 +53,7 @@ */ @Override public void saveElement(Document document, Element xmlElement, Code element) - throws Exception { + throws SimExplorerException { setXMLProperty(document, xmlElement, KEY_CODE_LANGUAGE, element .getLanguage()); setXMLProperty(document, xmlElement, KEY_CODE_CODE, element.getCode()); Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ComponentFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ComponentFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ComponentFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -25,6 +25,7 @@ import fr.cemagref.simexplorer.is.entities.data.Constant; import fr.cemagref.simexplorer.is.entities.data.Library; import fr.cemagref.simexplorer.is.entities.data.Structure; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * A factory for creating Component objects. @@ -45,7 +46,7 @@ * @see fr.cemagref.simexplorer.is.factories.LoggableElementFactory#loadElement(org.w3c.dom.Element) */ @Override - public Component loadElement(Element xmlElement) throws Exception { + public Component loadElement(Element xmlElement) throws SimExplorerException { Component component = super.loadElement(xmlElement); component.setConstants(loadCollection(KEY_COMPONENT_CONSTANTS, @@ -68,7 +69,7 @@ */ @Override public void saveElement(Document document, Element xmlElement, - Component element) throws Exception { + Component element) throws SimExplorerException { super.saveElement(document, xmlElement, element); Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ConstantFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ConstantFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ConstantFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -21,6 +21,8 @@ import org.w3c.dom.Element; import fr.cemagref.simexplorer.is.entities.data.Constant; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; /** * A factory for creating Constant objects. @@ -41,11 +43,15 @@ * @see fr.cemagref.simexplorer.is.factories.BaseEntityFactory#loadElement(org.w3c.dom.Element) */ @Override - public Constant loadElement(Element xmlElement) throws Exception { + public Constant loadElement(Element xmlElement) throws SimExplorerException { Constant constant = super.loadElement(xmlElement); constant.setName(getXMLProperty(xmlElement, KEY_CONSTANT_NAME)); String className = getXMLProperty(xmlElement, KEY_CONSTANT_TYPE); - constant.setType(Class.forName(className)); + try { + constant.setType(Class.forName(className)); + } catch (ClassNotFoundException e) { + throw new SimExplorerTechnicalException(e); + } return constant; } @@ -54,7 +60,7 @@ */ @Override public void saveElement(Document document, Element xmlElement, - Constant element) throws Exception { + Constant element) throws SimExplorerException { setXMLProperty(document, xmlElement, KEY_CONSTANT_NAME, element .getName()); String className = element.getType().getName(); Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ConstantValueFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ConstantValueFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ConstantValueFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -22,6 +22,7 @@ import fr.cemagref.simexplorer.is.entities.data.Constant; import fr.cemagref.simexplorer.is.entities.data.ConstantValue; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * A factory for creating ConstantValue objects. @@ -42,7 +43,7 @@ * @see fr.cemagref.simexplorer.is.factories.BaseEntityFactory#loadElement(org.w3c.dom.Element) */ @Override - public ConstantValue loadElement(Element xmlElement) throws Exception { + public ConstantValue loadElement(Element xmlElement) throws SimExplorerException { ConstantValue constantValue = super.loadElement(xmlElement); constantValue.setConstant((Constant) getFactory(Constant.class) .loadElement( @@ -58,7 +59,7 @@ */ @Override public void saveElement(Document document, Element xmlElement, - ConstantValue element) throws Exception { + ConstantValue element) throws SimExplorerException { Element xmlConstant = document .createElement(KEY_CONSTANTVALUE_CONSTANT); Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ExplorationApplicationFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ExplorationApplicationFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ExplorationApplicationFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -23,6 +23,7 @@ import fr.cemagref.simexplorer.is.entities.data.Component; import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication; import fr.cemagref.simexplorer.is.entities.data.ExplorationData; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * A factory for creating ExplorationApplication objects. @@ -43,7 +44,7 @@ */ @Override public void saveElement(Document document, Element xmlElement, - ExplorationApplication element) throws Exception { + ExplorationApplication element) throws SimExplorerException { super.saveElement(document, xmlElement, element); saveCollection(element.getExplorations(), KEY_EXPLORATIONAPPLICATION_DATA, @@ -60,7 +61,7 @@ */ @Override public ExplorationApplication loadElement(Element xmlElement) - throws Exception { + throws SimExplorerException { ExplorationApplication explorationApplication = super .loadElement(xmlElement); explorationApplication.setExplorations(loadCollection( Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ExplorationDataFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ExplorationDataFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ExplorationDataFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -23,6 +23,7 @@ import fr.cemagref.simexplorer.is.entities.data.ConstantValue; import fr.cemagref.simexplorer.is.entities.data.ExplorationData; import fr.cemagref.simexplorer.is.entities.data.Result; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * A factory for creating ExplorationData objects. @@ -42,7 +43,7 @@ * @see fr.cemagref.simexplorer.is.factories.LoggableElementFactory#loadElement(org.w3c.dom.Element) */ @Override - public ExplorationData loadElement(Element xmlElement) throws Exception { + public ExplorationData loadElement(Element xmlElement) throws SimExplorerException { ExplorationData explorationData = super.loadElement(xmlElement); explorationData.setResult((Result) getFactory(Result.class) .loadElement( @@ -59,7 +60,7 @@ */ @Override public void saveElement(Document document, Element xmlElement, - ExplorationData element) throws Exception { + ExplorationData element) throws SimExplorerException { super.saveElement(document, xmlElement, element); Element xmlResult = document.createElement(KEY_EXPLORATIONDATA_RESULT); Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/LoggableElementFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/LoggableElementFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/LoggableElementFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -21,6 +21,7 @@ import fr.cemagref.simexplorer.is.entities.data.LoggableElement; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * A factory for creating LoggableElement objects. @@ -35,7 +36,7 @@ * @see fr.cemagref.simexplorer.is.factories.BaseEntityFactory#loadElement(org.w3c.dom.Element) */ @Override - public E loadElement(Element xmlElement) throws Exception { + public E loadElement(Element xmlElement) throws SimExplorerException { E element = super.loadElement(xmlElement); MetaDataFactory<MetaData> elementFactory = MetaDataFactory @@ -54,7 +55,7 @@ */ @Override public void saveElement(org.w3c.dom.Document document, Element xmlElement, - E element) throws Exception { + E element) throws SimExplorerException { MetaDataFactory<MetaData> elementFactory = MetaDataFactory .getFactory(MetaData.class); Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/MetaDataFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/MetaDataFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/MetaDataFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -20,6 +20,7 @@ import java.io.InputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -41,6 +42,8 @@ import fr.cemagref.simexplorer.is.attachment.ContentType; import fr.cemagref.simexplorer.is.attachment.ContentTypeFactory; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; /** * A factory for creating MetaData objects. @@ -69,10 +72,10 @@ * * @return the factory * - * @throws Exception the exception + * @throws SimExplorerException the exception */ @SuppressWarnings( { "unchecked" }) - public static <E extends MetaData> MetaDataFactory<E> getFactory(Class<E> entityClass) throws Exception { + public static <E extends MetaData> MetaDataFactory<E> getFactory(Class<E> entityClass) throws SimExplorerException { return (MetaDataFactory) BaseEntityFactory.getFactory(entityClass); } @@ -83,7 +86,7 @@ */ @Override - public MetaData loadElement(Element xmlElement) throws Exception { + public MetaData loadElement(Element xmlElement) throws SimExplorerException { MetaData entity = super.loadElement(xmlElement); entity.setUuid(getXMLProperty(xmlElement, KEY_METADATA_UUID)); entity.setName(getXMLProperty(xmlElement, KEY_METADATA_NAME)); @@ -100,7 +103,12 @@ String creationDate = getXMLProperty(xmlElement, KEY_METADATA_CREATIONDATE); if (creationDate != null) { - Date date = sdf.parse(creationDate); + Date date; + try { + date = sdf.parse(creationDate); + } catch (ParseException e) { + throw new SimExplorerTechnicalException(e); + } entity.setCreationDate(date); } @@ -152,7 +160,7 @@ * @see fr.cemagref.simexplorer.is.factories.BaseEntityFactory#saveElement(org.w3c.dom.Document, org.w3c.dom.Element, fr.cemagref.simexplorer.is.entities.BaseEntity) */ @Override - public void saveElement(Document document, Element xmlElement, MetaData element) throws Exception { + public void saveElement(Document document, Element xmlElement, MetaData element) throws SimExplorerException { setXMLProperty(document, xmlElement, KEY_METADATA_UUID, element.getUuid()); setXMLProperty(document, xmlElement, KEY_METADATA_NAME, element.getName()); @@ -217,12 +225,16 @@ * * @return the meta data * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public MetaData loadElementFromParentXML(Element node) throws Exception { + public MetaData loadElementFromParentXML(Element node) throws SimExplorerException { Element mdeElement = getXMLElementByTagName(node, KEY_METADATA); MetaData mde; - mde = loadElement(mdeElement); + try { + mde = loadElement(mdeElement); + } catch (SimExplorerException e) { + throw new SimExplorerTechnicalException(e); + } return mde; } @@ -234,27 +246,37 @@ * * @return the input stream * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public InputStream modifyMedataElementStream(InputStream xmlStream, MetaData newMetadata) throws Exception { - Document document = getXMLBuilder().parse(xmlStream); - Element rootElement = (Element) document.getFirstChild(); - - Element newElement = document.createElement(KEY_METADATA); + public InputStream modifyMedataElementStream(InputStream xmlStream, MetaData newMetadata) + throws SimExplorerException { + Document document; + Element rootElement; + Element newElement; + try { + document = getXMLBuilder().parse(xmlStream); + rootElement = (Element) document.getFirstChild(); + newElement = document.createElement(KEY_METADATA); + } catch (Exception e) { + throw new SimExplorerTechnicalException(e); + } this.saveElement(document, newElement, newMetadata); - Element oldElement = getXMLElementByTagName(rootElement, KEY_METADATA); rootElement.replaceChild(newElement, oldElement); DOMSource domSource = new DOMSource(document); - PipedOutputStream os = new PipedOutputStream(); - PipedInputStream is = new PipedInputStream(os); + try { + PipedOutputStream os = new PipedOutputStream(); + PipedInputStream is = new PipedInputStream(os); - XMLStreamEncoder xse = new XMLStreamEncoder(domSource, os); - xse.start(); + XMLStreamEncoder xse = new XMLStreamEncoder(domSource, os); + xse.start(); - return is; + return is; + } catch (Exception e) { + throw new SimExplorerTechnicalException(e); + } } /** @@ -264,9 +286,10 @@ * @param document the document * @param xmlNode the xml node * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public void replaceMetadataInXML(Document document, Element xmlNode, MetaData newMetadata) throws Exception { + public void replaceMetadataInXML(Document document, Element xmlNode, MetaData newMetadata) + throws SimExplorerException { Element newElement = document.createElement(KEY_METADATA); this.saveElement(document, newElement, newMetadata); @@ -281,18 +304,22 @@ * * @return the string * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - public String computeHash(Element node) throws Exception { - Document document = getXMLBuilder().newDocument(); - document.appendChild(document.importNode(node, true)); + public String computeHash(Element node) throws SimExplorerException { + try { + Document document = getXMLBuilder().newDocument(); + document.appendChild(document.importNode(node, true)); - int removeNodes = removeMetadatas(document); + int removeNodes = removeMetadatas(document); - DigestGenerator digestGenerator = new DigestGenerator(); - byte[] digest = digestGenerator.getDigest(document, DigestGenerator.sha1DigestAlgorithm); + DigestGenerator digestGenerator = new DigestGenerator(); + byte[] digest = digestGenerator.getDigest(document, DigestGenerator.sha1DigestAlgorithm); - return MD5.asHex(digest); + return MD5.asHex(digest); + } catch (Exception e) { + throw new SimExplorerTechnicalException(e); + } } /** Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/RepositoryFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/RepositoryFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/RepositoryFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -21,6 +21,7 @@ import org.w3c.dom.Element; import fr.cemagref.simexplorer.is.entities.data.Repository; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * A factory for creating Repository objects. @@ -41,7 +42,7 @@ * @see fr.cemagref.simexplorer.is.factories.BaseEntityFactory#loadElement(org.w3c.dom.Element) */ @Override - public Repository loadElement(Element xmlElement) throws Exception { + public Repository loadElement(Element xmlElement) throws SimExplorerException { return super.loadElement(xmlElement); } @@ -50,7 +51,7 @@ */ @Override public void saveElement(Document document, Element xmlElement, - Repository element) throws Exception { + Repository element) throws SimExplorerException { // nothing to do yet } Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ResultFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ResultFactory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/factories/ResultFactory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -21,6 +21,7 @@ import org.w3c.dom.Element; import fr.cemagref.simexplorer.is.entities.data.Result; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * A factory for creating Result objects. @@ -40,7 +41,7 @@ * @see fr.cemagref.simexplorer.is.factories.BaseEntityFactory#loadElement(org.w3c.dom.Element) */ @Override - public Result loadElement(Element xmlElement) throws Exception { + public Result loadElement(Element xmlElement) throws SimExplorerException { return super.loadElement(xmlElement); } @@ -49,7 +50,7 @@ */ @Override public void saveElement(Document document, Element xmlElement, - Result element) throws Exception { + Result element) throws SimExplorerException { // not used yet Deleted: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -1,63 +0,0 @@ -/* -* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.storage; - -/** - * The Class SimExplorerStorageException. - */ -public abstract class SimExplorerStorageException extends Exception { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 4405447107690074844L; - - /** - * Instantiates a new sim explorer storage exception. - */ - public SimExplorerStorageException() { - super(); - } - - /** - * Instantiates a new sim explorer storage exception. - * - * @param message the message - */ - public SimExplorerStorageException(String message) { - super(message); - } - - /** - * Instantiates a new sim explorer storage exception. - * - * @param cause the cause - */ - public SimExplorerStorageException(Throwable cause) { - super(cause); - } - - /** - * Instantiates a new sim explorer storage exception. - * - * @param message the message - * @param cause the cause - */ - public SimExplorerStorageException(String message, Throwable cause) { - super(message, cause); - } - -} Deleted: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageTechnicalException.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageTechnicalException.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageTechnicalException.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -1,62 +0,0 @@ -/* -* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.storage; - -/** - * The Class SimExplorerStorageTechnicalException. - */ -public class SimExplorerStorageTechnicalException extends SimExplorerStorageException { - - private static final long serialVersionUID = 7182289381405452276L; - - /** - * Instantiates a new sim explorer storage technical exception. - */ - public SimExplorerStorageTechnicalException() { - super(); - } - - /** - * Instantiates a new sim explorer storage technical exception. - * - * @param message the message - */ - public SimExplorerStorageTechnicalException(String message) { - super(message); - } - - /** - * Instantiates a new sim explorer storage technical exception. - * - * @param cause the cause - */ - public SimExplorerStorageTechnicalException(Throwable cause) { - super(cause); - } - - /** - * Instantiates a new sim explorer storage technical exception. - * - * @param message the message - * @param cause the cause - */ - public SimExplorerStorageTechnicalException(String message, Throwable cause) { - super(message, cause); - } - -} Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -21,7 +21,7 @@ import fr.cemagref.simexplorer.is.attachment.Attachment; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * Store, retrieve and delete content. @@ -40,11 +40,11 @@ * @param attachment * the attachment * - * @throws SimExplorerStorageException + * @throws SimExplorerException * the sim explorer storage exception */ public abstract void storeData(MetaData entity, Attachment attachment, InputStream is) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Retrieve content. @@ -56,11 +56,11 @@ * * @return Content * - * @throws SimExplorerStorageException + * @throws SimExplorerException * the sim explorer storage exception */ public abstract InputStream retrieveData(MetaData entity, Attachment attachment) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Retrieve MD5. @@ -72,11 +72,11 @@ * * @return the string * - * @throws SimExplorerStorageException + * @throws SimExplorerException * the sim explorer storage exception */ public abstract String retrieveMD5Data(MetaData entity, Attachment attachment) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Delete content. @@ -86,10 +86,10 @@ * @param attachment * the attachment * - * @throws SimExplorerStorageException + * @throws SimExplorerException * the sim explorer storage exception */ public abstract void deleteData(MetaData entity, Attachment attachment) - throws SimExplorerStorageException; + throws SimExplorerException; } \ No newline at end of file Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -31,8 +31,8 @@ import fr.cemagref.simexplorer.is.attachment.Attachment; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageTechnicalException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; import fr.cemagref.simexplorer.is.storage.util.Config; /** @@ -102,13 +102,13 @@ * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#retrieveData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String) */ @Override - public InputStream retrieveData(MetaData entity, Attachment attachment) throws SimExplorerStorageException { + public InputStream retrieveData(MetaData entity, Attachment attachment) throws SimExplorerException { // Simple stream on file FileInputStream fis; try { fis = new FileInputStream(getFile(entity, attachment, false)); } catch (FileNotFoundException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } return fis; } @@ -117,12 +117,12 @@ * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#retrieveMD5Data(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String) */ @Override - public String retrieveMD5Data(MetaData entity, Attachment attachment) throws SimExplorerStorageException { + public String retrieveMD5Data(MetaData entity, Attachment attachment) throws SimExplorerException { String md5; try { md5 = MD5.asHex(MD5.getHash(getFile(entity, attachment, false))); } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } return md5; } @@ -131,7 +131,7 @@ * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#storeData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String, java.io.InputStream) */ @Override - public void storeData(MetaData entity, Attachment attachment, InputStream is) throws SimExplorerStorageException { + public void storeData(MetaData entity, Attachment attachment, InputStream is) throws SimExplorerException { BufferedOutputStream bout = null; // Simple stream on file @@ -154,21 +154,21 @@ bout.flush(); } catch (FileNotFoundException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } catch (IOException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } finally { closeStream(bout); } } - protected void closeStream(OutputStream fos) throws SimExplorerStorageException { + protected void closeStream(OutputStream fos) throws SimExplorerException { if (fos != null) { // Close file try { fos.close(); } catch (IOException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } } } @@ -177,12 +177,12 @@ * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#deleteData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String) */ @Override - public void deleteData(MetaData entity, Attachment attachment) throws SimExplorerStorageException { + public void deleteData(MetaData entity, Attachment attachment) throws SimExplorerException { try { // Simple delete on file getFile(entity, attachment, false).delete(); } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } } Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -25,7 +25,7 @@ import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * Interface of a database able to manage metadata elements. @@ -37,9 +37,9 @@ /** * Open database connection. * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public void open() throws SimExplorerStorageException { + public void open() throws SimExplorerException { open(false); } @@ -48,23 +48,23 @@ * * @param create Create database * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void open(boolean create) throws SimExplorerStorageException; + public abstract void open(boolean create) throws SimExplorerException; /** * Close database connection. * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void close() throws SimExplorerStorageException; + public abstract void close() throws SimExplorerException; /** * Commit pending modifications. * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void commit() throws SimExplorerStorageException; + public abstract void commit() throws SimExplorerException; // Create / Update @@ -74,9 +74,9 @@ * @param element Element to insert * @param readers the readers * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void insertElement(MetaData element, List<Reader> readers) throws SimExplorerStorageException; + public abstract void insertElement(MetaData element, List<Reader> readers) throws SimExplorerException; /** * Save element hierarchy, saving the fact that parent uses child. @@ -84,18 +84,18 @@ * @param parent the parent * @param child the child * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void saveElementHierarchy(MetaData parent, MetaData child) throws SimExplorerStorageException; + public abstract void saveElementHierarchy(MetaData parent, MetaData child) throws SimExplorerException; /** * Duplicate element hierarchy. * * @param fromElement the from element * @param toElement the to element - * @throws SimExplorerStorageException + * @throws SimExplorerException */ - public abstract void duplicateElementHierarchy(MetaData fromElement, MetaData toElement) throws SimExplorerStorageException; + public abstract void duplicateElementHierarchy(MetaData fromElement, MetaData toElement) throws SimExplorerException; // Read @@ -107,9 +107,9 @@ * * @return Fund element, null if not fund * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract MetaData getElement(String uuid, Version version) throws SimExplorerStorageException; + public abstract MetaData getElement(String uuid, Version version) throws SimExplorerException; /** * Get all version of an element thanks to its id <br> @@ -119,9 +119,9 @@ * * @return Versions * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract List<Version> getVersions(String uuid) throws SimExplorerStorageException; + public abstract List<Version> getVersions(String uuid) throws SimExplorerException; /** * Gets the elements used by mde. @@ -129,9 +129,9 @@ * @param mde the mde * * @return the elements used by - * @throws SimExplorerStorageException + * @throws SimExplorerException */ - public abstract Set<MetaData> getElementsUsedBy(MetaData mde) throws SimExplorerStorageException; + public abstract Set<MetaData> getElementsUsedBy(MetaData mde) throws SimExplorerException; /** * Gets the elements using mde. @@ -139,9 +139,9 @@ * @param mde the mde * * @return the elements using - * @throws SimExplorerStorageException + * @throws SimExplorerException */ - public abstract Set<MetaData> getElementsUsing(MetaData mde) throws SimExplorerStorageException; + public abstract Set<MetaData> getElementsUsing(MetaData mde) throws SimExplorerException; /** * Retrieve all elements by id Empty list if no element with this id. @@ -151,9 +151,9 @@ * * @return Element list * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract Set<MetaData> findElementsById(String uuid, boolean onlyLatest) throws SimExplorerStorageException; + public abstract Set<MetaData> findElementsById(String uuid, boolean onlyLatest) throws SimExplorerException; /** * Retrieve elements with specific properties<br> @@ -163,9 +163,9 @@ * * @return Element list * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public Set<MetaData> findElementsByProperties(Map<String, String> properties) throws SimExplorerStorageException { + public Set<MetaData> findElementsByProperties(Map<String, String> properties) throws SimExplorerException { return findElementsByProperties(properties, 0, -1, 0); } @@ -180,10 +180,10 @@ * * @return Element list * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract Set<MetaData> findElementsByProperties(Map<String, String> properties, int start, int count, - int dateOrder) throws SimExplorerStorageException; + int dateOrder) throws SimExplorerException; /** * Retrieve element count specific properties. @@ -192,10 +192,10 @@ * * @return Number of elements fund * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract int findElementsByPropertiesCount(Map<String, String> properties) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Prepare properties for query. @@ -225,10 +225,10 @@ * * @return Element list * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public Set<MetaData> findElementsByType(String type, boolean onlyLatest, int start, int count, int dateOrder) - throws SimExplorerStorageException { + throws SimExplorerException { return findElementsByProperties(getPropertiesByType(type, onlyLatest), start, count, dateOrder); } @@ -240,9 +240,9 @@ * * @return Number of elements * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public int findElementsByTypeCount(String type, boolean onlyLatest) throws SimExplorerStorageException { + public int findElementsByTypeCount(String type, boolean onlyLatest) throws SimExplorerException { return findElementsByPropertiesCount(getPropertiesByType(type, onlyLatest)); } @@ -258,10 +258,10 @@ * * @return Element list * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract Set<MetaData> findElementsByContentSearch(String queryText, boolean onlyLatest, int start, - int count, int dateOrder) throws SimExplorerStorageException; + int count, int dateOrder) throws SimExplorerException; /** * Retrieve element count with specific content. @@ -271,10 +271,10 @@ * * @return Number of elements fund * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract int findElementsByContentSearchCount(String queryText, boolean onlyLatest) - throws SimExplorerStorageException; + throws SimExplorerException; // Delete @@ -283,9 +283,9 @@ * * @param element Element to delete * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer exception */ - public void deleteElement(MetaData element) throws SimExplorerStorageException { + public void deleteElement(MetaData element) throws SimExplorerException { deleteElement(element.getUuid(), element.getVersion()); } @@ -295,9 +295,9 @@ * @param uuid Id * @param version Version * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void deleteElement(String uuid, Version version) throws SimExplorerStorageException; + public abstract void deleteElement(String uuid, Version version) throws SimExplorerException; } Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -59,8 +59,8 @@ import fr.cemagref.simexplorer.is.attachment.ContentTypeFactory; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageTechnicalException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; import fr.cemagref.simexplorer.is.storage.database.Database; import fr.cemagref.simexplorer.is.storage.util.Config; import fr.cemagref.simexplorer.is.storage.util.KeyValue; @@ -171,7 +171,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#open(boolean) */ @Override - public void open(boolean create) throws SimExplorerStorageException { + public void open(boolean create) throws SimExplorerException { if (writer == null) { // Create an analyzer Analyzer analyzer = new SimpleAnalyzer(); @@ -200,7 +200,7 @@ commit(); } } catch (IOException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } } } @@ -209,7 +209,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#close() */ @Override - public void close() throws SimExplorerStorageException { + public void close() throws SimExplorerException { try { synchronized (writerSynchronizer) { // Close writer and invalidate reader @@ -218,7 +218,7 @@ } resetReader(); } catch (IOException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } searcherPool = null; } @@ -249,12 +249,12 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#commit() */ @Override - public void commit() throws SimExplorerStorageException { + public void commit() throws SimExplorerException { try { // Allows concurent access synchedCommit(); } catch (IOException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } } @@ -262,7 +262,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#insertElement(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.util.List) */ @Override - public void insertElement(MetaData element, List<Reader> readers) throws SimExplorerStorageException { + public void insertElement(MetaData element, List<Reader> readers) throws SimExplorerException { // Save element to a Lucene document Document document = saveLuceneElement(element, readers); @@ -272,7 +272,7 @@ writer.addDocument(document); } } catch (IOException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } } @@ -280,7 +280,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#saveElementHierarchy(fr.cemagref.simexplorer.is.entities.metadata.MetaData, fr.cemagref.simexplorer.is.entities.metadata.MetaData) */ @Override - public void saveElementHierarchy(MetaData parent, MetaData child) throws SimExplorerStorageException { + public void saveElementHierarchy(MetaData parent, MetaData child) throws SimExplorerException { // Save element to a Lucene document Document document = saveLuceneElementHierarchy(parent, child); @@ -290,7 +290,7 @@ writer.addDocument(document); } } catch (IOException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } } @@ -298,7 +298,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#getElement(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) */ @Override - public MetaData getElement(String uuid, Version version) throws SimExplorerStorageException { + public MetaData getElement(String uuid, Version version) throws SimExplorerException { MetaData result = null; try { @@ -314,8 +314,10 @@ // Release searcher instance releaseSearcher(searcher); } + } catch (SimExplorerException e) { + throw e; } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } return result; @@ -347,7 +349,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#getVersions(java.lang.String) */ @Override - public List<Version> getVersions(String uuid) throws SimExplorerStorageException { + public List<Version> getVersions(String uuid) throws SimExplorerException { // Retrieve all document corresponding to id Map<String, String> properties = new HashMap<String, String>(); properties.put(KEY_UUID, uuid); @@ -373,7 +375,7 @@ releaseSearcher(searcher); } } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } return versions; @@ -383,7 +385,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsById(java.lang.String, boolean) */ @Override - public Set<MetaData> findElementsById(String uuid, boolean onlyLatest) throws SimExplorerStorageException { + public Set<MetaData> findElementsById(String uuid, boolean onlyLatest) throws SimExplorerException { // Create hash map with id Map<String, String> properties = new HashMap<String, String>(); properties.put(KEY_UUID, uuid); @@ -403,8 +405,10 @@ // Release searcher instance releaseSearcher(searcher); } + } catch (SimExplorerException e) { + throw e; } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } // Return all elements parsed from documents fund @@ -415,7 +419,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByPropertiesCount(java.util.Map) */ @Override - public int findElementsByPropertiesCount(Map<String, String> properties) throws SimExplorerStorageException { + public int findElementsByPropertiesCount(Map<String, String> properties) throws SimExplorerException { int result = 0; try { @@ -429,7 +433,7 @@ releaseSearcher(searcher); } } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } // Return all elements parsed from documents fund @@ -441,7 +445,7 @@ */ @Override public Set<MetaData> findElementsByProperties(Map<String, String> properties, int start, int count, int dateOrder) - throws SimExplorerStorageException { + throws SimExplorerException { Set<MetaData> result = null; try { @@ -454,8 +458,10 @@ // Release searcher instance releaseSearcher(searcher); } + } catch (SimExplorerException e) { + throw e; } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } // Return all elements parsed from documents fund @@ -466,13 +472,12 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByContentSearchCount(java.lang.String, boolean) */ @Override - public int findElementsByContentSearchCount(String queryText, boolean onlyLatest) - throws SimExplorerStorageException { + public int findElementsByContentSearchCount(String queryText, boolean onlyLatest) throws SimExplorerException { Query query; try { query = getQueryByContentSearch(queryText, onlyLatest); } catch (ParseException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } int result = 0; @@ -490,7 +495,7 @@ releaseSearcher(searcher); } } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } return result; @@ -519,12 +524,12 @@ */ @Override public Set<MetaData> findElementsByContentSearch(String queryText, boolean onlyLatest, int start, int count, - int dateOrder) throws SimExplorerStorageException { + int dateOrder) throws SimExplorerException { Query query; try { query = getQueryByContentSearch(queryText, onlyLatest); } catch (ParseException e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } Set<MetaData> result = null; @@ -541,8 +546,10 @@ // Release searcher instance releaseSearcher(searcher); } + } catch (SimExplorerException e) { + throw e; } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } return result; @@ -585,7 +592,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#deleteElement(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) */ @Override - public void deleteElement(String uuid, Version version) throws SimExplorerStorageException { + public void deleteElement(String uuid, Version version) throws SimExplorerException { // Delete element in db with term search Term term = new Term(KEY_UUID_VERSION, getUuidVersion(uuid, version)); @@ -595,7 +602,7 @@ writer.deleteDocuments(term); } } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } } @@ -630,17 +637,23 @@ * * @return Entities list * - * @throws Exception the exception + * @throws SimExplorerException the exception */ - private Set<MetaData> convertHitsToElements(Hits hits, int start, int count) throws Exception { + private Set<MetaData> convertHitsToElements(Hits hits, int start, int count) throws SimExplorerException { Set<MetaData> elements = new HashSet<MetaData>(); - if (hits != null) { - // For documents in range - for (int i = start; i < hits.length() && (i < start + count || count == -1); i++) { - Document document = hits.doc(i); - // Convert to element - elements.add(loadLuceneElement(document)); + try { + if (hits != null) { + // For documents in range + for (int i = start; i < hits.length() && (i < start + count || count == -1); i++) { + Document document = hits.doc(i); + // Convert to element + elements.add(loadLuceneElement(document)); + } } + } catch (SimExplorerException e) { + throw e; + } catch (Exception e) { + throw new SimExplorerTechnicalException(e); } return elements; } @@ -652,10 +665,10 @@ * * @return Instance of element * - * @throws Exception the exception + * @throws SimExplorerException the exception */ @SuppressWarnings( { "unchecked" }) - private MetaData loadLuceneElement(Document document) throws Exception { + private MetaData loadLuceneElement(Document document) throws SimExplorerException { MetaData element = new MetaData(); // Fill element with Lucene document @@ -866,10 +879,10 @@ * @param toField the to field * * @return the associated elements - * @throws SimExplorerStorageException + * @throws SimExplorerException */ protected Set<MetaData> getAssociatedElements(MetaData mde, String fromField, String toField) - throws SimExplorerStorageException { + throws SimExplorerException { Set<MetaData> result = new HashSet<MetaData>(); try { Query query; @@ -908,8 +921,10 @@ // Release searcher instance releaseSearcher(searcher); } + } catch (SimExplorerException e) { + throw e; } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } return result; } @@ -918,7 +933,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#getElementsUsedBy(fr.cemagref.simexplorer.is.entities.metadata.MetaData) */ @Override - public Set<MetaData> getElementsUsedBy(MetaData mde) throws SimExplorerStorageException { + public Set<MetaData> getElementsUsedBy(MetaData mde) throws SimExplorerException { return getAssociatedElements(mde, KEY_UUID_VERSION_CHILD, KEY_UUID_VERSION_PARENT); } @@ -926,7 +941,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#getElementsUsing(fr.cemagref.simexplorer.is.entities.metadata.MetaData) */ @Override - public Set<MetaData> getElementsUsing(MetaData mde) throws SimExplorerStorageException { + public Set<MetaData> getElementsUsing(MetaData mde) throws SimExplorerException { return getAssociatedElements(mde, KEY_UUID_VERSION_PARENT, KEY_UUID_VERSION_CHILD); } @@ -934,7 +949,7 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#duplicateElementHierarchy(fr.cemagref.simexplorer.is.entities.metadata.MetaData, fr.cemagref.simexplorer.is.entities.metadata.MetaData) */ @Override - public void duplicateElementHierarchy(MetaData fromElement, MetaData toElement) throws SimExplorerStorageException { + public void duplicateElementHierarchy(MetaData fromElement, MetaData toElement) throws SimExplorerException { // Delete element in db with term search Term term = new Term(KEY_UUID_VERSION_PARENT, getUuidVersion(toElement.getUuid(), toElement.getVersion())); try { @@ -942,7 +957,7 @@ writer.deleteDocuments(term); } } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); + throw new SimExplorerTechnicalException(e); } Set<MetaData> elementsUsedByFrom = getElementsUsedBy(fromElement); Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -27,7 +27,7 @@ import fr.cemagref.simexplorer.is.attachment.Attachment; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; /** * The Interface StorageEngine. @@ -38,23 +38,23 @@ /** * Open storage. * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void open() throws SimExplorerStorageException; + public abstract void open() throws SimExplorerException; /** * Close storage. * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void close() throws SimExplorerStorageException; + public abstract void close() throws SimExplorerException; /** * Commit changes to storage. * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void commit() throws SimExplorerStorageException; + public abstract void commit() throws SimExplorerException; /** * Save an element to storage. @@ -63,10 +63,10 @@ * @param attachments Attachments related * @param token the token * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract void saveElement(String token, MetaData element, Map<Attachment, InputStream> attachments) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Save element hierarchy. @@ -75,10 +75,10 @@ * @param parent the parent * @param child the child * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract void saveElementHierarchy(String token, MetaData parent, MetaData child) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Duplicate element hierarchy. @@ -86,9 +86,9 @@ * @param token the token * @param fromElement the from element * @param toElement the to element - * @throws SimExplorerStorageException + * @throws SimExplorerException */ - public abstract void duplicateElementHierarchy(String token, MetaData fromElement, MetaData toElement) throws SimExplorerStorageException; + public abstract void duplicateElementHierarchy(String token, MetaData fromElement, MetaData toElement) throws SimExplorerException; /** * Can create sub version for element. @@ -98,9 +98,9 @@ * * @return true, if can create sub version * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract boolean canCreateSubVersion(String token, String uuid) throws SimExplorerStorageException; + public abstract boolean canCreateSubVersion(String token, String uuid) throws SimExplorerException; /** * Retrieve an element. @@ -110,9 +110,9 @@ * * @return The element * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract MetaData getMetadata(String token, String uuid) throws SimExplorerStorageException; + public abstract MetaData getMetadata(String token, String uuid) throws SimExplorerException; /** * Retrieve versions of an element<br> @@ -123,9 +123,9 @@ * * @return List of versions of the element<br> * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract List<Version> getVersions(String token, String uuid) throws SimExplorerStorageException; + public abstract List<Version> getVersions(String token, String uuid) throws SimExplorerException; /** * Retrieve all version of a metadata. @@ -135,9 +135,9 @@ * * @return the element versions * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract Set<MetaData> getElementVersions(String token, String uuid) throws SimExplorerStorageException; + public abstract Set<MetaData> getElementVersions(String token, String uuid) throws SimExplorerException; /** * Retrieve an element in a specific version. @@ -148,9 +148,9 @@ * * @return the metadata * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract MetaData getMetadata(String token, String uuid, Version version) throws SimExplorerStorageException; + public abstract MetaData getMetadata(String token, String uuid, Version version) throws SimExplorerException; /** * Gets the metadatas used. @@ -161,10 +161,10 @@ * * @return the metadatas used * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract MetaData[] getMetadatasUsed(String token, String uuid, Version version) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Gets the metadatas using. @@ -175,10 +175,10 @@ * * @return the metadatas using * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract MetaData[] getMetadatasUsing(String token, String uuid, Version version) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Get data associated to an element. @@ -189,10 +189,10 @@ * * @return Data stream * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract InputStream retrieveData(String token, MetaData entity, Attachment attachment) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Get number of items corresponding to query. @@ -203,10 +203,10 @@ * * @return the int * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract int findFullTextCount(String token, String query, boolean onlyLatest) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Retrieve list of items corresponding to query. @@ -220,10 +220,10 @@ * * @return the meta data[] * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, - int dateOrder) throws SimExplorerStorageException; + int dateOrder) throws SimExplorerException; /** * Retrieve list of items of type wanted. @@ -237,10 +237,10 @@ * * @return the meta data[] * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract MetaData[] findElementsByType(String token, String type, boolean onlyLatest, int start, int count, - int dateOrder) throws SimExplorerStorageException; + int dateOrder) throws SimExplorerException; /** * Retrieve number of items of type wanted. @@ -251,10 +251,10 @@ * * @return the int * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ public abstract int findElementsByTypeCount(String token, String type, boolean onlyLatest) - throws SimExplorerStorageException; + throws SimExplorerException; /** * Delete elements. @@ -262,9 +262,9 @@ * @param uuid the uuid * @param token the token * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void deleteElements(String token, String uuid) throws SimExplorerStorageException; + public abstract void deleteElements(String token, String uuid) throws SimExplorerException; /** * Delete one element. @@ -273,9 +273,9 @@ * @param version the version * @param token the token * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void deleteElement(String token, String uuid, Version version) throws SimExplorerStorageException; + public abstract void deleteElement(String token, String uuid, Version version) throws SimExplorerException; /** * Store temporary data, for stream duplication. @@ -284,9 +284,9 @@ * * @return id for retrieval * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract String storeTempData(InputStream stream) throws SimExplorerStorageException; + public abstract String storeTempData(InputStream stream) throws SimExplorerException; /** * Store temporary data, for stream duplication. @@ -294,9 +294,9 @@ * @param stream Stream to store * @param id the id * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void storeTempData(String id, InputStream stream) throws SimExplorerStorageException; + public abstract void storeTempData(String id, InputStream stream) throws SimExplorerException; /** * Retrieve temporary data. @@ -305,9 +305,9 @@ * * @return Data stream * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract InputStream retrieveTempData(String id) throws SimExplorerStorageException; + public abstract InputStream retrieveTempData(String id) throws SimExplorerException; /** * Retrieve MD5 temp data. @@ -316,18 +316,18 @@ * * @return the string * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract String retrieveMD5TempData(String id) throws SimExplorerStorageException; + public abstract String retrieveMD5TempData(String id) throws SimExplorerException; /** * Delete temporary data. * * @param id the id * - * @throws SimExplorerStorageException the sim explorer storage exception + * @throws SimExplorerException the sim explorer storage exception */ - public abstract void deleteTempData(String id) throws SimExplorerStorageException; + public abstract void deleteTempData(String id) throws SimExplorerException; } \ No newline at end of file Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -31,8 +31,8 @@ import fr.cemagref.simexplorer.is.attachment.Attachment; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException; -import fr.cemagref.simexplorer.is.storage.SimExplorerStorageTechnicalException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; import fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler; import fr.cemagref.simexplorer.is.storage.attachment.FileSystemAttachmentHandler; import fr.cemagref.simexplorer.is.storage.database.Database; @@ -75,7 +75,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#open() */ - public void open() throws SimExplorerStorageException { + public void open() throws SimExplorerException { if (!opened) { database.open(); opened = true; @@ -85,14 +85,14 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#close() */ - public void close() throws SimExplorerStorageException { + public void close() throws SimExplorerException { database.close(); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#commit() */ - public void commit() throws SimExplorerStorageException { + public void commit() throws SimExplorerException { database.commit(); } @@ -102,7 +102,7 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#saveElement(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.util.Map) */ public void saveElement(String token, MetaData element, Map<Attachment, InputStream> attachments) - throws SimExplorerStorageException { + throws SimExplorerException { // Save all attachments in system for (Map.Entry<Attachment, InputStream> entry : attachments.entrySet()) { @@ -116,13 +116,9 @@ if (attachment.getContentType() != null) { InputStream content = attachmentHandler.retrieveData(element, attachment); - try { - // Transform stream into indexable text - Reader reader = attachment.getContentType().renderToText(content); - readers.add(reader); - } catch (Exception e) { - throw new SimExplorerStorageTechnicalException(e); - } + // Transform stream into indexable text + Reader reader = attachment.getContentType().renderToText(content); + readers.add(reader); } } @@ -146,21 +142,22 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#saveElementHierarchy(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.MetaData, fr.cemagref.simexplorer.is.entities.metadata.MetaData) */ - public void saveElementHierarchy(String token, MetaData parent, MetaData child) throws SimExplorerStorageException { + public void saveElementHierarchy(String token, MetaData parent, MetaData child) throws SimExplorerException { database.saveElementHierarchy(parent, child); } @Override - public void duplicateElementHierarchy(String token, MetaData fromElement, MetaData toElement) throws SimExplorerStorageException { - database.duplicateElementHierarchy(fromElement, toElement); + public void duplicateElementHierarchy(String token, MetaData fromElement, MetaData toElement) + throws SimExplorerException { + database.duplicateElementHierarchy(fromElement, toElement); } - + // Read /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#getMetadata(java.lang.String) */ - public MetaData getMetadata(String token, String uuid) throws SimExplorerStorageException { + public MetaData getMetadata(String token, String uuid) throws SimExplorerException { MetaData mde = null; Set<MetaData> set = database.findElementsById(uuid, true); if (!set.isEmpty()) { @@ -172,14 +169,14 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#getVersions(java.lang.String) */ - public List<Version> getVersions(String token, String uuid) throws SimExplorerStorageException { + public List<Version> getVersions(String token, String uuid) throws SimExplorerException { return database.getVersions(uuid); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#getMetadata(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) */ - public MetaData getMetadata(String token, String uuid, Version version) throws SimExplorerStorageException { + public MetaData getMetadata(String token, String uuid, Version version) throws SimExplorerException { MetaData mde = database.getElement(uuid, version); return mde; } @@ -188,7 +185,7 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#getMetadatasUsed(java.lang.String, java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) */ @Override - public MetaData[] getMetadatasUsed(String token, String uuid, Version version) throws SimExplorerStorageException { + public MetaData[] getMetadatasUsed(String token, String uuid, Version version) throws SimExplorerException { MetaData mde = database.getElement(uuid, version); Set<MetaData> elements = database.getElementsUsedBy(mde); return elements.toArray(new MetaData[elements.size()]); @@ -198,7 +195,7 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#getMetadatasUsing(java.lang.String, java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) */ @Override - public MetaData[] getMetadatasUsing(String token, String uuid, Version version) throws SimExplorerStorageException { + public MetaData[] getMetadatasUsing(String token, String uuid, Version version) throws SimExplorerException { MetaData mde = database.getElement(uuid, version); Set<MetaData> elements = database.getElementsUsing(mde); return elements.toArray(new MetaData[elements.size()]); @@ -207,8 +204,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#retrieveData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String) */ - public InputStream retrieveData(String token, MetaData entity, Attachment attachment) - throws SimExplorerStorageException { + public InputStream retrieveData(String token, MetaData entity, Attachment attachment) throws SimExplorerException { InputStream result = attachmentHandler.retrieveData(entity, attachment); return result; } @@ -216,7 +212,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#findFullTextCount(java.lang.String, boolean) */ - public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerStorageException { + public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException { return database.findElementsByContentSearchCount(query, onlyLatest); } @@ -224,7 +220,7 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#findFullText(java.lang.String, boolean, int, int, int) */ public MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, - int dateOrder) throws SimExplorerStorageException { + int dateOrder) throws SimExplorerException { Set<MetaData> elements = database.findElementsByContentSearch(query, onlyLatest, indexStart, count, dateOrder); MetaData[] result = elements.toArray(new MetaData[elements.size()]); return result; @@ -234,7 +230,7 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#findElementsByType(java.lang.String, boolean, int, int, int) */ public MetaData[] findElementsByType(String token, String type, boolean onlyLatest, int start, int count, - int dateOrder) throws SimExplorerStorageException { + int dateOrder) throws SimExplorerException { Set<MetaData> elements = database.findElementsByType(type, onlyLatest, start, count, dateOrder); MetaData[] result = elements.toArray(new MetaData[elements.size()]); return result; @@ -243,8 +239,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#findElementsByTypeCount(java.lang.String, boolean) */ - public int findElementsByTypeCount(String token, String type, boolean onlyLatest) - throws SimExplorerStorageException { + public int findElementsByTypeCount(String token, String type, boolean onlyLatest) throws SimExplorerException { return database.findElementsByTypeCount(type, onlyLatest); } @@ -253,7 +248,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#deleteElements(java.lang.String) */ - public void deleteElements(String token, String uuid) throws SimExplorerStorageException { + public void deleteElements(String token, String uuid) throws SimExplorerException { List<Version> versions = getVersions(token, uuid); for (Version version : versions) { deleteElement(token, uuid, version); @@ -263,7 +258,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#deleteElement(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version) */ - public void deleteElement(String token, String uuid, Version version) throws SimExplorerStorageException { + public void deleteElement(String token, String uuid, Version version) throws SimExplorerException { MetaData element = getMetadata(token, uuid, version); List<Attachment> attachments = element.getAttachments(); for (Attachment attachment : attachments) { @@ -291,7 +286,7 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#storeTempData(java.io.InputStream) */ - public String storeTempData(InputStream stream) throws SimExplorerStorageException { + public String storeTempData(InputStream stream) throws SimExplorerException { String id = UUID.randomUUID().toString(); storeTempData(id, stream); return id; @@ -301,14 +296,14 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#storeTempData(java.lang.String, java.io.InputStream) */ @Override - public void storeTempData(String id, InputStream stream) throws SimExplorerStorageException { + public void storeTempData(String id, InputStream stream) throws SimExplorerException { attachmentHandler.storeData(mdTmp, getTmpAttachment(id), stream); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#retrieveTempData(java.lang.String) */ - public InputStream retrieveTempData(String id) throws SimExplorerStorageException { + public InputStream retrieveTempData(String id) throws SimExplorerException { InputStream is = attachmentHandler.retrieveData(mdTmp, getTmpAttachment(id)); return is; } @@ -317,7 +312,7 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#retrieveMD5TempData(java.lang.String) */ @Override - public String retrieveMD5TempData(String id) throws SimExplorerStorageException { + public String retrieveMD5TempData(String id) throws SimExplorerException { String md5 = attachmentHandler.retrieveMD5Data(mdTmp, getTmpAttachment(id)); return md5; } @@ -325,14 +320,14 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#deleteTempData(java.lang.String) */ - public void deleteTempData(String id) throws SimExplorerStorageException { + public void deleteTempData(String id) throws SimExplorerException { attachmentHandler.deleteData(mdTmp, getTmpAttachment(id)); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#getElementVersions(java.lang.String, java.lang.String) */ - public Set<MetaData> getElementVersions(String token, String uuid) throws SimExplorerStorageException { + public Set<MetaData> getElementVersions(String token, String uuid) throws SimExplorerException { return database.findElementsById(uuid, false); } @@ -340,10 +335,9 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#canCreateSubVersion(java.lang.String, java.lang.String) */ @Override - public boolean canCreateSubVersion(String token, String uuid) throws SimExplorerStorageException { + public boolean canCreateSubVersion(String token, String uuid) throws SimExplorerException { // by default return true; } - } Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -18,15 +18,9 @@ * ##% */ package fr.cemagref.simexplorer.is.service; -import com.healthmarketscience.rmiio.SerializableInputStream; -import fr.cemagref.simexplorer.is.attachment.Attachment; -import fr.cemagref.simexplorer.is.entities.data.LoggableElement; -import fr.cemagref.simexplorer.is.entities.metadata.MetaData; -import fr.cemagref.simexplorer.is.entities.metadata.Version; import static fr.cemagref.simexplorer.is.factories.XmlConstants.FILE_DATA_PREFIX; import static fr.cemagref.simexplorer.is.factories.XmlConstants.FILE_XML; import static fr.cemagref.simexplorer.is.factories.XmlConstants.FOLDER_SEPARATOR; -import org.codelutin.util.ZipStreamEncoder; import java.io.InputStream; import java.io.PipedInputStream; @@ -36,6 +30,16 @@ import java.util.Map; import java.util.SortedMap; +import org.codelutin.util.ZipStreamEncoder; + +import com.healthmarketscience.rmiio.SerializableInputStream; + +import fr.cemagref.simexplorer.is.attachment.Attachment; +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.entities.metadata.MetaData; +import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; + /** * The Class MockStorageServiceImpl. * @@ -64,19 +68,19 @@ } public MetaData saveElement(String token, SerializableInputStream zipRemoteStream) - throws SimExplorerServiceException { + throws SimExplorerException { return (MetaData) checkImplemented(); } public MetaData saveElement(String token, SerializableInputStream xmlRemoteStream, Map<Attachment, SerializableInputStream> attachmentsRemoteStream) - throws SimExplorerServiceException { + throws SimExplorerException { return (MetaData) checkImplemented(); } public MetaData getMetadata(String token, String uuid) - throws SimExplorerServiceException { + throws SimExplorerException { MetaData[] datas = base.metadatas.get(uuid); return datas == null ? null : datas[0]; } @@ -85,7 +89,7 @@ * @see fr.cemagref.simexplorer.is.service.StorageService#getMetadata(java.lang.String, java.lang.String, java.lang.String) */ public MetaData getMetadata(String token, String uuid, String version) - throws SimExplorerServiceException { + throws SimExplorerException { MetaData[] datas = base.metadatas.get(uuid); if (datas == null) { return null; @@ -103,7 +107,7 @@ * @see fr.cemagref.simexplorer.is.service.StorageService#exportElement(java.lang.String, java.lang.String, java.lang.String) */ public InputStream retrieveElementXML(String token, String uuid, - String version) throws SimExplorerServiceException { + String version) throws SimExplorerException { return (InputStream) checkImplemented(); } @@ -111,7 +115,7 @@ * @see fr.cemagref.simexplorer.is.service.StorageService#exportFull(java.lang.String, java.lang.String, java.lang.String) */ public InputStream retrieveElementFull(String token, String uuid, - String version) throws SimExplorerServiceException { + String version) throws SimExplorerException { return (InputStream) checkImplemented(); } @@ -120,7 +124,7 @@ * @see fr.cemagref.simexplorer.is.service.StorageService#retrieveData(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ public InputStream retrieveElementData(String token, String uuid, - String version, Attachment attachment) throws SimExplorerServiceException { + String version, Attachment attachment) throws SimExplorerException { return null; } @@ -129,7 +133,7 @@ * @see fr.cemagref.simexplorer.is.service.StorageService#exportFull(java.lang.String, java.lang.String, java.lang.String) */ public InputStream downloadElementFull(String token, String uuid, - String version) throws SimExplorerServiceException { + String version) throws SimExplorerException { LoggableElement element = getLoggableElement(token, uuid, version); try { PipedOutputStream pipedOut = new PipedOutputStream(); @@ -150,14 +154,14 @@ zse.start(); return pipedIn; } catch (Exception e) { - throw new SimExplorerServiceException(e); + throw new SimExplorerException(e); } } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#retrieveData(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ - public InputStream downloadElementData(String token, String uuid, String version, Attachment attachment) throws SimExplorerServiceException { + public InputStream downloadElementData(String token, String uuid, String version, Attachment attachment) throws SimExplorerException { LoggableElement element = getLoggableElement(token, uuid, version); try { @@ -167,7 +171,7 @@ MockDatabase.log.info("setMd5 " + md5 + " for " + element); return stream.getStream(); } catch (Exception e) { - throw new SimExplorerServiceException(e); + throw new SimExplorerException(e); } } @@ -181,20 +185,20 @@ } public int findFullTextCount(String token, String query, boolean onlyLatest) - throws SimExplorerServiceException { + throws SimExplorerException { // TODO Changer return findApplicationsCount(token, onlyLatest); } public MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, int dateOrder) - throws SimExplorerServiceException { + throws SimExplorerException { // TODO Changer return findApplications(token, onlyLatest, indexStart, count, dateOrder); } public int findApplicationsCount(String token, boolean onlyLatest) - throws SimExplorerServiceException { + throws SimExplorerException { return base.metadatas.size(); } @@ -203,7 +207,7 @@ */ public MetaData[] findApplications(String token, boolean onlyLatest, int start, int count, int dateOrder) - throws SimExplorerServiceException { + throws SimExplorerException { int last = start + count; MockDatabase.log.info("ask data from " + start + " width:" + count); SortedMap<String, MetaData[]> map = base.metadatas; @@ -222,7 +226,7 @@ * @see fr.cemagref.simexplorer.is.service.StorageService#getElement(java.lang.String, java.lang.String, java.lang.String) */ public LoggableElement getLoggableElement(String token, String uuid, String version) - throws SimExplorerServiceException { + throws SimExplorerException { try { LoggableElement[] eas = base.loggableElements.get(uuid); if (eas == null) { @@ -236,7 +240,7 @@ } return null; } catch (Exception e) { - throw new SimExplorerServiceException(e); + throw new SimExplorerException(e); } } @@ -244,7 +248,7 @@ * @see fr.cemagref.simexplorer.is.service.StorageService#getVersions(java.lang.String, java.lang.String) */ public Version[] getVersions(String token, String uuid) - throws SimExplorerServiceException { + throws SimExplorerException { MetaData[] datas = base.metadatas.get(uuid); if (datas == null) { return new Version[0]; @@ -260,9 +264,9 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#loginUser(java.lang.String, java.lang.String) */ - public String loginUser(String login, String password) throws SimExplorerServiceException { + public String loginUser(String login, String password) throws SimExplorerException { if (login == null) { - throw new SimExplorerServiceException(new NullPointerException("login can not be null")); + throw new SimExplorerException(new NullPointerException("login can not be null")); } return password == null || password.length() == 0 ? null : "abc"; } @@ -283,7 +287,7 @@ @Override public void update(String token, String oldUuid, Version oldVersion, MetaData newVersion, boolean deleteOldElement) - throws SimExplorerServiceException { + throws SimExplorerException { checkImplemented(); } @@ -293,13 +297,13 @@ } @Override - public MetaData[] getMetadatasUsed(String token, String uuid, String version) throws SimExplorerServiceException { + public MetaData[] getMetadatasUsed(String token, String uuid, String version) throws SimExplorerException { checkImplemented(); return null; } @Override - public MetaData[] getMetadatasUsing(String token, String uuid, String version) throws SimExplorerServiceException { + public MetaData[] getMetadatasUsing(String token, String uuid, String version) throws SimExplorerException { checkImplemented(); return null; } Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerException.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerException.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorerException.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -1,44 +0,0 @@ -/* -* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, -* Tony Chemit, Gabriel Landais -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.ui; - -/** - * Exception de base. - * - * @author chemit - */ -public class SimExplorerException extends Exception { - - private static final long serialVersionUID = -8288416952045350383L; - - public SimExplorerException() { - } - - public SimExplorerException(Throwable cause) { - super(cause); - } - - public SimExplorerException(String message) { - super(message); - } - - public SimExplorerException(String message, Throwable cause) { - super(message, cause); - } -} Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/StorageServiceHelper.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/StorageServiceHelper.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/StorageServiceHelper.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -18,27 +18,30 @@ * ##% */ package fr.cemagref.simexplorer.is.ui; +import static fr.cemagref.simexplorer.is.service.StorageServiceHelper.STORAGE_SERVICE_LOOKUP_NAME; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URI; +import java.util.Properties; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + import com.healthmarketscience.rmiio.SerializableInputStream; + import fr.cemagref.simexplorer.is.attachment.Attachment; import fr.cemagref.simexplorer.is.entities.data.LoggableElement; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.service.MockStorageServiceImpl; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.service.StorageService; import fr.cemagref.simexplorer.is.service.StorageServiceClient; -import static fr.cemagref.simexplorer.is.service.StorageServiceHelper.STORAGE_SERVICE_LOOKUP_NAME; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.net.URI; -import java.util.Properties; - /** * Une classe pour encapsuler les appels aux services Storage et leur initialisation. * @@ -80,7 +83,7 @@ size = service.findFullTextCount(token, query, onlyLatest); } return size; - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerRuntimeException(e); } } @@ -96,7 +99,7 @@ data = service.findFullText(token, query, onlyLatest, (int) newFirstIndex, width, rowOrder); } return data; - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerRuntimeException(e); } } @@ -107,7 +110,7 @@ LoggableElement data; data = getService(context, remote).getLoggableElement(context.getToken(), uuid, version); return data; - } catch (SimExplorerServiceException e1) { + } catch (SimExplorerException e1) { throw new SimExplorerRuntimeException(e1); } } @@ -117,7 +120,7 @@ MetaData metas; metas = getService(context, remote).getMetadata(context.getToken(), uuid, version); return metas; - } catch (SimExplorerServiceException e1) { + } catch (SimExplorerException e1) { throw new SimExplorerRuntimeException(e1); } } @@ -129,7 +132,7 @@ BufferedInputStream bis; bis = new BufferedInputStream(stream); return bis; - } catch (SimExplorerServiceException e1) { + } catch (SimExplorerException e1) { throw new SimExplorerRuntimeException(e1); } } @@ -140,7 +143,7 @@ BufferedInputStream bis; bis = new BufferedInputStream(stream); return bis; - } catch (SimExplorerServiceException e1) { + } catch (SimExplorerException e1) { throw new SimExplorerRuntimeException(e1); } } @@ -160,7 +163,7 @@ Version[] result; result = getService(context, remote).getVersions(context.getToken(), uuid); return result; - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerRuntimeException(e); } } Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -18,19 +18,21 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.swing.actions; +import static org.codelutin.i18n.I18n._; + +import java.awt.event.ActionEvent; + +import javax.swing.JOptionPane; + +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.service.AuthenticationServiceHelper; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.service.StorageService; import fr.cemagref.simexplorer.is.ui.SimExplorerRuntimeException; import fr.cemagref.simexplorer.is.ui.StorageServiceHelper; import fr.cemagref.simexplorer.is.ui.swing.LoginUI; import fr.cemagref.simexplorer.is.ui.swing.MainUIRefreshHelper; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction; -import static org.codelutin.i18n.I18n._; -import javax.swing.JOptionPane; -import java.awt.event.ActionEvent; - /** * Action de connexion au serveur distant * @@ -115,7 +117,7 @@ String token; try { token = service.loginUser(login, password); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { token = null; } getContext().setToken(token); @@ -137,7 +139,7 @@ protected boolean connect(String login, char[] password) { try { return connect(login, AuthenticationServiceHelper.computeHash(password)); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerRuntimeException(e); } } Modified: trunk/simexplorer-is/simexplorer-is-swing/src/resources/i18n/simexplorer-is-swing-en_GB.properties =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/resources/i18n/simexplorer-is-swing-en_GB.properties 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-swing/src/resources/i18n/simexplorer-is-swing-en_GB.properties 2008-02-15 16:25:18 UTC (rev 1006) @@ -69,9 +69,6 @@ simexplorer.action.hide.remote=List (remote) simexplorer.action.hide.remote.help= simexplorer.action.hide.remote.tooltip=Hide the list of remote elements -simexplorer.action.hide.synchronize=Synchronize -simexplorer.action.hide.synchronize.help= -simexplorer.action.hide.synchronize.tooltip=Hide Synchronize screen simexplorer.action.historyNext=Next in history simexplorer.action.historyNext.help= simexplorer.action.historyNext.tooltip=Display next element ''{0}'' Modified: trunk/simexplorer-is/simexplorer-is-swing/src/resources/i18n/simexplorer-is-swing-fr_FR.properties =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/resources/i18n/simexplorer-is-swing-fr_FR.properties 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-swing/src/resources/i18n/simexplorer-is-swing-fr_FR.properties 2008-02-15 16:25:18 UTC (rev 1006) @@ -65,13 +65,10 @@ simexplorer.action.help.tooltip=Acc\u00E9der \u00E0 l'aide simexplorer.action.hide.local=Liste locale simexplorer.action.hide.local.help= -simexplorer.action.hide.local.tooltip=Cacher la liste des élements du serveur local +simexplorer.action.hide.local.tooltip=Cacher la liste des \u00E9lements du serveur local simexplorer.action.hide.remote=Liste distante simexplorer.action.hide.remote.help= -simexplorer.action.hide.remote.tooltip=Cacher la liste des éléments du serveur distant -simexplorer.action.hide.synchronize=Synchronisation -simexplorer.action.hide.synchronize.help= -simexplorer.action.hide.synchronize.tooltip=Cacher l'\u00E9cran de synchronisation +simexplorer.action.hide.remote.tooltip=Cacher la liste des \u00E9l\u00E9ments du serveur distant simexplorer.action.historyNext=El\u00E9ment suivant simexplorer.action.historyNext.help= simexplorer.action.historyNext.tooltip=Afficher l''\u00E9l\u00E9ment suivant ''{0}'' @@ -100,13 +97,13 @@ simexplorer.action.searchText.tooltip=Le texte de recherche simexplorer.action.show.detail=D\u00E9tail simexplorer.action.show.detail.help= -simexplorer.action.show.detail.tooltip=Affciher les d\u00E9tail de l'élément +simexplorer.action.show.detail.tooltip=Affciher les d\u00E9tail de l'\u00E9l\u00E9ment simexplorer.action.show.local=Liste locale simexplorer.action.show.local.help= -simexplorer.action.show.local.tooltip=Afficher la liste des éléments du serveur local +simexplorer.action.show.local.tooltip=Afficher la liste des \u00E9l\u00E9ments du serveur local simexplorer.action.show.remote=Liste distante simexplorer.action.show.remote.help= -simexplorer.action.show.remote.tooltip=Afficher la liste des éléments du serveur distant +simexplorer.action.show.remote.tooltip=Afficher la liste des \u00E9l\u00E9ments du serveur distant simexplorer.action.show.synchronize=Synchroniser simexplorer.action.show.synchronize.help= simexplorer.action.show.synchronize.tooltip=Afficher l'\u00E9cran de synchronisation des applications @@ -189,9 +186,9 @@ simexplorer.tab.detail=D\u00E9tail simexplorer.tab.detail.tooltip=L'\u00E9cran affichant les d\u00E9tails d'un \u00E9l\u00E9ment simexplorer.tab.local=Liste locale -simexplorer.tab.local.tooltip=La liste des éléments pr\u00E9sents sur le serveur local +simexplorer.tab.local.tooltip=La liste des \u00E9l\u00E9ments pr\u00E9sents sur le serveur local simexplorer.tab.remote=Liste distante -simexplorer.tab.remote.tooltip=La liste des éléments pr\u00E9sents sur le serveur distant +simexplorer.tab.remote.tooltip=La liste des \u00E9l\u00E9ments pr\u00E9sents sur le serveur distant simexplorer.tab.synchronize=Synchronisation -simexplorer.tab.synchronize.tooltip=L'\u00E9cran de synchronisation des éléments +simexplorer.tab.synchronize.tooltip=L'\u00E9cran de synchronisation des \u00E9l\u00E9ments {0}\ should\ have\ a\ name\ like\ this\ {1},\ but\ was\ {2}= Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -21,7 +21,7 @@ import org.apache.tapestry.grid.GridDataSource; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService; @@ -83,7 +83,7 @@ result = RemoteStorageService.getStorageService() .findFullTextCount(token, query, false); } - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return result; @@ -130,7 +130,7 @@ .findFullText(token, query, false, startIndex, 1 + endIndex - startIndex, dateOrder); } - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } } Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -19,7 +19,7 @@ import org.apache.tapestry.annotations.InjectPage; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService; @@ -42,7 +42,7 @@ RemoteStorageService.getStorageService().deleteElement(getToken(), getMetadata().getUuid(), getMetadata().getVersion().toString()); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return elementDetail; @@ -57,7 +57,7 @@ try { RemoteStorageService.getStorageService().deleteElement(getToken(), getMetadata().getUuid()); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return elementDetail; Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -26,7 +26,7 @@ import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService; @@ -78,9 +78,9 @@ * * @return the versions * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public List<TreeNode> getVersions() throws SimExplorerServiceException { + public List<TreeNode> getVersions() throws SimExplorerException { List<TreeNode> nodes = new ArrayList<TreeNode>(); nodes.add(generateNodes()); return nodes; @@ -91,9 +91,9 @@ * * @return the tree node * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private TreeNode generateNodes() throws SimExplorerServiceException { + private TreeNode generateNodes() throws SimExplorerException { Arrays.sort(versions); TreeNode rootNode = new TreeNode(); rootNode.setType(TreeNode.TYPE_FOLDER); @@ -113,9 +113,9 @@ * @param parent the parent * @param version the version * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private void insertNode(Version version, int pos, TreeNode parent) throws SimExplorerServiceException { + private void insertNode(Version version, int pos, TreeNode parent) throws SimExplorerException { List<TreeNode> nodes = parent.getChildren(); if (pos == version.getLength()) { nodes.add(generateLeaf(version)); @@ -177,9 +177,9 @@ * * @return the tree node * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - private TreeNode generateLeaf(Version version) throws SimExplorerServiceException { + private TreeNode generateLeaf(Version version) throws SimExplorerException { TreeNode node = new TreeNode(); MetaData mde = RemoteStorageService.getStorageService().getMetadata(getToken(), getMetadata().getUuid(), version.toString()); Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -24,6 +24,8 @@ import de.hsofttec.t5components.annotations.SetterGetter; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.pages.security.UserPage; import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService; @@ -52,31 +54,25 @@ * * @throws Exception the exception */ - public Object onSuccess() throws Exception { + public Object onSuccess() throws SimExplorerException { MetaData mde = null; if (_fileEA != null) { - SerializableInputStream zipStream = new SerializableInputStream(_fileEA.getStream()); - // RemoteInputStreamServer zipRemoteStream = new SimpleRemoteInputStream( - // _fileEA.getStream()); + SerializableInputStream zipStream; try { - // mde = RemoteStorageService.getStorageService().saveElement( - // getToken(), zipRemoteStream.export()); - mde = RemoteStorageService.getStorageService().saveElement(getToken(), zipStream); + zipStream = new SerializableInputStream(_fileEA.getStream()); } catch (Exception e) { - throw new SimExplorerWebException(e); + throw new SimExplorerTechnicalException(e); } + mde = RemoteStorageService.getStorageService().saveElement(getToken(), zipStream); } else { if (_fileLib != null) { - SerializableInputStream zipStream = new SerializableInputStream(_fileLib.getStream()); - // RemoteInputStreamServer zipRemoteStream = new SimpleRemoteInputStream( - // _fileLib.getStream()); + SerializableInputStream zipStream; try { - // mde = RemoteStorageService.getStorageService().saveElement( - // getToken(), zipRemoteStream.export()); - mde = RemoteStorageService.getStorageService().saveElement(getToken(), zipStream); + zipStream = new SerializableInputStream(_fileLib.getStream()); } catch (Exception e) { - throw new SimExplorerWebException(); + throw new SimExplorerTechnicalException(e); } + mde = RemoteStorageService.getStorageService().saveElement(getToken(), zipStream); } } if (mde != null) { Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementMetadata.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementMetadata.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementMetadata.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -25,7 +25,7 @@ import de.hsofttec.t5components.annotations.SetterGetter; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService; import fr.cemagref.simexplorer.is.ui.web.tools.MetaDataModelFactory; @@ -79,9 +79,9 @@ * * @return the elements used * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public MetaData[] getElementsUsed() throws SimExplorerServiceException { + public MetaData[] getElementsUsed() throws SimExplorerException { return RemoteStorageService.getStorageService().getMetadatasUsed(getToken(), getMetadata().getUuid(), getMetadata().getVersion().toString()); } @@ -91,9 +91,9 @@ * * @return the elements using * - * @throws SimExplorerServiceException the sim explorer service exception + * @throws SimExplorerException the sim explorer service exception */ - public MetaData[] getElementsUsing() throws SimExplorerServiceException { + public MetaData[] getElementsUsing() throws SimExplorerException { return RemoteStorageService.getStorageService().getMetadatasUsing(getToken(), getMetadata().getUuid(), getMetadata().getVersion().toString()); } Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementRights.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementRights.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementRights.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -26,11 +26,11 @@ import org.apache.tapestry.annotations.InjectPage; import org.apache.tapestry.annotations.Persist; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.Actor; import fr.cemagref.simexplorer.is.security.entities.Group; import fr.cemagref.simexplorer.is.security.entities.Permission; import fr.cemagref.simexplorer.is.security.entities.User; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.services.GroupValueEncoder; import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService; @@ -232,7 +232,7 @@ User[] users = RemoteSecurityService.getAuthentificationService() .getUsers(getToken()); result.addAll(Arrays.asList(users)); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return result; @@ -249,7 +249,7 @@ Group[] groups = RemoteSecurityService.getAuthentificationService() .getGroups(getToken()); result.addAll(Arrays.asList(groups)); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupEdit.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupEdit.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupEdit.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -25,9 +25,9 @@ import org.apache.tapestry.annotations.InjectPage; import org.apache.tapestry.annotations.Persist; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.Group; import fr.cemagref.simexplorer.is.security.entities.User; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.pages.security.AdminPage; import fr.cemagref.simexplorer.is.ui.web.services.GroupValueEncoder; @@ -97,7 +97,7 @@ .getAuthentificationService().getGroupsOfGroup( getToken(), group); this.groupsInGroup.addAll(Arrays.asList(groups)); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } @@ -138,7 +138,7 @@ } RemoteSecurityService.getAuthentificationService() .setGroupsOfGroup(getToken(), group, groupsIds); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } @@ -165,7 +165,7 @@ User[] users = RemoteSecurityService.getAuthentificationService() .getUsers(getToken()); result.addAll(Arrays.asList(users)); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return result; @@ -182,7 +182,7 @@ Group[] groups = RemoteSecurityService.getAuthentificationService() .getGroups(getToken()); result.addAll(Arrays.asList(groups)); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupList.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupList.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupList.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -28,8 +28,8 @@ import org.apache.tapestry.services.BeanModelSource; import de.hsofttec.t5components.annotations.SetterGetter; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.Group; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.pages.security.AdminPage; import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService; @@ -103,7 +103,7 @@ .getGroupsOwnedBy(getToken(), getUserLogged()); } - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } @@ -122,7 +122,7 @@ try { RemoteSecurityService.getAuthentificationService().deleteGroup( getToken(), context); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return null; Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -17,8 +17,8 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.web.pages; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.service.AuthenticationServiceHelper; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService; import org.apache.tapestry.annotations.ApplicationState; @@ -83,7 +83,7 @@ formLogin.recordError(messages .get("simexplorer.ui.web.login.invalid")); return this; - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } } @@ -97,7 +97,7 @@ try { RemoteSecurityService.getAuthentificationService().requestAccount( login, mail); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return this; Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserEdit.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserEdit.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserEdit.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -31,9 +31,9 @@ import org.apache.tapestry.services.BeanModelSource; import de.hsofttec.t5components.annotations.SetterGetter; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.Group; import fr.cemagref.simexplorer.is.security.entities.User; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.pages.security.AdminPage; import fr.cemagref.simexplorer.is.ui.web.services.GroupValueEncoder; @@ -118,7 +118,7 @@ .getAuthentificationService().getGroupsOfUser( getToken(), this.user); groupsOfUser.addAll(Arrays.asList(groups)); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } @@ -150,7 +150,7 @@ getToken(), user, groupsIds); return userList; - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } } @@ -165,7 +165,7 @@ try { groups = RemoteSecurityService.getAuthentificationService() .getGroups(getToken()); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } List<Group> result = new ArrayList<Group>(); @@ -185,7 +185,7 @@ } return RemoteSecurityService.getAuthentificationService() .getGroupsOwnedBy(getToken(), user); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } } @@ -227,7 +227,7 @@ RemoteSecurityService.getAuthentificationService().resetPassword( getToken(), user.getLogin()); return this; - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } } Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserList.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserList.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserList.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -28,8 +28,8 @@ import org.apache.tapestry.services.BeanModelSource; import de.hsofttec.t5components.annotations.SetterGetter; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.User; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.pages.security.AdminPage; import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService; @@ -99,7 +99,7 @@ try { users = RemoteSecurityService.getAuthentificationService() .getUsers(getToken()); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } @@ -118,7 +118,7 @@ try { RemoteSecurityService.getAuthentificationService().deleteUser( getToken(), context); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return null; Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -22,8 +22,8 @@ import org.apache.tapestry.ioc.Messages; import org.apache.tapestry.ioc.annotations.Inject; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.User; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService; @@ -108,7 +108,7 @@ try { loggedUser = RemoteSecurityService.getAuthentificationService() .getLoggedUser(token); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } } Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/GroupValueEncoder.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/GroupValueEncoder.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/GroupValueEncoder.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -19,8 +19,8 @@ import org.apache.tapestry.ValueEncoder; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.Group; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; /** @@ -57,7 +57,7 @@ try { group = RemoteSecurityService.getAuthentificationService().getGroup( token, Integer.decode(arg0)); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return group; Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/UserValueEncoder.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/UserValueEncoder.java 2008-02-15 15:45:52 UTC (rev 1005) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/UserValueEncoder.java 2008-02-15 16:25:18 UTC (rev 1006) @@ -19,8 +19,8 @@ import org.apache.tapestry.ValueEncoder; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.User; -import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException; /** @@ -57,7 +57,7 @@ try { user = RemoteSecurityService.getAuthentificationService().getUser( token, Integer.decode(arg0)); - } catch (SimExplorerServiceException e) { + } catch (SimExplorerException e) { throw new SimExplorerWebException(e); } return user;