Author: tchemit Date: 2013-07-14 00:05:49 +0200 (Sun, 14 Jul 2013) New Revision: 2765 Url: http://nuiton.org/projects/topia/repository/revisions/2765 Log: fixes #2088: remove i18n from ToPIA Removed: trunk/topia-persistence/src/main/resources/i18n/ trunk/topia-service-migration/src/main/resources/i18n/ trunk/topia-service-replication/src/main/resources/i18n/ Modified: trunk/pom.xml trunk/topia-persistence/pom.xml trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java trunk/topia-service-migration/pom.xml trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/AbstractTopiaMigrationCallback.java trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java trunk/topia-service-replication/pom.xml trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/TopiaReplicationModelBuilder.java trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachLink.java trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/LoadLink.java trunk/topia-service-security/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/pom.xml 2013-07-13 22:05:49 UTC (rev 2765) @@ -62,16 +62,12 @@ <eugeneVersion>2.6.4-SNAPSHOT</eugeneVersion> <nuitonUtilsVersion>2.6.12</nuitonUtilsVersion> <processorPluginVersion>1.3</processorPluginVersion> - <nuitonI18nVersion>2.5.1</nuitonI18nVersion> <xmlrpcVersion>3.1.2</xmlrpcVersion> <hibernateVersion>4.2.2.Final</hibernateVersion> <sl4jVersion>1.7.5</sl4jVersion> <h2Version>1.3.172</h2Version> <hamcrestVersion>1.3</hamcrestVersion> - <!-- i18n configuration --> - <i18n.bundles>fr_FR,en_GB,es_ES</i18n.bundles> - </properties> <!-- ************************************************************* --> @@ -122,12 +118,6 @@ </dependency> <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - <version>${nuitonI18nVersion}</version> - </dependency> - - <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernateVersion}</version> @@ -398,12 +388,6 @@ </plugin> <plugin> - <groupId>org.nuiton.i18n</groupId> - <artifactId>i18n-maven-plugin</artifactId> - <version>${nuitonI18nVersion}</version> - </plugin> - - <plugin> <artifactId>maven-site-plugin</artifactId> <dependencies> <dependency> Modified: trunk/topia-persistence/pom.xml =================================================================== --- trunk/topia-persistence/pom.xml 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-persistence/pom.xml 2013-07-13 22:05:49 UTC (rev 2765) @@ -54,11 +54,6 @@ </dependency> <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - </dependency> - - <dependency> <groupId>org.nuiton.eugene</groupId> <artifactId>eugene</artifactId> </dependency> @@ -188,32 +183,6 @@ <artifactId>processor-maven-plugin</artifactId> </plugin> - <plugin> - <groupId>org.nuiton.i18n</groupId> - <artifactId>i18n-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>parserJava</goal> - <goal>gen</goal> - </goals> - <!-- restrict parsing beacause this is expensive --> - <!-- if you want to parse more, add your package in includes --> - <configuration> - <treateDefaultEntry>false</treateDefaultEntry> - <entries> - <entry> - <basedir>${maven.src.dir}/main/java</basedir> - <includes> - <include>org/nuiton/topia/framework/*.java</include> - </includes> - </entry> - </entries> - </configuration> - </execution> - </executions> - </plugin> - <!-- expose new plexus components --> <plugin> <groupId>org.codehaus.plexus</groupId> 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 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2013-07-13 22:05:49 UTC (rev 2765) @@ -618,7 +618,7 @@ log.debug("Class " + classname + " not found"); } throw new TopiaNotFoundException( - _("topia.persistence.error.class.not.found", + String.format("Persistence class %1$s not found", classname)); } persistenceClasses.add(clazz); @@ -671,12 +671,12 @@ throws TopiaException { if (entityClass == null) { throw new IllegalArgumentException( - _("topia.persistence.error.null.param", + String.format("The method '%1$s' requires a non null parameter '%2$s'.", "entityClass", "getDAO")); } if (equals(getRootContext())) { throw new TopiaException( - _("topia.persistence.error.rootContext.access")); + "You are on root context, you MUST open a transaction to perform any database access."); } if (getHibernateFactory().getClassMetadata(entityClass) == null && getHibernateFactory().getClassMetadata( @@ -684,10 +684,10 @@ getHibernateFactory().getClassMetadata( entityClass.getName() + "Abstract") == null) { - log.info(_("topia.persistence.supported.classes.for.context", + log.info(String.format("List of supported persistence classes: %1$s", getHibernateFactory().getAllClassMetadata().keySet())); throw new TopiaException( - _("topia.persistence.error.unsupported.class", + String.format("The following entity type %1$s is not managed by this context, you probably forgot to declare it.", entityClass.getName())); } @@ -724,7 +724,7 @@ @Override public TopiaContext beginTransaction() throws TopiaException { - checkClosed(_("topia.persistence.error.context.is.closed")); + checkClosed("Context is closed, no operation is possible."); TopiaContextImpl result = new TopiaContextImpl(this); SessionFactory factory = getHibernateFactory(); @@ -758,7 +758,7 @@ } throw new TopiaException( - _("topia.persistence.error.open.transaction.failed", + String.format("An error occurs while asking a new transaction: %1$s", eee.getMessage()), eee); } @@ -774,10 +774,10 @@ @Override public void commitTransaction() throws TopiaException { if (equals(getRootContext())) { - throw new TopiaException(_("topia.persistence.error.unsupported.operation.on.root.context", + throw new TopiaException(String.format("Unsupported operation %s on root context", "commit")); } - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "commit")); try { @@ -804,7 +804,7 @@ // hibernate = getHibernateFactory().openSession(); // hibernate.setFlushMode(FlushMode.NEVER); } catch (Exception eee) { - throw new TopiaException(_("topia.persistence.error.on.commit", + throw new TopiaException(String.format("An error occurs while commit operation: %1$s", eee.getMessage()), eee); } } @@ -812,10 +812,10 @@ @Override public void rollbackTransaction() throws TopiaException { if (equals(getRootContext())) { - throw new TopiaException(_("topia.persistence.error.unsupported.operation.on.root.context", + throw new TopiaException(String.format("Unsupported operation %s on root context", "rollback")); } - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "rollback")); try { // for (TopiaDAO<? extends TopiaEntity> dao : daoCache.values()) { @@ -842,7 +842,7 @@ } catch (HibernateException eee) { throw new TopiaException( - _("topia.persistence.error.on.rollback", + String.format("An error occurs while rollback operation: %1$s", eee.getMessage()), eee); } } @@ -850,7 +850,7 @@ @Override public void closeContext() throws TopiaException { // Throw exception if context is already closed - checkClosed(_("topia.persistence.error.context.already.closed")); + checkClosed("Context was already closed"); // FD-20100421 : Ano #546 : no need to copy childContext, the // {@link #getChildContext()} provides a thread-safe copy to iterate @@ -926,7 +926,7 @@ @Override public <E extends TopiaEntity> E findByTopiaId(String id) throws TopiaException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "findById")); Class<E> entityClass = getTopiaIdFactory().getClassName(id); @@ -937,7 +937,7 @@ @Override public <E> List<E> findAll(String hql, Object... args) throws TopiaException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "findAll")); try { @@ -961,7 +961,7 @@ result = firesSupport.fireEntitiesLoad(this, result); return result; } catch (HibernateException eee) { - throw new TopiaException(_("topia.persistence.error.on.query", + throw new TopiaException(String.format("An error occurs while query operation: %1$s : %2$s", hql, eee.getMessage()), eee); } } @@ -969,7 +969,7 @@ @Override public <E> List<E> find(String hql, int startIndex, int endIndex, Object... args) throws TopiaException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "find")); try { @@ -995,7 +995,7 @@ result = firesSupport.fireEntitiesLoad(this, result); return result; } catch (HibernateException eee) { - throw new TopiaException(_("topia.persistence.error.on.query", + throw new TopiaException(String.format("An error occurs while query operation: %1$s : %2$s", hql, eee.getMessage()), eee); } } @@ -1003,7 +1003,7 @@ @Override public <E> E findUnique(String hql, Object... paramNamesAndValues) throws TopiaException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "findUnique")); List<E> results = find(hql, 0, 1, paramNamesAndValues); @@ -1033,7 +1033,7 @@ */ @Override public int execute(String hql, Object... args) throws TopiaException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "find")); try { @@ -1044,14 +1044,14 @@ int result = query.executeUpdate(); return result; } catch (HibernateException eee) { - throw new TopiaException(_("topia.persistence.error.on.query", + throw new TopiaException(String.format("An error occurs while query operation: %1$s : %2$s", hql, eee.getMessage()), eee); } } @Override public void add(TopiaEntity e) throws TopiaException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "add")); String id = e.getTopiaId(); @@ -1063,17 +1063,16 @@ @Override public void replicate(TopiaContext dstCtxt, Object... entityAndCondition) throws TopiaException, IllegalArgumentException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "replicate")); TopiaContextImpl dstContextImpl = (TopiaContextImpl) dstCtxt; dstContextImpl.checkClosed( - _("topia.persistence.error.unsupported.operation.on.closed.context", + String.format("This context is closed, it is not possible to release the operation '%1$s'", "replicate")); if (getRootContext().equals(dstContextImpl.getRootContext())) { - throw new IllegalArgumentException( - _("topia.persistence.error.replicate.on.same.context")); + throw new IllegalArgumentException("Can not do a replication operation on same database."); } String[] queries = buildQueries(entityAndCondition); @@ -1091,7 +1090,7 @@ } } } catch (HibernateException eee) { - throw new TopiaException(_("topia.persistence.error.on.replicate", + throw new TopiaException(String.format("An error occurs while a replication operation: %s", eee.getMessage()), eee); } } @@ -1100,16 +1099,15 @@ public <T extends TopiaEntity> void replicateEntity(TopiaContext dstCtxt, T entity) throws TopiaException, IllegalArgumentException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "replicateEntity")); TopiaContextImpl dstContextImpl = (TopiaContextImpl) dstCtxt; - dstContextImpl.checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + dstContextImpl.checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "replicateEntity")); if (getRootContext().equals(dstContextImpl.getRootContext())) { - throw new IllegalArgumentException(_( - "topia.persistence.error.replicate.on.same.context")); + throw new IllegalArgumentException("Can not do a replication operation on same database."); } replicate0(dstContextImpl, entity); } @@ -1118,15 +1116,15 @@ public <T extends TopiaEntity> void replicateEntities(TopiaContext dstCtxt, List<T> entities) throws TopiaException, IllegalArgumentException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "replicateEntities")); TopiaContextImpl dstContextImpl = (TopiaContextImpl) dstCtxt; - dstContextImpl.checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + dstContextImpl.checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "replicateEntities")); if (getRootContext().equals(dstContextImpl.getRootContext())) { - throw new IllegalArgumentException(_("topia.persistence.error.replicate.on.same.context")); + throw new IllegalArgumentException("Can not do a replication operation on same database."); } replicate0(dstContextImpl, entities.toArray()); } @@ -1147,7 +1145,7 @@ */ @Override public void backup(File file, boolean compress) throws TopiaException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "backup")); try { String options = ""; @@ -1160,8 +1158,8 @@ query.list(); } catch (Exception eee) { - throw new TopiaException(_( - "topia.persistence.error.on.backup", + throw new TopiaException(String.format( + "An error occurs while backup operation: %1$s", eee.getMessage()), eee); } } @@ -1177,7 +1175,7 @@ public void restore(File file) throws TopiaException { // send event getFiresSupport().firePreRestoreSchema(this); - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "restore")); String sql = null; @@ -1210,8 +1208,8 @@ // send event AFTER restore getFiresSupport().firePostRestoreSchema(this); } catch (Exception eee) { - throw new TopiaException(_( - "topia.persistence.error.on.restore", + throw new TopiaException(String.format( + "An error occurs while restore operation: %1$s", sql, eee.getMessage()), eee); } } @@ -1237,7 +1235,7 @@ root.finalize(); } catch (Throwable eee) { throw new TopiaException( - _("topia.persistence.error.on.clear", eee.getMessage()), eee); + String.format("Error %s on clear operation", eee.getMessage()), eee); } } @@ -1259,7 +1257,7 @@ @Override public boolean isSchemaExist(Class<?> clazz) throws TopiaException { - checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context", + checkClosed(String.format("This context is closed, it is not possible to release the operation '%1$s'", "replicateEntity")); boolean result = TopiaUtil.isSchemaExist(this, clazz.getName()); return result; @@ -1452,7 +1450,7 @@ } } catch (HibernateException eee) { - throw new TopiaException(_("topia.persistence.error.on.replicate", + throw new TopiaException(String.format("An error occurs while a replication operation : %s", eee.getMessage()), eee); } } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2013-07-13 22:05:49 UTC (rev 2765) @@ -25,7 +25,7 @@ package org.nuiton.topia.persistence.util; -import com.google.common.base.Function; +import com.google.common.base.Preconditions; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.TopiaContext; @@ -57,8 +57,6 @@ import java.util.SortedMap; import java.util.TreeMap; -import static org.nuiton.i18n.I18n._; - /** * Une classe avec des méthodes utiles sur les entités. * @@ -109,10 +107,8 @@ TopiaDAO<E> dao, String topiaId) throws TopiaException, IllegalArgumentException { E entity = dao.findByTopiaId(topiaId); - if (entity == null) { - throw new IllegalArgumentException( - "could not find entity with topiaId " + topiaId); - } + Preconditions.checkArgument(entity != null, + "could not find entity with topiaId " + topiaId); return entity; } @@ -150,14 +146,9 @@ public static <E extends TopiaEntity> void checkNotNullAndExistingEntity( String paramName, E bean) throws IllegalStateException, NullPointerException { - if (bean == null) { - throw new NullPointerException(paramName + " can not be null"); - } - if (bean.getTopiaId() == null) { - // can not create bean here - throw new IllegalStateException( - "can not create " + bean.getClass() + " here..."); - } + Preconditions.checkNotNull(bean, paramName + " can not be null"); + Preconditions.checkState(bean.getTopiaId() != null, + "can not create " + bean.getClass() + " here..."); } /** @@ -172,14 +163,9 @@ public static <E extends TopiaEntity> void checkNotNullAndNoneExistingEntity( String paramName, E bean) throws NullPointerException, IllegalStateException { - if (bean == null) { - throw new NullPointerException(paramName + " can not be null"); - } - if (bean.getTopiaId() != null) { - // can not create bean here - throw new IllegalStateException( - "can not update " + bean.getClass() + " here..."); - } + Preconditions.checkNotNull(bean, paramName + " can not be null"); + Preconditions.checkState(bean.getTopiaId() == null, + "can not update " + bean.getClass() + " here..."); } /** @@ -197,15 +183,9 @@ TopiaContext topiaContext, URI resource) throws IOException, TopiaException, NullPointerException { - if (dbDirectory == null) { - throw new NullPointerException("dbDirectory can not be null"); - } - if (topiaContext == null) { - throw new NullPointerException("topiaContext can not be null"); - } - if (resource == null) { - throw new NullPointerException("resource can not be null"); - } + Preconditions.checkNotNull(dbDirectory, dbDirectory + " can not be null"); + Preconditions.checkNotNull(topiaContext, topiaContext + " can not be null"); + Preconditions.checkNotNull(resource, resource + " can not be null"); File databaseDump; if (resource.isOpaque()) { @@ -265,12 +245,9 @@ public static void saveDB( File gzipFile, TopiaContext topiaContext) throws TopiaException, IOException, NullPointerException { - if (gzipFile == null) { - throw new NullPointerException("gzipFile can not be null"); - } - if (topiaContext == null) { - throw new NullPointerException("topiaContext can not be null"); - } + Preconditions.checkNotNull(gzipFile, gzipFile + " can not be null"); + Preconditions.checkNotNull(topiaContext, topiaContext + " can not be null"); + if (!gzipFile.getParentFile().exists()) { if (!gzipFile.getParentFile().mkdirs()) { throw new IOException("could not create directory " + @@ -674,7 +651,9 @@ List<String> ids = Arrays.asList(expressions); /** le dictionnaire des références détectées indexées par leur type */ - SortedMap<TopiaEntity, List<TopiaEntityRef>> refs;{ + SortedMap<TopiaEntity, List<TopiaEntityRef>> refs; + + { refs = new TreeMap<TopiaEntity, List<TopiaEntityRef>>( getTopiaIdComparator()); } @@ -1145,11 +1124,8 @@ public static void checkNotNull(String methodName, String parameterName, Object value) { - if (value == null) { - throw new NullPointerException( - _("topia.persistence.error.null.param", - methodName, parameterName)); - } + Preconditions.checkNotNull(value, + String.format("The method '%1$s' requires a non null parameter '%2$s'.", methodName, parameterName)); } public static void checkParameters(Class<?>[] paramsType, @@ -1161,10 +1137,7 @@ } public static void checkSize(int size, Object[] params) { - if (params.length != size) { - throw new IllegalArgumentException( - _("topia.persistence.error.invalid.size", size, params.length)); - } + Preconditions.checkArgument(params.length == size, String.format("Invalid parameters size. Expected:%d but was:%d", size, params.length)); } public static void checkType(Class<?>[] paramsType, @@ -1172,17 +1145,11 @@ Object[] params) { Class<?> requiredType = paramsType[index]; Object value = params[index]; - if (value == null) { - throw new IllegalArgumentException( - _("topia.persistence.error.null.param.in.array", index)); - } - Class<?> foundType = value.getClass(); + Preconditions.checkArgument(value != null, String.format("The parameter at index %d must not be null", index)); - if (!requiredType.isAssignableFrom(foundType)) { - throw new IllegalArgumentException( - _("topia.persistence.error.invalid.type.in.array", - index, requiredType, foundType)); - } + Class<?> foundType = value.getClass(); + Preconditions.checkArgument(requiredType.isAssignableFrom(foundType), String.format("The parameter at index %d is not the expected type. Expected:%s but was:%s", + index, requiredType, foundType)); } /** Modified: trunk/topia-service-migration/pom.xml =================================================================== --- trunk/topia-service-migration/pom.xml 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-service-migration/pom.xml 2013-07-13 22:05:49 UTC (rev 2765) @@ -65,11 +65,6 @@ </dependency> <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - </dependency> - - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> @@ -129,19 +124,6 @@ <plugins> - <plugin> - <groupId>org.nuiton.i18n</groupId> - <artifactId>i18n-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>parserJava</goal> - <goal>gen</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> </build> </project> Modified: trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/AbstractTopiaMigrationCallback.java =================================================================== --- trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/AbstractTopiaMigrationCallback.java 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/AbstractTopiaMigrationCallback.java 2013-07-13 22:05:49 UTC (rev 2765) @@ -38,8 +38,6 @@ import java.sql.SQLException; import java.util.List; -import static org.nuiton.i18n.I18n._; - /** * Abstract migration callback. * @@ -115,7 +113,7 @@ try { - log.info(_("topia.migration.start.migrate", v)); + log.info(String.format("Start migration to version %s", v)); migrateForVersion(v, tx, showSql, showProgression); @@ -124,7 +122,7 @@ } catch (Exception eee) { // en cas d'erreur - log.error("Migration impossible de la base", eee); + log.error("Could not migrate database", eee); // rollback du travail en cours tx.rollbackTransaction(); // propagation de l'erreur @@ -168,7 +166,7 @@ if (log.isInfoEnabled()) { - log.info(_("topia.migration.start.sqls", sqls.length)); + log.info(String.format("Will execute %1$s requests...", sqls.length)); } if (showSql) { StringBuilder buffer = new StringBuilder(); @@ -196,7 +194,7 @@ String message = ""; if (showProgression) { - message = _("topia.migration.start.sql", index, max); + message = String.format("Executing request [%1$-4s/%2$-4s]", index, max); } if (showSql) { message += "\n" + sql; @@ -214,7 +212,7 @@ } if (log.isDebugEnabled()) { String message; - message = _("topia.migration.end.sql", index, max, StringUtil.convertTime(System.nanoTime() - t0)); + message = String.format("Request [%1$-4s/%2$-4s] executed in %3$s.", index, max, StringUtil.convertTime(System.nanoTime() - t0)); log.debug(message); } } 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 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java 2013-07-13 22:05:49 UTC (rev 2765) @@ -25,6 +25,7 @@ package org.nuiton.topia.migration; +import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -51,8 +52,6 @@ import java.util.SortedSet; import java.util.TreeSet; -import static org.nuiton.i18n.I18n._; - /** * Le moteur de migration proposé par topia. Il est basé sur un {@link AbstractTopiaMigrationCallback} * qui donne la version de l'application, les version de mises à jour disponibles. @@ -278,9 +277,9 @@ boolean complete = migrateSchema(); if (!complete) { if (log.isErrorEnabled()) { - log.error(_("topia.migration.migration.incomplete")); + log.error("Database migration not succesfully ended!"); } - throw new TopiaException(_("topia.migration.migration.incomplete")); + throw new TopiaException("Database migration not succesfully ended!"); } } @@ -297,9 +296,9 @@ Version version = callback.getApplicationVersion(); - log.info(_("topia.migration.start.migration", - version.getVersion(), - dbVersion.getVersion()) + log.info(String.format("Starting Topia Migration Service - Application version \\: %1$s, Database version \\: %2$s", + version.getVersion(), + dbVersion.getVersion()) ); if (log.isDebugEnabled()) { @@ -317,7 +316,7 @@ if (versionTableExist && dbVersion.equals(version)) { if (log.isInfoEnabled()) { - log.info(_("topia.migration.skip.migration.db.is.up.to.date")); + log.info("Database is up to date, no migration needed."); } // la base est a jour return true; @@ -325,7 +324,7 @@ // Aucune version existante, la base de données est vierge if (versionTableExist && dbNotVersioned && migrateOnInit) { - log.info(_("topia.migration.skip.migration.db.is.empty")); + log.info("Database is empty, no migration needed."); // la base est vierge, aucune migration nécessaire // mise à jour de la table tmsversion saveApplicationVersion(); @@ -337,7 +336,7 @@ // on a trouvee une table depreciee tmsVersion avec la bonne version de base // il suffit donc d'enregister la version dans la nouvelle table if (log.isInfoEnabled()) { - log.info(_("topia.migration.skip.migration.db.is.up.to.date")); + log.info("Database is up to date, no migration needed."); } // la base est a jour mais il faut migrer la table saveApplicationVersion(); @@ -348,7 +347,7 @@ new TreeSet<Version>(new VersionComparator()); allVersions.addAll(Arrays.asList(callback.getAvailableVersions())); if (log.isInfoEnabled()) { - log.info(_("topia.migration.available.versions", allVersions)); + log.info(String.format("Available versions: %1$s", allVersions)); } // tell if migration is needed @@ -367,11 +366,11 @@ if (versionsToApply.isEmpty()) { if (log.isInfoEnabled()) { - log.info(_("topia.migration.skip.migration.no.version.to.apply")); + log.info("No version to apply, no migration needed."); } } else { if (log.isInfoEnabled()) { - log.info(_("topia.migration.migrate.versions", versionsToApply)); + log.info(String.format("Versions to apply: %1$s", versionsToApply)); } // perform the migration @@ -457,14 +456,14 @@ TMSVersionDAO.deleteAll(tx); if (log.isInfoEnabled()) { - log.info(_("topia.migration.saving.db.version", version)); + log.info(String.format("Saving new database version: %1$s", 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()); + log.debug("Created version: " + tmsVersion.getVersion()); } tx.commitTransaction(); @@ -572,7 +571,7 @@ if (v != null) { if (log.isDebugEnabled()) { - log.debug("Legacy : " + _("topia.migration.detected.db.version", v)); + log.debug(String.format("Legacy : detected database version: %1$s", v)); } } } @@ -585,9 +584,9 @@ // etre detenu en local v = Version.VZERO; dbNotVersioned = true; - log.info(_("topia.migration.db.not.versionned")); + log.info("Database version not found, so database schema is considered as V0"); } else { - log.info(_("topia.migration.detected.db.version", v)); + log.info(String.format("detected database version: %1$s", v)); } dbVersion = v; versionDetected = true; @@ -642,16 +641,12 @@ protected String getSafeParameter(Properties config, String key) { String value = config.getProperty(key, null); - if (StringUtils.isEmpty(value)) { - throw new IllegalStateException("'" + key + "' not set."); - } + Preconditions.checkState(StringUtils.isNotEmpty(value), "'" + key + "' not set."); return value; } protected void checkInit() { - if (!init) { - throw new IllegalStateException("le service n'est pas initialisé!"); - } + Preconditions.checkState(init, "Service was not initialized!"); } /** Modified: trunk/topia-service-replication/pom.xml =================================================================== --- trunk/topia-service-replication/pom.xml 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-service-replication/pom.xml 2013-07-13 22:05:49 UTC (rev 2765) @@ -60,11 +60,6 @@ </dependency> <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - </dependency> - - <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> </dependency> @@ -118,18 +113,6 @@ <build> <plugins> - <plugin> - <groupId>org.nuiton.i18n</groupId> - <artifactId>i18n-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>parserJava</goal> - <goal>gen</goal> - </goals> - </execution> - </executions> - </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> @@ -207,7 +190,7 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> - <version>2.4</version> + <version>${coberturaPluginVersion}</version> </plugin> </plugins> </reporting> Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/TopiaReplicationModelBuilder.java =================================================================== --- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/TopiaReplicationModelBuilder.java 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/TopiaReplicationModelBuilder.java 2013-07-13 22:05:49 UTC (rev 2765) @@ -38,8 +38,6 @@ import java.util.Arrays; import java.util.Set; -import static org.nuiton.i18n.I18n._; - /** * Builder of {@link ReplicationModel}. * @@ -128,7 +126,7 @@ if (operation == null) { throw new IllegalArgumentException( - _("topia.replication.error.unkown.operation", + String.format("The operation %1$s is unknown, known operations are: %2$s", operationClass.getSimpleName(), Arrays.toString(getOperationProvider().getOperations())) ); @@ -137,7 +135,7 @@ ReplicationNode node = model.getNode(type); if (node == null) { throw new IllegalArgumentException( - _("topia.replication.error.unkown.owner.node", + String.format("The target node (of type %1$s) for operation %2$s is unknown, known nodes are: %3$s", type, operationClass.getSimpleName(), model.getNodes()) Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachLink.java =================================================================== --- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachLink.java 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachLink.java 2013-07-13 22:05:49 UTC (rev 2765) @@ -44,8 +44,6 @@ import java.util.Collections; import java.util.List; -import static org.nuiton.i18n.I18n._; - /** * Pour attacher une association. * <p/> @@ -132,8 +130,7 @@ if (ownerIds == null || ownerIds.isEmpty()) { // pas de donnees a traiter - log.info(_("topia.replication.attachAssociation.nothing.to.do", - ownerOperator)); + log.info("Nothing to attach..."); return; } Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/LoadLink.java =================================================================== --- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/LoadLink.java 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/LoadLink.java 2013-07-13 22:05:49 UTC (rev 2765) @@ -41,8 +41,6 @@ import java.util.List; -import static org.nuiton.i18n.I18n._; - /** * Pour charger une association sur le noeud de l'operation. * <p/> @@ -84,8 +82,8 @@ if (!ownerNode.equals(operationDef.getNode())) { throw new IllegalStateException( - _("topia.replication.error.operation.loadLink.illegalSource", - operationDef.getNode(), ownerNode)); + String.format("The source node of loading association requires the node %1$s, but was %2$s.", + operationDef.getNode(), ownerNode)); } if (log.isDebugEnabled()) { Modified: trunk/topia-service-security/pom.xml =================================================================== --- trunk/topia-service-security/pom.xml 2013-07-13 21:18:30 UTC (rev 2764) +++ trunk/topia-service-security/pom.xml 2013-07-13 22:05:49 UTC (rev 2765) @@ -63,11 +63,6 @@ </dependency> <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - </dependency> - - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency>