Author: tchemit Date: 2011-11-04 11:09:27 +0100 (Fri, 04 Nov 2011) New Revision: 8 Url: http://forge.codelutin.com/repositories/revision/echobase/8 Log: using Arnaud and Brendan api + add entity ExportQuery in model Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTechnicalException.java trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java trunk/echobase-entities/src/test/resources/echobase.properties trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java Removed: trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationHelper.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSessionAware.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseTransactionActionSupport.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseSessionInterceptor.java Modified: trunk/LICENSE.txt trunk/README.txt trunk/changelog.txt trunk/echobase-entities/LICENSE.txt trunk/echobase-entities/README.txt trunk/echobase-entities/changelog.txt trunk/echobase-entities/pom.xml trunk/echobase-entities/src/license/THIRD-PARTY.properties trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties trunk/echobase-entities/src/main/xmi/echobase.properties trunk/echobase-entities/src/main/xmi/echobase.zargo trunk/echobase-entities/src/test/resources/log4j.properties trunk/echobase-services/LICENSE.txt trunk/echobase-services/README.txt trunk/echobase-services/changelog.txt trunk/echobase-services/pom.xml trunk/echobase-services/src/license/THIRD-PARTY.properties trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInitializable.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInjectable.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSingleton.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/IOCService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/AbstractInjector.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectDAO.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntitiesById.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntityById.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectFromDAO.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/Injector.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorDAO.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntitiesById.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntityById.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorFromDAO.java trunk/echobase-services/src/main/resources/META-INF/services/fr.ifremer.echobase.services.ioc.Injector trunk/echobase-services/src/main/resources/echobase-config trunk/echobase-services/src/main/resources/echobase-db-h2.properties trunk/echobase-services/src/main/resources/echobase-db.properties trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties trunk/echobase-services/src/test/resources/log4j.properties trunk/echobase-ui/LICENSE.txt trunk/echobase-ui/README.txt trunk/echobase-ui/changelog.txt trunk/echobase-ui/pom.xml trunk/echobase-ui/src/license/THIRD-PARTY.properties trunk/echobase-ui/src/main/env/dev/resources/log4j.properties trunk/echobase-ui/src/main/env/dev/resources/struts.properties trunk/echobase-ui/src/main/env/prod/resources/log4j.properties trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/HomeAction.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/AbstractCheckInterceptor.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckUserIsAdmin.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CleanEchoBaseSessionInterceptor.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java trunk/echobase-ui/src/main/resources/config/struts-user.xml trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties trunk/echobase-ui/src/main/resources/struts.xml trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/includes/i18n.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportProgress.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/login.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml trunk/echobase-ui/src/main/webapp/css/screen.css trunk/echobase-ui/src/main/webapp/images/exclamation.png trunk/echobase-ui/src/main/webapp/images/logo_codelutin.png trunk/echobase-ui/src/main/webapp/images/true.png trunk/echobase-ui/src/main/webapp/index.jsp trunk/echobase-ui/src/main/webapp/js/gridHelper.js trunk/echobase-ui/src/site/rst/index.rst trunk/echobase-ui/src/site/site_fr.xml trunk/echobase-ui/web/WEB-INF/web.xml trunk/pom.xml trunk/src/doc/reunions/reunion-2011-11-03.txt trunk/src/site/rst/Todo.rst trunk/src/site/rst/index.rst trunk/src/site/site_fr.xml Property changes on: trunk/LICENSE.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/README.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/changelog.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-entities/LICENSE.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-entities/README.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-entities/changelog.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-entities/pom.xml =================================================================== --- trunk/echobase-entities/pom.xml 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-entities/pom.xml 2011-11-04 10:09:27 UTC (rev 8) @@ -54,12 +54,12 @@ <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> - </dependency> + </dependency--> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> - </dependency--> + </dependency> <!-- ToPIA dependencies --> Property changes on: trunk/echobase-entities/pom.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-entities/src/license/THIRD-PARTY.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Copied: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java (from rev 5, trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java) =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java (rev 0) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,128 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase; + +import com.google.common.base.Preconditions; +import org.apache.commons.lang.builder.ReflectionToStringBuilder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.ArgumentsParserException; +import org.nuiton.util.FileUtil; +import org.nuiton.util.Version; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.Properties; + +/** + * EchoBase configuration + * + * @author chemit <chemit@codelutin.com> + * @since 1.0 + */ +public class EchoBaseConfiguration { + + /** Logger. */ + protected static final Log log = LogFactory.getLog(EchoBaseConfiguration.class); + + /** Delegate application config object containing all the configuration. */ + protected ApplicationConfig applicationConfig; + + public EchoBaseConfiguration() { + applicationConfig = new ApplicationConfig(); + applicationConfig.setConfigFileName("echobase.properties"); + + if (log.isInfoEnabled()) { + log.info(this + " is initializing..."); + } + try { + applicationConfig.loadDefaultOptions(EchoBaseConfigurationOption.class); + applicationConfig.parse(); + } catch (ArgumentsParserException e) { + throw new EchoBaseTechnicalException( + "Could not parse configuration", e); + } + + createDirectory(EchoBaseConfigurationOption.DATA_DIRECTORY); + + if (log.isDebugEnabled()) { + log.debug("parsed options in config file" + applicationConfig.getOptions()); + } + } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } + + public Properties getProperties() { + Properties result = applicationConfig.getFlatOptions(); + return result; + } + + public File getDataDirectory() { + File v = applicationConfig.getOptionAsFile(EchoBaseConfigurationOption.DATA_DIRECTORY.key); + return v; + } + + public Version getApplicationVersion() { + Version v = applicationConfig.getOptionAsVersion(EchoBaseConfigurationOption.VERSION.key); + return v; + } + + public URL getApplicationSite() { + URL url = applicationConfig.getOptionAsURL(EchoBaseConfigurationOption.SITE_URL.key); + return url; + } + + /** + * Creates a directory given the configuration given key. + * + * @param key the configuration option key which contains the location of + * the directory to create + */ + protected void createDirectory(EchoBaseConfigurationOption key) { + + File directory = applicationConfig.getOptionAsFile(key.getKey()); + + Preconditions.checkNotNull( + directory, + "Could not find directory " + directory + " (key " + + key + + "in your configuration file named echobase.properties)" + ); + if (log.isInfoEnabled()) { + log.info(key + " = " + directory); + } + try { + FileUtil.createDirectoryIfNecessary(directory); + } catch (IOException e) { + throw new EchoBaseTechnicalException( + "Could not create directory " + directory, e); + } + } + +} Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java (rev 0) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,127 @@ +/* + * #%L + * EchoBase :: Entities + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase; + +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.Version; + +import java.io.File; +import java.net.URL; + +import static org.nuiton.i18n.I18n.n_; + +/** + * All EchoBase configuration options. + * + * @since 1.0 + */ +public enum EchoBaseConfigurationOption implements ApplicationConfig.OptionDef { + + /** Main directory where to put echobase data (logs, and others...). */ + DATA_DIRECTORY( + "data.directory", + n_("echobase.config.data.directory.description"), + "/var/local/echobase", + File.class), + + PASSWORD_DIGEST_ALGORITHM( + "password.digest.algorithm", + "Algorithme de hashage à utiliser pour les mot de passe", + "SHA1", String.class), + VERSION( + "project.version", + "Version de l'application", + "", Version.class), + SITE_URL( + "project.siteUrl", + "URL du site de l'application", + "", URL.class); + + /** Configuration key. */ + protected final String key; + + /** I18n key of option description */ + protected final String description; + + /** Type of option */ + protected final Class<?> type; + + /** Default value of option. */ + protected String defaultValue; + + EchoBaseConfigurationOption(String key, + String description, + String defaultValue, + Class<?> type) { + this.key = key; + this.description = description; + this.defaultValue = defaultValue; + this.type = type; + } + + @Override + public String getKey() { + return key; + } + + @Override + public Class<?> getType() { + return type; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public String getDefaultValue() { + return defaultValue; + } + + @Override + public boolean isTransient() { + return true; + } + + @Override + public boolean isFinal() { + return true; + } + + @Override + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + @Override + public void setTransient(boolean newValue) { + // not used + } + + @Override + public void setFinal(boolean newValue) { + // not used + } +} Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTechnicalException.java =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTechnicalException.java (rev 0) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTechnicalException.java 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,44 @@ +/* + * #%L + * EchoBase :: Entities + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase; + +public class EchoBaseTechnicalException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public EchoBaseTechnicalException() { + } + + public EchoBaseTechnicalException(String message) { + super(message); + } + + public EchoBaseTechnicalException(String message, Throwable cause) { + super(message, cause); + } + + public EchoBaseTechnicalException(Throwable cause) { + super(cause); + } +} Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTechnicalException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java (rev 0) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,133 @@ +/* + * #%L + * Extranet NF-Logement :: Entities + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Cerqual + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase; + +import com.google.common.base.Supplier; +import com.google.common.collect.Sets; +import com.google.common.io.Closeables; +import fr.ifremer.echobase.entities.EchoBaseDAOHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.hibernate.cfg.Environment; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaContextFactory; +import org.nuiton.topia.TopiaNotFoundException; +import org.nuiton.topia.TopiaRuntimeException; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import java.util.Set; + +public class EchoBaseTopiaRootContextSupplierFactory { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(EchoBaseTopiaRootContextSupplierFactory.class); + + protected static class EchoBaseTopiaRootContextSupplier implements Supplier<TopiaContext> { + + protected TopiaContext rootContext; + + public EchoBaseTopiaRootContextSupplier(TopiaContext rootContext) { + this.rootContext = rootContext; + } + + @Override + public TopiaContext get() { + return rootContext; + } + } + + public Supplier<TopiaContext> newEmbeddedDatabase(File dir) { + + File databaseFile = new File(dir, "h2-db"); + + String databaseAbsolutePath = databaseFile.getAbsolutePath(); + + // prepare call to topia-context factory + Properties properties = new Properties(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/topia-h2.properties"); + properties.load(input); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + Closeables.closeQuietly(input); + } + properties.setProperty(Environment.URL, + "jdbc:h2:file:" + databaseAbsolutePath); + + // add entities to the context + properties.setProperty( + TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES, + EchoBaseDAOHelper.getImplementationClassesAsString()); + + TopiaContext rootContext; + try { + rootContext = TopiaContextFactory.getContext(properties); + } catch (TopiaNotFoundException e) { + throw new TopiaRuntimeException(e); + } + + if (log.isDebugEnabled()) { + log.debug("will output database in " + databaseAbsolutePath); + } + + return new EchoBaseTopiaRootContextSupplier(rootContext); + } + + public Supplier<TopiaContext> newDatabaseFromConfig(EchoBaseConfiguration config) { + + Properties properties = config.getProperties(); + + if (log.isDebugEnabled()) { + log.debug("Database settings are :"); + Set<String> keysToDisplay = Sets.newHashSet( + "hibernate.dialect", + "hibernate.connection.driver_class", + "hibernate.connection.url", + "hibernate.connection.username"); + for (String key : keysToDisplay) { + log.debug(String.format("%s=%s", key, properties.getProperty(key))); + } + } + + // add entities to the context + String classesKey = TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES; + String classesValue = EchoBaseDAOHelper.getImplementationClassesAsString(); + properties.setProperty(classesKey, classesValue); + + TopiaContext rootContext; + try { + rootContext = TopiaContextFactory.getContext(properties); + } catch (TopiaNotFoundException e) { + throw new TopiaRuntimeException(e); + } + + return new EchoBaseTopiaRootContextSupplier(rootContext); + } +} Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties =================================================================== --- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-04 10:09:27 UTC (rev 8) @@ -1,4 +1,16 @@ echobase.common.admin= +echobase.common.description= echobase.common.echoBaseUser= +echobase.common.email= +echobase.common.exportQuery= +echobase.common.lastModifiedDate= +echobase.common.lastModifiedUser= echobase.common.login= +echobase.common.name= echobase.common.password= +echobase.common.sqlQuery= +echobase.config.data.directory.description= +echobase.config.internal.db.directory.description= +echobase.config.parameterProfiles.storage.directory.description= +echobase.config.treatment.working.directory.description= +echobase.user.log.directory.description= Property changes on: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-entities/src/main/xmi/echobase.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo =================================================================== (Binary files differ) Property changes on: trunk/echobase-entities/src/main/xmi/echobase.zargo ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/echobase-entities/src/test/resources/echobase.properties =================================================================== --- trunk/echobase-entities/src/test/resources/echobase.properties (rev 0) +++ trunk/echobase-entities/src/test/resources/echobase.properties 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,31 @@ +### +# #%L +# EchoBase :: Entities +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2011 Ifremer, Codelutin +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# #L% +### +hibernate.hbm2ddl.auto=update +hibernate.show_sql=false +hibernate.dialect=org.hibernate.dialect.H2Dialect + +hibernate.connection.driver_class=org.h2.Driver +hibernate.connection.url=jdbc:h2:file:${data.directory}/echobase/h2data +hibernate.connection.username=sa +hibernate.connection.password=sa Property changes on: trunk/echobase-entities/src/test/resources/echobase.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-entities/src/test/resources/log4j.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/LICENSE.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/README.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/changelog.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/pom.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/license/THIRD-PARTY.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-04 10:09:27 UTC (rev 8) @@ -1,218 +0,0 @@ -/* - * #%L - * EchoBase :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase; - -import com.google.common.base.Preconditions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.ApplicationConfig; -import org.nuiton.util.ArgumentsParserException; -import org.nuiton.util.FileUtil; - -import java.io.File; -import java.io.IOException; - -import static org.nuiton.i18n.I18n.n_; - -/** - * EchoBase configuration - * - * @author chemit <chemit@codelutin.com> - * @since 1.0 - */ -public class EchoBaseConfiguration extends ApplicationConfig { - - /** Logger. */ - protected static final Log log = LogFactory.getLog(EchoBaseConfiguration.class); - - public EchoBaseConfiguration() { - - setConfigFileName("echobase-config"); - - if (log.isInfoEnabled()) { - log.info(this + " is initializing..."); - } - loadDefaultOptions(EchoBaseConfigurationOption.class); - } - - /** - * To initialise the configuration. - * <p/> - * Will mainly parse configuration options and creates required directories. - */ - public void init() { - - // parse configuration (with no parameters) - try { - parse(); - } catch (ArgumentsParserException e) { - if (log.isErrorEnabled()) { - log.error("Could not parse configuration", e); - } - } - - createDirectory(EchoBaseConfigurationOption.DATA_DIRECTORY, - "data directory"); - - createDirectory(EchoBaseConfigurationOption.USER_LOG_DIRECTORY, - "user logs directory"); - - createDirectory(EchoBaseConfigurationOption.TREATMENT_WORKING_DIRECTORY, - "treatment workdir directory"); - } - - /** - * Creates a directory given the configuration given key. - * - * @param key the configuration option key which contains the location of - * the directory to create - * @param name a name used for logs - */ - protected void createDirectory(EchoBaseConfigurationOption key, String name) { - - File directory = getOptionAsFile(key.getKey()); - - Preconditions.checkNotNull( - directory, - "Could not find " + name + " (key " + - key + - "in your configuration file named echobase-config)" - ); - if (log.isInfoEnabled()) { - log.info(key + " = " + directory); - } - try { - FileUtil.createDirectoryIfNecessary(directory); - } catch (IOException e) { - throw new IllegalStateException( - "Could not create " + name + "in " + directory); - } - } - - /** - * All EchoBase configuration options. - * - * @since 1.0 - */ - public enum EchoBaseConfigurationOption implements OptionDef { - - /** Main directory where to put echobase data (logs, and others...). */ - DATA_DIRECTORY( - "data.directory", - n_("echobase.config.data.directory.description"), - "/var/local/echobase", - File.class), - - INTERNAL_DB_DIRECTORY( - "internal.db.directory", - n_("echobase.config.internal.db.directory.description"), - "${data.directory}/echobase", - File.class), - - PARAMETER_PROFILE_DIRECTORY( - "parameterProfiles.storage.directory", - n_("echobase.config.parameterProfiles.storage.directory.description"), - "${data.directory}/parameter-profiles", - File.class), - - USER_LOG_DIRECTORY( - "user.log.directory", - n_("echobase.user.log.directory.description"), - "${data.directory}/logs", - File.class), - - TREATMENT_WORKING_DIRECTORY( - "treatment.working.directory", - n_("echobase.config.treatment.working.directory.description"), - "${data.directory}/treatments", - File.class); - - /** Configuration key. */ - protected final String key; - - /** I18n key of option description */ - protected final String description; - - /** Type of option */ - protected final Class<?> type; - - /** Default value of option. */ - protected String defaultValue; - - EchoBaseConfigurationOption(String key, - String description, - String defaultValue, - Class<?> type) { - this.key = key; - this.description = description; - this.defaultValue = defaultValue; - this.type = type; - } - - @Override - public String getKey() { - return key; - } - - @Override - public Class<?> getType() { - return type; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public String getDefaultValue() { - return defaultValue; - } - - @Override - public boolean isTransient() { - return true; - } - - @Override - public boolean isFinal() { - return true; - } - - @Override - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - @Override - public void setTransient(boolean newValue) { - // not used - } - - @Override - public void setFinal(boolean newValue) { - // not used - } - } -} Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationHelper.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationHelper.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationHelper.java 2011-11-04 10:09:27 UTC (rev 8) @@ -1,65 +0,0 @@ -/* - * #%L - * EchoBase :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.ApplicationConfig; - -import java.net.URL; -import java.util.Properties; - - -/** - * Helper to access specialized property from a neutral configuration - * {@link ApplicationConfig}. - * - * @author chemit <chemit@codelutin.com> - * @since 1.0 - */ -public class EchoBaseConfigurationHelper { - - /** Logger. */ - protected static final Log log = - LogFactory.getLog(EchoBaseConfigurationHelper.class); - - public static String getApplicationVersion(ApplicationConfig config) { - String v = config.getOption("application.version"); - return v; - } - - public static URL getApplicationSite(ApplicationConfig config) { - URL url = config.getOptionAsURL("application.site.url"); - return url; - } - - protected EchoBaseConfigurationHelper() { - // hide helper constructor - } - - protected static void reloadProperty(Properties properties, String propertyName) { - Object o = properties.getProperty(propertyName); - properties.put(propertyName, o); - } -} Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java 2011-11-04 10:09:27 UTC (rev 8) @@ -25,15 +25,14 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Maps; -import fr.ifremer.echobase.services.IOCService; import fr.ifremer.echobase.services.EchoBaseServiceInitializable; import fr.ifremer.echobase.services.EchoBaseServiceInjectable; import fr.ifremer.echobase.services.EchoBaseServiceSingleton; +import fr.ifremer.echobase.services.IOCService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.framework.TopiaTransactionAware; -import org.nuiton.util.ApplicationConfig; import org.nuiton.util.ObjectUtil; import java.util.Map; @@ -55,14 +54,14 @@ * <b>Note:</b> this configuration must be filled before any invocation * to a service. */ - protected static ApplicationConfig configuration; + protected static EchoBaseConfiguration configuration; /** * Sets the shared application configuration. * * @param configuration the shared application configuration to set */ - public static void setConfiguration(ApplicationConfig configuration) { + public static void setConfiguration(EchoBaseConfiguration configuration) { EchoBaseObjectFactory.configuration = configuration; } @@ -72,7 +71,7 @@ * @return the share application configuration, or {@code null} if none * was setted */ - public static ApplicationConfig getConfiguration() { + public static EchoBaseConfiguration getConfiguration() { return configuration; } @@ -81,7 +80,7 @@ * <p/> * <strong>Note:</strong> The shared configuration must have been setted * before using this method via the method - * {@link #setConfiguration(ApplicationConfig)} + * {@link #setConfiguration(EchoBaseConfiguration)} * * @return the new instanciated EchoBase factory. */ Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,31 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +package fr.ifremer.echobase.services; + +public interface EchoBaseService { + + void setServiceContext(EchoBaseServiceContext serviceContext); + +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,43 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +package fr.ifremer.echobase.services; + +import fr.ifremer.echobase.EchoBaseConfiguration; +import org.nuiton.topia.TopiaContext; + +/** + * This contract represents objects you must provide when asking for a service. + * Objects provided may be injected in services returned by + * {@link EchoBaseServiceFactory#newService(Class, EchoBaseServiceContext)} + */ +public interface EchoBaseServiceContext { + + TopiaContext getTransaction(); + + <E extends EchoBaseService> E newService(Class<E> clazz); + + EchoBaseConfiguration getConfiguration(); + +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,66 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services; + +import com.google.common.base.Preconditions; +import fr.ifremer.echobase.EchoBaseConfiguration; +import org.nuiton.topia.TopiaContext; + +/** Instances of this class will be given to service factory. */ +public class EchoBaseServiceContextImpl implements EchoBaseServiceContext { + + protected TopiaContext transaction; + + protected EchoBaseServiceFactory serviceFactory; + + protected EchoBaseConfiguration configuration; + + public EchoBaseServiceContextImpl(TopiaContext transaction, + EchoBaseConfiguration configuration, + EchoBaseServiceFactory serviceFactory) { + this.transaction = transaction; + this.configuration = configuration; + this.serviceFactory = serviceFactory; + } + + @Override + public TopiaContext getTransaction() { + Preconditions.checkNotNull(transaction); + return transaction; + } + + @Override + public <E extends EchoBaseService> E newService(Class<E> clazz) { + return serviceFactory.newService(clazz, this); + } + + @Override + public EchoBaseConfiguration getConfiguration() { + return configuration; + } + + protected EchoBaseServiceFactory getServiceFactory() { + return serviceFactory; + } +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,52 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services; + +import fr.ifremer.echobase.EchoBaseTechnicalException; + +import java.lang.reflect.InvocationTargetException; + +public class EchoBaseServiceFactory { + + public <E extends EchoBaseService> E newService(Class<E> clazz, EchoBaseServiceContext serviceContext) { + // instantiate service using empty constructor + E service; + try { + service = clazz.getConstructor().newInstance(); + } catch (InstantiationException e) { + throw new EchoBaseTechnicalException(e); + } catch (IllegalAccessException e) { + throw new EchoBaseTechnicalException(e); + } catch (InvocationTargetException e) { + throw new EchoBaseTechnicalException(e); + } catch (NoSuchMethodException e) { + throw new EchoBaseTechnicalException(e); + } + + service.setServiceContext(serviceContext); + + return service; + } + +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInitializable.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInjectable.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSingleton.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/IOCService.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/AbstractInjector.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectDAO.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntitiesById.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntityById.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectFromDAO.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/Injector.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorDAO.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntitiesById.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntityById.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorFromDAO.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/resources/META-INF/services/fr.ifremer.echobase.services.ioc.Injector ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-services/src/main/resources/echobase-config ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-services/src/main/resources/echobase-db-h2.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/resources/echobase-db.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-services/src/test/resources/log4j.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/LICENSE.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/README.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/changelog.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/pom.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/license/THIRD-PARTY.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/env/dev/resources/log4j.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/env/dev/resources/struts.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/env/prod/resources/log4j.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java 2011-11-04 10:09:27 UTC (rev 8) @@ -23,8 +23,11 @@ */ package fr.ifremer.echobase.ui; +import com.google.common.base.Supplier; import fr.ifremer.echobase.EchoBaseConfiguration; import fr.ifremer.echobase.EchoBaseObjectFactory; +import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; import fr.ird.converter.FloatConverter; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.Converter; @@ -58,6 +61,8 @@ protected static final Log log = LogFactory.getLog(ApplicationListener.class); + private Supplier<TopiaContext> rootContextSupplier; + @Override public void contextInitialized(ServletContextEvent sce) { @@ -65,19 +70,30 @@ log.info("Application starting at " + new Date() + "..."); } + // init I18n + DefaultI18nInitializer i18nInitializer = + new DefaultI18nInitializer("echobase-i18n"); + i18nInitializer.setMissingKeyReturnNull(true); + I18n.init(i18nInitializer, Locale.getDefault()); + + EchoBaseApplicationContext applicationContext = new EchoBaseApplicationContext(); + sce.getServletContext().setAttribute(EchoBaseActionSupport.APPLICATION_CONTEXT_PARAMETER, applicationContext); + // initialize configuration EchoBaseConfiguration configuration = new EchoBaseConfiguration(); - configuration.init(); + applicationContext.setConfiguration(configuration); + if (log.isInfoEnabled()) { + log.info("Initializing RootContextSupplier..."); + } + EchoBaseTopiaRootContextSupplierFactory factory = + new EchoBaseTopiaRootContextSupplierFactory(); + rootContextSupplier = factory.newDatabaseFromConfig(configuration); + applicationContext.setRootContextSupplier(rootContextSupplier); + // attach configuration to service factory EchoBaseObjectFactory.setConfiguration(configuration); - // init I18n - DefaultI18nInitializer i18nInitializer = - new DefaultI18nInitializer("echobase-i18n"); - i18nInitializer.setMissingKeyReturnNull(true); - I18n.init(i18nInitializer, Locale.getDefault()); - // register our not locale dependant converter Converter converter = ConverterUtil.getConverter(Float.class); if (converter != null) { @@ -89,6 +105,7 @@ EchoBaseObjectFactory serviceFactory = EchoBaseObjectFactory.newInstance(); // init database (and create minimal admin user if required) + // initInternalDatabase(serviceFactory, configuration); } Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java 2011-11-04 10:09:27 UTC (rev 8) @@ -0,0 +1,51 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.ui; + +import com.google.common.base.Supplier; +import fr.ifremer.echobase.EchoBaseConfiguration; +import org.nuiton.topia.TopiaContext; + +public class EchoBaseApplicationContext { + + protected EchoBaseConfiguration configuration; + + protected Supplier<TopiaContext> rootContextSupplier; + + public EchoBaseConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration(EchoBaseConfiguration configuration) { + this.configuration = configuration; + } + + public Supplier<TopiaContext> getRootContextSupplier() { + return rootContextSupplier; + } + + public void setRootContextSupplier(Supplier<TopiaContext> rootContextSupplier) { + this.rootContextSupplier = rootContextSupplier; + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-04 10:09:27 UTC (rev 8) @@ -23,7 +23,6 @@ */ package fr.ifremer.echobase.ui; -import com.opensymphony.xwork2.ActionContext; import fr.ifremer.echobase.EchoBaseObjectFactory; import fr.ifremer.echobase.entities.EchoBaseUser; import org.apache.commons.logging.Log; @@ -43,42 +42,42 @@ /** Logger. */ private static final Log log = LogFactory.getLog(EchoBaseSession.class); - /** - * Obtain the user EchoBase session. - * <p/> - * If not found in application session, then will instanciate it and - * push it in it. - * <p/> - * At the creation time the session, it will also set his object factory. - * - * @return the user EchoBase session (never null) - */ - public static EchoBaseSession getEchoBaseSession() { - Map<String, Object> session = ActionContext.getContext().getSession(); - EchoBaseSession echoBaseSession = (EchoBaseSession) - session.get(SESSION_PARAMETER_ECHO_BASE_SESSION); - if (echoBaseSession == null) { - // let's create it - echoBaseSession = new EchoBaseSession(); - echoBaseSession.setObjectFactory(EchoBaseObjectFactory.newInstance()); - session.put(SESSION_PARAMETER_ECHO_BASE_SESSION, echoBaseSession); - } - return echoBaseSession; - } +// /** +// * Obtain the user EchoBase session. +// * <p/> +// * If not found in application session, then will instanciate it and +// * push it in it. +// * <p/> +// * At the creation time the session, it will also set his object factory. +// * +// * @return the user EchoBase session (never null) +// */ +// public static EchoBaseSession getEchoBaseSession() { +// Map<String, Object> session = ActionContext.getContext().getSession(); +// EchoBaseSession echoBaseSession = (EchoBaseSession) +// session.get(SESSION_PARAMETER_ECHO_BASE_SESSION); +// if (echoBaseSession == null) { +// // let's create it +// echoBaseSession = new EchoBaseSession(); +// echoBaseSession.setObjectFactory(EchoBaseObjectFactory.newInstance()); +// session.put(SESSION_PARAMETER_ECHO_BASE_SESSION, echoBaseSession); +// } +// return echoBaseSession; +// } - /** - * Tests if user is loggued (means the {@link #getEchoBaseUser()} is not null). - * - * @return {@code true} if user is loggued, {@code false} otherwise - */ - public static boolean isUserInSession() { - EchoBaseSession session = getEchoBaseSession(); - boolean result = session.getEchoBaseUser() != null; - return result; - } +// /** +// * Tests if user is loggued (means the {@link #getEchoBaseUser()} is not null). +// * +// * @return {@code true} if user is loggued, {@code false} otherwise +// */ +// public static boolean isUserInSession() { +// EchoBaseSession session = getEchoBaseSession(); +// boolean result = session.getEchoBaseUser() != null; +// return result; +// } /** Key used to store this EchoBase session in application session */ - public static final String SESSION_PARAMETER_ECHO_BASE_SESSION = "echobaseSession"; +// public static final String SESSION_PARAMETER_ECHO_BASE_SESSION = "echobaseSession"; /** Key to set EchoBase factory in this session. */ protected static final String PROPERTY_OBJECT_FACTORY = "objectFactory"; @@ -152,7 +151,7 @@ } /** Protect session constructor. */ - protected EchoBaseSession() { + public EchoBaseSession() { store = new TreeMap<String, Object>(); } Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSessionAware.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSessionAware.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSessionAware.java 2011-11-04 10:09:27 UTC (rev 8) @@ -1,35 +0,0 @@ -/* - * #%L - * EchoBase :: UI - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.ui; - -/** - * Set the EchoBase session user in the action. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0 - */ -public interface EchoBaseSessionAware { - - void setEchoBaseSession(EchoBaseSession echoBaseSession); -} Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-04 10:09:27 UTC (rev 8) @@ -24,16 +24,23 @@ package fr.ifremer.echobase.ui.actions; import com.google.common.base.Preconditions; -import fr.ifremer.echobase.EchoBaseConfigurationHelper; +import com.opensymphony.xwork2.ActionContext; +import fr.ifremer.echobase.EchoBaseConfiguration; import fr.ifremer.echobase.EchoBaseObjectFactory; +import fr.ifremer.echobase.services.EchoBaseService; +import fr.ifremer.echobase.services.EchoBaseServiceContext; +import fr.ifremer.echobase.services.EchoBaseServiceContextImpl; +import fr.ifremer.echobase.services.EchoBaseServiceFactory; import fr.ifremer.echobase.services.IOCService; +import fr.ifremer.echobase.ui.EchoBaseApplicationContext; import fr.ifremer.echobase.ui.EchoBaseSession; -import fr.ifremer.echobase.ui.EchoBaseSessionAware; -import org.nuiton.util.ApplicationConfig; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.framework.TopiaTransactionAware; import org.nuiton.web.struts2.BaseAction; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Map; /** * EchoBase action support. @@ -46,49 +53,75 @@ * @author chemit <chemit@codelutin.com> * @since 1.0 */ -public class EchoBaseActionSupport extends BaseAction implements EchoBaseSessionAware { +public class EchoBaseActionSupport extends BaseAction implements TopiaTransactionAware { private static final long serialVersionUID = 1L; public static final String LOG_LINE = "--------------------------------------------------------------------------------"; + /** Key to store the {@link EchoBaseSession} instance in the session's map. */ + protected static final String SESSION_PARAMETER = "echoBaseSession"; + + /** Key to store the single instance of the application context */ + public static final String APPLICATION_CONTEXT_PARAMETER = "echoBaseApplicationContext"; + private SimpleDateFormat dateFormat; private SimpleDateFormat monthFormat; + public static EchoBaseApplicationContext getEchoBaseApplicationContext() { + Map<String, Object> application = ActionContext.getContext().getApplication(); + EchoBaseApplicationContext applicationContext = + (EchoBaseApplicationContext) application.get(APPLICATION_CONTEXT_PARAMETER); + return applicationContext; + } - /** - * EchoBase User session. - * <p/> - * <strong>This object will be injected only if you implements the - * contract {@link EchoBaseSessionAware} on your action.</strong> - */ + protected EchoBaseConfiguration getConfiguration() { + return getEchoBaseApplicationContext().getConfiguration(); + } + + /** EchoBase User session. */ private transient EchoBaseSession echoBaseSession; /** - * To inject the EchoBase User session in action. - * - * @param echoBaseSession the new EchoBase User session to inject in action + * Provides a way to get a service. + * <p/> + * Actions may <strong>not</strong> call it directly by use + * {@link #newService(Class)} instead. */ - @Override - public final void setEchoBaseSession(EchoBaseSession echoBaseSession) { - this.echoBaseSession = echoBaseSession; - } + protected transient EchoBaseServiceFactory serviceFactory = + new EchoBaseServiceFactory(); - protected EchoBaseSession getEchoBaseSession() { + protected transient EchoBaseServiceContext serviceContext; + + protected transient TopiaContext transaction; + + public EchoBaseSession getEchoBaseSession() { + if (echoBaseSession == null) { + + // load it from session + Map<String, Object> strutsSession = ActionContext.getContext().getSession(); + EchoBaseSession session = (EchoBaseSession) + strutsSession.get(SESSION_PARAMETER); + + if (session == null) { + + // create an empty session + session = new EchoBaseSession(); + + // and store it in the struts session + strutsSession.put(SESSION_PARAMETER, session); + } + echoBaseSession = session; + } return echoBaseSession; } public static String getApplicationVersion() { - return EchoBaseConfigurationHelper.getApplicationVersion( - EchoBaseObjectFactory.getConfiguration()); + return getEchoBaseApplicationContext().getConfiguration().getApplicationVersion().toString(); } - protected ApplicationConfig getApplicationConfig() { - return EchoBaseObjectFactory.getConfiguration(); - } - public EchoBaseObjectFactory getServiceFactory() { Preconditions.checkNotNull(echoBaseSession, "No echo base user session injected."); @@ -96,6 +129,39 @@ return factory; } + /** + * Fabrique pour récupérer le ServiceContext tel qu'il devrait être fourni + * à la fabrication d'un service. + */ + protected EchoBaseServiceContext getServiceContext() { + if (serviceContext == null) { + serviceContext = new EchoBaseServiceContextImpl( + getTransaction(), getConfiguration(), serviceFactory); + } + return serviceContext; + } + + /** + * Sub-classes should use this method to easily get a service instance. + * + * @param serviceClass The type of service to instantiate + * @return A newly created service of the expected type with necessary data set + */ + public <E extends EchoBaseService> E newService(Class<E> serviceClass) { + E service = serviceFactory.newService(serviceClass, getServiceContext()); + return service; + } + + @Override + public TopiaContext getTransaction() { + return transaction; + } + + @Override + public void setTransaction(TopiaContext transaction) { + this.transaction = transaction; + } + public IOCService getIocService() { return getServiceFactory().newService(IOCService.class); } Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseTransactionActionSupport.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseTransactionActionSupport.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseTransactionActionSupport.java 2011-11-04 10:09:27 UTC (rev 8) @@ -1,53 +0,0 @@ -/* - * #%L - * EchoBase :: UI - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.ui.actions; - -import org.nuiton.topia.TopiaContext; -import org.nuiton.topia.framework.TopiaTransactionAware; - -/** - * EchoBase action with a transaction. - * - * @author chemit <chemit@codelutin.com> - * @see TopiaTransactionAware - * @see EchoBaseActionSupport - * @since 1.0 - */ -public class EchoBaseTransactionActionSupport extends EchoBaseActionSupport implements TopiaTransactionAware { - - private static final long serialVersionUID = 1L; - - protected transient TopiaContext transaction; - - @Override - public TopiaContext getTransaction() { - return transaction; - } - - @Override - public void setTransaction(TopiaContext transaction) { - this.transaction = transaction; - } - -} Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/HomeAction.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/HomeAction.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/HomeAction.java 2011-11-04 10:09:27 UTC (rev 8) @@ -32,7 +32,7 @@ * @author tchemit <chemit@codelutin.com> * @since 1.0 */ -public class HomeAction extends EchoBaseTransactionActionSupport { +public class HomeAction extends EchoBaseActionSupport { private static final long serialVersionUID = 1L; Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/HomeAction.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-04 10:09:27 UTC (rev 8) @@ -40,7 +40,7 @@ * @author chemit <chemit@codelutin.com> * @since 1.0 */ -public class LoginAction extends EchoBaseTransactionActionSupport implements SessionAware { +public class LoginAction extends EchoBaseActionSupport implements SessionAware { protected static final Log log = LogFactory.getLog(LoginAction.class); @@ -124,8 +124,7 @@ userSession.setObjectFactory(null); // remove echoBaseSession from application session - ActionContext.getContext().getSession().remove( - EchoBaseSession.SESSION_PARAMETER_ECHO_BASE_SESSION); + ActionContext.getContext().getSession().remove(SESSION_PARAMETER); return SUCCESS; } Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/AbstractCheckInterceptor.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java 2011-11-04 10:09:27 UTC (rev 8) @@ -27,6 +27,7 @@ import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.util.TextParseUtil; import fr.ifremer.echobase.ui.EchoBaseSession; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -63,7 +64,9 @@ @Override protected boolean doCheck(ActionInvocation invocation) { - EchoBaseSession echoBaseSession = EchoBaseSession.getEchoBaseSession(); + EchoBaseActionSupport action = (EchoBaseActionSupport) invocation.getAction(); + + EchoBaseSession echoBaseSession = action.getEchoBaseSession(); Set<String> missingKeys = null; for (String parameter : parameters) { boolean ok = echoBaseSession.contains(parameter); Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java 2011-11-04 10:09:27 UTC (rev 8) @@ -25,6 +25,7 @@ import com.opensymphony.xwork2.ActionInvocation; import fr.ifremer.echobase.ui.EchoBaseSession; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -53,8 +54,11 @@ @Override protected boolean doCheck(ActionInvocation invocation) { - boolean userLoggued = EchoBaseSession.isUserInSession(); + EchoBaseActionSupport action = (EchoBaseActionSupport) invocation.getAction(); + EchoBaseSession echoBaseSession = action.getEchoBaseSession(); + boolean userLoggued = echoBaseSession.getEchoBaseUser() != null; + if (!userLoggued) { if (log.isInfoEnabled()) { log.info("No user loggued!"); Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckUserIsAdmin.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckUserIsAdmin.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckUserIsAdmin.java 2011-11-04 10:09:27 UTC (rev 8) @@ -27,6 +27,7 @@ import com.opensymphony.xwork2.ActionInvocation; import fr.ifremer.echobase.entities.EchoBaseUser; import fr.ifremer.echobase.ui.EchoBaseSession; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; /** * To check if logged user is admin. @@ -40,8 +41,10 @@ @Override protected boolean doCheck(ActionInvocation invocation) { - EchoBaseSession echoBaseSession = EchoBaseSession.getEchoBaseSession(); + EchoBaseActionSupport action = (EchoBaseActionSupport) invocation.getAction(); + EchoBaseSession echoBaseSession = action.getEchoBaseSession(); + EchoBaseUser user = echoBaseSession.getEchoBaseUser(); Preconditions.checkNotNull(user, "No user found is session"); Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckUserIsAdmin.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CleanEchoBaseSessionInterceptor.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CleanEchoBaseSessionInterceptor.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CleanEchoBaseSessionInterceptor.java 2011-11-04 10:09:27 UTC (rev 8) @@ -27,6 +27,7 @@ import com.opensymphony.xwork2.interceptor.AbstractInterceptor; import com.opensymphony.xwork2.util.TextParseUtil; import fr.ifremer.echobase.ui.EchoBaseSession; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -62,18 +63,17 @@ @Override public String intercept(ActionInvocation invocation) throws Exception { - EchoBaseSession echoBaseSession = EchoBaseSession.getEchoBaseSession(); - if (echoBaseSession != null) { + EchoBaseActionSupport action = (EchoBaseActionSupport) invocation.getAction(); - for (String paramName : parameters) { - Object value = echoBaseSession.remove(paramName); - if (log.isDebugEnabled()) { - log.debug("Removed [" + paramName + "] : " + value); - } + EchoBaseSession echoBaseSession = action.getEchoBaseSession(); - + for (String paramName : parameters) { + Object value = echoBaseSession.remove(paramName); + if (log.isDebugEnabled()) { + log.debug("Removed [" + paramName + "] : " + value); } } + return invocation.invoke(); } } Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CleanEchoBaseSessionInterceptor.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseSessionInterceptor.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseSessionInterceptor.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseSessionInterceptor.java 2011-11-04 10:09:27 UTC (rev 8) @@ -1,51 +0,0 @@ -/* - * #%L - * EchoBase :: UI - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.ui.interceptors; - -import com.opensymphony.xwork2.ActionInvocation; -import com.opensymphony.xwork2.interceptor.AbstractInterceptor; -import fr.ifremer.echobase.ui.EchoBaseSession; -import fr.ifremer.echobase.ui.EchoBaseSessionAware; - -/** - * Inject the {@link EchoBaseSession} inside any action with contract - * {@link EchoBaseSessionAware}. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0 - */ -public class EchoBaseSessionInterceptor extends AbstractInterceptor { - private static final long serialVersionUID = 1L; - - @Override - public String intercept(ActionInvocation invocation) throws Exception { - - Object action = invocation.getAction(); - if (action instanceof EchoBaseSessionAware) { - EchoBaseSession echoBaseSession = EchoBaseSession.getEchoBaseSession(); - ((EchoBaseSessionAware) action).setEchoBaseSession(echoBaseSession); - } - return invocation.invoke(); - } -} Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java 2011-11-04 10:09:27 UTC (rev 8) @@ -23,7 +23,9 @@ */ package fr.ifremer.echobase.ui.interceptors; -import fr.ifremer.echobase.ui.EchoBaseSession; +import com.google.common.base.Supplier; +import fr.ifremer.echobase.ui.EchoBaseApplicationContext; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.TopiaContext; @@ -47,8 +49,13 @@ @Override protected TopiaContext beginTransaction() throws TopiaException { - EchoBaseSession echoBaseSession = EchoBaseSession.getEchoBaseSession(); - TopiaContext transaction = echoBaseSession.getObjectFactory().beginTransaction(); + EchoBaseApplicationContext applicationContext = + EchoBaseActionSupport.getEchoBaseApplicationContext(); + Supplier<TopiaContext> rootContextSupplier = + applicationContext.getRootContextSupplier(); + + TopiaContext rootContext = rootContextSupplier.get(); + TopiaContext transaction = rootContext.beginTransaction(); if (log.isDebugEnabled()) { log.debug("Starts a new echo transaction " + transaction); } Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/resources/config/struts-user.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-ui/src/main/resources/struts.xml =================================================================== --- trunk/echobase-ui/src/main/resources/struts.xml 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/resources/struts.xml 2011-11-04 10:09:27 UTC (rev 8) @@ -61,10 +61,6 @@ <interceptor name="topiaTransaction" class="fr.ifremer.echobase.ui.interceptors.EchoBaseTransactionInterceptorImpl"/> - <!-- to inject the echobase session inside an action --> - <interceptor name="injectEchoBaseSession" - class="fr.ifremer.echobase.ui.interceptors.EchoBaseSessionInterceptor"/> - <!-- to clean some properties from the echobase session --> <interceptor name="cleanEchoBaseSession" class="fr.ifremer.echobase.ui.interceptors.CleanEchoBaseSessionInterceptor"/> @@ -97,16 +93,12 @@ <!-- echobase basic authenticated stack --> <interceptor-stack name="echoBaseBasicStack"> - <interceptor-ref name="injectEchoBaseSession"/> - <!--<interceptor-ref name="checkEchoBaseDatabaseSelected"/>--> <interceptor-ref name="topiaTransaction"/> <interceptor-ref name="basicStack"/> </interceptor-stack> <!-- echobase stack with params--> <interceptor-stack name="echoBaseParamsPrepareParamsStack"> - <interceptor-ref name="injectEchoBaseSession"/> - <!--<interceptor-ref name="checkEchoBaseDatabaseSelected"/>--> <interceptor-ref name="topiaTransaction"/> <interceptor-ref name="paramsPrepareParamsStack"/> </interceptor-stack> @@ -118,15 +110,6 @@ <interceptor-ref name="echoBaseBasicStack"/> </interceptor-stack> - <interceptor-stack name="loginAndActionContext"> - <interceptor-ref name="i18n"/> - <interceptor-ref name="checkUserLoggued"/> - <interceptor-ref name="checkEchobaseSession"> - <param name="parameters">actionContext</param> - <param name="redirectAction">/missingActionContext</param> - </interceptor-ref> - </interceptor-stack> - <!-- authenticated stack with params--> <interceptor-stack name="paramsPrepareParamsStackLoggued"> <interceptor-ref name="i18n"/> @@ -159,7 +142,6 @@ <param name="paramNames">request_locale</param> </interceptor-ref> <interceptor-ref name="checkUserLoggued"/> - <interceptor-ref name="injectEchoBaseSession"/> <interceptor-ref name="topiaTransaction"/> </action> Property changes on: trunk/echobase-ui/src/main/resources/struts.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/i18n.jsp ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp 2011-11-04 09:21:14 UTC (rev 7) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp 2011-11-04 10:09:27 UTC (rev 8) @@ -2,7 +2,7 @@ #%L EchoBase :: UI - $Id: i18n.jsp 1 2011-11-03 14:23:42Z tchemit $ + $Id$ $HeadURL$ %% Copyright (C) 2011 Ifremer, Codelutin Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportProgress.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/login.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/css/screen.css ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/images/exclamation.png ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/images/logo_codelutin.png ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/images/true.png ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/index.jsp ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/main/webapp/js/gridHelper.js ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/src/site/rst/index.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-ui/src/site/site_fr.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/echobase-ui/web/WEB-INF/web.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/pom.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/src/doc/reunions/reunion-2011-11-03.txt ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/src/site/rst/Todo.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/src/site/rst/index.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/src/site/site_fr.xml ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL