r2553 - in trunk: . topia-persistence/src/main/java/org/nuiton/topia topia-persistence/src/main/java/org/nuiton/topia/framework topia-persistence/src/main/java/org/nuiton/topia/generator topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence topia-service-migration/src/main/java/org/nuiton/topia/migration
Author: athimel Date: 2012-05-29 17:40:37 +0200 (Tue, 29 May 2012) New Revision: 2553 Url: http://nuiton.org/repositories/revision/topia/2553 Log: #refs #1945 TopiaRuntimeException deleted TopiaException is now runtime Removed: trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaRuntimeException.java Modified: trunk/pom.xml trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/TopiaHibernateSpecificUtil.java trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaException.java trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaPersistenceProvider.java trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-05-29 15:05:59 UTC (rev 2552) +++ trunk/pom.xml 2012-05-29 15:40:37 UTC (rev 2553) @@ -73,7 +73,6 @@ <processorPluginVersion>1.2.2</processorPluginVersion> <nuitonI18nVersion>2.4.1</nuitonI18nVersion> <xmlrpcVersion>3.1.2</xmlrpcVersion> - <!--<hibernateVersion>3.6.10.Final</hibernateVersion>--> <hibernateVersion>4.1.3.Final</hibernateVersion> <sl4jVersion>1.6.4</sl4jVersion> <h2Version>1.3.167</h2Version> Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaException.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaException.java 2012-05-29 15:05:59 UTC (rev 2552) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaException.java 2012-05-29 15:40:37 UTC (rev 2553) @@ -26,20 +26,24 @@ package org.nuiton.topia; /** - * Main exception for Topia errors on hibernate manipulations. - * + * Main exception for ToPIA manipulation errors (entity class not found, context + * unavailable, invalid state, access denied, ...). Since ToPIA 3.0, this + * exception is unchecked. + * <p/> * Created: 23 déc. 2005 23:03:36 * * @author poussin <poussin@codelutin.com> * @version $Id$ */ -public class TopiaException extends Exception { +public class TopiaException extends RuntimeException { - /** Version UID */ - private static final long serialVersionUID = -1251439453383121393L; + /** + * Version UID + */ + private static final long serialVersionUID = 3692450097443844102L; /** - * Default constructor. + * Default constructor. */ public TopiaException() { } @@ -58,7 +62,7 @@ * with a {@code message}. * * @param message exception message - * @param cause exception cause + * @param cause exception cause */ public TopiaException(String message, Throwable cause) { super(message, cause); Deleted: trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaRuntimeException.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaRuntimeException.java 2012-05-29 15:05:59 UTC (rev 2552) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaRuntimeException.java 2012-05-29 15:40:37 UTC (rev 2553) @@ -1,74 +0,0 @@ -/* - * #%L - * ToPIA :: Persistence - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package org.nuiton.topia; - -/** - * TODO-FD20100507 : Need javadoc. - * - * @author chatellier <chatellier@codelutin.com> - * @version $Id$ - */ -public class TopiaRuntimeException extends RuntimeException { - - /** Version UID */ - private static final long serialVersionUID = 4706337137948838375L; - - /** - * Default constructor. - */ - public TopiaRuntimeException() { - } - - /** - * Constructor with {@code message}. - * - * @param message exception message - */ - public TopiaRuntimeException(String message) { - super(message); - } - - /** - * Constructor for a wrapped TopiaRuntimeException over a {@code cause} - * with a {@code message}. - * - * @param message exception message - * @param cause exception cause - */ - public TopiaRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructor for a wrapped TopiaRuntimeException over a {@code cause}. - * - * @param cause exception cause - */ - public TopiaRuntimeException(Throwable cause) { - super(cause); - } - -} Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2012-05-29 15:05:59 UTC (rev 2552) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2012-05-29 15:40:37 UTC (rev 2553) @@ -43,7 +43,6 @@ import org.nuiton.topia.TopiaContextFactory; import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; -import org.nuiton.topia.TopiaRuntimeException; import org.nuiton.topia.event.TopiaContextListener; import org.nuiton.topia.event.TopiaEntitiesVetoable; import org.nuiton.topia.event.TopiaEntityListener; @@ -304,7 +303,7 @@ } @Override - public EntityManager getEntityManager() throws TopiaException { + public EntityManager getEntityManager() { if (entityManager == null) { throw new TopiaException( "No EntityManager found. Please open first a new " + @@ -334,7 +333,7 @@ result = getParentContext().getSpecificUtil(); } if (result == null) { - throw new TopiaRuntimeException("No TopiaSpecificUtil found."); + throw new TopiaException("No TopiaSpecificUtil found."); } return result; } @@ -471,7 +470,7 @@ @Override public <E extends TopiaEntity> TopiaDAO<E> getDAO(Class<E> entityClass) - throws TopiaException { + { if (entityClass == null) { String message = String.format( "The method '%s' requires a non null parameter '%s'.", @@ -531,7 +530,7 @@ @Override public <E extends TopiaEntity, D extends TopiaDAO<E>> D getDAO( - Class<E> entityClass, Class<D> daoClass) throws TopiaException { + Class<E> entityClass, Class<D> daoClass) { return (D) getDAO(entityClass); } @@ -539,7 +538,7 @@ /* -------------------- TRANSACTION MANAGEMENT --------------------------*/ @Override - public TopiaContext beginTransaction() throws TopiaException { + public TopiaContext beginTransaction() { checkClosed("beginTransaction"); TopiaContextImpl result = new TopiaContextImpl(this); @@ -588,7 +587,7 @@ } @Override - public void commitTransaction() throws TopiaException { + public void commitTransaction() { if (TopiaPredicates.IS_ROOT_CONTEXT.apply(this)) { String message = String.format("Operation '%s' is not permitted on root context", "commitTransaction"); throw new TopiaException(message); @@ -616,7 +615,7 @@ } @Override - public void rollbackTransaction() throws TopiaException { + public void rollbackTransaction() { if (TopiaPredicates.IS_ROOT_CONTEXT.apply(this)) { String message = String.format("Operation '%s' is not permitted on root context", "rollbackTransaction"); throw new TopiaException(message); @@ -648,7 +647,7 @@ } @Override - public void closeContext() throws TopiaException { + public void closeContext() { checkClosed("closeContext"); // Remove all children context @@ -691,7 +690,7 @@ return closed; } - protected void checkClosed(String method) throws TopiaException { + protected void checkClosed(String method) { if (closed) { String message = String.format( "This context is closed, unable to perform operation '%s'", @@ -840,7 +839,7 @@ /* -------------------- GLOBAL OPERATIONS ON ENTITIES --------------------*/ @Override - public TopiaEntity findByTopiaId(String id) throws TopiaException { + public TopiaEntity findByTopiaId(String id) { checkClosed("findByTopiaId"); Class<TopiaEntity> entityClass = TopiaIdUtil.getClassName(id); @@ -850,7 +849,7 @@ } @Override - public List<?> findByQuery(TopiaQuery query) throws TopiaException { + public List<?> findByQuery(TopiaQuery query) { return query.execute(this); } @@ -860,7 +859,7 @@ } @Override - public List<?> find(String jpaql, Object... paramNamesAndValues) throws TopiaException { + public List<?> find(String jpaql, Object... paramNamesAndValues) { List<?> result = find(jpaql, 0, -1, paramNamesAndValues); return result; } @@ -875,7 +874,7 @@ @Override public List<?> find(String jpaql, int startIndex, int endIndex, Object... paramNamesAndValues) - throws TopiaException { + { checkClosed("find"); try { @@ -905,7 +904,7 @@ } @Override - public int execute(String jpaql, Object... paramNamesAndValues) throws TopiaException { + public int execute(String jpaql, Object... paramNamesAndValues) { checkClosed("execute"); try { @@ -926,7 +925,7 @@ } @Override - public void add(TopiaEntity e) throws TopiaException { + public void add(TopiaEntity e) { checkClosed("add"); String id = e.getTopiaId(); @@ -937,7 +936,7 @@ } @Override - public void executeSQL(String sqlScript) throws TopiaException { + public void executeSQL(String sqlScript) { try { Query nativeQuery = getEntityManager().createNativeQuery(sqlScript); nativeQuery.executeUpdate(); @@ -966,18 +965,15 @@ } } return true; - } catch (TopiaException te) { - throw new TopiaRuntimeException( - "Unable to detect if schema is empty", te); } catch (ClassNotFoundException cnfe) { - throw new TopiaRuntimeException( + throw new TopiaException( "Unable to detect if schema is empty", cnfe); } } @Override public boolean isSchemaExist(Class<?> clazz) - throws TopiaException { + { checkClosed("isSchemaExist"); boolean result = getSpecificUtil().isTableExists(clazz); @@ -991,7 +987,7 @@ } @Override - public void createSchema() throws TopiaException { + public void createSchema() { try { boolean showSchema = log.isDebugEnabled(); getFiresSupport().firePreCreateSchema(this); @@ -1005,7 +1001,7 @@ } @Override - public void showCreateSchema() throws TopiaException { + public void showCreateSchema() { try { getSpecificUtil().showCreateSchema(); } catch (PersistenceException eee) { @@ -1016,7 +1012,7 @@ } @Override - public void updateSchema() throws TopiaException { + public void updateSchema() { try { boolean showSchema = log.isDebugEnabled(); getFiresSupport().firePreUpdateSchema(this); @@ -1184,7 +1180,7 @@ /* ------------------ IMPORT / EXPORT / REPLICATION ---------------------*/ @Override - public void importXML(Reader xml) throws TopiaException { + public void importXML(Reader xml) { checkClosed("importXML"); Document doc; @@ -1213,7 +1209,7 @@ @Override public void exportXML(Writer xml, Object... entityAndCondition) - throws TopiaException { + { checkClosed("exportXML"); List<String> queries = buildQueries(entityAndCondition); @@ -1251,7 +1247,7 @@ @Override public void replicate(TopiaContext destinationContext, Object... entityAndCondition) - throws TopiaException, IllegalArgumentException { + throws IllegalArgumentException { checkClosed("replicate"); TopiaContextImpl destinationContextImpl = (TopiaContextImpl) destinationContext; @@ -1284,7 +1280,7 @@ @Override public <T extends TopiaEntity> void replicateEntity(TopiaContext destinationContext, T entity) - throws TopiaException, IllegalArgumentException { + throws IllegalArgumentException { checkClosed("replicateEntity"); TopiaContextImpl destinationContextImpl = (TopiaContextImpl) destinationContext; @@ -1299,7 +1295,7 @@ @Override public <T extends TopiaEntity> void replicateEntities(TopiaContext destinationContext, List<T> entities) - throws TopiaException, IllegalArgumentException { + throws IllegalArgumentException { checkClosed("replicateEntities"); TopiaContextImpl destinationContextImpl = (TopiaContextImpl) destinationContext; @@ -1320,13 +1316,13 @@ * * @param entityAndCondition the list of tuples (Class,String) * @return the list of queries. - * @throws TopiaException if any pb of db while getting entities + * @ if any pb of db while getting entities * classes. * @throws IllegalArgumentException if any pb with the given parameter * (mainly ClassCastException). */ protected List<String> buildQueries(Object... entityAndCondition) - throws TopiaException, IllegalArgumentException { + throws IllegalArgumentException { Class<?> entityClass; String condition; @@ -1382,7 +1378,7 @@ protected void replicateOnDestinationContext( TopiaContextImplementor destinationContext, - Object... entities) throws TopiaException { + Object... entities) { try { for (Object entity : entities) { // detach entity from the source session, to make possible copy @@ -1404,17 +1400,17 @@ } @Override - public void backup(File file, boolean compress) throws TopiaException { + public void backup(File file, boolean compress) { new TopiaH2Util(this).backup(file, compress); } @Override - public void restore(File file) throws TopiaException { + public void restore(File file) { new TopiaH2Util(this).restore(file); } @Override - public void clear(boolean dropDatabase) throws TopiaException { + public void clear(boolean dropDatabase) { new TopiaH2Util(this).clear(dropDatabase); } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaPersistenceProvider.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaPersistenceProvider.java 2012-05-29 15:05:59 UTC (rev 2552) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaPersistenceProvider.java 2012-05-29 15:40:37 UTC (rev 2553) @@ -24,7 +24,7 @@ package org.nuiton.topia.framework; import org.apache.commons.lang3.tuple.Pair; -import org.nuiton.topia.TopiaRuntimeException; +import org.nuiton.topia.TopiaException; import javax.persistence.EntityManagerFactory; import javax.persistence.spi.PersistenceProvider; @@ -69,14 +69,14 @@ Set<Class<?>> entityClasses = (Set<Class<?>>) map.get(TOPIA_ENTITIES); if (entityClasses == null) { String message = String.format(MISSING_PROPERTY, TOPIA_ENTITIES); - throw new TopiaRuntimeException(message); + throw new TopiaException(message); } // Get the TopiaContextImplementor TopiaContextImplementor topiaContext = (TopiaContextImplementor)map.get(TOPIA_CONTEXT); if (topiaContext == null) { String message = String.format(MISSING_PROPERTY, TOPIA_CONTEXT); - throw new TopiaRuntimeException(message); + throw new TopiaException(message); } // Delegate creation to the specific JPA implementation Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java 2012-05-29 15:05:59 UTC (rev 2552) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java 2012-05-29 15:40:37 UTC (rev 2553) @@ -26,7 +26,6 @@ import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; -import org.nuiton.topia.TopiaRuntimeException; import java.sql.Connection; import java.sql.PreparedStatement; @@ -88,7 +87,7 @@ findSingleResult(result, set); } catch (Exception e) { - throw new TopiaRuntimeException("Could not execute query", e); + throw new TopiaException("Could not execute query", e); } finally { ps.close(); } @@ -119,7 +118,7 @@ findMultipleResult(result, set); } catch (Exception e) { - throw new TopiaRuntimeException("Could not execute query", e); + throw new TopiaException("Could not execute query", e); } finally { ps.close(); } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java 2012-05-29 15:05:59 UTC (rev 2552) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java 2012-05-29 15:40:37 UTC (rev 2553) @@ -36,7 +36,6 @@ import org.nuiton.eugene.models.object.xml.ObjectModelEnumerationImpl; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; -import org.nuiton.topia.TopiaRuntimeException; import org.nuiton.topia.framework.TopiaContextImplementor; import org.nuiton.topia.persistence.TopiaDAO; import org.nuiton.topia.persistence.TopiaEntity; @@ -46,7 +45,6 @@ import java.lang.reflect.Array; import java.util.Arrays; -import java.util.Collection; import java.util.List; @@ -98,7 +96,7 @@ addImport(entityEnum, TopiaEntity.class); addImport(entityEnum, EntityOperatorStore.class); addImport(entityEnum, Arrays.class); - addImport(entityEnum, TopiaRuntimeException.class); + addImport(entityEnum, TopiaException.class); addImport(entityEnum, ArrayUtils.class); } else { @@ -107,7 +105,7 @@ ObjectModelType.OBJECT_MODEL_ENUMERATION, entityEnumName ); - addImport(daoHelper, TopiaRuntimeException.class); + addImport(daoHelper, TopiaException.class); addImport(daoHelper, TopiaEntityEnum.class); addImport(daoHelper, EntityOperatorStore.class); addImport(daoHelper, Arrays.class); @@ -475,7 +473,7 @@ try { implementation = (Class<? extends TopiaEntity>) Class.forName(implementationFQN); } catch (ClassNotFoundException e) { - throw new TopiaRuntimeException("could not find class " + implementationFQN, e); + throw new TopiaException("could not find class " + implementationFQN, e); } } return implementation; Modified: trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/TopiaHibernateSpecificUtil.java =================================================================== --- trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/TopiaHibernateSpecificUtil.java 2012-05-29 15:05:59 UTC (rev 2552) +++ trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/TopiaHibernateSpecificUtil.java 2012-05-29 15:40:37 UTC (rev 2553) @@ -39,8 +39,6 @@ import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaUpdate; import org.hibernate.tool.hbm2ddl.TableMetadata; -import org.nuiton.topia.TopiaException; -import org.nuiton.topia.TopiaRuntimeException; import org.nuiton.topia.framework.TopiaContextImplementor; import org.nuiton.topia.framework.TopiaSQLWork; import org.nuiton.topia.framework.TopiaSpecificUtil; @@ -154,17 +152,13 @@ @Override public void receiveReplicatedEntity(TopiaContextImplementor context, Object entity) { - try { - EntityManager entityManager = context.getEntityManager(); - if (entityManager instanceof EntityManagerImpl) { - Session session = ((EntityManagerImpl) entityManager).getSession(); - session.replicate(entity, ReplicationMode.EXCEPTION); - } else { - throw new UnsupportedOperationException( - "Cannot find Hibernate session to receive replicated entity"); - } - } catch (TopiaException te) { - throw new TopiaRuntimeException("Unable to receive replicated entity", te); + EntityManager entityManager = context.getEntityManager(); + if (entityManager instanceof EntityManagerImpl) { + Session session = ((EntityManagerImpl) entityManager).getSession(); + session.replicate(entity, ReplicationMode.EXCEPTION); + } else { + throw new UnsupportedOperationException( + "Cannot find Hibernate session to receive replicated entity"); } } @@ -231,17 +225,13 @@ } }; - try { - EntityManager entityManager = context.getEntityManager(); - if (entityManager instanceof EntityManagerImpl) { - Session session = ((EntityManagerImpl) entityManager).getSession(); - session.doWork(hibernateWork); - } else { - throw new UnsupportedOperationException( - "Cannot find Hibernate session to run the SQL work"); - } - } catch (TopiaException te) { - throw new TopiaRuntimeException("Unable to run SQL work", te); + EntityManager entityManager = context.getEntityManager(); + if (entityManager instanceof EntityManagerImpl) { + Session session = ((EntityManagerImpl) entityManager).getSession(); + session.doWork(hibernateWork); + } else { + throw new UnsupportedOperationException( + "Cannot find Hibernate session to run the SQL work"); } } } Modified: trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java =================================================================== --- trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java 2012-05-29 15:05:59 UTC (rev 2552) +++ trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java 2012-05-29 15:40:37 UTC (rev 2553) @@ -31,7 +31,6 @@ import org.hibernate.cfg.Configuration; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; -import org.nuiton.topia.TopiaRuntimeException; import org.nuiton.topia.event.TopiaContextAdapter; import org.nuiton.topia.event.TopiaContextEvent; import org.nuiton.topia.event.TopiaContextListener; @@ -256,7 +255,7 @@ doMigrateSchema(); } catch (MigrationServiceException e) { - throw new TopiaRuntimeException("Can't migrate schema for reason " + e.getMessage(), e); + throw new TopiaException("Can't migrate schema for reason " + e.getMessage(), e); } } else { if (log.isDebugEnabled()) { @@ -279,7 +278,7 @@ if (log.isErrorEnabled()) { log.error(_("topia.migration.migration.incomplete")); } - throw new TopiaRuntimeException(_("topia.migration.migration.incomplete")); + throw new TopiaException(_("topia.migration.migration.incomplete")); } } @@ -429,67 +428,62 @@ log.debug("Detected version = " + dbVersion); } - try { + boolean createTable = !versionTableExist; + // update version even if database has not been migrated + // only case that database doesn't exist match this + if (createTable) { + // si la base n'etait pas versionnee, la table version n'existe pas + // creation + if (log.isDebugEnabled()) { + log.debug("Adding tms_version table"); + } - boolean createTable = !versionTableExist; - // update version even if database has not been migrated - // only case that database doesn't exist match this - if (createTable) { - // si la base n'etait pas versionnee, la table version n'existe pas - // creation - if (log.isDebugEnabled()) { - log.debug("Adding tms_version table"); - } + // creer le schema en base + // dans la configuration versionConfiguration, il n'y a que la table version + TMSVersionDAO.createTable(versionConfiguration); - // creer le schema en base - // dans la configuration versionConfiguration, il n'y a que la table version - TMSVersionDAO.createTable(versionConfiguration); - - if (log.isDebugEnabled()) { - log.debug("Table for " + TMSVersion.class.getSimpleName() + " created"); - } + if (log.isDebugEnabled()) { + log.debug("Table for " + TMSVersion.class.getSimpleName() + " created"); } + } - // Set new version in database - TopiaContext tx = rootContext.beginTransaction(); - try { + // Set new version in database + TopiaContext tx = rootContext.beginTransaction(); + try { - // delete all previous data in table - TMSVersionDAO.deleteAll(tx); + // delete all previous data in table + TMSVersionDAO.deleteAll(tx); - if (log.isInfoEnabled()) { - log.info(_("topia.migration.saving.db.version", version)); - } + if (log.isInfoEnabled()) { + log.info(_("topia.migration.saving.db.version", version)); + } - // create new version and store it in table - TMSVersion tmsVersion = - TMSVersionDAO.create(tx, version.getVersion()); - if (log.isDebugEnabled()) { - log.debug("Created version : " + tmsVersion.getVersion()); - } + // create new version and store it in table + TMSVersion tmsVersion = + TMSVersionDAO.create(tx, version.getVersion()); + if (log.isDebugEnabled()) { + log.debug("Created version : " + tmsVersion.getVersion()); + } - tx.commitTransaction(); - } catch (TopiaException e) { - if (tx != null) { - tx.rollbackTransaction(); - } - throw e; - } finally { - if (tx != null) { - tx.closeContext(); - } + tx.commitTransaction(); + } catch (TopiaException e) { + if (tx != null) { + tx.rollbackTransaction(); } + throw e; + } finally { + if (tx != null) { + tx.closeContext(); + } + } - if (legacyVersionTableExist) { + if (legacyVersionTableExist) { - if (log.isDebugEnabled()) { - log.debug("Will drop legacy tmsVersion table"); - } - // on supprime l'ancienne table - TMSVersionDAO.dropTable(legacyVersionConfiguration); + if (log.isDebugEnabled()) { + log.debug("Will drop legacy tmsVersion table"); } - } catch (TopiaException e) { - throw new TopiaRuntimeException(e); + // on supprime l'ancienne table + TMSVersionDAO.dropTable(legacyVersionConfiguration); } // on change les etats internes du service @@ -592,18 +586,14 @@ // table does not exist, version is null return null; } + TopiaContext tx = rootContext.beginTransaction(); try { - TopiaContext tx = rootContext.beginTransaction(); - try { - Version v = TMSVersionDAO.getVersion(tx, tableName); - return v; - } finally { - if (tx != null) { - tx.closeContext(); - } + Version v = TMSVersionDAO.getVersion(tx, tableName); + return v; + } finally { + if (tx != null) { + tx.closeContext(); } - } catch (TopiaException e) { - throw new TopiaRuntimeException("Can't obtain dbVersion for reason " + e.getMessage(), e); } }
participants (1)
-
athimel@users.nuiton.org