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
February 2008
- 2 participants
- 701 discussions
r635 - trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao
by glandais@users.labs.libre-entreprise.org 04 Feb '08
by glandais@users.labs.libre-entreprise.org 04 Feb '08
04 Feb '08
Author: glandais
Date: 2008-02-04 15:40:42 +0000 (Mon, 04 Feb 2008)
New Revision: 635
Modified:
trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java
Log:
Warnings
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-02-04 15:18:45 UTC (rev 634)
+++ trunk/simexplorer-is-security/src/java/fr/cemagref/simexplorer/is/security/dao/DaoSecurityImpl.java 2008-02-04 15:40:42 UTC (rev 635)
@@ -26,6 +26,8 @@
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
+import org.codelutin.util.CollectionUtil;
+
import fr.cemagref.simexplorer.is.security.entities.Group;
import fr.cemagref.simexplorer.is.security.entities.LoginAction;
import fr.cemagref.simexplorer.is.security.entities.Permission;
@@ -214,76 +216,76 @@
/* (non-Javadoc)
* @see fr.cemagref.simexplorer.is.security.dao.DaoSecurity#getGroups()
*/
- @SuppressWarnings("unchecked")
public List<Group> getGroups() {
- List<Group> groups = em.createQuery("select g from Group g")
- .getResultList();
+ List<Group> groups = CollectionUtil.toGenericList(em.createQuery(
+ "select g from Group g").getResultList(), Group.class);
return groups;
}
/* (non-Javadoc)
* @see fr.cemagref.simexplorer.is.security.dao.DaoSecurity#getGroupsOwnedBy(fr.cemagref.simexplorer.is.security.entities.User)
*/
- @SuppressWarnings("unchecked")
public List<Group> getGroupsOwnedBy(User user) {
- List<Group> groups = em.createQuery(
+ List<Group> groups = CollectionUtil.toGenericList(em.createQuery(
"select g from Group g where g.owner=:owner").setParameter(
- "owner", user).getResultList();
+ "owner", user).getResultList(), Group.class);
return groups;
}
/* (non-Javadoc)
* @see fr.cemagref.simexplorer.is.security.dao.DaoSecurity#getUsers()
*/
- @SuppressWarnings("unchecked")
public List<User> getUsers() {
- List<User> users = em.createQuery("select u from User u")
- .getResultList();
+ List<User> users = CollectionUtil.toGenericList(em.createQuery(
+ "select u from User u").getResultList(), User.class);
return users;
}
/* (non-Javadoc)
* @see fr.cemagref.simexplorer.is.security.dao.DaoSecurity#getUsersOfGroup(fr.cemagref.simexplorer.is.security.entities.Group)
*/
- @SuppressWarnings("unchecked")
public List<User> getUsersOfGroup(Group group) {
- List<User> users = em
- .createQuery(
- "select distinct u from User u where :group member of u.groups")
- .setParameter("group", group).getResultList();
+ List<User> users = CollectionUtil
+ .toGenericList(
+ em
+ .createQuery(
+ "select distinct u from User u where :group member of u.groups")
+ .setParameter("group", group).getResultList(),
+ User.class);
return users;
}
/* (non-Javadoc)
* @see fr.cemagref.simexplorer.is.security.dao.DaoSecurity#getGroupsOfUser(fr.cemagref.simexplorer.is.security.entities.User)
*/
- @SuppressWarnings("unchecked")
public List<Group> getGroupsOfUser(User user) {
- List<Group> groups = em.createQuery(
+ List<Group> groups = CollectionUtil.toGenericList(em.createQuery(
"select distinct u.groups from User u where u = :user")
- .setParameter("user", user).getResultList();
+ .setParameter("user", user).getResultList(), Group.class);
return groups;
}
/* (non-Javadoc)
* @see fr.cemagref.simexplorer.is.security.dao.DaoSecurity#getGroupsOfGroup(fr.cemagref.simexplorer.is.security.entities.Group)
*/
- @SuppressWarnings("unchecked")
public List<Group> getGroupsOfGroup(Group group) {
- List<Group> groups = em.createQuery(
+ List<Group> groups = CollectionUtil.toGenericList(em.createQuery(
"select distinct g.groups from Group g where g = :group")
- .setParameter("group", group).getResultList();
+ .setParameter("group", group).getResultList(), Group.class);
return groups;
}
/* (non-Javadoc)
* @see fr.cemagref.simexplorer.is.security.dao.DaoSecurity#getPermissions(java.lang.String)
*/
- @SuppressWarnings("unchecked")
public List<Permission> getPermissions(String businessId) {
- List<Permission> permissions = em.createQuery(
- "select p from Permission p where p.businessId=:businessId")
- .setParameter("businessId", businessId).getResultList();
+ List<Permission> permissions = CollectionUtil
+ .toGenericList(
+ em
+ .createQuery(
+ "select p from Permission p where p.businessId=:businessId")
+ .setParameter("businessId", businessId)
+ .getResultList(), Permission.class);
return permissions;
}
1
0
r634 - trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service
by glandais@users.labs.libre-entreprise.org 04 Feb '08
by glandais@users.labs.libre-entreprise.org 04 Feb '08
04 Feb '08
Author: glandais
Date: 2008-02-04 15:18:45 +0000 (Mon, 04 Feb 2008)
New Revision: 634
Modified:
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java
Log:
Constructor
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java 2008-02-04 15:17:29 UTC (rev 633)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java 2008-02-04 15:18:45 UTC (rev 634)
@@ -32,7 +32,7 @@
* Instantiates a new sim explorer service exception.
*/
public SimExplorerServiceException() {
- // nothing yet
+ super();
}
/**
1
0
r633 - in trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web: . components grid pages pages/security services tools
by glandais@users.labs.libre-entreprise.org 04 Feb '08
by glandais@users.labs.libre-entreprise.org 04 Feb '08
04 Feb '08
Author: glandais
Date: 2008-02-04 15:17:29 +0000 (Mon, 04 Feb 2008)
New Revision: 633
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/components/Back.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/components/Layout.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java
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/ElementHistory.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementList.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/ElementPageDetail.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/GroupList.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Install.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/java/fr/cemagref/simexplorer/is/ui/web/pages/UserList.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/AdminPage.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/SuperAdminPage.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/UserPage.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/AppModule.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/GroupValueEncoder.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteSecurityService.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteStorageService.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/UserValueEncoder.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/AttachmentStreamResponse.java
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/XMLAttachment.java
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/ZipAttachment.java
Log:
Javadoc
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/SimExplorerWebException.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -17,22 +17,49 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.web;
+/**
+ * The Class SimExplorerWebException.
+ */
public class SimExplorerWebException extends RuntimeException {
+ /** The Constant serialVersionUID. */
private static final long serialVersionUID = 4644835311729988659L;
+ /**
+ * Instantiates a new sim explorer web exception.
+ */
public SimExplorerWebException() {
super();
}
+ /**
+ * Instantiates a new sim explorer web exception.
+ *
+ * @param cause
+ * the cause
+ */
public SimExplorerWebException(Throwable cause) {
super(cause);
}
+ /**
+ * Instantiates a new sim explorer web exception.
+ *
+ * @param message
+ * the message
+ */
public SimExplorerWebException(String message) {
super(message);
}
+ /**
+ * Instantiates a new sim explorer web exception.
+ *
+ * @param message
+ * the message
+ * @param cause
+ * the cause
+ */
public SimExplorerWebException(String message, Throwable cause) {
super(message, cause);
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/components/Back.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/components/Back.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/components/Back.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -19,15 +19,30 @@
import org.apache.tapestry.annotations.Parameter;
+/**
+ * The Class Back.
+ */
public class Back {
+ /** The label. */
@Parameter(required = true)
private String label;
+ /**
+ * Gets the label.
+ *
+ * @return the label
+ */
public String getLabel() {
return label;
}
+ /**
+ * Sets the label.
+ *
+ * @param label
+ * the new label
+ */
public void setLabel(String label) {
this.label = label;
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/components/Layout.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/components/Layout.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/components/Layout.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -21,20 +21,15 @@
import javax.servlet.http.HttpSession;
-import org.apache.tapestry.annotations.ApplicationState;
-import org.apache.tapestry.annotations.Component;
import org.apache.tapestry.annotations.IncludeStylesheet;
import org.apache.tapestry.annotations.InjectPage;
import org.apache.tapestry.annotations.Parameter;
import org.apache.tapestry.annotations.Service;
-import org.apache.tapestry.corelib.components.Form;
-import org.apache.tapestry.corelib.components.TextField;
import org.apache.tapestry.ioc.annotations.Inject;
import org.apache.tapestry.services.PersistentLocale;
import org.apache.tapestry.services.RequestGlobals;
import de.hsofttec.t5components.annotations.SetterGetter;
-
import fr.cemagref.simexplorer.is.ui.web.pages.ElementList;
/**
@@ -48,39 +43,37 @@
@IncludeStylesheet("css/Layout.css")
public class Layout {
+ /** The persistent locale. */
@Inject
@Service("PersistentLocale")
private PersistentLocale persistentLocale;
- @ApplicationState
- private String token;
-
- @Component
- private TextField searchField;
-
+ /** The _search text. */
@SetterGetter
private String _searchText;
- @Component
- private Form form;
-
+ /** The element list. */
@InjectPage
private ElementList elementList;
+ /** The request globals. */
@Inject
private RequestGlobals requestGlobals;
- /**
- * page title
- */
+ /** page title. */
@Parameter("defaulttitle")
private String title;
+ /**
+ * Instantiates a new layout.
+ */
public Layout() {
super();
}
/**
+ * Gets the title.
+ *
* @return the title
*/
public String getTitle() {
@@ -88,22 +81,37 @@
}
/**
- * Set default title
+ * Set default title.
*/
void getDefaultTitle() {
title = "";
}
+ /**
+ * On action from switch locale fr.
+ *
+ * @return the object
+ */
Object onActionFromSwitchLocaleFr() {
persistentLocale.set(new Locale("fr"));
return null;
}
+ /**
+ * On action from switch locale en.
+ *
+ * @return the object
+ */
Object onActionFromSwitchLocaleEn() {
persistentLocale.set(new Locale("en"));
return null;
}
+ /**
+ * On success.
+ *
+ * @return the object
+ */
Object onSuccess() {
elementList.searchQuery(_searchText);
// form.recordError(searchField, "Invalid request.");
@@ -111,29 +119,60 @@
return elementList;
}
+ /**
+ * On action from application list.
+ *
+ * @return the object
+ */
public Object onActionFromApplicationList() {
elementList.searchQuery(null);
return elementList;
}
+ /**
+ * On action from logout.
+ *
+ * @return the object
+ */
public Object onActionFromLogout() {
- HttpSession session = requestGlobals.getHTTPServletRequest().getSession();
+ HttpSession session = requestGlobals.getHTTPServletRequest()
+ .getSession();
session.invalidate();
return elementList;
}
+ /**
+ * Gets the login name.
+ *
+ * @return the login name
+ */
public String getLoginName() {
return elementList.getUserLogged().getLogin();
}
+ /**
+ * Gets the logged.
+ *
+ * @return the logged
+ */
public boolean getLogged() {
return elementList.isUserLogged();
}
+ /**
+ * Gets the administrator.
+ *
+ * @return the administrator
+ */
public boolean getAdministrator() {
return elementList.isUserAdmin();
}
+ /**
+ * Gets the super administrator.
+ *
+ * @return the super administrator
+ */
public boolean getSuperAdministrator() {
return elementList.isUserSuperAdmin();
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -26,36 +26,31 @@
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
/**
- * Datasource of element list
+ * Datasource of element list.
*
* @author glandais
- *
*/
public class ElementDataSource implements GridDataSource {
- /**
- * Query being searched
- */
+ /** Query being searched. */
private String query = "";
- /**
- * Bookmark on first item index
- */
+
+ /** Bookmark on first item index. */
private int indexStart = 0;
- /**
- * Cached entities
- */
+
+ /** Cached entities. */
private MetaData[] entities = null;
- /**
- * Authentification token
- */
+ /** Authentification token. */
private String token;
/**
- * Build datasource with text query
+ * Build datasource with text query.
*
* @param token
+ * the token
* @param query
+ * the query
*/
public ElementDataSource(String token, String query) {
super();
@@ -64,9 +59,10 @@
}
/**
- * Build datasource without text query
+ * Build datasource without text query.
*
* @param token
+ * the token
*/
public ElementDataSource(String token) {
super();
@@ -96,7 +92,7 @@
/* (non-Javadoc)
* @see org.apache.tapestry.grid.GridDataSource#getRowType()
*/
- public Class getRowType() {
+ public Class<?> getRowType() {
return MetaData.class;
}
@@ -140,7 +136,7 @@
}
/**
- * Current query
+ * Current query.
*
* @return Current text query
*/
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDelete.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -17,22 +17,26 @@
* ##% */
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;
+/**
+ * The Class ElementDelete.
+ */
public class ElementDelete extends ElementPage {
+ /** The element detail. */
@InjectPage
private ElementDetail elementDetail;
+ /**
+ * On action from confirm.
+ *
+ * @return the object
+ */
public Object onActionFromConfirm() {
try {
RemoteStorageService.getStorageService().deleteElement(getToken(),
@@ -44,6 +48,11 @@
return elementDetail;
}
+ /**
+ * On action from confirm all.
+ *
+ * @return the object
+ */
public Object onActionFromConfirmAll() {
try {
RemoteStorageService.getStorageService().deleteElement(getToken(),
@@ -54,6 +63,10 @@
return elementDetail;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -17,25 +17,12 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.web.pages;
-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;
-import org.apache.tapestry.StreamResponse;
-import org.apache.tapestry.annotations.InjectPage;
-import org.apache.tapestry.ioc.annotations.Inject;
import org.codelutin.tapestry.beans.TreeNode;
-import com.healthmarketscience.rmiio.RemoteInputStream;
-import com.healthmarketscience.rmiio.RemoteInputStreamClient;
-
-import fr.cemagref.simexplorer.is.attachment.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;
@@ -43,21 +30,23 @@
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.data.Structure;
-import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
-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;
+/**
+ * The Class ElementDetail.
+ */
public class ElementDetail extends ElementPageDetail {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
return "";
}
/**
- * Headers of tree grid
+ * Headers of tree grid.
*
* @return Headers
*/
@@ -70,12 +59,22 @@
return result;
}
+ /**
+ * Gets the nodes.
+ *
+ * @return the nodes
+ */
public List<TreeNode> getNodes() {
List<TreeNode> nodes = new ArrayList<TreeNode>();
nodes.add(generateElement());
return nodes;
}
+ /**
+ * Generate element.
+ *
+ * @return the tree node
+ */
private TreeNode generateElement() {
TreeNode node = null;
if (getElement() instanceof ExplorationApplication) {
@@ -94,6 +93,14 @@
return node;
}
+ /**
+ * Generate header.
+ *
+ * @param caption
+ * the caption
+ *
+ * @return the string
+ */
private String generateHeader(String caption) {
StringBuilder sb = new StringBuilder();
sb.append("<b>");
@@ -102,6 +109,11 @@
return sb.toString();
}
+ /**
+ * Generate exploration application.
+ *
+ * @return the tree node
+ */
private TreeNode generateExplorationApplication() {
TreeNode node;
node = new TreeNode();
@@ -132,6 +144,14 @@
return node;
}
+ /**
+ * Generate explorations.
+ *
+ * @param explorationApplication
+ * the exploration application
+ *
+ * @return the list< tree node>
+ */
private List<TreeNode> generateExplorations(
ExplorationApplication explorationApplication) {
List<TreeNode> res = new ArrayList<TreeNode>();
@@ -144,6 +164,14 @@
return res;
}
+ /**
+ * Generate exploration data.
+ *
+ * @param explorationData
+ * the exploration data
+ *
+ * @return the tree node
+ */
private TreeNode generateExplorationData(ExplorationData explorationData) {
TreeNode explorationDataNode = new TreeNode();
explorationDataNode.setType(TreeNode.TYPE_FOLDER);
@@ -168,6 +196,14 @@
return explorationDataNode;
}
+ /**
+ * Generate values.
+ *
+ * @param explorationData
+ * the exploration data
+ *
+ * @return the list< tree node>
+ */
private List<TreeNode> generateValues(ExplorationData explorationData) {
Set<ConstantValue> values = explorationData.getValuesMap();
List<TreeNode> res = new ArrayList<TreeNode>();
@@ -183,6 +219,14 @@
return res;
}
+ /**
+ * Generate result.
+ *
+ * @param explorationData
+ * the exploration data
+ *
+ * @return the tree node
+ */
private TreeNode generateResult(ExplorationData explorationData) {
TreeNode res = new TreeNode();
res.setType(TreeNode.TYPE_DOCUMENT);
@@ -192,6 +236,14 @@
return res;
}
+ /**
+ * Generate components.
+ *
+ * @param explorationApplication
+ * the exploration application
+ *
+ * @return the list< tree node>
+ */
private List<TreeNode> generateComponents(
ExplorationApplication explorationApplication) {
Set<Component> components = explorationApplication.getComponents();
@@ -204,12 +256,25 @@
return res;
}
+ /**
+ * Inits the node.
+ *
+ * @return the tree node
+ */
private TreeNode initNode() {
TreeNode node = new TreeNode();
node.setType(TreeNode.TYPE_FOLDER);
return node;
}
+ /**
+ * Generate component.
+ *
+ * @param component
+ * the component
+ *
+ * @return the tree node
+ */
private TreeNode generateComponent(Component component) {
TreeNode componentNode = new TreeNode();
componentNode.setType(TreeNode.TYPE_FOLDER);
@@ -254,6 +319,14 @@
return componentNode;
}
+ /**
+ * Generate libraries.
+ *
+ * @param component
+ * the component
+ *
+ * @return the list< tree node>
+ */
private List<TreeNode> generateLibraries(Component component) {
Set<Library> libraries = component.getLibraries();
@@ -266,6 +339,14 @@
return res;
}
+ /**
+ * Generate library.
+ *
+ * @param library
+ * the library
+ *
+ * @return the tree node
+ */
private TreeNode generateLibrary(Library library) {
TreeNode node = new TreeNode();
node.setType(TreeNode.TYPE_DOCUMENT);
@@ -276,6 +357,14 @@
return node;
}
+ /**
+ * Generate codes.
+ *
+ * @param codes
+ * the codes
+ *
+ * @return the list< tree node>
+ */
private List<TreeNode> generateCodes(Set<Code> codes) {
List<TreeNode> res = new ArrayList<TreeNode>();
for (Code code : codes) {
@@ -288,6 +377,15 @@
return res;
}
+ /**
+ * Generate structures.
+ *
+ * @param structures
+ * the structures
+ *
+ * @return the list< tree node>
+ */
+ @SuppressWarnings("unused")
private List<TreeNode> generateStructures(Set<Structure> structures) {
List<TreeNode> res = new ArrayList<TreeNode>();
for (Structure structure : structures) {
@@ -299,6 +397,14 @@
return res;
}
+ /**
+ * Generate constants.
+ *
+ * @param constants
+ * the constants
+ *
+ * @return the list< tree node>
+ */
private List<TreeNode> generateConstants(Set<Constant> constants) {
List<TreeNode> res = new ArrayList<TreeNode>();
for (Constant constant : constants) {
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementExport.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -20,7 +20,6 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
@@ -31,7 +30,6 @@
import com.healthmarketscience.rmiio.RemoteInputStreamClient;
import fr.cemagref.simexplorer.is.attachment.Attachment;
-import fr.cemagref.simexplorer.is.attachment.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;
@@ -44,12 +42,24 @@
import fr.cemagref.simexplorer.is.ui.web.tools.XMLAttachment;
import fr.cemagref.simexplorer.is.ui.web.tools.ZipAttachment;
+/**
+ * The Class ElementExport.
+ */
public class ElementExport extends ElementPageDetail {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
return "";
}
+ /**
+ * On action from download xml.
+ *
+ * @return the object
+ */
public Object onActionFromDownloadXML() {
Object response;
@@ -70,6 +80,11 @@
return response;
}
+ /**
+ * On action from download full.
+ *
+ * @return the object
+ */
public Object onActionFromDownloadFull() {
Object response;
@@ -89,6 +104,14 @@
return response;
}
+ /**
+ * On download file.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onDownloadFile(String context) {
StreamResponse response;
@@ -111,7 +134,7 @@
}
/**
- * Headers of tree grid
+ * Headers of tree grid.
*
* @return Headers
*/
@@ -124,12 +147,22 @@
return result;
}
+ /**
+ * Gets the nodes.
+ *
+ * @return the nodes
+ */
public List<TreeNode> getNodes() {
List<TreeNode> nodes = new ArrayList<TreeNode>();
nodes.add(generateNodes());
return nodes;
}
+ /**
+ * Generate nodes.
+ *
+ * @return the tree node
+ */
private TreeNode generateNodes() {
TreeNode node = null;
if (getElement() instanceof ExplorationApplication) {
@@ -147,6 +180,11 @@
return node;
}
+ /**
+ * Generate exploration application.
+ *
+ * @return the tree node
+ */
private TreeNode generateExplorationApplication() {
TreeNode node;
node = new TreeNode();
@@ -175,6 +213,14 @@
return node;
}
+ /**
+ * Generate explorations.
+ *
+ * @param explorationApplication
+ * the exploration application
+ *
+ * @return the list< tree node>
+ */
private List<TreeNode> generateExplorations(
ExplorationApplication explorationApplication) {
List<TreeNode> res = new ArrayList<TreeNode>();
@@ -187,6 +233,14 @@
return res;
}
+ /**
+ * Generate exploration data.
+ *
+ * @param explorationData
+ * the exploration data
+ *
+ * @return the tree node
+ */
private TreeNode generateExplorationData(ExplorationData explorationData) {
TreeNode explorationDataNode = new TreeNode();
explorationDataNode.setType(TreeNode.TYPE_FOLDER);
@@ -207,6 +261,14 @@
return explorationDataNode;
}
+ /**
+ * Generate components.
+ *
+ * @param explorationApplication
+ * the exploration application
+ *
+ * @return the list< tree node>
+ */
private List<TreeNode> generateComponents(
ExplorationApplication explorationApplication) {
Set<Component> components = explorationApplication.getComponents();
@@ -219,6 +281,14 @@
return res;
}
+ /**
+ * Generate component.
+ *
+ * @param component
+ * the component
+ *
+ * @return the tree node
+ */
private TreeNode generateComponent(Component component) {
TreeNode componentNode = new TreeNode();
componentNode.setType(TreeNode.TYPE_FOLDER);
@@ -242,9 +312,16 @@
return componentNode;
}
+ /**
+ * Generate libraries.
+ *
+ * @param libraries
+ * the libraries
+ *
+ * @return the list< tree node>
+ */
private List<TreeNode> generateLibraries(Set<Library> libraries) {
List<TreeNode> res = new ArrayList<TreeNode>();
- int i = 0;
for (Library library : libraries) {
TreeNode node = generateLibrary(library);
res.add(node);
@@ -252,6 +329,14 @@
return res;
}
+ /**
+ * Generate library.
+ *
+ * @param library
+ * the library
+ *
+ * @return the tree node
+ */
private TreeNode generateLibrary(Library library) {
TreeNode node = new TreeNode();
node.setType(TreeNode.TYPE_FOLDER);
@@ -268,6 +353,16 @@
return node;
}
+ /**
+ * Generate download.
+ *
+ * @param explorationData
+ * the exploration data
+ * @param attachment
+ * the attachment
+ *
+ * @return the tree node
+ */
private TreeNode generateDownload(LoggableElement explorationData,
Attachment attachment) {
TreeNode node = new TreeNode();
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementHistory.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -22,35 +22,40 @@
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.MetaData;
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;
+/**
+ * The Class ElementHistory.
+ */
public class ElementHistory extends ElementPageDetail {
- public class MetadataVersionComparator implements
- Comparator<MetaData> {
+ /**
+ * The Class MetadataVersionComparator.
+ */
+ public class MetadataVersionComparator implements Comparator<MetaData> {
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
public int compare(MetaData arg0, MetaData arg1) {
return arg0.getVersion().compareTo(arg1.getVersion());
}
}
+ /** The versions. */
@Persist
private MetaData[] versions;
- @Inject
- private ComponentResources resources;
-
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.ElementPage#setup(java.lang.String, java.lang.String)
+ */
@Override
public void setup(String uuid, String version) {
super.setup(uuid, version);
@@ -62,12 +67,16 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
return "";
}
/**
- * Headers of tree grid
+ * Headers of tree grid.
*
* @return Headers
*/
@@ -79,12 +88,22 @@
return result;
}
+ /**
+ * Gets the versions.
+ *
+ * @return the versions
+ */
public List<TreeNode> getVersions() {
List<TreeNode> nodes = new ArrayList<TreeNode>();
nodes.add(generateNodes());
return nodes;
}
+ /**
+ * Generate nodes.
+ *
+ * @return the tree node
+ */
private TreeNode generateNodes() {
Arrays.sort(versions, new MetadataVersionComparator());
TreeNode rootNode = new TreeNode();
@@ -98,6 +117,16 @@
return rootNode;
}
+ /**
+ * Insert node.
+ *
+ * @param mde
+ * the mde
+ * @param pos
+ * the pos
+ * @param parent
+ * the parent
+ */
private void insertNode(MetaData mde, int pos, TreeNode parent) {
List<TreeNode> nodes = parent.getChildren();
if (pos == mde.getVersion().getLength()) {
@@ -119,6 +148,18 @@
}
}
+ /**
+ * Generate folder.
+ *
+ * @param mde
+ * the mde
+ * @param pos
+ * the pos
+ * @param parent
+ * the parent
+ *
+ * @return the tree node
+ */
private TreeNode generateFolder(MetaData mde, int pos, TreeNode parent) {
TreeNode node = new TreeNode();
node.setChildren(new ArrayList<TreeNode>());
@@ -129,6 +170,16 @@
return node;
}
+ /**
+ * Generate version.
+ *
+ * @param version
+ * the version
+ * @param pos
+ * the pos
+ *
+ * @return the version
+ */
private Version generateVersion(Version version, int pos) {
Version v = new Version("");
for (int i = 0; i <= pos; i++) {
@@ -137,6 +188,14 @@
return v;
}
+ /**
+ * Generate leaf.
+ *
+ * @param mde
+ * the mde
+ *
+ * @return the tree node
+ */
private TreeNode generateLeaf(MetaData mde) {
TreeNode node = new TreeNode();
// FIXME date tostring
@@ -148,6 +207,14 @@
return node;
}
+ /**
+ * Gets the version.
+ *
+ * @param treeNode
+ * the tree node
+ *
+ * @return the version
+ */
private Version getVersion(TreeNode treeNode) {
return (Version) treeNode.getObject();
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -27,14 +27,22 @@
import fr.cemagref.simexplorer.is.ui.web.pages.security.UserPage;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
+/**
+ * The Class ElementImport.
+ */
public class ElementImport extends UserPage {
+ /** The _file ea. */
@SetterGetter
private UploadedFile _fileEA;
+ /** The _file lib. */
@SetterGetter
private UploadedFile _fileLib;
+ /**
+ * On success.
+ */
public void onSuccess() {
if (_fileEA != null) {
RemoteInputStreamServer zipRemoteStream = new SimpleRemoteInputStream(
@@ -58,6 +66,10 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
return "";
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementList.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementList.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementList.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -34,26 +34,38 @@
import fr.cemagref.simexplorer.is.ui.web.grid.ElementDataSource;
import fr.cemagref.simexplorer.is.ui.web.pages.security.UserPage;
+/**
+ * The Class ElementList.
+ */
public class ElementList extends UserPage {
+ /** The model. */
@Retain
private BeanModel model;
+ /** The bean model source. */
@Inject
private BeanModelSource beanModelSource;
+ /** The resources. */
@Inject
private ComponentResources resources;
+ /** The element data source. */
@Persist
private ElementDataSource elementDataSource;
+ /** The _element. */
@SetterGetter
private MetaData _element;
+ /** The element detail. */
@InjectPage
private ElementDetail elementDetail;
+ /**
+ * Page loaded.
+ */
void pageLoaded() {
model = beanModelSource.create(MetaData.class, true, resources);
List<String> wantedProperties = new ArrayList<String>();
@@ -75,10 +87,21 @@
elementDataSource = new ElementDataSource(getToken());
}
+ /**
+ * Gets the model.
+ *
+ * @return the model
+ */
public BeanModel getModel() {
return model;
}
+ /**
+ * Search query.
+ *
+ * @param query
+ * the query
+ */
public void searchQuery(String query) {
if (query == null || query.equals("")) {
elementDataSource = new ElementDataSource(getToken());
@@ -87,6 +110,11 @@
}
}
+ /**
+ * Gets the elements.
+ *
+ * @return the elements
+ */
public ElementDataSource getElements() {
if (elementDataSource == null) {
elementDataSource = new ElementDataSource(getToken());
@@ -94,11 +122,24 @@
return elementDataSource;
}
+ /**
+ * Gets the detail element context.
+ *
+ * @return the detail element context
+ */
public String getDetailElementContext() {
String result = _element.getUuid() + "," + _element.getVersion();
return result;
}
+ /**
+ * On action from detail element.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onActionFromDetailElement(String context) {
StringTokenizer st = new StringTokenizer(context, ",");
String uuid = st.nextToken();
@@ -107,6 +148,10 @@
return elementDetail;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
String windowTitle = null;
if (elementDataSource.getQuery() != null
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPage.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -17,9 +17,7 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.web.pages;
-import org.apache.tapestry.ComponentResources;
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.entities.metadata.MetaData;
@@ -27,13 +25,17 @@
import fr.cemagref.simexplorer.is.ui.web.pages.security.UserPage;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
+/**
+ * The Class ElementPage.
+ */
public abstract class ElementPage extends UserPage {
+ /** The element. */
@Persist
private LoggableElement element;
/**
- * Prepare page
+ * Prepare page.
*
* @param uuid
* Id of element to display
@@ -49,10 +51,20 @@
}
}
+ /**
+ * Gets the element.
+ *
+ * @return the element
+ */
public LoggableElement getElement() {
return element;
}
+ /**
+ * Gets the metadata.
+ *
+ * @return the metadata
+ */
public MetaData getMetadata() {
return element.getMetaData();
}
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementPageDetail.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -26,29 +26,45 @@
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.MetaData;
+/**
+ * The Class ElementPageDetail.
+ */
public abstract class ElementPageDetail extends ElementPage {
+ /** The resources. */
@Inject
private ComponentResources resources;
+ /** The element export. */
@InjectPage
private ElementExport elementExport;
+ /** The element history. */
@InjectPage
private ElementHistory elementHistory;
+ /** The element delete. */
@InjectPage
private ElementDelete elementDelete;
+ /** The element rights. */
@InjectPage
private ElementRights elementRights;
+ /** The element detail. */
@InjectPage
private ElementDetail elementDetail;
+ /**
+ * On export.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onExport(String context) {
StringTokenizer st = new StringTokenizer(context, ",");
String uuid = st.nextToken();
@@ -57,6 +73,14 @@
return elementExport;
}
+ /**
+ * On history.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onHistory(String context) {
StringTokenizer st = new StringTokenizer(context, ",");
String uuid = st.nextToken();
@@ -65,6 +89,14 @@
return elementHistory;
}
+ /**
+ * On delete.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onDelete(String context) {
StringTokenizer st = new StringTokenizer(context, ",");
String uuid = st.nextToken();
@@ -73,6 +105,14 @@
return elementDelete;
}
+ /**
+ * On rights.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onRights(String context) {
StringTokenizer st = new StringTokenizer(context, ",");
String uuid = st.nextToken();
@@ -81,6 +121,14 @@
return elementRights;
}
+ /**
+ * On details.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onDetails(String context) {
StringTokenizer st = new StringTokenizer(context, ",");
String uuid = st.nextToken();
@@ -89,6 +137,18 @@
return elementDetail;
}
+ /**
+ * Generate string.
+ *
+ * @param actionCaption
+ * the action caption
+ * @param action
+ * the action
+ * @param context
+ * the context
+ *
+ * @return the string
+ */
protected String generateString(String actionCaption, String action,
String context) {
Link link = resources.createActionLink(action, false, context);
@@ -101,12 +161,36 @@
return sb.toString();
}
+ /**
+ * Generate string.
+ *
+ * @param actionCaption
+ * the action caption
+ * @param action
+ * the action
+ * @param element
+ * the element
+ *
+ * @return the string
+ */
protected String generateString(String actionCaption, String action,
MetaData element) {
String context = element.getUuid() + "," + element.getVersion();
return generateString(actionCaption, action, context);
}
+ /**
+ * Generate actions.
+ *
+ * @param element
+ * the element
+ * @param security
+ * the security
+ * @param actions
+ * the actions
+ *
+ * @return the string
+ */
private String generateActions(MetaData element, boolean security,
String... actions) {
StringBuilder sb = new StringBuilder("");
@@ -125,6 +209,24 @@
return res;
}
+ /**
+ * Generate string array.
+ *
+ * @param s1
+ * the s1
+ * @param s2
+ * the s2
+ * @param s3
+ * the s3
+ * @param element
+ * the element
+ * @param security
+ * the security
+ * @param actions
+ * the actions
+ *
+ * @return the string[]
+ */
protected String[] generateStringArray(String s1, String s2, String s3,
MetaData element, boolean security, String... actions) {
List<String> result = new ArrayList<String>();
@@ -140,6 +242,14 @@
return result.toArray(new String[result.size()]);
}
+ /**
+ * Generate string array.
+ *
+ * @param s
+ * the s
+ *
+ * @return the string[]
+ */
protected String[] generateStringArray(String... s) {
return s;
}
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementRights.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -36,41 +36,66 @@
import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService;
import fr.cemagref.simexplorer.is.ui.web.services.UserValueEncoder;
+/**
+ * The Class ElementRights.
+ */
public class ElementRights extends ElementPage {
+ /** The user encoder. */
@Persist
private UserValueEncoder userEncoder;
+ /** The group encoder. */
@Persist
private GroupValueEncoder groupEncoder;
+ /** The owner users. */
@Persist
private List<User> ownerUsers;
+
+ /** The owner groups. */
@Persist
private List<Group> ownerGroups;
+ /** The read users. */
@Persist
private List<User> readUsers;
+
+ /** The read groups. */
@Persist
private List<Group> readGroups;
+ /** The write users. */
@Persist
private List<User> writeUsers;
+
+ /** The write groups. */
@Persist
private List<Group> writeGroups;
+ /** The admin users. */
@Persist
private List<User> adminUsers;
+
+ /** The admin groups. */
@Persist
private List<Group> adminGroups;
+ /** The element detail. */
@InjectPage
private ElementDetail elementDetail;
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
return "";
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.ElementPage#setup(java.lang.String, java.lang.String)
+ */
@Override
public void setup(String uuid, String version) {
super.setup(uuid, version);
@@ -127,6 +152,16 @@
}
+ /**
+ * Gets the permission.
+ *
+ * @param actor
+ * the actor
+ * @param permissions
+ * the permissions
+ *
+ * @return the permission
+ */
private Permission getPermission(Actor actor,
Map<Actor, Permission> permissions) {
Permission permission = permissions.get(actor);
@@ -143,6 +178,11 @@
return permission;
}
+ /**
+ * On success.
+ *
+ * @return the object
+ */
public Object onSuccess() {
Map<Actor, Permission> permissions = new HashMap<Actor, Permission>();
@@ -181,6 +221,11 @@
return elementDetail;
}
+ /**
+ * Gets the users.
+ *
+ * @return the users
+ */
public List<User> getUsers() {
List<User> result = new ArrayList<User>();
try {
@@ -193,6 +238,11 @@
return result;
}
+ /**
+ * Gets the groups.
+ *
+ * @return the groups
+ */
public List<Group> getGroups() {
List<Group> result = new ArrayList<Group>();
try {
@@ -206,74 +256,172 @@
return result;
}
+ /**
+ * Gets the owner users.
+ *
+ * @return the owner users
+ */
public List<User> getOwnerUsers() {
return ownerUsers;
}
+ /**
+ * Sets the owner users.
+ *
+ * @param ownerUsers
+ * the new owner users
+ */
public void setOwnerUsers(List<User> ownerUsers) {
this.ownerUsers = ownerUsers;
}
+ /**
+ * Gets the read users.
+ *
+ * @return the read users
+ */
public List<User> getReadUsers() {
return readUsers;
}
+ /**
+ * Sets the read users.
+ *
+ * @param readUsers
+ * the new read users
+ */
public void setReadUsers(List<User> readUsers) {
this.readUsers = readUsers;
}
+ /**
+ * Gets the read groups.
+ *
+ * @return the read groups
+ */
public List<Group> getReadGroups() {
return readGroups;
}
+ /**
+ * Sets the read groups.
+ *
+ * @param readGroups
+ * the new read groups
+ */
public void setReadGroups(List<Group> readGroups) {
this.readGroups = readGroups;
}
+ /**
+ * Gets the write users.
+ *
+ * @return the write users
+ */
public List<User> getWriteUsers() {
return writeUsers;
}
+ /**
+ * Sets the write users.
+ *
+ * @param writeUsers
+ * the new write users
+ */
public void setWriteUsers(List<User> writeUsers) {
this.writeUsers = writeUsers;
}
+ /**
+ * Gets the write groups.
+ *
+ * @return the write groups
+ */
public List<Group> getWriteGroups() {
return writeGroups;
}
+ /**
+ * Sets the write groups.
+ *
+ * @param writeGroups
+ * the new write groups
+ */
public void setWriteGroups(List<Group> writeGroups) {
this.writeGroups = writeGroups;
}
+ /**
+ * Gets the admin users.
+ *
+ * @return the admin users
+ */
public List<User> getAdminUsers() {
return adminUsers;
}
+ /**
+ * Sets the admin users.
+ *
+ * @param adminUsers
+ * the new admin users
+ */
public void setAdminUsers(List<User> adminUsers) {
this.adminUsers = adminUsers;
}
+ /**
+ * Gets the admin groups.
+ *
+ * @return the admin groups
+ */
public List<Group> getAdminGroups() {
return adminGroups;
}
+ /**
+ * Sets the admin groups.
+ *
+ * @param adminGroups
+ * the new admin groups
+ */
public void setAdminGroups(List<Group> adminGroups) {
this.adminGroups = adminGroups;
}
+ /**
+ * Gets the user encoder.
+ *
+ * @return the user encoder
+ */
public UserValueEncoder getUserEncoder() {
return userEncoder;
}
+ /**
+ * Gets the group encoder.
+ *
+ * @return the group encoder
+ */
public GroupValueEncoder getGroupEncoder() {
return groupEncoder;
}
+ /**
+ * Gets the owner groups.
+ *
+ * @return the owner groups
+ */
public List<Group> getOwnerGroups() {
return ownerGroups;
}
+ /**
+ * Sets the owner groups.
+ *
+ * @param ownerGroups
+ * the new owner groups
+ */
public void setOwnerGroups(List<Group> ownerGroups) {
this.ownerGroups = ownerGroups;
}
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ExceptionReport.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -17,7 +17,6 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.web.pages;
-import java.io.FileNotFoundException;
import java.util.List;
import org.apache.tapestry.ioc.annotations.Inject;
@@ -27,76 +26,117 @@
import org.apache.tapestry.services.ExceptionReporter;
import de.hsofttec.t5components.annotations.SetterGetter;
-
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
+/**
+ * The Class ExceptionReport.
+ */
public class ExceptionReport implements ExceptionReporter {
+ /** The _unknown. */
@SetterGetter(onlyGetter = true)
private boolean _unknown;
+ /** The exception. */
private SimExplorerWebException exception;
+ /** The _stack. */
+ @SuppressWarnings("unused")
@SetterGetter(onlyGetter = true)
private List<ExceptionInfo> _stack;
+ /** The _info. */
@SetterGetter
private ExceptionInfo _info;
+ /** The _property name. */
@SetterGetter
private String _propertyName;
+ /** The _frame. */
+ @SuppressWarnings("unused")
@SetterGetter
private String _frame;
+ /** The analyzer. */
@Inject
private ExceptionAnalyzer analyzer;
+ /**
+ * Gets the window title.
+ *
+ * @return the window title
+ */
public String getWindowTitle() {
return "Error";
}
- public void reportException(Throwable exception) {
- SimExplorerWebException simException = getException(exception);
+ /* (non-Javadoc)
+ * @see org.apache.tapestry.services.ExceptionReporter#reportException(java.lang.Throwable)
+ */
+ public void reportException(Throwable exceptionReported) {
+ SimExplorerWebException simException = getException(exceptionReported);
if (simException != null) {
_unknown = false;
this.exception = simException;
_unknown = true;
- ExceptionAnalysis analysis = analyzer.analyze(exception);
+ ExceptionAnalysis analysis = analyzer.analyze(exceptionReported);
_stack = analysis.getExceptionInfos();
} else {
_unknown = true;
- ExceptionAnalysis analysis = analyzer.analyze(exception);
+ ExceptionAnalysis analysis = analyzer.analyze(exceptionReported);
_stack = analysis.getExceptionInfos();
}
}
- private SimExplorerWebException getException(Throwable exception) {
- if (exception != null) {
- if (exception instanceof SimExplorerWebException) {
- SimExplorerWebException result = (SimExplorerWebException) exception;
+ /**
+ * Gets the exception.
+ *
+ * @param exceptionReported
+ * the exception reported
+ *
+ * @return the exception
+ */
+ private SimExplorerWebException getException(Throwable exceptionReported) {
+ if (exceptionReported != null) {
+ if (exceptionReported instanceof SimExplorerWebException) {
+ SimExplorerWebException result = (SimExplorerWebException) exceptionReported;
return result;
}
- return getException(exception.getCause());
+ return getException(exceptionReported.getCause());
}
return null;
}
+ /**
+ * Gets the error message.
+ *
+ * @return the error message
+ */
public String getErrorMessage() {
if (!_unknown) {
return exception.getMessage();
- } else {
- return "";
}
+ return "";
}
+ /**
+ * Gets the show property list.
+ *
+ * @return the show property list
+ */
public boolean getShowPropertyList() {
// True if either is non-empty
return !(_info.getPropertyNames().isEmpty() && _info.getStackTrace()
.isEmpty());
}
+ /**
+ * Gets the property value.
+ *
+ * @return the property value
+ */
public Object getPropertyValue() {
return _info.getProperty(_propertyName);
}
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupEdit.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -34,30 +34,49 @@
import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService;
import fr.cemagref.simexplorer.is.ui.web.services.UserValueEncoder;
+/**
+ * The Class GroupEdit.
+ */
public class GroupEdit extends AdminPage {
+ /** The group. */
@Persist
private Group group;
+ /** The group list. */
@InjectPage
private GroupList groupList;
+ /** The users in group. */
@Persist
private List<User> usersInGroup;
+ /** The groups in group. */
@Persist
private List<Group> groupsInGroup;
+ /** The user encoder. */
@Persist
private UserValueEncoder userEncoder;
+ /** The group encoder. */
@Persist
private GroupValueEncoder groupEncoder;
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
return "";
}
+ /**
+ * Sets the up.
+ *
+ * @param groupId
+ * the new up
+ */
void setup(int groupId) {
this.usersInGroup = new ArrayList<User>();
this.groupsInGroup = new ArrayList<Group>();
@@ -87,6 +106,11 @@
groupEncoder = new GroupValueEncoder(getToken());
}
+ /**
+ * On success.
+ *
+ * @return the object
+ */
public Object onSuccess() {
try {
if (group.getId() == null) {
@@ -108,8 +132,8 @@
Integer[] groupsIds = new Integer[groupsInGroup.size()];
i = 0;
- for (Group group : groupsInGroup) {
- groupsIds[i] = group.getId();
+ for (Group aGroup : groupsInGroup) {
+ groupsIds[i] = aGroup.getId();
i++;
}
RemoteSecurityService.getAuthentificationService()
@@ -121,10 +145,20 @@
return groupList;
}
+ /**
+ * On action from cancel.
+ *
+ * @return the object
+ */
public Object onActionFromCancel() {
return groupList;
}
+ /**
+ * Gets the users.
+ *
+ * @return the users
+ */
public List<User> getUsers() {
List<User> result = new ArrayList<User>();
try {
@@ -137,6 +171,11 @@
return result;
}
+ /**
+ * Gets the groups.
+ *
+ * @return the groups
+ */
public List<Group> getGroups() {
List<Group> result = new ArrayList<Group>();
try {
@@ -150,50 +189,114 @@
return result;
}
- public ValueEncoder getUserEncoder() {
+ /**
+ * Gets the user encoder.
+ *
+ * @return the user encoder
+ */
+ public ValueEncoder<User> getUserEncoder() {
return userEncoder;
}
- public ValueEncoder getGroupEncoder() {
+ /**
+ * Gets the group encoder.
+ *
+ * @return the group encoder
+ */
+ public ValueEncoder<Group> getGroupEncoder() {
return groupEncoder;
}
+ /**
+ * Gets the super admin.
+ *
+ * @return the super admin
+ */
public boolean getSuperAdmin() {
return isUserSuperAdmin();
}
+ /**
+ * Gets the users in group.
+ *
+ * @return the users in group
+ */
public List<User> getUsersInGroup() {
return usersInGroup;
}
+ /**
+ * Sets the users in group.
+ *
+ * @param usersInGroup
+ * the new users in group
+ */
public void setUsersInGroup(List<User> usersInGroup) {
this.usersInGroup = usersInGroup;
}
+ /**
+ * Gets the group.
+ *
+ * @return the group
+ */
public Group getGroup() {
return group;
}
+ /**
+ * Gets the group list.
+ *
+ * @return the group list
+ */
public GroupList getGroupList() {
return groupList;
}
+ /**
+ * Sets the group list.
+ *
+ * @param groupList
+ * the new group list
+ */
public void setGroupList(GroupList groupList) {
this.groupList = groupList;
}
+ /**
+ * Gets the groups in group.
+ *
+ * @return the groups in group
+ */
public List<Group> getGroupsInGroup() {
return groupsInGroup;
}
+ /**
+ * Sets the groups in group.
+ *
+ * @param groupsInGroup
+ * the new groups in group
+ */
public void setGroupsInGroup(List<Group> groupsInGroup) {
this.groupsInGroup = groupsInGroup;
}
+ /**
+ * Gets the owner.
+ *
+ * @return the owner
+ */
public User getOwner() {
return this.group.getOwner();
}
+ /**
+ * Sets the owner.
+ *
+ * @param owner
+ * the new owner
+ */
public void setOwner(User owner) {
this.group.setOwner(owner);
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupList.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupList.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/GroupList.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -28,34 +28,49 @@
import org.apache.tapestry.services.BeanModelSource;
import de.hsofttec.t5components.annotations.SetterGetter;
-
import fr.cemagref.simexplorer.is.security.entities.Group;
import fr.cemagref.simexplorer.is.service.SimExplorerServiceException;
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
import fr.cemagref.simexplorer.is.ui.web.pages.security.AdminPage;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService;
+/**
+ * The Class GroupList.
+ */
public class GroupList extends AdminPage {
+ /** The model. */
@Retain
private BeanModel model;
+ /** The _group. */
+ @SuppressWarnings("unused")
@SetterGetter
private Group _group;
+ /** The bean model source. */
@Inject
private BeanModelSource beanModelSource;
+ /** The resources. */
@Inject
private ComponentResources resources;
+ /** The group edit. */
@InjectPage
private GroupEdit groupEdit;
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
return "";
}
-
+
+ /**
+ * Page loaded.
+ */
void pageLoaded() {
model = beanModelSource.create(Group.class, true, resources);
List<String> wantedProperties = new ArrayList<String>();
@@ -70,6 +85,11 @@
model.add("delete", null);
}
+ /**
+ * Gets the groups.
+ *
+ * @return the groups
+ */
public Group[] getGroups() {
Group[] groups;
@@ -90,6 +110,14 @@
return groups;
}
+ /**
+ * On action from delete.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onActionFromDelete(Integer context) {
try {
RemoteSecurityService.getAuthentificationService().deleteGroup(
@@ -100,24 +128,53 @@
return null;
}
+ /**
+ * On action from edit.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onActionFromEdit(Integer context) {
groupEdit.setup(context);
return groupEdit;
}
+ /**
+ * On action from add.
+ *
+ * @return the object
+ */
public Object onActionFromAdd() {
groupEdit.setup(-1);
return groupEdit;
}
+ /**
+ * Gets the model.
+ *
+ * @return the model
+ */
public BeanModel getModel() {
return model;
}
+ /**
+ * Gets the group edit.
+ *
+ * @return the group edit
+ */
public GroupEdit getGroupEdit() {
return groupEdit;
}
+ /**
+ * Sets the group edit.
+ *
+ * @param groupEdit
+ * the new group edit
+ */
public void setGroupEdit(GroupEdit groupEdit) {
this.groupEdit = groupEdit;
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Install.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Install.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Install.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -43,16 +43,28 @@
import fr.cemagref.simexplorer.is.ui.web.pages.security.SuperAdminPage;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService;
+/**
+ * The Class Install.
+ */
public class Install extends SuperAdminPage {
+ /** The element list. */
@InjectPage
private ElementList elementList;
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
@Override
public String getWindowTitle() {
return "";
}
+ /**
+ * On action from generate data.
+ *
+ * @return the object
+ */
public Object onActionFromGenerateData() {
ElementGenerator elementGenerator = new ElementGenerator();
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -25,18 +25,31 @@
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService;
+/**
+ * The Class Login.
+ */
public class Login {
+ /** The user. */
@Persist
private String user;
+
+ /** The password. */
private String password;
+ /** The element list. */
@InjectPage
private ElementList elementList;
+ /** The token. */
@ApplicationState
private String token;
+ /**
+ * On success.
+ *
+ * @return the object
+ */
public Object onSuccess() {
Object result = null;
try {
@@ -52,26 +65,58 @@
return result;
}
+ /**
+ * Gets the user.
+ *
+ * @return the user
+ */
public String getUser() {
return user;
}
+ /**
+ * Sets the user.
+ *
+ * @param user
+ * the new user
+ */
public void setUser(String user) {
this.user = user;
}
+ /**
+ * Gets the password.
+ *
+ * @return the password
+ */
public String getPassword() {
return password;
}
+ /**
+ * Sets the password.
+ *
+ * @param password
+ * the new password
+ */
public void setPassword(String password) {
this.password = password;
}
+ /**
+ * Gets the element list.
+ *
+ * @return the element list
+ */
public ElementList getElementList() {
return elementList;
}
+ /**
+ * Gets the window title.
+ *
+ * @return the window title
+ */
public String getWindowTitle() {
return "Login";
}
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserEdit.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -40,36 +40,55 @@
import fr.cemagref.simexplorer.is.ui.web.services.GroupValueEncoder;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService;
+/**
+ * The Class UserEdit.
+ */
public class UserEdit extends AdminPage {
+ /** The user. */
@Persist
private User user;
+ /** The user list. */
@InjectPage
private UserList userList;
+ /** The groups of user. */
@Persist
private List<Group> groupsOfUser;
+ /** The group encoder. */
@Persist
private GroupValueEncoder groupEncoder;
+ /** The group model. */
@Retain
private BeanModel groupModel;
+ /** The bean model source. */
@Inject
private BeanModelSource beanModelSource;
+ /** The resources. */
@Inject
private ComponentResources resources;
+ /** The _group. */
+ @SuppressWarnings("unused")
@SetterGetter
private Group _group;
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
return "";
}
+ /**
+ * Page loaded.
+ */
void pageLoaded() {
groupModel = beanModelSource.create(Group.class, true, resources);
List<String> wantedProperties = new ArrayList<String>();
@@ -82,6 +101,12 @@
}
}
+ /**
+ * Sets the up.
+ *
+ * @param userId
+ * the new up
+ */
void setup(int userId) {
this.groupsOfUser = new ArrayList<Group>();
if (userId == -1) {
@@ -102,6 +127,11 @@
groupEncoder = new GroupValueEncoder(getToken());
}
+ /**
+ * On success.
+ *
+ * @return the object
+ */
public Object onSuccess() {
try {
if (user.getId() == null) {
@@ -127,6 +157,11 @@
return userList;
}
+ /**
+ * Gets the groups.
+ *
+ * @return the groups
+ */
public List<Group> getGroups() {
Group[] groups;
try {
@@ -140,51 +175,102 @@
return result;
}
+ /**
+ * Gets the owned groups.
+ *
+ * @return the owned groups
+ */
public Group[] getOwnedGroups() {
try {
if (user.getId() == null) {
return new Group[0];
- } else {
- return RemoteSecurityService.getAuthentificationService()
- .getGroupsOwnedBy(getToken(), user);
}
+ return RemoteSecurityService.getAuthentificationService()
+ .getGroupsOwnedBy(getToken(), user);
} catch (SimExplorerServiceException e) {
throw new SimExplorerWebException(e);
}
}
- public ValueEncoder getGroupEncoder() {
+ /**
+ * Gets the group encoder.
+ *
+ * @return the group encoder
+ */
+ public ValueEncoder<Group> getGroupEncoder() {
return groupEncoder;
}
+ /**
+ * Gets the creating.
+ *
+ * @return the creating
+ */
public boolean getCreating() {
return (user.getId() == null);
}
+ /**
+ * On action from cancel.
+ *
+ * @return the object
+ */
public Object onActionFromCancel() {
return userList;
}
+ /**
+ * Gets the user list.
+ *
+ * @return the user list
+ */
public UserList getUserList() {
return userList;
}
+ /**
+ * Sets the user list.
+ *
+ * @param userList
+ * the new user list
+ */
public void setUserList(UserList userList) {
this.userList = userList;
}
+ /**
+ * Gets the user.
+ *
+ * @return the user
+ */
public User getUser() {
return user;
}
+ /**
+ * Gets the groups of user.
+ *
+ * @return the groups of user
+ */
public List<Group> getGroupsOfUser() {
return groupsOfUser;
}
+ /**
+ * Sets the groups of user.
+ *
+ * @param groupsOfUser
+ * the new groups of user
+ */
public void setGroupsOfUser(List<Group> groupsOfUser) {
this.groupsOfUser = groupsOfUser;
}
+ /**
+ * Gets the group model.
+ *
+ * @return the group model
+ */
public BeanModel getGroupModel() {
return groupModel;
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserList.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserList.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/UserList.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -35,27 +35,43 @@
import fr.cemagref.simexplorer.is.ui.web.pages.security.AdminPage;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService;
+/**
+ * The Class UserList.
+ */
public class UserList extends AdminPage {
+ /** The model. */
@Retain
private BeanModel model;
+ /** The _user. */
+ @SuppressWarnings("unused")
@SetterGetter
private User _user;
+ /** The bean model source. */
@Inject
private BeanModelSource beanModelSource;
+ /** The resources. */
@Inject
private ComponentResources resources;
+ /** The user edit. */
@InjectPage
private UserEdit userEdit;
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle()
+ */
+ @Override
public String getWindowTitle() {
return "";
}
+ /**
+ * Page loaded.
+ */
void pageLoaded() {
model = beanModelSource.create(User.class, true, resources);
List<String> wantedProperties = new ArrayList<String>();
@@ -74,6 +90,11 @@
model.add("delete", null);
}
+ /**
+ * Gets the users.
+ *
+ * @return the users
+ */
public User[] getUsers() {
User[] users;
try {
@@ -86,6 +107,14 @@
return users;
}
+ /**
+ * On action from delete.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onActionFromDelete(Integer context) {
try {
RemoteSecurityService.getAuthentificationService().deleteUser(
@@ -96,24 +125,53 @@
return null;
}
+ /**
+ * On action from edit.
+ *
+ * @param context
+ * the context
+ *
+ * @return the object
+ */
public Object onActionFromEdit(Integer context) {
userEdit.setup(context);
return userEdit;
}
+ /**
+ * On action from add.
+ *
+ * @return the object
+ */
public Object onActionFromAdd() {
userEdit.setup(-1);
return userEdit;
}
+ /**
+ * Gets the user edit.
+ *
+ * @return the user edit
+ */
public UserEdit getUserEdit() {
return userEdit;
}
+ /**
+ * Sets the user edit.
+ *
+ * @param userEdit
+ * the new user edit
+ */
public void setUserEdit(UserEdit userEdit) {
this.userEdit = userEdit;
}
+ /**
+ * Gets the model.
+ *
+ * @return the model
+ */
public BeanModel getModel() {
return model;
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/AdminPage.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/AdminPage.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/AdminPage.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -17,11 +17,17 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.web.pages.security;
+/**
+ * The Class AdminPage.
+ */
public abstract class AdminPage extends ProtectedPage {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#hasAccessToPage()
+ */
@Override
public boolean hasAccessToPage() {
return isUserAdmin();
}
-
+
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -25,23 +25,36 @@
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
import fr.cemagref.simexplorer.is.ui.web.services.RemoteSecurityService;
+/**
+ * The Class ProtectedPage.
+ */
public abstract class ProtectedPage {
+ /** The token. */
@ApplicationState
private String token;
+ /** The user. */
@Persist
private User user;
+ /** The user logged. */
@Persist
private boolean userLogged;
+ /** The user admin. */
@Persist
private boolean userAdmin;
+ /** The user super admin. */
@Persist
private boolean userSuperAdmin;
+ /**
+ * On activate.
+ *
+ * @return the object
+ */
Object onActivate() {
getUserRights();
if (!userLogged)
@@ -51,6 +64,10 @@
return null;
}
+ /**
+ * Gets the user rights.
+ *
+ */
private void getUserRights() {
user = computeUserLogged();
if (user != null) {
@@ -64,10 +81,20 @@
}
}
+ /**
+ * Gets the token.
+ *
+ * @return the token
+ */
public String getToken() {
return token;
}
+ /**
+ * Compute user logged.
+ *
+ * @return the user
+ */
private User computeUserLogged() {
User loggedUser = null;
if (token != null) {
@@ -81,22 +108,52 @@
return loggedUser;
}
+ /**
+ * Checks for access to page.
+ *
+ * @return true, if successful
+ */
abstract boolean hasAccessToPage();
+ /**
+ * Gets the window title.
+ *
+ * @return the window title
+ */
public abstract String getWindowTitle();
+ /**
+ * Gets the user logged.
+ *
+ * @return the user logged
+ */
public User getUserLogged() {
return user;
}
+ /**
+ * Checks if is user logged.
+ *
+ * @return true, if is user logged
+ */
public boolean isUserLogged() {
return userLogged;
}
+ /**
+ * Checks if is user admin.
+ *
+ * @return true, if is user admin
+ */
public boolean isUserAdmin() {
return userAdmin;
}
+ /**
+ * Checks if is user super admin.
+ *
+ * @return true, if is user super admin
+ */
public boolean isUserSuperAdmin() {
return userSuperAdmin;
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/SuperAdminPage.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/SuperAdminPage.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/SuperAdminPage.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -17,8 +17,14 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.web.pages.security;
+/**
+ * The Class SuperAdminPage.
+ */
public abstract class SuperAdminPage extends ProtectedPage {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#hasAccessToPage()
+ */
@Override
public boolean hasAccessToPage() {
return isUserSuperAdmin();
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/UserPage.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/UserPage.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/UserPage.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -17,8 +17,14 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.web.pages.security;
+/**
+ * The Class UserPage.
+ */
public abstract class UserPage extends ProtectedPage {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#hasAccessToPage()
+ */
@Override
public boolean hasAccessToPage() {
return isUserLogged();
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/AppModule.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/AppModule.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/AppModule.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -19,7 +19,6 @@
import java.io.IOException;
-import org.apache.tapestry.internal.services.GenericValueEncoderFactory;
import org.apache.tapestry.ioc.MappedConfiguration;
import org.apache.tapestry.ioc.OrderedConfiguration;
import org.apache.tapestry.ioc.ServiceBinder;
@@ -31,10 +30,17 @@
import org.apache.tapestry.services.ValueEncoderFactory;
import org.slf4j.Logger;
-import fr.cemagref.simexplorer.is.security.entities.Group;
-import fr.cemagref.simexplorer.is.security.entities.User;
+/**
+ * The Class AppModule.
+ */
+public class AppModule {
-public class AppModule {
+ /**
+ * Bind.
+ *
+ * @param binder
+ * the binder
+ */
public static void bind(ServiceBinder binder) {
/*
binder.bind(RemoteStorageService.class, RemoteStorageServiceImpl.class);
@@ -47,12 +53,25 @@
// invoking the constructor.
}
+ /**
+ * Contribute application defaults.
+ *
+ * @param configuration
+ * the configuration
+ */
public static void contributeApplicationDefaults(
MappedConfiguration<String, String> configuration) {
configuration.add("tapestry.supported-locales", "en");
configuration.add("tapestry.supported-locales", "fr");
}
+ /**
+ * Contribute value encoder source.
+ *
+ * @param configuration
+ * the configuration
+ */
+ @SuppressWarnings("unchecked")
public static void contributeValueEncoderSource(
MappedConfiguration<Class, ValueEncoderFactory> configuration) {
/*
@@ -81,6 +100,11 @@
* the service interface and would be "RequestFilter". Since Tapestry
* already defines a service named "RequestFilter" we use an explicit
* service id that we can reference inside the contribution method.
+ *
+ * @param log
+ * the log
+ *
+ * @return the request filter
*/
public RequestFilter buildTimingFilter(final Logger log) {
return new RequestFilter() {
@@ -109,6 +133,11 @@
* This is a contribution to the RequestHandler service configuration. This
* is how we extend Tapestry using the timing filter. A common use for this
* kind of filter is transaction management or security.
+ *
+ * @param configuration
+ * the configuration
+ * @param filter
+ * the filter
*/
public void contributeRequestHandler(
OrderedConfiguration<RequestFilter> configuration,
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/GroupValueEncoder.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/GroupValueEncoder.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/GroupValueEncoder.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -23,19 +23,35 @@
import fr.cemagref.simexplorer.is.service.SimExplorerServiceException;
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
+/**
+ * The Class GroupValueEncoder.
+ */
public class GroupValueEncoder implements ValueEncoder<Group> {
+ /** The token. */
private String token;
+ /**
+ * Instantiates a new group value encoder.
+ *
+ * @param token
+ * the token
+ */
public GroupValueEncoder(String token) {
super();
this.token = token;
}
+ /* (non-Javadoc)
+ * @see org.apache.tapestry.ValueEncoder#toClient(java.lang.Object)
+ */
public String toClient(Group arg0) {
return Integer.toString(arg0.getId());
}
+ /* (non-Javadoc)
+ * @see org.apache.tapestry.ValueEncoder#toValue(java.lang.String)
+ */
public Group toValue(String arg0) {
Group group = null;
try {
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteSecurityService.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteSecurityService.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteSecurityService.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -19,8 +19,16 @@
import fr.cemagref.simexplorer.is.service.AuthenticationService;
+/**
+ * The Class RemoteSecurityService.
+ */
public class RemoteSecurityService extends RemoteService {
+ /**
+ * Gets the authentification service.
+ *
+ * @return the authentification service
+ */
public static AuthenticationService getAuthentificationService() {
return (AuthenticationService) getService("AuthenticationService");
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteService.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -27,10 +27,22 @@
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
+/**
+ * The Class RemoteService.
+ */
public abstract class RemoteService {
+ /** The services. */
protected static Map<String, Object> services = new HashMap<String, Object>();
+ /**
+ * Gets the service.
+ *
+ * @param serviceName
+ * the service name
+ *
+ * @return the service
+ */
protected static Object getService(String serviceName) {
Object service = null;
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteStorageService.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteStorageService.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/RemoteStorageService.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -19,9 +19,17 @@
import fr.cemagref.simexplorer.is.service.StorageService;
+/**
+ * The Class RemoteStorageService.
+ */
public class RemoteStorageService extends RemoteService {
+ /**
+ * Gets the storage service.
+ *
+ * @return the storage service
+ */
public static StorageService getStorageService() {
return (StorageService) getService("StorageService");
- }
+ }
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/UserValueEncoder.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/UserValueEncoder.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/UserValueEncoder.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -23,19 +23,35 @@
import fr.cemagref.simexplorer.is.service.SimExplorerServiceException;
import fr.cemagref.simexplorer.is.ui.web.SimExplorerWebException;
+/**
+ * The Class UserValueEncoder.
+ */
public class UserValueEncoder implements ValueEncoder<User> {
+ /** The token. */
private String token;
+ /**
+ * Instantiates a new user value encoder.
+ *
+ * @param token
+ * the token
+ */
public UserValueEncoder(String token) {
super();
this.token = token;
}
+ /* (non-Javadoc)
+ * @see org.apache.tapestry.ValueEncoder#toClient(java.lang.Object)
+ */
public String toClient(User arg0) {
return Integer.toString(arg0.getId());
}
+ /* (non-Javadoc)
+ * @see org.apache.tapestry.ValueEncoder#toValue(java.lang.String)
+ */
public User toValue(String arg0) {
User user = null;
try {
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/AttachmentStreamResponse.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/AttachmentStreamResponse.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/AttachmentStreamResponse.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -17,34 +17,58 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.web.tools;
-import java.io.IOException;
import java.io.InputStream;
import org.apache.tapestry.StreamResponse;
import org.apache.tapestry.services.Response;
+/**
+ * The Class AttachmentStreamResponse.
+ */
public class AttachmentStreamResponse implements StreamResponse {
+
+ /** The is. */
private InputStream is = null;
+ /** The content type. */
protected String contentType = "application/octet-stream";
+ /** The extension. */
protected String extension = null;
+ /** The filename. */
protected String filename = null;
+ /**
+ * Instantiates a new attachment stream response.
+ *
+ * @param is
+ * the is
+ * @param filenameIn
+ * the filename in
+ */
public AttachmentStreamResponse(InputStream is, String filenameIn) {
this.is = is;
this.filename = filenameIn;
}
+ /* (non-Javadoc)
+ * @see org.apache.tapestry.StreamResponse#getContentType()
+ */
public String getContentType() {
return contentType;
}
+ /* (non-Javadoc)
+ * @see org.apache.tapestry.StreamResponse#getStream()
+ */
public InputStream getStream() {
return is;
}
+ /* (non-Javadoc)
+ * @see org.apache.tapestry.StreamResponse#prepareResponse(org.apache.tapestry.services.Response)
+ */
public void prepareResponse(Response arg0) {
arg0.setHeader("Content-Disposition", "attachment; filename="
+ filename + ((extension == null) ? "" : ("." + extension)));
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-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/DownloadableFile.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -19,23 +19,51 @@
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
+/**
+ * The Class DownloadableFile.
+ */
public class DownloadableFile {
+ /** The meta data. */
private MetaData metaData;
+
+ /** The filename. */
private String filename;
+ /**
+ * Gets the filename.
+ *
+ * @return the filename
+ */
public String getFilename() {
return filename;
}
+ /**
+ * Sets the filename.
+ *
+ * @param filename
+ * the new filename
+ */
public void setFilename(String filename) {
this.filename = filename;
}
+ /**
+ * Gets the meta data entity.
+ *
+ * @return the meta data entity
+ */
public MetaData getMetaDataEntity() {
return metaData;
}
+ /**
+ * Sets the meta data entity.
+ *
+ * @param metaData
+ * the new meta data entity
+ */
public void setMetaDataEntity(MetaData metaData) {
this.metaData = metaData;
}
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/XMLAttachment.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/XMLAttachment.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/XMLAttachment.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -19,8 +19,19 @@
import java.io.InputStream;
+/**
+ * The Class XMLAttachment.
+ */
public class XMLAttachment extends AttachmentStreamResponse {
+ /**
+ * Instantiates a new XML attachment.
+ *
+ * @param is
+ * the is
+ * @param filenameIn
+ * the filename in
+ */
public XMLAttachment(InputStream is, String filenameIn) {
super(is, filenameIn);
this.contentType = "text/xml";
Modified: trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/ZipAttachment.java
===================================================================
--- trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/ZipAttachment.java 2008-02-04 15:13:55 UTC (rev 632)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/ZipAttachment.java 2008-02-04 15:17:29 UTC (rev 633)
@@ -19,8 +19,19 @@
import java.io.InputStream;
+/**
+ * The Class ZipAttachment.
+ */
public class ZipAttachment extends AttachmentStreamResponse {
+ /**
+ * Instantiates a new zip attachment.
+ *
+ * @param is
+ * the is
+ * @param filenameIn
+ * the filename in
+ */
public ZipAttachment(InputStream is, String filenameIn) {
super(is, filenameIn);
this.contentType = "application/zip";
1
0
Author: tchemit
Date: 2008-02-04 15:13:55 +0000 (Mon, 04 Feb 2008)
New Revision: 632
Removed:
trunk/simexplorer-is/.project
trunk/simexplorer-is/.project.ok
Log:
suppression fichiers sp?\195?\169cifiques ?\195?\160 Eclipse
Deleted: trunk/simexplorer-is/.project
===================================================================
--- trunk/simexplorer-is/.project 2008-02-04 14:49:55 UTC (rev 631)
+++ trunk/simexplorer-is/.project 2008-02-04 15:13:55 UTC (rev 632)
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>simexplorer-is</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
Deleted: trunk/simexplorer-is/.project.ok
===================================================================
--- trunk/simexplorer-is/.project.ok 2008-02-04 14:49:55 UTC (rev 631)
+++ trunk/simexplorer-is/.project.ok 2008-02-04 15:13:55 UTC (rev 632)
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>simexplorer-is</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
1
0
r631 - in trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing: action/application action/tab model
by tchemit@users.labs.libre-entreprise.org 04 Feb '08
by tchemit@users.labs.libre-entreprise.org 04 Feb '08
04 Feb '08
Author: tchemit
Date: 2008-02-04 14:49:55 +0000 (Mon, 04 Feb 2008)
New Revision: 631
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
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/ShowDetailTabAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/LoggableElementTreeHelper.java
Log:
d?\195?\169placement m?\195?\169thodes utilitaire sur node au bon endroit (LoggableElementtreeHelper)
refonte du model de d?\195?\169tail
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-02-04 14:49:05 UTC (rev 630)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DeleteAction.java 2008-02-04 14:49:55 UTC (rev 631)
@@ -21,7 +21,6 @@
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractTabAction;
-import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeHelper;
import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode;
import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationDetailTab;
@@ -69,7 +68,7 @@
tree = ui.getNavigationTree();
node = LoggableElementTreeHelper.getSelectedNodeOrRootNode(tree);
boolean result;
- result = ((DetailTabModel) getModel()).canDelete(node);
+ result = LoggableElementTreeHelper.canDelete(node);
if (result) {
// ask user confirmation of node to delete
element = (LoggableElement) node.getUserObject();
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-02-04 14:49:05 UTC (rev 630)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/DownloadAction.java 2008-02-04 14:49:55 UTC (rev 631)
@@ -78,7 +78,7 @@
tree = ui.getNavigationTree();
node = LoggableElementTreeHelper.getSelectedNodeOrRootNode(tree);
boolean result;
- result = ((DetailTabModel) getModel()).canDownload(node);
+ result = LoggableElementTreeHelper.canDownload(node);
if (result) {
// ask user path where to save data
String dir = org.codelutin.util.FileUtil.getDirectory();
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-02-04 14:49:05 UTC (rev 630)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ExportApplicationAction.java 2008-02-04 14:49:55 UTC (rev 631)
@@ -69,7 +69,7 @@
tree = ui.getNavigationTree();
node = LoggableElementTreeHelper.getSelectedNodeOrRootNode(tree);
boolean result;
- result = ((DetailTabModel) getModel()).canExport(node);
+ result = LoggableElementTreeHelper.canExport(node);
if (result) {
element = (LoggableElement) node.getUserObject();
uuid = element.getMetaData().getUuid();
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-02-04 14:49:05 UTC (rev 630)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/ResetSearchApplicationAction.java 2008-02-04 14:49:55 UTC (rev 631)
@@ -22,6 +22,7 @@
import fr.cemagref.simexplorer.is.ui.swing.model.JApplicationTableModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationListTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper;
import javax.swing.JTable;
import java.awt.event.ActionEvent;
@@ -45,7 +46,6 @@
private static final long serialVersionUID = -155773498930710467L;
-
public ResetSearchApplicationAction(String name) {
super(name);
}
@@ -58,8 +58,8 @@
ui.getSearchText().setText(null);
if (!model.hasQuery()) {
// directly refresh search actions
- // but do not realised action
- getMainUI().refreshSearchActions(ui,model);
+ // but do not realize action
+ SimExplorerUIRefreshHelper.refreshSearchActions(ui,model);
return false;
}
// only reset search if something was previously search
@@ -87,7 +87,7 @@
modelTab.setData(model.getList());
// refresh ui
- getMainUI().refreshListTabUI(model, container);
+ SimExplorerUIRefreshHelper.refreshListTabUI(container, model);
}
@Override
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-02-04 14:49:05 UTC (rev 630)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/application/SearchApplicationAction.java 2008-02-04 14:49:55 UTC (rev 631)
@@ -22,6 +22,7 @@
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.JApplicationTableModel;
import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationListTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper;
import javax.swing.JTextField;
import javax.swing.JTable;
@@ -78,7 +79,7 @@
modelTab.setData(model.getList());
// refresh ui
- getMainUI().refreshListTabUI(model, container);
+ SimExplorerUIRefreshHelper.refreshListTabUI(container, model);
}
@Override
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowDetailTabAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowDetailTabAction.java 2008-02-04 14:49:05 UTC (rev 630)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowDetailTabAction.java 2008-02-04 14:49:55 UTC (rev 631)
@@ -23,24 +23,23 @@
import fr.cemagref.simexplorer.is.service.SimExplorerServiceException;
import fr.cemagref.simexplorer.is.service.StorageService;
import fr.cemagref.simexplorer.is.ui.SimExplorerRuntimeException;
-import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper;
import fr.cemagref.simexplorer.is.ui.swing.action.ShowTabAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeHelper;
import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode;
import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationDetailTab;
-import static org.codelutin.i18n.I18n._;
import javax.swing.DefaultListModel;
import javax.swing.JTree;
+import javax.swing.ListModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
-import java.awt.event.ActionEvent;
/**
* Action pour afficher le tab de détail d'un LoggableElement
@@ -64,35 +63,25 @@
super(name);
}
- @Override
+ /*@Override
protected boolean beforeAction(ActionEvent e) throws Exception {
super.beforeAction(e);
- ListTabModel listModel;
DetailTabModel model = getTabModel();
- if (model.isRemote()) {
- listModel = (ListTabModel) SimExplorerTab.remote.getModel();
- } else {
- listModel = (ListTabModel) SimExplorerTab.local.getModel();
- }
-
- MetaData data = listModel.get(model.getIndex());
+ LoggableElement bean = model.getRootNode();
+ MetaData data = bean.getMetaData();
String uuid = data.getUuid();
Version version = data.getVersion();
log.info("show detail uuid:" + uuid + ", version:" + version + " (remote ?" + model.isRemote() + ")");
- // chargement de l'élément à partir du service
- LoggableElement element = StorageServiceHelper.getElement(getContext(), model.isRemote(), uuid, version.toString());
- // push dans le model
- model.setBean(element);
return true;
- }
+ } */
protected void initFirstUsage(final JApplicationDetailTab ui, final DetailTabModel model) {
-
+ //TODO cela peut être fait dans jaxx
ui.getNavigationTree().setModel(new DefaultTreeModel(null));
-
+ //TODO cela peut être fait dans jaxx
ui.getHistoryList().setModel(new DefaultListModel());
- // add a listener of tree model
+ // add a listener on navigation tree
ui.getNavigationTree().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
TreePath path = e.getNewLeadSelectionPath();
@@ -103,25 +92,41 @@
StorageService service = getContext().getStorageService(model.isRemote());
String token = getContext().getToken();
- // update download button
- refreshDownloadAction(ui, node, model);
- // update delete button
- refreshDeleteAction(ui, node, model);
- // update export button
- refreshExportAction(ui, node, model);
+ // update actions
+ SimExplorerUIRefreshHelper.refreshDetailActions(ui, model, node);
+
+ model.setSelectedNode((LoggableElement) (node == null ? null : node.getUserObject()));
+
// update detail panel
- refreshDetail(ui, node, model, service, token);
+ //updateDetail(ui, model, node, service, token);
+
// update history list
- refreshHistory(ui, node, model, service, token);
+ updateHistoryList(ui, model, node, service, token);
+
// refresh ui
- getMainUI().refreshDetailTabUI(ui, model);
+ SimExplorerUIRefreshHelper.refreshDetailTabUI(ui, model);
}
});
+
+ // add a listener on history list
+ ui.getHistoryList().addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ int index = e.getLastIndex();
+ //int lastIndex = e.getLastIndex();
+ log.info("last index : " + index);
+ ListModel listModel = ui.getHistoryList().getModel();
+ if (index > -1 && listModel.getSize() > index && ui.getHistoryList().getSelectedIndex() != index) {
+ Object selectedVersion = listModel.getElementAt(index);
+ log.info("selected version " + selectedVersion);
+ //TODO load details for this version
+ }
+ }
+ });
}
protected void initUI(JApplicationDetailTab ui, DetailTabModel model) {
// création de l'arbre de navigation
- TreeNode root = LoggableElementTreeHelper.buildLoggableElementNode(model.getBean());
+ TreeNode root = LoggableElementTreeHelper.buildLoggableElementNode(model.getRootNode());
// push tree model
JTree tree = ui.getNavigationTree();
DefaultTreeModel modelTree = (DefaultTreeModel) tree.getModel();
@@ -129,45 +134,15 @@
// by default select the root node (to display info about the exploration)
tree.setSelectionRow(0);
// refresh ui
- getMainUI().refreshDetailTabUI(ui, model);
+ SimExplorerUIRefreshHelper.refreshDetailTabUI(ui, model);
}
- protected static void refreshExportAction(JApplicationDetailTab ui, LoggableElementTreeNode node, DetailTabModel model) {
- boolean export = model.canExport(node);
- ui.getExportApplication().setEnabled(export);
- if (export) {
- ui.getExportApplication().setToolTipText(_("simexplorer.action.export2", node.getUserObject()));
- } else {
- ui.getExportApplication().setToolTipText(null);
- }
- }
-
- protected static void refreshDeleteAction(JApplicationDetailTab ui, LoggableElementTreeNode node, DetailTabModel model) {
- boolean delete = model.canDelete(node);
- ui.getDelete().setEnabled(delete);
- if (delete) {
- ui.getDelete().setToolTipText(_("simexplorer.action.delete2", node.getUserObject()));
- } else {
- ui.getDelete().setToolTipText(null);
- }
- }
-
- protected static void refreshDownloadAction(JApplicationDetailTab ui, LoggableElementTreeNode node, DetailTabModel model) {
- boolean download = model.canDownload(node);
- ui.getDownload().setEnabled(download);
- if (download) {
- ui.getDownload().setToolTipText(_("simexplorer.action.dowload2", node.getUserObject()));
- } else {
- ui.getDownload().setToolTipText(null);
- }
- }
-
- protected static void refreshDetail(JApplicationDetailTab ui, LoggableElementTreeNode node, DetailTabModel model, StorageService service, String token) {
- boolean detail = model.isLoggableElement(node);
+ public static void updateDetail(JApplicationDetailTab ui, DetailTabModel model, LoggableElementTreeNode node, StorageService service, String token) {
+ boolean detail = LoggableElementTreeHelper.isLoggableElement(node);
String text;
if (detail) {
LoggableElement element = (LoggableElement) node.getUserObject();
- model.setBean(element);
+ model.setSelectedNode(element);
text = "detail [" + node.getUserObject().getClass().getSimpleName() + "]" + element;
} else {
text = "No detail";
@@ -175,23 +150,25 @@
ui.getDetailFake().setText(text);
}
- protected static void refreshHistory(JApplicationDetailTab ui, LoggableElementTreeNode node, DetailTabModel model, StorageService service, String token) {
- boolean history = model.isLoggableElement(node);
+ public static void updateHistoryList(JApplicationDetailTab ui, DetailTabModel model, LoggableElementTreeNode node, StorageService service, String token) {
+ //boolean history = LoggableElementTreeHelper.isLoggableElement(node);
+ LoggableElement element = model.getSelectedNode();
+ boolean history = element !=null;
if (!history) {
model.setVersions(null);
+ model.setSelectedVersion(null);
return;
- }
- //TODO should use model.getBean() ???
- LoggableElement element = (LoggableElement) node.getUserObject();
+ }
+ //LoggableElement element = (LoggableElement) node.getUserObject();
try {
- MetaData[] metas;
- metas = service.getVersions(token, element.getMetaData().getUuid());
+ MetaData[] metas = service.getVersions(token, element.getMetaData().getUuid());
Version[] versions = new Version[metas.length];
for (int i = 0; i < metas.length; i++) {
MetaData meta = metas[i];
versions[i] = meta.getVersion();
}
model.setVersions(versions);
+ model.setSelectedVersion(element.getMetaData().getVersion());
} catch (SimExplorerServiceException e) {
throw new SimExplorerRuntimeException(e);
}
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java 2008-02-04 14:49:05 UTC (rev 630)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/tab/ShowListTabAbstractAction.java 2008-02-04 14:49:55 UTC (rev 631)
@@ -18,9 +18,14 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.action.tab;
+import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
+import fr.cemagref.simexplorer.is.entities.metadata.Version;
+import fr.cemagref.simexplorer.is.ui.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper;
import fr.cemagref.simexplorer.is.ui.swing.action.ShowTabAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.JApplicationTableModel;
@@ -31,7 +36,6 @@
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.JTabbedPane;
-import javax.swing.JTable;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
@@ -43,6 +47,7 @@
public class ShowListTabAbstractAction extends ShowTabAbstractAction<JApplicationListTab, ListTabModel> {
private static final long serialVersionUID = 3813479850648257169L;
+ /** flag pour indiquer si la liste est locale ou remote */
protected boolean remote;
public ShowListTabAbstractAction(String name, boolean remote) {
@@ -62,9 +67,6 @@
return false;
}
- // mark it, after action will push table model
- firstTime = ui == null;
-
ListTabModel model = (ListTabModel) getModel();
MetaData[] data = model.getList();
@@ -79,34 +81,54 @@
protected void initFirstUsage(final JApplicationListTab ui, final ListTabModel model) {
// add a show detail action when double click on a row of the table
ui.getTable().addMouseListener(new MouseAdapter() {
+
+ /** l'action d'affichage de l'onglet de détail */
AbstractAction detailAction = SimExplorerActionManager.newAction("showTab_detail", (AbstractButton) null);
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
- JTable table = (JTable) e.getSource();
- int selectRow = table.getSelectedRow();
- DetailTabModel model = (DetailTabModel) SimExplorerTab.detail.getModel();
- model.setRemote(remote);
- model.setIndex(selectRow);
- detailAction.actionPerformed(new ActionEvent(table, ActionEvent.ACTION_FIRST, "showTab_detail"));
- System.out.println("action detail ("+remote+")" + selectRow + " : " + table.getValueAt(selectRow, 0));
+ // récupération du metadata à afficher
+ MetaData data = model.get(ui.getTable().getSelectedRow());
+ // récupération de l'uuid à afficher
+ String uuid = data.getUuid();
+ // récupération de la version à afficher
+ Version version = data.getVersion();
+ try {
+ // chargement de l'élément à partir du service
+ LoggableElement element = StorageServiceHelper.getElement(getContext(), remote, uuid, version.toString());
+ // préparation du modèle de détail
+ DetailTabModel detailModel = (DetailTabModel) SimExplorerTab.detail.getModel();
+ // on supprime les anciennes données du modèle
+ detailModel.reset();
+ // positionnement du type de détail (local ou remote)
+ detailModel.setRemote(remote);
+ // positionnement du rootNode du modèle
+ detailModel.setRootNode(element);
+ log.info("prepare detail - uuid:" + uuid + ", version:" + version + " (remote ?" + remote + ")");
+ // lancement de l'action d'affichage du tab
+ detailAction.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_FIRST, "showTab_detail"));
+ } catch (Exception e1) {
+ throw new SimExplorerRuntimeException(e1);
+ }
}
}
});
- // push model into tableModel
- JApplicationTableModel modelTab = (JApplicationTableModel) ui.getTable().getModel();
- modelTab.setData(model.getList());
// add search actions listeners
+
ui.getSearchText().addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
- getMainUI().refreshSearchActions(ui, model);
+ SimExplorerUIRefreshHelper.refreshSearchActions(ui, model);
}
});
+ //TODO Est-ce vraiment le bon endroit pour faire ça ?
+ // push model into tableModel
+ JApplicationTableModel modelTab = (JApplicationTableModel) ui.getTable().getModel();
+ modelTab.setData(model.getList());
}
protected void initUI(JApplicationListTab ui, ListTabModel model) {
- getMainUI().refreshListTabUI(model, ui);
+ SimExplorerUIRefreshHelper.refreshListTabUI(ui, model);
}
}
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java 2008-02-04 14:49:05 UTC (rev 630)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java 2008-02-04 14:49:55 UTC (rev 631)
@@ -34,79 +34,84 @@
private static final long serialVersionUID = 4851121531481734868L;
- /** l'uuid de l'élément que l'on veut récupérer */
- protected String uuid;
/** flag pour savoir si on est dans le cas local ou remote */
protected boolean remote;
- /** l'index de l'élément recherché à partir de la liste */
- protected int index;
- /** l'élément dont on veut afficher le détail */
- protected LoggableElement bean;
- /** la liste des versions disponibles pour un élément */
+
+ /** le LoggableElement root de l'arbre de navigation */
+ protected LoggableElement rootNode;
+
+ /**
+ * le LoggableElement sélectionné dans l'arbre de navigation (ou null
+ * si le node sélectioné n'est pas un LoggableElement)
+ */
+ protected LoggableElement selectedNode;
+
+ /**
+ * la liste des versions disponibles pour le LoggableElement sélectionné
+ * dans l'arbre (ou null si pas de LoggableElement sélectionné dans l'arbre
+ * de navigation)
+ */
protected Version[] versions;
+ /**
+ * la version sélectionnée dans la liste des versions (ou null si la liste
+ * des versions est nulle)
+ */
+ protected Version selectedVersion;
+
+
public String getName() {
return tab.name();
}
- public SimExplorerTab getTab() {
- return tab;
+ public boolean isRemote() {
+ return remote;
}
- public LoggableElement getBean() {
- return bean;
+ public LoggableElement getRootNode() {
+ return rootNode;
}
- public boolean isRemote() {
- return remote;
+ public LoggableElement getSelectedNode() {
+ return selectedNode;
}
- public int getIndex() {
- return index;
+ public Version getSelectedVersion() {
+ return selectedVersion;
}
- public String getUuid() {
- return uuid;
- }
-
public Version[] getVersions() {
return versions;
}
- public boolean isLoggableElement(LoggableElementTreeNode node) {
- return node != null && node.isLoggableElement();
+ public void setRemote(boolean remote) {
+ this.remote = remote;
}
- public boolean canExport(LoggableElementTreeNode node) {
- return node != null && node.isRoot();
+ public void setName(String name) {
+ this.tab = SimExplorerTab.valueOf(name);
}
- public boolean canDelete(LoggableElementTreeNode node) {
- return node != null && node.isLoggableElement();
+ public void setRootNode(LoggableElement rootNode) {
+ this.rootNode = rootNode;
}
- public boolean canDownload(LoggableElementTreeNode node) {
- return node != null && node.isDownloadableElement();
+ public void setSelectedNode(LoggableElement selectedNode) {
+ this.selectedNode = selectedNode;
}
- public void setRemote(boolean remote) {
- this.remote = remote;
+ public void setSelectedVersion(Version selectedVersion) {
+ this.selectedVersion = selectedVersion;
}
- public void setIndex(int index) {
- this.index = index;
- }
-
- public void setName(String name) {
- this.tab = SimExplorerTab.valueOf(name);
- }
-
- public void setBean(LoggableElement bean) {
- this.bean = bean;
- }
-
public void setVersions(Version[] versions) {
this.versions = versions;
}
+ public void reset() {
+ rootNode = null;
+ selectedNode = null;
+ versions = null;
+ selectedVersion = null;
+ }
}
\ No newline at end of file
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/LoggableElementTreeHelper.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/LoggableElementTreeHelper.java 2008-02-04 14:49:05 UTC (rev 630)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/LoggableElementTreeHelper.java 2008-02-04 14:49:55 UTC (rev 631)
@@ -1,5 +1,5 @@
/*
-* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
* Tony Chemit, Gabriel Landais
*
* This program is free software; you can redistribute it and/or
@@ -15,7 +15,7 @@
* 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.swing.model;
import fr.cemagref.simexplorer.is.entities.data.Code;
@@ -42,6 +42,25 @@
* @see LoggableElementTreeNode
*/
public class LoggableElementTreeHelper {
+
+ public enum TypeNode {
+ explorationApplication(ExplorationApplication.class),
+ explorationData(ExplorationData.class),
+ component(Component.class),
+ result(Result.class),
+ library(Library.class);
+
+ private Class<?> klass;
+
+ TypeNode(Class<?> aClass) {
+ this.klass = aClass;
+ }
+
+ public Class<?> getKlass() {
+ return klass;
+ }
+ }
+
public static LoggableElementTreeNode getSelectedNodeOrRootNode(JTree tree) {
TreePath path = tree.getSelectionPath();
LoggableElementTreeNode node = null;
@@ -63,22 +82,20 @@
return node;
}
- public enum TypeNode {
- explorationApplication(ExplorationApplication.class),
- explorationData(ExplorationData.class),
- component(Component.class),
- result(Result.class),
- library(Library.class);
+ public static boolean isLoggableElement(LoggableElementTreeNode node) {
+ return node != null && node.isLoggableElement();
+ }
- private Class<?> klass;
+ public static boolean canExport(LoggableElementTreeNode node) {
+ return node != null && node.isRoot();
+ }
- TypeNode(Class<?> aClass) {
- this.klass = aClass;
- }
+ public static boolean canDelete(LoggableElementTreeNode node) {
+ return node != null && node.isLoggableElement();
+ }
- public Class<?> getKlass() {
- return klass;
- }
+ public static boolean canDownload(LoggableElementTreeNode node) {
+ return node != null && node.isDownloadableElement();
}
public static TypeNode getTypeNode(LoggableElementTreeNode node) {
1
0
r630 - in trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui: . swing swing/action/auth swing/action/pagination
by tchemit@users.labs.libre-entreprise.org 04 Feb '08
by tchemit@users.labs.libre-entreprise.org 04 Feb '08
04 Feb '08
Author: tchemit
Date: 2008-02-04 14:49:05 +0000 (Mon, 04 Feb 2008)
New Revision: 630
Modified:
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java
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/auth/ConnectAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/auth/UnconnectAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/pagination/ChangePageAction.java
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/pagination/ChangeSizorAction.java
Log:
utilisation SimExplorerUIRefreshHelper
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java 2008-02-04 14:47:45 UTC (rev 629)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java 2008-02-04 14:49:05 UTC (rev 630)
@@ -22,6 +22,7 @@
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerMainUI;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper;
import org.codelutin.i18n.I18n;
import org.codelutin.option.ui.ConfigTableModel;
@@ -115,7 +116,7 @@
boolean isConnected = context.isConnected();
// refresh ui accessibles actions
- mainUI.refreshConnnectState(isConnected);
+ SimExplorerUIRefreshHelper.refreshConnnectState(mainUI,isConnected);
if (isConnected) {
if (conf.isShowRemoteTab()) {
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-02-04 14:47:45 UTC (rev 629)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerMainUI.java 2008-02-04 14:49:05 UTC (rev 630)
@@ -18,25 +18,12 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing;
-import fr.cemagref.simexplorer.is.entities.metadata.Version;
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
-import fr.cemagref.simexplorer.is.ui.swing.action.ChangeI18nAbstractAction;
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.PaginationModel;
-import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationDetailTab;
import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationListTab;
-import org.codelutin.i18n.CountryEnum;
-import org.codelutin.i18n.LanguageEnum;
-import javax.swing.AbstractButton;
-import javax.swing.DefaultListModel;
-import javax.swing.JComboBox;
-import javax.swing.JList;
import javax.swing.JTabbedPane;
-import javax.swing.JTree;
import javax.swing.SwingUtilities;
-import java.util.regex.Matcher;
/**
* L'ui principale de l'application
@@ -52,169 +39,7 @@
SimExplorerActionManager.loadActions(this, null);
// repaint i18n actions
- refreshI18nActions();
+ SimExplorerUIRefreshHelper.refreshI18nActions(this);
}
- public void refreshI18nActions() {
- LanguageEnum language = SimExplorer.getContext().getConfig().getLanguage();
- CountryEnum country = SimExplorer.getContext().getConfig().getCountry();
- String[] actions = SimExplorerActionManager.getFactory().getActionNames();
- for (String actionName : actions) {
- Matcher matcher = ChangeI18nAbstractAction.PATTERN_NAME.matcher(actionName);
- if (!matcher.matches()) {
- continue;
- }
- AbstractButton button = (AbstractButton) getObjectById(actionName);
- ChangeI18nAbstractAction action = (ChangeI18nAbstractAction) button.getAction();
- boolean enable = !action.equalsLocale(language, country);
- button.setEnabled(enable);
- }
- }
-
- public void refreshDetailTabUI(final JApplicationDetailTab ui, final DetailTabModel model) {
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- JTree tree = ui.getNavigationTree();
-
- // tree data model may have changed, must revalidate
- tree.invalidate();
-
- JList historyList = ui.getHistoryList();
-
- DefaultListModel historyModel = (DefaultListModel) historyList.getModel();
-
- Version[] versions = model.getVersions();
- historyList.setSelectedIndex(-1);
- if (versions == null) {
- historyModel.setSize(0);
- } else {
- Version currentVersion = model.getBean().getMetaData().getVersion();
- historyModel.setSize(versions.length);
-
- for (int i = 0; i < versions.length; i++) {
- Version version = versions[i];
- historyModel.setElementAt(version, i);
- if (version.equals(currentVersion)) {
- historyList.setSelectedIndex(i);
- }
- }
- }
-
- // history list may have changed, must revalidate
- historyList.invalidate();
-
- // parent must be repaint (will revalidate layout for tree)
- ui.repaint();
- }
- });
- }
-
- public void refreshListTabUI(final ListTabModel model, final JApplicationListTab ui) {
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
-
- // refresh search text
- ui.getSearchText().setText(model.getQuery());
-
- // refresh search actions
- refreshSearchActions(ui, model);
-
- // refresh changePage combobox
- refreshChangePageCombo(ui, model);
-
- // refresh changeSizor combo
- refreshChangeSizorCombo(ui, model);
-
- // refresh pagination buttons
- refreshPagination(ui, model.getPagination());
-
- // table data model may have changed, must revalidate
- ui.getTable().invalidate();
-
- // parent must be repaint (will revalidate layout for table)
- ui.repaint();
- }
- });
- }
-
- 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() {
- // public void run() {
- getConnect().setEnabled(!isConnected);
- getUnconnect().setEnabled(isConnected);
- getShowTab_remote().setEnabled(isConnected);
- getShowTab_synchronize().setEnabled(isConnected);
- getToggleTab_remote().setEnabled(isConnected);
- getToggleTab_synchronize().setEnabled(isConnected);
- if (!isConnected) {
- // close all connected ui
- JTabbedPane container = getContent();
-
- if (SimExplorerTab.remote.isTabVisible(container)) {
- // close tab
- SimExplorerTab.remote.closeTab(container);
- }
- if (SimExplorerTab.synchronize.isTabVisible(container)) {
- // close tab
- SimExplorerTab.synchronize.closeTab(container);
- }
- if (SimExplorerTab.detail.isTabVisible(container)) {
- DetailTabModel model = (DetailTabModel) SimExplorerTab.detail.getModel();
- if (model.isRemote()) {
- // close tab
- SimExplorerTab.detail.closeTab(container);
- }
- }
- }
- // }
- //});
- }
-
- protected void refreshPagination(JApplicationListTab ui, PaginationModel pagination) {
- int page = pagination.getCurrentPage();
- boolean notLast = page + 1 < pagination.getNbPages();
- ui.getGoNextPage().setEnabled(notLast);
- ui.getGoLastPage().setEnabled(notLast);
- }
-
- protected void refreshChangeSizorCombo(JApplicationListTab ui, ListTabModel model) {
- JComboBox combo = ui.getChangeSizor();
- String s = model.getPagination().getWidth() + "";
- if (!s.equals(String.valueOf(combo.getSelectedItem()))) {
- combo.setEnabled(false);
- combo.setSelectedItem(s);
- combo.setEnabled(true);
- }
- }
-
- protected void refreshChangePageCombo(JApplicationListTab ui, ListTabModel model) {
- JComboBox combo = ui.getGoPage();
- long size = model.getPagination().getNbPages();
- combo.setEnabled(false);
- //System.out.println("page old size : " + combo.getItemCount() + " new size : " + size);
- if (size < combo.getItemCount()) {
- while (size < combo.getItemCount()) {
- combo.removeItemAt(combo.getItemCount() - 1);
- }
- } else {
- while (size > combo.getItemCount()) {
- combo.addItem(combo.getItemCount());
- }
- }
- //System.out.println("new page size : " + combo.getItemCount());
-
- combo.setSelectedIndex(model.getPagination().getCurrentPage());
- boolean b = combo.getItemCount() > 1;
- combo.setEnabled(b);
- ui.getCurrentPage().setEnabled(b);
- }
}
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/auth/ConnectAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/auth/ConnectAction.java 2008-02-04 14:47:45 UTC (rev 629)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/auth/ConnectAction.java 2008-02-04 14:49:05 UTC (rev 630)
@@ -20,8 +20,8 @@
import fr.cemagref.simexplorer.is.service.SimExplorerServiceException;
import fr.cemagref.simexplorer.is.service.StorageService;
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractAction;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper;
import java.awt.event.ActionEvent;
@@ -84,7 +84,7 @@
@Override
protected void afterAction(ActionEvent e) throws Exception {
- SimExplorer.getUI().refreshConnnectState(true);
+ SimExplorerUIRefreshHelper.refreshConnnectState(getMainUI(), true);
}
@Override
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/auth/UnconnectAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/auth/UnconnectAction.java 2008-02-04 14:47:45 UTC (rev 629)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/auth/UnconnectAction.java 2008-02-04 14:49:05 UTC (rev 630)
@@ -18,8 +18,8 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing.action.auth;
-import fr.cemagref.simexplorer.is.ui.SimExplorer;
import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractAction;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper;
import java.awt.event.ActionEvent;
@@ -60,6 +60,6 @@
@Override
protected void afterAction(ActionEvent e) throws Exception {
- SimExplorer.getUI().refreshConnnectState(false);
+ SimExplorerUIRefreshHelper.refreshConnnectState(getMainUI(), false);
}
}
\ No newline at end of file
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/pagination/ChangePageAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/pagination/ChangePageAction.java 2008-02-04 14:47:45 UTC (rev 629)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/pagination/ChangePageAction.java 2008-02-04 14:49:05 UTC (rev 630)
@@ -19,6 +19,7 @@
package fr.cemagref.simexplorer.is.ui.swing.action.pagination;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper;
import fr.cemagref.simexplorer.is.ui.swing.action.SimExplorerAbstractTabAction;
import fr.cemagref.simexplorer.is.ui.swing.model.JApplicationTableModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
@@ -91,7 +92,7 @@
modelTab.setData(model.getList());
// refresh ui
- getMainUI().refreshListTabUI(model, container);
+ SimExplorerUIRefreshHelper.refreshListTabUI(container, model);
}
@Override
Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/pagination/ChangeSizorAction.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/pagination/ChangeSizorAction.java 2008-02-04 14:47:45 UTC (rev 629)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/pagination/ChangeSizorAction.java 2008-02-04 14:49:05 UTC (rev 630)
@@ -23,6 +23,7 @@
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.PaginationModel;
import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationListTab;
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper;
import javax.swing.Action;
import javax.swing.JComboBox;
@@ -88,7 +89,7 @@
modelTab.setData(model.getList());
// refresh ui
- getMainUI().refreshListTabUI(model, container);
+ SimExplorerUIRefreshHelper.refreshListTabUI(container, model);
}
@Override
1
0
r629 - trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing
by tchemit@users.labs.libre-entreprise.org 04 Feb '08
by tchemit@users.labs.libre-entreprise.org 04 Feb '08
04 Feb '08
Author: tchemit
Date: 2008-02-04 14:47:45 +0000 (Mon, 04 Feb 2008)
New Revision: 629
Added:
trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUIRefreshHelper.java
Log:
introduction classe SimExplorerUIRefreshHelper pour traiter tous les rafraichissements d'ui ?\195?\160 partir de nos mod?\195?\168les
Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUIRefreshHelper.java
===================================================================
--- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUIRefreshHelper.java (rev 0)
+++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerUIRefreshHelper.java 2008-02-04 14:47:45 UTC (rev 629)
@@ -0,0 +1,306 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+* Tony Chemit, 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.swing;
+
+import fr.cemagref.simexplorer.is.entities.metadata.Version;
+import fr.cemagref.simexplorer.is.ui.SimExplorer;
+import fr.cemagref.simexplorer.is.ui.swing.action.ChangeI18nAbstractAction;
+import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode;
+import fr.cemagref.simexplorer.is.ui.swing.model.PaginationModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeHelper;
+import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationDetailTab;
+import fr.cemagref.simexplorer.is.ui.swing.tab.JApplicationListTab;
+import org.codelutin.i18n.CountryEnum;
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.i18n.LanguageEnum;
+
+import javax.swing.AbstractButton;
+import javax.swing.DefaultListModel;
+import javax.swing.JComboBox;
+import javax.swing.JList;
+import javax.swing.JTabbedPane;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import java.util.regex.Matcher;
+
+/**
+ * Cette classe contient les méthodes utiles et réutilisables pour rafraichit
+ * les ui.
+ * <p/>
+ * Les méthodes utilisent les données stockées dans les modèles pour rafraichir
+ * les uis concernées.
+ * <p/>
+ * Note : <b>Dans toutes ces méthodes, NOS modèles ne doivent en aucun cas être modifiés</b>
+ * <p/>
+ * Par contre les modèles des ui peuvent être modifiés (par exemple modèle d'arbre, de liste)
+ * mais uniquement à partir de nos modèles.
+ *
+ * @author chemit
+ */
+public class SimExplorerUIRefreshHelper {
+
+ /**
+ * Rafraichit un onglet de type liste à partir de son modèle.
+ *
+ * @param ui l'onglet de liste à utiliser
+ * @param model le modèle de liste à utiliser
+ */
+ public static void refreshListTabUI(final JApplicationListTab ui, final ListTabModel model) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+
+ // refresh search text
+ ui.getSearchText().setText(model.getQuery());
+
+ // refresh search actions
+ refreshSearchActions(ui, model);
+
+ // refresh changePage combobox
+ refreshChangePageCombo(ui, model);
+
+ // refresh changeSizor combo
+ refreshChangeSizorCombo(ui, model);
+
+ // refresh pagination buttons
+ refreshPagination(ui, model.getPagination());
+
+ // table data model may have changed, must revalidate
+ ui.getTable().invalidate();
+
+ // parent must be repaint (will revalidate layout for table)
+ ui.repaint();
+ }
+ });
+ }
+
+ /**
+ * Rafraichit l'onglet de détail à partir de notre modèle de détail.
+ *
+ * @param ui l'onglet de détail
+ * @param model le modele de détail
+ */
+ public static void refreshDetailTabUI(final JApplicationDetailTab ui, final DetailTabModel model) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ JTree tree = ui.getNavigationTree();
+
+ // tree data model may have changed, must revalidate
+ tree.invalidate();
+
+ JList historyList = ui.getHistoryList();
+
+ DefaultListModel historyModel = (DefaultListModel) historyList.getModel();
+
+ Version[] versions = model.getVersions();
+ historyList.setSelectedIndex(-1);
+ if (versions == null) {
+ historyModel.setSize(0);
+ } else {
+ Version currentVersion = model.getSelectedNode().getMetaData().getVersion();
+ historyModel.setSize(versions.length);
+
+ for (int i = 0; i < versions.length; i++) {
+ Version version = versions[i];
+ historyModel.setElementAt(version, i);
+ if (version.equals(currentVersion)) {
+ historyList.setSelectedIndex(i);
+ }
+ }
+ }
+
+ // history list may have changed, must revalidate
+ historyList.invalidate();
+
+ // parent must be repaint (will revalidate layout for tree)
+ ui.repaint();
+ }
+ });
+ }
+
+ /**
+ * Rafraichit les actions d'un node dans l'arbre de navigation
+ *
+ * @param ui l'onglet de détail
+ * @param model le model du détail
+ * @param node le node sélectionné dans l'arbre de navigation
+ */
+ public static void refreshDetailActions(JApplicationDetailTab ui, DetailTabModel model, LoggableElementTreeNode node) {
+ // refresh download button
+ refreshDownloadAction(ui, model, node);
+ // refresh delete button
+ refreshDeleteAction(ui, model, node);
+ // refresh export button
+ refreshExportAction(ui, model, node);
+ }
+
+ /**
+ * Rafraichit les actions i18n dans le menu en fonction de la locale
+ * actuellement utilisée.
+ *
+ * @param ui l'ui principale
+ */
+ public static void refreshI18nActions(SimExplorerMainUI ui) {
+ LanguageEnum language = SimExplorer.getContext().getConfig().getLanguage();
+ CountryEnum country = SimExplorer.getContext().getConfig().getCountry();
+ String[] actions = SimExplorerActionManager.getFactory().getActionNames();
+ for (String actionName : actions) {
+ Matcher matcher = ChangeI18nAbstractAction.PATTERN_NAME.matcher(actionName);
+ if (!matcher.matches()) {
+ continue;
+ }
+ AbstractButton button = (AbstractButton) ui.getObjectById(actionName);
+ ChangeI18nAbstractAction action = (ChangeI18nAbstractAction) button.getAction();
+ boolean enable = !action.equalsLocale(language, country);
+ button.setEnabled(enable);
+ }
+ }
+
+ /**
+ * Rafraichit les actions de recherche d'un onglet de type liste.
+ *
+ * @param ui l'onglet de liste à utiliser
+ * @param model le modèle de liste à utiliser
+ */
+ public static void refreshSearchActions(JApplicationListTab ui, ListTabModel model) {
+ String text = ui.getSearchText().getText();
+ ui.getSearchApplication().setEnabled(model.hasQuery() || !text.isEmpty());
+ ui.getResetSearchApplication().setEnabled(model.hasQuery() || !text.isEmpty());
+ }
+
+ /**
+ * Rafraichit les uis après un changement de status de connexion de l'utilisateur.
+ * <p/>
+ * Si l'utilisateur est déconnecté, alors toutes les ui et actions liées au
+ * mode remote sont fermées et les actions correspondantes sont rendues
+ * inaccessibles.
+ *
+ * @param ui l'ui principale
+ * @param isConnected flag pour indique si l'utiliseur est connecté
+ */
+ public static void refreshConnnectState(SimExplorerMainUI ui, final boolean isConnected) {
+
+ //SwingUtilities.invokeLater(new Runnable() {
+ // public void run() {
+ ui.getConnect().setEnabled(!isConnected);
+ ui.getUnconnect().setEnabled(isConnected);
+ ui.getShowTab_remote().setEnabled(isConnected);
+ ui.getShowTab_synchronize().setEnabled(isConnected);
+ ui.getToggleTab_remote().setEnabled(isConnected);
+ ui.getToggleTab_synchronize().setEnabled(isConnected);
+ if (!isConnected) {
+ // close all connected ui
+ JTabbedPane container = ui.getContent();
+
+ if (SimExplorerTab.remote.isTabVisible(container)) {
+ // close tab
+ SimExplorerTab.remote.closeTab(container);
+ }
+ if (SimExplorerTab.synchronize.isTabVisible(container)) {
+ // close tab
+ SimExplorerTab.synchronize.closeTab(container);
+ }
+ if (SimExplorerTab.detail.isTabVisible(container)) {
+ DetailTabModel model = (DetailTabModel) SimExplorerTab.detail.getModel();
+ if (model.isRemote()) {
+ // close tab
+ SimExplorerTab.detail.closeTab(container);
+ }
+ }
+ }
+ // }
+ //});
+ }
+
+ protected static void refreshExportAction(JApplicationDetailTab ui, DetailTabModel model, LoggableElementTreeNode node) {
+ boolean export = LoggableElementTreeHelper.canExport(node);
+ ui.getExportApplication().setEnabled(export);
+ if (export) {
+ ui.getExportApplication().setToolTipText(_("simexplorer.action.export2", node.getUserObject()));
+ } else {
+ ui.getExportApplication().setToolTipText(null);
+ }
+ }
+
+ protected static void refreshDeleteAction(JApplicationDetailTab ui, DetailTabModel model, LoggableElementTreeNode node) {
+ boolean delete = LoggableElementTreeHelper.canDelete(node);
+ ui.getDelete().setEnabled(delete);
+ if (delete) {
+ ui.getDelete().setToolTipText(_("simexplorer.action.delete2", node.getUserObject()));
+ } else {
+ ui.getDelete().setToolTipText(null);
+ }
+ }
+
+ protected static void refreshDownloadAction(JApplicationDetailTab ui, DetailTabModel model, LoggableElementTreeNode node) {
+ boolean download = LoggableElementTreeHelper.canDownload(node);
+ ui.getDownload().setEnabled(download);
+ if (download) {
+ ui.getDownload().setToolTipText(_("simexplorer.action.dowload2", node.getUserObject()));
+ } else {
+ ui.getDownload().setToolTipText(null);
+ }
+ }
+
+ protected static void refreshPagination(JApplicationListTab ui, PaginationModel pagination) {
+ int page = pagination.getCurrentPage();
+ boolean notLast = page + 1 < pagination.getNbPages();
+ ui.getGoNextPage().setEnabled(notLast);
+ ui.getGoLastPage().setEnabled(notLast);
+ }
+
+ protected static void refreshChangeSizorCombo(JApplicationListTab ui, ListTabModel model) {
+ JComboBox combo = ui.getChangeSizor();
+ String s = model.getPagination().getWidth() + "";
+ if (!s.equals(String.valueOf(combo.getSelectedItem()))) {
+ combo.setEnabled(false);
+ combo.setSelectedItem(s);
+ combo.setEnabled(true);
+ }
+ }
+
+ protected static void refreshChangePageCombo(JApplicationListTab ui, ListTabModel model) {
+ JComboBox combo = ui.getGoPage();
+ long size = model.getPagination().getNbPages();
+ combo.setEnabled(false);
+ //System.out.println("page old size : " + combo.getItemCount() + " new size : " + size);
+ if (size < combo.getItemCount()) {
+ while (size < combo.getItemCount()) {
+ combo.removeItemAt(combo.getItemCount() - 1);
+ }
+ } else {
+ while (size > combo.getItemCount()) {
+ combo.addItem(combo.getItemCount());
+ }
+ }
+ //System.out.println("new page size : " + combo.getItemCount());
+
+ combo.setSelectedIndex(model.getPagination().getCurrentPage());
+ boolean b = combo.getItemCount() > 1;
+ combo.setEnabled(b);
+ ui.getCurrentPage().setEnabled(b);
+ }
+
+ protected SimExplorerUIRefreshHelper() {
+ // do not instanciate me please
+ }
+}
1
0
r628 - in trunk/simexplorer-is-storage/src: java/fr/cemagref/simexplorer/is/storage java/fr/cemagref/simexplorer/is/storage/attachment java/fr/cemagref/simexplorer/is/storage/database java/fr/cemagref/simexplorer/is/storage/database/lucene java/fr/cemagref/simexplorer/is/storage/engine java/fr/cemagref/simexplorer/is/storage/util test/fr/cemagref/simexplorer/is/storage test/fr/cemagref/simexplorer/is/storage/database/lucene
by glandais@users.labs.libre-entreprise.org 04 Feb '08
by glandais@users.labs.libre-entreprise.org 04 Feb '08
04 Feb '08
Author: glandais
Date: 2008-02-04 14:47:21 +0000 (Mon, 04 Feb 2008)
New Revision: 628
Removed:
trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/test/
Modified:
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/MetaDataGenerator.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/VersionGenerator.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/DatabaseConstants.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/SearcherPool.java
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/StorageEngineImpl.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/Config.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/KeyValue.java
trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/ZipStreamEncoder.java
trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/VersionGeneratorTest.java
trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java
trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java
trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThread.java
trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThreadsMassTestCase.java
trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneSimpleTest.java
Log:
Javadoc
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/MetaDataGenerator.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/MetaDataGenerator.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/MetaDataGenerator.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -27,8 +27,12 @@
import java.util.Map;
import java.util.UUID;
+/**
+ * The Class MetaDataGenerator.
+ */
public class MetaDataGenerator {
+ /** The r. */
java.util.Random r = new java.util.Random();
/*
@@ -40,8 +44,22 @@
* descriptorFields[i] = "descriptor" + i; } }
*/
+ /**
+ * Generate meta data entity.
+ *
+ * @param uuid
+ * the uuid
+ * @param version
+ * the version
+ * @param parentVersion
+ * the parent version
+ * @param parentData
+ * the parent data
+ *
+ * @return the meta data
+ */
public MetaData generateMetaDataEntity(String uuid, Version version,
- MetaData parentVersion, MetaData parentData) {
+ MetaData parentVersion, MetaData parentData) {
MetaData me = generateMetaDataEntity(uuid, version, parentVersion);
if (parentData != null) {
me.setParentDataUuid(parentData.getUuid());
@@ -50,8 +68,20 @@
return me;
}
+ /**
+ * Generate meta data entity.
+ *
+ * @param uuid
+ * the uuid
+ * @param version
+ * the version
+ * @param parentVersion
+ * the parent version
+ *
+ * @return the meta data
+ */
public MetaData generateMetaDataEntity(String uuid, Version version,
- MetaData parentVersion) {
+ MetaData parentVersion) {
MetaData me = generateMetaDataEntity(uuid, version);
if (parentVersion != null) {
@@ -64,6 +94,16 @@
return me;
}
+ /**
+ * Generate meta data entity.
+ *
+ * @param uuid
+ * the uuid
+ * @param version
+ * the version
+ *
+ * @return the meta data
+ */
public MetaData generateMetaDataEntity(String uuid, Version version) {
MetaData me = new MetaData();
@@ -92,11 +132,21 @@
return me;
}
+ /**
+ * Generate meta data entity.
+ *
+ * @return the meta data
+ */
public MetaData generateMetaDataEntity() {
- return generateMetaDataEntity(UUID.randomUUID().toString(),
- Version.valueOf("1.0"));
+ return generateMetaDataEntity(UUID.randomUUID().toString(), Version
+ .valueOf("1.0"));
}
+ /**
+ * Generate versionned meta data entity.
+ *
+ * @return the meta data[]
+ */
public MetaData[] generateVersionnedMetaDataEntity() {
Version[] versions = VersionGenerator.getInstance().generateVersions();
@@ -112,9 +162,18 @@
return mes;
}
+ /**
+ * Generate versionned meta data entity.
+ *
+ * @param nbMax
+ * the nb max
+ *
+ * @return the meta data[]
+ */
public MetaData[] generateVersionnedMetaDataEntity(int nbMax) {
- Version[] versions = VersionGenerator.getInstance().generateVersions(nbMax);
+ Version[] versions = VersionGenerator.getInstance().generateVersions(
+ nbMax);
String uuid = UUID.randomUUID().toString();
int nb = versions.length;
@@ -127,9 +186,18 @@
return mes;
}
+ /**
+ * Generate versionned meta data.
+ *
+ * @param mandatory
+ * the mandatory
+ *
+ * @return the meta data[]
+ */
public MetaData[] generateVersionnedMetaData(Version mandatory) {
- Version[] versions = VersionGenerator.getInstance().generateVersions(mandatory);
+ Version[] versions = VersionGenerator.getInstance().generateVersions(
+ mandatory);
String uuid = UUID.randomUUID().toString();
int nb = versions.length;
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SimExplorerStorageException.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -17,22 +17,49 @@
* ##% */
package fr.cemagref.simexplorer.is.storage;
+/**
+ * The Class SimExplorerStorageException.
+ */
public class SimExplorerStorageException extends Exception {
+ /** The Constant serialVersionUID. */
private static final long serialVersionUID = 4405447107690074844L;
+ /**
+ * Instantiates a new sim explorer storage exception.
+ */
public SimExplorerStorageException() {
super();
}
+ /**
+ * Instantiates a new sim explorer storage exception.
+ *
+ * @param message
+ * the message
+ */
public SimExplorerStorageException(String message) {
super(message);
}
+ /**
+ * Instantiates a new sim explorer storage exception.
+ *
+ * @param cause
+ * the cause
+ */
public SimExplorerStorageException(Throwable cause) {
super(cause);
}
+ /**
+ * Instantiates a new sim explorer storage exception.
+ *
+ * @param message
+ * the message
+ * @param cause
+ * the cause
+ */
public SimExplorerStorageException(String message, Throwable cause) {
super(message, cause);
}
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/VersionGenerator.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/VersionGenerator.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/VersionGenerator.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -25,26 +25,33 @@
import java.util.Arrays;
import java.util.Collections;
-
/**
- * A Version generator
- *
+ * A Version generator.
+ *
* @author chemit
*/
public class VersionGenerator {
- /** la taille maximum d'une version générée */
+ /** la taille maximum d'une version générée. */
static final int MAX_SIZE = 5;
- /** la valeur maximum d'un numéro de version à générer */
+ /** la valeur maximum d'un numéro de version à générer. */
static final int MAX_VERSION_NUMBER = 10;
- /** le nombre maximum de versions générées dans la méthode {@link #generateVersions()} */
+ /**
+ * le nombre maximum de versions générées dans la méthode
+ * {@link #generateVersions()}.
+ */
static final int MAX_NB_VERSIONS = 20;
- /** instance statique partagée */
+ /** instance statique partagée. */
protected static VersionGenerator instance;
+ /**
+ * Gets the single instance of VersionGenerator.
+ *
+ * @return single instance of VersionGenerator
+ */
public static VersionGenerator getInstance() {
if (instance == null) {
instance = new VersionGenerator();
@@ -52,8 +59,14 @@
return instance;
}
+ /** The r. */
protected Random r;
+ /**
+ * Generate version.
+ *
+ * @return the version
+ */
public Version generateVersion() {
StringBuilder sb = new StringBuilder();
for (int i = 0, size = generateNotNullAbsInt(MAX_SIZE); i < size; i++) {
@@ -62,11 +75,24 @@
return Version.valueOf(sb.substring(1));
}
+ /**
+ * Generate versions.
+ *
+ * @return the version[]
+ */
public Version[] generateVersions() {
int nb = generateNotNullAbsInt(MAX_NB_VERSIONS);
return generateVersions(nb);
}
+ /**
+ * Generate versions.
+ *
+ * @param mandatory
+ * the mandatory
+ *
+ * @return the version[]
+ */
public Version[] generateVersions(Version mandatory) {
int nb = generateNotNullAbsInt(MAX_NB_VERSIONS);
Version[] versions = generateVersions(nb);
@@ -78,22 +104,46 @@
return list.toArray(new Version[list.size()]);
}
+ /**
+ * Generate versions.
+ *
+ * @param nb
+ * the nb
+ *
+ * @return the version[]
+ */
public Version[] generateVersions(int nb) {
Version[] result = new Version[nb];
result[0] = generateVersion();
- //System.out.println("nb versions :" + nb);
- //System.out.println("version 0 :" + result[0]);
+ // System.out.println("nb versions :" + nb);
+ // System.out.println("version 0 :" + result[0]);
for (int i = 1; i < nb; i++) {
result[i] = result[i - 1].incVersion(generateAbsInt(MAX_SIZE));
- //System.out.println("version " + i + " :" + result[i]);
+ // System.out.println("version " + i + " :" + result[i]);
}
return result;
}
+ /**
+ * Generate abs int.
+ *
+ * @param max
+ * the max
+ *
+ * @return the int
+ */
protected int generateAbsInt(int max) {
return Math.abs(r.nextInt()) % max;
}
+ /**
+ * Generate not null abs int.
+ *
+ * @param max
+ * the max
+ *
+ * @return the int
+ */
protected int generateNotNullAbsInt(int max) {
int nb = 0;
while (nb == 0) {
@@ -102,6 +152,9 @@
return nb;
}
+ /**
+ * Instantiates a new version generator.
+ */
protected VersionGenerator() {
this.r = new Random();
}
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/AttachmentHandler.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -23,15 +23,14 @@
import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException;
/**
- * Store, retrieve and delete content
+ * Store, retrieve and delete content.
*
* @author landais
- *
*/
public abstract class AttachmentHandler {
/**
- * Store content
+ * Store content.
*
* @param entity
* DataEntity related to content
@@ -39,32 +38,39 @@
* Unique field for content
* @param is
* Content
- * @throws SimExplorerStorageException
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void storeData(MetaData entity, String field,
InputStream is) throws SimExplorerStorageException;
/**
- * Retrieve content
+ * Retrieve content.
*
* @param entity
* DataEntity related to content
* @param field
* Unique field for content
+ *
* @return Content
- * @throws SimExplorerStorageException
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract InputStream retrieveData(MetaData entity, String field)
throws SimExplorerStorageException;
/**
- * Delete content
+ * Delete content.
*
* @param entity
* DataEntity related to content
* @param field
* Unique field for content
- * @throws SimExplorerStorageException
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void deleteData(MetaData entity, String field)
throws SimExplorerStorageException;
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/attachment/FileSystemAttachmentHandler.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -31,26 +31,25 @@
import fr.cemagref.simexplorer.is.storage.util.Config;
/**
- * File system implementation
+ * File system implementation.
*
* @author landais
- *
*/
public class FileSystemAttachmentHandler extends AttachmentHandler {
- /**
- * Base folder
- */
+ /** Base folder. */
private static String baseFolder = Config.getProperties().getProperty(
"simexplorer.data");
/**
- * Retrieve file associated to content Create directories associated to file
+ * Retrieve file associated to content Create directories associated to
+ * file.
*
* @param entity
* DataEntity related to content
* @param field
* Unique field for content
+ *
* @return Instance of file
*/
private File getFile(MetaData entity, String field) {
@@ -77,6 +76,9 @@
return result;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#retrieveData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String)
+ */
@Override
public InputStream retrieveData(MetaData entity, String field)
throws SimExplorerStorageException {
@@ -90,11 +92,13 @@
return fis;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#storeData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String, java.io.InputStream)
+ */
@Override
public void storeData(MetaData entity, String field, InputStream is)
throws SimExplorerStorageException {
-
// Simple stream on file
try {
File file = getFile(entity, field);
@@ -121,11 +125,18 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler#deleteData(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String)
+ */
@Override
public void deleteData(MetaData entity, String field)
throws SimExplorerStorageException {
- // Simple delete on file
- getFile(entity, field).delete();
+ try {
+ // Simple delete on file
+ getFile(entity, field).delete();
+ } catch (Exception e) {
+ throw new SimExplorerStorageException(e);
+ }
}
}
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -28,114 +28,136 @@
import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException;
/**
- * Interface of a database able to manage metadata elements
+ * Interface of a database able to manage metadata elements.
*
* @author landais
- *
*/
public abstract class Database implements DatabaseConstants {
/**
- * Open database connection
+ * Open database connection.
*
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public void open() throws SimExplorerStorageException {
open(false);
}
/**
- * Open database connection
+ * Open database connection.
*
* @param create
* Create database
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public abstract void open(boolean create) throws SimExplorerStorageException;
+ public abstract void open(boolean create)
+ throws SimExplorerStorageException;
/**
- * Close database connection
+ * Close database connection.
*
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void close() throws SimExplorerStorageException;
/**
- * Commit pending modifications
+ * Commit pending modifications.
*
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void commit() throws SimExplorerStorageException;
// Create / Update
/**
- * Insert an element into database
- * Delete existing element with same id/version if exists
+ * Insert an element into database Delete existing element with same
+ * id/version if exists.
*
* @param element
* Element to insert
- * @param readers
+ * @param readers
+ * the readers
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public abstract void insertElement(MetaData element,
- List<Reader> readers) throws SimExplorerStorageException;
+ public abstract void insertElement(MetaData element, List<Reader> readers)
+ throws SimExplorerStorageException;
// Read
/**
- * Get an element from its id and its version null if not fund
+ * Get an element from its id and its version null if not fund.
*
* @param uuid
* Id
* @param version
* version
+ *
* @return Fund element, null if not fund
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract MetaData getElement(String uuid, Version version)
throws SimExplorerStorageException;
/**
* Get all version of an element thanks to its id <br>
- * Empty list if no element with this id
+ * Empty list if no element with this id.
*
* @param uuid
* Id
+ *
* @return Versions
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public abstract List<Version> getVersions(String uuid) throws SimExplorerStorageException;
+ public abstract List<Version> getVersions(String uuid)
+ throws SimExplorerStorageException;
/**
- * Retrieve all elements by id Empty list if no element with this id
+ * Retrieve all elements by id Empty list if no element with this id.
*
* @param uuid
* Id
- * @param onlyLatest
+ * @param onlyLatest
+ * the only latest
+ *
* @return Element list
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract Set<MetaData> findElementsById(String uuid,
boolean onlyLatest) throws SimExplorerStorageException;
/**
* Retrieve elements with specific properties<br>
- * Empty list if no element
+ * Empty list if no element.
*
* @param properties
* Matching properties needed
+ *
* @return Element list
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public Set<MetaData> findElementsByProperties(
- Map<String, String> properties) throws SimExplorerStorageException {
+ public Set<MetaData> findElementsByProperties(Map<String, String> properties)
+ throws SimExplorerStorageException {
return findElementsByProperties(properties, 0, -1, 0);
}
/**
* Retrieve elements with specific properties<br>
- * Empty list if no element
+ * Empty list if no element.
*
* @param properties
* Matching properties needed
@@ -143,32 +165,40 @@
* Index of first element returned
* @param count
* Number of elements to return
- * @param dateOrder
+ * @param dateOrder
+ * the date order
+ *
* @return Element list
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract Set<MetaData> findElementsByProperties(
Map<String, String> properties, int start, int count, int dateOrder)
throws SimExplorerStorageException;
/**
- * Retrieve element count specific properties
+ * Retrieve element count specific properties.
*
* @param properties
* Matching properties needed
+ *
* @return Number of elements fund
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract int findElementsByPropertiesCount(
Map<String, String> properties) throws SimExplorerStorageException;
/**
- * Prepare properties for query
+ * Prepare properties for query.
*
* @param type
* Type of entity wanted
* @param onlyLatest
* Only wanted elements
+ *
* @return Properties for query
*/
private Map<String, String> getPropertiesByType(String type,
@@ -182,7 +212,7 @@
}
/**
- * Retrieve elements of a certain type
+ * Retrieve elements of a certain type.
*
* @param type
* Type wanted
@@ -194,25 +224,31 @@
* Number of documents
* @param dateOrder
* Sorting
+ *
* @return Element list
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public Set<MetaData> findElementsByType(String type,
- boolean onlyLatest, int start, int count, int dateOrder)
+ public Set<MetaData> findElementsByType(String type, boolean onlyLatest,
+ int start, int count, int dateOrder)
throws SimExplorerStorageException {
return findElementsByProperties(getPropertiesByType(type, onlyLatest),
start, count, dateOrder);
}
/**
- * Number of elements of the type
+ * Number of elements of the type.
*
* @param type
* Type wanted
* @param onlyLatest
* Only latest elements
+ *
* @return Number of elements
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public int findElementsByTypeCount(String type, boolean onlyLatest)
throws SimExplorerStorageException {
@@ -222,31 +258,40 @@
/**
* Retrieve elements by content search<br>
- * Empty list if no element
+ * Empty list if no element.
*
* @param queryText
* Searched text
- * @param onlyLatest
+ * @param onlyLatest
+ * the only latest
* @param start
* Index of first element returned
* @param count
* Number of elements to return
- * @param dateOrder
+ * @param dateOrder
+ * the date order
+ *
* @return Element list
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public abstract Set<MetaData> findElementsByContentSearch(
- String queryText, boolean onlyLatest, int start, int count,
- int dateOrder) throws SimExplorerStorageException;
+ public abstract Set<MetaData> findElementsByContentSearch(String queryText,
+ boolean onlyLatest, int start, int count, int dateOrder)
+ throws SimExplorerStorageException;
/**
- * Retrieve element count with specific content
+ * Retrieve element count with specific content.
*
* @param queryText
* Searched text
- * @param onlyLatest
+ * @param onlyLatest
+ * the only latest
+ *
* @return Number of elements fund
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract int findElementsByContentSearchCount(String queryText,
boolean onlyLatest) throws SimExplorerStorageException;
@@ -254,24 +299,29 @@
// Delete
/**
- * Delete an a specific element
+ * Delete an a specific element.
*
* @param element
* Element to delete
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public void deleteElement(MetaData element) throws SimExplorerStorageException {
+ public void deleteElement(MetaData element)
+ throws SimExplorerStorageException {
deleteElement(element.getUuid(), element.getVersion());
}
/**
- * Delete an element by id and version
+ * Delete an element by id and version.
*
* @param uuid
* Id
* @param version
* Version
+ *
* @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void deleteElement(String uuid, Version version)
throws SimExplorerStorageException;
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/DatabaseConstants.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/DatabaseConstants.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/DatabaseConstants.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -18,109 +18,84 @@
package fr.cemagref.simexplorer.is.storage.database;
/**
- * Constants for database implementations
+ * Constants for database implementations.
*
* @author landais
- *
*/
public interface DatabaseConstants {
+ /** The Constant DOT. */
public static final String DOT = ".";
- /**
- * Field name for id
- */
+
+ /** Field name for id. */
public static final String KEY_UUID = "simexplorer.uuid";
- /**
- * Field name for name
- */
+
+ /** Field name for name. */
public static final String KEY_NAME = "simexplorer.name";
- /**
- * Field name for type
- */
+
+ /** Field name for type. */
public static final String KEY_TYPE = "simexplorer.type";
- /**
- * Field name for description
- */
+
+ /** Field name for description. */
public static final String KEY_DESCRIPTION = "simexplorer.description";
- /**
- * Field name for version
- */
+
+ /** Field name for version. */
public static final String KEY_VERSION = "simexplorer.version";
- /**
- * Field name for latest
- */
+
+ /** Field name for latest. */
public static final String KEY_LATEST = "simexplorer.latest";
- /**
- *
- * Field name for creation date
- */
+
+ /** Field name for creation date. */
public static final String KEY_CREATIONDATE = "simexplorer.creationdate";
- /**
- * Field name for hash
- */
+
+ /** Field name for hash. */
public static final String KEY_HASH = "simexplorer.hash";
- /**
- * Field name for descriptor
- */
+
+ /** Field name for descriptor. */
public static final String KEY_DESCRIPTOR = "simexplorer.descriptor";
- /**
- * Field name for descriptor
- */
+
+ /** Field name for descriptor. */
public static final String KEY_DESCRIPTOR_KEY = "key";
- /**
- * Field name for descriptor
- */
+
+ /** Field name for descriptor. */
public static final String KEY_DESCRIPTOR_VALUE = "value";
- /**
- * Field name for attachment
- */
+
+ /** Field name for attachment. */
public static final String KEY_ATTACHMENT = "simexplorer.attachment";
- /**
- * Field name for attachment
- */
+
+ /** Field name for attachment. */
public static final String KEY_ATTACHMENT_FILENAME = "filename";
- /**
- * Field name for attachment
- */
+
+ /** Field name for attachment. */
public static final String KEY_ATTACHMENT_HASH = "hash";
- /**
- * Field name for attachment
- */
+
+ /** Field name for attachment. */
public static final String KEY_ATTACHMENT_TYPE = "type";
- /**
- * Field name for id of parent data
- */
+
+ /** Field name for id of parent data. */
public static final String KEY_PARENTDATA_UUID = "simexplorer.parentdata.uuid";
- /**
- * Field name for version of parent data
- */
+
+ /** Field name for version of parent data. */
public static final String KEY_PARENTDATA_VERSION = "simexplorer.parentdata.version";
- /**
- * Field name for id of parent version
- */
+
+ /** Field name for id of parent version. */
public static final String KEY_PARENTVERSION_UUID = "simexplorer.parentversion.uuid";
- /**
- * Field name for version of parent version
- */
+
+ /** Field name for version of parent version. */
public static final String KEY_PARENTVERSION_VERSION = "simexplorer.parentversion.version";
- /**
- * Field name for searchable content
- */
+
+ /** Field name for searchable content. */
public static final String KEY_SEARCHABLE_CONTENT = "simexplorer.searchablecontent";
- /**
- * Field name for sorting
- */
+
+ /** Field name for sorting. */
public static final String SORT_DATE_FIELD = KEY_CREATIONDATE;
- /**
- * No date sort
- */
+
+ /** No date sort. */
public static final int SORT_DATE_NONE = 0;
- /**
- * Sort element by date (ascending)
- */
+
+ /** Sort element by date (ascending). */
public static final int SORT_DATE_ASCENDING = 1;
- /**
- * Sort element by date (descending)
- */
+
+ /** Sort element by date (descending). */
public static final int SORT_DATE_DESCENDING = -1;
}
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -54,7 +54,6 @@
import org.apache.lucene.store.NoLockFactory;
import fr.cemagref.simexplorer.is.attachment.Attachment;
-import fr.cemagref.simexplorer.is.attachment.ContentType;
import fr.cemagref.simexplorer.is.attachment.ContentTypeFactory;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
@@ -64,53 +63,49 @@
import fr.cemagref.simexplorer.is.storage.util.KeyValue;
/**
- * Lucene implementation
+ * Lucene implementation.
*
* @author landais
- *
*/
public class LuceneDatabase extends Database {
- /**
- * DB folder
- */
+ /** DB folder. */
private static String dbFolder = Config.getProperties().getProperty(
"simexplorer.db");
- /**
- * Optimize period
- */
+ /** Optimize period. */
private static Integer optimizePeriod = new Integer(Config.getProperties()
.getProperty("simexplorer.optimizeperiod"));
- /**
- * Lock factory for Lucene writer
- */
+ /** Lock factory for Lucene writer. */
private static LockFactory lockFactory = new NoLockFactory();
- /**
- * Location of index
- */
+
+ /** Location of index. */
private static Directory directory;
- /**
- * Index writer
- */
+
+ /** Index writer. */
private static IndexWriter writer = null;
- /**
- * Pool of searcher
- */
+
+ /** Pool of searcher. */
private static SearcherPool searcherPool = null;
- /**
- * Searcher that should be used for new queries
- */
+
+ /** Searcher that should be used for new queries. */
private static Searcher cachedSearcher = null;
- /**
- * Date of latest optimization
- */
+
+ /** Date of latest optimization. */
private static Date lastOptimize = new Date();
+ /** The Constant searcherSynchronizer. */
private final static Object searcherSynchronizer = new Object();
+
+ /** The Constant writerSynchronizer. */
private final static Object writerSynchronizer = new Object();
+ /**
+ * Gets the searcher pool.
+ *
+ * @return the searcher pool
+ */
private SearcherPool getSearcherPool() {
if (searcherPool == null) {
searcherPool = new SearcherPool();
@@ -119,10 +114,12 @@
}
/**
- * Retrieve searcher for a new query
+ * Retrieve searcher for a new query.
*
* @return Searcher
+ *
* @throws IOException
+ * Signals that an I/O exception has occurred.
*/
private Searcher getSearcher() throws IOException {
synchronized (searcherSynchronizer) {
@@ -138,11 +135,13 @@
}
/**
- * Release searcher, after the end of a query execution
+ * Release searcher, after the end of a query execution.
*
* @param searcher
* Searcher to be released
+ *
* @throws IOException
+ * Signals that an I/O exception has occurred.
*/
private void releaseSearcher(Searcher searcher) throws IOException {
synchronized (searcherSynchronizer) {
@@ -151,9 +150,10 @@
}
/**
- * Called to invalidate reader
+ * Called to invalidate reader.
*
* @throws IOException
+ * Signals that an I/O exception has occurred.
*/
private void resetReader() throws IOException {
synchronized (searcherSynchronizer) {
@@ -166,6 +166,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#open(boolean)
+ */
@Override
public void open(boolean create) throws SimExplorerStorageException {
if (writer == null) {
@@ -201,6 +204,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#close()
+ */
@Override
public void close() throws SimExplorerStorageException {
try {
@@ -217,9 +223,10 @@
}
/**
- * Push commit to db
+ * Push commit to db.
*
* @throws IOException
+ * Signals that an I/O exception has occurred.
*/
private void synchedCommit() throws IOException {
synchronized (writerSynchronizer) {
@@ -239,6 +246,9 @@
resetReader();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#commit()
+ */
@Override
public void commit() throws SimExplorerStorageException {
try {
@@ -249,6 +259,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#insertElement(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.util.List)
+ */
@Override
public void insertElement(MetaData element, List<Reader> readers)
throws SimExplorerStorageException {
@@ -274,6 +287,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#getElement(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version)
+ */
@Override
public MetaData getElement(String uuid, Version version)
throws SimExplorerStorageException {
@@ -300,12 +316,19 @@
}
/**
+ * Gets the hits by id version.
+ *
* @param uuid
+ * the uuid
* @param version
+ * the version
* @param searcher
- * @return
+ * the searcher
+ *
+ * @return the hits by id version
+ *
* @throws IOException
- * @throws Exception
+ * Signals that an I/O exception has occurred.
*/
private Hits getHitsByIdVersion(String uuid, Version version,
Searcher searcher) throws IOException {
@@ -319,8 +342,12 @@
return hits;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#getVersions(java.lang.String)
+ */
@Override
- public List<Version> getVersions(String uuid) throws SimExplorerStorageException {
+ public List<Version> getVersions(String uuid)
+ throws SimExplorerStorageException {
// Retrieve all document corresponding to id
Map<String, String> properties = new HashMap<String, String>();
properties.put(KEY_UUID, uuid);
@@ -352,6 +379,9 @@
return versions;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsById(java.lang.String, boolean)
+ */
@Override
public Set<MetaData> findElementsById(String uuid, boolean onlyLatest)
throws SimExplorerStorageException {
@@ -382,6 +412,9 @@
return result;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByPropertiesCount(java.util.Map)
+ */
@Override
public int findElementsByPropertiesCount(Map<String, String> properties)
throws SimExplorerStorageException {
@@ -405,6 +438,9 @@
return result;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByProperties(java.util.Map, int, int, int)
+ */
@Override
public Set<MetaData> findElementsByProperties(
Map<String, String> properties, int start, int count, int dateOrder)
@@ -429,6 +465,9 @@
return result;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByContentSearchCount(java.lang.String, boolean)
+ */
@Override
public int findElementsByContentSearchCount(String queryText,
boolean onlyLatest) throws SimExplorerStorageException {
@@ -461,11 +500,12 @@
}
/**
- * Retrieve a Lucene Sort for date sorting
+ * Retrieve a Lucene Sort for date sorting.
*
* @param dateOrder
* sort wanted SORT_DATE_NONE, SORT_DATE_DESCENDING,
* SORT_DATE_ASCENDING,
+ *
* @return null if no sort
*/
private Sort getSortDate(int dateOrder) {
@@ -479,6 +519,9 @@
return sort;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByContentSearch(java.lang.String, boolean, int, int, int)
+ */
@Override
public Set<MetaData> findElementsByContentSearch(String queryText,
boolean onlyLatest, int start, int count, int dateOrder)
@@ -512,14 +555,17 @@
}
/**
- * Retrieve a Lucene Query for a full text search
+ * Retrieve a Lucene Query for a full text search.
*
* @param queryText
* String to match
* @param onlyLatest
* Latest flag
+ *
* @return Query
+ *
* @throws ParseException
+ * the parse exception
*/
private Query getQueryByContentSearch(String queryText, boolean onlyLatest)
throws ParseException {
@@ -547,6 +593,9 @@
return query;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.database.Database#deleteElement(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version)
+ */
@Override
public void deleteElement(String uuid, Version version)
throws SimExplorerStorageException {
@@ -565,13 +614,19 @@
}
/**
- * Find all documents matching properties
+ * Find all documents matching properties.
*
* @param properties
* criteria
+ * @param searcher
+ * the searcher
+ * @param dateOrder
+ * the date order
+ *
* @return Documents and search handle
+ *
* @throws IOException
- * @throws Exception
+ * Signals that an I/O exception has occurred.
*/
private Hits findHits(Map<String, String> properties, Searcher searcher,
int dateOrder) throws IOException {
@@ -587,7 +642,7 @@
}
/**
- * Convert Lucene documents to real entities
+ * Convert Lucene documents to real entities.
*
* @param hits
* Document collection
@@ -595,8 +650,11 @@
* Index of first document to return
* @param count
* Number of documents to return
+ *
* @return Entities list
+ *
* @throws Exception
+ * the exception
*/
private Set<MetaData> convertHitsToElements(Hits hits, int start, int count)
throws Exception {
@@ -614,14 +672,17 @@
}
/**
- * Transform a Lucene document into a LoggableElement thanks to a factory
+ * Transform a Lucene document into a LoggableElement thanks to a factory.
*
* @param document
* The document to transform
+ *
* @return Instance of element
+ *
* @throws Exception
+ * the exception
*/
- @SuppressWarnings({"unchecked"})
+ @SuppressWarnings( { "unchecked" })
private MetaData loadLuceneElement(Document document) throws Exception {
MetaData element = new MetaData();
@@ -691,7 +752,8 @@
attachment.setFileName(fieldValue);
}
if (field.equals(KEY_ATTACHMENT_HASH)) {
- attachment.setDataHash(Attachment.intFromHexString("0X" + fieldValue));
+ attachment.setDataHash(Attachment.intFromHexString("0X"
+ + fieldValue));
}
if (field.equals(KEY_ATTACHMENT_TYPE)) {
attachment.setContentType(ContentTypeFactory
@@ -725,7 +787,7 @@
}
/**
- * Add a field to a document
+ * Add a field to a document.
*
* @param document
* Document to add the field
@@ -744,12 +806,14 @@
}
/**
- * Transform an element to a Lucene document thanks to a factory
+ * Transform an element to a Lucene document thanks to a factory.
*
* @param readers
+ * the readers
* @param element
- * @return
- * @throws Exception
+ * the element
+ *
+ * @return the document
*/
private Document saveLuceneElement(MetaData element, List<Reader> readers) {
Document document = new Document();
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/SearcherPool.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/SearcherPool.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/SearcherPool.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -26,38 +26,34 @@
/**
* Pool of searchers, being randomly accessed<br>
- * Manage life cycle of searchers
+ * Manage life cycle of searchers.
*
* @author landais
- *
*/
public class SearcherPool {
/**
- * Searcher record
+ * Searcher record.
*
* @author landais
- *
*/
- private class SearcherInfo {
- /**
- * Numbre of queries using this searcher
- */
+ public class SearcherInfo {
+
+ /** Numbre of queries using this searcher. */
public int count = 0;
+
/**
* If marked, searcher is not valid anymore<br>
- * It should be closed upon last query ended
+ * It should be closed upon last query ended.
*/
public boolean marked = false;
}
- /**
- * Searchers used by database
- */
+ /** Searchers used by database. */
Map<Searcher, SearcherInfo> searchers = new HashMap<Searcher, SearcherInfo>();
/**
- * Called when a searcher will be used for a query
+ * Called when a searcher will be used for a query.
*
* @param searcher
* Searcher used
@@ -79,13 +75,15 @@
}
/**
- * Check if searcher should be closed
+ * Check if searcher should be closed.
*
* @param searcher
* Searcher aiming to be closed
* @param searcherInfo
* Searcher info related
+ *
* @throws IOException
+ * Signals that an I/O exception has occurred.
*/
private void checkClose(Searcher searcher, SearcherInfo searcherInfo)
throws IOException {
@@ -99,12 +97,13 @@
}
/**
- * Release a searcher from a query
+ * Release a searcher from a query.
*
* @param searcher
* Searcher released
*
* @throws IOException
+ * Signals that an I/O exception has occurred.
*/
public void release(Searcher searcher) throws IOException {
// Retrieve searcher info
@@ -116,10 +115,13 @@
}
/**
- * Mark searcher as being invalid anymore
+ * Mark searcher as being invalid anymore.
*
* @param searcher
+ * the searcher
+ *
* @throws IOException
+ * Signals that an I/O exception has occurred.
*/
public void mark(Searcher searcher) throws IOException {
// Retrieve searcher
@@ -131,7 +133,7 @@
}
/**
- * Check if any reader is opened
+ * Check if any reader is opened.
*
* @return true if no reader is open
*/
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-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -28,199 +28,292 @@
import fr.cemagref.simexplorer.is.entities.metadata.Version;
import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException;
+/**
+ * The Interface StorageEngine.
+ */
@Local
public interface StorageEngine {
/**
- * Open storage
+ * Open storage.
*
- * @throws Exception
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void open() throws SimExplorerStorageException;
/**
- * Close storage
+ * Close storage.
*
- * @throws Exception
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void close() throws SimExplorerStorageException;
/**
- * Commit changes to storage
+ * Commit changes to storage.
*
- * @throws Exception
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void commit() throws SimExplorerStorageException;
/**
- * Save an element to storage
+ * Save an element to storage.
*
* @param element
* Element to save
* @param attachments
* Attachments related
- * @throws Exception
+ * @param token
+ * the token
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void saveElement(String token, MetaData element,
- Map<String, InputStream> attachments) throws SimExplorerStorageException;
+ Map<String, InputStream> attachments)
+ throws SimExplorerStorageException;
/**
- * Retrieve an element
+ * Retrieve an element.
*
* @param uuid
* Id of the element
+ * @param token
+ * the token
+ *
* @return The element
- * @throws Exception
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract MetaData getMetadata(String token, String uuid)
throws SimExplorerStorageException;
/**
* Retrieve versions of an element<br>
- * Empty list if no element with this id
+ * Empty list if no element with this id.
*
* @param uuid
* Id of the element
+ * @param token
+ * the token
+ *
* @return List of versions of the element<br>
*
- * @throws Exception
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract List<Version> getVersions(String token, String uuid)
throws SimExplorerStorageException;
/**
- * Retrieve all version of a metadata
+ * Retrieve all version of a metadata.
*
* @param token
+ * the token
* @param uuid
- * @return
+ * the uuid
+ *
+ * @return the element versions
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public abstract Set<MetaData> getElementVersions(String token,
- String uuid) throws SimExplorerStorageException;
+ public abstract Set<MetaData> getElementVersions(String token, String uuid)
+ throws SimExplorerStorageException;
/**
- * Retrieve an element in a specific version
+ * Retrieve an element in a specific version.
*
* @param uuid
+ * the uuid
* @param version
- * @return
- * @throws Exception
+ * the version
+ * @param token
+ * the token
+ *
+ * @return the metadata
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract MetaData getMetadata(String token, String uuid,
Version version) throws SimExplorerStorageException;
/**
- * Get data associated to an element
+ * Get data associated to an element.
*
* @param entity
* Element related
* @param field
* Data field
+ * @param token
+ * the token
+ *
* @return Data stream
- * @throws Exception
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public abstract InputStream retrieveData(String token,
- MetaData entity, String field) throws SimExplorerStorageException;
+ public abstract InputStream retrieveData(String token, MetaData entity,
+ String field) throws SimExplorerStorageException;
/**
- * Get number of items corresponding to query
+ * Get number of items corresponding to query.
*
* @param query
+ * the query
* @param onlyLatest
- * @return
- * @throws Exception
+ * the only latest
+ * @param token
+ * the token
+ *
+ * @return the int
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract int findFullTextCount(String token, String query,
boolean onlyLatest) throws SimExplorerStorageException;
/**
- * Retrieve list of items corresponding to query
+ * Retrieve list of items corresponding to query.
*
* @param query
+ * the query
* @param onlyLatest
+ * the only latest
* @param indexStart
+ * the index start
* @param count
+ * the count
* @param dateOrder
- * @return
- * @throws Exception
+ * the date order
+ * @param token
+ * the token
+ *
+ * @return the meta data[]
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract MetaData[] findFullText(String token, String query,
boolean onlyLatest, int indexStart, int count, int dateOrder)
throws SimExplorerStorageException;
/**
- * Retrieve list of items of type wanted
+ * Retrieve list of items of type wanted.
*
* @param type
+ * the type
* @param onlyLatest
+ * the only latest
* @param start
+ * the start
* @param count
+ * the count
* @param dateOrder
- * @return
- * @throws Exception
+ * the date order
+ * @param token
+ * the token
+ *
+ * @return the meta data[]
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public abstract MetaData[] findElementsByType(String token,
- String type, boolean onlyLatest, int start, int count, int dateOrder)
+ public abstract MetaData[] findElementsByType(String token, String type,
+ boolean onlyLatest, int start, int count, int dateOrder)
throws SimExplorerStorageException;
/**
- * Retrieve number of items of type wanted
+ * Retrieve number of items of type wanted.
*
* @param type
+ * the type
* @param onlyLatest
- * @return
- * @throws Exception
+ * the only latest
+ * @param token
+ * the token
+ *
+ * @return the int
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract int findElementsByTypeCount(String token, String type,
boolean onlyLatest) throws SimExplorerStorageException;
/**
- * Delete elements
+ * Delete elements.
*
* @param uuid
- * @throws Exception
+ * the uuid
+ * @param token
+ * the token
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void deleteElements(String token, String uuid)
throws SimExplorerStorageException;
/**
- * Delete one element
+ * Delete one element.
*
* @param uuid
+ * the uuid
* @param version
- * @throws Exception
+ * the version
+ * @param token
+ * the token
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract void deleteElement(String token, String uuid,
Version version) throws SimExplorerStorageException;
/**
- * Store temporary data, for stream duplication
+ * Store temporary data, for stream duplication.
*
* @param stream
* Stream to store
+ *
* @return id for retrieval
- * @throws Exception
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract String storeTempData(InputStream stream)
throws SimExplorerStorageException;
/**
- * Retrieve temporary data
+ * Retrieve temporary data.
*
* @param id
* Id associated
+ *
* @return Data stream
- * @throws Exception
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
public abstract InputStream retrieveTempData(String id)
throws SimExplorerStorageException;
/**
- * Delete temporary data
+ * Delete temporary data.
*
* @param id
- * @throws Exception
+ * the id
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
*/
- public abstract void deleteTempData(String id) throws SimExplorerStorageException;
+ public abstract void deleteTempData(String id)
+ throws SimExplorerStorageException;
}
\ No newline at end of file
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -27,7 +27,6 @@
import java.util.UUID;
import fr.cemagref.simexplorer.is.attachment.Attachment;
-import fr.cemagref.simexplorer.is.attachment.ContentType;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException;
@@ -37,32 +36,26 @@
import fr.cemagref.simexplorer.is.storage.database.lucene.LuceneDatabase;
/**
- * Handle data storage and indexing
+ * Handle data storage and indexing.
*
* @author landais
- *
*/
public class StorageEngineImpl implements StorageEngine {
- /**
- * Indexing
- */
+ /** Indexing. */
protected Database database;
- /**
- * Storage
- */
+ /** Storage. */
protected AttachmentHandler attachmentHandler;
- /**
- * Metadata handling temporary data
- */
+ /** Metadata handling temporary data. */
private MetaData mdTmp;
+ /** The opened. */
private boolean opened = false;
/**
- * Default constructor with default implementations of storage and indexing
+ * Default constructor with default implementations of storage and indexing.
*/
public StorageEngineImpl() {
super();
@@ -106,7 +99,8 @@
* @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#saveElement(fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.util.Map)
*/
public void saveElement(String token, MetaData element,
- Map<String, InputStream> attachments) throws SimExplorerStorageException {
+ Map<String, InputStream> attachments)
+ throws SimExplorerStorageException {
// Save all attachments in system
for (Map.Entry<String, InputStream> entry : attachments.entrySet()) {
@@ -149,6 +143,16 @@
database.insertElement(element, readers);
}
+ /**
+ * Find attachment.
+ *
+ * @param uniqueId
+ * the unique id
+ * @param attachments
+ * the attachments
+ *
+ * @return the attachment
+ */
private Attachment findAttachment(String uniqueId,
List<Attachment> attachments) {
for (Attachment attachment : attachments) {
@@ -270,7 +274,8 @@
/* (non-Javadoc)
* @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#storeTempData(java.io.InputStream)
*/
- public String storeTempData(InputStream stream) throws SimExplorerStorageException {
+ public String storeTempData(InputStream stream)
+ throws SimExplorerStorageException {
String id = UUID.randomUUID().toString();
attachmentHandler.storeData(mdTmp, id, stream);
return id;
@@ -279,7 +284,8 @@
/* (non-Javadoc)
* @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#retrieveTempData(java.lang.String)
*/
- public InputStream retrieveTempData(String id) throws SimExplorerStorageException {
+ public InputStream retrieveTempData(String id)
+ throws SimExplorerStorageException {
InputStream is = attachmentHandler.retrieveData(mdTmp, id);
return is;
}
@@ -291,6 +297,9 @@
attachmentHandler.deleteData(mdTmp, id);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#getElementVersions(java.lang.String, java.lang.String)
+ */
public Set<MetaData> getElementVersions(String token, String uuid)
throws SimExplorerStorageException {
return database.findElementsById(uuid, false);
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/Config.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/Config.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/Config.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -24,15 +24,28 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+/**
+ * The Class Config.
+ */
public class Config {
+ /** The Constant log. */
private static final Log log = LogFactory.getLog(Config.class);
+ /** The properties. */
private static Properties properties = null;
+
+ /** The properties location. */
private static String propertiesLocation = "/properties/config.properties";
+ /**
+ * Inits the properties.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
private static void initProperties() throws IOException {
- log.info("Loading properties "+propertiesLocation);
+ log.info("Loading properties " + propertiesLocation);
properties = new Properties();
@@ -46,6 +59,11 @@
}
}
+ /**
+ * Gets the properties.
+ *
+ * @return the properties
+ */
public static Properties getProperties() {
if (properties == null) {
try {
@@ -59,10 +77,22 @@
return properties;
}
+ /**
+ * Sets the properties.
+ *
+ * @param properties
+ * the new properties
+ */
public static void setProperties(Properties properties) {
Config.properties = properties;
}
+ /**
+ * Sets the properties location.
+ *
+ * @param propertiesLocation
+ * the new properties location
+ */
public static void setPropertiesLocation(String propertiesLocation) {
Config.propertiesLocation = propertiesLocation;
setProperties(null);
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/KeyValue.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/KeyValue.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/KeyValue.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -17,24 +17,51 @@
* ##% */
package fr.cemagref.simexplorer.is.storage.util;
+/**
+ * The Class KeyValue.
+ */
public class KeyValue {
+ /** The key. */
private String key;
+ /** The value. */
private String value;
+ /**
+ * Gets the key.
+ *
+ * @return the key
+ */
public String getKey() {
return key;
}
+ /**
+ * Sets the key.
+ *
+ * @param key
+ * the new key
+ */
public void setKey(String key) {
this.key = key;
}
+ /**
+ * Gets the value.
+ *
+ * @return the value
+ */
public String getValue() {
return value;
}
+ /**
+ * Sets the value.
+ *
+ * @param value
+ * the new value
+ */
public void setValue(String value) {
this.value = value;
}
Modified: trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/ZipStreamEncoder.java
===================================================================
--- trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/ZipStreamEncoder.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/util/ZipStreamEncoder.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -25,15 +25,31 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
+/**
+ * The Class ZipStreamEncoder.
+ */
public class ZipStreamEncoder extends Thread {
+ /** The Constant BUFFER. */
static final int BUFFER = 2048;
+ /** The files. */
private Map<String, InputStream> files;
+
+ /** The os. */
private PipedOutputStream os;
+ /** The zos. */
private ZipOutputStream zos;
+ /**
+ * Instantiates a new zip stream encoder.
+ *
+ * @param files
+ * the files
+ * @param os
+ * the os
+ */
public ZipStreamEncoder(Map<String, InputStream> files, PipedOutputStream os) {
super();
this.files = files;
@@ -44,6 +60,10 @@
zos.setLevel(Deflater.BEST_COMPRESSION);
}
+ /* (non-Javadoc)
+ * @see java.lang.Thread#run()
+ */
+ @Override
public void run() {
byte data[] = new byte[BUFFER];
try {
Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/VersionGeneratorTest.java
===================================================================
--- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/VersionGeneratorTest.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/VersionGeneratorTest.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -22,36 +22,65 @@
/**
* VersionGenerator Tester.
- *
+ *
* @author chemit
* @version 1.0
- * @since <pre>02/02/2008</pre>
+ * @since
+ *
+ * <pre>
+ * 02 / 02 / 2008
+ * </pre>
*/
public class VersionGeneratorTest extends TestCase {
+ /** The generator. */
VersionGenerator generator;
+ /**
+ * Instantiates a new version generator test.
+ *
+ * @param name
+ * the name
+ */
public VersionGeneratorTest(String name) {
super(name);
}
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
@Override
public void setUp() throws Exception {
super.setUp();
generator = VersionGenerator.getInstance();
}
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
@Override
public void tearDown() throws Exception {
super.tearDown();
generator = null;
}
+ /**
+ * Test generate version.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testGenerateVersion() throws Exception {
Version version = generator.generateVersion();
assertTrue(version.getLength() < VersionGenerator.MAX_SIZE);
}
+ /**
+ * Test generate versions.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testGenerateVersions() throws Exception {
Version[] version = generator.generateVersions();
assertTrue(version.length < VersionGenerator.MAX_NB_VERSIONS);
Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java
===================================================================
--- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -31,18 +31,40 @@
import fr.cemagref.simexplorer.is.storage.MetaDataGenerator;
import fr.cemagref.simexplorer.is.storage.util.Config;
+/**
+ * The Class LuceneDatabaseLoadMassTestCase.
+ */
public class LuceneDatabaseLoadMassTestCase extends TestCase {
+ /** The database. */
private Database database;
+
+ /** The r. */
private Random r = new Random();
+
+ /** The mdg. */
private MetaDataGenerator mdg = new MetaDataGenerator();
+ /** The strings init. */
private static boolean stringsInit = false;
+
+ /** The cs. */
private static int cs;
+
+ /** The randomstrings. */
private static String[] randomstrings;
+ /** The valid chars. */
private static String validChars = "abcdefghijklmnopqrstuvwxyz";
+ /**
+ * Generate string.
+ *
+ * @param length
+ * the length
+ *
+ * @return the string
+ */
private String generateString(int length) {
StringBuffer result = new StringBuffer();
@@ -54,6 +76,9 @@
return result.toString();
}
+ /**
+ * Initialize strings.
+ */
private void initializeStrings() {
if (!stringsInit) {
@@ -72,11 +97,20 @@
initializeStrings();
} */
+ /**
+ * Instantiates a new lucene database load mass test case.
+ *
+ * @param name
+ * the name
+ */
public LuceneDatabaseLoadMassTestCase(String name) {
super(name);
initializeStrings();
}
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -85,12 +119,21 @@
// database.open();
}
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
@Override
protected void tearDown() throws Exception {
super.tearDown();
database.close();
}
+ /**
+ * Test mass insert.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testMassInsert() throws Exception {
database.open(true);
@@ -149,6 +192,12 @@
System.out.println("Content size : " + contentSize);
}
+ /**
+ * Test mass search paginated.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testMassSearchPaginated() throws Exception {
database.open();
@@ -165,8 +214,8 @@
int start = count / 2;
int length = Math.min(200, Math.min(count, Math.max(1, count / 4)));
- Set<MetaData> metaDatas = database
- .findElementsByContentSearch(key, false, start, length, 1);
+ Set<MetaData> metaDatas = database.findElementsByContentSearch(key,
+ false, start, length, 1);
System.out.println(key + " (" + start + " " + length + ") : "
+ metaDatas.size());
Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java
===================================================================
--- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -35,14 +35,27 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+/**
+ * The Class LuceneDatabaseTestCase.
+ */
public class LuceneDatabaseTestCase extends TestCase {
- private static final Log log = LogFactory.getLog(LuceneDatabaseTestCase.class);
+ /** The Constant log. */
+ private static final Log log = LogFactory
+ .getLog(LuceneDatabaseTestCase.class);
+
+ /** The database. */
private Database database;
// private ElementGenerator elementGenerator;
+ /** The mdg. */
private MetaDataGenerator mdg = new MetaDataGenerator();
+
+ /** The r. */
private Random r = new Random();
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -52,12 +65,21 @@
// elementGenerator = new ElementGenerator();
}
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
@Override
protected void tearDown() throws Exception {
super.tearDown();
database.close();
}
+ /**
+ * Test insert element get element.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testInsertElementGetElement() throws Exception {
MetaData me = mdg.generateMetaDataEntity();
database.insertElement(me, new ArrayList<Reader>());
@@ -68,6 +90,12 @@
database.commit();
}
+ /**
+ * Test index add find elements by content search.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testIndexAddFindElementsByContentSearch() throws Exception {
MetaData me = mdg.generateMetaDataEntity();
@@ -88,6 +116,12 @@
assertEquals(1, mesCount);
}
+ /**
+ * Test get versions.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testGetVersions() throws Exception {
MetaData[] mes = mdg.generateVersionnedMetaDataEntity();
for (MetaData me : mes) {
@@ -100,10 +134,16 @@
Collections.sort(versions);
for (int i = 0; i < mes.length; i++) {
MetaData me = mes[i];
- assertEquals(me.getVersion(),versions.get(i));
+ assertEquals(me.getVersion(), versions.get(i));
}
}
+ /**
+ * Test find elements by id.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testFindElementsById() throws Exception {
MetaData[] mes = mdg.generateVersionnedMetaDataEntity();
for (MetaData me : mes) {
@@ -111,11 +151,17 @@
}
database.commit();
- Set<MetaData> elements = database.findElementsById(mes[0]
- .getUuid(), false);
+ Set<MetaData> elements = database.findElementsById(mes[0].getUuid(),
+ false);
assertEquals(elements.size(), mes.length);
}
+ /**
+ * Test find elements by properties.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testFindElementsByProperties() throws Exception {
MetaData me = mdg.generateMetaDataEntity();
@@ -123,18 +169,30 @@
database.commit();
}
+ /**
+ * Test delete elements.
+ */
public void testDeleteElements() {
log.warn("Not yet implemented");
}
+ /**
+ * Test delete element string version.
+ */
public void testDeleteElementStringVersion() {
log.warn("Not yet implemented");
}
+ /**
+ * Test get element latest version.
+ */
public void testGetElementLatestVersion() {
log.warn("Not yet implemented");
}
+ /**
+ * Test delete element meta data entity.
+ */
public void testDeleteElementMetaDataEntity() {
log.warn("Not yet implemented");
}
Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThread.java
===================================================================
--- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThread.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThread.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -26,14 +26,23 @@
import fr.cemagref.simexplorer.is.storage.database.Database;
import fr.cemagref.simexplorer.is.storage.MetaDataGenerator;
+/**
+ * The Class LuceneDatabaseThread.
+ */
public class LuceneDatabaseThread extends Thread {
+ /** The database. */
private Database database;
+
+ /** The id thread lucene. */
private int idThreadLucene;
+ /** The mdg. */
private MetaDataGenerator mdg = new MetaDataGenerator();
/**
+ * Gets the database.
+ *
* @return the database
*/
public Database getDatabase() {
@@ -41,6 +50,8 @@
}
/**
+ * Sets the database.
+ *
* @param database
* the database to set
*/
@@ -48,6 +59,9 @@
this.database = database;
}
+ /* (non-Javadoc)
+ * @see java.lang.Thread#run()
+ */
@Override
public void run() {
int npass = 10;
@@ -70,6 +84,15 @@
}
+ /**
+ * Search elements.
+ *
+ * @param id
+ * the id
+ *
+ * @throws Exception
+ * the exception
+ */
private void searchElements(String id) throws Exception {
Set<MetaData> mde = database.findElementsById(id, true);
if (mde.isEmpty()) {
@@ -77,6 +100,17 @@
}
}
+ /**
+ * Insert elements.
+ *
+ * @param ipass
+ * the ipass
+ *
+ * @return the string
+ *
+ * @throws Exception
+ * the exception
+ */
private String insertElements(int ipass) throws Exception {
String id = null;
@@ -97,6 +131,8 @@
}
/**
+ * Gets the id thread lucene.
+ *
* @return the idThreadLucene
*/
public int getIdThreadLucene() {
@@ -104,6 +140,8 @@
}
/**
+ * Sets the id thread lucene.
+ *
* @param idThreadLucene
* the idThreadLucene to set
*/
Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThreadsMassTestCase.java
===================================================================
--- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThreadsMassTestCase.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseThreadsMassTestCase.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -21,10 +21,17 @@
import fr.cemagref.simexplorer.is.storage.util.Config;
import junit.framework.TestCase;
+/**
+ * The Class LuceneDatabaseThreadsMassTestCase.
+ */
public class LuceneDatabaseThreadsMassTestCase extends TestCase {
+ /** The database. */
private Database database;
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -33,12 +40,21 @@
database.open(true);
}
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
@Override
protected void tearDown() throws Exception {
super.tearDown();
database.close();
}
+ /**
+ * Test lucene database threads.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testLuceneDatabaseThreads() throws Exception {
int nthreads = 5;
Modified: trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneSimpleTest.java
===================================================================
--- trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneSimpleTest.java 2008-02-04 14:46:14 UTC (rev 627)
+++ trunk/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneSimpleTest.java 2008-02-04 14:47:21 UTC (rev 628)
@@ -34,6 +34,9 @@
import java.io.File;
+/**
+ * The Class LuceneSimpleTest.
+ */
public class LuceneSimpleTest extends TestCase {
/*
@@ -46,12 +49,16 @@
* hits.doc(i); System.out.println(doc.get("simexplorer.creationdate")); }
* System.out.println(hits.length()); }
*/
- String indexDir="/tmp/indextest/";
+ /** The index dir. */
+ String indexDir = "/tmp/indextest/";
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
@Override
protected void tearDown() throws Exception {
super.tearDown();
- if (indexDir!=null) {
+ if (indexDir != null) {
File dir = new File(indexDir);
File[] files = dir.listFiles();
for (File file : files) {
@@ -61,6 +68,12 @@
}
}
+ /**
+ * Test lucene simple.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testLuceneSimple() throws Exception {
IndexWriter writer;
1
0
r627 - trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages
by tchemit@users.labs.libre-entreprise.org 04 Feb '08
by tchemit@users.labs.libre-entreprise.org 04 Feb '08
04 Feb '08
Author: tchemit
Date: 2008-02-04 14:46:14 +0000 (Mon, 04 Feb 2008)
New Revision: 627
Modified:
trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java
Log:
redundant initialize +unused local variables
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-02-04 14:39:44 UTC (rev 626)
+++ trunk/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementDetail.java 2008-02-04 14:46:14 UTC (rev 627)
@@ -222,7 +222,7 @@
List<TreeNode> children = new ArrayList<TreeNode>();
- TreeNode node = null;
+ TreeNode node;
node = initNode();
node.setColumns(generateStringArray("Constants",
@@ -258,7 +258,6 @@
Set<Library> libraries = component.getLibraries();
List<TreeNode> res = new ArrayList<TreeNode>();
- int i = 0;
for (Library library : libraries) {
TreeNode node = generateLibrary(library);
@@ -270,7 +269,6 @@
private TreeNode generateLibrary(Library library) {
TreeNode node = new TreeNode();
node.setType(TreeNode.TYPE_DOCUMENT);
-
node.setColumns(generateStringArray("Library", library
.getMetaData().getName(), library.getMetaData()
.getVersion().toString(), library.getMetaData(), true,
@@ -280,7 +278,6 @@
private List<TreeNode> generateCodes(Set<Code> codes) {
List<TreeNode> res = new ArrayList<TreeNode>();
- int i = 0;
for (Code code : codes) {
TreeNode node = new TreeNode();
node.setType(TreeNode.TYPE_DOCUMENT);
@@ -293,7 +290,6 @@
private List<TreeNode> generateStructures(Set<Structure> structures) {
List<TreeNode> res = new ArrayList<TreeNode>();
- int i = 0;
for (Structure structure : structures) {
TreeNode node = new TreeNode();
node.setType(TreeNode.TYPE_DOCUMENT);
@@ -305,7 +301,6 @@
private List<TreeNode> generateConstants(Set<Constant> constants) {
List<TreeNode> res = new ArrayList<TreeNode>();
- int i = 0;
for (Constant constant : constants) {
TreeNode node = new TreeNode();
node.setType(TreeNode.TYPE_DOCUMENT);
1
0
r626 - in trunk/simexplorer-is-service/src: java/fr/cemagref/simexplorer/is/service java/fr/cemagref/simexplorer/is/storage/engine test/fr/cemagref/simexplorer/is/service
by glandais@users.labs.libre-entreprise.org 04 Feb '08
by glandais@users.labs.libre-entreprise.org 04 Feb '08
04 Feb '08
Author: glandais
Date: 2008-02-04 14:39:44 +0000 (Mon, 04 Feb 2008)
New Revision: 626
Removed:
trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/
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/AuthenticationServiceImpl.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/MockAuthenticationServiceImpl.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java
trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.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/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/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java
trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityEqualsTestCase.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-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java
trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceTest.java
Log:
Javadoc
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationService.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -23,80 +23,397 @@
import fr.cemagref.simexplorer.is.security.entities.Permission;
import fr.cemagref.simexplorer.is.security.entities.User;
+/**
+ * The Interface AuthenticationService.
+ */
@Remote
public interface AuthenticationService {
+ /**
+ * Login user.
+ *
+ * @param login
+ * the login
+ * @param password
+ * the password
+ *
+ * @return the string
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public String loginUser(String login, String password)
throws SimExplorerServiceException;
+ /**
+ * Request account.
+ *
+ * @param login
+ * the login
+ * @param mail
+ * the mail
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void requestAccount(String login, String mail)
throws SimExplorerServiceException;
+ /**
+ * Save user.
+ *
+ * @param token
+ * the token
+ * @param login
+ * the login
+ * @param mail
+ * the mail
+ *
+ * @return the user
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public User saveUser(String token, String login, String mail)
throws SimExplorerServiceException;
+ /**
+ * Reset password.
+ *
+ * @param token
+ * the token
+ * @param login
+ * the login
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void resetPassword(String token, String login)
throws SimExplorerServiceException;
+ /**
+ * Change password.
+ *
+ * @param token
+ * the token
+ * @param password
+ * the password
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void changePassword(String token, String password)
throws SimExplorerServiceException;
+ /**
+ * Gets the user.
+ *
+ * @param token
+ * the token
+ * @param id
+ * the id
+ *
+ * @return the user
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public User getUser(String token, Integer id)
throws SimExplorerServiceException;
+ /**
+ * Gets the user.
+ *
+ * @param token
+ * the token
+ * @param login
+ * the login
+ *
+ * @return the user
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public User getUser(String token, String login)
throws SimExplorerServiceException;
+ /**
+ * Update user.
+ *
+ * @param token
+ * the token
+ * @param user
+ * the user
+ *
+ * @return the user
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public User updateUser(String token, User user)
throws SimExplorerServiceException;
+ /**
+ * Delete user.
+ *
+ * @param token
+ * the token
+ * @param id
+ * the id
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void deleteUser(String token, Integer id)
throws SimExplorerServiceException;
+ /**
+ * Gets the users.
+ *
+ * @param token
+ * the token
+ *
+ * @return the users
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public User[] getUsers(String token) throws SimExplorerServiceException;
+ /**
+ * Gets the users of group.
+ *
+ * @param token
+ * the token
+ * @param group
+ * the group
+ *
+ * @return the users of group
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public User[] getUsersOfGroup(String token, Group group)
throws SimExplorerServiceException;
+ /**
+ * Sets the users of group.
+ *
+ * @param token
+ * the token
+ * @param group
+ * the group
+ * @param usersInGroup
+ * the users in group
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void setUsersOfGroup(String token, Group group,
Integer[] usersInGroup) throws SimExplorerServiceException;
+ /**
+ * Sets the groups of group.
+ *
+ * @param token
+ * the token
+ * @param group
+ * the group
+ * @param groupsIds
+ * the groups ids
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void setGroupsOfGroup(String token, Group group, Integer[] groupsIds)
throws SimExplorerServiceException;
+ /**
+ * Gets the groups of user.
+ *
+ * @param token
+ * the token
+ * @param user
+ * the user
+ *
+ * @return the groups of user
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public Group[] getGroupsOfUser(String token, User user)
throws SimExplorerServiceException;
+ /**
+ * Gets the groups of group.
+ *
+ * @param token
+ * the token
+ * @param group
+ * the group
+ *
+ * @return the groups of group
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public Group[] getGroupsOfGroup(String token, Group group)
throws SimExplorerServiceException;
+ /**
+ * Sets the groups of user.
+ *
+ * @param token
+ * the token
+ * @param user
+ * the user
+ * @param groupsIds
+ * the groups ids
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void setGroupsOfUser(String token, User user, Integer[] groupsIds)
throws SimExplorerServiceException;
+ /**
+ * Save group.
+ *
+ * @param token
+ * the token
+ * @param name
+ * the name
+ *
+ * @return the group
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public Group saveGroup(String token, String name)
throws SimExplorerServiceException;
+ /**
+ * Gets the group.
+ *
+ * @param token
+ * the token
+ * @param id
+ * the id
+ *
+ * @return the group
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public Group getGroup(String token, Integer id)
throws SimExplorerServiceException;
+ /**
+ * Gets the group.
+ *
+ * @param token
+ * the token
+ * @param name
+ * the name
+ *
+ * @return the group
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public Group getGroup(String token, String name)
throws SimExplorerServiceException;
+ /**
+ * Update group.
+ *
+ * @param token
+ * the token
+ * @param group
+ * the group
+ *
+ * @return the group
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public Group updateGroup(String token, Group group)
throws SimExplorerServiceException;
+ /**
+ * Delete group.
+ *
+ * @param token
+ * the token
+ * @param id
+ * the id
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void deleteGroup(String token, Integer id)
throws SimExplorerServiceException;
+ /**
+ * Gets the groups.
+ *
+ * @param token
+ * the token
+ *
+ * @return the groups
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public Group[] getGroups(String token) throws SimExplorerServiceException;
+ /**
+ * Gets the groups owned by.
+ *
+ * @param token
+ * the token
+ * @param user
+ * the user
+ *
+ * @return the groups owned by
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public Group[] getGroupsOwnedBy(String token, User user)
throws SimExplorerServiceException;
+ /**
+ * Gets the logged user.
+ *
+ * @param token
+ * the token
+ *
+ * @return the logged user
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public User getLoggedUser(String token) throws SimExplorerServiceException;
+ /**
+ * Gets the permissions.
+ *
+ * @param uuid
+ * the uuid
+ *
+ * @return the permissions
+ */
public Permission[] getPermissions(String uuid);
+ /**
+ * Sets the permissions.
+ *
+ * @param uuid
+ * the uuid
+ * @param permissions
+ * the permissions
+ */
public void setPermissions(String uuid, Permission[] permissions);
}
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -27,10 +27,8 @@
import java.util.List;
import java.util.UUID;
-import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.Remote;
-import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
@@ -49,20 +47,32 @@
import fr.cemagref.simexplorer.is.security.entities.Permission;
import fr.cemagref.simexplorer.is.security.entities.User;
+/**
+ * The Class AuthenticationServiceImpl.
+ */
@Stateless(name = "AuthenticationService")
@Remote(AuthenticationService.class)
@RemoteBinding(jndiBinding = "AuthenticationService")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class AuthenticationServiceImpl implements AuthenticationService {
+ /** The dao. */
@EJB
private DaoSecurity dao;
- @Resource
- private SessionContext sessionContext;
-
+ /** The super admin check. */
private static boolean superAdminCheck = false;
+ /**
+ * Gets the mail content with password.
+ *
+ * @param login
+ * the login
+ * @param password
+ * the password
+ *
+ * @return the mail content with password
+ */
private String getMailContentWithPassword(String login, String password) {
StringBuffer sb = new StringBuffer("");
sb.append(_("simexplorer.service.mail.header")).append("\n");
@@ -74,6 +84,19 @@
return sb.toString();
}
+ /**
+ * Send mail.
+ *
+ * @param mail
+ * the mail
+ * @param subject
+ * the subject
+ * @param content
+ * the content
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
private void sendMail(String mail, String subject, String content)
throws SimExplorerServiceException {
try {
@@ -94,6 +117,17 @@
}
}
+ /**
+ * Compute hash.
+ *
+ * @param clearString
+ * the clear string
+ *
+ * @return the string
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
private String computeHash(String clearString)
throws SimExplorerServiceException {
MessageDigest messageDigest = null;
@@ -109,11 +143,29 @@
return hashedPassword;
}
+ /**
+ * Generate password.
+ *
+ * @return the string
+ */
private String generatePassword() {
// FIXME
return "password";
}
+ /**
+ * Can admin group.
+ *
+ * @param token
+ * the token
+ * @param id
+ * the id
+ *
+ * @return true, if successful
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
private boolean canAdminGroup(String token, Integer id)
throws SimExplorerServiceException {
User loggedUser = getLoggedUser(token);
@@ -128,6 +180,16 @@
return false;
}
+ /**
+ * User owner of group.
+ *
+ * @param loggedUser
+ * the logged user
+ * @param group
+ * the group
+ *
+ * @return true, if successful
+ */
private boolean userOwnerOfGroup(User loggedUser, Group group) {
if (group.getOwner().getId() == loggedUser.getId()) {
return true;
@@ -141,6 +203,19 @@
return false;
}
+ /**
+ * Can admin user.
+ *
+ * @param token
+ * the token
+ * @param id
+ * the id
+ *
+ * @return true, if successful
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
private boolean canAdminUser(String token, Integer id)
throws SimExplorerServiceException {
User loggedUser = getLoggedUser(token);
@@ -161,6 +236,14 @@
return false;
}
+ /**
+ * Removes the user from group.
+ *
+ * @param user
+ * the user
+ * @param group
+ * the group
+ */
private void removeUserFromGroup(User user, Group group) {
List<Group> toRemove = new ArrayList<Group>();
for (Group testGroup : user.getGroups()) {
@@ -173,6 +256,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#deleteGroup(java.lang.String, java.lang.Integer)
+ */
public void deleteGroup(String token, Integer id)
throws SimExplorerServiceException {
if (canAdminGroup(token, id)) {
@@ -182,6 +268,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#deleteUser(java.lang.String, java.lang.Integer)
+ */
public void deleteUser(String token, Integer id)
throws SimExplorerServiceException {
if (canAdminUser(token, id)) {
@@ -191,6 +280,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroup(java.lang.String, java.lang.Integer)
+ */
public Group getGroup(String token, Integer id)
throws SimExplorerServiceException {
if (canAdminGroup(token, id)) {
@@ -200,6 +292,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroup(java.lang.String, java.lang.String)
+ */
public Group getGroup(String token, String name)
throws SimExplorerServiceException {
Group group = dao.getGroup(name);
@@ -210,6 +305,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUser(java.lang.String, java.lang.Integer)
+ */
public User getUser(String token, Integer id)
throws SimExplorerServiceException {
if (canAdminUser(token, id)) {
@@ -219,6 +317,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUser(java.lang.String, java.lang.String)
+ */
public User getUser(String token, String login)
throws SimExplorerServiceException {
User user = dao.getUser(login);
@@ -229,6 +330,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#saveGroup(java.lang.String, java.lang.String)
+ */
public Group saveGroup(String token, String name)
throws SimExplorerServiceException {
User loggedUser = getLoggedUser(token);
@@ -244,6 +348,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#saveUser(java.lang.String, java.lang.String, java.lang.String)
+ */
public User saveUser(String token, String login, String mail)
throws SimExplorerServiceException {
User loggedUser = getLoggedUser(token);
@@ -266,6 +373,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#updateGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group)
+ */
public Group updateGroup(String token, Group group)
throws SimExplorerServiceException {
if (canAdminGroup(token, group.getId())) {
@@ -275,6 +385,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#updateUser(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User)
+ */
public User updateUser(String token, User user)
throws SimExplorerServiceException {
if (canAdminUser(token, user.getId())) {
@@ -284,6 +397,9 @@
_("simexplorer.service.security.norights"));
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getLoggedUser(java.lang.String)
+ */
public User getLoggedUser(String token) throws SimExplorerServiceException {
if (token == null || token.equals("")) {
return null;
@@ -297,6 +413,12 @@
_("simexplorer.service.security.norights"));
}
+ /**
+ * Check super admin.
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
private void checkSuperAdmin() throws SimExplorerServiceException {
if (dao.getUser("superadmin") == null) {
User user = new User();
@@ -311,6 +433,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#loginUser(java.lang.String, java.lang.String)
+ */
public String loginUser(String login, String password)
throws SimExplorerServiceException {
if (!superAdminCheck) {
@@ -332,6 +457,9 @@
return token;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#requestAccount(java.lang.String, java.lang.String)
+ */
public void requestAccount(String login, String mail)
throws SimExplorerServiceException {
// FIXME send mail to superadmin
@@ -348,6 +476,9 @@
*/
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#changePassword(java.lang.String, java.lang.String)
+ */
public void changePassword(String token, String password)
throws SimExplorerServiceException {
User user = getLoggedUser(token);
@@ -356,6 +487,9 @@
dao.updateUser(user);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#resetPassword(java.lang.String, java.lang.String)
+ */
public void resetPassword(String token, String login)
throws SimExplorerServiceException {
User user = getUser(token, login);
@@ -371,6 +505,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroups(java.lang.String)
+ */
public Group[] getGroups(String token) {
List<Group> groups = dao.getGroups();
Group[] result;
@@ -378,21 +515,33 @@
return result;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroupsOwnedBy(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User)
+ */
public Group[] getGroupsOwnedBy(String token, User user) {
List<Group> list = dao.getGroupsOwnedBy(user);
return list.toArray(new Group[list.size()]);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUsers(java.lang.String)
+ */
public User[] getUsers(String token) {
List<User> users = dao.getUsers();
return users.toArray(new User[users.size()]);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUsersOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group)
+ */
public User[] getUsersOfGroup(String token, Group group) {
List<User> usersOfGroup = dao.getUsersOfGroup(group);
return usersOfGroup.toArray(new User[usersOfGroup.size()]);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setUsersOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group, java.lang.Integer[])
+ */
public void setUsersOfGroup(String token, Group group,
Integer[] usersInGroup) {
List<Integer> newUsers = new ArrayList<Integer>();
@@ -431,6 +580,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setGroupsOfUser(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User, java.lang.Integer[])
+ */
public void setGroupsOfUser(String token, User user, Integer[] groupsIds) {
User realUser = dao.getUser(user.getId());
realUser.getGroups().clear();
@@ -442,16 +594,25 @@
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroupsOfUser(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User)
+ */
public Group[] getGroupsOfUser(String token, User user) {
List<Group> list = dao.getGroupsOfUser(user);
return list.toArray(new Group[list.size()]);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroupsOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group)
+ */
public Group[] getGroupsOfGroup(String token, Group group) {
List<Group> groupsOfGroup = dao.getGroupsOfGroup(group);
return groupsOfGroup.toArray(new Group[groupsOfGroup.size()]);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setGroupsOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group, java.lang.Integer[])
+ */
public void setGroupsOfGroup(String token, Group group, Integer[] groupsIds) {
Group realGroup = dao.getGroup(group.getId());
realGroup.getGroups().clear();
@@ -462,11 +623,17 @@
dao.updateGroup(realGroup);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getPermissions(java.lang.String)
+ */
public Permission[] getPermissions(String uuid) {
List<Permission> permissions = dao.getPermissions(uuid);
return permissions.toArray(new Permission[permissions.size()]);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setPermissions(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Permission[])
+ */
public void setPermissions(String uuid, Permission[] permissions) {
dao.setPermissions(uuid, permissions);
}
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -46,22 +46,42 @@
import fr.cemagref.simexplorer.is.entities.metadata.Version;
import fr.cemagref.simexplorer.is.factories.BaseEntityFactory;
+/**
+ * The Class ElementGenerator.
+ */
public class ElementGenerator {
+ /** The r. */
private Random r = new Random();
+ /** The cs. */
private static int cs;
+
+ /** The randomstrings. */
private static String[] randomstrings;
+ /**
+ * Instantiates a new element generator.
+ */
public ElementGenerator() {
super();
initializeStrings();
}
+ /**
+ * Short string.
+ *
+ * @return the string
+ */
private String shortString() {
return RandomStringUtils.randomAlphabetic(r.nextInt(5) + 5);
}
+ /**
+ * Long string.
+ *
+ * @return the string
+ */
private String longString() {
/*
StringBuilder sb = new StringBuilder();
@@ -75,6 +95,9 @@
return RandomStringUtils.randomAlphabetic(r.nextInt(10) + 10);
}
+ /**
+ * Initialize strings.
+ */
private void initializeStrings() {
cs = 150000;
randomstrings = new String[cs];
@@ -83,6 +106,15 @@
}
}
+ /**
+ * Update.
+ *
+ * @param element
+ * the element
+ *
+ * @throws Exception
+ * the exception
+ */
private void update(LoggableElement element) throws Exception {
MetaData metaData = new MetaData();
metaData.setUuid(UUID.randomUUID().toString());
@@ -116,6 +148,20 @@
element.setMetaData(metaData);
}
+ /**
+ * Generate array.
+ *
+ * @param <T>
+ * clazz Class
+ *
+ * @param clazz
+ * the clazz
+ *
+ * @return the set< t>
+ *
+ * @throws Exception
+ * the exception
+ */
private <T extends DataEntity> Set<T> generateArray(Class<T> clazz)
throws Exception {
Set<T> elements = new HashSet<T>();
@@ -131,6 +177,14 @@
return elements;
}
+ /**
+ * Generate random ea.
+ *
+ * @return the exploration application
+ *
+ * @throws Exception
+ * the exception
+ */
public ExplorationApplication generateRandomEA() throws Exception {
ExplorationApplication ea = new ExplorationApplication();
update(ea);
@@ -147,6 +201,15 @@
return ea;
}
+ /**
+ * Process component.
+ *
+ * @param component
+ * the component
+ *
+ * @throws Exception
+ * the exception
+ */
private void processComponent(Component component) throws Exception {
Set<Constant> constants = generateArray(Constant.class);
for (Constant constant : constants) {
@@ -170,6 +233,14 @@
}
+ /**
+ * Generate attachment.
+ *
+ * @return the attachment
+ *
+ * @throws Exception
+ * the exception
+ */
private Attachment generateAttachment() throws Exception {
Attachment attachment = new Attachment();
attachment.setContentType(ContentTypeFactory
@@ -179,20 +250,50 @@
return attachment;
}
+ /**
+ * Process library.
+ *
+ * @param library
+ * the library
+ *
+ * @throws Exception
+ * the exception
+ */
private void processLibrary(Library library) throws Exception {
library.getMetaData().getAttachments().add(generateAttachment());
}
+ /**
+ * Process code.
+ *
+ * @param code
+ * the code
+ */
private void processCode(Code code) {
code.setCode(shortString());
code.setLanguage(shortString());
}
+ /**
+ * Process constant.
+ *
+ * @param constant
+ * the constant
+ */
private void processConstant(Constant constant) {
constant.setName(shortString());
constant.setType(String.class);
}
+ /**
+ * Process exploration data.
+ *
+ * @param explorationData
+ * the exploration data
+ *
+ * @throws Exception
+ * the exception
+ */
private void processExplorationData(ExplorationData explorationData)
throws Exception {
Result result = new Result();
@@ -208,6 +309,12 @@
}
+ /**
+ * Process constant value.
+ *
+ * @param constantValue
+ * the constant value
+ */
private void processConstantValue(ConstantValue constantValue) {
Constant constant = new Constant();
constant.setName(shortString());
@@ -217,6 +324,14 @@
constantValue.setValue(Integer.toString(r.nextInt()));
}
+ /**
+ * Generate text stream.
+ *
+ * @return the input stream
+ *
+ * @throws Exception
+ * the exception
+ */
public InputStream generateTextStream() throws Exception {
int wordcount = 300 + r.nextInt(300);
StringBuffer sb = new StringBuffer();
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockAuthenticationServiceImpl.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -21,118 +21,210 @@
import fr.cemagref.simexplorer.is.security.entities.Permission;
import fr.cemagref.simexplorer.is.security.entities.User;
+/**
+ * The Class MockAuthenticationServiceImpl.
+ */
public class MockAuthenticationServiceImpl implements AuthenticationService {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#loginUser(java.lang.String, java.lang.String)
+ */
public String loginUser(String login, String password) {
return (String) checkImplemented();
}
+ /**
+ * Close session timer.
+ *
+ * @param token
+ * the token
+ */
public void closeSessionTimer(String token) {
checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#requestAccount(java.lang.String, java.lang.String)
+ */
public void requestAccount(String login, String mail) {
checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#saveUser(java.lang.String, java.lang.String, java.lang.String)
+ */
public User saveUser(String token, String login, String mail) {
return (User) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#resetPassword(java.lang.String, java.lang.String)
+ */
public void resetPassword(String token, String login) {
checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#changePassword(java.lang.String, java.lang.String)
+ */
public void changePassword(String token, String password) {
checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUser(java.lang.String, java.lang.Integer)
+ */
public User getUser(String token, Integer id) {
return (User) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUser(java.lang.String, java.lang.String)
+ */
public User getUser(String token, String login) {
return (User) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#updateUser(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User)
+ */
public User updateUser(String token, User user) {
return (User) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#deleteUser(java.lang.String, java.lang.Integer)
+ */
public void deleteUser(String token, Integer id) {
checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUsers(java.lang.String)
+ */
public User[] getUsers(String token) {
return (User[]) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getUsersOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group)
+ */
public User[] getUsersOfGroup(String token, Group group) {
return (User[]) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setUsersOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group, java.lang.Integer[])
+ */
public void setUsersOfGroup(String token, Group group,
Integer[] usersInGroup) {
checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setGroupsOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group, java.lang.Integer[])
+ */
public void setGroupsOfGroup(String token, Group group, Integer[] groupsIds) {
checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroupsOfUser(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User)
+ */
public Group[] getGroupsOfUser(String token, User user) {
return (Group[]) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroupsOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group)
+ */
public Group[] getGroupsOfGroup(String token, Group group) {
return (Group[]) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setGroupsOfUser(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User, java.lang.Integer[])
+ */
public void setGroupsOfUser(String token, User user, Integer[] groupsIds) {
checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#saveGroup(java.lang.String, java.lang.String)
+ */
public Group saveGroup(String token, String name) {
return (Group) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroup(java.lang.String, java.lang.Integer)
+ */
public Group getGroup(String token, Integer id) {
return (Group) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroup(java.lang.String, java.lang.String)
+ */
public Group getGroup(String token, String name) {
return (Group) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#updateGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group)
+ */
public Group updateGroup(String token, Group group) {
return (Group) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#deleteGroup(java.lang.String, java.lang.Integer)
+ */
public void deleteGroup(String token, Integer id) {
checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroups(java.lang.String)
+ */
public Group[] getGroups(String token) {
return (Group[]) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getGroupsOwnedBy(java.lang.String, fr.cemagref.simexplorer.is.security.entities.User)
+ */
public Group[] getGroupsOwnedBy(String token, User user) {
return (Group[]) checkImplemented();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getLoggedUser(java.lang.String)
+ */
public User getLoggedUser(String token) {
return (User) checkImplemented();
}
+ /**
+ * Check implemented.
+ *
+ * @return the object
+ */
private Object checkImplemented() {
throw new IllegalStateException("not implemented");
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#getPermissions(java.lang.String)
+ */
public Permission[] getPermissions(String uuid) {
// TODO Auto-generated method stub
return null;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setPermissions(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Permission[])
+ */
public void setPermissions(String uuid, Permission[] permissions) {
// TODO Auto-generated method stub
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -31,18 +31,33 @@
import java.util.SortedMap;
import java.util.TreeMap;
-/** @author tony */
+/**
+ * The Class MockStorageServiceImpl.
+ *
+ * @author tony
+ */
public class MockStorageServiceImpl implements StorageService {
+ /** The Constant SIZE. */
static final int SIZE = 400;
+ /** The mock data. */
protected SortedMap<String, MetaData> mockData;
+ /** The mock data index. */
protected List<String> mockDataIndex;
+ /** The meta generator. */
protected MetaDataGenerator metaGenerator;
+
+ /** The generator. */
protected ElementGenerator generator;
+ /**
+ * Mock data.
+ *
+ * @return the sorted map< string, meta data>
+ */
public SortedMap<String, MetaData> mockData() {
if (mockData == null) {
mockData = new TreeMap<String, MetaData>();
@@ -58,57 +73,113 @@
return mockData;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#commit()
+ */
public void commit() throws SimExplorerServiceException {
checkImplemented();
}
+ /**
+ * Check implemented.
+ *
+ * @return the object
+ */
private Object checkImplemented() {
throw new IllegalStateException("not implemented");
}
- public MetaData saveElement(String token, RemoteInputStream zipRemoteStream) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#saveElement(java.lang.String, com.healthmarketscience.rmiio.RemoteInputStream)
+ */
+ public MetaData saveElement(String token, RemoteInputStream zipRemoteStream)
+ throws SimExplorerServiceException {
return (MetaData) checkImplemented();
}
- public MetaData saveElement(String token, RemoteInputStream xmlRemoteStream, Map<String, RemoteInputStream> attachmentsRemoteStream) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#saveElement(java.lang.String, com.healthmarketscience.rmiio.RemoteInputStream, java.util.Map)
+ */
+ public MetaData saveElement(String token,
+ RemoteInputStream xmlRemoteStream,
+ Map<String, RemoteInputStream> attachmentsRemoteStream)
+ throws SimExplorerServiceException {
return (MetaData) checkImplemented();
}
- public MetaData getMetadata(String token, String uuid) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#getMetadata(java.lang.String, java.lang.String)
+ */
+ public MetaData getMetadata(String token, String uuid)
+ throws SimExplorerServiceException {
return mockData().get(uuid);
}
- public MetaData getMetadata(String token, String uuid, String version) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#getMetadata(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public MetaData getMetadata(String token, String uuid, String version)
+ throws SimExplorerServiceException {
return mockData().get(uuid);
}
- public RemoteInputStream exportElement(String token, String uuid, String version) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#exportElement(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public RemoteInputStream exportElement(String token, String uuid,
+ String version) throws SimExplorerServiceException {
return (RemoteInputStream) checkImplemented();
}
- public RemoteInputStream exportFull(String token, String uuid, String version) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#exportFull(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public RemoteInputStream exportFull(String token, String uuid,
+ String version) throws SimExplorerServiceException {
return (RemoteInputStream) checkImplemented();
}
-
- public RemoteInputStream retrieveData(String token, String uuid, String version, String dataKey) throws SimExplorerServiceException {
+
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#retrieveData(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+ */
+ public RemoteInputStream retrieveData(String token, String uuid,
+ String version, String dataKey) throws SimExplorerServiceException {
return null;
}
- public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerServiceException {
- //TODO Changer
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#findFullTextCount(java.lang.String, java.lang.String, boolean)
+ */
+ public int findFullTextCount(String token, String query, boolean onlyLatest)
+ throws SimExplorerServiceException {
+ // TODO Changer
return findApplicationsCount(token, onlyLatest);
}
- public MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, int dateOrder) throws SimExplorerServiceException {
- //TODO Changer
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#findFullText(java.lang.String, java.lang.String, boolean, int, int, int)
+ */
+ public MetaData[] findFullText(String token, String query,
+ boolean onlyLatest, int indexStart, int count, int dateOrder)
+ throws SimExplorerServiceException {
+ // TODO Changer
return findApplications(token, onlyLatest, indexStart, count, dateOrder);
}
- public int findApplicationsCount(String token, boolean onlyLatest) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#findApplicationsCount(java.lang.String, boolean)
+ */
+ public int findApplicationsCount(String token, boolean onlyLatest)
+ throws SimExplorerServiceException {
return mockData().size();
}
- public MetaData[] findApplications(String token, boolean onlyLatest, int start, int count, int dateOrder) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#findApplications(java.lang.String, boolean, int, int, int)
+ */
+ public MetaData[] findApplications(String token, boolean onlyLatest,
+ int start, int count, int dateOrder)
+ throws SimExplorerServiceException {
int last = start + count;
System.out.println("ask data from " + start + " width:" + count);
SortedMap<String, MetaData> map = mockData();
@@ -123,9 +194,14 @@
return result;
}
- public LoggableElement getElement(String token, String uuid, String version) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#getElement(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public LoggableElement getElement(String token, String uuid, String version)
+ throws SimExplorerServiceException {
try {
- ExplorationApplication explorationApplication = getGenerator().generateRandomEA();
+ ExplorationApplication explorationApplication = getGenerator()
+ .generateRandomEA();
explorationApplication.getMetaData().setUuid(uuid);
explorationApplication.getMetaData().setVersion(version);
return explorationApplication;
@@ -134,10 +210,14 @@
}
}
- public MetaData[] getVersions(String token, String uuid) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#getVersions(java.lang.String, java.lang.String)
+ */
+ public MetaData[] getVersions(String token, String uuid)
+ throws SimExplorerServiceException {
MetaData meta = mockData().get(uuid);
Version version;
- if (meta==null) {
+ if (meta == null) {
version = Version.valueOf("1.0");
} else {
version = meta.getVersion();
@@ -145,13 +225,23 @@
return getMetaGenerator().generateVersionnedMetaData(version);
}
- public String loginUser(String login, String password) throws SimExplorerServiceException {
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#loginUser(java.lang.String, java.lang.String)
+ */
+ public String loginUser(String login, String password)
+ throws SimExplorerServiceException {
if (login == null) {
- throw new SimExplorerServiceException(new NullPointerException("login can not be null"));
+ throw new SimExplorerServiceException(new NullPointerException(
+ "login can not be null"));
}
return "password";
}
+ /**
+ * Gets the generator.
+ *
+ * @return the generator
+ */
protected ElementGenerator getGenerator() {
if (generator == null) {
generator = new ElementGenerator();
@@ -159,6 +249,11 @@
return generator;
}
+ /**
+ * Gets the meta generator.
+ *
+ * @return the meta generator
+ */
public MetaDataGenerator getMetaGenerator() {
if (metaGenerator == null) {
metaGenerator = new MetaDataGenerator();
@@ -166,11 +261,17 @@
return metaGenerator;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#deleteElement(java.lang.String, java.lang.String, java.lang.String)
+ */
public void deleteElement(String token, String uuid, String version) {
// TODO Auto-generated method stub
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#deleteElement(java.lang.String, java.lang.String)
+ */
public void deleteElement(String token, String uuid) {
// TODO Auto-generated method stub
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java 2008-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/SimExplorerServiceException.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -20,23 +20,49 @@
/**
* Exception de base pour toute erreur rencontrée dans un service.
- *
+ *
* @author chemit
*/
public class SimExplorerServiceException extends Exception {
+
+ /** The Constant serialVersionUID. */
private static final long serialVersionUID = 1054522404126322604L;
+ /**
+ * Instantiates a new sim explorer service exception.
+ */
public SimExplorerServiceException() {
+ // nothing yet
}
+ /**
+ * Instantiates a new sim explorer service exception.
+ *
+ * @param cause
+ * the cause
+ */
public SimExplorerServiceException(Throwable cause) {
super(cause);
}
+ /**
+ * Instantiates a new sim explorer service exception.
+ *
+ * @param message
+ * the message
+ */
public SimExplorerServiceException(String message) {
super(message);
}
+ /**
+ * Instantiates a new sim explorer service exception.
+ *
+ * @param message
+ * the message
+ * @param cause
+ * the cause
+ */
public SimExplorerServiceException(String message, Throwable cause) {
super(message, cause);
}
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -27,7 +27,7 @@
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
/**
- * Service interface
+ * Service interface.
*
* @author glandais
*/
@@ -35,201 +35,296 @@
public interface StorageService {
/**
- * Commit in storage
+ * Commit in storage.
*
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
void commit() throws SimExplorerServiceException;
/**
- * Login user onto system Not used for local usages
+ * Login user onto system Not used for local usages.
*
* @param login
* Login
* @param password
* Password
+ *
* @return Token as logon evidence
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
String loginUser(String login, String password)
throws SimExplorerServiceException;
/**
- * Save a remote element
+ * Save a remote element.
*
* @param token
+ * the token
* @param zipRemoteStream
* RIIO stream containing data inside a zip
+ *
* @return Metadata of element imported
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
MetaData saveElement(String token, RemoteInputStream zipRemoteStream)
throws SimExplorerServiceException;
/**
- * Save a remote element
+ * Save a remote element.
*
* @param token
+ * the token
* @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
+ * the sim explorer service exception
*/
MetaData saveElement(String token, RemoteInputStream xmlRemoteStream,
Map<String, RemoteInputStream> attachmentsRemoteStream)
throws SimExplorerServiceException;
/**
- * Retrieve metadata (latest version)
+ * Retrieve metadata (latest version).
*
* @param token
+ * the token
* @param uuid
- * @return
+ * the uuid
+ *
+ * @return the metadata
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
MetaData getMetadata(String token, String uuid)
throws SimExplorerServiceException;
/**
- * Retrieve metadata
+ * Retrieve metadata.
*
* @param token
+ * the token
* @param uuid
+ * the uuid
* @param version
- * @return
+ * the version
+ *
+ * @return the metadata
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
MetaData getMetadata(String token, String uuid, String version)
throws SimExplorerServiceException;
/**
- * Export XML of element to a remote stream
+ * Export XML of element to a remote stream.
*
* @param token
+ * the token
* @param uuid
+ * the uuid
* @param version
+ * the version
+ *
* @return RMIIO stream with data
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
RemoteInputStream exportElement(String token, String uuid, String version)
throws SimExplorerServiceException;
/**
- * Export full element to a remote stream as a zip
+ * Export full element to a remote stream as a zip.
*
* @param token
+ * the token
* @param uuid
+ * the uuid
* @param version
+ * the version
+ *
* @return RMIIO stream with data
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
RemoteInputStream exportFull(String token, String uuid, String version)
throws SimExplorerServiceException;
/**
- * Retrieve data related to an entity
+ * Retrieve data related to an entity.
*
* @param token
+ * the token
* @param uuid
+ * the uuid
* @param version
+ * the version
* @param dataKey
- * @return
+ * the data key
+ *
+ * @return the remote input stream
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
RemoteInputStream retrieveData(String token, String uuid, String version,
String dataKey) throws SimExplorerServiceException;
/**
- * Retrieve number of elements matching query
+ * Retrieve number of elements matching query.
*
* @param token
+ * the token
* @param query
+ * the query
* @param onlyLatest
- * @return
+ * the only latest
+ *
+ * @return the int
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
int findFullTextCount(String token, String query, boolean onlyLatest)
throws SimExplorerServiceException;
/**
- * Find elements matching query
+ * Find elements matching query.
*
* @param token
+ * the token
* @param query
+ * the query
* @param onlyLatest
+ * the only latest
* @param indexStart
+ * the index start
* @param count
+ * the count
* @param dateOrder
- * @return
+ * the date order
+ *
+ * @return the meta data[]
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
- MetaData[] findFullText(String token, String query,
- boolean onlyLatest, int indexStart, int count, int dateOrder)
+ MetaData[] findFullText(String token, String query, boolean onlyLatest,
+ int indexStart, int count, int dateOrder)
throws SimExplorerServiceException;
/**
- * Retrieve number of applications
+ * Retrieve number of applications.
*
* @param token
+ * the token
* @param onlyLatest
- * @return
+ * the only latest
+ *
+ * @return the int
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
int findApplicationsCount(String token, boolean onlyLatest)
throws SimExplorerServiceException;
/**
- * Get a list of applications
+ * Get a list of applications.
*
* @param token
+ * the token
* @param onlyLatest
+ * the only latest
* @param start
+ * the start
* @param count
+ * the count
* @param dateOrder
- * @return
+ * the date order
+ *
+ * @return the meta data[]
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
- MetaData[] findApplications(String token, boolean onlyLatest,
- int start, int count, int dateOrder)
- throws SimExplorerServiceException;
+ MetaData[] findApplications(String token, boolean onlyLatest, int start,
+ int count, int dateOrder) throws SimExplorerServiceException;
/**
- * Fully load an element
+ * Fully load an element.
*
* @param token
+ * the token
* @param uuid
+ * the uuid
* @param version
- * @return
+ * the version
+ *
+ * @return the element
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
LoggableElement getElement(String token, String uuid, String version)
throws SimExplorerServiceException;
/**
- * Get all version of an element
+ * Get all version of an element.
*
* @param token
+ * the token
* @param uuid
- * @return
+ * the uuid
+ *
+ * @return the versions
+ *
* @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
MetaData[] getVersions(String token, String uuid)
throws SimExplorerServiceException;
/**
+ * Delete element.
+ *
* @param token
+ * the token
* @param uuid
+ * the uuid
* @param version
+ * the version
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
void deleteElement(String token, String uuid, String version)
throws SimExplorerServiceException;
/**
+ * Delete element.
+ *
* @param token
+ * the token
* @param uuid
+ * the uuid
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
*/
void deleteElement(String token, String uuid)
throws SimExplorerServiceException;
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceClient.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -21,17 +21,28 @@
import fr.cemagref.simexplorer.is.storage.engine.StorageEngine;
import fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl;
+/**
+ * The Class StorageServiceClient.
+ */
public class StorageServiceClient extends StorageServiceCommon {
+ /** The storage engine. */
private static StorageEngine storageEngine;
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#loginUser(java.lang.String, java.lang.String)
+ */
public String loginUser(String login, String password)
throws SimExplorerServiceException {
throw new SimExplorerServiceException("can not log to local service");
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageServiceCommon#getStorageEngine()
+ */
@Override
- protected StorageEngine getStorageEngine() throws SimExplorerStorageException {
+ protected StorageEngine getStorageEngine()
+ throws SimExplorerStorageException {
if (storageEngine == null) {
storageEngine = new StorageEngineImpl();
storageEngine.open();
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -48,17 +48,39 @@
import fr.cemagref.simexplorer.is.storage.engine.StorageEngine;
import fr.cemagref.simexplorer.is.storage.util.ZipStreamEncoder;
+/**
+ * The Class StorageServiceCommon.
+ */
public abstract class StorageServiceCommon implements StorageService,
XmlConstants {
+ /** The Constant KEY_XML. */
private static final String KEY_XML = "_xml";
- protected abstract StorageEngine getStorageEngine() throws SimExplorerStorageException;
+ /**
+ * Gets the storage engine.
+ *
+ * @return the storage engine
+ *
+ * @throws SimExplorerStorageException
+ * the sim explorer storage exception
+ */
+ protected abstract StorageEngine getStorageEngine()
+ throws SimExplorerStorageException;
+ /**
+ * Close.
+ *
+ * @throws Exception
+ * the exception
+ */
public void close() throws Exception {
getStorageEngine().close();
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#commit()
+ */
public void commit() throws SimExplorerServiceException {
try {
getStorageEngine().commit();
@@ -67,6 +89,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#saveElement(java.lang.String, com.healthmarketscience.rmiio.RemoteInputStream)
+ */
public MetaData saveElement(String token, RemoteInputStream zipRemoteStream)
throws SimExplorerServiceException {
InputStream zipStream;
@@ -78,6 +103,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#saveElement(java.lang.String, com.healthmarketscience.rmiio.RemoteInputStream, java.util.Map)
+ */
public MetaData saveElement(String token,
RemoteInputStream xmlRemoteStream,
Map<String, RemoteInputStream> attachmentsRemoteStream)
@@ -98,6 +126,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#getMetadata(java.lang.String, java.lang.String)
+ */
public MetaData getMetadata(String token, String uuid)
throws SimExplorerServiceException {
try {
@@ -107,6 +138,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#getMetadata(java.lang.String, java.lang.String, java.lang.String)
+ */
public MetaData getMetadata(String token, String uuid, String version)
throws SimExplorerServiceException {
try {
@@ -117,6 +151,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#findFullText(java.lang.String, java.lang.String, boolean, int, int, int)
+ */
public MetaData[] findFullText(String token, String query,
boolean onlyLatest, int indexStart, int count, int dateOrder)
throws SimExplorerServiceException {
@@ -128,6 +165,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#findFullTextCount(java.lang.String, java.lang.String, boolean)
+ */
public int findFullTextCount(String token, String query, boolean onlyLatest)
throws SimExplorerServiceException {
try {
@@ -138,6 +178,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#findApplicationsCount(java.lang.String, boolean)
+ */
public int findApplicationsCount(String token, boolean onlyLatest)
throws SimExplorerServiceException {
try {
@@ -148,6 +191,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#findApplications(java.lang.String, boolean, int, int, int)
+ */
public MetaData[] findApplications(String token, boolean onlyLatest,
int start, int count, int dateOrder)
throws SimExplorerServiceException {
@@ -160,6 +206,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#getElement(java.lang.String, java.lang.String, java.lang.String)
+ */
public LoggableElement getElement(String token, String uuid, String version)
throws SimExplorerServiceException {
MetaData mde = getMetadata(token, uuid, version);
@@ -177,6 +226,19 @@
}
}
+ /**
+ * Save element.
+ *
+ * @param token
+ * the token
+ * @param zipStream
+ * the zip stream
+ *
+ * @return the meta data
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
private MetaData saveElement(String token, InputStream zipStream)
throws SimExplorerServiceException {
String xmlFile = null;
@@ -213,6 +275,21 @@
}
}
+ /**
+ * Save element.
+ *
+ * @param token
+ * the token
+ * @param xmlFile
+ * the xml file
+ * @param attachments
+ * the attachments
+ *
+ * @return the meta data
+ *
+ * @throws Exception
+ * the exception
+ */
private MetaData saveElement(String token, InputStream xmlFile,
Map<String, InputStream> attachments) throws Exception {
// Store temporary data
@@ -231,6 +308,9 @@
return elementSaved;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#retrieveData(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+ */
public RemoteInputStream retrieveData(String token, String uuid,
String version, String dataKey) throws SimExplorerServiceException {
try {
@@ -247,6 +327,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#exportElement(java.lang.String, java.lang.String, java.lang.String)
+ */
public RemoteInputStream exportElement(String token, String uuid,
String version) throws SimExplorerServiceException {
MetaData mde = getMetadata(token, uuid, version);
@@ -264,6 +347,9 @@
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#exportFull(java.lang.String, java.lang.String, java.lang.String)
+ */
public RemoteInputStream exportFull(String token, String uuid,
String version) throws SimExplorerServiceException {
LoggableElement element = getElement(token, uuid, version);
@@ -304,18 +390,25 @@
}
/**
- * Real implementation of saveElement
+ * Real implementation of saveElement.
*
* @param token
+ * the token
* @param idxml
+ * the idxml
* @param idsattachment
- * @return
+ * the idsattachment
+ *
+ * @return the meta data
+ *
* @throws Exception
+ * the exception
*/
private MetaData saveElement(String token, String idxml,
Map<String, String> idsattachment) throws Exception {
// Load metadata xml
- MetaDataFactory mdeFactory = MetaDataFactory.getFactory(MetaData.class);
+ MetaDataFactory<MetaData> mdeFactory = MetaDataFactory
+ .getFactory(MetaData.class);
MetaData metaData = mdeFactory
.loadElementFromParentXML(getStorageEngine().retrieveTempData(
idxml));
@@ -359,6 +452,23 @@
return metaData;
}
+ /**
+ * Save sub elements.
+ *
+ * @param token
+ * the token
+ * @param idxml
+ * the idxml
+ * @param entitiesNode
+ * the entities node
+ * @param entityNode
+ * the entity node
+ * @param idsattachment
+ * the idsattachment
+ *
+ * @throws Exception
+ * the exception
+ */
private void saveSubElements(String token, String idxml,
String entitiesNode, String entityNode,
Map<String, String> idsattachment) throws Exception {
@@ -385,6 +495,17 @@
}
+ /**
+ * Process version rules.
+ *
+ * @param token
+ * the token
+ * @param metaData
+ * the meta data
+ *
+ * @throws Exception
+ * the exception
+ */
private void processVersionRules(String token, MetaData metaData)
throws Exception {
@@ -408,6 +529,9 @@
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#getVersions(java.lang.String, java.lang.String)
+ */
public MetaData[] getVersions(String token, String uuid)
throws SimExplorerServiceException {
try {
@@ -419,6 +543,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#deleteElement(java.lang.String, java.lang.String, java.lang.String)
+ */
public void deleteElement(String token, String uuid, String version)
throws SimExplorerServiceException {
try {
@@ -428,6 +555,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#deleteElement(java.lang.String, java.lang.String)
+ */
public void deleteElement(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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceServer.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -27,25 +27,37 @@
import fr.cemagref.simexplorer.is.storage.engine.StorageEngine;
import fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl;
+/**
+ * The Class StorageServiceServer.
+ */
@Stateless(name = "StorageService")
@Remote(StorageService.class)
@RemoteBinding(jndiBinding = "StorageService")
public class StorageServiceServer extends StorageServiceCommon {
+ /** The authentication service. */
@EJB
private AuthenticationService authenticationService;
+ /** The storage engine. */
@EJB
private StorageEngine storageEngine;
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageService#loginUser(java.lang.String, java.lang.String)
+ */
public String loginUser(String login, String password)
throws SimExplorerServiceException {
String token = authenticationService.loginUser(login, password);
return token;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.service.StorageServiceCommon#getStorageEngine()
+ */
@Override
- protected StorageEngine getStorageEngine() throws SimExplorerStorageException {
+ protected StorageEngine getStorageEngine()
+ throws SimExplorerStorageException {
storageEngine.open();
return storageEngine;
}
Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java
===================================================================
--- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java 2008-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -31,13 +31,20 @@
import fr.cemagref.simexplorer.is.security.entities.Permission;
import fr.cemagref.simexplorer.is.storage.SimExplorerStorageException;
+/**
+ * The Class StorageEngineSecuImpl.
+ */
@Stateless(name = "StorageEngine")
@Local(StorageEngine.class)
public class StorageEngineSecuImpl extends StorageEngineImpl {
+ /** The credential manager. */
@EJB
private CredentialManager credentialManager;
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#deleteElement(java.lang.String, java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version)
+ */
@Override
public void deleteElement(String token, String uuid, Version version)
throws SimExplorerStorageException {
@@ -50,6 +57,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#deleteElements(java.lang.String, java.lang.String)
+ */
@Override
public void deleteElements(String token, String uuid)
throws SimExplorerStorageException {
@@ -62,6 +72,9 @@
}
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#findElementsByType(java.lang.String, java.lang.String, boolean, int, int, int)
+ */
@Override
public MetaData[] findElementsByType(String token, String type,
boolean onlyLatest, int start, int count, int dateOrder)
@@ -73,6 +86,9 @@
return list;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#findElementsByTypeCount(java.lang.String, java.lang.String, boolean)
+ */
@Override
public int findElementsByTypeCount(String token, String type,
boolean onlyLatest) throws SimExplorerStorageException {
@@ -80,6 +96,9 @@
return super.findElementsByTypeCount(token, type, onlyLatest);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#findFullText(java.lang.String, java.lang.String, boolean, int, int, int)
+ */
@Override
public MetaData[] findFullText(String token, String query,
boolean onlyLatest, int indexStart, int count, int dateOrder)
@@ -89,6 +108,9 @@
dateOrder);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#findFullTextCount(java.lang.String, java.lang.String, boolean)
+ */
@Override
public int findFullTextCount(String token, String query, boolean onlyLatest)
throws SimExplorerStorageException {
@@ -96,6 +118,9 @@
return super.findFullTextCount(token, query, onlyLatest);
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#getMetadata(java.lang.String, java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.Version)
+ */
@Override
public MetaData getMetadata(String token, String uuid, Version version)
throws SimExplorerStorageException {
@@ -109,6 +134,9 @@
return mde;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#getMetadata(java.lang.String, java.lang.String)
+ */
@Override
public MetaData getMetadata(String token, String uuid)
throws SimExplorerStorageException {
@@ -122,6 +150,9 @@
return mde;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#getVersions(java.lang.String, java.lang.String)
+ */
@Override
public List<Version> getVersions(String token, String uuid)
throws SimExplorerStorageException {
@@ -135,9 +166,12 @@
return versions;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#retrieveData(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.lang.String)
+ */
@Override
- public InputStream retrieveData(String token, MetaData entity,
- String field) throws SimExplorerStorageException {
+ public InputStream retrieveData(String token, MetaData entity, String field)
+ throws SimExplorerStorageException {
InputStream stream;
Permission permission = credentialManager.getPermission(token, entity
.getUuid());
@@ -149,9 +183,13 @@
return stream;
}
+ /* (non-Javadoc)
+ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#saveElement(java.lang.String, fr.cemagref.simexplorer.is.entities.metadata.MetaData, java.util.Map)
+ */
@Override
public void saveElement(String token, MetaData element,
- Map<String, InputStream> attachments) throws SimExplorerStorageException {
+ Map<String, InputStream> attachments)
+ throws SimExplorerStorageException {
Permission permission = credentialManager.getPermission(token, element
.getUuid());
if (permission != null && permission.isCanWrite()) {
Modified: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityEqualsTestCase.java
===================================================================
--- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityEqualsTestCase.java 2008-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityEqualsTestCase.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -25,10 +25,17 @@
import junit.framework.TestCase;
import fr.cemagref.simexplorer.is.security.entities.User;
+/**
+ * The Class SecurityEqualsTestCase.
+ */
public class SecurityEqualsTestCase extends TestCase {
+ /** The authentication service. */
AuthenticationService authenticationService = null;
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -43,18 +50,25 @@
.lookup("AuthenticationService");
}
-
+
+ /**
+ * Test hash code.
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void testHashCode() throws SimExplorerServiceException {
- String token = authenticationService.loginUser("superadmin", "password");
+ String token = authenticationService
+ .loginUser("superadmin", "password");
User[] users1 = authenticationService.getUsers(token);
User[] users2 = authenticationService.getUsers(token);
for (int i = 0; i < users1.length; i++) {
User user1 = users1[i];
User user2 = users2[i];
System.out.println("User " + i + " :");
- System.out.println(user1.hashCode() + " " + user2.hashCode());
- assertEquals(user1.hashCode(),user2.hashCode());
- assertEquals(user1,user2);
+ System.out.println(user1.hashCode() + " " + user2.hashCode());
+ assertEquals(user1.hashCode(), user2.hashCode());
+ assertEquals(user1, user2);
}
}
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/SecurityTestCase.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -26,10 +26,17 @@
import fr.cemagref.simexplorer.is.security.entities.Group;
import fr.cemagref.simexplorer.is.security.entities.User;
+/**
+ * The Class SecurityTestCase.
+ */
public class SecurityTestCase extends TestCase {
+ /** The authentication service. */
AuthenticationService authenticationService = null;
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -45,6 +52,12 @@
}
+ /**
+ * Test security entities.
+ *
+ * @throws SimExplorerServiceException
+ * the sim explorer service exception
+ */
public void testSecurityEntities() throws SimExplorerServiceException {
/*
User user = authenticationService.getUser("user3");
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-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -37,7 +37,6 @@
import com.healthmarketscience.rmiio.SimpleRemoteInputStream;
import fr.cemagref.simexplorer.is.attachment.Attachment;
-import fr.cemagref.simexplorer.is.attachment.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;
@@ -45,13 +44,23 @@
import fr.cemagref.simexplorer.is.factories.BaseEntityFactory;
import fr.cemagref.simexplorer.is.factories.XmlConstants;
+/**
+ * The Class StorageServiceMassInsert.
+ */
public class StorageServiceMassInsert extends TestCase {
+ /** The storage service. */
private StorageService storageService;
+
+ /** The element generator. */
private ElementGenerator elementGenerator;
+ /** The r. */
private Random r = new Random();
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -90,6 +99,12 @@
}
*/
+ /**
+ * Test mass insert.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testMassInsert() throws Exception {
int c = 5;
@@ -140,7 +155,8 @@
InputStream stream = elementGenerator.generateTextStream();
RemoteInputStreamServer remoteStream = new SimpleRemoteInputStream(
stream);
- attachments.put(attachment.getUniqueId(), remoteStream.export());
+ attachments.put(attachment.getUniqueId(), remoteStream
+ .export());
}
RemoteInputStreamServer xmlRemoteStream = new SimpleRemoteInputStream(
Modified: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java
===================================================================
--- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java 2008-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -25,10 +25,17 @@
import junit.framework.TestCase;
import fr.cemagref.simexplorer.is.service.StorageService;
+/**
+ * The Class StorageServiceServerTest.
+ */
public class StorageServiceServerTest extends TestCase {
+ /** The storage service. */
private StorageService storageService;
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -43,7 +50,10 @@
storageService = (StorageService) context.lookup("StorageService");
}
-
+
+ /**
+ * Test login.
+ */
public void testLogin() {
try {
String token = storageService.loginUser("superadmin", "password");
Modified: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceTest.java
===================================================================
--- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceTest.java 2008-02-04 14:34:43 UTC (rev 625)
+++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceTest.java 2008-02-04 14:39:44 UTC (rev 626)
@@ -34,11 +34,20 @@
import fr.cemagref.simexplorer.is.service.StorageService;
import fr.cemagref.simexplorer.is.service.StorageServiceClient;
+/**
+ * The Class StorageServiceTest.
+ */
public class StorageServiceTest extends TestCase {
+ /** The storage service. */
private StorageService storageService;
+
+ /** The r. */
private Random r = new Random();
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -46,11 +55,20 @@
storageService = new StorageServiceClient();
}
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
+ /**
+ * Test insert element zip.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testInsertElementZip() throws Exception {
InputStream zipStream = new FileInputStream(
"./src/ressources/testImport/test.zip");
@@ -61,6 +79,12 @@
assertNotNull(storageService.getMetadata(null, "abcd"));
}
+ /**
+ * Test insert element streams.
+ *
+ * @throws Exception
+ * the exception
+ */
public void testInsertElementStreams() throws Exception {
String id = UUID.randomUUID().toString();
String[] randomcontent = new String[2];
1
0