Echobase-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- 1864 discussions
r16 - in trunk: echobase-services/src/main/java/fr/ifremer/echobase echobase-services/src/main/java/fr/ifremer/echobase/services echobase-services/src/main/resources echobase-services/src/main/resources/i18n echobase-ui/src/main/java/fr/ifremer/echobase/ui echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators echobase-ui/src/main/webapp/WEB-INF
by tchemit@users.forge.codelutin.com 07 Nov '11
by tchemit@users.forge.codelutin.com 07 Nov '11
07 Nov '11
Author: tchemit
Date: 2011-11-07 11:55:42 +0100 (Mon, 07 Nov 2011)
New Revision: 16
Url: http://forge.codelutin.com/repositories/revision/echobase/16
Log:
let's play it by the nflogement way :)
Added:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
Removed:
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/
trunk/echobase-services/src/main/resources/META-INF/
trunk/echobase-services/src/main/resources/echobase-config
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java
trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java
trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -1,216 +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 com.google.common.collect.Maps;
-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.ObjectUtil;
-
-import java.util.Map;
-
-/**
- * To obtain services.
- *
- * @author chemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class EchoBaseObjectFactory {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(EchoBaseObjectFactory.class);
-
- /**
- * Shared application configuration.
- * <p/>
- * <b>Note:</b> this configuration must be filled before any invocation
- * to a service.
- */
- protected static EchoBaseConfiguration configuration;
-
- /**
- * Sets the shared application configuration.
- *
- * @param configuration the shared application configuration to set
- */
- public static void setConfiguration(EchoBaseConfiguration configuration) {
- EchoBaseObjectFactory.configuration = configuration;
- }
-
- /**
- * Get the shared application configuration.
- *
- * @return the share application configuration, or {@code null} if none
- * was setted
- */
- public static EchoBaseConfiguration getConfiguration() {
- return configuration;
- }
-
- /**
- * Obtain a new EchoBase factory.
- * <p/>
- * <strong>Note:</strong> The shared configuration must have been setted
- * before using this method via the method
- * {@link #setConfiguration(EchoBaseConfiguration)}
- *
- * @return the new instanciated EchoBase factory.
- */
- public static EchoBaseObjectFactory newInstance() {
- // must have a configuration to start the factory
- Preconditions.checkNotNull(
- configuration,
- "No EchoBase appliation configuration registred.");
-
- if (log.isInfoEnabled()) {
- log.info("New EchoBaseObjectFactory with configuration " + configuration);
- }
- // instanciate factory
- EchoBaseObjectFactory factory = new EchoBaseObjectFactory();
- return factory;
- }
-
- /**
- * Destroy the static states of this class (mainly should be called at the
- * end of the application).
- */
- public static void destroy() {
- setConfiguration(null);
- }
-
- /**
- * To store shared services.
- * <p/>
- * A shared service is in fact a singleton so can keep it once for all
- * while using {@link #newService(Class)}.
- */
- protected final Map<Class<?>, ?> services;
-
- /**
- * Gets an instance of the service of the given type.
- * <p/>
- * If the service is marked as share, then the same instance will be
- * always delivred, otheriwse a new instance will be each time created.
- *
- * @param serviceClass the type of service to obtain
- * @param <S> the type of service to obtain
- * @return the instance of required service
- */
- public <S> S newService(Class<S> serviceClass) {
- S service = newService0(serviceClass, null);
- return service;
- }
-
- /**
- * Gets an instance of the transactional service of the given type.
- * <p/>
- * The given transaction will be injected into the transactional service.
- * <p/>
- * <strong>Note:</strong> To avoid problems, a transactional service should
- * always not to be shared service.
- *
- * @param serviceClass the type of the service to obtain
- * @param tx the transaction to inject in the service
- * @param <S> the type of the service to obtain
- * @return the instance of the required service
- */
- public <S extends TopiaTransactionAware> S newTransactionalService(Class<S> serviceClass,
- TopiaContext tx) {
- S service = newService0(serviceClass, tx);
- return service;
- }
-
- @Override
- protected void finalize() throws Throwable {
- if (services != null) {
- services.clear();
- }
- super.finalize();
- }
-
- /** Protected constructor to avoid external instanciations... */
- protected EchoBaseObjectFactory() {
- services = Maps.newHashMap();
- }
-
- /**
- * Gets a service given his type.
- * <p/>
- * It will first search in cache (if service is marked as shared).
- * <p/>
- * If not found, then creates the new service and can do some stuffs on
- * the freshly instanciaed service.
- *
- * @param serviceClass the type of service to obtain
- * @param tx the optinal transaction to set
- * @param <S> the type of service to obtain
- * @return the required service (from cache) or freshly instanciated
- * @see EchoBaseServiceInitializable
- */
- @SuppressWarnings({"unchecked"})
- private <S> S newService0(Class<S> serviceClass, TopiaContext tx) {
- Object service = null;
- if (EchoBaseServiceSingleton.class.isAssignableFrom(serviceClass)) {
-
- // try to obtain it from cache
- service = services.get(serviceClass);
- }
- if (service == null) {
-
- service = ObjectUtil.newInstance(serviceClass);
- if (tx != null && service instanceof TopiaTransactionAware) {
- TopiaTransactionAware transactionAware = (TopiaTransactionAware) service;
- transactionAware.setTransaction(tx);
- }
- if (service instanceof EchoBaseServiceInitializable) {
- EchoBaseServiceInitializable initializable = (EchoBaseServiceInitializable) service;
- initializable.init(this);
- }
- if (service instanceof EchoBaseServiceInjectable) {
- try {
- newService(IOCService.class).injectExcept(service);
- } catch (Exception e) {
- throw new IllegalStateException(
- "Could not inject into service " + service, e);
- }
- }
- if (service instanceof EchoBaseServiceSingleton) {
- ((Map) services).put(serviceClass, service);
- }
- }
- return (S) service;
- }
-
- public TopiaContext beginTransaction() {
- //TODO Make it happens
- return null;
- }
-}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -25,7 +25,11 @@
package fr.ifremer.echobase.services;
/**
+ * Contract to place on each EchBase service to push the {@code serviceContext}
+ * inside the service.
+ *
* @author chemit <chemit(a)codelutin.com>
+ * @see EchoBaseServiceContext
* @since 0.1
*/
public interface EchoBaseService {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -26,11 +26,14 @@
import fr.ifremer.echobase.EchoBaseTechnicalException;
import java.lang.reflect.InvocationTargetException;
+
/**
+ * Factory of services.
+ *
* @author chemit <chemit(a)codelutin.com>
* @since 0.1
- **/
- public class EchoBaseServiceFactory {
+ */
+public class EchoBaseServiceFactory {
public <E extends EchoBaseService> E newService(Class<E> clazz, EchoBaseServiceContext serviceContext) {
// instantiate service using empty constructor
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInitializable.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInitializable.java 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInitializable.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -1,46 +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.services;
-
-/**
- * @author chemit <chemit(a)codelutin.com>
- * @since 0.1
- **/
-import fr.ifremer.echobase.EchoBaseObjectFactory;
-
-/**
- * Contract for service which need an intialization after their instanciation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public interface EchoBaseServiceInitializable {
-
- /**
- * Init the service using the T3 service factory which instanciated the service.
- *
- * @param factory the factory used to instanciate the service
- */
- void init(EchoBaseObjectFactory factory);
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInjectable.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInjectable.java 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInjectable.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -1,34 +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.services;
-
-/**
- * Contract for service which need an injections.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public interface EchoBaseServiceInjectable {
-
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSingleton.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSingleton.java 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSingleton.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -1,38 +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.services;
-
-
-import fr.ifremer.echobase.EchoBaseObjectFactory;
-
-/**
- * A contract to mark a shared service.
- * <p/>
- * A shared service will be keep as a singleton in the {@link EchoBaseObjectFactory}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public interface EchoBaseServiceSingleton {
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/IOCService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/IOCService.java 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/IOCService.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -1,166 +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.services;
-
-import com.google.common.collect.Lists;
-import fr.ifremer.echobase.EchoBaseObjectFactory;
-import fr.ifremer.echobase.services.ioc.Injector;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ServiceLoader;
-
-/**
- * Service to inject stuff using T3 IOC engine.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @see Injector
- * @since 0.1
- */
-public class IOCService implements EchoBaseServiceInitializable, EchoBaseServiceSingleton {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(IOCService.class);
-
- protected Collection<Injector<?, ?>> injectors;
-
- @Override
- public void init(EchoBaseObjectFactory factory) {
- for (Injector<?, ?> injector : getInjectors()) {
- injector.init(factory);
- }
- }
-
- public void injectExcept(Object bean,
- Class<?>... excludedInjectors) throws Exception {
-
- // obtain the list of available injectors
- Collection<Injector<?, ?>> injectorsToUse;
-
- if (excludedInjectors.length == 0) {
-
- // use all injectors
- injectorsToUse = getInjectors();
- } else {
- injectorsToUse = Lists.newArrayList(getInjectors());
- List<Class<?>> annotations = Arrays.asList(excludedInjectors);
- Iterator<Injector<?, ?>> itr = injectorsToUse.iterator();
- while (itr.hasNext()) {
- Injector<?, ?> injector = itr.next();
- if (annotations.contains(injector.getAnnotationType())) {
- itr.remove();
- }
- }
- }
-
- // get all fields for the given type
- injectForType(bean, bean.getClass(), injectorsToUse);
- }
-
- public void injectOnly(Object bean,
- Class<?>... onlyInjectors) throws Exception {
-
- // obtain the list of available injectors
- Collection<Injector<?, ?>> injectorsToUse =
- Lists.newArrayList(getInjectors());
- List<Class<?>> annotations = Arrays.asList(onlyInjectors);
- Iterator<Injector<?, ?>> itr = injectorsToUse.iterator();
- while (itr.hasNext()) {
- Injector<?, ?> injector = itr.next();
- if (!annotations.contains(injector.getAnnotationType())) {
- itr.remove();
- }
- }
-
- // get all fields for the given type
- injectForType(bean, bean.getClass(), injectorsToUse);
- }
-
- protected void injectForType(Object bean,
- Class<?> beanType,
- Collection<Injector<?, ?>> injectors) throws Exception {
- Field[] fields = beanType.getDeclaredFields();
- for (Field field : fields) {
-
- if (Modifier.isFinal(field.getModifiers())) {
-
- // nothing to affect to a final field
- continue;
- }
-
- if (Modifier.isStatic(field.getModifiers())) {
-
- // nothing to affect to a static field
- continue;
- }
-
- Injector injector = getInjector(field, injectors);
- if (injector != null) {
- if (log.isDebugEnabled()) {
- log.debug("Will use injector " + injector + " for " + field);
- }
- injector.processField(field, bean);
- }
- }
- Class<?> superclass = beanType.getSuperclass();
- if (superclass != null && superclass.isAssignableFrom(beanType)) {
- injectForType(bean, superclass, injectors);
- }
- }
-
- protected Injector<?, ?> getInjector(Field field,
- Collection<Injector<?, ?>> injectors) {
-
- Injector<?, ?> result = null;
- for (Injector<?, ?> injector : injectors) {
- Class<? extends Annotation> annotationType =
- injector.getAnnotationType();
- if (field.isAnnotationPresent(annotationType)) {
- result = injector;
- break;
- }
- }
-
- return result;
- }
-
- protected Collection<Injector<?, ?>> getInjectors() {
- if (injectors == null) {
- injectors = Lists.newArrayList();
- for (Injector<?, ?> injector :
- ServiceLoader.load(Injector.class)) {
-
- injectors.add(injector);
- }
- }
- return injectors;
- }
-}
Deleted: trunk/echobase-services/src/main/resources/echobase-config
===================================================================
--- trunk/echobase-services/src/main/resources/echobase-config 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-services/src/main/resources/echobase-config 2011-11-07 10:55:42 UTC (rev 16)
@@ -1,2 +0,0 @@
-application.version=${project.version}
-application.site.url=${project.url}
Modified: trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties
===================================================================
--- trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2011-11-07 10:55:42 UTC (rev 16)
@@ -1,9 +0,0 @@
-echobase.config.data.directory.description=
-echobase.config.internal.db.directory.description=
-echobase.config.level0.weightedSetWeight.description=
-echobase.config.parameterProfiles.storage.directory.description=
-echobase.config.rf1.maximumrate.description=
-echobase.config.rf1.minimumrate.description=
-echobase.config.stratum.weightRatio.description=
-echobase.config.treatment.working.directory.description=
-echobase.user.log.directory.description=
Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java (from rev 14, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java)
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -0,0 +1,255 @@
+/*
+ * #%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 fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EchoBaseUserDTO;
+import fr.ifremer.echobase.entities.EchoBaseUserDTOImpl;
+import fr.ifremer.echobase.entities.EchoBaseUserImpl;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
+import fr.ifremer.echobase.services.EchoBaseServiceContextImpl;
+import fr.ifremer.echobase.services.EchoBaseServiceFactory;
+import fr.ifremer.echobase.services.UserService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import fr.ird.converter.FloatConverter;
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.i18n.I18n;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.framework.TopiaUtil;
+import org.nuiton.util.converter.ConverterUtil;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+
+/**
+ * To listen start or end of the application.
+ * <p/>
+ * On start we will load the configuration and check connection to internal
+ * database, creates schema and create an admin user in none found in database.
+ * <p/>
+ * On stop, just release the application configuration.
+ *
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class EchoBaseApplicationListener implements ServletContextListener {
+
+ /** Logger. */
+ protected static final Log log =
+ LogFactory.getLog(EchoBaseApplicationListener.class);
+
+ private Supplier<TopiaContext> rootContextSupplier;
+
+ @Override
+ public void contextInitialized(ServletContextEvent sce) {
+
+ if (log.isInfoEnabled()) {
+ 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();
+ applicationContext.setConfiguration(configuration);
+
+ if (log.isInfoEnabled()) {
+ log.info("Initializing RootContextSupplier...");
+ }
+ EchoBaseTopiaRootContextSupplierFactory factory =
+ new EchoBaseTopiaRootContextSupplierFactory();
+ rootContextSupplier = factory.newDatabaseFromConfig(configuration);
+ applicationContext.setRootContextSupplier(rootContextSupplier);
+
+ // register our not locale dependant converter
+ Converter converter = ConverterUtil.getConverter(Float.class);
+ if (converter != null) {
+ ConvertUtils.deregister(Float.class);
+ }
+ ConvertUtils.register(new FloatConverter(), Float.class);
+
+ // init database (and create minimal admin user if required)
+ try {
+ boolean schemaExist = isSchemaCreated();
+ if (!schemaExist) {
+
+ updateSchema(configuration);
+ }
+
+ createAdminUser(configuration);
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not init db", e);
+ }
+ }
+
+ @Override
+ public void contextDestroyed(ServletContextEvent sce) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Application is ending at " + new Date() + "...");
+ }
+ if (rootContextSupplier != null) {
+ if (log.isInfoEnabled()) {
+ log.info("Shuting down RootContextSupplier...");
+ }
+ TopiaContext rootContext = rootContextSupplier.get();
+ if (!rootContext.isClosed()) {
+ try {
+ rootContext.closeContext();
+ } catch (TopiaException te) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not close rootContext", te);
+ }
+ }
+ }
+ }
+ }
+
+ protected void updateSchema(EchoBaseConfiguration configuration) throws TopiaException {
+ if (log.isInfoEnabled()) {
+ log.info("Will create or update schema for db.");
+ }
+ // must create the schema
+
+ Properties dbConf = configuration.getProperties();
+
+ dbConf.put("hibernate.hbm2ddl.auto", "update");
+
+ EchoBaseTopiaRootContextSupplierFactory factory =
+ new EchoBaseTopiaRootContextSupplierFactory();
+ Supplier<TopiaContext> topiaContextSupplier =
+ factory.newDatabaseFromProperties(dbConf);
+
+ // start a connexion to load schema
+ TopiaContext tx = null;
+
+ try {
+ tx = topiaContextSupplier.get().beginTransaction();
+
+ } finally {
+
+ // no more update of schema...
+ dbConf.put("hibernate.hbm2ddl.auto", "none");
+
+ closeTransaction(tx);
+ }
+ }
+
+ /**
+ * Creates the adminsitrator ({@code admin/admin}) on the internal
+ * database.
+ *
+ * @param configuration EchoBase configuration
+ * @throws TopiaException if could not create the user.
+ */
+ protected void createAdminUser(EchoBaseConfiguration configuration) throws TopiaException {
+
+ EchoBaseServiceFactory serviceFactory =
+ new EchoBaseServiceFactory();
+ TopiaContext transaction = rootContextSupplier.get().beginTransaction();
+
+ try {
+ EchoBaseServiceContext serviceContext = new EchoBaseServiceContextImpl(
+ transaction,
+ configuration,
+ serviceFactory
+ );
+
+ UserService service = serviceFactory.newService(UserService.class, serviceContext);
+
+ List<EchoBaseUser> users = service.getUsers();
+
+ if (CollectionUtils.isEmpty(users)) {
+
+ // no users in database create the admin user
+ if (log.isInfoEnabled()) {
+ log.info("No user in database, will create default " +
+ "admin user (password admin).");
+ }
+
+ EchoBaseUserDTO userDTO = new EchoBaseUserDTOImpl();
+ userDTO.setEmail("admin");
+ userDTO.setPassword("admin");
+ userDTO.setAdmin(true);
+ service.createOrUpdate(userDTO);
+ }
+ } finally {
+ transaction.closeContext();
+ }
+
+ }
+
+ protected boolean isSchemaCreated() throws TopiaException {
+
+ TopiaContextImplementor tx =
+ (TopiaContextImplementor)
+ rootContextSupplier.get();
+ try {
+ boolean schemaFound = TopiaUtil.isSchemaExist(
+ tx.getHibernateConfiguration(),
+ EchoBaseUserImpl.class.getName()
+ );
+
+ return schemaFound;
+
+ } finally {
+ closeTransaction(tx);
+ }
+ }
+
+ /**
+ * Try to close the given transaction.
+ *
+ * @param tx the transaction to close
+ * @throws TopiaException if could not close the transaction
+ */
+ protected void closeTransaction(TopiaContext tx) throws TopiaException {
+ if (tx != null && !tx.isClosed()) {
+ tx.closeContext();
+ }
+ }
+
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.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/actions/LoginAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -120,7 +120,6 @@
// remove user from session
userSession.setEchoBaseUser(null);
- userSession.setObjectFactory(null);
// remove echoBaseSession from application session
ActionContext.getContext().getSession().remove(SESSION_PARAMETER);
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java 2011-11-07 10:55:42 UTC (rev 16)
@@ -25,7 +25,6 @@
import com.opensymphony.xwork2.validator.ValidationException;
import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EchoBaseUserDTO;
import fr.ifremer.echobase.services.UserService;
/**
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml 2011-11-07 10:46:58 UTC (rev 15)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml 2011-11-07 10:55:42 UTC (rev 16)
@@ -75,7 +75,7 @@
<listener>
<description>Init</description>
- <listener-class>fr.ifremer.echobase.ui.ApplicationListener</listener-class>
+ <listener-class>fr.ifremer.echobase.ui.EchoBaseApplicationListener</listener-class>
</listener>
<welcome-file-list>
1
0
07 Nov '11
Author: sletellier
Date: 2011-11-07 11:46:58 +0100 (Mon, 07 Nov 2011)
New Revision: 15
Url: http://forge.codelutin.com/repositories/revision/echobase/15
Log:
Update javadoc
Modified:
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-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
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-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/UserService.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-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.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/actions/UserAction.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/java/fr/ifremer/echobase/ui/validators/EchoBaseFieldValidatorSupport.java
trunk/echobase-ui/src/main/resources/config/struts-user.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -42,7 +42,7 @@
* EchoBase configuration
*
* @author chemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class EchoBaseConfiguration {
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -34,7 +34,8 @@
/**
* All EchoBase configuration options.
*
- * @since 1.0
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
*/
public enum EchoBaseConfigurationOption implements ApplicationConfig.OptionDef {
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTechnicalException.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTechnicalException.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTechnicalException.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -23,6 +23,10 @@
*/
package fr.ifremer.echobase;
+/**
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
public class EchoBaseTechnicalException extends RuntimeException {
private static final long serialVersionUID = 1L;
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -41,6 +41,10 @@
import java.util.Properties;
import java.util.Set;
+/**
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
public class EchoBaseTopiaRootContextSupplierFactory {
/** Logger. */
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/EchoBaseObjectFactory.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -41,7 +41,7 @@
* To obtain services.
*
* @author chemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class EchoBaseObjectFactory {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -26,7 +26,8 @@
import org.nuiton.topia.TopiaContext;
/**
- * @author sletellier
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
*/
public class AbstractEchoBaseService implements EchoBaseService {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -24,6 +24,10 @@
package fr.ifremer.echobase.services;
+/**
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
public interface EchoBaseService {
void setServiceContext(EchoBaseServiceContext serviceContext);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -31,6 +31,9 @@
* 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)}
+ *
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
*/
public interface EchoBaseServiceContext {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -27,7 +27,11 @@
import fr.ifremer.echobase.EchoBaseConfiguration;
import org.nuiton.topia.TopiaContext;
-/** Instances of this class will be given to service factory. */
+/** Instances of this class will be given to service factory.
+ *
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
+ **/
public class EchoBaseServiceContextImpl implements EchoBaseServiceContext {
protected TopiaContext transaction;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -26,9 +26,12 @@
import fr.ifremer.echobase.EchoBaseTechnicalException;
import java.lang.reflect.InvocationTargetException;
+/**
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
+ **/
+ public class EchoBaseServiceFactory {
-public class EchoBaseServiceFactory {
-
public <E extends EchoBaseService> E newService(Class<E> clazz, EchoBaseServiceContext serviceContext) {
// instantiate service using empty constructor
E service;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInitializable.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInitializable.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInitializable.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -23,7 +23,10 @@
*/
package fr.ifremer.echobase.services;
-
+/**
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
+ **/
import fr.ifremer.echobase.EchoBaseObjectFactory;
/**
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInjectable.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInjectable.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceInjectable.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -27,7 +27,7 @@
* Contract for service which need an injections.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public interface EchoBaseServiceInjectable {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSingleton.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSingleton.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSingleton.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -32,7 +32,7 @@
* A shared service will be keep as a singleton in the {@link EchoBaseObjectFactory}.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public interface EchoBaseServiceSingleton {
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/IOCService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/IOCService.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/IOCService.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -43,7 +43,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see Injector
- * @since 1.0
+ * @since 0.1
*/
public class IOCService implements EchoBaseServiceInitializable, EchoBaseServiceSingleton {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -35,7 +35,10 @@
import java.util.List;
-/** @author sletellier */
+/**
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
+ **/
public class UserService extends AbstractEchoBaseService {
public EchoBaseUserDAO getDAO() throws TopiaException {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/AbstractInjector.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/AbstractInjector.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/AbstractInjector.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -38,7 +38,7 @@
* Abstract injector with some useful logi.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public abstract class AbstractInjector<A extends Annotation, B> implements Injector<A, B> {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectDAO.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectDAO.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectDAO.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -36,7 +36,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see InjectorDAO
- * @since 1.0
+ * @since 0.1
*/
@Retention(RUNTIME)
@Target(FIELD)
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntitiesById.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntitiesById.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntitiesById.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -36,7 +36,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see InjectorEntitiesById
- * @since 1.0
+ * @since 0.1
*/
@Retention(RUNTIME)
@Target(FIELD)
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntityById.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntityById.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectEntityById.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -36,7 +36,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see InjectorEntityById
- * @since 1.0
+ * @since 0.1
*/
@Retention(RUNTIME)
@Target(FIELD)
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectFromDAO.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectFromDAO.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectFromDAO.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -36,7 +36,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see InjectorFromDAO
- * @since 1.0
+ * @since 0.1
*/
@Retention(RUNTIME)
@Target(FIELD)
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/Injector.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/Injector.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/Injector.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -35,7 +35,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see IOCService
- * @since 1.0
+ * @since 0.1
*/
public interface Injector<A extends Annotation, B> extends EchoBaseServiceInitializable {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorDAO.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorDAO.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorDAO.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -36,7 +36,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see InjectDAO
- * @since 1.0
+ * @since 0.1
*/
public class InjectorDAO extends AbstractInjector<InjectDAO, TopiaTransactionAware> {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntitiesById.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntitiesById.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntitiesById.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -40,7 +40,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see InjectEntitiesById
- * @since 1.0
+ * @since 0.1
*/
public class InjectorEntitiesById extends AbstractInjector<InjectEntitiesById, TopiaTransactionAware> {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntityById.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntityById.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorEntityById.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -37,8 +37,8 @@
* Fires the {@link InjectEntityById} annotation.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
* @see InjectEntityById
+ * @since 0.1
*/
public class InjectorEntityById extends AbstractInjector<InjectEntityById, TopiaTransactionAware> {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorFromDAO.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorFromDAO.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ioc/InjectorFromDAO.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -41,7 +41,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see InjectFromDAO
- * @since 1.0
+ * @since 0.1
*/
public class InjectorFromDAO extends AbstractInjector<InjectFromDAO, TopiaTransactionAware> {
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -66,7 +66,7 @@
* On stop, just release the application configuration.
*
* @author chemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class ApplicationListener implements ServletContextListener {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -27,6 +27,10 @@
import fr.ifremer.echobase.EchoBaseConfiguration;
import org.nuiton.topia.TopiaContext;
+/**
+ * @author chemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
public class EchoBaseApplicationContext {
protected EchoBaseConfiguration configuration;
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -34,7 +34,7 @@
* The session object of EchoBase to put in servlet session.
*
* @author chemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class 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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -48,7 +48,7 @@
* untranslated key.
*
* @author chemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class EchoBaseActionSupport extends BaseAction implements TopiaTransactionAware {
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/HomeAction.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -28,7 +28,7 @@
* To go to the home page.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class HomeAction extends EchoBaseActionSupport {
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -39,7 +39,7 @@
* Login and Logout action.
*
* @author chemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class LoginAction extends EchoBaseActionSupport implements SessionAware {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -1,20 +1,17 @@
package fr.ifremer.echobase.ui.actions;
-import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EchoBaseUserDAO;
import fr.ifremer.echobase.entities.EchoBaseUserDTO;
import fr.ifremer.echobase.services.UserService;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.TopiaException;
import java.util.ArrayList;
import java.util.List;
/**
- * @author sletellier
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
*/
public class UserAction extends EchoBaseActionSupport {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/AbstractCheckInterceptor.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/AbstractCheckInterceptor.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/AbstractCheckInterceptor.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -36,7 +36,7 @@
* Abstract check interceptor.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public abstract class AbstractCheckInterceptor extends AbstractInterceptor {
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -40,7 +40,7 @@
*
* @author chemit <chemit(a)codelutin.com>
* @see EchoBaseSession
- * @since 1.0
+ * @since 0.1
*/
public class CheckInUserSessionInterceptor extends AbstractCheckInterceptor {
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -33,7 +33,7 @@
* To check user is loggued. If not, then redirect to the {@link #loginAction}.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class CheckLogguedInterceptor extends AbstractCheckInterceptor {
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckUserIsAdmin.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -33,7 +33,7 @@
* To check if logged user is admin.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class CheckUserIsAdmin extends AbstractCheckInterceptor {
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CleanEchoBaseSessionInterceptor.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -39,7 +39,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see EchoBaseSession
- * @since 1.0
+ * @since 0.1
*/
public class CleanEchoBaseSessionInterceptor extends AbstractInterceptor {
private static final long serialVersionUID = 1L;
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-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -37,7 +37,7 @@
* create a new topia transaction on a EchoBase database.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class EchoBaseTransactionInterceptorImpl extends OpenTopiaTransactionInterceptor {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/EchoBaseFieldValidatorSupport.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/EchoBaseFieldValidatorSupport.java 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/EchoBaseFieldValidatorSupport.java 2011-11-07 10:46:58 UTC (rev 15)
@@ -31,7 +31,7 @@
* Base T3 validator.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public abstract class EchoBaseFieldValidatorSupport extends NuitonFieldValidatorSupport {
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-07 10:46:58 UTC (rev 15)
@@ -52,7 +52,7 @@
<interceptor-ref name="basicStack"/>
</action>
- <!-- Display lists of users -->
+ <!-- display lists of users -->
<action name="userList" class="fr.ifremer.echobase.ui.actions.UserAction">
<interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="checkUserIsAdmin"/>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp 2011-11-07 10:32:04 UTC (rev 14)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp 2011-11-07 10:46:58 UTC (rev 15)
@@ -42,6 +42,7 @@
href="%{userListUrl}"
pager="false"
navigator="true"
+ rowNum="-1"
navigatorAddOptions="{
height:280,
reloadAfterSubmit:true,
@@ -89,7 +90,7 @@
editable="true"
edittype="password"
hidden="true"/>
- gridModel
+
<sjg:gridColumn name="admin"
title='%{getText("echobase.common.admin")}'
sortable="true"
1
0
r14 - in trunk/echobase-ui/src/main: java/fr/ifremer/echobase/ui java/fr/ifremer/echobase/ui/actions java/fr/ifremer/echobase/ui/validators resources/config resources/i18n
by tchemit@users.forge.codelutin.com 07 Nov '11
by tchemit@users.forge.codelutin.com 07 Nov '11
07 Nov '11
Author: tchemit
Date: 2011-11-07 11:32:04 +0100 (Mon, 07 Nov 2011)
New Revision: 14
Url: http://forge.codelutin.com/repositories/revision/echobase/14
Log:
fix login + clean ui classes
Added:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/
Modified:
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/validators/LoginValidator.java
trunk/echobase-ui/src/main/resources/config/struts-user.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
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-07 10:30:22 UTC (rev 13)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-07 10:32:04 UTC (rev 14)
@@ -23,7 +23,6 @@
*/
package fr.ifremer.echobase.ui;
-import fr.ifremer.echobase.EchoBaseObjectFactory;
import fr.ifremer.echobase.entities.EchoBaseUser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,46 +41,6 @@
/** 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;
-// }
-
-// /**
-// * 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";
-
- /** Key to set EchoBase factory in this session. */
- protected static final String PROPERTY_OBJECT_FACTORY = "objectFactory";
-
/** Key to set User connected in this session. */
protected static final String PROPERTY_ECHO_BASE_USER = "echobaseUser";
@@ -89,24 +48,6 @@
protected Map<String, Object> store;
/**
- * Gets the object factory dedicated for this user.
- *
- * @return the user's object factory or {@code null} if not in session
- */
- public EchoBaseObjectFactory getObjectFactory() {
- return get(PROPERTY_OBJECT_FACTORY, EchoBaseObjectFactory.class);
- }
-
- /**
- * Sets in this session the object factory.
- *
- * @param objectFactory the new object factory to use in this session
- */
- public void setObjectFactory(EchoBaseObjectFactory objectFactory) {
- set(PROPERTY_OBJECT_FACTORY, objectFactory);
- }
-
- /**
* Gets the informations of user as soon as the user is loggued.
*
* @return the informations of loggued user or {@code null} if not in session
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-07 10:30:22 UTC (rev 13)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-07 10:32:04 UTC (rev 14)
@@ -23,15 +23,12 @@
*/
package fr.ifremer.echobase.ui.actions;
-import com.google.common.base.Preconditions;
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 org.nuiton.topia.TopiaContext;
@@ -122,13 +119,6 @@
return getEchoBaseApplicationContext().getConfiguration().getApplicationVersion().toString();
}
- public EchoBaseObjectFactory getServiceFactory() {
- Preconditions.checkNotNull(echoBaseSession,
- "No echo base user session injected.");
- EchoBaseObjectFactory factory = echoBaseSession.getObjectFactory();
- return factory;
- }
-
/**
* Fabrique pour récupérer le ServiceContext tel qu'il devrait être fourni
* à la fabrication d'un service.
@@ -162,18 +152,6 @@
this.transaction = transaction;
}
- public IOCService getIocService() {
- return getServiceFactory().newService(IOCService.class);
- }
-
- protected void injectExcept(Class<?>... annotations) throws Exception {
- getIocService().injectExcept(this, annotations);
- }
-
- protected void injectOnly(Class<?>... annotations) throws Exception {
- getIocService().injectOnly(this, annotations);
- }
-
public String formatDate(Date date) {
String result = getDateFormat().format(date);
return result;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java 2011-11-07 10:30:22 UTC (rev 13)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java 2011-11-07 10:32:04 UTC (rev 14)
@@ -32,7 +32,7 @@
* Check user login.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
+ * @since 0.1
*/
public class LoginValidator extends EchoBaseFieldValidatorSupport {
@@ -42,7 +42,7 @@
UserService userService =
(UserService) getFieldValue("userService", object);
- String login = (String) getFieldValue("login", object);
+ String login = (String) getFieldValue("email", object);
String password = (String) getFieldValue("password", object);
if (log.isInfoEnabled()) {
@@ -56,14 +56,14 @@
if (user == null) {
// user not found
- addFieldError("login", _("t3.error.login.unknown"));
+ addFieldError("email", _("echobase.error.login.unknown"));
return;
}
boolean passwordOk = userService.checkPassword(user, password);
if (!passwordOk) {
- addFieldError("password", _("t3.error.bad.password"));
+ addFieldError("password", _("echobase.error.bad.password"));
}
} catch (Exception e) {
if (log.isErrorEnabled()) {
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-07 10:30:22 UTC (rev 13)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-07 10:32:04 UTC (rev 14)
@@ -38,8 +38,7 @@
<result name="input">/WEB-INF/jsp/user/login.jsp</result>
<result name="error">/WEB-INF/jsp/user/login.jsp</result>
<result name="redirect" type="redirect">${redirectAction}</result>
- <interceptor-ref name="topiaTransaction"/>
- <interceptor-ref name="basicStack"/>
+ <interceptor-ref name="echoBaseParamsPrepareParamsStack"/>
</action>
<!-- logout action -->
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-07 10:30:22 UTC (rev 13)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-07 10:32:04 UTC (rev 14)
@@ -6,6 +6,8 @@
echobase.common.email=Email
echobase.common.password=Mot de passe
echobase.common.save=Sauvegarder
+echobase.error.bad.password=Mot de passe incorrrect
+echobase.error.login.unknown=Utilisateur inconnu
echobase.export.queryDescription=Description
echobase.export.queryName=Nom
echobase.export.querySql=SQL
@@ -27,5 +29,3 @@
echobase.title.login=Connection
echobase.title.users=Adminitration des utilisateurs
echobase.user.gridTitle=Liste des utilisateurs
-t3.error.bad.password=
-t3.error.login.unknown=
1
0
07 Nov '11
Author: sletellier
Date: 2011-11-07 11:30:22 +0100 (Mon, 07 Nov 2011)
New Revision: 13
Url: http://forge.codelutin.com/repositories/revision/echobase/13
Log:
- Dont return dtos in service
- Clean project
- Fix traductions
- Debug user page
- Remove hasActionError and hasActionMessages
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.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/webapp/WEB-INF/decorators/layout-default.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-07 10:30:22 UTC (rev 13)
@@ -1,3 +1,26 @@
+/*
+ * #%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 org.nuiton.topia.TopiaContext;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-07 10:30:22 UTC (rev 13)
@@ -1,3 +1,26 @@
+/*
+ * #%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;
@@ -10,7 +33,6 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.util.StringUtil;
-import java.util.ArrayList;
import java.util.List;
/** @author sletellier */
@@ -20,26 +42,21 @@
return EchoBaseDAOHelper.getEchoBaseUserDAO(getTransaction());
}
- public List<EchoBaseUserDTO> getUsers() throws EchoBaseTechnicalException {
+ public List<EchoBaseUser> getUsers() throws EchoBaseTechnicalException {
try {
List<EchoBaseUser> users = getDAO().findAll();
- // Fill dtos
- List<EchoBaseUserDTO> usersDtos = new ArrayList<EchoBaseUserDTO>(users.size());
- for (EchoBaseUser user : users) {
- usersDtos.add(user.toDTO());
- }
- return usersDtos;
+ return users;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
}
}
- public EchoBaseUserDTO getUserById(String topiaId) {
+ public EchoBaseUser getUserById(String topiaId) {
try {
EchoBaseUser user = getDAO().findByTopiaId(topiaId);
- return user.toDTO();
+ return user;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
}
@@ -82,18 +99,18 @@
}
}
- public EchoBaseUserDTO getUserByEmail(String email) {
+ public EchoBaseUser getUserByEmail(String email) {
Preconditions.checkNotNull(email);
try {
EchoBaseUserDAO dao = getDAO();
EchoBaseUser user = dao.findByEmail(email);
- return user.toDTO();
+ return user;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
}
}
- public boolean checkPassword(EchoBaseUserDTO user,
+ public boolean checkPassword(EchoBaseUser user,
String password) throws Exception {
String s = encodePassword(password);
return s.equals(user.getPassword());
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 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java 2011-11-07 10:30:22 UTC (rev 13)
@@ -27,6 +27,7 @@
import fr.ifremer.echobase.EchoBaseConfiguration;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory;
+import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.EchoBaseUserDTO;
import fr.ifremer.echobase.entities.EchoBaseUserDTOImpl;
import fr.ifremer.echobase.entities.EchoBaseUserImpl;
@@ -181,7 +182,7 @@
* Creates the adminsitrator ({@code admin/admin}) on the internal
* database.
*
- * @param configuration
+ * @param configuration EchoBase configuration
* @throws TopiaException if could not create the user.
*/
protected void createAdminUser(EchoBaseConfiguration configuration) throws TopiaException {
@@ -199,7 +200,7 @@
UserService service = serviceFactory.newService(UserService.class, serviceContext);
- List<EchoBaseUserDTO> users = service.getUsers();
+ List<EchoBaseUser> users = service.getUsers();
if (CollectionUtils.isEmpty(users)) {
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 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-07 10:30:22 UTC (rev 13)
@@ -25,8 +25,7 @@
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.interceptor.I18nInterceptor;
-import fr.ifremer.echobase.entities.EchoBaseUserDTO;
-import fr.ifremer.echobase.entities.EchoBaseUserImpl;
+import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.services.UserService;
import fr.ifremer.echobase.ui.EchoBaseSession;
import org.apache.commons.logging.Log;
@@ -91,14 +90,12 @@
public String doLogin() throws Exception {
- EchoBaseUserDTO user = getUserService().getUserByEmail(email);
+ EchoBaseUser user = getUserService().getUserByEmail(email);
EchoBaseSession userSession = getEchoBaseSession();
// user is authorized, keep it in his echoBaseSession
- EchoBaseUserImpl echoBaseUser = new EchoBaseUserImpl();
- echoBaseUser.fromDTO(user);
- userSession.setEchoBaseUser(echoBaseUser);
+ userSession.setEchoBaseUser(user);
// add locale in echoBaseSession if required
Object o = session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE);
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java 2011-11-07 10:30:22 UTC (rev 13)
@@ -1,8 +1,16 @@
package fr.ifremer.echobase.ui.actions;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EchoBaseUserDAO;
import fr.ifremer.echobase.entities.EchoBaseUserDTO;
import fr.ifremer.echobase.services.UserService;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -12,8 +20,113 @@
private static final long serialVersionUID = 1L;
+ protected static final Log log = LogFactory.getLog(UserAction.class);
+
protected transient UserService service;
+ // Grid model
+ protected List<EchoBaseUserDTO> userList;
+ protected EchoBaseUserDTO selectedUserDto;
+
+ //get how many rows we want to have into the grid - rowNum attribute in the grid
+ protected Integer rows = 0;
+ //Get the requested page. By default grid sets this to 1.
+ protected Integer page = 0;
+ // sorting order - asc or desc
+ protected String sord;
+ // get index row - i.e. user click to sort.
+ protected String sidx;
+ // Search Field
+ protected String searchField;
+ // The Search String
+ protected String searchString;
+ // he Search Operation ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']
+ protected String searchOper;
+ // Your Total Pages
+ protected Integer total = 0;
+ // All Record
+ protected Integer records = 0;
+
+ public EchoBaseUserDTO getSelectedUserDto() {
+ return selectedUserDto;
+ }
+
+ public void setSelectedUserDto(EchoBaseUserDTO selectedUserDto) {
+ this.selectedUserDto = selectedUserDto;
+ }
+
+ public Integer getRows() {
+ return rows;
+ }
+
+ public void setRows(Integer rows) {
+ this.rows = rows;
+ }
+
+ public Integer getPage() {
+ return page;
+ }
+
+ public void setPage(Integer page) {
+ this.page = page;
+ }
+
+ public String getSord() {
+ return sord;
+ }
+
+ public void setSord(String sord) {
+ this.sord = sord;
+ }
+
+ public String getSidx() {
+ return sidx;
+ }
+
+ public void setSidx(String sidx) {
+ this.sidx = sidx;
+ }
+
+ public String getSearchField() {
+ return searchField;
+ }
+
+ public void setSearchField(String searchField) {
+ this.searchField = searchField;
+ }
+
+ public String getSearchString() {
+ return searchString;
+ }
+
+ public void setSearchString(String searchString) {
+ this.searchString = searchString;
+ }
+
+ public String getSearchOper() {
+ return searchOper;
+ }
+
+ public void setSearchOper(String searchOper) {
+ this.searchOper = searchOper;
+ }
+
+ public Integer getTotal() {
+ return total;
+ }
+
+ public void setTotal(Integer total) {
+ this.total = total;
+ }
+
+ public Integer getRecords() {
+ return records;
+ }
+
+ public void setRecords(Integer records) {
+ this.records = records;
+ }
+
protected UserService getService() {
if (service == null) {
service = newService(UserService.class);
@@ -22,14 +135,42 @@
}
public List<EchoBaseUserDTO> getUserList() {
- return getService().getUsers();
+ return userList;
}
- public void createOrUpdate(EchoBaseUserDTO userDTO) {
- getService().createOrUpdate(userDTO);
+ public void setUserList(List<EchoBaseUserDTO> userList) {
+ this.userList = userList;
}
- public void delete(EchoBaseUserDTO userDTO) {
- getService().delete(userDTO);
+ @Override
+ public String execute() throws Exception {
+
+ List<EchoBaseUser> users = getService().getUsers();
+
+ // Fill dtos
+ int size = users.size();
+ setRecords(size);
+
+ //calculate the total pages for the query
+ setTotal((int) Math.ceil((double) getRecords() / (double) getRows()));
+ List<EchoBaseUserDTO> userList = new ArrayList<EchoBaseUserDTO>(size);
+ for (EchoBaseUser user : users) {
+ userList.add(user.toDTO());
+ }
+ log.info(size + " users founds");
+
+ setUserList(userList);
+
+ return super.execute();
}
+
+ public String createOrUpdate() throws Exception {
+ getService().createOrUpdate(selectedUserDto);
+ return SUCCESS;
+ }
+
+ public String delete() throws Exception {
+ getService().delete(selectedUserDto);
+ return SUCCESS;
+ }
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java 2011-11-07 10:30:22 UTC (rev 13)
@@ -24,6 +24,7 @@
package fr.ifremer.echobase.ui.validators;
import com.opensymphony.xwork2.validator.ValidationException;
+import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.EchoBaseUserDTO;
import fr.ifremer.echobase.services.UserService;
@@ -50,7 +51,7 @@
try {
// check in db that user is ok
- EchoBaseUserDTO user = userService.getUserByEmail(login);
+ EchoBaseUser user = userService.getUserByEmail(login);
if (user == null) {
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-07 10:30:22 UTC (rev 13)
@@ -53,25 +53,32 @@
<interceptor-ref name="basicStack"/>
</action>
- <!-- get lists of users -->
+ <!-- Display lists of users -->
<action name="userList" class="fr.ifremer.echobase.ui.actions.UserAction">
<interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="checkUserIsAdmin"/>
- <result name="input">/WEB-INF/jsp/user/users.jsp</result>
+ <result name="success">/WEB-INF/jsp/user/users.jsp</result>
</action>
+ <!-- get lists of users -->
+ <action name="userListData" class="fr.ifremer.echobase.ui.actions.UserAction">
+ <interceptor-ref name="basicStackLoggued"/>
+ <interceptor-ref name="checkUserIsAdmin"/>
+ <result name="success" type="json"/>
+ </action>
+
<!-- update or create (if not exist) user -->
- <action name="createOrUpdate" class="fr.ifremer.echobase.ui.actions.UserAction">
+ <action name="createOrUpdate" method="createOrUpdate" class="fr.ifremer.echobase.ui.actions.UserAction">
<interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="checkUserIsAdmin"/>
- <result name="input">/WEB-INF/jsp/user/users.jsp</result>
+ <result name="success">/WEB-INF/jsp/user/users.jsp</result>
</action>
<!-- delete user -->
- <action name="delete" class="fr.ifremer.echobase.ui.actions.UserAction">
+ <action name="delete" method="delete" class="fr.ifremer.echobase.ui.actions.UserAction">
<interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="checkUserIsAdmin"/>
- <result name="input">/WEB-INF/jsp/user/users.jsp</result>
+ <result name="success">/WEB-INF/jsp/user/users.jsp</result>
</action>
</package>
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-07 10:30:22 UTC (rev 13)
@@ -13,6 +13,7 @@
echobase.label.locale.english=Anglais
echobase.label.locale.french=Français
echobase.label.login=Connection
+echobase.label.user.login=Utilisateur \: %s
echobase.label.welcome=Bienvenue
echobase.menu.export=Exports
echobase.menu.import=Imports
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2011-11-07 10:30:22 UTC (rev 13)
@@ -41,17 +41,18 @@
<div id="body">
- <s:if test="hasActionMessages()">
- <div class="info_success">
- <s:actionmessage/>
- </div>
- </s:if>
+ <%-- TODO sletellier 20111104 : add this --%>
+ <%--<s:if test="hasActionMessages()">--%>
+ <%--<div class="info_success">--%>
+ <%--<s:actionmessage/>--%>
+ <%--</div>--%>
+ <%--</s:if>--%>
- <s:if test="hasActionErrors()">
- <div class="info_error">
- <s:actionerror/>
- </div>
- </s:if>
+ <%--<s:if test="hasActionErrors()">--%>
+ <%--<div class="info_error">--%>
+ <%--<s:actionerror/>--%>
+ <%--</div>--%>
+ <%--</s:if>--%>
<d:body/>
</div>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2011-11-07 10:30:22 UTC (rev 13)
@@ -32,9 +32,9 @@
<div id='headerRight'>
<div>
<s:text name="echobase.label.user.login">
- <%--<s:param>--%>
- <%--<s:property value="#session.echoBaseSession.echoBaseUser.login"/>--%>
- <%--</s:param>--%>
+ <s:param>
+ <s:property value="#session.echoBaseSession.echoBaseUser.email"/>
+ </s:param>
</s:text>
<ul>
<li>
@@ -45,9 +45,9 @@
</ul>
</div>
<br/>
- <%@ include file="menu.jsp" %>
- <%@ include file="i18n.jsp" %>
+ <%@ include file="i18n.jsp" %>
<br/>
</div>
+ <%@ include file="menu.jsp" %>
</div>
<hr/>
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 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp 2011-11-07 10:30:22 UTC (rev 13)
@@ -36,7 +36,7 @@
<%--<s:if--%>
<%--test="%{userIsAdmin}">--%>
<li>
- <s:a namespace="admin" action="users"><s:text name="echobase.menu.users"/></s:a>
+ <s:a action="userList" namespace="/user"><s:text name="echobase.menu.users"/></s:a>
</li>
<%--</s:if>--%>
</ul>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp 2011-11-07 10:30:22 UTC (rev 13)
@@ -21,7 +21,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
#L%
--%>
-<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
@@ -32,14 +32,15 @@
<hr/>
-<s:url id="userListUrl" namespace="/users" action="userList"/>
-<s:url id="saveUrl" namespace="/users" action="createOrUpdate" />
+<s:url id="userListUrl" namespace="/user" action="userListData"/>
+<s:url id="saveUrl" namespace="/user" action="createOrUpdate"/>
<sjg:grid id="usersList"
caption='%{getText("echobase.user.gridTitle")}'
dataType="json"
+ title="%{getText('echobase.user.gridTitle')}"
href="%{userListUrl}"
- pager="true"
+ pager="false"
navigator="true"
navigatorAddOptions="{
height:280,
@@ -64,9 +65,7 @@
return isError(response.responseText);
}
}"
- gridModel="gridModel"
- rowList="10,100,1000"
- rowNum="10"
+ gridModel="userList"
editurl="%{saveUrl}"
editinline="false"
rownumbers="true"
@@ -75,6 +74,7 @@
viewrecords="true">
<sjg:gridColumn name="id"
+ title='id'
key="true"
hidden="true"/>
@@ -89,7 +89,7 @@
editable="true"
edittype="password"
hidden="true"/>
-
+ gridModel
<sjg:gridColumn name="admin"
title='%{getText("echobase.common.admin")}'
sortable="true"
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml 2011-11-04 14:01:05 UTC (rev 12)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml 2011-11-07 10:30:22 UTC (rev 13)
@@ -30,16 +30,14 @@
<display-name>EchoBase</display-name>
<filter>
- <filter-name>struts-prepare</filter-name>
- <filter-class>
- org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
- </filter-class>
+ <filter-name>topiaCloseTransaction</filter-name>
+ <filter-class>org.nuiton.web.struts2.filter.CloseTopiaTransactionFilter</filter-class>
</filter>
<filter>
- <filter-name>struts-execute</filter-name>
+ <filter-name>struts-prepare</filter-name>
<filter-class>
- org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
+ org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
</filter-class>
</filter>
@@ -49,27 +47,29 @@
</filter>
<filter>
- <filter-name>topiaCloseTransaction</filter-name>
- <filter-class>org.nuiton.web.struts2.filter.CloseTopiaTransactionFilter</filter-class>
+ <filter-name>struts-execute</filter-name>
+ <filter-class>
+ org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
+ </filter-class>
</filter>
<filter-mapping>
- <filter-name>struts-prepare</filter-name>
+ <filter-name>topiaCloseTransaction</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
- <filter-name>sitemesh</filter-name>
+ <filter-name>struts-prepare</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
- <filter-name>struts-execute</filter-name>
+ <filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
- <filter-name>topiaCloseTransaction</filter-name>
+ <filter-name>struts-execute</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
1
0
04 Nov '11
Author: tchemit
Date: 2011-11-04 15:01:05 +0100 (Fri, 04 Nov 2011)
New Revision: 12
Url: http://forge.codelutin.com/repositories/revision/echobase/12
Log:
login service + others
Added:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/EchoBaseFieldValidatorSupport.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java
trunk/echobase-ui/src/main/resources/echobase.properties
trunk/echobase-ui/src/main/resources/fr/
trunk/echobase-ui/src/main/resources/fr/ifremer/
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/LoginAction-login-validation.xml
trunk/echobase-ui/src/main/resources/validators.xml
Removed:
trunk/echobase-ui/web/
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserImpl.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
trunk/echobase-ui/pom.xml
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.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/actions/UserAction.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
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-04 12:50:20 UTC (rev 11)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-04 14:01:05 UTC (rev 12)
@@ -108,6 +108,11 @@
return klass;
}
+ public boolean isEmbedded() {
+ Class<?> driverClass = getDriverClass();
+ return driverClass.getSimpleName().toLowerCase().contains("h2");
+ }
+
/**
* Creates a directory given the configuration given key.
*
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserImpl.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserImpl.java 2011-11-04 12:50:20 UTC (rev 11)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserImpl.java 2011-11-04 14:01:05 UTC (rev 12)
@@ -38,7 +38,7 @@
EchoBaseUserDTO dto = new EchoBaseUserDTOImpl();
dto.setAdmin(isAdmin());
dto.setEmail(getEmail());
- dto.setPassword(getPassword());
+// dto.setPassword(getPassword());
dto.setId(getTopiaId());
return dto;
}
@@ -47,7 +47,7 @@
public void fromDTO(EchoBaseUserDTO dto) {
setAdmin(dto.isAdmin());
setEmail(dto.getEmail());
- setPassword(dto.getPassword());
+// setPassword(dto.getPassword());
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-04 12:50:20 UTC (rev 11)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-04 14:01:05 UTC (rev 12)
@@ -1,18 +1,19 @@
package fr.ifremer.echobase.services;
+import com.google.common.base.Preconditions;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.EchoBaseUserDAO;
import fr.ifremer.echobase.entities.EchoBaseUserDTO;
+import org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.TopiaException;
+import org.nuiton.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
-/**
- * @author sletellier
- */
+/** @author sletellier */
public class UserService extends AbstractEchoBaseService {
public EchoBaseUserDAO getDAO() throws TopiaException {
@@ -58,7 +59,13 @@
}
user.fromDTO(userDTO);
+ String password = userDTO.getPassword();
+ if (StringUtils.isNotEmpty(password)) {
+ user.setPassword(encodePassword(password));
+ }
dao.update(user);
+
+ getTransaction().commitTransaction();
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
}
@@ -74,4 +81,26 @@
throw new EchoBaseTechnicalException(eee);
}
}
+
+ public EchoBaseUserDTO getUserByEmail(String email) {
+ Preconditions.checkNotNull(email);
+ try {
+ EchoBaseUserDAO dao = getDAO();
+ EchoBaseUser user = dao.findByEmail(email);
+ return user.toDTO();
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+
+ public boolean checkPassword(EchoBaseUserDTO user,
+ String password) throws Exception {
+ String s = encodePassword(password);
+ return s.equals(user.getPassword());
+ }
+
+ public static String encodePassword(String password) {
+ String encodedPassword = StringUtil.encodeMD5(password);
+ return encodedPassword;
+ }
}
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2011-11-04 12:50:20 UTC (rev 11)
+++ trunk/echobase-ui/pom.xml 2011-11-04 14:01:05 UTC (rev 12)
@@ -43,11 +43,11 @@
<artifactId>nuiton-struts2</artifactId>
</dependency>
- <!--dependency>
+ <dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-validator</artifactId>
<scope>compile</scope>
- </dependency-->
+ </dependency>
<!-- struts 2 -->
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 12:50:20 UTC (rev 11)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java 2011-11-04 14:01:05 UTC (rev 12)
@@ -25,24 +25,36 @@
import com.google.common.base.Supplier;
import fr.ifremer.echobase.EchoBaseConfiguration;
-import fr.ifremer.echobase.EchoBaseObjectFactory;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory;
+import fr.ifremer.echobase.entities.EchoBaseUserDTO;
+import fr.ifremer.echobase.entities.EchoBaseUserDTOImpl;
+import fr.ifremer.echobase.entities.EchoBaseUserImpl;
+import fr.ifremer.echobase.services.EchoBaseServiceContext;
+import fr.ifremer.echobase.services.EchoBaseServiceContextImpl;
+import fr.ifremer.echobase.services.EchoBaseServiceFactory;
+import fr.ifremer.echobase.services.UserService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import fr.ird.converter.FloatConverter;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.Converter;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.framework.TopiaUtil;
import org.nuiton.util.converter.ConverterUtil;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.Date;
+import java.util.List;
import java.util.Locale;
+import java.util.Properties;
/**
* To listen start or end of the application.
@@ -90,9 +102,6 @@
new EchoBaseTopiaRootContextSupplierFactory();
rootContextSupplier = factory.newDatabaseFromConfig(configuration);
applicationContext.setRootContextSupplier(rootContextSupplier);
-
- // attach configuration to service factory
- EchoBaseObjectFactory.setConfiguration(configuration);
// register our not locale dependant converter
Converter converter = ConverterUtil.getConverter(Float.class);
@@ -101,161 +110,136 @@
}
ConvertUtils.register(new FloatConverter(), Float.class);
- // obtain a new service factory
- EchoBaseObjectFactory serviceFactory = EchoBaseObjectFactory.newInstance();
-
// init database (and create minimal admin user if required)
-
-// initInternalDatabase(serviceFactory, configuration);
+ try {
+ boolean schemaExist = isSchemaCreated();
+ if (!schemaExist) {
+
+ updateSchema(configuration);
+ }
+
+ createAdminUser(configuration);
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not init db", e);
+ }
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
+
if (log.isInfoEnabled()) {
log.info("Application is ending at " + new Date() + "...");
}
- EchoBaseObjectFactory.destroy();
+ if (rootContextSupplier != null) {
+ if (log.isInfoEnabled()) {
+ log.info("Shuting down RootContextSupplier...");
+ }
+ TopiaContext rootContext = rootContextSupplier.get();
+ if (!rootContext.isClosed()) {
+ try {
+ rootContext.closeContext();
+ } catch (TopiaException te) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not close rootContext", te);
+ }
+ }
+ }
+ }
}
-// /**
-// * Init the internal database, says :
-// * <ul>
-// * <li>If no schema found or if asked to updateSchema using the
-// * {@code updateSchema} configuration option is on.</li>
-// * <li>If no user found is db, create a administrator user
-// * {@code admin/admin}</li>
-// * </ul>
-// *
-// * @param serviceFactory the service factory to use
-// * @param configuration application configuration.
-// */
-// protected void initInternalDatabase(EchoBaseObjectFactory serviceFactory,
-// T3Configuration configuration) {
-//
-// DatabaseService databaseService =
-// serviceFactory.newService(DatabaseService.class);
-//
-// try {
-// boolean schemaNeedUpdate = !isInternalSchemaCreated(databaseService) ||
-// configuration.getOptionAsBoolean("updateSchema");
-//
-// if (schemaNeedUpdate) {
-//
-// updateInternalSchema(databaseService);
-// }
-// } catch (Exception e) {
-// throw new IllegalStateException("could not start db", e);
-// }
-//
-// try {
-// createAdminUser(serviceFactory, databaseService);
-//
-// } catch (Exception e) {
-// throw new IllegalStateException(
-// "could not create default admin user", e);
-// }
-// }
+ protected void updateSchema(EchoBaseConfiguration configuration) throws TopiaException {
+ if (log.isInfoEnabled()) {
+ log.info("Will create or update schema for db.");
+ }
+ // must create the schema
-// /**
-// * Updates the schema of the internal database.
-// *
-// * @param databaseService data service used to obtain transactions of db
-// * @throws TopiaException if something was wrong while schema update
-// */
-// protected void updateInternalSchema(DatabaseService databaseService) throws TopiaException {
-// if (log.isInfoEnabled()) {
-// log.info("Will create or update schema for db.");
-// }
-// // must create the schema
-//
-// Properties dbConf =
-// databaseService.getInternalDatabaseConfiguration();
-//
-// dbConf.put("hibernate.hbm2ddl.auto", "update");
-//
-// // start a connexion to load schema
-// TopiaContext tx = null;
-//
-// try {
-// tx = databaseService.beginInternalTransaction();
-//
-// } finally {
-//
-// // no more update of schema...
-// dbConf.put("hibernate.hbm2ddl.auto", "none");
-//
-// closeTransaction(tx);
-// }
-// }
+ Properties dbConf = configuration.getProperties();
-// /**
-// * Creates the adminsitrator ({@code admin/admin}) on the internal
-// * database.
-// *
-// * @param serviceFactory the service factory
-// * @param databaseService the database service used to obtain transactions.
-// * @throws Exception if could not create the user.
-// */
-// protected void createAdminUser(T3ServiceFactory serviceFactory,
-// DatabaseService databaseService) throws Exception {
-//
-// TopiaContext tx = databaseService.beginInternalTransaction();
-// try {
-// UserService service =
-// serviceFactory.newTransactionalService(UserService.class, tx);
-//
-// List<T3User> users = service.getUsers();
-//
-// if (CollectionUtils.isEmpty(users)) {
-//
-// // no users in database create the admin user
-// if (log.isInfoEnabled()) {
-// log.info("No user in database, will create default " +
-// "admin user (password admin).");
-// }
-//
-// T3User u = new T3UserImpl();
-// u.setLogin("admin");
-// u.setPassword("admin");
-// u.setAdmin(true);
-//
-// // store it in db
-// service.createUser(u);
-//
-// }
-// } finally {
-//
-// closeTransaction(tx);
-// }
-// }
+ dbConf.put("hibernate.hbm2ddl.auto", "update");
-// /**
-// * Tests if the internal database schema created.
-// *
-// * @param databaseService the database to obtains transactions on internal
-// * database
-// * @return {@code true} if the schema is already created, {@code false}
-// * otherwise
-// * @throws TopiaException if something was wrong while requesting database
-// */
-// protected boolean isInternalSchemaCreated(DatabaseService databaseService) throws TopiaException {
-//
-// TopiaContextImplementor tx =
-// (TopiaContextImplementor)
-// databaseService.beginInternalTransaction();
-// try {
-// boolean schemaFound = TopiaUtil.isSchemaExist(
-// tx.getHibernateConfiguration(),
-// T3UserImpl.class.getName());
-//
-// return schemaFound;
-//
-// } finally {
-// closeTransaction(tx);
-// }
-// }
+ EchoBaseTopiaRootContextSupplierFactory factory =
+ new EchoBaseTopiaRootContextSupplierFactory();
+ Supplier<TopiaContext> topiaContextSupplier =
+ factory.newDatabaseFromProperties(dbConf);
+ // start a connexion to load schema
+ TopiaContext tx = null;
+
+ try {
+ tx = topiaContextSupplier.get().beginTransaction();
+
+ } finally {
+
+ // no more update of schema...
+ dbConf.put("hibernate.hbm2ddl.auto", "none");
+
+ closeTransaction(tx);
+ }
+ }
+
/**
+ * Creates the adminsitrator ({@code admin/admin}) on the internal
+ * database.
+ *
+ * @param configuration
+ * @throws TopiaException if could not create the user.
+ */
+ protected void createAdminUser(EchoBaseConfiguration configuration) throws TopiaException {
+
+ EchoBaseServiceFactory serviceFactory =
+ new EchoBaseServiceFactory();
+ TopiaContext transaction = rootContextSupplier.get().beginTransaction();
+
+ try {
+ EchoBaseServiceContext serviceContext = new EchoBaseServiceContextImpl(
+ transaction,
+ configuration,
+ serviceFactory
+ );
+
+ UserService service = serviceFactory.newService(UserService.class, serviceContext);
+
+ List<EchoBaseUserDTO> users = service.getUsers();
+
+ if (CollectionUtils.isEmpty(users)) {
+
+ // no users in database create the admin user
+ if (log.isInfoEnabled()) {
+ log.info("No user in database, will create default " +
+ "admin user (password admin).");
+ }
+
+ EchoBaseUserDTO userDTO = new EchoBaseUserDTOImpl();
+ userDTO.setEmail("admin");
+ userDTO.setPassword("admin");
+ userDTO.setAdmin(true);
+ service.createOrUpdate(userDTO);
+ }
+ } finally {
+ transaction.closeContext();
+ }
+
+ }
+
+ protected boolean isSchemaCreated() throws TopiaException {
+
+ TopiaContextImplementor tx =
+ (TopiaContextImplementor)
+ rootContextSupplier.get();
+ try {
+ boolean schemaFound = TopiaUtil.isSchemaExist(
+ tx.getHibernateConfiguration(),
+ EchoBaseUserImpl.class.getName()
+ );
+
+ return schemaFound;
+
+ } finally {
+ closeTransaction(tx);
+ }
+ }
+
+ /**
* Try to close the given transaction.
*
* @param tx the transaction to close
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 12:50:20 UTC (rev 11)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/HomeAction.java 2011-11-04 14:01:05 UTC (rev 12)
@@ -24,8 +24,6 @@
package fr.ifremer.echobase.ui.actions;
-import fr.ifremer.echobase.services.ioc.InjectFromDAO;
-
/**
* To go to the home page.
*
@@ -39,8 +37,7 @@
@Override
public String execute() throws Exception {
- injectOnly(InjectFromDAO.class);
-
+
return SUCCESS;
}
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 12:50:20 UTC (rev 11)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-04 14:01:05 UTC (rev 12)
@@ -25,7 +25,9 @@
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.interceptor.I18nInterceptor;
-import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EchoBaseUserDTO;
+import fr.ifremer.echobase.entities.EchoBaseUserImpl;
+import fr.ifremer.echobase.services.UserService;
import fr.ifremer.echobase.ui.EchoBaseSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -46,30 +48,29 @@
private static final long serialVersionUID = 1L;
- protected boolean logging;
+ protected String email;
- protected String login;
-
protected String password;
protected String redirectAction;
private transient Map<String, Object> session;
- public boolean isLogging() {
- return logging;
- }
+ protected transient UserService userService;
- public void setLogging(boolean logging) {
- this.logging = logging;
+ public UserService getUserService() {
+ if (userService == null) {
+ userService = newService(UserService.class);
+ }
+ return userService;
}
- public String getLogin() {
- return login;
+ public String getEmail() {
+ return email;
}
- public void setLogin(String login) {
- this.login = login;
+ public void setEmail(String email) {
+ this.email = email;
}
public String getPassword() {
@@ -90,13 +91,14 @@
public String doLogin() throws Exception {
- // TODO Get user from userService
- EchoBaseUser user = null;
+ EchoBaseUserDTO user = getUserService().getUserByEmail(email);
EchoBaseSession userSession = getEchoBaseSession();
// user is authorized, keep it in his echoBaseSession
- userSession.setEchoBaseUser(user);
+ EchoBaseUserImpl echoBaseUser = new EchoBaseUserImpl();
+ echoBaseUser.fromDTO(user);
+ userSession.setEchoBaseUser(echoBaseUser);
// add locale in echoBaseSession if required
Object o = session.get(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE);
@@ -109,7 +111,7 @@
// redecode parameters
if (log.isInfoEnabled()) {
- log.info("success login for user " + login +
+ log.info("success login for user " + email +
", will redirect to " + redirectAction);
}
return "redirect";
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java 2011-11-04 12:50:20 UTC (rev 11)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java 2011-11-04 14:01:05 UTC (rev 12)
@@ -10,8 +10,10 @@
*/
public class UserAction extends EchoBaseActionSupport {
- protected UserService service;
+ private static final long serialVersionUID = 1L;
+ protected transient UserService service;
+
protected UserService getService() {
if (service == null) {
service = newService(UserService.class);
@@ -19,7 +21,7 @@
return service;
}
- public List<EchoBaseUserDTO> userList() {
+ public List<EchoBaseUserDTO> getUserList() {
return getService().getUsers();
}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/EchoBaseFieldValidatorSupport.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/EchoBaseFieldValidatorSupport.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/EchoBaseFieldValidatorSupport.java 2011-11-04 14:01:05 UTC (rev 12)
@@ -0,0 +1,62 @@
+/*
+ * #%L
+ * T3 :: Web
+ *
+ * $Id: T3BaseFieldValidatorSupport.java 623 2011-10-24 14:43:56Z chemit $
+ * $HeadURL: https://svn.mpl.ird.fr/osiris/t3/trunk/t3-web/src/main/java/fr/ird/t3/web/v… $
+ * %%
+ * Copyright (C) 2010 - 2011 IRD, Codelutin, Tony Chemit
+ * %%
+ * 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.validators;
+
+import org.nuiton.validator.xwork2.field.NuitonFieldValidatorSupport;
+
+import java.util.Arrays;
+
+/**
+ * Base T3 validator.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public abstract class EchoBaseFieldValidatorSupport extends NuitonFieldValidatorSupport {
+
+ /**
+ * Add directly a field error with the given sentence wihtout any translation from the xml validator file.
+ *
+ * @param propertyName name of the property where to push the error
+ * @param error the error
+ */
+ protected void addFieldError(String propertyName, String error) {
+ getValidatorContext().addFieldError(propertyName, error);
+ }
+
+ /**
+ * Translate the given i18n key with his optional arguments.
+ * <p/>
+ * <strong>Note:</strong> This method name is fixed to be detected via the
+ * nuiton i18n system, do NOT change this method name.
+ *
+ * @param key the i18n key to translate
+ * @param args the optional arguments of the sentence
+ * @return the translated sentence
+ */
+ protected String _(String key, Object... args) {
+ String text = getValidatorContext().getText(key, Arrays.asList(args));
+ return text;
+ }
+}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/validators/LoginValidator.java 2011-11-04 14:01:05 UTC (rev 12)
@@ -0,0 +1,79 @@
+/*
+ * #%L
+ * T3 :: Web
+ *
+ * $Id: LoginValidator.java 623 2011-10-24 14:43:56Z chemit $
+ * $HeadURL: https://svn.mpl.ird.fr/osiris/t3/trunk/t3-web/src/main/java/fr/ird/t3/web/v… $
+ * %%
+ * Copyright (C) 2010 - 2011 IRD, Codelutin, Tony Chemit
+ * %%
+ * 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.validators;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import fr.ifremer.echobase.entities.EchoBaseUserDTO;
+import fr.ifremer.echobase.services.UserService;
+
+/**
+ * Check user login.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class LoginValidator extends EchoBaseFieldValidatorSupport {
+
+ @Override
+ public void validateWhenNotSkip(Object object) throws ValidationException {
+
+ UserService userService =
+ (UserService) getFieldValue("userService", object);
+
+ String login = (String) getFieldValue("login", object);
+ String password = (String) getFieldValue("password", object);
+
+ if (log.isInfoEnabled()) {
+ log.info("try to log for user " + login);
+ }
+
+ try {
+ // check in db that user is ok
+ EchoBaseUserDTO user = userService.getUserByEmail(login);
+
+ if (user == null) {
+
+ // user not found
+ addFieldError("login", _("t3.error.login.unknown"));
+ return;
+ }
+
+ boolean passwordOk = userService.checkPassword(user, password);
+
+ if (!passwordOk) {
+ addFieldError("password", _("t3.error.bad.password"));
+ }
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not validate login", e);
+ }
+ throw new ValidationException("Could not validate login : " + e.getMessage());
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "login";
+ }
+}
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-04 12:50:20 UTC (rev 11)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-04 14:01:05 UTC (rev 12)
@@ -30,21 +30,16 @@
<struts>
- <package name="user" extends="default" namespace="/user">
+ <package name="user" extends="loggued" namespace="/user">
- <!-- when a action has no context -->
- <!--<action name="missingEchoBaseDatabase">-->
- <!--<result name="success">/WEB-INF/jsp/missingEchoBaseDatabaseSelected.jsp</result>-->
- <!--</action>-->
-
<!-- login action -->
<action name="login" class="fr.ifremer.echobase.ui.actions.LoginAction"
method="doLogin">
<result name="input">/WEB-INF/jsp/user/login.jsp</result>
<result name="error">/WEB-INF/jsp/user/login.jsp</result>
<result name="redirect" type="redirect">${redirectAction}</result>
- <!--<interceptor-ref name="internalTransaction"/>-->
- <interceptor-ref name="paramsPrepareParamsStack"/>
+ <interceptor-ref name="topiaTransaction"/>
+ <interceptor-ref name="basicStack"/>
</action>
<!-- logout action -->
@@ -56,28 +51,27 @@
</result>
<interceptor-ref name="checkUserLoggued"/>
<interceptor-ref name="basicStack"/>
- <interceptor-ref name="injectEchoBaseSession"/>
</action>
<!-- get lists of users -->
<action name="userList" class="fr.ifremer.echobase.ui.actions.UserAction">
- <interceptor-ref name="internalBasicStackLoggued"/>
+ <interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="checkUserIsAdmin"/>
- <result name="input">/WEB-INF/jsp/admin/users.jsp</result>
+ <result name="input">/WEB-INF/jsp/user/users.jsp</result>
</action>
<!-- update or create (if not exist) user -->
<action name="createOrUpdate" class="fr.ifremer.echobase.ui.actions.UserAction">
- <interceptor-ref name="internalBasicStackLoggued"/>
+ <interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="checkUserIsAdmin"/>
- <result name="input">/WEB-INF/jsp/admin/users.jsp</result>
+ <result name="input">/WEB-INF/jsp/user/users.jsp</result>
</action>
<!-- delete user -->
<action name="delete" class="fr.ifremer.echobase.ui.actions.UserAction">
- <interceptor-ref name="internalBasicStackLoggued"/>
+ <interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="checkUserIsAdmin"/>
- <result name="input">/WEB-INF/jsp/admin/users.jsp</result>
+ <result name="input">/WEB-INF/jsp/user/users.jsp</result>
</action>
</package>
Added: trunk/echobase-ui/src/main/resources/echobase.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/echobase.properties (rev 0)
+++ trunk/echobase-ui/src/main/resources/echobase.properties 2011-11-04 14:01:05 UTC (rev 12)
@@ -0,0 +1,8 @@
+hibernate.hbm2ddl.auto=none
+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}/db/h2data
+hibernate.connection.username=sa
+hibernate.connection.password=sa
\ No newline at end of file
Added: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/LoginAction-login-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/LoginAction-login-validation.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/LoginAction-login-validation.xml 2011-11-04 14:01:05 UTC (rev 12)
@@ -0,0 +1,36 @@
+<!--
+ #%L
+ T3 :: Web
+
+ $Id: LoginAction-login-validation.xml 614 2011-10-22 00:49:05Z chemit $
+ $HeadURL: https://svn.mpl.ird.fr/osiris/t3/trunk/t3-web/src/main/resources/fr/ird/t3/… $
+ %%
+ Copyright (C) 2010 - 2011 IRD, Codelutin, Tony Chemit
+ %%
+ 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%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="email">
+
+ <field-validator type="login">
+ <message/>
+ </field-validator>
+ </field>
+
+</validators>
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-04 12:50:20 UTC (rev 11)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-04 14:01:05 UTC (rev 12)
@@ -26,3 +26,5 @@
echobase.title.login=Connection
echobase.title.users=Adminitration des utilisateurs
echobase.user.gridTitle=Liste des utilisateurs
+t3.error.bad.password=
+t3.error.login.unknown=
Modified: trunk/echobase-ui/src/main/resources/struts.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/struts.xml 2011-11-04 12:50:20 UTC (rev 11)
+++ trunk/echobase-ui/src/main/resources/struts.xml 2011-11-04 14:01:05 UTC (rev 12)
@@ -117,12 +117,6 @@
<interceptor-ref name="echoBaseParamsPrepareParamsStack"/>
</interceptor-stack>
- <interceptor-stack name="execAndwaitStackLoggued">
- <interceptor-ref name="loginAndActionContext"/>
- <interceptor-ref name="echoBaseParamsPrepareParamsStack"/>
- <interceptor-ref name="execAndWait"/>
- </interceptor-stack>
-
</interceptors>
<!-- must be authenticated to perform any actions -->
Added: trunk/echobase-ui/src/main/resources/validators.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/validators.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/validators.xml 2011-11-04 14:01:05 UTC (rev 12)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator Config 1.0//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd">
+<validators>
+ <!-- default validators from XWork framework -->
+ <validator name="int" class="com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"/>
+ <validator name="long" class="com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"/>
+ <validator name="short" class="com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"/>
+ <validator name="double" class="com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"/>
+ <validator name="date" class="com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator"/>
+ <validator name="expression" class="com.opensymphony.xwork2.validator.validators.ExpressionValidator"/>
+ <validator name="fieldexpression" class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/>
+ <validator name="conversion" class="com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"/>
+ <validator name="stringlength" class="com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator"/>
+
+ <!-- default nuiton-validator validators -->
+ <validator name="fieldexpressionwithparams" class="org.nuiton.validator.xwork2.field.FieldExpressionWithParamsValidator"/>
+ <validator name="required" class="org.nuiton.validator.xwork2.field.SkipableRequiredFieldValidator"/>
+ <validator name="requiredstring" class="org.nuiton.validator.xwork2.field.SkipableRequiredStringFieldValidator"/>
+
+ <!-- EchoBase validators -->
+ <validator name="login" class="fr.ifremer.echobase.ui.validators.LoginValidator"/>
+
+</validators>
1
0
r11 - in trunk/echobase-ui/src/main: resources/i18n webapp/WEB-INF/jsp webapp/WEB-INF/jsp/export
by sletellier@users.forge.codelutin.com 04 Nov '11
by sletellier@users.forge.codelutin.com 04 Nov '11
04 Nov '11
Author: sletellier
Date: 2011-11-04 13:50:20 +0100 (Fri, 04 Nov 2011)
New Revision: 11
Url: http://forge.codelutin.com/repositories/revision/echobase/11
Log:
- Creating export page
Added:
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/export.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp
Modified:
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-04 12:50:00 UTC (rev 10)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-04 12:50:20 UTC (rev 11)
@@ -5,6 +5,10 @@
echobase.common.admin=Administrateur
echobase.common.email=Email
echobase.common.password=Mot de passe
+echobase.common.save=Sauvegarder
+echobase.export.queryDescription=Description
+echobase.export.queryName=Nom
+echobase.export.querySql=SQL
echobase.label.language=Language
echobase.label.locale.english=Anglais
echobase.label.locale.french=Français
@@ -15,6 +19,7 @@
echobase.menu.logs=Logs
echobase.menu.users=Utilisateurs
echobase.msg.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir acceder au résultats de l'import.
+echobase.title.export=Export
echobase.title.import=Imports
echobase.title.importProgress=Import en cours
echobase.title.importResult=Résultats de l'import
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/export.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/export.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/export.jsp 2011-11-04 12:50:20 UTC (rev 11)
@@ -0,0 +1,53 @@
+<%--
+ #%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%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<title><s:text name="echobase.title.export"/></title>
+
+<s:url id="savedExportQueries" action="savedExportQueries" namespace="/ajax"/>
+
+<sj:select id="lastQueriesSelect"
+ href="%{savedExportQueries}"
+ name="selectedQuery"
+ listKey="topiaId"
+ listValue="name"
+ list="savedExportQueries"
+ emptyOption="true"
+ listenTopics="updateSavedExportQueries"
+ onChangeTopics="updateExportQueryForm"/>
+
+<s:url id="exportQueryFormUrl" action="exportQueryFormForm" namespace="/fragment"/>
+<sj:div id="exportQueryForm"
+ href="%{exportQueryFormUrl}"
+ listenTopics="updateExportQueryForm"
+ onSuccessTopics="updateExportGrid"
+ indicator="indicator-searchPanel">
+ <img id="indicator-searchPanel" src="/img/indicator.gif" alt="Loading..." style="display:none"/>
+</sj:div>
+
+<%-- TODO sletellier : add result grid listen event updateExportGrid named exportGrid --%>
+
+</sjg:grid>
\ No newline at end of file
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp 2011-11-04 12:50:20 UTC (rev 11)
@@ -0,0 +1,67 @@
+<%--
+ #%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%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@taglib prefix="s" uri="/struts-tags"%>
+<%@taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<s:form id="exportQueryForm" action="executeExportQuery" namespace="/export">
+
+ <s:text name="echobase.export.queryName"/>
+ <s:textfield id="queryName"
+ cssClass="right"
+ theme="simple"
+ name="queryName"
+ size="40"/>
+
+ <s:text name="echobase.export.querySql"/>
+ <s:textarea id="querySql"
+ name="querySql"
+ cols="160"
+ rows="6"/>
+
+ <s:text name="echobase.export.queryDescription"/>
+ <s:textarea id="querySql"
+ name="querySql"
+ cols="160"
+ rows="6"/>
+
+ <s:url id="saveExportQueryUrl" action="saveExportQuery" namespace="export"/>
+
+ <s:set id="saveExportQueryText">
+ <s:text name="echobase.common.save"/>
+ </s:set>
+
+ <sj:submit id="saveQuery"
+ href="%{saveExportQueryUrl}"
+ value="%{saveExportQueryText}"
+ onSuccessTopics="updateExportQueries"
+ button="true"/>
+
+ <sj:submit id="search"
+ value="%{searchText}"
+ indicator="indicator-exportGrid"
+ targets="exportGrid"
+ button="true"/>
+
+</s:form>
\ No newline at end of file
1
0
r10 - in trunk: echobase-services/src/main/java/fr/ifremer/echobase/services echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions echobase-ui/src/main/resources/config echobase-ui/src/main/webapp/WEB-INF/jsp/user
by sletellier@users.forge.codelutin.com 04 Nov '11
by sletellier@users.forge.codelutin.com 04 Nov '11
04 Nov '11
Author: sletellier
Date: 2011-11-04 13:50:00 +0100 (Fri, 04 Nov 2011)
New Revision: 10
Url: http://forge.codelutin.com/repositories/revision/echobase/10
Log:
- Creating Abstract for services
- Creating user service
- Creating user action
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java
Modified:
trunk/echobase-ui/src/main/resources/config/struts-user.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-04 12:50:00 UTC (rev 10)
@@ -0,0 +1,20 @@
+package fr.ifremer.echobase.services;
+
+import org.nuiton.topia.TopiaContext;
+
+/**
+ * @author sletellier
+ */
+public class AbstractEchoBaseService implements EchoBaseService {
+
+ protected EchoBaseServiceContext serviceContext;
+
+ @Override
+ public void setServiceContext(EchoBaseServiceContext serviceContext) {
+ this.serviceContext = serviceContext;
+ }
+
+ public TopiaContext getTransaction() {
+ return serviceContext.getTransaction();
+ }
+}
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-04 12:50:00 UTC (rev 10)
@@ -0,0 +1,77 @@
+package fr.ifremer.echobase.services;
+
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EchoBaseUserDAO;
+import fr.ifremer.echobase.entities.EchoBaseUserDTO;
+import org.nuiton.topia.TopiaException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author sletellier
+ */
+public class UserService extends AbstractEchoBaseService {
+
+ public EchoBaseUserDAO getDAO() throws TopiaException {
+ return EchoBaseDAOHelper.getEchoBaseUserDAO(getTransaction());
+ }
+
+ public List<EchoBaseUserDTO> getUsers() throws EchoBaseTechnicalException {
+ try {
+ List<EchoBaseUser> users = getDAO().findAll();
+
+ // Fill dtos
+ List<EchoBaseUserDTO> usersDtos = new ArrayList<EchoBaseUserDTO>(users.size());
+ for (EchoBaseUser user : users) {
+ usersDtos.add(user.toDTO());
+ }
+ return usersDtos;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+
+ public EchoBaseUserDTO getUserById(String topiaId) {
+ try {
+ EchoBaseUser user = getDAO().findByTopiaId(topiaId);
+
+ return user.toDTO();
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+
+ public void createOrUpdate(EchoBaseUserDTO userDTO) {
+ try {
+ EchoBaseUserDAO dao = getDAO();
+ EchoBaseUser user;
+
+ // No id, creating new one entity
+ String id = userDTO.getId();
+ if (id == null) {
+ user = dao.create();
+ } else {
+ user = dao.findByTopiaId(id);
+ }
+ user.fromDTO(userDTO);
+
+ dao.update(user);
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+
+ public void delete(EchoBaseUserDTO userDTO) {
+ try {
+ EchoBaseUserDAO dao = getDAO();
+ EchoBaseUser user = dao.findByTopiaId(userDTO.getId());
+
+ dao.delete(user);
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java 2011-11-04 12:50:00 UTC (rev 10)
@@ -0,0 +1,33 @@
+package fr.ifremer.echobase.ui.actions;
+
+import fr.ifremer.echobase.entities.EchoBaseUserDTO;
+import fr.ifremer.echobase.services.UserService;
+
+import java.util.List;
+
+/**
+ * @author sletellier
+ */
+public class UserAction extends EchoBaseActionSupport {
+
+ protected UserService service;
+
+ protected UserService getService() {
+ if (service == null) {
+ service = newService(UserService.class);
+ }
+ return service;
+ }
+
+ public List<EchoBaseUserDTO> userList() {
+ return getService().getUsers();
+ }
+
+ public void createOrUpdate(EchoBaseUserDTO userDTO) {
+ getService().createOrUpdate(userDTO);
+ }
+
+ public void delete(EchoBaseUserDTO userDTO) {
+ getService().delete(userDTO);
+ }
+}
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-04 12:06:39 UTC (rev 9)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-04 12:50:00 UTC (rev 10)
@@ -60,31 +60,25 @@
</action>
<!-- get lists of users -->
- <!--<action name="userList" class="fr.ird.t3.web.actions.admin.UserAction"-->
- <!--method="input">-->
- <!--<interceptor-ref name="internalBasicStackLoggued"/>-->
- <!--<interceptor-ref name="checkUserIsAdmin"/>-->
- <!--<result name="input">/WEB-INF/jsp/admin/userList.jsp</result>-->
- <!--</action>-->
+ <action name="userList" class="fr.ifremer.echobase.ui.actions.UserAction">
+ <interceptor-ref name="internalBasicStackLoggued"/>
+ <interceptor-ref name="checkUserIsAdmin"/>
+ <result name="input">/WEB-INF/jsp/admin/users.jsp</result>
+ </action>
- <!-- get detail of a user -->
- <!--<action name="userForm" class="fr.ird.t3.web.actions.admin.UserAction"-->
- <!--method="input">-->
- <!--<interceptor-ref name="internalParamsPrepareParamsStackLoggued"/>-->
- <!--<result name="input">/WEB-INF/jsp/admin/userForm.jsp</result>-->
- <!--<result name="error">/WEB-INF/jsp/admin/userForm.jsp</result>-->
- <!--<result name="success">/WEB-INF/jsp/admin/userForm.jsp</result>-->
- <!--<result name="backToList" type="redirectAction">userList</result>-->
- <!--</action>-->
+ <!-- update or create (if not exist) user -->
+ <action name="createOrUpdate" class="fr.ifremer.echobase.ui.actions.UserAction">
+ <interceptor-ref name="internalBasicStackLoggued"/>
+ <interceptor-ref name="checkUserIsAdmin"/>
+ <result name="input">/WEB-INF/jsp/admin/users.jsp</result>
+ </action>
- <!-- download user log file -->
- <!--<action name="getUserLog"-->
- <!--class="fr.ifremer.echobase.web.actions.data.DownloadUserLogAction">-->
- <!--<interceptor-ref name="internalBasicStackLoggued"/>-->
- <!--<result name="success" type="stream">-->
- <!--<param name="contentCharSet">UTF-8</param>-->
- <!--</result>-->
- <!--</action>-->
+ <!-- delete user -->
+ <action name="delete" class="fr.ifremer.echobase.ui.actions.UserAction">
+ <interceptor-ref name="internalBasicStackLoggued"/>
+ <interceptor-ref name="checkUserIsAdmin"/>
+ <result name="input">/WEB-INF/jsp/admin/users.jsp</result>
+ </action>
</package>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp 2011-11-04 12:06:39 UTC (rev 9)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp 2011-11-04 12:50:00 UTC (rev 10)
@@ -32,13 +32,13 @@
<hr/>
-<s:url id="usersListUrl" namespace="/users" action="list"/>
-<s:url id="saveUrl" action="saveUser" />
+<s:url id="userListUrl" namespace="/users" action="userList"/>
+<s:url id="saveUrl" namespace="/users" action="createOrUpdate" />
<sjg:grid id="usersList"
caption='%{getText("echobase.user.gridTitle")}'
dataType="json"
- href="%{usersListUrl}"
+ href="%{userListUrl}"
pager="true"
navigator="true"
navigatorAddOptions="{
1
0
r9 - in trunk/echobase-entities/src/main: java/fr/ifremer/echobase java/fr/ifremer/echobase/entities resources/i18n xmi
by tchemit@users.forge.codelutin.com 04 Nov '11
by tchemit@users.forge.codelutin.com 04 Nov '11
04 Nov '11
Author: tchemit
Date: 2011-11-04 13:06:39 +0100 (Fri, 04 Nov 2011)
New Revision: 9
Url: http://forge.codelutin.com/repositories/revision/echobase/9
Log:
add DTO for JSON purposes + remove generated i18n
Added:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserImpl.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/ExportQueryImpl.java
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java
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
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-04 10:09:27 UTC (rev 8)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-04 12:06:39 UTC (rev 9)
@@ -27,6 +27,7 @@
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
import org.nuiton.util.FileUtil;
@@ -84,20 +85,29 @@
}
public File getDataDirectory() {
- File v = applicationConfig.getOptionAsFile(EchoBaseConfigurationOption.DATA_DIRECTORY.key);
- return v;
+ File file = applicationConfig.getOptionAsFile(EchoBaseConfigurationOption.DATA_DIRECTORY.key);
+ Preconditions.checkNotNull(file);
+ return file;
}
public Version getApplicationVersion() {
Version v = applicationConfig.getOptionAsVersion(EchoBaseConfigurationOption.VERSION.key);
+ Preconditions.checkNotNull(v);
return v;
}
public URL getApplicationSite() {
URL url = applicationConfig.getOptionAsURL(EchoBaseConfigurationOption.SITE_URL.key);
+ Preconditions.checkNotNull(url);
return url;
}
+ public Class<?> getDriverClass() {
+ Class<?> klass = applicationConfig.getOptionAsClass(TopiaContextFactory.CONFIG_DRIVER);
+ Preconditions.checkNotNull(klass);
+ return klass;
+ }
+
/**
* Creates a directory given the configuration given key.
*
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java 2011-11-04 10:09:27 UTC (rev 8)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java 2011-11-04 12:06:39 UTC (rev 9)
@@ -104,6 +104,11 @@
Properties properties = config.getProperties();
+ return newDatabaseFromProperties(properties);
+ }
+
+ public Supplier<TopiaContext> newDatabaseFromProperties(Properties properties) {
+
if (log.isDebugEnabled()) {
log.debug("Database settings are :");
Set<String> keysToDisplay = Sets.newHashSet(
Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserImpl.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserImpl.java (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserImpl.java 2011-11-04 12:06:39 UTC (rev 9)
@@ -0,0 +1,53 @@
+/*
+ * #%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.entities;
+
+/**
+ * Default implementation of the {@link EchoBaseUser}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class EchoBaseUserImpl extends EchoBaseUserAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public EchoBaseUserDTO toDTO() {
+ EchoBaseUserDTO dto = new EchoBaseUserDTOImpl();
+ dto.setAdmin(isAdmin());
+ dto.setEmail(getEmail());
+ dto.setPassword(getPassword());
+ dto.setId(getTopiaId());
+ return dto;
+ }
+
+ @Override
+ public void fromDTO(EchoBaseUserDTO dto) {
+ setAdmin(dto.isAdmin());
+ setEmail(dto.getEmail());
+ setPassword(dto.getPassword());
+ }
+
+}
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/ExportQueryImpl.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/ExportQueryImpl.java (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/ExportQueryImpl.java 2011-11-04 12:06:39 UTC (rev 9)
@@ -0,0 +1,47 @@
+/*
+ * #%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.entities;
+
+/**
+ * Default implementation of the {@link ExportQuery}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class ExportQueryImpl extends ExportQueryAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ExportQueryDTO toDTO() {
+ ExportQueryDTO dto = new ExportQueryDTOImpl();
+ dto.setDescription(getDescription());
+ dto.setId(getTopiaId());
+ dto.setLastModifiedDate(getLastModifiedDate());
+ dto.setLastModifiedUser(getLastModifiedUser().toDTO());
+ dto.setName(getName());
+ dto.setSqlQuery(getSqlQuery());
+ return dto;
+ }
+}
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/ExportQueryImpl.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 10:09:27 UTC (rev 8)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-04 12:06:39 UTC (rev 9)
@@ -1,16 +1 @@
-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=
Modified: trunk/echobase-entities/src/main/xmi/echobase.properties
===================================================================
--- trunk/echobase-entities/src/main/xmi/echobase.properties 2011-11-04 10:09:27 UTC (rev 8)
+++ trunk/echobase-entities/src/main/xmi/echobase.properties 2011-11-04 12:06:39 UTC (rev 9)
@@ -22,7 +22,7 @@
# #L%
###
-model.tagValue.i18n=echobase.common.
+#model.tagValue.i18n=echobase.common.
model.tagValue.notGenerateToString=true
model.tagValue.generateOperatorForDAOHelper=true
model.tagValue.generateStandaloneEnumForDAOHelper=true
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
1
0
04 Nov '11
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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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
1
0
r7 - in trunk/echobase-ui/src/main: resources resources/config resources/i18n webapp/WEB-INF/jsp webapp/WEB-INF/jsp/import webapp/WEB-INF/jsp/user
by sletellier@users.forge.codelutin.com 04 Nov '11
by sletellier@users.forge.codelutin.com 04 Nov '11
04 Nov '11
Author: sletellier
Date: 2011-11-04 10:21:14 +0100 (Fri, 04 Nov 2011)
New Revision: 7
Url: http://forge.codelutin.com/repositories/revision/echobase/7
Log:
- Rename all ecobase to ecHobase
- Creating import pages
- Creating user administration page
- Add missing traductions
Added:
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/
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/users.jsp
Modified:
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/jsp/home.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/login.jsp
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-04 08:43:34 UTC (rev 6)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-04 09:21:14 UTC (rev 7)
@@ -40,8 +40,8 @@
<!-- login action -->
<action name="login" class="fr.ifremer.echobase.ui.actions.LoginAction"
method="doLogin">
- <result name="input">/WEB-INF/jsp/login.jsp</result>
- <result name="error">/WEB-INF/jsp/login.jsp</result>
+ <result name="input">/WEB-INF/jsp/user/login.jsp</result>
+ <result name="error">/WEB-INF/jsp/user/login.jsp</result>
<result name="redirect" type="redirect">${redirectAction}</result>
<!--<interceptor-ref name="internalTransaction"/>-->
<interceptor-ref name="paramsPrepareParamsStack"/>
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-04 08:43:34 UTC (rev 6)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-04 09:21:14 UTC (rev 7)
@@ -1,10 +1,23 @@
echobase.action.locale.english=Anglais
echobase.action.locale.french=Français
+echobase.action.login=Connection
echobase.action.logout=Déconnection
+echobase.common.admin=Administrateur
+echobase.common.email=Email
+echobase.common.password=Mot de passe
echobase.label.language=Language
echobase.label.locale.english=Anglais
echobase.label.locale.french=Français
-echobase.label.user.login=Login
-ecobase.label.login=Connection
-ecobase.label.welcome=Bienvenue
-ecobase.title.login=Connection
+echobase.label.login=Connection
+echobase.label.welcome=Bienvenue
+echobase.menu.export=Exports
+echobase.menu.import=Imports
+echobase.menu.logs=Logs
+echobase.menu.users=Utilisateurs
+echobase.msg.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir acceder au résultats de l'import.
+echobase.title.import=Imports
+echobase.title.importProgress=Import en cours
+echobase.title.importResult=Résultats de l'import
+echobase.title.login=Connection
+echobase.title.users=Adminitration des utilisateurs
+echobase.user.gridTitle=Liste des utilisateurs
Modified: trunk/echobase-ui/src/main/resources/struts.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/struts.xml 2011-11-04 08:43:34 UTC (rev 6)
+++ trunk/echobase-ui/src/main/resources/struts.xml 2011-11-04 09:21:14 UTC (rev 7)
@@ -57,15 +57,15 @@
<interceptor name="paramRemover"
class="com.opensymphony.xwork2.interceptor.ParameterRemoverInterceptor"/>
- <!-- to manage the Ecobase topia transaction inside an action -->
+ <!-- to manage the echobase topia transaction inside an action -->
<interceptor name="topiaTransaction"
class="fr.ifremer.echobase.ui.interceptors.EchoBaseTransactionInterceptorImpl"/>
- <!-- to inject the ecobase session inside an action -->
+ <!-- to inject the echobase session inside an action -->
<interceptor name="injectEchoBaseSession"
class="fr.ifremer.echobase.ui.interceptors.EchoBaseSessionInterceptor"/>
- <!-- to clean some properties from the ecobase session -->
+ <!-- to clean some properties from the echobase session -->
<interceptor name="cleanEchoBaseSession"
class="fr.ifremer.echobase.ui.interceptors.CleanEchoBaseSessionInterceptor"/>
@@ -81,7 +81,7 @@
<param name="redirectAction">/home</param>
</interceptor>
- <interceptor name="checkEcobaseSession"
+ <interceptor name="checkEchobaseSession"
class="fr.ifremer.echobase.ui.interceptors.CheckInUserSessionInterceptor"/>
</interceptors>
@@ -95,7 +95,7 @@
<interceptors>
- <!-- ecobase basic authenticated stack -->
+ <!-- echobase basic authenticated stack -->
<interceptor-stack name="echoBaseBasicStack">
<interceptor-ref name="injectEchoBaseSession"/>
<!--<interceptor-ref name="checkEchoBaseDatabaseSelected"/>-->
@@ -103,7 +103,7 @@
<interceptor-ref name="basicStack"/>
</interceptor-stack>
- <!-- ecobase stack with params-->
+ <!-- echobase stack with params-->
<interceptor-stack name="echoBaseParamsPrepareParamsStack">
<interceptor-ref name="injectEchoBaseSession"/>
<!--<interceptor-ref name="checkEchoBaseDatabaseSelected"/>-->
@@ -121,7 +121,7 @@
<interceptor-stack name="loginAndActionContext">
<interceptor-ref name="i18n"/>
<interceptor-ref name="checkUserLoggued"/>
- <interceptor-ref name="checkEcobaseSession">
+ <interceptor-ref name="checkEchobaseSession">
<param name="parameters">actionContext</param>
<param name="redirectAction">/missingActionContext</param>
</interceptor-ref>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-11-04 08:43:34 UTC (rev 6)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-11-04 09:21:14 UTC (rev 7)
@@ -23,9 +23,9 @@
--%>
<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
-<%--<s:set var="userIsAdmin" value="%{#session.ecobaseSession.ecobaseUser.admin}"/>--%>
-<title><s:text name="ecobase.label.welcome"/></title>
+<%--<s:set var="userIsAdmin" value="%{#session.echobaseSession.echobaseUser.admin}"/>--%>
+<title><s:text name="echobase.label.welcome"/></title>
-<h2><s:text name="ecobase.label.welcome"/></h2>
+<h2><s:text name="echobase.label.welcome"/></h2>
<hr/>
\ No newline at end of file
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportProgress.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportProgress.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportProgress.jsp 2011-11-04 09:21:14 UTC (rev 7)
@@ -0,0 +1,33 @@
+<%--
+ #%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%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<title><s:text name="echobase.title.importProgress"/></title>
+
+<sj:progressbar value="%{EchoBaseActionContext.progression}"/>
+
+<%-- TODO letellier 20111104 : Add warn icon --%>
+<p><s:text name="echobase.msg.warnImportInProgress"/></p>
\ No newline at end of file
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp 2011-11-04 09:21:14 UTC (rev 7)
@@ -0,0 +1,29 @@
+<%--
+ #%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%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<title><s:text name="echobase.title.importResult"/></title>
+
+<%-- TODO letellier 20111104 : Add import results --%>
\ No newline at end of file
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp 2011-11-04 09:21:14 UTC (rev 7)
@@ -0,0 +1,43 @@
+<%--
+ #%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%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<title><s:text name="echobase.title.import"/></title>
+
+<s:form id="importForm" action="importFiles" namespace="/import" method="POST" enctype="multipart/form-data">
+
+ <%-- TODO letellier 20111104 : Allow to select existing campagne --%>
+
+ <s:file name="accoustique" key="echobase.importFile.accoustique"/>
+ <s:file name="pecherie" key="echobase.importFile.pecherie"/>
+ <s:file name="lectureAgeGen" key="echobase.importFile.lectureAgeGen"/>
+ <s:file name="events" key="echobase.importFile.events"/>
+ <s:file name="typeEchoSpecies" key="echobase.importFile.typeEchoSpecies"/>
+
+ <s:textarea name="comment" key="echobase.common.comment"/>
+
+ <s:submit id="addFilesSubmit"
+ value="%{saveText}"/>
+</s:form>
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/login.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/login.jsp 2011-11-04 08:43:34 UTC (rev 6)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/login.jsp 2011-11-04 09:21:14 UTC (rev 7)
@@ -27,7 +27,7 @@
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>Ecobase - <s:text name="ecobase.label.login"/></title>
+ <title>Echobase - <s:text name="echobase.label.login"/></title>
<link rel="stylesheet" type="text/css"
href="<s:url value='/css/screen.css' />"/>
<link rel="icon" type="image/png"
@@ -41,7 +41,7 @@
<div class='displayBlock'>
<div class='floatLeft'>
- <s:a action="home" namespace="/">Ecobase</s:a>
+ <s:a action="home" namespace="/">Echobase</s:a>
</div>
<div id='headerRight'>
<%@ include file="/WEB-INF/includes/i18n.jsp" %>
@@ -52,13 +52,13 @@
<%-- content --%>
-<h2><s:text name="ecobase.title.login"/></h2>
+<h2><s:text name="echobase.title.login"/></h2>
<s:form method="POST" namespace="/user">
<s:hidden key="redirectAction" label=""/>
- <s:textfield name="login" key="ecobase.common.login" required="true"/>
- <s:password name="password" key="ecobase.common.password" required="true"/>
- <s:submit action="login" key="ecobase.action.login" align="right"/>
+ <s:textfield name="email" key="echobase.common.email" required="true"/>
+ <s:password name="password" key="echobase.common.password" required="true"/>
+ <s:submit action="login" key="echobase.action.login" align="right"/>
</s:form>
<br/>
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/users.jsp 2011-11-04 09:21:14 UTC (rev 7)
@@ -0,0 +1,99 @@
+<%--
+ #%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%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+
+<title><s:text name="echobase.title.users"/></title>
+
+<h2><s:text name="echobase.title.users"/></h2>
+
+<hr/>
+
+<s:url id="usersListUrl" namespace="/users" action="list"/>
+<s:url id="saveUrl" action="saveUser" />
+
+<sjg:grid id="usersList"
+ caption='%{getText("echobase.user.gridTitle")}'
+ dataType="json"
+ href="%{usersListUrl}"
+ pager="true"
+ navigator="true"
+ navigatorAddOptions="{
+ height:280,
+ reloadAfterSubmit:true,
+ afterSubmit:function(response, postdata) {
+ return isError(response.responseText);
+ }
+ }"
+ navigatorEdit="true"
+ navigatorEditOptions="{
+ height:280,
+ reloadAfterSubmit:true,
+ afterSubmit:function(response, postdata) {
+ return isError(response.responseText);
+ }
+ }"
+ navigatorDelete="true"
+ navigatorDeleteOptions="{
+ height:280,
+ reloadAfterSubmit:true,
+ afterSubmit:function(response, postdata) {
+ return isError(response.responseText);
+ }
+ }"
+ gridModel="gridModel"
+ rowList="10,100,1000"
+ rowNum="10"
+ editurl="%{saveUrl}"
+ editinline="false"
+ rownumbers="true"
+ multiselect="false"
+ autowidth="true"
+ viewrecords="true">
+
+ <sjg:gridColumn name="id"
+ key="true"
+ hidden="true"/>
+
+ <sjg:gridColumn name="email"
+ title='%{getText("echobase.common.email")}'
+ sortable="true"
+ editable="true"
+ edittype="text"/>
+
+ <sjg:gridColumn name="password"
+ title='%{getText("echobase.common.password")}'
+ editable="true"
+ edittype="password"
+ hidden="true"/>
+
+ <sjg:gridColumn name="admin"
+ title='%{getText("echobase.common.admin")}'
+ sortable="true"
+ editable="true"
+ edittype="checkbox"/>
+
+</sjg:grid>
\ No newline at end of file
1
0