Simexplorer-si-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
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
January 2008
- 2 participants
- 470 discussions
r554 - in trunk: simexplorer-is/src/site/fr/rst simexplorer-is-web/src/main/webapp/WEB-INF
by glandais@users.labs.libre-entreprise.org 28 Jan '08
by glandais@users.labs.libre-entreprise.org 28 Jan '08
28 Jan '08
Author: glandais
Date: 2008-01-28 16:59:58 +0000 (Mon, 28 Jan 2008)
New Revision: 554
Added:
trunk/simexplorer-is/src/site/fr/rst/install.rst
Modified:
trunk/simexplorer-is-web/src/main/webapp/WEB-INF/web.xml
Log:
Doc install
Added: trunk/simexplorer-is/src/site/fr/rst/install.rst
===================================================================
--- trunk/simexplorer-is/src/site/fr/rst/install.rst (rev 0)
+++ trunk/simexplorer-is/src/site/fr/rst/install.rst 2008-01-28 16:59:58 UTC (rev 554)
@@ -0,0 +1,56 @@
+=============================
+SimExplorer SI - Installation
+=============================
+
+Logiciels
+=========
+
+Plateforme
+----------
+
+SimExplorer SI étant en pur Java, toutes les plateformes supportant JBoss 4.2 sont compatibles.
+Nous traiterons pour le moment uniquement des plateformes à base Linux 2.6.
+
+Java
+----
+
+Il est nécessaire d'installer au minimum un JRE 1.5 disponible sur le site de Sun.
+
+JBoss
+-----
+
+L'application nécessite le serveur d'application JBoss AS 4.2.2GA.
+L'archive correspondant à la version supportée est jboss-4.2.2.GA.zip.
+
+Après avoir décompressé l'archive dans un dossier, dupliquer le dossier server/default en serveur/simexplorer.
+
+Installation
+============
+
+Dossiers
+--------
+
+Créer le dossier /var/local/simexplorer/h2. Ce dossier contiendra la base de données contenant les
+informations de sécurité. Lorsque l'application sera lancée pour la première fois, d'autres dossiers
+seront créés dans /var/local/simexplorer/ pour la base Lucene et les données.
+
+Applicatif
+----------
+
+Copier l'applicatif (simexplorer-is-ear-VERSION.ear) dans le dossier server/simexplorer/deploy de JBoss.
+
+Exécution
+=========
+
+Lancer JBoss via son script de lancement :
+
+::
+ bin/run.sh -c simexplorer
+
+Première connexion
+==================
+
+Si la configuration du serveur n'a pas été modifiée, se connecté à l'application
+via l'URL http://ADRESSE-DU-SERVEUR:8080/simexplorer-is-web
+
+Se connecter avec le login superadmin et le mot de passe password.
\ No newline at end of file
Modified: trunk/simexplorer-is-web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/simexplorer-is-web/src/main/webapp/WEB-INF/web.xml 2008-01-28 16:37:53 UTC (rev 553)
+++ trunk/simexplorer-is-web/src/main/webapp/WEB-INF/web.xml 2008-01-28 16:59:58 UTC (rev 554)
@@ -23,6 +23,6 @@
</filter-mapping>
<welcome-file-list>
- <welcome-file>ElementList</welcome-file>
+ <welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
\ No newline at end of file
1
0
r553 - in trunk: simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/factories simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/to
by glandais@users.labs.libre-entreprise.org 28 Jan '08
by glandais@users.labs.libre-entreprise.org 28 Jan '08
28 Jan '08
Author: glandais
Date: 2008-01-28 16:37:53 +0000 (Mon, 28 Jan 2008)
New Revision: 553
Added:
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java
trunk/simexplorer-is-web/src/main/webapp/ElementImport.tml
trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.properties
Removed:
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.java
trunk/simexplorer-is-web/src/main/webapp/ApplicationImport.tml
trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.properties
Modified:
trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java
trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/RawType.java
trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/factories/XmlConstants.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceClient.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceServer.java
trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/SimExplorerWebException.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementExport.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPageDetail.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/DownloadableFile.java
trunk/simexplorer-is-web/src/main/webapp/ElementExport.tml
trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/components/Layout.tml
Log:
Attachment handling
Modified: trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java
===================================================================
--- trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -29,52 +29,23 @@
public abstract class ContentType {
/**
- * MIME type
- */
- private String mimeType;
- /**
- * Text description
- */
- private String description;
-
- /**
* Index content
*
* @param is
* Input stream
* @return Indexable text
- * @throws Exception
+ * @throws Exception
*/
public abstract Reader renderToText(InputStream is) throws Exception;
/**
* @return the mimeType
*/
- public String getMimeType() {
- return mimeType;
- }
+ public abstract String getMimeType();
/**
- * @param mimeType
- * the mimeType to set
- */
- protected void setMimeType(String mimeType) {
- this.mimeType = mimeType;
- }
-
- /**
* @return the description
*/
- public String getDescription() {
- return description;
- }
+ public abstract String getDescription();
- /**
- * @param description
- * the description to set
- */
- protected void setDescription(String description) {
- this.description = description;
- }
-
}
Modified: trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/RawType.java
===================================================================
--- trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/RawType.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/RawType.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -32,19 +32,20 @@
private static final long serialVersionUID = -8010160085848440286L;
- /**
- * Set inner properties
- */
- public RawType() {
- super();
- setDescription("rawtype");
- setMimeType("text/text");
- }
-
@Override
public Reader renderToText(InputStream is) {
// No parsing
return new InputStreamReader(is);
}
+ @Override
+ public String getDescription() {
+ return "rawtype";
+ }
+
+ @Override
+ public String getMimeType() {
+ return "text/text";
+ }
+
}
Modified: trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/factories/XmlConstants.java
===================================================================
--- trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/factories/XmlConstants.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/factories/XmlConstants.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -63,6 +63,7 @@
public static final String KEY_METADATA_TYPE = "type";
public static final String VALUE_METADATA_TYPE_EA = "ExplorationApplication";
+ public static final String VALUE_METADATA_TYPE_COMPONENT = "Component";
public static final String KEY_METADATA_DESCRIPTION = "description";
public static final String KEY_METADATA_CREATIONDATE = "creationdate";
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -145,20 +145,6 @@
processComponent(object);
}
ea.setComponents(components);
-
- Map<String, ContentType> contents = new HashMap<String, ContentType>();
- for (ExplorationData object : datas) {
- contents.putAll(object.getMetaData().getAttachments());
- }
- for (Component object : components) {
- Set<Library> libraries = object.getLibraries();
- for (Library library : libraries) {
- contents.putAll(library.getMetaData().getAttachments());
- }
- contents.putAll(object.getMetaData().getAttachments());
- }
- ea.getMetaData().setAttachments(contents);
-
return ea;
}
@@ -186,7 +172,7 @@
}
private void processLibrary(Library library) throws Exception {
- library.getMetaData().getAttachments().put(shortString() + ".zip",
+ library.getMetaData().getAttachments().put(shortString() + ".txt",
ContentTypeFactory.getContentTypeInstance("RawType"));
}
@@ -205,7 +191,7 @@
Result result = new Result();
explorationData.setResult(result);
explorationData.getMetaData().getAttachments().put(
- shortString() + ".zip",
+ shortString() + ".txt",
ContentTypeFactory.getContentTypeInstance("RawType"));
Set<ConstantValue> constantValues = generateArray(ConstantValue.class);
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceClient.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceClient.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceClient.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -27,9 +27,7 @@
}
public String loginUser(String login, String password) throws SimExplorerServiceException {
- //TODO Should use this ?
- //throw new SimExplorerServiceException("can not log to local service");
- return null;
+ throw new SimExplorerServiceException("can not log to local service");
}
}
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -41,6 +41,7 @@
import com.healthmarketscience.rmiio.RemoteOutputStreamClient;
import com.healthmarketscience.rmiio.SimpleRemoteInputStream;
+import fr.cemagref.simexplorer.is.contenttype.ContentType;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
@@ -221,7 +222,7 @@
}
}
- public MetaDataEntity saveElement(String token, InputStream xmlFile,
+ private MetaDataEntity saveElement(String token, InputStream xmlFile,
Map<String, InputStream> attachments) throws Exception {
// Store temporary data
String idxml = storageEngine.storeTempData(xmlFile);
@@ -295,43 +296,20 @@
if (metaData.getType() != null
&& VALUE_METADATA_TYPE_EA.equals(metaData.getType())) {
-
- /*
- ExplorationApplication ea = (ExplorationApplication) BaseEntityFactory
- .getFactory(ExplorationApplication.class).loadElement(
- storageEngine.retrieveTempData(idxml));
- */
-
- // If element is an EA, save inner Components and Data
- List<String> components = new ArrayList<String>();
- List<String[]> explorationDatas = new ArrayList<String[]>();
-
- // Retrieve elements
- extractChildren(token, idxml, idsattachment, components,
- explorationDatas);
-
- // For each exploration data
- for (String[] explorationData : explorationDatas) {
- // where is stored xml
- String idxmlED = explorationData[0];
-
- // where is stored result
- Map<String, String> attachmentsED = new HashMap<String, String>();
- if (explorationData.length > 1) {
- attachmentsED.put(explorationData[1], idsattachment
- .get(explorationData[1]));
- }
- // recursive save
- saveElement(token, idxmlED, attachmentsED);
-
- }
-
- // For each component
- for (String idComponent : components) {
- saveElement(token, idComponent, new HashMap<String, String>());
- }
-
+ // Save components
+ saveSubElements(token, idxml,
+ KEY_EXPLORATIONAPPLICATION_COMPONENTS,
+ KEY_EXPLORATIONAPPLICATION_COMPONENT_NODE, idsattachment);
+ // Save exploration data
+ saveSubElements(token, idxml, KEY_EXPLORATIONAPPLICATION_DATA,
+ KEY_EXPLORATIONAPPLICATION_DATA_NODE, idsattachment);
}
+ if (metaData.getType() != null
+ && VALUE_METADATA_TYPE_COMPONENT.equals(metaData.getType())) {
+ // Save libraries
+ saveSubElements(token, idxml, KEY_COMPONENT_LIBRARIES,
+ KEY_COMPONENT_LIBRARY_NODE, idsattachment);
+ }
// Process version rules
processVersionRules(token, metaData);
@@ -340,19 +318,43 @@
Map<String, InputStream> attachments = new HashMap<String, InputStream>();
attachments.put(KEY_XML, storageEngine.retrieveTempData(idxml));
- if (metaData.getType() != null
- && !VALUE_METADATA_TYPE_EA.equals(metaData.getType())) {
- for (Map.Entry<String, String> entry : idsattachment.entrySet()) {
- attachments.put(entry.getKey(), storageEngine
- .retrieveTempData(entry.getValue()));
- }
+
+ Map<String, ContentType> realAttachments = metaData.getAttachments();
+ for (Map.Entry<String, ContentType> entry : realAttachments.entrySet()) {
+ attachments.put(entry.getKey(), storageEngine
+ .retrieveTempData(idsattachment.get(entry.getKey())));
}
+
storageEngine.saveElement(token, metaData, attachments);
storageEngine.commit();
return metaData;
}
+ private void saveSubElements(String token, String idxml,
+ String entitiesNode, String entityNode,
+ Map<String, String> idsattachment) throws Exception {
+
+ BaseEntityFactory<MetaDataEntity> elementFactory = MetaDataEntityFactory
+ .getFactory(MetaDataEntity.class);
+
+ Document document = BaseEntityFactory.getXMLBuilder().parse(
+ storageEngine.retrieveTempData(idxml));
+
+ Element rootElement = (Element) document.getFirstChild();
+
+ // Elements
+ Element entitiesElement = elementFactory.getXMLElementByTagName(
+ rootElement, entitiesNode);
+ Set<Element> entityElements = elementFactory.getXMLElementsByTagName(
+ entitiesElement, entityNode);
+ for (Element element : entityElements) {
+ saveElement(token, storageEngine.storeTempData(BaseEntityFactory
+ .serializeElement(element)), idsattachment);
+ }
+
+ }
+
private void processVersionRules(String token, MetaDataEntity metaData)
throws Exception {
@@ -376,58 +378,6 @@
}
- private void extractChildren(String token, String idxml,
- Map<String, String> idsattachment, List<String> components,
- List<String[]> explorationDatas) throws Exception {
-
- BaseEntityFactory<MetaDataEntity> elementFactory = MetaDataEntityFactory
- .getFactory(MetaDataEntity.class);
-
- Document document = BaseEntityFactory.getXMLBuilder().parse(
- storageEngine.retrieveTempData(idxml));
-
- Element rootElement = (Element) document.getFirstChild();
-
- // Components
- Element componentsElement = elementFactory.getXMLElementByTagName(
- rootElement, KEY_EXPLORATIONAPPLICATION_COMPONENTS);
- Set<Element> componentElements = elementFactory
- .getXMLElementsByTagName(componentsElement,
- KEY_EXPLORATIONAPPLICATION_COMPONENT_NODE);
- for (Element element : componentElements) {
- components.add(storageEngine.storeTempData(BaseEntityFactory
- .serializeElement(element)));
- }
-
- Element applicationDatasElement = elementFactory
- .getXMLElementByTagName(rootElement,
- KEY_EXPLORATIONAPPLICATION_DATA);
- Set<Element> applicationDataElements = elementFactory
- .getXMLElementsByTagName(applicationDatasElement,
- KEY_EXPLORATIONAPPLICATION_DATA_NODE);
-
- for (Element elementAD : applicationDataElements) {
- Element element = elementFactory.getXMLElementByTagName(elementAD,
- KEY_EXPLORATIONDATA_RESULT);
- String result = elementFactory.getXMLProperty(element,
- KEY_RESULT_FILE);
-
- String[] explorationDataArray;
- if (result != null) {
- explorationDataArray = new String[2];
- explorationDataArray[1] = result;
- } else {
- explorationDataArray = new String[1];
- }
- explorationDataArray[0] = storageEngine
- .storeTempData(BaseEntityFactory
- .serializeElement(elementAD));
-
- explorationDatas.add(explorationDataArray);
- }
-
- }
-
public MetaDataEntity[] getVersions(String token, String uuid)
throws SimExplorerServiceException {
try {
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceServer.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceServer.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceServer.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -42,12 +42,6 @@
public String loginUser(String login, String password) throws SimExplorerServiceException {
String token = authenticationService.loginUser(login, password);
- if (token != null) {
- // FIXME datasource différent pour la secu et les timers =
- // impossible de faire des requêtes sur les deux dans la même
- // transaction
- // authenticationService.closeSessionTimer(token);
- }
return token;
}
Modified: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java
===================================================================
--- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -21,20 +21,30 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import java.util.Random;
+import java.util.Set;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
import junit.framework.TestCase;
+
+import com.healthmarketscience.rmiio.RemoteInputStream;
+import com.healthmarketscience.rmiio.RemoteInputStreamServer;
+import com.healthmarketscience.rmiio.SimpleRemoteInputStream;
+
import fr.cemagref.simexplorer.is.contenttype.ContentType;
+import fr.cemagref.simexplorer.is.entities.data.Component;
import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication;
+import fr.cemagref.simexplorer.is.entities.data.ExplorationData;
+import fr.cemagref.simexplorer.is.entities.data.Library;
import fr.cemagref.simexplorer.is.factories.BaseEntityFactory;
import fr.cemagref.simexplorer.is.factories.XmlConstants;
-import fr.cemagref.simexplorer.is.service.StorageServiceClient;
-import fr.cemagref.simexplorer.is.service.StorageServiceCommon;
-import fr.cemagref.simexplorer.is.service.ElementGenerator;
public class StorageServiceMassInsert extends TestCase {
- private StorageServiceCommon storageService;
+ private StorageService storageService;
private ElementGenerator elementGenerator;
private Random r = new Random();
@@ -44,14 +54,14 @@
super.setUp();
elementGenerator = new ElementGenerator();
- storageService = new StorageServiceClient();
- storageService.open();
- }
+ Properties properties = (Properties) System.getProperties().clone();
+ properties.put("java.naming.provider.url", "jnp://localhost:1099");
+ properties.put("java.naming.factory.initial",
+ "org.jnp.interfaces.NamingContextFactory");
+ properties.put("java.naming.factory.url.pkgs", "org.jnp.interfaces");
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- storageService.close();
+ Context context = new InitialContext(properties);
+ storageService = (StorageService) context.lookup("StorageService");
}
/*
@@ -80,31 +90,61 @@
public void testMassInsert() throws Exception {
int c = 5;
+ String token = storageService.loginUser("superadmin", "password");
+
Date begin = new Date();
- ExplorationApplication ea = null;
for (int i = 0; i < c; i++) {
- ea = elementGenerator.generateRandomEA();
+ ExplorationApplication parentEa = null;
+ parentEa = elementGenerator.generateRandomEA();
int v = 2 + r.nextInt(5);
for (int j = 0; j < v; j++) {
+ ExplorationApplication ea = elementGenerator.generateRandomEA();
+ ea.getMetaData().setUuid(parentEa.getMetaData().getUuid());
+ ea.getMetaData().setVersion(
+ parentEa.getMetaData().getVersion().toString());
+
ea.getMetaData().getVersion().incVersion(r.nextInt(3));
InputStream xmlStream = BaseEntityFactory.getFactory(
ExplorationApplication.class).saveElement(
XmlConstants.VALUE_METADATA_TYPE_EA, ea);
- Map<String, InputStream> attachments = new HashMap<String, InputStream>();
- Map<String, ContentType> attachmentsKeys = ea.getMetaData()
- .getAttachments();
+ Map<String, RemoteInputStream> attachments = new HashMap<String, RemoteInputStream>();
+
+ Map<String, ContentType> attachmentsKeys = new HashMap<String, ContentType>();
+
+ attachmentsKeys.putAll(ea.getMetaData().getAttachments());
+ Set<Component> components = ea.getComponents();
+ for (Component component : components) {
+ attachmentsKeys.putAll(component.getMetaData()
+ .getAttachments());
+ Set<Library> libraries = component.getLibraries();
+ for (Library library : libraries) {
+ attachmentsKeys.putAll(library.getMetaData()
+ .getAttachments());
+ }
+ }
+ Set<ExplorationData> explorations = ea.getExplorations();
+ for (ExplorationData explorationData : explorations) {
+ attachmentsKeys.putAll(explorationData.getMetaData()
+ .getAttachments());
+ }
+
for (Map.Entry<String, ContentType> kv : attachmentsKeys
.entrySet()) {
InputStream stream = elementGenerator.generateTextStream();
- attachments.put(kv.getKey(), stream);
+ RemoteInputStreamServer remoteStream = new SimpleRemoteInputStream(
+ stream);
+ attachments.put(kv.getKey(), remoteStream.export());
}
- storageService.saveElement(null, xmlStream, attachments);
+ RemoteInputStreamServer xmlRemoteStream = new SimpleRemoteInputStream(
+ xmlStream);
+ storageService.saveElement(token, xmlRemoteStream.export(),
+ attachments);
}
if (i > 0 && i % 100 == 0) {
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/SimExplorerWebException.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/SimExplorerWebException.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/SimExplorerWebException.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -37,4 +37,9 @@
super(message, cause);
}
+ @Override
+ public String getMessage() {
+ return getMessage();
+ }
+
}
Deleted: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -1,67 +0,0 @@
-/*
-* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-* ##% */
-package fr.cemagref.simexplorer.is.ui.web.pages;
-
-import org.apache.tapestry.upload.services.UploadedFile;
-
-import com.healthmarketscience.rmiio.RemoteInputStreamServer;
-import com.healthmarketscience.rmiio.SimpleRemoteInputStream;
-
-import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
-import fr.cemagref.simexplorer.is.ui.web.pages.security.UserPage;
-import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
-
-public class ApplicationImport extends UserPage {
-
- private UploadedFile fileEA;
- private UploadedFile fileLib;
-
- public UploadedFile getFileEA() {
- return fileEA;
- }
-
- public void setFileEA(UploadedFile fileEA) {
- this.fileEA = fileEA;
- }
-
- public UploadedFile getFileLib() {
- return fileLib;
- }
-
- public void setFileLib(UploadedFile fileLib) {
- this.fileLib = fileLib;
- }
-
- public void onSuccess() {
- if (fileEA != null) {
- RemoteInputStreamServer zipRemoteStream = new SimpleRemoteInputStream(
- fileEA.getStream());
- try {
- RemoteStorageService.getStorageService().saveElement(getToken(),
- zipRemoteStream.export());
- } catch (Exception e) {
- throw new SimExplorerWebException();
- }
- }
- }
-
- public String getWindowTitle() {
- return "";
- }
-
-}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -19,9 +19,11 @@
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
+import java.util.Map.Entry;
import org.apache.tapestry.ComponentResources;
import org.apache.tapestry.Link;
@@ -33,6 +35,7 @@
import com.healthmarketscience.rmiio.RemoteInputStream;
import com.healthmarketscience.rmiio.RemoteInputStreamClient;
+import fr.cemagref.simexplorer.is.contenttype.ContentType;
import fr.cemagref.simexplorer.is.entities.data.Code;
import fr.cemagref.simexplorer.is.entities.data.Component;
import fr.cemagref.simexplorer.is.entities.data.Constant;
@@ -73,31 +76,6 @@
return nodes;
}
- private Object downloadElement(String uuid, String version) {
- StreamResponse response;
-
- try {
- MetaDataEntity mde = RemoteStorageService.getStorageService()
- .getMetadata(getToken(), uuid, version);
- RemoteInputStream ris = RemoteStorageService.getStorageService()
- .retrieveData(getToken(), uuid, version, "_xml");
- InputStream stream = RemoteInputStreamClient.wrap(ris);
-
- response = new AttachmentStreamResponse(stream, "_xml");
- } catch (Exception e) {
- throw new SimExplorerWebException(e);
- }
-
- return response;
- }
-
- public Object onDownload(String context) {
- StringTokenizer st = new StringTokenizer(context, ",");
- String uuid = st.nextToken();
- String version = st.nextToken();
- return downloadElement(uuid, version);
- }
-
private TreeNode generateElement() {
TreeNode node = null;
if (getElement() instanceof ExplorationApplication) {
@@ -128,9 +106,9 @@
node.setType(TreeNode.TYPE_FOLDER);
node.setColumns(generateStringArray("Application exploration",
- getMetadata().getName(), getElement()
- .getMetaData().getVersion().toString(), getElement()
- .getMetaData(), "export", "history", "delete"));
+ getMetadata().getName(), getElement().getMetaData()
+ .getVersion().toString(), getElement().getMetaData(),
+ true, "export", "history", "delete"));
List<TreeNode> children = new ArrayList<TreeNode>();
TreeNode node1 = new TreeNode();
@@ -170,7 +148,7 @@
explorationDataNode.setColumns(generateStringArray("Exploration data",
explorationData.getMetaData().getName(), explorationData
.getMetaData().getVersion().toString(), explorationData
- .getMetaData(), "history", "delete"));
+ .getMetaData(), true, "history", "delete"));
List<TreeNode> children = new ArrayList<TreeNode>();
@@ -207,7 +185,7 @@
res.setType(TreeNode.TYPE_DOCUMENT);
res.setColumns(generateStringArray("Result", "", "", explorationData
- .getMetaData(), "download"));
+ .getMetaData(), false, "export"));
return res;
}
@@ -233,9 +211,11 @@
TreeNode componentNode = new TreeNode();
componentNode.setType(TreeNode.TYPE_FOLDER);
- componentNode.setColumns(generateStringArray("Component", component
- .getMetaData().getName(), component.getMetaData().getVersion()
- .toString(), component.getMetaData(), "history", "delete"));
+ componentNode
+ .setColumns(generateStringArray("Component", component
+ .getMetaData().getName(), component.getMetaData()
+ .getVersion().toString(), component.getMetaData(),
+ true, "history", "delete"));
List<TreeNode> children = new ArrayList<TreeNode>();
@@ -263,7 +243,7 @@
node = initNode();
node.setColumns(generateStringArray("Libraries", "", ""));
- node.setChildren(generateLibraries(component.getLibraries()));
+ node.setChildren(generateLibraries(component));
children.add(node);
@@ -271,18 +251,19 @@
return componentNode;
}
- private List<TreeNode> generateLibraries(Set<Library> libraries) {
+ private List<TreeNode> generateLibraries(Component component) {
+ Set<Library> libraries = component.getLibraries();
+
List<TreeNode> res = new ArrayList<TreeNode>();
int i = 0;
for (Library library : libraries) {
TreeNode node = new TreeNode();
node.setType(TreeNode.TYPE_DOCUMENT);
- node
- .setColumns(generateStringArray("Library", library
- .getMetaData().getName(), library.getMetaData()
- .getVersion().toString(), library.getMetaData(),
- "download"));
+ node.setColumns(generateStringArray("Library", library
+ .getMetaData().getName(), library.getMetaData()
+ .getVersion().toString(), component.getMetaData(), false,
+ "export"));
res.add(node);
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementExport.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementExport.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementExport.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -22,15 +22,25 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Map.Entry;
import org.apache.tapestry.StreamResponse;
+import org.codelutin.tapestry.beans.TreeNode;
import com.healthmarketscience.rmiio.RemoteInputStream;
import com.healthmarketscience.rmiio.RemoteInputStreamClient;
import com.healthmarketscience.rmiio.RemoteOutputStreamServer;
import com.healthmarketscience.rmiio.SimpleRemoteOutputStream;
+import fr.cemagref.simexplorer.is.contenttype.ContentType;
+import fr.cemagref.simexplorer.is.entities.data.Component;
+import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication;
+import fr.cemagref.simexplorer.is.entities.data.ExplorationData;
+import fr.cemagref.simexplorer.is.entities.data.Library;
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity;
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
@@ -38,10 +48,8 @@
import fr.cemagref.simexplorer.is.ui.web.tools.DownloadableFile;
import fr.cemagref.simexplorer.is.ui.web.tools.XMLAttachment;
-public class ElementExport extends ElementPage {
+public class ElementExport extends ElementPageDetail {
- private DownloadableFile attachment;
-
public String getWindowTitle() {
return "";
}
@@ -70,14 +78,17 @@
return response;
}
- public Object onActionFromDownloadFile(String fileName) {
+ public Object onDownloadFile(String context) {
StreamResponse response;
try {
- MetaDataEntity mde = getMetadata();
+ StringTokenizer st = new StringTokenizer(context, ",");
+ String uuid = st.nextToken();
+ String version = st.nextToken();
+ String fileName = st.nextToken();
+
RemoteInputStream ris = RemoteStorageService.getStorageService()
- .retrieveData(getToken(), mde.getUuid(),
- mde.getVersion().toString(), fileName);
+ .retrieveData(getToken(), uuid, version, fileName);
InputStream stream = RemoteInputStreamClient.wrap(ris);
response = new AttachmentStreamResponse(stream, fileName);
@@ -88,23 +99,172 @@
return response;
}
- public List<DownloadableFile> getAttachments() {
- Set<String> attachments = getMetadata().getAttachments().keySet();
- List<DownloadableFile> result = new ArrayList<DownloadableFile>();
- for (String attachment : attachments) {
- DownloadableFile file = new DownloadableFile();
- file.setFilename(attachment);
- result.add(file);
- }
+ /**
+ * Headers of tree grid
+ *
+ * @return Headers
+ */
+ public List<String> getHeaders() {
+ List<String> result = new ArrayList<String>();
+ result.add("Type");
+ result.add("Name");
+ result.add("File");
+ result.add("");
return result;
}
- public DownloadableFile getAttachment() {
- return attachment;
+ public List<TreeNode> getNodes() {
+ List<TreeNode> nodes = new ArrayList<TreeNode>();
+ nodes.add(generateNodes());
+ return nodes;
}
- public void setAttachment(DownloadableFile attachment) {
- this.attachment = attachment;
+ private TreeNode generateNodes() {
+ TreeNode node = null;
+ if (getElement() instanceof ExplorationApplication) {
+ node = generateExplorationApplication();
+ }
+ if (getElement() instanceof ExplorationData) {
+ node = generateExplorationData((ExplorationData) getElement());
+ }
+ if (getElement() instanceof Component) {
+ node = generateComponent((Component) getElement());
+ }
+ return node;
}
+ private TreeNode generateExplorationApplication() {
+ TreeNode node;
+ node = new TreeNode();
+
+ node.setType(TreeNode.TYPE_FOLDER);
+
+ node.setColumns(generateStringArray("Application exploration",
+ getMetadata().getName()));
+
+ List<TreeNode> children = new ArrayList<TreeNode>();
+ TreeNode node1 = new TreeNode();
+ node1.setType(TreeNode.TYPE_FOLDER);
+ node1.setColumns(generateStringArray("Components"));
+ node1
+ .setChildren(generateComponents((ExplorationApplication) getElement()));
+ children.add(node1);
+
+ TreeNode node2 = new TreeNode();
+ node2.setType(TreeNode.TYPE_FOLDER);
+ node2.setColumns(generateStringArray("Explorations"));
+ node2
+ .setChildren(generateExplorations((ExplorationApplication) getElement()));
+ children.add(node2);
+
+ node.setChildren(children);
+ return node;
+ }
+
+ private List<TreeNode> generateExplorations(
+ ExplorationApplication explorationApplication) {
+ List<TreeNode> res = new ArrayList<TreeNode>();
+ int i = 0;
+ for (ExplorationData explorationData : explorationApplication
+ .getExplorations()) {
+ res.add(generateExplorationData(explorationData));
+ i++;
+ }
+ return res;
+ }
+
+ private TreeNode generateExplorationData(ExplorationData explorationData) {
+ TreeNode explorationDataNode = new TreeNode();
+ explorationDataNode.setType(TreeNode.TYPE_FOLDER);
+
+ explorationDataNode.setColumns(generateStringArray("Exploration data",
+ explorationData.getMetaData().getName()));
+
+ List<TreeNode> children = new ArrayList<TreeNode>();
+
+ Map<String, ContentType> attachments = explorationData.getMetaData()
+ .getAttachments();
+
+ for (Map.Entry<String, ContentType> kv : attachments.entrySet()) {
+ children.add(generateDownload(explorationData, kv));
+ }
+ explorationDataNode.setChildren(children);
+
+ return explorationDataNode;
+ }
+
+ private List<TreeNode> generateComponents(
+ ExplorationApplication explorationApplication) {
+ Set<Component> components = explorationApplication.getComponents();
+ List<TreeNode> res = new ArrayList<TreeNode>();
+
+ for (Component component : components) {
+ res.add(generateComponent(component));
+ }
+
+ return res;
+ }
+
+ private TreeNode generateComponent(Component component) {
+ TreeNode componentNode = new TreeNode();
+ componentNode.setType(TreeNode.TYPE_FOLDER);
+
+ componentNode.setColumns(generateStringArray("Component", component
+ .getMetaData().getName()));
+
+ List<TreeNode> children = new ArrayList<TreeNode>();
+
+ TreeNode node = null;
+
+ node = new TreeNode();
+ node.setType(TreeNode.TYPE_FOLDER);
+
+ node.setColumns(generateStringArray("Libraries"));
+ node.setChildren(generateLibraries(component.getLibraries()));
+
+ children.add(node);
+
+ componentNode.setChildren(children);
+ return componentNode;
+ }
+
+ private List<TreeNode> generateLibraries(Set<Library> libraries) {
+ List<TreeNode> res = new ArrayList<TreeNode>();
+ int i = 0;
+ for (Library library : libraries) {
+ TreeNode node = new TreeNode();
+ node.setType(TreeNode.TYPE_FOLDER);
+
+ Map<String, ContentType> attachments = library.getMetaData()
+ .getAttachments();
+ List<TreeNode> children = new ArrayList<TreeNode>();
+ for (Map.Entry<String, ContentType> kv : attachments.entrySet()) {
+ children.add(generateDownload(library, kv));
+ }
+ node.setChildren(children);
+
+ node.setColumns(generateStringArray("Library", library
+ .getMetaData().getName()));
+
+ res.add(node);
+ }
+ return res;
+ }
+
+ private TreeNode generateDownload(LoggableElement explorationData,
+ Entry<String, ContentType> kv) {
+ TreeNode node = new TreeNode();
+ node.setType(TreeNode.TYPE_DOCUMENT);
+
+ String context = explorationData.getMetaData().getUuid() + ","
+ + explorationData.getMetaData().getVersion() + ","
+ + kv.getKey();
+
+ node
+ .setColumns(generateStringArray(kv.getValue().getDescription(),
+ kv.getKey(), generateString(kv.getKey(),
+ "downloadFile", context)));
+ return node;
+ }
+
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -142,7 +142,7 @@
// FIXME date tostring
node.setColumns(generateStringArray(mde.getVersion().toString(), mde
.getDescription(), mde.getCreationDate().toString(), mde,
- "export", "delete", "details"));
+ false, "export", "delete", "details"));
node.setObject(mde.getVersion());
node.setType(TreeNode.TYPE_DOCUMENT);
return node;
Copied: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java (from rev 552, trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.java)
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java (rev 0)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -0,0 +1,77 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.ui.web.pages;
+
+import org.apache.tapestry.upload.services.UploadedFile;
+
+import com.healthmarketscience.rmiio.RemoteInputStreamServer;
+import com.healthmarketscience.rmiio.SimpleRemoteInputStream;
+
+import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
+import fr.cemagref.simexplorer.is.ui.web.pages.security.UserPage;
+import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
+
+public class ElementImport extends UserPage {
+
+ private UploadedFile fileEA;
+ private UploadedFile fileLib;
+
+ public UploadedFile getFileEA() {
+ return fileEA;
+ }
+
+ public void setFileEA(UploadedFile fileEA) {
+ this.fileEA = fileEA;
+ }
+
+ public UploadedFile getFileLib() {
+ return fileLib;
+ }
+
+ public void setFileLib(UploadedFile fileLib) {
+ this.fileLib = fileLib;
+ }
+
+ public void onSuccess() {
+ if (fileEA != null) {
+ RemoteInputStreamServer zipRemoteStream = new SimpleRemoteInputStream(
+ fileEA.getStream());
+ try {
+ RemoteStorageService.getStorageService().saveElement(
+ getToken(), zipRemoteStream.export());
+ } catch (Exception e) {
+ throw new SimExplorerWebException();
+ }
+ }
+ if (fileLib != null) {
+ RemoteInputStreamServer zipRemoteStream = new SimpleRemoteInputStream(
+ fileLib.getStream());
+ try {
+ RemoteStorageService.getStorageService().saveElement(
+ getToken(), zipRemoteStream.export());
+ } catch (Exception e) {
+ throw new SimExplorerWebException();
+ }
+ }
+ }
+
+ public String getWindowTitle() {
+ return "";
+ }
+
+}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPageDetail.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPageDetail.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPageDetail.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -89,9 +89,8 @@
return elementDetail;
}
- private String generateString(String actionCaption, String action,
- MetaDataEntity element) {
- String context = element.getUuid() + "," + element.getVersion();
+ protected String generateString(String actionCaption, String action,
+ String context) {
Link link = resources.createActionLink(action, false, context);
StringBuffer sb = new StringBuffer("");
sb.append("<a href=\"");
@@ -102,7 +101,14 @@
return sb.toString();
}
- private String generateActions(MetaDataEntity element, String... actions) {
+ protected String generateString(String actionCaption, String action,
+ MetaDataEntity element) {
+ String context = element.getUuid() + "," + element.getVersion();
+ return generateString(actionCaption, action, context);
+ }
+
+ private String generateActions(MetaDataEntity element, boolean security,
+ String... actions) {
StringBuilder sb = new StringBuilder("");
String res;
@@ -110,23 +116,25 @@
sb.append("<br>");
sb.append(generateString(anAction, anAction, element));
}
- sb.append("<br>");
- // TODO add security
- sb.append(generateString("rights", "rights", element));
+ if (security) {
+ sb.append("<br>");
+ // TODO add security
+ sb.append(generateString("rights", "rights", element));
+ }
res = sb.substring(4);
return res;
}
protected String[] generateStringArray(String s1, String s2, String s3,
- MetaDataEntity element, String... actions) {
+ MetaDataEntity element, boolean security, String... actions) {
List<String> result = new ArrayList<String>();
result.add(s1);
result.add(s2);
result.add(s3);
String s4 = "";
if (element != null) {
- s4 = generateActions(element, actions);
+ s4 = generateActions(element, security, actions);
}
result.add(s4);
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -47,13 +47,14 @@
public String getWindowTitle() {
return "Error";
}
-
+
public void reportException(Throwable exception) {
- if (exception instanceof SimExplorerWebException) {
+ SimExplorerWebException simException = getException(exception);
+ if (simException != null) {
// unknown = false;
// FIXME debug mode
- unknown = true;
- this.exception = (SimExplorerWebException) exception;
+ unknown = false;
+ this.exception = simException;
} else {
unknown = true;
ExceptionAnalysis analysis = analyzer.analyze(exception);
@@ -61,8 +62,23 @@
}
}
+ private SimExplorerWebException getException(Throwable exception) {
+ if (exception != null) {
+ if (exception instanceof SimExplorerWebException) {
+ SimExplorerWebException result = (SimExplorerWebException) exception;
+ return result;
+ }
+ return getException(exception.getCause());
+ }
+ return null;
+ }
+
public String getErrorMessage() {
- return "Custom message describing error.";
+ if (!unknown) {
+ return exception.getMessage();
+ } else {
+ return "";
+ }
}
public boolean getShowPropertyList() {
@@ -71,11 +87,10 @@
.isEmpty());
}
- public Object getPropertyValue()
- {
+ public Object getPropertyValue() {
return info.getProperty(propertyName);
}
-
+
public List<ExceptionInfo> getStack() {
return stack;
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/DownloadableFile.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/DownloadableFile.java 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/DownloadableFile.java 2008-01-28 16:37:53 UTC (rev 553)
@@ -17,8 +17,11 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.web.tools;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity;
+
public class DownloadableFile {
+ private MetaDataEntity metaDataEntity;
private String filename;
public String getFilename() {
@@ -29,4 +32,12 @@
this.filename = filename;
}
+ public MetaDataEntity getMetaDataEntity() {
+ return metaDataEntity;
+ }
+
+ public void setMetaDataEntity(MetaDataEntity metaDataEntity) {
+ this.metaDataEntity = metaDataEntity;
+ }
+
}
Deleted: trunk/simexplorer-is-web/src/main/webapp/ApplicationImport.tml
===================================================================
--- trunk/simexplorer-is-web/src/main/webapp/ApplicationImport.tml 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/main/webapp/ApplicationImport.tml 2008-01-28 16:37:53 UTC (rev 553)
@@ -1,20 +0,0 @@
-<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
- title="${windowtitle}">
-
- <t:form>
- <t:errors/>
-
- <h1 class="Title">${message:explorationapplication}</h1>
-
- <input t:type="upload" t:id="fileEA"/>
- <br/>
-
- <h1 class="Title">${message:library}</h1>
-
- <input t:type="upload" t:id="fileLib"/>
- <br/>
-
- <input type="submit" value="${message:upload}"/>
- </t:form>
-
-</t:layout>
Modified: trunk/simexplorer-is-web/src/main/webapp/ElementExport.tml
===================================================================
--- trunk/simexplorer-is-web/src/main/webapp/ElementExport.tml 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/main/webapp/ElementExport.tml 2008-01-28 16:37:53 UTC (rev 553)
@@ -7,15 +7,8 @@
<p>
<h2>${message:attachments}</h2>
</p>
- <p>${message:download}</p>
<p>
- <table t:type="Grid" source="attachments" row="attachment">
- <t:parameter name="empty">
- noAttachment ${message:noAttachment}
- </t:parameter>
- <t:parameter name="filenameCell">
- <t:actionlink t:id="downloadFile" context="${attachment.filename}">${attachment.filename}</t:actionlink>
- </t:parameter>
+ <table t:type="cl/TreeGrid" source="nodes" columnHeaders="headers">
</table>
</p>
Copied: trunk/simexplorer-is-web/src/main/webapp/ElementImport.tml (from rev 552, trunk/simexplorer-is-web/src/main/webapp/ApplicationImport.tml)
===================================================================
--- trunk/simexplorer-is-web/src/main/webapp/ElementImport.tml (rev 0)
+++ trunk/simexplorer-is-web/src/main/webapp/ElementImport.tml 2008-01-28 16:37:53 UTC (rev 553)
@@ -0,0 +1,20 @@
+<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
+ title="${windowtitle}">
+
+ <t:form>
+ <t:errors/>
+
+ <h1 class="Title">${message:explorationapplication}</h1>
+
+ <input t:type="upload" t:id="fileEA"/>
+ <br/>
+
+ <h1 class="Title">${message:library}</h1>
+
+ <input t:type="upload" t:id="fileLib"/>
+ <br/>
+
+ <input type="submit" value="${message:upload}"/>
+ </t:form>
+
+</t:layout>
Modified: trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/components/Layout.tml
===================================================================
--- trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/components/Layout.tml 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/components/Layout.tml 2008-01-28 16:37:53 UTC (rev 553)
@@ -28,7 +28,7 @@
<menu class="menu">
<li><t:actionlink t:id="applicationList">${message:layout-list}</t:actionlink>
</li>
- <li><t:pagelink page="ApplicationImport">${message:layout-import}</t:pagelink></li>
+ <li><t:pagelink page="ElementImport">${message:layout-import}</t:pagelink></li>
</menu>
<t:if test="administrator">
Deleted: trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.properties
===================================================================
--- trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.properties 2008-01-28 13:00:46 UTC (rev 552)
+++ trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.properties 2008-01-28 16:37:53 UTC (rev 553)
@@ -1 +0,0 @@
-windowtitle=Import
Copied: trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.properties (from rev 552, trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/pages/ApplicationImport.properties)
===================================================================
--- trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.properties (rev 0)
+++ trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.properties 2008-01-28 16:37:53 UTC (rev 553)
@@ -0,0 +1 @@
+windowtitle=Import
1
0
r552 - in trunk: simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service simexplorer-is-storage/src/resources/properties simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools simexpl
by glandais@users.labs.libre-entreprise.org 28 Jan '08
by glandais@users.labs.libre-entreprise.org 28 Jan '08
28 Jan '08
Author: glandais
Date: 2008-01-28 13:00:46 +0000 (Mon, 28 Jan 2008)
New Revision: 552
Added:
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/DownloadableFile.java
Modified:
trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/RawType.java
trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurity.java
trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationService.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockAuthenticationServiceImpl.java
trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityTestCase.java
trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java
trunk/simexplorer-is-storage/src/resources/properties/config.properties
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementExport.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPage.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementRights.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupEdit.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserEdit.java
trunk/simexplorer-is-web/src/main/webapp/ElementExport.tml
trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml
trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/components/Layout.tml
Log:
Security updates
Modified: trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/RawType.java
===================================================================
--- trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/RawType.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/RawType.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -20,6 +20,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.io.Serializable;
/**
* Raw content type
@@ -27,8 +28,10 @@
* @author landais
*
*/
-public class RawType extends ContentType {
+public class RawType extends ContentType implements Serializable {
+ private static final long serialVersionUID = -8010160085848440286L;
+
/**
* Set inner properties
*/
Modified: trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurity.java
===================================================================
--- trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurity.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurity.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -52,7 +52,15 @@
public void saveToken(LoginAction loginAction);
- public void deleteToken(String token);
+ /**
+ * Delete old tokens associated to user
+ *
+ * @param login
+ * Login of user
+ * @param before
+ * ms before now
+ */
+ public void deleteTokens(String login, long before);
public List<Group> getGroups();
Modified: trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java
===================================================================
--- trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -130,13 +130,14 @@
em.persist(loginAction);
}
- public void deleteToken(String token) {
- LoginAction loginAction = (LoginAction) getSingleResult(em.createQuery(
- "select la from LoginAction la where la.token=:token")
- .setParameter("token", token));
- if (loginAction != null) {
- em.remove(loginAction);
- }
+ public void deleteTokens(String login, long before) {
+ Date now = new Date();
+ Date date = new Date(now.getTime() - before);
+ em
+ .createQuery(
+ "delete from LoginAction la where la.loggedUser.login = :login and la.time < :time")
+ .setParameter("time", date)
+ .setParameter("login", login).executeUpdate();
}
public User getUser(String login) {
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationService.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationService.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationService.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -29,19 +29,16 @@
public String loginUser(String login, String password)
throws SimExplorerServiceException;
- public void closeSessionTimer(String token)
+ public void requestAccount(String login, String mail)
throws SimExplorerServiceException;
- public User requestAccount(String login, String mail)
- throws SimExplorerServiceException;
-
public User saveUser(String token, String login, String mail)
throws SimExplorerServiceException;
public void resetPassword(String token, String login)
throws SimExplorerServiceException;
- public void changePassword(String token, String login, String password)
+ public void changePassword(String token, String password)
throws SimExplorerServiceException;
public User getUser(String token, Integer id)
@@ -76,7 +73,7 @@
public void setGroupsOfUser(String token, User user, Integer[] groupsIds)
throws SimExplorerServiceException;
- public Group saveGroup(String token, String name, User owner)
+ public Group saveGroup(String token, String name)
throws SimExplorerServiceException;
public Group getGroup(String token, Integer id)
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -20,19 +20,16 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
-import java.util.Arrays;
import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
-import javax.ejb.Timeout;
-import javax.ejb.Timer;
-import javax.ejb.TimerService;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
@@ -62,13 +59,9 @@
/*
javax.mail.Session mailSession = (javax.mail.Session) new InitialContext().lookup("java:/Mail");
javax.mail.Message msg = new MimeMessage(mailSession);
- msg.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse("AQui at aQui.be,siplusieuradresse at hotmail.com", false));
- msg.setSubject("This is a test");
- msg.setContent("<html><body><h2>Helle le monde mondial des terriens " +
- " Petit test de jboss Mail-Service" +
- " Ne m'en voulez pas si vous recevez ce mail alors que vous nedevrez pas " +
- " Braim " +
- "</h2></body></html>", "text/html");
+ msg.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(mail, false));
+ msg.setSubject("");
+ msg.setContent("", "text/text");
msg.setHeader("X-Mailer", "JavaMailer");
msg.setSentDate(new java.util.Date());
Transport.send(msg);
@@ -95,6 +88,53 @@
return "password";
}
+ private boolean canAdminGroup(String token, Integer id)
+ throws SimExplorerServiceException {
+ User loggedUser = getLoggedUser(token);
+ if (loggedUser != null) {
+ if (loggedUser.isSuperAdmin()) {
+ return true;
+ }
+ if (loggedUser.isAdmin()) {
+ return userOwnerOfGroup(loggedUser, dao.getGroup(id));
+ }
+ }
+ return false;
+ }
+
+ private boolean userOwnerOfGroup(User loggedUser, Group group) {
+ if (group.getOwner().getId() == loggedUser.getId()) {
+ return true;
+ }
+ List<Group> groups = group.getGroups();
+ for (Group parent : groups) {
+ if (userOwnerOfGroup(loggedUser, parent)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean canAdminUser(String token, Integer id)
+ throws SimExplorerServiceException {
+ User loggedUser = getLoggedUser(token);
+ if (loggedUser != null) {
+ if (loggedUser.isSuperAdmin()) {
+ return true;
+ }
+ if (loggedUser.isAdmin()) {
+ User user = dao.getUser(id);
+ List<Group> groups = user.getGroups();
+ for (Group group : groups) {
+ if (canAdminGroup(token, group.getId())) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
private void removeUserFromGroup(User user, Group group) {
List<Group> toRemove = new ArrayList<Group>();
for (Group testGroup : user.getGroups()) {
@@ -107,67 +147,116 @@
}
}
- public void deleteGroup(String token, Integer id) {
- dao.deleteGroup(id);
+ public void deleteGroup(String token, Integer id)
+ throws SimExplorerServiceException {
+ if (canAdminGroup(token, id)) {
+ dao.deleteGroup(id);
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
- public void deleteUser(String token, Integer id) {
- dao.deleteUser(id);
+ public void deleteUser(String token, Integer id)
+ throws SimExplorerServiceException {
+ if (canAdminUser(token, id)) {
+ dao.deleteUser(id);
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
- public Group getGroup(String token, Integer id) {
- return dao.getGroup(id);
+ public Group getGroup(String token, Integer id)
+ throws SimExplorerServiceException {
+ if (canAdminGroup(token, id)) {
+ return dao.getGroup(id);
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
- public Group getGroup(String token, String name) {
- return dao.getGroup(name);
+ public Group getGroup(String token, String name)
+ throws SimExplorerServiceException {
+ Group group = dao.getGroup(name);
+ if (canAdminGroup(token, group.getId())) {
+ return group;
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
- public User getUser(String token, Integer id) {
- return dao.getUser(id);
+ public User getUser(String token, Integer id)
+ throws SimExplorerServiceException {
+ if (canAdminUser(token, id)) {
+ return dao.getUser(id);
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
- public User getUser(String token, String login) {
- return dao.getUser(login);
+ public User getUser(String token, String login)
+ throws SimExplorerServiceException {
+ User user = dao.getUser(login);
+ if (canAdminUser(token, user.getId())) {
+ return user;
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
- public Group saveGroup(String token, String name, User owner) {
- Group group = new Group();
- group.setName(name);
- group.setOwner(owner);
- dao.saveGroup(group);
- group = getGroup(token, group.getId());
- return group;
+ public Group saveGroup(String token, String name)
+ throws SimExplorerServiceException {
+ User loggedUser = getLoggedUser(token);
+ if (loggedUser.isAdmin() || loggedUser.isSuperAdmin()) {
+ Group group = new Group();
+ group.setName(name);
+ group.setOwner(loggedUser);
+ dao.saveGroup(group);
+ group = getGroup(token, group.getId());
+ return group;
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
public User saveUser(String token, String login, String mail)
throws SimExplorerServiceException {
- User user = new User();
- user.setLogin(login);
- user.setMail(mail);
- String password = generatePassword();
- sendMail(login, mail, password);
- String passwordHash = computeHash(password);
- user.setPasswordHash(passwordHash);
- user.setAdmin(false);
- user.setSuperAdmin(false);
- dao.saveUser(user);
- user = getUser(token, user.getId());
- return user;
+ User loggedUser = getLoggedUser(token);
+ if (loggedUser.isAdmin() || loggedUser.isSuperAdmin()) {
+ User user = new User();
+ user.setLogin(login);
+ user.setMail(mail);
+ String password = generatePassword();
+ sendMail(login, mail, password);
+ String passwordHash = computeHash(password);
+ user.setPasswordHash(passwordHash);
+ user.setAdmin(false);
+ user.setSuperAdmin(false);
+ dao.saveUser(user);
+ user = getUser(token, user.getId());
+ return user;
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
- public Group updateGroup(String token, Group group) {
- return dao.updateGroup(group);
+ public Group updateGroup(String token, Group group)
+ throws SimExplorerServiceException {
+ if (canAdminGroup(token, group.getId())) {
+ return dao.updateGroup(group);
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
- public User updateUser(String token, User user) {
- return dao.updateUser(user);
+ public User updateUser(String token, User user)
+ throws SimExplorerServiceException {
+ if (canAdminUser(token, user.getId())) {
+ return dao.updateUser(user);
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
- public User getLoggedUser(String token) {
+ public User getLoggedUser(String token) throws SimExplorerServiceException {
+ if (token == null || token.equals("")) {
+ return null;
+ }
User loggedUser;
loggedUser = dao.getLoggedUser(token);
- return loggedUser;
+ if (loggedUser != null) {
+ return loggedUser;
+ }
+ throw new SimExplorerServiceException("simexplorer.security.loggedoff");
}
private void checkSuperAdmin() throws SimExplorerServiceException {
@@ -193,6 +282,8 @@
String token = null;
User loggedUser = dao.loginUser(login, computeHash(password));
if (loggedUser != null) {
+ // dao.deleteTokens(login, 10 * 60 * 1000);
+
LoginAction loginAction = new LoginAction();
loginAction.setLoggedUser(loggedUser);
loginAction.setTime(new Date());
@@ -203,20 +294,10 @@
return token;
}
- public void closeSessionTimer(String token) {
- // FIXME session length
- TimerService timerService = sessionContext.getTimerService();
- timerService.createTimer(10 * 60 * 1000, token);
- }
-
- @Timeout
- public void timeoutHandler(Timer timer) {
- String token = (String) timer.getInfo();
- dao.deleteToken(token);
- }
-
- public User requestAccount(String login, String mail)
+ public void requestAccount(String login, String mail)
throws SimExplorerServiceException {
+ // FIXME send mail to superadmin
+ /*
User user = new User();
user.setLogin(login);
user.setMail(mail);
@@ -226,24 +307,28 @@
user.setPasswordHash(passwordHash);
dao.saveUser(user);
return user;
+ */
}
- public void changePassword(String token, String login, String password)
+ public void changePassword(String token, String password)
throws SimExplorerServiceException {
- User user = getUser(token, login);
+ User user = getLoggedUser(token);
String passwordHash = computeHash(password);
user.setPasswordHash(passwordHash);
- dao.saveUser(user);
+ dao.updateUser(user);
}
public void resetPassword(String token, String login)
throws SimExplorerServiceException {
User user = getUser(token, login);
- String password = generatePassword();
- sendMail(login, user.getMail(), password);
- String passwordHash = computeHash(password);
- user.setPasswordHash(passwordHash);
- dao.saveUser(user);
+ if (canAdminUser(token, user.getId())) {
+ String password = generatePassword();
+ sendMail(login, user.getMail(), password);
+ String passwordHash = computeHash(password);
+ user.setPasswordHash(passwordHash);
+ dao.updateUser(user);
+ }
+ throw new SimExplorerServiceException("simexplorer.security.norights");
}
public Group[] getGroups(String token) {
@@ -259,7 +344,8 @@
}
public User[] getUsers(String token) {
- return dao.getUsers().toArray(new User[dao.getUsers().size()]);
+ List<User> users = dao.getUsers();
+ return users.toArray(new User[users.size()]);
}
public User[] getUsersOfGroup(String token, Group group) {
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockAuthenticationServiceImpl.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockAuthenticationServiceImpl.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockAuthenticationServiceImpl.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -21,10 +21,8 @@
import fr.cemagref.simexplorer.is.security.entities.Permission;
import fr.cemagref.simexplorer.is.security.entities.User;
-
public class MockAuthenticationServiceImpl implements AuthenticationService {
-
public String loginUser(String login, String password) {
return (String) checkImplemented();
}
@@ -33,8 +31,8 @@
checkImplemented();
}
- public User requestAccount(String login, String mail) {
- return (User) checkImplemented();
+ public void requestAccount(String login, String mail) {
+ checkImplemented();
}
public User saveUser(String token, String login, String mail) {
@@ -45,7 +43,7 @@
checkImplemented();
}
- public void changePassword(String token, String login, String password) {
+ public void changePassword(String token, String password) {
checkImplemented();
}
@@ -73,7 +71,8 @@
return (User[]) checkImplemented();
}
- public void setUsersOfGroup(String token, Group group, Integer[] usersInGroup) {
+ public void setUsersOfGroup(String token, Group group,
+ Integer[] usersInGroup) {
checkImplemented();
}
@@ -93,7 +92,7 @@
checkImplemented();
}
- public Group saveGroup(String token, String name, User owner) {
+ public Group saveGroup(String token, String name) {
return (Group) checkImplemented();
}
@@ -136,6 +135,6 @@
public void setPermissions(String uuid, Permission[] permissions) {
// TODO Auto-generated method stub
-
+
}
}
\ No newline at end of file
Modified: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityTestCase.java
===================================================================
--- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityTestCase.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityTestCase.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -56,8 +56,7 @@
String token = authenticationService
.loginUser("superadmin", "password");
- Group everybody = authenticationService.saveGroup(token, "everybody",
- authenticationService.getLoggedUser(token));
+ Group everybody = authenticationService.saveGroup(token, "everybody");
User me = authenticationService.getLoggedUser(token);
me.getGroups().add(everybody);
@@ -83,8 +82,11 @@
adminUsers[i].getGroups().add(everybody);
authenticationService.updateUser(token, adminUsers[i]);
- groups[i] = authenticationService.saveGroup(token, "group" + i,
- adminUsers[i]);
+ String tokenAdmin = authenticationService.loginUser("admin" + i,
+ "password");
+
+ groups[i] = authenticationService
+ .saveGroup(tokenAdmin, "group" + i);
for (int j = i * 4; j < (i * 4 + 5); j++) {
simpleUsers[j].getGroups().add(groups[i]);
authenticationService.updateUser(token, simpleUsers[j]);
Modified: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java
===================================================================
--- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -21,6 +21,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.util.Random;
import junit.framework.TestCase;
import fr.cemagref.simexplorer.is.contenttype.ContentType;
@@ -36,6 +37,8 @@
private StorageServiceCommon storageService;
private ElementGenerator elementGenerator;
+ private Random r = new Random();
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -82,20 +85,28 @@
ExplorationApplication ea = null;
for (int i = 0; i < c; i++) {
ea = elementGenerator.generateRandomEA();
- InputStream xmlStream = BaseEntityFactory.getFactory(
- ExplorationApplication.class).saveElement(
- XmlConstants.VALUE_METADATA_TYPE_EA, ea);
- Map<String, InputStream> attachments = new HashMap<String, InputStream>();
- Map<String, ContentType> attachmentsKeys = ea.getMetaData()
- .getAttachments();
- for (Map.Entry<String, ContentType> kv : attachmentsKeys.entrySet()) {
- InputStream stream = elementGenerator.generateTextStream();
- attachments.put(kv.getKey(), stream);
+ int v = 2 + r.nextInt(5);
+
+ for (int j = 0; j < v; j++) {
+ ea.getMetaData().getVersion().incVersion(r.nextInt(3));
+
+ InputStream xmlStream = BaseEntityFactory.getFactory(
+ ExplorationApplication.class).saveElement(
+ XmlConstants.VALUE_METADATA_TYPE_EA, ea);
+
+ Map<String, InputStream> attachments = new HashMap<String, InputStream>();
+ Map<String, ContentType> attachmentsKeys = ea.getMetaData()
+ .getAttachments();
+ for (Map.Entry<String, ContentType> kv : attachmentsKeys
+ .entrySet()) {
+ InputStream stream = elementGenerator.generateTextStream();
+ attachments.put(kv.getKey(), stream);
+ }
+
+ storageService.saveElement(null, xmlStream, attachments);
}
- storageService.saveElement(null, xmlStream, attachments);
-
if (i > 0 && i % 100 == 0) {
Date end = new Date();
long time = end.getTime() - begin.getTime();
Modified: trunk/simexplorer-is-storage/src/resources/properties/config.properties
===================================================================
--- trunk/simexplorer-is-storage/src/resources/properties/config.properties 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-storage/src/resources/properties/config.properties 2008-01-28 13:00:46 UTC (rev 552)
@@ -1,3 +1,3 @@
-simexplorer.db=/var/local/simexplorer/db3
-simexplorer.data=/var/local/simexplorer/data3/
+simexplorer.db=/var/local/simexplorer/db4
+simexplorer.data=/var/local/simexplorer/data4/
simexplorer.optimizeperiod=3600
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -36,8 +36,8 @@
public Object onActionFromConfirm() {
try {
RemoteStorageService.getStorageService().deleteElement(getToken(),
- getElement().getMetaData().getUuid(),
- getElement().getMetaData().getVersion().toString());
+ getMetadata().getUuid(),
+ getMetadata().getVersion().toString());
} catch (SimExplorerServiceException e) {
throw new SimExplorerWebException(e);
}
@@ -47,7 +47,7 @@
public Object onActionFromConfirmAll() {
try {
RemoteStorageService.getStorageService().deleteElement(getToken(),
- getElement().getMetaData().getUuid());
+ getMetadata().getUuid());
} catch (SimExplorerServiceException e) {
throw new SimExplorerWebException(e);
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -128,7 +128,7 @@
node.setType(TreeNode.TYPE_FOLDER);
node.setColumns(generateStringArray("Application exploration",
- getElement().getMetaData().getName(), getElement()
+ getMetadata().getName(), getElement()
.getMetaData().getVersion().toString(), getElement()
.getMetaData(), "export", "history", "delete"));
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementExport.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementExport.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementExport.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -19,29 +19,38 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
+import org.apache.tapestry.StreamResponse;
+
+import com.healthmarketscience.rmiio.RemoteInputStream;
+import com.healthmarketscience.rmiio.RemoteInputStreamClient;
import com.healthmarketscience.rmiio.RemoteOutputStreamServer;
import com.healthmarketscience.rmiio.SimpleRemoteOutputStream;
import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity;
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
+import fr.cemagref.simexplorer.is.ui.web.tools.AttachmentStreamResponse;
+import fr.cemagref.simexplorer.is.ui.web.tools.DownloadableFile;
import fr.cemagref.simexplorer.is.ui.web.tools.XMLAttachment;
public class ElementExport extends ElementPage {
- private String attachment;
+ private DownloadableFile attachment;
public String getWindowTitle() {
return "";
}
-
+
public Object onActionFromDownloadXML() {
Object response;
- MetaDataEntity mde = getElement().getMetaData();
+ MetaDataEntity mde = getMetadata();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
RemoteOutputStreamServer xmlRemoteOutputStream = new SimpleRemoteOutputStream(
@@ -61,17 +70,40 @@
return response;
}
- public Set<String> getAttachments() {
- Set<String> result = getElement().getMetaData().getAttachments()
- .keySet();
+ public Object onActionFromDownloadFile(String fileName) {
+ StreamResponse response;
+
+ try {
+ MetaDataEntity mde = getMetadata();
+ RemoteInputStream ris = RemoteStorageService.getStorageService()
+ .retrieveData(getToken(), mde.getUuid(),
+ mde.getVersion().toString(), fileName);
+ InputStream stream = RemoteInputStreamClient.wrap(ris);
+
+ response = new AttachmentStreamResponse(stream, fileName);
+ } catch (Exception e) {
+ throw new SimExplorerWebException(e);
+ }
+
+ return response;
+ }
+
+ public List<DownloadableFile> getAttachments() {
+ Set<String> attachments = getMetadata().getAttachments().keySet();
+ List<DownloadableFile> result = new ArrayList<DownloadableFile>();
+ for (String attachment : attachments) {
+ DownloadableFile file = new DownloadableFile();
+ file.setFilename(attachment);
+ result.add(file);
+ }
return result;
}
- public String getAttachment() {
+ public DownloadableFile getAttachment() {
return attachment;
}
- public void setAttachment(String attachment) {
+ public void setAttachment(DownloadableFile attachment) {
this.attachment = attachment;
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPage.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPage.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPage.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -22,6 +22,7 @@
import org.apache.tapestry.ioc.annotations.Inject;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity;
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
import fr.cemagref.simexplorer.is.ui.web.pages.security.UserPage;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
@@ -52,4 +53,8 @@
return element;
}
+ public MetaDataEntity getMetadata() {
+ return element.getMetaData();
+ }
+
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementRights.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementRights.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementRights.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -70,7 +70,7 @@
public String getWindowTitle() {
return "";
}
-
+
@Override
public void setup(String uuid, String version) {
super.setup(uuid, version);
@@ -91,7 +91,7 @@
Permission[] permissions = RemoteSecurityService
.getAuthentificationService().getPermissions(
- getElement().getMetaData().getUuid());
+ getMetadata().getUuid());
for (Permission permission : permissions) {
if (permission.isOwner() && permission.getActor() instanceof User) {
ownerUsers.add((User) permission.getActor());
@@ -133,7 +133,7 @@
if (permission == null) {
permission = new Permission();
permission.setActor(actor);
- permission.setBusinessId(getElement().getMetaData().getUuid());
+ permission.setBusinessId(getMetadata().getUuid());
permission.setOwner(false);
permission.setCanRead(false);
permission.setCanWrite(false);
@@ -176,7 +176,7 @@
new Permission[permissions.values().size()]);
RemoteSecurityService.getAuthentificationService().setPermissions(
- getElement().getMetaData().getUuid(), permissionsArray);
+ getMetadata().getUuid(), permissionsArray);
return elementDetail;
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -62,7 +62,7 @@
}
public String getErrorMessage() {
- return "Error";
+ return "Custom message describing error.";
}
public boolean getShowPropertyList() {
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupEdit.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupEdit.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupEdit.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -57,7 +57,7 @@
public String getWindowTitle() {
return "";
}
-
+
void setup(int groupId) {
this.usersInGroup = new ArrayList<User>();
this.groupsInGroup = new ArrayList<Group>();
@@ -90,9 +90,8 @@
public Object onSuccess() {
try {
if (group.getId() == null) {
- group = RemoteSecurityService
- .getAuthentificationService()
- .saveGroup(getToken(), group.getName(), getUserLogged());
+ group = RemoteSecurityService.getAuthentificationService()
+ .saveGroup(getToken(), group.getName());
} else {
group = RemoteSecurityService.getAuthentificationService()
.updateGroup(getToken(), group);
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -43,8 +43,6 @@
token = RemoteSecurityService.getAuthentificationService()
.loginUser(user, password);
if (token != null) {
- RemoteSecurityService.getAuthentificationService()
- .closeSessionTimer(token);
result = elementList;
}
} catch (SimExplorerServiceException e) {
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserEdit.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserEdit.java 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserEdit.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -66,7 +66,7 @@
public String getWindowTitle() {
return "";
}
-
+
void pageLoaded() {
groupModel = beanModelSource.create(Group.class, true, resources);
List<String> wantedProperties = new ArrayList<String>();
@@ -79,14 +79,14 @@
}
}
- void setup(int groupId) {
+ void setup(int userId) {
this.groupsOfUser = new ArrayList<Group>();
- if (groupId == -1) {
+ if (userId == -1) {
this.user = new User();
} else {
try {
this.user = RemoteSecurityService.getAuthentificationService()
- .getUser(getToken(), groupId);
+ .getUser(getToken(), userId);
Group[] groups = RemoteSecurityService
.getAuthentificationService().getGroupsOfUser(
getToken(), this.user);
@@ -139,8 +139,12 @@
public Group[] getOwnedGroups() {
try {
- return RemoteSecurityService.getAuthentificationService()
- .getGroupsOwnedBy(getToken(), user);
+ if (user.getId() == null) {
+ return new Group[0];
+ } else {
+ return RemoteSecurityService.getAuthentificationService()
+ .getGroupsOwnedBy(getToken(), user);
+ }
} catch (SimExplorerServiceException e) {
throw new SimExplorerWebException(e);
}
Added: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/DownloadableFile.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/DownloadableFile.java (rev 0)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/DownloadableFile.java 2008-01-28 13:00:46 UTC (rev 552)
@@ -0,0 +1,32 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.ui.web.tools;
+
+public class DownloadableFile {
+
+ private String filename;
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+
+}
Modified: trunk/simexplorer-is-web/src/main/webapp/ElementExport.tml
===================================================================
--- trunk/simexplorer-is-web/src/main/webapp/ElementExport.tml 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/main/webapp/ElementExport.tml 2008-01-28 13:00:46 UTC (rev 552)
@@ -6,14 +6,19 @@
<p>
<h2>${message:attachments}</h2>
- <br />
+ </p>
+ <p>${message:download}</p>
+ <p>
<table t:type="Grid" source="attachments" row="attachment">
<t:parameter name="empty">
- ${message:noAttachment}
+ noAttachment ${message:noAttachment}
</t:parameter>
+ <t:parameter name="filenameCell">
+ <t:actionlink t:id="downloadFile" context="${attachment.filename}">${attachment.filename}</t:actionlink>
+ </t:parameter>
</table>
</p>
-
+
<p><t:back label="${message:back}" /></p>
</t:layout>
Modified: trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml
===================================================================
--- trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml 2008-01-28 13:00:46 UTC (rev 552)
@@ -4,8 +4,10 @@
${errormessage}
<t:if test="unknown">
-
- <div class="t-exception-report">
+
+ <h1>Unknown Exception</h1>
+
+ <div class="t-exception-report" id="errordetail">
<ul>
<t:loop source="stack" value="info">
<li><span class="t-exception-class-name">${info.className}</span>
Modified: trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/components/Layout.tml
===================================================================
--- trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/components/Layout.tml 2008-01-27 15:19:44 UTC (rev 551)
+++ trunk/simexplorer-is-web/src/resources/fr/cemagref/simexplorer/is/ui/web/components/Layout.tml 2008-01-28 13:00:46 UTC (rev 552)
@@ -1,80 +1,62 @@
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
- <head>
- <title>${title}</title>
- </head>
-
- <body>
-
- <!-- titre -->
- <h1 id="Title">${message:layout-pagetitle}</h1>
-
- <!-- barre -->
- <div id="Header">
- <div class="Left">
- [<a t:type="actionlink" t:id="switchLocaleEn">${message:layout-localeen}</a>]
- -
- [<a t:type="actionlink" t:id="switchLocaleFr">${message:layout-localefr}</a>]
- </div>
- <t:if test="logged">
- <div class="Right">
- ${loginName} [<a t:type="actionlink" t:id="logout">${message:layout-logout}</a>]
- </div>
- </t:if>
- </div>
-
- <t:if test="logged">
+<head>
+<title>${title}</title>
+</head>
- <div id="Menu" class="">
+<body>
- <!-- menu -->
- <h1 class="tab">${message:layout-menutitle}</h1>
- <div id="tabMenu">
-
- <h2 class="Title">${message:layout-applications}</h2>
- <menu class="menu">
- <li>
- <t:actionlink t:id="applicationList">${message:layout-list}</t:actionlink>
- </li>
- <li><t:pagelink page="ApplicationImport">${message:layout-import}</t:pagelink></li>
- </menu>
-
- <t:if test="administrator">
-
- <h2 class="Title">${message:layout-administration}</h2>
- <menu class="menu">
- <t:if test="superadministrator">
- <li><t:pagelink page="UserList">${message:layout-userlist}</t:pagelink></li>
- </t:if>
- <li><t:pagelink page="GroupList">${message:layout-grouplist}</t:pagelink></li>
- </menu>
-
- </t:if>
-
- </div>
-
- <!-- menu -->
- <h1 class="tab">${message:search}</h1>
- <div id="tabMenu">
-
- <t:form>
- <t:errors/>
- <h2 class="Title"><t:label for="searchField"/>:</h2>
- <input t:type="TextField" t:id="searchField" t:value="searchText" t:validate="required,minlength=3" size="30"/>
- <input type="submit" value="${message:search}"/>
- </t:form>
-
- </div>
-
- </div>
-
- </t:if>
-
- <div id="Content">
- <!-- main template here -->
- <t:body/>
- </div>
-
- <div id="FooterAdd">${message:layout-copyright}
- </div>
- </body>
+<!-- titre -->
+<h1 id="Title">${message:layout-pagetitle}</h1>
+
+<!-- barre -->
+<div id="Header">
+<div class="Left">[<a t:type="actionlink" t:id="switchLocaleEn">${message:layout-localeen}</a>]
+- [<a t:type="actionlink" t:id="switchLocaleFr">${message:layout-localefr}</a>]
+</div>
+<t:if test="logged">
+ <div class="Right">${loginName} [<a t:type="actionlink"
+ t:id="logout">${message:layout-logout}</a>]</div>
+</t:if></div>
+
+<t:if test="logged">
+
+ <div id="Menu" class=""><!-- menu -->
+ <h1 class="tab">${message:layout-menutitle}</h1>
+ <div id="tabMenu">
+
+ <h2 class="Title">${message:layout-applications}</h2>
+ <menu class="menu">
+ <li><t:actionlink t:id="applicationList">${message:layout-list}</t:actionlink>
+ </li>
+ <li><t:pagelink page="ApplicationImport">${message:layout-import}</t:pagelink></li>
+ </menu>
+
+ <t:if test="administrator">
+
+ <h2 class="Title">${message:layout-administration}</h2>
+ <menu class="menu">
+ <li><t:pagelink page="UserList">${message:layout-userlist}</t:pagelink></li>
+ <li><t:pagelink page="GroupList">${message:layout-grouplist}</t:pagelink></li>
+ </menu>
+
+ </t:if></div>
+
+ <!-- menu -->
+ <h1 class="tab">${message:search}</h1>
+ <div id="tabMenu"><t:form>
+ <t:errors />
+ <h2 class="Title"><t:label for="searchField" />:</h2>
+ <input t:type="TextField" t:id="searchField" t:value="searchText"
+ t:validate="required,minlength=3" size="30" />
+ <input type="submit" value="${message:search}" />
+ </t:form></div>
+
+ </div>
+
+</t:if>
+
+<div id="Content"><!-- main template here --> <t:body /></div>
+
+<div id="FooterAdd">${message:layout-copyright}</div>
+</body>
</html>
\ No newline at end of file
1
0
r551 - trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application
by tchemit@users.labs.libre-entreprise.org 27 Jan '08
by tchemit@users.labs.libre-entreprise.org 27 Jan '08
27 Jan '08
Author: tchemit
Date: 2008-01-27 15:19:44 +0000 (Sun, 27 Jan 2008)
New Revision: 551
Modified:
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DeleteAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DownloadAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExportApplicationAction.java
Log:
action avec texte non visible
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DeleteAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DeleteAction.java 2008-01-27 15:18:52 UTC (rev 550)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DeleteAction.java 2008-01-27 15:19:44 UTC (rev 551)
@@ -41,7 +41,7 @@
longDescription = "simexplorer.action.application.delete.help",
smallIcon = "action/delete.png",
mnemonic = 'x',
- hideActionText = false
+ hideActionText = true
)
public class DeleteAction extends SimExplorerAbstractTabAction {
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DownloadAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DownloadAction.java 2008-01-27 15:18:52 UTC (rev 550)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DownloadAction.java 2008-01-27 15:19:44 UTC (rev 551)
@@ -50,7 +50,7 @@
longDescription = "simexplorer.action.application.download.help",
smallIcon = "action/download.png",
mnemonic = 'x',
- hideActionText = false
+ hideActionText = true
)
public class DownloadAction extends SimExplorerAbstractTabAction {
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExportApplicationAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExportApplicationAction.java 2008-01-27 15:18:52 UTC (rev 550)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExportApplicationAction.java 2008-01-27 15:19:44 UTC (rev 551)
@@ -43,7 +43,7 @@
longDescription = "simexplorer.action.application.export.help",
smallIcon = "action/export-application.png",
mnemonic = 'x',
- hideActionText = false
+ hideActionText = true
)
public class ExportApplicationAction extends SimExplorerAbstractTabAction {
1
0
r550 - trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model
by tchemit@users.labs.libre-entreprise.org 27 Jan '08
by tchemit@users.labs.libre-entreprise.org 27 Jan '08
27 Jan '08
Author: tchemit
Date: 2008-01-27 15:18:52 +0000 (Sun, 27 Jan 2008)
New Revision: 550
Modified:
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java
Log:
ajout m?\195?\169thode pour savoir si une recherche a ?\195?\169t?\195?\169 lanc?\195?\169e (hasQuery())
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java 2008-01-27 15:17:50 UTC (rev 549)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java 2008-01-27 15:18:52 UTC (rev 550)
@@ -42,7 +42,7 @@
protected boolean onlyLatest;
protected int dateOrder;
-
+
private static final long serialVersionUID = -3623331875470531459L;
public String getName() {
@@ -53,6 +53,10 @@
return tab;
}
+ public boolean hasQuery() {
+ return query != null && !query.isEmpty();
+ }
+
public String getQuery() {
return query;
}
@@ -143,10 +147,10 @@
}
public void updateTabModel(boolean remote, SimExplorerContext context) throws Exception {
-
+
// init pagination
PaginationModel paginationModel = getPagination();
-
+
// obtain datas from service
MetaDataEntity[] data = StorageServiceHelper.getData(context, remote, isOnlyLatest(), getQuery(), (int) paginationModel.getFirstIndex(), paginationModel.getWidth(), getDateOrder());
1
0
r549 - in trunk/simexplorer-is-swing/src: java/fr/cemagref/simexplorer/is/ui/swing java/fr/cemagref/simexplorer/is/ui/swing/action/application java/fr/cemagref/simexplorer/is/ui/swing/action/tab uimodel/fr/cemagref/simexplorer/is/ui/swing/tab
by tchemit@users.labs.libre-entreprise.org 27 Jan '08
by tchemit@users.labs.libre-entreprise.org 27 Jan '08
27 Jan '08
Author: tchemit
Date: 2008-01-27 15:17:50 +0000 (Sun, 27 Jan 2008)
New Revision: 549
Modified:
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ResetSearchApplicationAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/SearchApplicationAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowLocalTabAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowRemoteTabAction.java
trunk/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/tab/JApplicationListTab.jaxx
Log:
lterminer l'accessibilite des actions de recherche
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java 2008-01-27 14:27:31 UTC (rev 548)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java 2008-01-27 15:17:50 UTC (rev 549)
@@ -91,6 +91,9 @@
// refresh search text
ui.getSearchText().setText(model.getQuery());
+ // refresh search actions
+ refreshSearchActions(ui,model);
+
// refresh changePage combobox
refreshChangePageCombo(ui, model);
@@ -109,6 +112,12 @@
});
}
+ public void refreshSearchActions(JApplicationListTab container, ListTabModel model) {
+ String text = container.getSearchText().getText();
+ container.getSearchApplication().setEnabled(model.hasQuery() || !text.isEmpty());
+ container.getResetSearchApplication().setEnabled(model.hasQuery() || !text.isEmpty());
+ }
+
public void refreshConnnectState(final boolean isConnected) {
//SwingUtilities.invokeLater(new Runnable() {
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ResetSearchApplicationAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ResetSearchApplicationAction.java 2008-01-27 14:27:31 UTC (rev 548)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ResetSearchApplicationAction.java 2008-01-27 15:17:50 UTC (rev 549)
@@ -53,11 +53,17 @@
@Override
protected boolean beforeAction(ActionEvent e) throws Exception {
ListTabModel model = (ListTabModel) getModel();
- String query = model.getQuery();
- // always clean the input text (should be done in jaxx)
- ((JApplicationListTab)getUI()).getSearchText().setText(model.getQuery());
+ JApplicationListTab ui = (JApplicationListTab) getUI();
+ // always clean the input text (should be done in jaxx)
+ ui.getSearchText().setText(null);
+ if (!model.hasQuery()) {
+ // directly refresh search actions
+ // but do not realised action
+ getMainUI().refreshSearchActions(ui,model);
+ return false;
+ }
// only reset search if something was previously search
- return query != null && !query.isEmpty();
+ return true;
}
@Override
@@ -83,4 +89,10 @@
// refresh ui
getMainUI().refreshListTabUI(model, container);
}
+
+ @Override
+ protected void clear() {
+ super.clear();
+ setTab(null);
+ }
}
\ No newline at end of file
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/SearchApplicationAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/SearchApplicationAction.java 2008-01-27 14:27:31 UTC (rev 548)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/SearchApplicationAction.java 2008-01-27 15:17:50 UTC (rev 549)
@@ -85,5 +85,6 @@
protected void clear() {
super.clear();
query = null;
+ setTab(null);
}
}
\ No newline at end of file
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowLocalTabAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowLocalTabAction.java 2008-01-27 14:27:31 UTC (rev 548)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowLocalTabAction.java 2008-01-27 15:17:50 UTC (rev 549)
@@ -28,6 +28,8 @@
import javax.swing.JTabbedPane;
import java.awt.Component;
import java.awt.event.ActionEvent;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
/**
* Action pour afficher le tab local
@@ -80,13 +82,20 @@
@Override
protected void afterAction(ActionEvent e) {
- ListTabModel model = (ListTabModel) getModel();
if (firstTime) {
+ final ListTabModel model = (ListTabModel) getModel();
+
// push model into tableModel
- JApplicationListTab container = (JApplicationListTab) getUI();
+ final JApplicationListTab container = (JApplicationListTab) getUI();
JApplicationTableModel modelTab = (JApplicationTableModel) container.getTable().getModel();
modelTab.setData(model.getList());
-
+ // add search actions listeners
+ container.getSearchText().addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ getMainUI().refreshSearchActions(container, model);
+ }
+ });
// refresh ui
getMainUI().refreshListTabUI(model, container);
}
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowRemoteTabAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowRemoteTabAction.java 2008-01-27 14:27:31 UTC (rev 548)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowRemoteTabAction.java 2008-01-27 15:17:50 UTC (rev 549)
@@ -28,6 +28,8 @@
import javax.swing.JTabbedPane;
import java.awt.Component;
import java.awt.event.ActionEvent;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
/**
* Action pour afficher le tab local
@@ -76,27 +78,35 @@
if (data == null) {
// first coming here, init model
- model.initTabModel(true,getContext());
+ model.initTabModel(true, getContext());
}
return true;
}
@Override
protected void afterAction(ActionEvent e) {
- ListTabModel model = (ListTabModel) getModel();
if (firstTime) {
-
+ final ListTabModel model = (ListTabModel) getModel();
// push model into TableModel
- JApplicationListTab container = (JApplicationListTab) getUI();
+ final JApplicationListTab container = (JApplicationListTab) getUI();
JApplicationTableModel modelTab = (JApplicationTableModel) container.getTable().getModel();
modelTab.setData(model.getList());
+ // add search actions listeners
+ container.getSearchText().addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ getMainUI().refreshSearchActions(container, model);
+ }
+ });
+
// refresh ui
getMainUI().refreshListTabUI(model, container);
}
}
+
@Override
protected void clear() {
super.clear();
Modified: trunk/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/tab/JApplicationListTab.jaxx
===================================================================
--- trunk/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/tab/JApplicationListTab.jaxx 2008-01-27 14:27:31 UTC (rev 548)
+++ trunk/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/tab/JApplicationListTab.jaxx 2008-01-27 15:17:50 UTC (rev 549)
@@ -16,10 +16,8 @@
<JTextField id='searchText'
toolTipText='{_("simexplorer.action.application.searchText.tooltip")}'/>
- <JButton id='searchApplication'
- enabled='{!searchText.getText().isEmpty()}' />
- <JButton id='resetSearchApplication'
- enabled='{!searchText.getText().isEmpty()}'/>
+ <JButton id='searchApplication'/>
+ <JButton id='resetSearchApplication'/>
<JButton id='advancedSearchApplication' enabled='false'/>
<JComboBox id='changeSizor' enabled='false' font-size='9'
1
0
r548 - in trunk: simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/metadata simexplorer-is-service simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service
by glandais@users.labs.libre-entreprise.org 27 Jan '08
by glandais@users.labs.libre-entreprise.org 27 Jan '08
27 Jan '08
Author: glandais
Date: 2008-01-27 14:27:31 +0000 (Sun, 27 Jan 2008)
New Revision: 548
Modified:
trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/metadata/MetaDataEntity.java
trunk/simexplorer-is-service/pom.xml
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java
trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java
Log:
MAJ tests - attachments
Modified: trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/metadata/MetaDataEntity.java
===================================================================
--- trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/metadata/MetaDataEntity.java 2008-01-25 17:46:25 UTC (rev 547)
+++ trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/metadata/MetaDataEntity.java 2008-01-27 14:27:31 UTC (rev 548)
@@ -19,6 +19,7 @@
import java.io.Serializable;
import java.util.Date;
+import java.util.HashMap;
import java.util.Map;
import fr.cemagref.simexplorer.is.contenttype.ContentType;
@@ -167,6 +168,9 @@
* @return the attachments
*/
public Map<String, ContentType> getAttachments() {
+ if (attachments == null) {
+ attachments = new HashMap<String, ContentType>();
+ }
return attachments;
}
Modified: trunk/simexplorer-is-service/pom.xml
===================================================================
--- trunk/simexplorer-is-service/pom.xml 2008-01-25 17:46:25 UTC (rev 547)
+++ trunk/simexplorer-is-service/pom.xml 2008-01-27 14:27:31 UTC (rev 548)
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
-
+
<groupId>simexplorer-is</groupId>
<artifactId>simexplorer-is-service</artifactId>
<name>Service</name>
-
+
<version>0.0.1-SNAPSHOT</version>
<description>services ejb de SimExplorer-IS</description>
<packaging>ejb</packaging>
@@ -26,7 +26,7 @@
<groupId>simexplorer-is</groupId>
<artifactId>simexplorer-is-security</artifactId>
<version>0.0.1-SNAPSHOT</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>com.healthmarketscience.rmiio</groupId>
<artifactId>rmiio</artifactId>
@@ -44,11 +44,16 @@
<version>4.2.2.GA</version>
<scope>provided</scope>
</dependency>
- <dependency>
+ <dependency>
<groupId>jboss</groupId>
<artifactId>jbossall-client</artifactId>
<version>4.2.2.GA</version>
<scope>provided</scope>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.3</version>
+ </dependency>
+ </dependencies>
</project>
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java 2008-01-25 17:46:25 UTC (rev 547)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java 2008-01-27 14:27:31 UTC (rev 548)
@@ -17,6 +17,9 @@
* ##% */
package fr.cemagref.simexplorer.is.service;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -25,6 +28,10 @@
import java.util.Set;
import java.util.UUID;
+import org.apache.commons.lang.RandomStringUtils;
+
+import fr.cemagref.simexplorer.is.contenttype.ContentType;
+import fr.cemagref.simexplorer.is.contenttype.ContentTypeFactory;
import fr.cemagref.simexplorer.is.entities.data.Code;
import fr.cemagref.simexplorer.is.entities.data.Component;
import fr.cemagref.simexplorer.is.entities.data.Constant;
@@ -44,28 +51,52 @@
private Random r = new Random();
+ private static int cs;
+ private static String[] randomstrings;
+
+ public ElementGenerator() {
+ super();
+ initializeStrings();
+ }
+
private String shortString() {
- return Long.toHexString(r.nextLong());
+ return RandomStringUtils.randomAlphabetic(r.nextInt(5) + 5);
}
private String longString() {
- return UUID.randomUUID().toString();
+ /*
+ StringBuilder sb = new StringBuilder();
+ int c = 3 + r.nextInt(5);
+ for (int i = 0; i < c; i++) {
+ sb.append(shortString());
+ sb.append(" ");
+ }
+ return sb.toString();
+ */
+ return RandomStringUtils.randomAlphabetic(r.nextInt(10) + 10);
}
+ private void initializeStrings() {
+ cs = 150000;
+ randomstrings = new String[cs];
+ for (int i = 0; i < randomstrings.length; i++) {
+ randomstrings[i] = shortString();
+ }
+ }
+
private void update(LoggableElement element) throws Exception {
MetaDataEntity metaData = new MetaDataEntity();
- metaData.setUuid(shortString());
+ metaData.setUuid(UUID.randomUUID().toString());
metaData.setName(longString());
metaData.setType(element.getClass().getSimpleName());
-
+
StringBuffer sb = new StringBuffer("");
int c = 3 + r.nextInt(5);
for (int i = 0; i < c; i++) {
- sb.append(shortString());
- sb.append(" ");
+ sb.append(randomstrings[r.nextInt(cs)]).append(" ");
}
metaData.setDescription(sb.toString());
-
+
Version v = new Version("0");
c = 2 + r.nextInt(2);
for (int i = 0; i < c; i++) {
@@ -91,7 +122,8 @@
Set<T> elements = new HashSet<T>();
int i = 3 + r.nextInt(2);
for (int j = 0; j < i; j++) {
- T element = BaseEntityFactory.<T>getFactory(clazz).createInstance();
+ T element = BaseEntityFactory.<T> getFactory(clazz)
+ .createInstance();
if (element instanceof LoggableElement) {
update((LoggableElement) element);
}
@@ -113,6 +145,20 @@
processComponent(object);
}
ea.setComponents(components);
+
+ Map<String, ContentType> contents = new HashMap<String, ContentType>();
+ for (ExplorationData object : datas) {
+ contents.putAll(object.getMetaData().getAttachments());
+ }
+ for (Component object : components) {
+ Set<Library> libraries = object.getLibraries();
+ for (Library library : libraries) {
+ contents.putAll(library.getMetaData().getAttachments());
+ }
+ contents.putAll(object.getMetaData().getAttachments());
+ }
+ ea.getMetaData().setAttachments(contents);
+
return ea;
}
@@ -139,7 +185,9 @@
}
- private void processLibrary(Library library) {
+ private void processLibrary(Library library) throws Exception {
+ library.getMetaData().getAttachments().put(shortString() + ".zip",
+ ContentTypeFactory.getContentTypeInstance("RawType"));
}
private void processCode(Code code) {
@@ -156,6 +204,9 @@
throws Exception {
Result result = new Result();
explorationData.setResult(result);
+ explorationData.getMetaData().getAttachments().put(
+ shortString() + ".zip",
+ ContentTypeFactory.getContentTypeInstance("RawType"));
Set<ConstantValue> constantValues = generateArray(ConstantValue.class);
for (ConstantValue constantValue : constantValues) {
@@ -174,4 +225,15 @@
constantValue.setValue(Integer.toString(r.nextInt()));
}
+ public InputStream generateTextStream() throws Exception {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ int wordcount = 300 + r.nextInt(300);
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < wordcount; i++) {
+ sb.append(randomstrings[r.nextInt(cs)]).append(" ");
+ }
+ os.write(sb.toString().getBytes());
+ InputStream is = new ByteArrayInputStream(os.toByteArray());
+ return is;
+ }
}
Modified: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java
===================================================================
--- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java 2008-01-25 17:46:25 UTC (rev 547)
+++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java 2008-01-27 14:27:31 UTC (rev 548)
@@ -20,8 +20,10 @@
import java.io.InputStream;
import java.util.Date;
import java.util.HashMap;
+import java.util.Map;
import junit.framework.TestCase;
+import fr.cemagref.simexplorer.is.contenttype.ContentType;
import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication;
import fr.cemagref.simexplorer.is.factories.BaseEntityFactory;
import fr.cemagref.simexplorer.is.factories.XmlConstants;
@@ -73,7 +75,7 @@
*/
public void testMassInsert() throws Exception {
- int c = 350;
+ int c = 5;
Date begin = new Date();
@@ -84,9 +86,16 @@
ExplorationApplication.class).saveElement(
XmlConstants.VALUE_METADATA_TYPE_EA, ea);
- storageService.saveElement(null, xmlStream,
- new HashMap<String, InputStream>());
+ Map<String, InputStream> attachments = new HashMap<String, InputStream>();
+ Map<String, ContentType> attachmentsKeys = ea.getMetaData()
+ .getAttachments();
+ for (Map.Entry<String, ContentType> kv : attachmentsKeys.entrySet()) {
+ InputStream stream = elementGenerator.generateTextStream();
+ attachments.put(kv.getKey(), stream);
+ }
+ storageService.saveElement(null, xmlStream, attachments);
+
if (i > 0 && i % 100 == 0) {
Date end = new Date();
long time = end.getTime() - begin.getTime();
@@ -99,6 +108,7 @@
}
}
+ storageService.commit();
}
}
1
0
r547 - in trunk: simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages simexplorer-is-web/src/main/webapp
by glandais@users.labs.libre-entreprise.org 25 Jan '08
by glandais@users.labs.libre-entreprise.org 25 Jan '08
25 Jan '08
Author: glandais
Date: 2008-01-25 17:46:25 +0000 (Fri, 25 Jan 2008)
New Revision: 547
Modified:
trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java
trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials/CredentialManager.java
trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java
trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml
Log:
Exception page
Modified: trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java
===================================================================
--- trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java 2008-01-25 16:48:09 UTC (rev 546)
+++ trunk/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/contenttype/ContentType.java 2008-01-25 17:46:25 UTC (rev 547)
@@ -43,6 +43,7 @@
* @param is
* Input stream
* @return Indexable text
+ * @throws Exception
*/
public abstract Reader renderToText(InputStream is) throws Exception;
Modified: trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials/CredentialManager.java
===================================================================
--- trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials/CredentialManager.java 2008-01-25 16:48:09 UTC (rev 546)
+++ trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/credentials/CredentialManager.java 2008-01-25 17:46:25 UTC (rev 547)
@@ -17,8 +17,6 @@
* ##% */
package fr.cemagref.simexplorer.is.security.credentials;
-import java.util.List;
-
import javax.ejb.Local;
import fr.cemagref.simexplorer.is.security.entities.Permission;
Modified: trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java
===================================================================
--- trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java 2008-01-25 16:48:09 UTC (rev 546)
+++ trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java 2008-01-25 17:46:25 UTC (rev 547)
@@ -22,6 +22,7 @@
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@@ -40,7 +41,7 @@
Object o;
try {
o = query.getSingleResult();
- } catch (RuntimeException e) {
+ } catch (NoResultException e) {
o = null;
}
return o;
@@ -50,7 +51,7 @@
Object o;
try {
o = em.find(clazz, arg);
- } catch (RuntimeException e) {
+ } catch (NoResultException e) {
o = null;
}
return o;
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java 2008-01-25 16:48:09 UTC (rev 546)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java 2008-01-25 17:46:25 UTC (rev 547)
@@ -18,27 +18,94 @@
package fr.cemagref.simexplorer.is.ui.web.pages;
import java.io.FileNotFoundException;
+import java.util.List;
+import org.apache.tapestry.ioc.annotations.Inject;
+import org.apache.tapestry.ioc.services.ExceptionAnalysis;
+import org.apache.tapestry.ioc.services.ExceptionAnalyzer;
+import org.apache.tapestry.ioc.services.ExceptionInfo;
import org.apache.tapestry.services.ExceptionReporter;
-public class ExceptionReport extends
- org.apache.tapestry.corelib.pages.ExceptionReport implements
- ExceptionReporter {
+import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
- private boolean unknown;
+public class ExceptionReport implements ExceptionReporter {
+
+ private boolean unknown;
+
+ private SimExplorerWebException exception;
+
+ private List<ExceptionInfo> stack;
+ private ExceptionInfo info;
+
+ private String propertyName;
+
+ private String frame;
+
+ @Inject
+ private ExceptionAnalyzer analyzer;
+
+ public String getWindowTitle() {
+ return "Error";
+ }
- @Override
public void reportException(Throwable exception) {
- if (exception instanceof FileNotFoundException) {
- unknown = false;
+ if (exception instanceof SimExplorerWebException) {
+ // unknown = false;
+ // FIXME debug mode
+ unknown = true;
+ this.exception = (SimExplorerWebException) exception;
} else {
unknown = true;
- super.reportException(exception);
+ ExceptionAnalysis analysis = analyzer.analyze(exception);
+ stack = analysis.getExceptionInfos();
}
}
+ public String getErrorMessage() {
+ return "Error";
+ }
+
+ public boolean getShowPropertyList() {
+ // True if either is non-empty
+ return !(info.getPropertyNames().isEmpty() && info.getStackTrace()
+ .isEmpty());
+ }
+
+ public Object getPropertyValue()
+ {
+ return info.getProperty(propertyName);
+ }
+
+ public List<ExceptionInfo> getStack() {
+ return stack;
+ }
+
+ public ExceptionInfo getInfo() {
+ return info;
+ }
+
+ public void setInfo(ExceptionInfo info) {
+ this.info = info;
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
public boolean isUnknown() {
return unknown;
}
+ public String getFrame() {
+ return frame;
+ }
+
+ public void setFrame(String frame) {
+ this.frame = frame;
+ }
+
}
Modified: trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml
===================================================================
--- trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml 2008-01-25 16:48:09 UTC (rev 546)
+++ trunk/simexplorer-is-web/src/main/webapp/ExceptionReport.tml 2008-01-25 17:46:25 UTC (rev 547)
@@ -1,50 +1,39 @@
-<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
-<head>
-<title>Application Exception</title>
-</head>
-<body>
-<h1 class="t-exception-report">An unexpected application exception
-has occurred.</h1>
+<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
+ title="${windowtitle}">
+ ${errormessage}
-<div class="t-exception-report">
-<ul>
- <t:loop source="stack" value="info">
- <li><span class="t-exception-class-name">${info.className}</span>
+ <t:if test="unknown">
- <t:if test="info.message">
- <div class="t-exception-message">${info.message}</div>
- </t:if> <t:if test="showPropertyList">
- <dl>
- <t:loop source="info.propertyNames" value="propertyName">
- <dt>${propertyName}</dt>
- <dd><t:renderobject object="propertyValue" /></dd>
- </t:loop>
- <t:if test="info.stackTrace">
- <dt>Stack trace</dt>
- <dd>
- <ul class="t-stack-trace">
- <t:loop source="info.stackTrace" value="frame">
- <li>${frame}</li>
+ <div class="t-exception-report">
+ <ul>
+ <t:loop source="stack" value="info">
+ <li><span class="t-exception-class-name">${info.className}</span>
+
+ <t:if test="info.message">
+ <div class="t-exception-message">${info.message}</div>
+ </t:if> <t:if test="showPropertyList">
+ <dl>
+ <t:loop source="info.propertyNames" value="propertyName">
+ <dt>${propertyName}</dt>
+ <dd><t:renderobject object="propertyValue" /></dd>
</t:loop>
- </ul>
- </dd>
- </t:if>
- </dl>
- </t:if></li>
- </t:loop>
-</ul>
-</div>
-<div class="t-env-data">
-<h2>Request</h2>
-<t:renderobject object="request" /> <t:if test="hasSession">
- <h2>Session</h2>
- <dl>
- <t:loop source="session.attributeNames" value="attributeName">
- <dt>${attributeName}</dt>
- <dd><t:renderobject object="attributeValue" /></dd>
- </t:loop>
- </dl>
-</t:if></div>
-</body>
-</html>
+ <t:if test="info.stackTrace">
+ <dt>Stack trace</dt>
+ <dd>
+ <ul class="t-stack-trace">
+ <t:loop source="info.stackTrace" value="frame">
+ <li>${frame}</li>
+ </t:loop>
+ </ul>
+ </dd>
+ </t:if>
+ </dl>
+ </t:if></li>
+ </t:loop>
+ </ul>
+ </div>
+
+ </t:if>
+
+</t:layout>
1
0
r546 - in trunk: simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages simexplorer-is-web/src/main/webapp simexplorer-is-web/src/main/webapp/WEB-INF
by glandais@users.labs.libre-entreprise.org 25 Jan '08
by glandais@users.labs.libre-entreprise.org 25 Jan '08
25 Jan '08
Author: glandais
Date: 2008-01-25 16:48:09 +0000 (Fri, 25 Jan 2008)
New Revision: 546
Removed:
trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/service/
Modified:
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java
trunk/simexplorer-is-web/src/main/webapp/ElementDelete.tml
trunk/simexplorer-is-web/src/main/webapp/WEB-INF/app.properties
Log:
Delete page
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-01-25 16:16:46 UTC (rev 545)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-01-25 16:48:09 UTC (rev 546)
@@ -148,4 +148,14 @@
}
return generator;
}
+
+ public void deleteElement(String token, String uuid, String version) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteElement(String token, String uuid) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java 2008-01-25 16:16:46 UTC (rev 545)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java 2008-01-25 16:48:09 UTC (rev 546)
@@ -17,17 +17,19 @@
* ##% */
package fr.cemagref.simexplorer.is.service;
+import java.util.Map;
+
+import javax.ejb.Remote;
+
import com.healthmarketscience.rmiio.RemoteInputStream;
import com.healthmarketscience.rmiio.RemoteOutputStream;
+
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity;
-import javax.ejb.Remote;
-import java.util.Map;
-
/**
* Service interface
- *
+ *
* @author glandais
*/
@Remote
@@ -35,26 +37,30 @@
/**
* Commit in storage
- *
+ *
* @throws SimExplorerServiceException
*/
void commit() throws SimExplorerServiceException;
/**
* Login user onto system Not used for local usages
- *
- * @param login Login
- * @param password Password
+ *
+ * @param login
+ * Login
+ * @param password
+ * Password
* @return Token as logon evidence
* @throws SimExplorerServiceException
*/
- String loginUser(String login, String password) throws SimExplorerServiceException;
+ String loginUser(String login, String password)
+ throws SimExplorerServiceException;
/**
* Save a remote element
- *
+ *
* @param token
- * @param zipRemoteStream RIIO stream containing data inside a zip
+ * @param zipRemoteStream
+ * RIIO stream containing data inside a zip
* @return Metadata of element imported
* @throws SimExplorerServiceException
*/
@@ -63,31 +69,34 @@
/**
* Save a remote element
- *
+ *
* @param token
- * @param xmlRemoteStream RIIO stream containing XML Stream
- * @param attachmentsRemoteStream RIIO stream containing attached data. Key matches metadata
- * attachment keys
+ * @param xmlRemoteStream
+ * RIIO stream containing XML Stream
+ * @param attachmentsRemoteStream
+ * RIIO stream containing attached data. Key matches metadata
+ * attachment keys
* @return Metadata of element saved
* @throws SimExplorerServiceException
*/
MetaDataEntity saveElement(String token, RemoteInputStream xmlRemoteStream,
- Map<String, RemoteInputStream> attachmentsRemoteStream)
+ Map<String, RemoteInputStream> attachmentsRemoteStream)
throws SimExplorerServiceException;
/**
* Retrieve metadata (latest version)
- *
+ *
* @param token
* @param uuid
* @return
* @throws SimExplorerServiceException
*/
- MetaDataEntity getMetadata(String token, String uuid) throws SimExplorerServiceException;
+ MetaDataEntity getMetadata(String token, String uuid)
+ throws SimExplorerServiceException;
/**
* Retrieve metadata
- *
+ *
* @param token
* @param uuid
* @param version
@@ -99,19 +108,20 @@
/**
* Export element to a remote stream
- *
+ *
* @param token
- * @param xmlOutputStream RMIIO stream where to save data
+ * @param xmlOutputStream
+ * RMIIO stream where to save data
* @param uuid
* @param version
* @throws SimExplorerServiceException
*/
void exportElement(String token, RemoteOutputStream xmlOutputStream,
- String uuid, String version) throws SimExplorerServiceException;
+ String uuid, String version) throws SimExplorerServiceException;
/**
* Retrieve data related to an entity
- *
+ *
* @param token
* @param uuid
* @param version
@@ -120,11 +130,11 @@
* @throws SimExplorerServiceException
*/
RemoteInputStream retrieveData(String token, String uuid, String version,
- String dataKey) throws SimExplorerServiceException;
+ String dataKey) throws SimExplorerServiceException;
/**
* Retrieve number of elements matching query
- *
+ *
* @param token
* @param query
* @param onlyLatest
@@ -136,7 +146,7 @@
/**
* Find elements matching query
- *
+ *
* @param token
* @param query
* @param onlyLatest
@@ -147,12 +157,12 @@
* @throws SimExplorerServiceException
*/
MetaDataEntity[] findFullText(String token, String query,
- boolean onlyLatest, int indexStart, int count, int dateOrder)
+ boolean onlyLatest, int indexStart, int count, int dateOrder)
throws SimExplorerServiceException;
/**
* Retrieve number of applications
- *
+ *
* @param token
* @param onlyLatest
* @return
@@ -163,7 +173,7 @@
/**
* Get a list of applications
- *
+ *
* @param token
* @param onlyLatest
* @param start
@@ -173,11 +183,12 @@
* @throws SimExplorerServiceException
*/
MetaDataEntity[] findApplications(String token, boolean onlyLatest,
- int start, int count, int dateOrder) throws SimExplorerServiceException;
+ int start, int count, int dateOrder)
+ throws SimExplorerServiceException;
/**
* Fully load an element
- *
+ *
* @param token
* @param uuid
* @param version
@@ -189,25 +200,28 @@
/**
* Get all version of an element
- *
+ *
* @param token
* @param uuid
* @return
* @throws SimExplorerServiceException
*/
- MetaDataEntity[] getVersions(String token, String uuid) throws SimExplorerServiceException;
+ MetaDataEntity[] getVersions(String token, String uuid)
+ throws SimExplorerServiceException;
/**
* @param token
* @param uuid
* @param version
*/
-// void deleteElement(String token, String uuid, Version version);
+ void deleteElement(String token, String uuid, String version)
+ throws SimExplorerServiceException;
/**
* @param token
* @param uuid
*/
-// void deleteElement(String token, String uuid);
+ void deleteElement(String token, String uuid)
+ throws SimExplorerServiceException;
}
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java 2008-01-25 16:16:46 UTC (rev 545)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java 2008-01-25 16:48:09 UTC (rev 546)
@@ -50,7 +50,8 @@
import fr.cemagref.simexplorer.is.storage.engine.StorageEngine;
import fr.cemagref.simexplorer.is.storage.StorageException;
-public abstract class StorageServiceCommon implements StorageService, XmlConstants {
+public abstract class StorageServiceCommon implements StorageService,
+ XmlConstants {
protected StorageEngine storageEngine;
@@ -81,7 +82,8 @@
}
}
- public MetaDataEntity saveElement(String token, RemoteInputStream zipRemoteStream)
+ public MetaDataEntity saveElement(String token,
+ RemoteInputStream zipRemoteStream)
throws SimExplorerServiceException {
InputStream zipStream;
try {
@@ -92,15 +94,18 @@
}
}
- public MetaDataEntity saveElement(String token, RemoteInputStream xmlRemoteStream,
+ public MetaDataEntity saveElement(String token,
+ RemoteInputStream xmlRemoteStream,
Map<String, RemoteInputStream> attachmentsRemoteStream)
throws SimExplorerServiceException {
try {
- InputStream xmlStream = RemoteInputStreamClient.wrap(xmlRemoteStream);
+ InputStream xmlStream = RemoteInputStreamClient
+ .wrap(xmlRemoteStream);
Map<String, InputStream> attachmentStreams = new HashMap<String, InputStream>();
for (Map.Entry<String, RemoteInputStream> entry : attachmentsRemoteStream
.entrySet()) {
- InputStream stream = RemoteInputStreamClient.wrap(entry.getValue());
+ InputStream stream = RemoteInputStreamClient.wrap(entry
+ .getValue());
attachmentStreams.put(entry.getKey(), stream);
}
return saveElement(token, xmlStream, attachmentStreams);
@@ -109,7 +114,8 @@
}
}
- public MetaDataEntity getMetadata(String token, String uuid) throws SimExplorerServiceException {
+ public MetaDataEntity getMetadata(String token, String uuid)
+ throws SimExplorerServiceException {
try {
return storageEngine.getMetadata(token, uuid);
} catch (StorageException e) {
@@ -126,10 +132,12 @@
}
}
- public MetaDataEntity[] findFullText(String token, String query, boolean onlyLatest,
- int indexStart, int count, int dateOrder) throws SimExplorerServiceException {
+ public MetaDataEntity[] findFullText(String token, String query,
+ boolean onlyLatest, int indexStart, int count, int dateOrder)
+ throws SimExplorerServiceException {
try {
- return storageEngine.findFullText(token, query, onlyLatest, indexStart, count,dateOrder);
+ return storageEngine.findFullText(token, query, onlyLatest,
+ indexStart, count, dateOrder);
} catch (StorageException e) {
throw new SimExplorerServiceException(e);
}
@@ -144,18 +152,23 @@
}
}
- public int findApplicationsCount(String token, boolean onlyLatest) throws SimExplorerServiceException {
+ public int findApplicationsCount(String token, boolean onlyLatest)
+ throws SimExplorerServiceException {
try {
- return storageEngine.findElementsByTypeCount(token, VALUE_METADATA_TYPE_EA,onlyLatest);
+ return storageEngine.findElementsByTypeCount(token,
+ VALUE_METADATA_TYPE_EA, onlyLatest);
} catch (StorageException e) {
throw new SimExplorerServiceException(e);
}
}
- public MetaDataEntity[] findApplications(String token, boolean onlyLatest, int start,
- int count, int dateOrder) throws SimExplorerServiceException {
+ public MetaDataEntity[] findApplications(String token, boolean onlyLatest,
+ int start, int count, int dateOrder)
+ throws SimExplorerServiceException {
try {
- return storageEngine.findElementsByType(token, VALUE_METADATA_TYPE_EA,onlyLatest, start, count, dateOrder);
+ return storageEngine
+ .findElementsByType(token, VALUE_METADATA_TYPE_EA,
+ onlyLatest, start, count, dateOrder);
} catch (StorageException e) {
throw new SimExplorerServiceException(e);
}
@@ -168,8 +181,9 @@
try {
LoggableElement le;
le = (LoggableElement) BaseEntityFactory.getFactory(
- LoggableElement.class.getPackage().getName() + "." + mde.getType())
- .loadElement(storageEngine.retrieveData(token, mde, KEY_XML));
+ LoggableElement.class.getPackage().getName() + "."
+ + mde.getType()).loadElement(
+ storageEngine.retrieveData(token, mde, KEY_XML));
return le;
} catch (Exception e) {
@@ -177,7 +191,8 @@
}
}
- private MetaDataEntity saveElement(String token, InputStream zipStream) throws SimExplorerServiceException {
+ private MetaDataEntity saveElement(String token, InputStream zipStream)
+ throws SimExplorerServiceException {
String xmlFile = null;
Map<String, String> attachments = new HashMap<String, String>();
@@ -192,8 +207,8 @@
xmlFile = storageEngine.storeTempData(zis);
} else {
if (entryName.startsWith(FILE_DATA_PREFIX)) {
- String fileName = entryName.replace(FILE_DATA_PREFIX
- + "/", "");
+ String fileName = entryName.replace(
+ FILE_DATA_PREFIX + "/", "");
String idFile = storageEngine.storeTempData(zis);
attachments.put(fileName, idFile);
}
@@ -222,7 +237,8 @@
String version, String dataKey) throws SimExplorerServiceException {
try {
MetaDataEntity mde = getMetadata(token, uuid, version);
- InputStream stream = storageEngine.retrieveData(token, mde, dataKey);
+ InputStream stream = storageEngine
+ .retrieveData(token, mde, dataKey);
RemoteInputStreamServer remoteStream = new SimpleRemoteInputStream(
stream);
return remoteStream.export();
@@ -233,11 +249,12 @@
}
}
- public void exportElement(String token, RemoteOutputStream xmlOutputStream, String uuid,
- String version) throws SimExplorerServiceException {
+ public void exportElement(String token, RemoteOutputStream xmlOutputStream,
+ String uuid, String version) throws SimExplorerServiceException {
MetaDataEntity mde = getMetadata(token, uuid, version);
try {
- InputStream xmlStream = storageEngine.retrieveData(token, mde, KEY_XML);
+ InputStream xmlStream = storageEngine.retrieveData(token, mde,
+ KEY_XML);
OutputStream os = RemoteOutputStreamClient.wrap(xmlOutputStream);
// Buffer copy stream to stream
@@ -271,7 +288,8 @@
private MetaDataEntity saveElement(String token, String idxml,
Map<String, String> idsattachment) throws Exception {
// Load metadata xml
- MetaDataEntityFactory mdeFactory = MetaDataEntityFactory.getFactory(MetaDataEntity.class);
+ MetaDataEntityFactory mdeFactory = MetaDataEntityFactory
+ .getFactory(MetaDataEntity.class);
MetaDataEntity metaData = mdeFactory
.loadElementFromParentXML(storageEngine.retrieveTempData(idxml));
@@ -289,7 +307,8 @@
List<String[]> explorationDatas = new ArrayList<String[]>();
// Retrieve elements
- extractChildren(token, idxml, idsattachment, components, explorationDatas);
+ extractChildren(token, idxml, idsattachment, components,
+ explorationDatas);
// For each exploration data
for (String[] explorationData : explorationDatas) {
@@ -334,11 +353,12 @@
return metaData;
}
- private void processVersionRules(String token, MetaDataEntity metaData) throws Exception {
+ private void processVersionRules(String token, MetaDataEntity metaData)
+ throws Exception {
// Check existing version in storage
- MetaDataEntity previousVersion = storageEngine.getMetadata(token, metaData
- .getUuid(), metaData.getVersion());
+ MetaDataEntity previousVersion = storageEngine.getMetadata(token,
+ metaData.getUuid(), metaData.getVersion());
/*
* MetaDataEntity parentData = storageEngine.getElementVersion(metaData
* .getParentData().getUuid(), metaData.getParentData() .getVersion());
@@ -360,7 +380,8 @@
Map<String, String> idsattachment, List<String> components,
List<String[]> explorationDatas) throws Exception {
- BaseEntityFactory<MetaDataEntity> elementFactory = MetaDataEntityFactory.getFactory(MetaDataEntity.class);
+ BaseEntityFactory<MetaDataEntity> elementFactory = MetaDataEntityFactory
+ .getFactory(MetaDataEntity.class);
Document document = BaseEntityFactory.getXMLBuilder().parse(
storageEngine.retrieveTempData(idxml));
@@ -399,19 +420,41 @@
explorationDataArray = new String[1];
}
explorationDataArray[0] = storageEngine
- .storeTempData(BaseEntityFactory.serializeElement(elementAD));
+ .storeTempData(BaseEntityFactory
+ .serializeElement(elementAD));
explorationDatas.add(explorationDataArray);
}
}
- public MetaDataEntity[] getVersions(String token, String uuid) throws SimExplorerServiceException {
+ public MetaDataEntity[] getVersions(String token, String uuid)
+ throws SimExplorerServiceException {
try {
- Set<MetaDataEntity> versions = storageEngine.getElementVersions(token, uuid);
+ Set<MetaDataEntity> versions = storageEngine.getElementVersions(
+ token, uuid);
return versions.toArray(new MetaDataEntity[versions.size()]);
} catch (StorageException e) {
throw new SimExplorerServiceException(e);
}
}
+
+ public void deleteElement(String token, String uuid, String version)
+ throws SimExplorerServiceException {
+ try {
+ storageEngine.deleteElement(token, uuid, new Version(version));
+ } catch (StorageException e) {
+ throw new SimExplorerServiceException(e);
+ }
+ }
+
+ public void deleteElement(String token, String uuid)
+ throws SimExplorerServiceException {
+ try {
+ storageEngine.deleteElements(token, uuid);
+ } catch (StorageException e) {
+ throw new SimExplorerServiceException(e);
+ }
+ }
+
}
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-01-25 16:16:46 UTC (rev 545)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-01-25 16:48:09 UTC (rev 546)
@@ -198,7 +198,8 @@
* @return id for retrieval
* @throws Exception
*/
- public abstract String storeTempData(InputStream stream) throws StorageException;
+ public abstract String storeTempData(InputStream stream)
+ throws StorageException;
/**
* Retrieve temporary data
@@ -208,7 +209,8 @@
* @return Data stream
* @throws Exception
*/
- public abstract InputStream retrieveTempData(String id) throws StorageException;
+ public abstract InputStream retrieveTempData(String id)
+ throws StorageException;
/**
* Delete temporary data
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java 2008-01-25 16:16:46 UTC (rev 545)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java 2008-01-25 16:48:09 UTC (rev 546)
@@ -18,30 +18,44 @@
package fr.cemagref.simexplorer.is.ui.web.pages;
import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.annotations.InjectPage;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.ioc.annotations.Inject;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.service.SimExplorerServiceException;
+import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
import fr.cemagref.simexplorer.is.ui.web.pages.security.UserPage;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
public class ElementDelete extends ElementPage {
-// public Object onDelete() {
-// RemoteStorageService.getStorageService().deleteElement(getToken(),
-// element.getMetaData().getUuid(),
-// element.getMetaData().getVersion());
-// return null;
-// }
-//
-// public Object onDeleteAll() {
-// RemoteStorageService.getStorageService().deleteElement(getToken(),
-// element.getMetaData().getUuid());
-// return null;
-// }
+ @InjectPage
+ private ElementDetail elementDetail;
+ public Object onActionFromConfirm() {
+ try {
+ RemoteStorageService.getStorageService().deleteElement(getToken(),
+ getElement().getMetaData().getUuid(),
+ getElement().getMetaData().getVersion().toString());
+ } catch (SimExplorerServiceException e) {
+ throw new SimExplorerWebException(e);
+ }
+ return elementDetail;
+ }
+
+ public Object onActionFromConfirmAll() {
+ try {
+ RemoteStorageService.getStorageService().deleteElement(getToken(),
+ getElement().getMetaData().getUuid());
+ } catch (SimExplorerServiceException e) {
+ throw new SimExplorerWebException(e);
+ }
+ return elementDetail;
+ }
+
public String getWindowTitle() {
return "";
}
-
+
}
Modified: trunk/simexplorer-is-web/src/main/webapp/ElementDelete.tml
===================================================================
--- trunk/simexplorer-is-web/src/main/webapp/ElementDelete.tml 2008-01-25 16:16:46 UTC (rev 545)
+++ trunk/simexplorer-is-web/src/main/webapp/ElementDelete.tml 2008-01-25 16:48:09 UTC (rev 546)
@@ -5,6 +5,14 @@
<p><t:actionlink t:id="confirm">${message:confirm}</t:actionlink> -
<t:back label="${message:cancel}" /></p>
+ <hr />
+
+ <p>${message:confirmdeleteAll}</p>
+ <p><t:actionlink t:id="confirmall">${message:confirm}</t:actionlink>
+ - <t:back label="${message:cancel}" /></p>
+
+ <hr />
+
<p><t:back label="${message:back}" /></p>
</t:layout>
Modified: trunk/simexplorer-is-web/src/main/webapp/WEB-INF/app.properties
===================================================================
--- trunk/simexplorer-is-web/src/main/webapp/WEB-INF/app.properties 2008-01-25 16:16:46 UTC (rev 545)
+++ trunk/simexplorer-is-web/src/main/webapp/WEB-INF/app.properties 2008-01-25 16:48:09 UTC (rev 546)
@@ -13,6 +13,7 @@
upload=Upload
confirmdelete=Confirm delete?
+confirmdeleteAll=Confirm delete all versions?
resetPassword=Reset password
name=Name
1
0
r545 - trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages
by glandais@users.labs.libre-entreprise.org 25 Jan '08
by glandais@users.labs.libre-entreprise.org 25 Jan '08
25 Jan '08
Author: glandais
Date: 2008-01-25 16:16:46 +0000 (Fri, 25 Jan 2008)
New Revision: 545
Added:
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPageDetail.java
Modified:
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java
Log:
Share common links of detail and history
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-01-25 16:16:18 UTC (rev 544)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-01-25 16:16:46 UTC (rev 545)
@@ -47,27 +47,12 @@
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
import fr.cemagref.simexplorer.is.ui.web.tools.AttachmentStreamResponse;
-public class ElementDetail extends ElementPage {
+public class ElementDetail extends ElementPageDetail {
- @Inject
- private ComponentResources resources;
-
- @InjectPage
- private ElementExport elementExport;
-
- @InjectPage
- private ElementHistory elementHistory;
-
- @InjectPage
- private ElementDelete elementDelete;
-
- @InjectPage
- private ElementRights elementRights;
-
public String getWindowTitle() {
return "";
}
-
+
/**
* Headers of tree grid
*
@@ -88,38 +73,6 @@
return nodes;
}
- public Object onExport(String context) {
- StringTokenizer st = new StringTokenizer(context, ",");
- String uuid = st.nextToken();
- String version = st.nextToken();
- elementExport.setup(uuid, version);
- return elementExport;
- }
-
- public Object onHistory(String context) {
- StringTokenizer st = new StringTokenizer(context, ",");
- String uuid = st.nextToken();
- String version = st.nextToken();
- elementHistory.setup(uuid, version);
- return elementHistory;
- }
-
- public Object onDelete(String context) {
- StringTokenizer st = new StringTokenizer(context, ",");
- String uuid = st.nextToken();
- String version = st.nextToken();
- elementDelete.setup(uuid, version);
- return elementDelete;
- }
-
- public Object onRights(String context) {
- StringTokenizer st = new StringTokenizer(context, ",");
- String uuid = st.nextToken();
- String version = st.nextToken();
- elementRights.setup(uuid, version);
- return elementRights;
- }
-
private Object downloadElement(String uuid, String version) {
StreamResponse response;
@@ -160,55 +113,6 @@
return node;
}
- private String generateString(String actionCaption, String action,
- LoggableElement element) {
- String context = element.getMetaData().getUuid() + ","
- + element.getMetaData().getVersion();
- Link link = resources.createActionLink(action, false, context);
- StringBuffer sb = new StringBuffer("");
- sb.append("<a href=\"");
- sb.append(link.toString());
- sb.append("\">");
- sb.append(actionCaption);
- sb.append("</a>");
- return sb.toString();
- }
-
- private String generateActions(LoggableElement element, StringBuilder sb,
- String... actions) {
- String res;
- for (String anAction : actions) {
- sb.append("<br>");
- sb.append(generateString(anAction, anAction, element));
- }
- sb.append("<br>");
- // TODO add security
- sb.append(generateString("rights", "rights", element));
-
- res = sb.substring(4);
- return res;
- }
-
- private String[] generateStringArray(String s1, String s2, String s3,
- LoggableElement element, String... actions) {
- List<String> result = new ArrayList<String>();
- result.add(s1);
- result.add(s2);
- result.add(s3);
- String s4 = "";
- StringBuilder sb = new StringBuilder("");
- if (element != null) {
- s4 = generateActions(element, sb, actions);
- }
- result.add(s4);
-
- return result.toArray(new String[result.size()]);
- }
-
- private String[] generateStringArray(String s1, String s2, String s3) {
- return generateStringArray(s1, s2, s3, null);
- }
-
private String generateHeader(String caption) {
StringBuilder sb = new StringBuilder();
sb.append("<b>");
@@ -225,8 +129,8 @@
node.setColumns(generateStringArray("Application exploration",
getElement().getMetaData().getName(), getElement()
- .getMetaData().getVersion().toString(), getElement(),
- "export", "history", "delete"));
+ .getMetaData().getVersion().toString(), getElement()
+ .getMetaData(), "export", "history", "delete"));
List<TreeNode> children = new ArrayList<TreeNode>();
TreeNode node1 = new TreeNode();
@@ -265,8 +169,8 @@
explorationDataNode.setColumns(generateStringArray("Exploration data",
explorationData.getMetaData().getName(), explorationData
- .getMetaData().getVersion().toString(),
- explorationData, "history", "delete"));
+ .getMetaData().getVersion().toString(), explorationData
+ .getMetaData(), "history", "delete"));
List<TreeNode> children = new ArrayList<TreeNode>();
@@ -302,8 +206,8 @@
TreeNode res = new TreeNode();
res.setType(TreeNode.TYPE_DOCUMENT);
- res.setColumns(generateStringArray("Result", "", "", explorationData,
- "download"));
+ res.setColumns(generateStringArray("Result", "", "", explorationData
+ .getMetaData(), "download"));
return res;
}
@@ -331,7 +235,7 @@
componentNode.setColumns(generateStringArray("Component", component
.getMetaData().getName(), component.getMetaData().getVersion()
- .toString(), component, "history", "delete"));
+ .toString(), component.getMetaData(), "history", "delete"));
List<TreeNode> children = new ArrayList<TreeNode>();
@@ -374,9 +278,11 @@
TreeNode node = new TreeNode();
node.setType(TreeNode.TYPE_DOCUMENT);
- node.setColumns(generateStringArray("Library", library
- .getMetaData().getName(), library.getMetaData()
- .getVersion().toString(), library, "download"));
+ node
+ .setColumns(generateStringArray("Library", library
+ .getMetaData().getName(), library.getMetaData()
+ .getVersion().toString(), library.getMetaData(),
+ "download"));
res.add(node);
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java 2008-01-25 16:16:18 UTC (rev 544)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java 2008-01-25 16:16:46 UTC (rev 545)
@@ -22,15 +22,19 @@
import java.util.Comparator;
import java.util.List;
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.Link;
import org.apache.tapestry.annotations.Persist;
+import org.apache.tapestry.ioc.annotations.Inject;
import org.codelutin.tapestry.beans.TreeNode;
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
-public class ElementHistory extends ElementPage {
+public class ElementHistory extends ElementPageDetail {
public class MetadataVersionComparator implements
Comparator<MetaDataEntity> {
@@ -44,6 +48,9 @@
@Persist
private MetaDataEntity[] versions;
+ @Inject
+ private ComponentResources resources;
+
@Override
public void setup(String uuid, String version) {
super.setup(uuid, version);
@@ -58,7 +65,7 @@
public String getWindowTitle() {
return "";
}
-
+
/**
* Headers of tree grid
*
@@ -134,7 +141,8 @@
TreeNode node = new TreeNode();
// FIXME date tostring
node.setColumns(generateStringArray(mde.getVersion().toString(), mde
- .getDescription(), mde.getCreationDate().toString()));
+ .getDescription(), mde.getCreationDate().toString(), mde,
+ "export", "delete", "details"));
node.setObject(mde.getVersion());
node.setType(TreeNode.TYPE_DOCUMENT);
return node;
@@ -144,8 +152,4 @@
return (Version) treeNode.getObject();
}
- private String[] generateStringArray(String... s) {
- return s;
- }
-
}
Added: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPageDetail.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPageDetail.java (rev 0)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPageDetail.java 2008-01-25 16:16:46 UTC (rev 545)
@@ -0,0 +1,140 @@
+/*
+* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.ui.web.pages;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.Link;
+import org.apache.tapestry.annotations.InjectPage;
+import org.apache.tapestry.ioc.annotations.Inject;
+
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
+import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity;
+
+public abstract class ElementPageDetail extends ElementPage {
+
+ @Inject
+ private ComponentResources resources;
+
+ @InjectPage
+ private ElementExport elementExport;
+
+ @InjectPage
+ private ElementHistory elementHistory;
+
+ @InjectPage
+ private ElementDelete elementDelete;
+
+ @InjectPage
+ private ElementRights elementRights;
+
+ @InjectPage
+ private ElementDetail elementDetail;
+
+ public Object onExport(String context) {
+ StringTokenizer st = new StringTokenizer(context, ",");
+ String uuid = st.nextToken();
+ String version = st.nextToken();
+ elementExport.setup(uuid, version);
+ return elementExport;
+ }
+
+ public Object onHistory(String context) {
+ StringTokenizer st = new StringTokenizer(context, ",");
+ String uuid = st.nextToken();
+ String version = st.nextToken();
+ elementHistory.setup(uuid, version);
+ return elementHistory;
+ }
+
+ public Object onDelete(String context) {
+ StringTokenizer st = new StringTokenizer(context, ",");
+ String uuid = st.nextToken();
+ String version = st.nextToken();
+ elementDelete.setup(uuid, version);
+ return elementDelete;
+ }
+
+ public Object onRights(String context) {
+ StringTokenizer st = new StringTokenizer(context, ",");
+ String uuid = st.nextToken();
+ String version = st.nextToken();
+ elementRights.setup(uuid, version);
+ return elementRights;
+ }
+
+ public Object onDetails(String context) {
+ StringTokenizer st = new StringTokenizer(context, ",");
+ String uuid = st.nextToken();
+ String version = st.nextToken();
+ elementDetail.setup(uuid, version);
+ return elementDetail;
+ }
+
+ private String generateString(String actionCaption, String action,
+ MetaDataEntity element) {
+ String context = element.getUuid() + "," + element.getVersion();
+ Link link = resources.createActionLink(action, false, context);
+ StringBuffer sb = new StringBuffer("");
+ sb.append("<a href=\"");
+ sb.append(link.toString());
+ sb.append("\">");
+ sb.append(actionCaption);
+ sb.append("</a>");
+ return sb.toString();
+ }
+
+ private String generateActions(MetaDataEntity element, String... actions) {
+ StringBuilder sb = new StringBuilder("");
+
+ String res;
+ for (String anAction : actions) {
+ sb.append("<br>");
+ sb.append(generateString(anAction, anAction, element));
+ }
+ sb.append("<br>");
+ // TODO add security
+ sb.append(generateString("rights", "rights", element));
+
+ res = sb.substring(4);
+ return res;
+ }
+
+ protected String[] generateStringArray(String s1, String s2, String s3,
+ MetaDataEntity element, String... actions) {
+ List<String> result = new ArrayList<String>();
+ result.add(s1);
+ result.add(s2);
+ result.add(s3);
+ String s4 = "";
+ if (element != null) {
+ s4 = generateActions(element, actions);
+ }
+ result.add(s4);
+
+ return result.toArray(new String[result.size()]);
+ }
+
+ protected String[] generateStringArray(String... s) {
+ return s;
+ }
+
+}
1
0