Vradi-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
- 198 discussions
Author: sletellier
Date: 2011-05-27 11:22:54 +0200 (Fri, 27 May 2011)
New Revision: 58
Url: http://chorem.org/repositories/revision/vradi/58
Log:
Delete unused dir
Removed:
trunk/vradi-web/src/main/webapp/jsp/
1
0
27 May '11
Author: sletellier
Date: 2011-05-27 09:44:09 +0200 (Fri, 27 May 2011)
New Revision: 57
Url: http://chorem.org/repositories/revision/vradi/57
Log:
Retrieve index.html
Added:
trunk/vradi-web/src/main/webapp/index.html
Modified:
trunk/vradi-web/src/main/webapp/WEB-INF/web.xml
Modified: trunk/vradi-web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/vradi-web/src/main/webapp/WEB-INF/web.xml 2011-05-26 15:11:59 UTC (rev 56)
+++ trunk/vradi-web/src/main/webapp/WEB-INF/web.xml 2011-05-27 07:44:09 UTC (rev 57)
@@ -35,6 +35,6 @@
</filter-mapping>
<!-- Welcome file lists -->
<welcome-file-list>
- <welcome-file>search.action</welcome-file>
+ <welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Added: trunk/vradi-web/src/main/webapp/index.html
===================================================================
--- trunk/vradi-web/src/main/webapp/index.html (rev 0)
+++ trunk/vradi-web/src/main/webapp/index.html 2011-05-27 07:44:09 UTC (rev 57)
@@ -0,0 +1,9 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="refresh" content="0;URL=search.action"/>
+ <title>Vradi web</title>
+ </head>
+ <body onload="">
+ </body>
+</html>
1
0
r56 - in trunk: vradi-services/src/main/java/org/chorem/vradi vradi-services/src/main/java/org/chorem/vradi/services vradi-swing/src/main/resources
by sletellier@users.chorem.org 26 May '11
by sletellier@users.chorem.org 26 May '11
26 May '11
Author: sletellier
Date: 2011-05-26 17:11:59 +0200 (Thu, 26 May 2011)
New Revision: 56
Url: http://chorem.org/repositories/revision/vradi/56
Log:
- Fix using on remote
Modified:
trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java
trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java
trunk/vradi-swing/src/main/resources/vradi.properties
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java 2011-05-26 14:55:23 UTC (rev 55)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java 2011-05-26 15:11:59 UTC (rev 56)
@@ -277,6 +277,7 @@
/**
* Get remote service port.
+ * (was for cajo use)
*
* @param config vradi swing configuration
* @return remote service port
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java 2011-05-26 14:55:23 UTC (rev 55)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java 2011-05-26 15:11:59 UTC (rev 56)
@@ -92,10 +92,9 @@
factory.setOverloadEnabled(true);
// vradi service
- int servicePort = VradiServiceConfigurationHelper.getServicePort(VradiServiceConfiguration.getConfig());
result = (VradiStorageService) factory.
create(VradiStorageService.class,
- getServiceURL(serviceEndpoint, servicePort, VradiStorageService.VRADI_SERVICE));
+ getServiceURL(serviceEndpoint, VradiStorageService.VRADI_SERVICE));
} catch (Exception eee) {
if (log.isErrorEnabled()) {
@@ -142,9 +141,8 @@
FileService fileService;
String serviceEndpoint = VradiServiceConfigurationHelper.getRemoteEndpoint(config);
if (isValidUrl(serviceEndpoint)) {
- int servletPort = VradiServiceConfigurationHelper.getServletPort(config);
// file service
- String fileServiceUrl = getServiceURL(serviceEndpoint, servletPort, "file");
+ String fileServiceUrl = getServiceURL(serviceEndpoint, "file");
log.info("File service url : " + fileServiceUrl);
fileService = new FileServiceProxy(fileServiceUrl);
} else {
@@ -164,14 +162,9 @@
* @param serviceEndUrl service small name
* @return service full url
*/
- protected static String getServiceURL(String serviceEndpoint, int port, String serviceEndUrl) {
+ protected static String getServiceURL(String serviceEndpoint, String serviceEndUrl) {
String fullUrl = serviceEndpoint;
- // Add port if != 0
- if (port != 0) {
- fullUrl += ":" + port;
- }
-
// Warn hessian won't work with double /
if (!fullUrl.endsWith("/")) {
fullUrl += "/";
Modified: trunk/vradi-swing/src/main/resources/vradi.properties
===================================================================
--- trunk/vradi-swing/src/main/resources/vradi.properties 2011-05-26 14:55:23 UTC (rev 55)
+++ trunk/vradi-swing/src/main/resources/vradi.properties 2011-05-26 15:11:59 UTC (rev 56)
@@ -40,7 +40,7 @@
wikitty.service.event.listen=true
wikitty.service.event.propagate.transporter=org.nuiton.wikitty.services.XMPPNotifierTransporter
wikitty.WikittyServiceCached.components=org.nuiton.wikitty.services.WikittyCacheJCS
-wikitty.service.server.url=${vradi.remote.endpoint}:${vradi.remote.service.port}/wikittyservice
+wikitty.service.server.url=${vradi.remote.endpoint}/wikittyservice
wikitty.service.cache.priority.extensions=Thesaurus, User, Status, XmlStream
jcs.default=
jcs.default.cacheattributes.MaxObjects=1000
1
0
Author: sletellier
Date: 2011-05-26 16:55:23 +0200 (Thu, 26 May 2011)
New Revision: 55
Url: http://chorem.org/repositories/revision/vradi/55
Log:
Revert to hessian
Added:
trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java
trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java
trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/
trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ReindexService.java
Modified:
trunk/pom.xml
trunk/vradi-services-web/pom.xml
trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml
trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearService.java
trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java
trunk/vradi-services-web/src/test/resources/log4j.properties
trunk/vradi-services/pom.xml
trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java
trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java
trunk/vradi-services/src/main/resources/vradi-services.properties
trunk/vradi-swing/pom.xml
trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java
trunk/vradi-swing/src/main/resources/vradi.properties
trunk/vradi-web/pom.xml
trunk/vradi-web/src/main/java/org/chorem/vradi/VradiProxy.java
trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/pom.xml 2011-05-26 14:55:23 UTC (rev 55)
@@ -277,6 +277,12 @@
</dependency>
<dependency>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-hessian-client</artifactId>
+ <version>${wikittyVersion}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>0.8</version>
@@ -348,6 +354,13 @@
</dependency>
<dependency>
+ <groupId>com.caucho</groupId>
+ <artifactId>hessian</artifactId>
+ <version>4.0.6</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
Modified: trunk/vradi-services/pom.xml
===================================================================
--- trunk/vradi-services/pom.xml 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-services/pom.xml 2011-05-26 14:55:23 UTC (rev 55)
@@ -161,6 +161,10 @@
<artifactId>lucene-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.caucho</groupId>
+ <artifactId>hessian</artifactId>
+ </dependency>
</dependencies>
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -23,13 +23,15 @@
*/
package org.chorem.vradi.services;
-import gnu.cajo.utils.extra.TransparentItemProxy;
+import com.caucho.hessian.client.HessianProxyFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.vradi.VradiServiceConfiguration;
import org.chorem.vradi.VradiServiceConfigurationHelper;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.WikittyService;
+import org.nuiton.wikitty.WikittyServiceFactory;
/**
* VradiServiceFactory.
@@ -61,24 +63,40 @@
if (isValidUrl(serviceEndpoint)) {
try {
+// Cajo impl
+// String cajoEndPoint = serviceEndpoint;
+// // cajo url is not http or other protocol, url must start with //
+// // example: //localhost:1198/ws
+// // remove protocol
+// int i = cajoEndPoint.indexOf("://");
+// if (i >= 0) {
+// cajoEndPoint = serviceEndpoint.substring(i+1);
+// }
+// int servicePort = VradiServiceConfigurationHelper.getServicePort(config);
+// serviceEndpoint = getServiceURL(cajoEndPoint, servicePort, VradiStorageService.VRADI_SERVICE);
+//
+// if (log.isInfoEnabled()) {
+// log.info("Use remote mode with url : " + serviceEndpoint);
+// }
+// result = (VradiStorageService) TransparentItemProxy.getItem(
+// serviceEndpoint, new Class[]{VradiStorageService.class});
- String cajoEndPoint = serviceEndpoint;
- // cajo url is not http or other protocol, url must start with //
- // example: //localhost:1198/ws
- // remove protocol
- int i = cajoEndPoint.indexOf("://");
- if (i >= 0) {
- cajoEndPoint = serviceEndpoint.substring(i+1);
- }
- int servicePort = VradiServiceConfigurationHelper.getServicePort(config);
- serviceEndpoint = getServiceURL(cajoEndPoint, servicePort, VradiStorageService.VRADI_SERVICE);
-
if (log.isInfoEnabled()) {
log.info("Use remote mode with url : " + serviceEndpoint);
}
- result = (VradiStorageService) TransparentItemProxy.getItem(
- serviceEndpoint, new Class[]{VradiStorageService.class});
+ HessianProxyFactory factory = new HessianProxyFactory();
+ // Fix : com.caucho.hessian.io.HessianProtocolException: '���' is an unknown code
+ factory.setHessian2Request(true);
+ // pour que les méthodes aux noms dupliquées fonctionnent (arguments different)
+ factory.setOverloadEnabled(true);
+
+ // vradi service
+ int servicePort = VradiServiceConfigurationHelper.getServicePort(VradiServiceConfiguration.getConfig());
+ result = (VradiStorageService) factory.
+ create(VradiStorageService.class,
+ getServiceURL(serviceEndpoint, servicePort, VradiStorageService.VRADI_SERVICE));
+
} catch (Exception eee) {
if (log.isErrorEnabled()) {
log.error("Can't init remote proxy", eee);
@@ -103,11 +121,10 @@
/**
* Get wikittyService instanciate by vradiService
*
- * @param vradiService of application
* @return wikittyService instanciate
*/
- public static WikittyService getWikittyService(VradiStorageService vradiService) {
- return vradiService.getWikittyService();
+ public static WikittyService getWikittyService(ApplicationConfig config) {
+ return WikittyServiceFactory.buildWikittyService(config);
}
/**
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -102,10 +102,8 @@
protected FileService fileService;
- /**
- * Must be instanciate using {@link VradiServiceFactory}
- */
- protected VradiStorageServiceImpl() {
+ /** Remote instantiation and empty constructor for hessian. */
+ public VradiStorageServiceImpl() {
this(VradiServiceConfiguration.getConfig(), VradiServiceContext.getWikittyProxy());
}
Modified: trunk/vradi-services/src/main/resources/vradi-services.properties
===================================================================
--- trunk/vradi-services/src/main/resources/vradi-services.properties 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-services/src/main/resources/vradi-services.properties 2011-05-26 14:55:23 UTC (rev 55)
@@ -68,4 +68,4 @@
#wikitty.service.cache.priority.extensions=Thesaurus
jcs.default=
jcs.default.cacheattributes.MaxObjects=10000
-#jcs.priority.cacheattributes.MaxObjects=10000
\ No newline at end of file
+#jcs.priority.cacheattributes.MaxObjects=10000
Modified: trunk/vradi-services-web/pom.xml
===================================================================
--- trunk/vradi-services-web/pom.xml 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-services-web/pom.xml 2011-05-26 14:55:23 UTC (rev 55)
@@ -47,6 +47,11 @@
</dependency>
<dependency>
+ <groupId>com.caucho</groupId>
+ <artifactId>hessian</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
Added: trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java
===================================================================
--- trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java (rev 0)
+++ trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -0,0 +1,48 @@
+/*
+ * #%L
+ * Vradi :: Services Web
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package org.chorem.vradi.services;
+
+import org.chorem.vradi.VradiServiceConfiguration;
+import org.nuiton.wikitty.services.WikittyServiceDelegator;
+
+/**
+ * Wikitty proxy delegator.
+ * <p/>
+ * This delegator exist only because we cannot put instance as hessian service.
+ * <p/>
+ * This delegator just delegate everything to a static real wikitty service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ * <p/>
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class VradiWikittyServiceDelegator extends WikittyServiceDelegator {
+
+ public VradiWikittyServiceDelegator() {
+ super(VradiServiceFactory.getWikittyService(VradiServiceConfiguration.getConfig()));
+ }
+}
Modified: trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml 2011-05-26 14:55:23 UTC (rev 55)
@@ -29,52 +29,54 @@
<display-name>Vradi</display-name>
- <!--<servlet>-->
- <!--<servlet-name>vradiStorageServlet</servlet-name>-->
- <!--<servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>-->
- <!--<init-param>-->
- <!--<param-name>home-api</param-name>-->
- <!--<param-value>org.chorem.vradi.services.VradiStorageService</param-value>-->
- <!--</init-param>-->
- <!--<init-param>-->
- <!--<param-name>home-class</param-name>-->
- <!--<param-value>org.chorem.vradi.services.VradiStorageServiceImpl-->
- <!--</param-value>-->
- <!--</init-param>-->
- <!--<load-on-startup>1</load-on-startup>-->
- <!--</servlet>-->
- <!--<servlet>-->
- <!--<servlet-name>wikittyServiceServlet</servlet-name>-->
- <!--<servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>-->
- <!--<init-param>-->
- <!--<param-name>home-api</param-name>-->
- <!--<param-value>org.nuiton.wikitty.WikittyService</param-value>-->
- <!--</init-param>-->
- <!--<init-param>-->
- <!--<param-name>home-class</param-name>-->
- <!--<param-value>org.chorem.vradi.services.VradiWikittyServiceDelegator-->
- <!--</param-value>-->
- <!--</init-param>-->
- <!--<load-on-startup>2</load-on-startup>-->
- <!--</servlet>-->
<servlet>
+ <servlet-name>vradiStorageServlet</servlet-name>
+ <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
+ <init-param>
+ <param-name>home-api</param-name>
+ <param-value>org.chorem.vradi.services.VradiStorageService</param-value>
+ </init-param>
+ <init-param>
+ <param-name>home-class</param-name>
+ <param-value>org.chorem.vradi.services.VradiStorageServiceImpl
+ </param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>wikittyServiceServlet</servlet-name>
+ <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
+ <init-param>
+ <param-name>home-api</param-name>
+ <param-value>org.nuiton.wikitty.WikittyService</param-value>
+ </init-param>
+ <init-param>
+ <param-name>home-class</param-name>
+ <param-value>org.chorem.vradi.services.VradiWikittyServiceDelegator
+ </param-value>
+ </init-param>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+ <servlet>
<servlet-name>fileServlet</servlet-name>
<servlet-class>org.chorem.vradi.services.FileServlet</servlet-class>
</servlet>
- <!--<servlet-mapping>-->
- <!--<servlet-name>vradiStorageServlet</servlet-name>-->
- <!--<url-pattern>/vradiservice</url-pattern>-->
- <!--</servlet-mapping>-->
- <!--<servlet-mapping>-->
- <!--<servlet-name>wikittyServiceServlet</servlet-name>-->
- <!--<url-pattern>/wikittyservice</url-pattern>-->
- <!--</servlet-mapping>-->
- <listener>
- <description>Init</description>
- <listener-class>org.chorem.vradi.ApplicationListener</listener-class>
- </listener>
+ <servlet-mapping>
+ <servlet-name>vradiStorageServlet</servlet-name>
+ <url-pattern>/vradiservice</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>wikittyServiceServlet</servlet-name>
+ <url-pattern>/wikittyservice</url-pattern>
+ </servlet-mapping>
+ <!-- Used for cajo -->
+ <!--<listener>-->
+ <!--<description>Init</description>-->
+ <!--<listener-class>org.chorem.vradi.ApplicationListener</listener-class>-->
+ <!--</listener>-->
+
<servlet-mapping>
<servlet-name>fileServlet</servlet-name>
<url-pattern>/file/*</url-pattern>
Modified: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearService.java
===================================================================
--- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearService.java 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearService.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -8,17 +8,18 @@
* Copyright (C) 2009 - 2010 Codelutin
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
package org.chorem.vradi.services;
Modified: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java
===================================================================
--- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -8,17 +8,18 @@
* Copyright (C) 2009 - 2010 Codelutin
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
package org.chorem.vradi.services;
Added: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java
===================================================================
--- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java (rev 0)
+++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -0,0 +1,199 @@
+/*
+ * #%L
+ * Vradi :: Services Web
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.vradi.services;
+
+import com.caucho.hessian.client.HessianProxyFactory;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.vradi.VradiConstants;
+import org.chorem.vradi.beans.XmlStreamImportResult;
+import org.chorem.vradi.entities.Session;
+import org.chorem.vradi.entities.SessionImpl;
+import org.chorem.vradi.entities.XmlFieldBinding;
+import org.chorem.vradi.entities.XmlStream;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mortbay.jetty.runner.Runner;
+import org.nuiton.util.Resource;
+import org.nuiton.util.converter.ConverterUtil;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.WikittyService;
+import org.nuiton.wikitty.WikittyUtil;
+import org.nuiton.wikitty.entities.WikittyExtension;
+
+import java.net.URL;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * VradiHessianStorageTest.
+ *
+ * @author $Author$
+ * @version $Revision$ $Date$
+ * @since 21 févr. 2010 02:13:16
+ */
+public class VradiHessianStorageTest extends VradiStorageServiceTest {
+ static final Log log = LogFactory.getLog(VradiHessianStorageTest.class);
+
+ static final String port = "9000";
+
+ static final String clearUrl = "http://localhost:" + port + "/clearservice";
+
+ static final String storageUrl = "http://localhost:" + port + "/vradiservice";
+
+ static final String wikittyUrl = "http://localhost:" + port + "/wikittyservice";
+
+ static final String fileUrl = "http://localhost:" + port + "/file";
+
+ static VradiJettyRunner runner;
+
+ public static class VradiJettyRunner extends Runner {
+ @Override
+ public void run() throws Exception {
+ _server.start();
+ // Skip join
+ }
+
+ public void stop() throws Exception {
+ _server.stop();
+ }
+ }
+
+ @BeforeClass
+ public static void startServer() throws Exception {
+ runner = new VradiJettyRunner();
+
+ // This is the file to find to get the path of vradi-services-web module
+ String placeHolder = "/vradi_services_web.place_holder";
+
+ // Find the file
+ URL url = Resource.getURL(placeHolder);
+
+ // Remove the file name and folder 'target/test-classes'
+ String contextPath = url.toString();
+ String target = "/target/test-classes";
+ contextPath = contextPath.substring(0, contextPath.length() - (placeHolder.length() + target.length()));
+
+ // Add webapp context
+ contextPath += "/src/test/webapp";
+ String[] args = {"--port", port, contextPath};
+ runner.configure(args);
+
+ runner.run();
+ }
+
+ @AfterClass
+ public static void stopServer() throws Exception {
+ runner.stop();
+ }
+
+ @Override
+ @Before
+ public void clear() throws Exception {
+ ConverterUtil.initConverters();
+
+ HessianProxyFactory factory = new HessianProxyFactory();
+ factory.setHessian2Request(true);
+ factory.setOverloadEnabled(true);
+
+ log.debug("--clear-----------------------------------------");
+ ClearService clearService = (ClearService) factory.create(ClearService.class, clearUrl);
+ clearService.clear();
+ storageService = (VradiStorageService) factory.create(VradiStorageService.class, storageUrl);
+ WikittyService wikittyService = (WikittyService) factory.create(WikittyService.class, wikittyUrl);
+ wikittyProxy = new WikittyProxy(wikittyService);
+ dataService = new VradiDataServiceImpl(config, wikittyProxy);
+
+ // fait avec le proxy > servlet pour tester
+ fileService = new FileServiceProxy(fileUrl);
+ }
+
+ @Override
+ protected XmlStreamImportResult initData(WikittyExtension extension)
+ throws Exception {
+ List<XmlFieldBinding> bindings = createXmlBindings(extension);
+ XmlStream xmlStream = createXmlStream(extension, bindings);
+ return storageService.importFormsFromXmlStream(xmlStream);
+ }
+
+ /*
+ * TODO add doc about this test !!!
+ *
+ */
+ @Test
+ public void testPropagation() throws Exception {
+
+ Session session = new SessionImpl();
+
+ session.setNum(7);
+ wikittyProxy.getWikitty(session).addExtension(
+ new WikittyExtension("ouaf", "2.0", null,
+ WikittyUtil.buildFieldMapExtension(
+ "Numeric a",
+ "Numeric b",
+ "String c")));
+ session.setSessionDate(new Date());
+
+ session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue());
+
+ session = wikittyProxy.store(session);
+
+ session.setField("ouaf", "a", 1);
+ session.setField("ouaf", "b", 1.0);
+ session.setField("ouaf", "c", "Ouaf");
+ session.setNum(1);
+ session.setSessionDate(DateUtils.addMinutes(new Date(), 15));
+ Session sessionService = wikittyProxy.store(session);
+
+ if (session.getWikittyId().equals(sessionService.getWikittyId())) {
+ int scInt = wikittyProxy.getWikitty(sessionService).getFieldAsInt("ouaf", "a");
+ int lcInt = wikittyProxy.getWikitty(session).getFieldAsInt("ouaf", "a");
+
+ Float scFloat = wikittyProxy.getWikitty(sessionService).getFieldAsFloat("ouaf", "b");
+ Float lcFloat = wikittyProxy.getWikitty(session).getFieldAsFloat("ouaf", "b");
+
+ String scString = wikittyProxy.getWikitty(sessionService).getFieldAsString("ouaf", "c");
+ String lcString = wikittyProxy.getWikitty(session).getFieldAsString("ouaf", "c");
+
+ log.info("testPropagation result, local : " + session.getNum() + " serveur : " + sessionService.getNum());
+ log.info("testPropagation result as int, local : " + lcInt + " serveur : " + scInt);
+ log.info("testPropagation result as float, local : " + lcFloat + " serveur : " + scFloat);
+ log.info("testPropagation result as String, local : " + lcString + " serveur : " + scString);
+ log.info("testPropagation result, local : " + session.getSessionDate() + " serveur : " + sessionService.getSessionDate());
+
+ Assert.assertEquals(session.getNum(), sessionService.getNum());
+ Assert.assertEquals(lcInt, scInt);
+ Assert.assertEquals(lcFloat, scFloat);
+ Assert.assertEquals(lcString, scString);
+ Assert.assertEquals(session.getSessionDate(), sessionService.getSessionDate());
+ }
+
+ wikittyProxy.delete(session.getWikittyId());
+ }
+
+}
Added: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ReindexService.java
===================================================================
--- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ReindexService.java (rev 0)
+++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ReindexService.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -0,0 +1,104 @@
+/*
+ * #%L
+ * Vradi :: Services Web
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package org.chorem.vradi.services.util;
+
+import com.caucho.hessian.client.HessianProxyFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.vradi.entities.Thesaurus;
+import org.nuiton.util.StringUtil;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.WikittyService;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.Search;
+import org.nuiton.wikitty.search.operators.Element;
+
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Attention, cette class n'est pas un test, elle est utilisée
+ * pour faire une reindexation d'un service distant facilement.
+ *
+ * @author chatellier
+ * @version $Revision$
+ * <p/>
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ReindexService {
+
+ static final String wikittyUrl = "http://dbdev/vradi/wikittyservice";
+
+ static final Log log = LogFactory.getLog(ReindexService.class);
+
+ public static void main(String... args) throws MalformedURLException {
+
+ HessianProxyFactory factory = new HessianProxyFactory();
+ factory.setHessian2Request(true);
+ factory.setOverloadEnabled(true);
+
+ WikittyService wikittyService = (WikittyService) factory.create(WikittyService.class, wikittyUrl);
+ WikittyProxy wikittyProxy = new WikittyProxy(wikittyService);
+
+ //synEngin(wikittyProxy);
+ //deleteObseleteThesaurus(wikittyProxy);
+ }
+
+ public static void syncSearchEngine(WikittyProxy wikittyProxy) throws MalformedURLException {
+ wikittyProxy.syncSearchEngine();
+ System.out.println("syncEngin complete !");
+ }
+
+ public static void deleteObseleteThesaurus(WikittyProxy wikittyProxy) {
+ log.info("Starting deleting obselete thesaurus");
+
+ long startingTime = System.nanoTime();
+
+ Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Thesaurus.EXT_THESAURUS).criteria();
+ List<Thesaurus> thesauruses = wikittyProxy.findAllByCriteria(Thesaurus.class, criteria).getAll();
+
+ List<String> thesaurusToDelete = new ArrayList<String>();
+ for (Thesaurus thesaurus : thesauruses) {
+ String parentId = thesaurus.getParent();
+ if (parentId == null) {
+ thesaurusToDelete.add(thesaurus.getWikittyId());
+
+ log.info("Found thesaurus '" + thesaurus.getName() + "' has no parentId, deleting this");
+ } else {
+ Thesaurus parent = wikittyProxy.restore(Thesaurus.class, parentId);
+ if (parent == null) {
+ thesaurusToDelete.add(thesaurus.getWikittyId());
+ log.info("Found thesaurus '" + thesaurus.getName() + "' has no parent with id '" + parentId + ", deleting this");
+ }
+ }
+ }
+
+ //wikittyProxy.delete(thesaurusToDelete);
+
+ log.info("Deleting obselete thesaurus is finished in " + StringUtil.convertTime(startingTime, System.nanoTime()));
+ }
+}
Modified: trunk/vradi-services-web/src/test/resources/log4j.properties
===================================================================
--- trunk/vradi-services-web/src/test/resources/log4j.properties 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-services-web/src/test/resources/log4j.properties 2011-05-26 14:55:23 UTC (rev 55)
@@ -8,17 +8,18 @@
# Copyright (C) 2009 - 2010 Codelutin
# %%
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/gpl-3.0.html>.
# #L%
###
Modified: trunk/vradi-swing/pom.xml
===================================================================
--- trunk/vradi-swing/pom.xml 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-swing/pom.xml 2011-05-26 14:55:23 UTC (rev 55)
@@ -86,6 +86,12 @@
</dependency>
<dependency>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-hessian-client</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
@@ -106,6 +112,11 @@
</dependency>
<dependency>
+ <groupId>com.caucho</groupId>
+ <artifactId>hessian</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>runtime</scope>
Modified: trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java
===================================================================
--- trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -65,7 +65,7 @@
vradiStorageService = VradiServiceFactory.getVradiServiceStorage(configuration);
- wikittyService = VradiServiceFactory.getWikittyService(vradiStorageService);
+ wikittyService = VradiServiceFactory.getWikittyService(configuration);
fileService = VradiServiceFactory.getFileService(configuration);
Modified: trunk/vradi-swing/src/main/resources/vradi.properties
===================================================================
--- trunk/vradi-swing/src/main/resources/vradi.properties 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-swing/src/main/resources/vradi.properties 2011-05-26 14:55:23 UTC (rev 55)
@@ -31,7 +31,8 @@
application.organisation.url=${project.organization.url}
# Wikitty
-wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceNotifier,\
+wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceHessianClient,\
+org.nuiton.wikitty.services.WikittyServiceNotifier,\
org.nuiton.wikitty.services.WikittyServiceCached,\
org.nuiton.wikitty.services.WikittyServiceSecurity
wikitty.service.cache.allwaysRestoreCopies=false
@@ -39,7 +40,7 @@
wikitty.service.event.listen=true
wikitty.service.event.propagate.transporter=org.nuiton.wikitty.services.XMPPNotifierTransporter
wikitty.WikittyServiceCached.components=org.nuiton.wikitty.services.WikittyCacheJCS
-wikitty.service.server.url=${vradi.remote.endpoint}/wikittyservice
+wikitty.service.server.url=${vradi.remote.endpoint}:${vradi.remote.service.port}/wikittyservice
wikitty.service.cache.priority.extensions=Thesaurus, User, Status, XmlStream
jcs.default=
jcs.default.cacheattributes.MaxObjects=1000
Modified: trunk/vradi-web/pom.xml
===================================================================
--- trunk/vradi-web/pom.xml 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-web/pom.xml 2011-05-26 14:55:23 UTC (rev 55)
@@ -186,6 +186,12 @@
</dependency>
<dependency>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-hessian-client</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>runtime</scope>
Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/VradiProxy.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/VradiProxy.java 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/VradiProxy.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -4,11 +4,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.vradi.entities.Attachment;
-import org.chorem.vradi.services.VradiServiceFactory;
-import org.chorem.vradi.services.VradiStorageService;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.WikittyService;
+import org.nuiton.wikitty.WikittyServiceFactory;
import org.nuiton.wikitty.search.Criteria;
import org.nuiton.wikitty.search.PagedResult;
import org.nuiton.wikitty.search.Search;
@@ -38,11 +37,9 @@
* @param token
* @return
*/
- static public VradiProxy getInstance(VradiStorageService vradiStorageService, String token) {
+ static public VradiProxy getInstance(String token) {
ApplicationConfig config = VradiWebConfig.getConfig();
- if (ws == null) {
- ws = VradiServiceFactory.getWikittyService(vradiStorageService);
- }
+ WikittyService ws = getWikittyService(config);
VradiProxy result = new VradiProxy(config, ws);
result.setSecurityToken(token);
@@ -50,17 +47,35 @@
}
/**
+ * Returns WikittyService to use. This WikittyService is singleton.
+ *
+ * @param config
+ * @return WikittyService instance
+ */
+ static protected WikittyService getWikittyService(ApplicationConfig config) {
+ if (ws == null) {
+ synchronized(VradiProxy.class) {
+ if (ws == null) {
+ ws = WikittyServiceFactory.buildWikittyService(config);
+ }
+ }
+ }
+ return ws;
+ }
+
+ /**
* Returns the attachments linked with a wikitty id ordered descending
* by date
*
* @param formNoteId
* @return the list of attachments
*/
- public List<Attachment> getAttachments(String formNoteId) {
+ static public List<Attachment> getAttachments(String formNoteId) {
Criteria criteria = Search.query().
eq(Attachment.FQ_FIELD_ATTACHMENT_FORMNOTE, formNoteId)
.criteria().addSortDescending(Attachment.FQ_FIELD_ATTACHMENT_DATE);
- PagedResult<Attachment> result = findAllByCriteria(Attachment.class, criteria);
+ PagedResult<Attachment> result = getInstance(null).
+ findAllByCriteria(Attachment.class, criteria);
List<Attachment> attachments = result.getAll();
return attachments;
}
Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java 2011-05-26 13:39:50 UTC (rev 54)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java 2011-05-26 14:55:23 UTC (rev 55)
@@ -1,5 +1,6 @@
package org.chorem.vradi;
+import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -7,11 +8,16 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.vradi.entities.VradiUser;
import org.chorem.vradi.services.VradiDataService;
+import org.chorem.vradi.services.VradiDataServiceImpl;
import org.chorem.vradi.services.VradiServiceFactory;
-import org.chorem.vradi.services.VradiStorageService;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.util.ApplicationConfig;
+import org.nuiton.wikitty.WikittyConfigOption;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.WikittyService;
+import org.nuiton.wikitty.WikittyServiceFactory;
+import org.nuiton.wikitty.entities.WikittyUser;
/**
* Classe utilisee pour stocker les objets utils en session utilisateur
@@ -34,7 +40,6 @@
transient protected VradiProxy proxy = null;
transient protected VradiDataService dataService;
- transient protected VradiStorageService vradiServiceStorage;
public VradiSession() {
// FIXME poussin 20110521 ?
@@ -60,7 +65,7 @@
public VradiProxy getProxy() {
if (proxy == null) {
- proxy = VradiProxy.getInstance(getVradiStorageService(), securityToken);
+ proxy = VradiProxy.getInstance(securityToken);
}
return proxy;
}
@@ -97,18 +102,6 @@
return result;
}
- public VradiStorageService getVradiStorageService() {
- if (vradiServiceStorage == null) {
- synchronized(VradiSession.class) {
- if (vradiServiceStorage == null) {
- ApplicationConfig config = VradiWebConfig.getConfig();
- vradiServiceStorage = VradiServiceFactory.getVradiServiceStorage(config);
- }
- }
- }
- return vradiServiceStorage;
- }
-
public VradiDataService getDataService() {
if (dataService == null) {
synchronized(VradiSession.class) {
1
0
Author: sletellier
Date: 2011-05-26 15:39:50 +0200 (Thu, 26 May 2011)
New Revision: 54
Url: http://chorem.org/repositories/revision/vradi/54
Log:
#397 Up to cajo
Added:
trunk/vradi-services-web/src/main/java/org/chorem/vradi/ApplicationListener.java
trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceContext.java
trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java
Removed:
trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java
trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java
trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/
trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java
Modified:
trunk/pom.xml
trunk/vradi-services-web/pom.xml
trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml
trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java
trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceAction.java
trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfiguration.java
trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java
trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceMigration.java
trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java
trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageService.java
trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java
trunk/vradi-services/src/main/resources/i18n/vradi-services_fr_FR.properties
trunk/vradi-services/src/main/resources/vradi-services.properties
trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestAbstract.java
trunk/vradi-swing/pom.xml
trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfig.java
trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfigHelper.java
trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java
trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUIHandler.java
trunk/vradi-swing/src/main/resources/vradi.properties
trunk/vradi-web/pom.xml
trunk/vradi-web/src/main/java/org/chorem/vradi/VradiProxy.java
trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java
trunk/vradi-web/src/main/resources/vradi-web.properties
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/pom.xml 2011-05-26 13:39:50 UTC (rev 54)
@@ -277,12 +277,6 @@
</dependency>
<dependency>
- <groupId>org.nuiton.wikitty</groupId>
- <artifactId>wikitty-hessian-client</artifactId>
- <version>${wikittyVersion}</version>
- </dependency>
-
- <dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>0.8</version>
@@ -354,13 +348,6 @@
</dependency>
<dependency>
- <groupId>com.caucho</groupId>
- <artifactId>hessian</artifactId>
- <version>4.0.6</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceAction.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceAction.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceAction.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -31,7 +31,7 @@
import org.chorem.vradi.entities.Status;
import org.chorem.vradi.entities.Thesaurus;
import org.chorem.vradi.entities.User;
-import org.chorem.vradi.services.ServiceFactory;
+import org.chorem.vradi.services.VradiServiceContext;
import org.chorem.vradi.services.VradiException;
import org.chorem.vradi.services.VradiStorageService;
import org.nuiton.util.ApplicationConfig;
@@ -85,7 +85,7 @@
long startingTime = System.nanoTime();
- ServiceFactory.getWikittyProxy().syncSearchEngine();
+ VradiServiceContext.getWikittyProxy().syncSearchEngine();
if (log.isInfoEnabled()) {
log.info("ReIndex solr is finished in " + StringUtil.convertTime(startingTime, System.nanoTime()));
@@ -101,7 +101,7 @@
Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Thesaurus.EXT_THESAURUS).criteria();
- WikittyProxy proxy = ServiceFactory.getWikittyProxy();
+ WikittyProxy proxy = VradiServiceContext.getWikittyProxy();
List<Thesaurus> thesauruses = proxy.findAllByCriteria(Thesaurus.class, criteria).getAll();
for (Thesaurus thesaurus : thesauruses) {
@@ -131,7 +131,7 @@
Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Status.EXT_STATUS).criteria();
- WikittyProxy proxy = ServiceFactory.getWikittyProxy();
+ WikittyProxy proxy = VradiServiceContext.getWikittyProxy();
List<Status> statuses = proxy.findAllByCriteria(Status.class, criteria).getAll();
List<String> statusesIds = new ArrayList<String>();
@@ -143,7 +143,7 @@
proxy.delete(statusesIds);
try {
- ServiceFactory.getVradiStorageService().createDefaultStatuses();
+ VradiServiceContext.getVradiStorageService().createDefaultStatuses();
} catch (VradiException eee) {
log.error(eee);
}
@@ -160,7 +160,7 @@
Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, User.EXT_USER).criteria();
- WikittyProxy proxy = ServiceFactory.getWikittyProxy();
+ WikittyProxy proxy = VradiServiceContext.getWikittyProxy();
List<User> users = proxy.findAllByCriteria(User.class, criteria).getAll();
for (User user : users) {
@@ -190,7 +190,7 @@
Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, User.EXT_USER).criteria();
- WikittyProxy proxy = ServiceFactory.getWikittyProxy();
+ WikittyProxy proxy = VradiServiceContext.getWikittyProxy();
List<User> users = proxy.findAllByCriteria(User.class, criteria).getAll();
for (User user : users) {
@@ -242,7 +242,7 @@
String uri = f.toURI().toString();
try {
log.info("Start import file " + uri);
- ServiceFactory.getVradiStorageService().importAsCSV(uri);
+ VradiServiceContext.getVradiStorageService().importAsCSV(uri);
} catch (VradiException eee) {
log.error("failled to import file : " + uri, eee);
}
@@ -265,7 +265,7 @@
}
// export
- VradiStorageService vradiStorageService = ServiceFactory.getVradiStorageService();
+ VradiStorageService vradiStorageService = VradiServiceContext.getVradiStorageService();
String vscContent = null;
try {
vscContent = vradiStorageService.exportClientDB();
@@ -305,7 +305,7 @@
Criteria criteria = search.criteria();
// export
- VradiStorageService vradiStorageService = ServiceFactory.getVradiStorageService();
+ VradiStorageService vradiStorageService = VradiServiceContext.getVradiStorageService();
String vscContent = null;
try {
vscContent = vradiStorageService.exportAsCSV(criteria);
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfiguration.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfiguration.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfiguration.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -169,6 +169,22 @@
_("vradi.service.config.version.description"),
null, String.class, false, false),
+ // achitecture client serveur
+ REMOTE_ENDPOINT(
+ "vradi.remote.endpoint",
+ _("vradi.config.remote.endpoint.description"),
+ "", String.class, false, false),
+
+ SERVLET_PORT(
+ "vradi.remote.servlet.port",
+ _("vradi.config.remote.servlet.port.description"),
+ "0", Integer.class, false, false),
+
+ SERVICE_PORT(
+ "vradi.remote.service.port",
+ _("vradi.config.remote.service.port.description"),
+ "0", Integer.class, false, false),
+
DATA_DIR(
"vradi.data.dir",
_("vradi.service.config.data.dir.description"),
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -239,4 +239,50 @@
public static String getWikittyEventTransporterXMPPRoom(ApplicationConfig config) {
return config.getOption(WikittyConfigOption.WIKITTY_EVENT_TRANSPORTER_XMPP_ROOM.key);
}
+
+ /**
+ * Get remote endpoint base url.
+ * <p/>
+ * If not valid url, embedded mode is used.
+ *
+ * @param config vradi swing configuration
+ * @return remote endpoint base url
+ */
+ public static String getRemoteEndpoint(ApplicationConfig config) {
+ String endpoint = config.getOption(VradiServiceOption.REMOTE_ENDPOINT.key);
+ return endpoint;
+ }
+
+
+ /**
+ * Change remote endpoint url.
+ *
+ * @param config vradi swing configuration
+ * @param newEndpoint new base url
+ */
+ public static void setRemoteEndPoint(ApplicationConfig config, String newEndpoint) {
+ config.setOption(VradiServiceOption.REMOTE_ENDPOINT.key, newEndpoint);
+ }
+
+ /**
+ * Get remote servlet port.
+ *
+ * @param config vradi swing configuration
+ * @return remote servlet port
+ */
+ public static int getServletPort(ApplicationConfig config) {
+ int servletPort = config.getOptionAsInt(VradiServiceOption.SERVLET_PORT.key);
+ return servletPort;
+ }
+
+ /**
+ * Get remote service port.
+ *
+ * @param config vradi swing configuration
+ * @return remote service port
+ */
+ public static int getServicePort(ApplicationConfig config) {
+ int endpoint = config.getOptionAsInt(VradiServiceOption.SERVICE_PORT.key);
+ return endpoint;
+ }
}
Deleted: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -1,244 +0,0 @@
-/*
- * #%L
- * Vradi :: Services
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.vradi.services;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.vradi.VradiServiceConfiguration;
-import org.chorem.vradi.VradiServiceConfigurationHelper;
-import org.chorem.vradi.entities.ClientImpl;
-import org.chorem.vradi.entities.FormImpl;
-import org.chorem.vradi.entities.GroupFormsImpl;
-import org.chorem.vradi.entities.GroupImpl;
-import org.chorem.vradi.entities.InfogeneImpl;
-import org.chorem.vradi.entities.ModificationTagImpl;
-import org.chorem.vradi.entities.QueryMakerImpl;
-import org.chorem.vradi.entities.RootThesaurusImpl;
-import org.chorem.vradi.entities.SendingImpl;
-import org.chorem.vradi.entities.SessionImpl;
-import org.chorem.vradi.entities.StatusImpl;
-import org.chorem.vradi.entities.ThesaurusImpl;
-import org.chorem.vradi.entities.UserImpl;
-import org.chorem.vradi.entities.VradiUserImpl;
-import org.chorem.vradi.entities.WebHarvestStreamImpl;
-import org.chorem.vradi.entities.XmlFieldBindingImpl;
-import org.chorem.vradi.entities.XmlStreamImpl;
-import org.nuiton.i18n.I18n;
-import org.nuiton.util.ApplicationConfig;
-import org.nuiton.util.converter.ConverterUtil;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.WikittyService;
-import org.nuiton.wikitty.WikittyServiceFactory;
-import org.nuiton.wikitty.entities.WikittyExtension;
-import org.nuiton.wikitty.entities.WikittyTreeNodeImpl;
-import org.nuiton.wikitty.entities.WikittyUserImpl;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * ServiceFactory.
- *
- * @author $Author$
- * @version $Revision$ $Date$
- * @since 24 févr. 2010 22:18:17
- */
-public class ServiceFactory {
-
- /** Log. */
- private static final Log log = LogFactory.getLog(ServiceFactory.class);
-
- /** Wikitty service (cached version) for remote access. */
- protected static WikittyService vradiWikittyService;
-
- /** Single instance of storage service. */
- protected static VradiStorageService vradiStorageService;
-
- /** Single instance of wikitty proxy. */
- protected static WikittyProxy wikittyProxy;
-
- protected static ApplicationConfig config;
-
-
- static {
- // Dans un block static pour definition des variables
- // d'environnement solr et jbossts
- // A voir pourquoi, les converters s'initialise mal durant les tests
- try {
-
- ConverterUtil.initConverters();
- config = VradiServiceConfiguration.getConfig();
- I18n.setDefaultLocale(VradiServiceConfigurationHelper.getLocale(config));
- } catch (Exception eee) {
- log.error("Cant initialize Service factory : ", eee);
- }
- }
-
- public static synchronized VradiStorageService getVradiStorageService() {
- if (vradiStorageService == null) {
- vradiStorageService = new VradiStorageServiceImpl();
- }
- return vradiStorageService;
- }
-
- /**
- * Creates wikitty service (cached).
- * <p/>
- * Getter for service, with default service configuration.
- *
- * @return a unique instance of WikittyService
- */
- public static synchronized WikittyService getWikittyService() {
- if (vradiWikittyService == null) {
- getWikittyService(config);
- }
-
- return vradiWikittyService;
- }
-
- /**
- * Creates wikitty service (cached).
- * <p/>
- * Constructor added for UI embedded mode, with custom configuration.
- *
- * @param config configuration of vradi service
- * @return a unique instance of WikittyService
- */
- public static synchronized WikittyService getWikittyService(ApplicationConfig config) {
- if (vradiWikittyService == null) {
-
- vradiWikittyService = WikittyServiceFactory.buildWikittyService(config);
- }
-
- return vradiWikittyService;
- }
-
- /**
- * Creates wikitty proxy.
- *
- * @return a unique instance of WikittyProxy.
- */
- public static synchronized WikittyProxy getWikittyProxy() {
- if (wikittyProxy == null) {
- WikittyService wikittyService = getWikittyService();
-
- // init proxy on cached service
- wikittyProxy = new WikittyProxy(wikittyService);
-
- // post operation : register extensions
- updateExtensions(wikittyProxy);
-
- // post operation : reindex data if necessary
- reindexData(wikittyProxy);
- }
-
- return wikittyProxy;
- }
-
- /**
- * Register all extensions.
- * <p/>
- * Already existing extensions with same version are skipped,
- * new extension are created and stored.
- *
- * @param localWikittyProxy wikitty proxy
- */
- static void updateExtensions(WikittyProxy localWikittyProxy) {
-
- // easier if ordered
- // TODO EC20100616 don't work with required extensions :(
- List<WikittyExtension> extensions = Arrays.asList(
- ClientImpl.extensionClient,
- FormImpl.extensionForm,
- GroupImpl.extensionGroup,
- InfogeneImpl.extensionInfogene,
- ModificationTagImpl.extensionModificationTag,
- QueryMakerImpl.extensionQueryMaker,
- RootThesaurusImpl.extensionRootThesaurus,
- SendingImpl.extensionSending,
- SessionImpl.extensionSession,
- StatusImpl.extensionStatus,
- ThesaurusImpl.extensionThesaurus,
- WikittyTreeNodeImpl.extensionWikittyTreeNode,
- UserImpl.extensionUser,
- VradiUserImpl.extensionVradiUser,
- WebHarvestStreamImpl.extensionWebHarvestStream,
- WikittyUserImpl.extensionWikittyUser,
- XmlFieldBindingImpl.extensionXmlFieldBinding,
- XmlStreamImpl.extensionXmlStream,
- GroupFormsImpl.extensionGroupForms);
-
- localWikittyProxy.storeExtension(extensions);
- }
-
- /**
- * Check if version has changed and launch wikitty service reindex.
- *
- * @param localWikittyProxy local proxy
- */
- protected static void reindexData(WikittyProxy localWikittyProxy) {
- try {
-
- String currentVersion = VradiServiceConfigurationHelper.getApplicationVersion(config);
- String lastVersion = VradiServiceConfigurationHelper.getServiceVersion(config);
-
- // different is enougth to reindex
- // currentVersion is never null, lastVersion could be
- if (!currentVersion.equals(lastVersion)) {
-
- // do version change migration
- ServiceMigration.versionChangeMigration(lastVersion, currentVersion, localWikittyProxy);
-
- // Dont reindex data on version change
-// if (log.isInfoEnabled()) {
-// log.info(_("Version change detected : %s. Reindexing data...", lastVersion));
-// }
-// long timeBefore = System.currentTimeMillis();
-//
-// // call syncEngin
-// localWikittyProxy.syncEngin();
-//
-// long timeAfter = System.currentTimeMillis();
-//
-// if (log.isInfoEnabled()) {
-// log.info("Reindexing completed in " + (timeAfter - timeBefore) + " ms");
-// }
-
- // save new version
- VradiServiceConfigurationHelper.setServiceVersion(config, currentVersion);
- config.saveForUser();
- } else {
- if (log.isInfoEnabled()) {
- log.info("No version change, skipping reindexing.");
- }
- }
-
- // post operation : register migration classes
- ServiceMigration.configureMigration();
-
- } catch (Exception eee) {
- log.error("Failled to reindex data : ", eee);
- }
- }
-}
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceMigration.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceMigration.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceMigration.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -26,14 +26,31 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.vradi.VradiServiceConfigurationHelper;
+import org.chorem.vradi.entities.ClientImpl;
+import org.chorem.vradi.entities.FormImpl;
import org.chorem.vradi.entities.GroupForms;
import org.chorem.vradi.entities.GroupFormsImpl;
+import org.chorem.vradi.entities.GroupImpl;
+import org.chorem.vradi.entities.InfogeneImpl;
+import org.chorem.vradi.entities.ModificationTagImpl;
+import org.chorem.vradi.entities.QueryMakerImpl;
import org.chorem.vradi.entities.RootThesaurusImpl;
import org.chorem.vradi.entities.Sending;
+import org.chorem.vradi.entities.SendingImpl;
+import org.chorem.vradi.entities.SessionImpl;
import org.chorem.vradi.entities.Status;
+import org.chorem.vradi.entities.StatusImpl;
import org.chorem.vradi.entities.Thesaurus;
+import org.chorem.vradi.entities.ThesaurusImpl;
import org.chorem.vradi.entities.User;
+import org.chorem.vradi.entities.UserImpl;
import org.chorem.vradi.entities.VradiUser;
+import org.chorem.vradi.entities.VradiUserImpl;
+import org.chorem.vradi.entities.WebHarvestStreamImpl;
+import org.chorem.vradi.entities.XmlFieldBindingImpl;
+import org.chorem.vradi.entities.XmlStreamImpl;
+import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.Version;
import org.nuiton.util.VersionUtil;
import org.nuiton.wikitty.WikittyProxy;
@@ -43,6 +60,7 @@
import org.nuiton.wikitty.entities.WikittyImpl;
import org.nuiton.wikitty.entities.WikittyTreeNode;
import org.nuiton.wikitty.entities.WikittyTreeNodeImpl;
+import org.nuiton.wikitty.entities.WikittyUserImpl;
import org.nuiton.wikitty.search.Criteria;
import org.nuiton.wikitty.search.Search;
import org.nuiton.wikitty.search.operators.Element;
@@ -50,6 +68,7 @@
import org.nuiton.wikitty.services.WikittyExtensionMigrationRename;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Set;
@@ -485,4 +504,91 @@
(currentVersion.equals(migrationVersion)
|| currentVersion.after(migrationVersion));
}
+
+ /**
+ * Register all extensions.
+ * <p/>
+ * Already existing extensions with same version are skipped,
+ * new extension are created and stored.
+ *
+ * @param localWikittyProxy wikitty proxy
+ */
+ static void updateExtensions(WikittyProxy localWikittyProxy) {
+
+ // easier if ordered
+ // TODO EC20100616 don't work with required extensions :(
+ List<WikittyExtension> extensions = Arrays.asList(
+ ClientImpl.extensionClient,
+ FormImpl.extensionForm,
+ GroupImpl.extensionGroup,
+ InfogeneImpl.extensionInfogene,
+ ModificationTagImpl.extensionModificationTag,
+ QueryMakerImpl.extensionQueryMaker,
+ RootThesaurusImpl.extensionRootThesaurus,
+ SendingImpl.extensionSending,
+ SessionImpl.extensionSession,
+ StatusImpl.extensionStatus,
+ ThesaurusImpl.extensionThesaurus,
+ WikittyTreeNodeImpl.extensionWikittyTreeNode,
+ UserImpl.extensionUser,
+ VradiUserImpl.extensionVradiUser,
+ WebHarvestStreamImpl.extensionWebHarvestStream,
+ WikittyUserImpl.extensionWikittyUser,
+ XmlFieldBindingImpl.extensionXmlFieldBinding,
+ XmlStreamImpl.extensionXmlStream,
+ GroupFormsImpl.extensionGroupForms);
+
+ localWikittyProxy.storeExtension(extensions);
+ }
+
+ /**
+ * Check if version has changed and launch wikitty service reindex.
+ *
+ * @param config app configuration
+ * @param localWikittyProxy local proxy
+ */
+ protected static void reindexData(ApplicationConfig config, WikittyProxy localWikittyProxy) {
+ try {
+
+ String currentVersion = VradiServiceConfigurationHelper.getApplicationVersion(config);
+ String lastVersion = VradiServiceConfigurationHelper.getServiceVersion(config);
+
+ // different is enougth to reindex
+ // currentVersion is never null, lastVersion could be
+ if (!currentVersion.equals(lastVersion)) {
+
+ // do version change migration
+ ServiceMigration.versionChangeMigration(lastVersion, currentVersion, localWikittyProxy);
+
+ // Dont reindex data on version change
+// if (log.isInfoEnabled()) {
+// log.info(_("Version change detected : %s. Reindexing data...", lastVersion));
+// }
+// long timeBefore = System.currentTimeMillis();
+//
+// // call syncEngin
+// localWikittyProxy.syncEngin();
+//
+// long timeAfter = System.currentTimeMillis();
+//
+// if (log.isInfoEnabled()) {
+// log.info("Reindexing completed in " + (timeAfter - timeBefore) + " ms");
+// }
+
+ // save new version
+ VradiServiceConfigurationHelper.setServiceVersion(config, currentVersion);
+ config.saveForUser();
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("No version change, skipping reindexing.");
+ }
+ }
+
+ // post operation : register migration classes
+ ServiceMigration.configureMigration();
+
+ } catch (Exception eee) {
+ log.error("Failled to reindex data : ", eee);
+ }
+ }
}
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -106,17 +106,6 @@
* <p/>
* Make sure that wikitty proxy doesn't access remote service.
*
- * @param wikittyProxy wikitty proxy
- */
- public VradiDataServiceImpl(WikittyProxy wikittyProxy) {
- this(VradiServiceConfiguration.getConfig(), wikittyProxy);
- }
-
- /**
- * Constructor with a wikitty proxy.
- * <p/>
- * Make sure that wikitty proxy doesn't access remote service.
- *
* @param config vradi configuration
* @param wikittyProxy wikitty proxy
*/
Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceContext.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceContext.java (rev 0)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceContext.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -0,0 +1,113 @@
+package org.chorem.vradi.services;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.vradi.VradiServiceConfiguration;
+import org.chorem.vradi.VradiServiceConfigurationHelper;
+import org.nuiton.i18n.I18n;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.converter.ConverterUtil;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.WikittyService;
+import org.nuiton.wikitty.WikittyServiceFactory;
+
+/**
+ * Context to keep all instanciate service
+ *
+ * Must be used only for vradi service, for clients, please use {@link VradiServiceFactory}
+ *
+ * @author sletellier
+ */
+public class VradiServiceContext {
+
+ /** Log. */
+ private static final Log log = LogFactory.getLog(VradiServiceFactory.class);
+
+ /** Wikitty service (cached version) for remote access. */
+ protected static WikittyService vradiWikittyService;
+
+ /** Single instance of storage service. */
+ protected static VradiStorageService vradiStorageService;
+
+ /** Single instance of wikitty proxy. */
+ protected static WikittyProxy wikittyProxy;
+
+ protected static ApplicationConfig config;
+
+ static {
+ // Dans un block static pour definition des variables
+ // d'environnement solr et jbossts
+ // A voir pourquoi, les converters s'initialise mal durant les tests
+ try {
+
+ ConverterUtil.initConverters();
+ config = VradiServiceConfiguration.getConfig();
+ I18n.setDefaultLocale(VradiServiceConfigurationHelper.getLocale(config));
+ } catch (Exception eee) {
+ log.error("Cant initialize Service factory : ", eee);
+ }
+ }
+
+ public static synchronized VradiStorageService getVradiStorageService() {
+ if (vradiStorageService == null) {
+ vradiStorageService = new VradiStorageServiceImpl();
+ }
+ return vradiStorageService;
+ }
+
+ /**
+ * Creates wikitty service (cached).
+ * <p/>
+ * Getter for service, with default service configuration.
+ *
+ * @return a unique instance of WikittyService
+ */
+ public static synchronized WikittyService getWikittyService() {
+ if (vradiWikittyService == null) {
+ getWikittyService(config);
+ }
+
+ return vradiWikittyService;
+ }
+
+ /**
+ * Creates wikitty service (cached).
+ * <p/>
+ * Constructor added for UI embedded mode, with custom configuration.
+ *
+ * @param config configuration of vradi service
+ * @return a unique instance of WikittyService
+ */
+ public static synchronized WikittyService getWikittyService(ApplicationConfig config) {
+ if (vradiWikittyService == null) {
+
+ synchronized (VradiServiceContext.class) {
+ vradiWikittyService = WikittyServiceFactory.buildWikittyService(config);
+ }
+ }
+
+ return vradiWikittyService;
+ }
+
+ /**
+ * Creates wikitty proxy.
+ *
+ * @return a unique instance of WikittyProxy.
+ */
+ public static synchronized WikittyProxy getWikittyProxy() {
+ if (wikittyProxy == null) {
+ WikittyService wikittyService = getWikittyService();
+
+ // init proxy on cached service
+ wikittyProxy = new WikittyProxy(wikittyService);
+
+ // post operation : register extensions
+ ServiceMigration.updateExtensions(wikittyProxy);
+
+ // post operation : reindex data if necessary
+ ServiceMigration.reindexData(config, wikittyProxy);
+ }
+
+ return wikittyProxy;
+ }
+}
Copied: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java (from rev 53, trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java)
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java (rev 0)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -0,0 +1,165 @@
+/*
+ * #%L
+ * Vradi :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2010 Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.vradi.services;
+
+import gnu.cajo.utils.extra.TransparentItemProxy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.vradi.VradiServiceConfigurationHelper;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.WikittyService;
+
+/**
+ * VradiServiceFactory.
+ *
+ * @author $Author$
+ * @version $Revision$ $Date$
+ * @since 24 févr. 2010 22:18:17
+ */
+public class VradiServiceFactory {
+
+ /** Log. */
+ private static final Log log = LogFactory.getLog(VradiServiceFactory.class);
+
+ /**
+ * Build {@link VradiStorageService} instance with on remote mode
+ * if {@link org.chorem.vradi.VradiServiceConfiguration.VradiServiceOption#REMOTE_ENDPOINT}
+ * is filled in config pass in param.
+ *
+ * @param config config of application
+ * @return instance of vradiServiceStorage
+ */
+ public static VradiStorageService getVradiServiceStorage(ApplicationConfig config) {
+
+ synchronized(VradiServiceFactory.class) {
+ String serviceEndpoint = VradiServiceConfigurationHelper.getRemoteEndpoint(config);
+
+ VradiStorageService result = null;
+ // check is it's valid url
+ if (isValidUrl(serviceEndpoint)) {
+
+ try {
+
+ String cajoEndPoint = serviceEndpoint;
+ // cajo url is not http or other protocol, url must start with //
+ // example: //localhost:1198/ws
+ // remove protocol
+ int i = cajoEndPoint.indexOf("://");
+ if (i >= 0) {
+ cajoEndPoint = serviceEndpoint.substring(i+1);
+ }
+ int servicePort = VradiServiceConfigurationHelper.getServicePort(config);
+ serviceEndpoint = getServiceURL(cajoEndPoint, servicePort, VradiStorageService.VRADI_SERVICE);
+
+ if (log.isInfoEnabled()) {
+ log.info("Use remote mode with url : " + serviceEndpoint);
+ }
+ result = (VradiStorageService) TransparentItemProxy.getItem(
+ serviceEndpoint, new Class[]{VradiStorageService.class});
+
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't init remote proxy", eee);
+ }
+ }
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse remote serveur endpoint as valid url (" + serviceEndpoint + ")");
+ log.warn("Use local embedded mode");
+ }
+
+ result = new VradiStorageServiceImpl();
+ }
+ return result;
+ }
+ }
+
+ public static VradiDataService getVradiDataService(ApplicationConfig config, WikittyProxy proxy) {
+ return new VradiDataServiceImpl(config, proxy);
+ }
+
+ /**
+ * Get wikittyService instanciate by vradiService
+ *
+ * @param vradiService of application
+ * @return wikittyService instanciate
+ */
+ public static WikittyService getWikittyService(VradiStorageService vradiService) {
+ return vradiService.getWikittyService();
+ }
+
+ /**
+ * Get proxy instanciate with wikittyService
+ *
+ * @param wikittyService of application
+ * @return wikittyProxy
+ */
+ public static WikittyProxy getProxy(WikittyService wikittyService) {
+ return new WikittyProxy(wikittyService);
+ }
+
+ public static FileService getFileService(ApplicationConfig config) {
+
+ FileService fileService;
+ String serviceEndpoint = VradiServiceConfigurationHelper.getRemoteEndpoint(config);
+ if (isValidUrl(serviceEndpoint)) {
+ int servletPort = VradiServiceConfigurationHelper.getServletPort(config);
+ // file service
+ String fileServiceUrl = getServiceURL(serviceEndpoint, servletPort, "file");
+ log.info("File service url : " + fileServiceUrl);
+ fileService = new FileServiceProxy(fileServiceUrl);
+ } else {
+ fileService = new FileServiceImpl();
+ }
+ return fileService;
+ }
+
+ protected static boolean isValidUrl(String serviceEndpoint) {
+ return serviceEndpoint != null && serviceEndpoint.startsWith("http://");
+ }
+
+ /**
+ * Get service full url.
+ *
+ * @param serviceEndpoint end point (can't be null)
+ * @param serviceEndUrl service small name
+ * @return service full url
+ */
+ protected static String getServiceURL(String serviceEndpoint, int port, String serviceEndUrl) {
+ String fullUrl = serviceEndpoint;
+
+ // Add port if != 0
+ if (port != 0) {
+ fullUrl += ":" + port;
+ }
+
+ // Warn hessian won't work with double /
+ if (!fullUrl.endsWith("/")) {
+ fullUrl += "/";
+ }
+ fullUrl += serviceEndUrl;
+ return fullUrl;
+ }
+}
Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiServiceFactory.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageService.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageService.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageService.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -34,6 +34,7 @@
import org.chorem.vradi.entities.VradiUser;
import org.chorem.vradi.entities.WebHarvestStream;
import org.chorem.vradi.entities.XmlStream;
+import org.nuiton.wikitty.WikittyService;
import org.nuiton.wikitty.entities.WikittyExtension;
import org.nuiton.wikitty.search.Criteria;
@@ -58,7 +59,10 @@
*/
public interface VradiStorageService {
+ public static final String VRADI_SERVICE = "vradiservice";
+ WikittyService getWikittyService();
+
/**
* Create all default status.
*
@@ -402,4 +406,5 @@
* @throws VradiException if exception occured
*/
Form updateForms(Form form, List<String> thesaurusIdsToAttach) throws VradiException;
+
}
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -23,18 +23,14 @@
*/
package org.chorem.vradi.services;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.vradi.VradiConstants;
import org.chorem.vradi.VradiServiceConfiguration;
import org.chorem.vradi.VradiServiceConfigurationHelper;
-import org.chorem.vradi.beans.SendingHelper;
import org.chorem.vradi.beans.XmlStreamImportResult;
import org.chorem.vradi.entities.Client;
import org.chorem.vradi.entities.Form;
import org.chorem.vradi.entities.Group;
-import org.chorem.vradi.entities.Infogene;
import org.chorem.vradi.entities.QueryMaker;
import org.chorem.vradi.entities.Sending;
import org.chorem.vradi.entities.Session;
@@ -53,7 +49,6 @@
import org.chorem.vradi.services.managers.ThesaurusManager;
import org.chorem.vradi.services.tasks.TasksManager;
import org.nuiton.util.ApplicationConfig;
-import org.nuiton.util.DateUtil;
import org.nuiton.wikitty.WikittyException;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.WikittyService;
@@ -66,18 +61,11 @@
import org.nuiton.wikitty.search.operators.Element;
import java.io.File;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import static org.chorem.vradi.VradiConstants.SendingStatus;
import static org.chorem.vradi.VradiConstants.SessionStatus;
-import static org.nuiton.i18n.I18n._;
/**
* Vradi storage implementation.
@@ -114,9 +102,11 @@
protected FileService fileService;
- /** Remote instantiation and empty constructor for hessian. */
- public VradiStorageServiceImpl() {
- this(VradiServiceConfiguration.getConfig(), ServiceFactory.getWikittyProxy());
+ /**
+ * Must be instanciate using {@link VradiServiceFactory}
+ */
+ protected VradiStorageServiceImpl() {
+ this(VradiServiceConfiguration.getConfig(), VradiServiceContext.getWikittyProxy());
}
/**
@@ -163,6 +153,11 @@
return importExportService;
}
+ @Override
+ public WikittyService getWikittyService() {
+ return wikittyProxy.getWikittyService();
+ }
+
/**
* Create all default status.
*
Modified: trunk/vradi-services/src/main/resources/i18n/vradi-services_fr_FR.properties
===================================================================
--- trunk/vradi-services/src/main/resources/i18n/vradi-services_fr_FR.properties 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/resources/i18n/vradi-services_fr_FR.properties 2011-05-26 13:39:50 UTC (rev 54)
@@ -9,6 +9,9 @@
vradi.adminXmlStream.config.interval.hours=heures
vradi.adminXmlStream.config.interval.minutes=minutes
vradi.autoSend.hour.description=
+vradi.config.remote.endpoint.description=
+vradi.config.remote.service.port.description=
+vradi.config.remote.servlet.port.description=
vradi.email.status.deleted=Supprimée
vradi.email.status.error=Erreur
vradi.email.status.received=Reçu
Modified: trunk/vradi-services/src/main/resources/vradi-services.properties
===================================================================
--- trunk/vradi-services/src/main/resources/vradi-services.properties 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/main/resources/vradi-services.properties 2011-05-26 13:39:50 UTC (rev 54)
@@ -68,4 +68,4 @@
#wikitty.service.cache.priority.extensions=Thesaurus
jcs.default=
jcs.default.cacheattributes.MaxObjects=10000
-#jcs.priority.cacheattributes.MaxObjects=10000
+#jcs.priority.cacheattributes.MaxObjects=10000
\ No newline at end of file
Modified: trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestAbstract.java
===================================================================
--- trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestAbstract.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestAbstract.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -48,7 +48,7 @@
import org.chorem.vradi.entities.XmlStreamImpl;
import org.chorem.vradi.services.FileService;
import org.chorem.vradi.services.FileServiceImpl;
-import org.chorem.vradi.services.ServiceFactory;
+import org.chorem.vradi.services.VradiServiceContext;
import org.chorem.vradi.services.VradiDataService;
import org.chorem.vradi.services.VradiDataServiceImpl;
import org.chorem.vradi.services.VradiException;
@@ -59,7 +59,6 @@
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.Resource;
import org.nuiton.util.converter.ConverterUtil;
-import org.nuiton.wikitty.WikittyConfig;
import org.nuiton.wikitty.WikittyConfigOption;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.entities.BusinessEntity;
@@ -140,8 +139,8 @@
config = VradiTestConfiguration.getConfig();
- storageService = ServiceFactory.getVradiStorageService();
- wikittyProxy = ServiceFactory.getWikittyProxy();
+ storageService = VradiServiceContext.getVradiStorageService();
+ wikittyProxy = VradiServiceContext.getWikittyProxy();
wikittyProxy.clear();
dataService = new VradiDataServiceImpl(config, wikittyProxy);
fileService = new FileServiceImpl(config);
Modified: trunk/vradi-services-web/pom.xml
===================================================================
--- trunk/vradi-services-web/pom.xml 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services-web/pom.xml 2011-05-26 13:39:50 UTC (rev 54)
@@ -47,11 +47,6 @@
</dependency>
<dependency>
- <groupId>com.caucho</groupId>
- <artifactId>hessian</artifactId>
- </dependency>
-
- <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
Added: trunk/vradi-services-web/src/main/java/org/chorem/vradi/ApplicationListener.java
===================================================================
--- trunk/vradi-services-web/src/main/java/org/chorem/vradi/ApplicationListener.java (rev 0)
+++ trunk/vradi-services-web/src/main/java/org/chorem/vradi/ApplicationListener.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -0,0 +1,51 @@
+package org.chorem.vradi;
+
+import gnu.cajo.invoke.Remote;
+import gnu.cajo.utils.ItemServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.vradi.services.VradiServiceFactory;
+import org.chorem.vradi.services.VradiStorageService;
+import org.nuiton.util.ApplicationConfig;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import java.io.IOException;
+
+/**
+ * For init cajo services
+ *
+ * @author sletellier
+ */
+public class ApplicationListener implements ServletContextListener {
+
+ protected static final Log log =
+ LogFactory.getLog(ApplicationListener.class);
+
+ @Override
+ public void contextInitialized(ServletContextEvent sce) {
+ if (log.isInfoEnabled()) {
+ log.info("Vradi starting...");
+ }
+ // Init wikitty service
+ ApplicationConfig config = VradiServiceConfiguration.getConfig();
+
+ // get port and path part of server url, only that is used for cajo
+ try {
+ VradiStorageService storageService = VradiServiceFactory.getVradiServiceStorage(config);
+
+ int port = VradiServiceConfigurationHelper.getServicePort(config);
+
+ Remote.config(null, port, null, 0);
+ ItemServer.bind(storageService, VradiStorageService.VRADI_SERVICE);
+ log.info(String.format("The vradi server is running on %s:%s/%s",
+ Remote.getDefaultServerHost(), Remote.getDefaultServerPort(), VradiStorageService.VRADI_SERVICE));
+ } catch (IOException eee) {
+ log.error("Error ocurred binding service, abording", eee);
+ }
+ }
+
+ @Override
+ public void contextDestroyed(ServletContextEvent sce) {
+ }
+}
Deleted: trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java
===================================================================
--- trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -1,47 +0,0 @@
-/*
- * #%L
- * Vradi :: Services Web
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-package org.chorem.vradi.services;
-
-import org.nuiton.wikitty.services.WikittyServiceDelegator;
-
-/**
- * Wikitty proxy delegator.
- * <p/>
- * This delegator exist only because we cannot put instance as hessian service.
- * <p/>
- * This delegator just delegate everything to a static real wikitty service.
- *
- * @author chatellier
- * @version $Revision$
- * <p/>
- * Last update : $Date$
- * By : $Author$
- */
-public class VradiWikittyServiceDelegator extends WikittyServiceDelegator {
-
- public VradiWikittyServiceDelegator() {
- super(ServiceFactory.getWikittyService());
- }
-}
Modified: trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml 2011-05-26 13:39:50 UTC (rev 54)
@@ -29,48 +29,53 @@
<display-name>Vradi</display-name>
+ <!--<servlet>-->
+ <!--<servlet-name>vradiStorageServlet</servlet-name>-->
+ <!--<servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>-->
+ <!--<init-param>-->
+ <!--<param-name>home-api</param-name>-->
+ <!--<param-value>org.chorem.vradi.services.VradiStorageService</param-value>-->
+ <!--</init-param>-->
+ <!--<init-param>-->
+ <!--<param-name>home-class</param-name>-->
+ <!--<param-value>org.chorem.vradi.services.VradiStorageServiceImpl-->
+ <!--</param-value>-->
+ <!--</init-param>-->
+ <!--<load-on-startup>1</load-on-startup>-->
+ <!--</servlet>-->
+ <!--<servlet>-->
+ <!--<servlet-name>wikittyServiceServlet</servlet-name>-->
+ <!--<servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>-->
+ <!--<init-param>-->
+ <!--<param-name>home-api</param-name>-->
+ <!--<param-value>org.nuiton.wikitty.WikittyService</param-value>-->
+ <!--</init-param>-->
+ <!--<init-param>-->
+ <!--<param-name>home-class</param-name>-->
+ <!--<param-value>org.chorem.vradi.services.VradiWikittyServiceDelegator-->
+ <!--</param-value>-->
+ <!--</init-param>-->
+ <!--<load-on-startup>2</load-on-startup>-->
+ <!--</servlet>-->
<servlet>
- <servlet-name>vradiStorageServlet</servlet-name>
- <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
- <init-param>
- <param-name>home-api</param-name>
- <param-value>org.chorem.vradi.services.VradiStorageService</param-value>
- </init-param>
- <init-param>
- <param-name>home-class</param-name>
- <param-value>org.chorem.vradi.services.VradiStorageServiceImpl
- </param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>wikittyServiceServlet</servlet-name>
- <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
- <init-param>
- <param-name>home-api</param-name>
- <param-value>org.nuiton.wikitty.WikittyService</param-value>
- </init-param>
- <init-param>
- <param-name>home-class</param-name>
- <param-value>org.chorem.vradi.services.VradiWikittyServiceDelegator
- </param-value>
- </init-param>
- <load-on-startup>2</load-on-startup>
- </servlet>
- <servlet>
<servlet-name>fileServlet</servlet-name>
<servlet-class>org.chorem.vradi.services.FileServlet</servlet-class>
</servlet>
+ <!--<servlet-mapping>-->
+ <!--<servlet-name>vradiStorageServlet</servlet-name>-->
+ <!--<url-pattern>/vradiservice</url-pattern>-->
+ <!--</servlet-mapping>-->
+ <!--<servlet-mapping>-->
+ <!--<servlet-name>wikittyServiceServlet</servlet-name>-->
+ <!--<url-pattern>/wikittyservice</url-pattern>-->
+ <!--</servlet-mapping>-->
+ <listener>
+ <description>Init</description>
+ <listener-class>org.chorem.vradi.ApplicationListener</listener-class>
+ </listener>
+
<servlet-mapping>
- <servlet-name>vradiStorageServlet</servlet-name>
- <url-pattern>/vradiservice</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>wikittyServiceServlet</servlet-name>
- <url-pattern>/wikittyservice</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
<servlet-name>fileServlet</servlet-name>
<url-pattern>/file/*</url-pattern>
</servlet-mapping>
Modified: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java
===================================================================
--- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -43,7 +43,7 @@
@Override
public void clear() {
- WikittyProxy proxy = ServiceFactory.getWikittyProxy();
+ WikittyProxy proxy = VradiServiceContext.getWikittyProxy();
proxy.clear();
}
Deleted: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java
===================================================================
--- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -1,199 +0,0 @@
-/*
- * #%L
- * Vradi :: Services Web
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package org.chorem.vradi.services;
-
-import com.caucho.hessian.client.HessianProxyFactory;
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.vradi.VradiConstants;
-import org.chorem.vradi.beans.XmlStreamImportResult;
-import org.chorem.vradi.entities.Session;
-import org.chorem.vradi.entities.SessionImpl;
-import org.chorem.vradi.entities.XmlFieldBinding;
-import org.chorem.vradi.entities.XmlStream;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mortbay.jetty.runner.Runner;
-import org.nuiton.util.Resource;
-import org.nuiton.util.converter.ConverterUtil;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.WikittyService;
-import org.nuiton.wikitty.WikittyUtil;
-import org.nuiton.wikitty.entities.WikittyExtension;
-
-import java.net.URL;
-import java.util.Date;
-import java.util.List;
-
-/**
- * VradiHessianStorageTest.
- *
- * @author $Author$
- * @version $Revision$ $Date$
- * @since 21 févr. 2010 02:13:16
- */
-public class VradiHessianStorageTest extends VradiStorageServiceTest {
- static final Log log = LogFactory.getLog(VradiHessianStorageTest.class);
-
- static final String port = "9000";
-
- static final String clearUrl = "http://localhost:" + port + "/clearservice";
-
- static final String storageUrl = "http://localhost:" + port + "/vradiservice";
-
- static final String wikittyUrl = "http://localhost:" + port + "/wikittyservice";
-
- static final String fileUrl = "http://localhost:" + port + "/file";
-
- static VradiJettyRunner runner;
-
- public static class VradiJettyRunner extends Runner {
- @Override
- public void run() throws Exception {
- _server.start();
- // Skip join
- }
-
- public void stop() throws Exception {
- _server.stop();
- }
- }
-
- @BeforeClass
- public static void startServer() throws Exception {
- runner = new VradiJettyRunner();
-
- // This is the file to find to get the path of vradi-services-web module
- String placeHolder = "/vradi_services_web.place_holder";
-
- // Find the file
- URL url = Resource.getURL(placeHolder);
-
- // Remove the file name and folder 'target/test-classes'
- String contextPath = url.toString();
- String target = "/target/test-classes";
- contextPath = contextPath.substring(0, contextPath.length() - (placeHolder.length() + target.length()));
-
- // Add webapp context
- contextPath += "/src/test/webapp";
- String[] args = {"--port", port, contextPath};
- runner.configure(args);
-
- runner.run();
- }
-
- @AfterClass
- public static void stopServer() throws Exception {
- runner.stop();
- }
-
- @Override
- @Before
- public void clear() throws Exception {
- ConverterUtil.initConverters();
-
- HessianProxyFactory factory = new HessianProxyFactory();
- factory.setHessian2Request(true);
- factory.setOverloadEnabled(true);
-
- log.debug("--clear-----------------------------------------");
- ClearService clearService = (ClearService) factory.create(ClearService.class, clearUrl);
- clearService.clear();
- storageService = (VradiStorageService) factory.create(VradiStorageService.class, storageUrl);
- WikittyService wikittyService = (WikittyService) factory.create(WikittyService.class, wikittyUrl);
- wikittyProxy = new WikittyProxy(wikittyService);
- dataService = new VradiDataServiceImpl(wikittyProxy);
-
- // fait avec le proxy > servlet pour tester
- fileService = new FileServiceProxy(fileUrl);
- }
-
- @Override
- protected XmlStreamImportResult initData(WikittyExtension extension)
- throws Exception {
- List<XmlFieldBinding> bindings = createXmlBindings(extension);
- XmlStream xmlStream = createXmlStream(extension, bindings);
- return storageService.importFormsFromXmlStream(xmlStream);
- }
-
- /*
- * TODO add doc about this test !!!
- *
- */
- @Test
- public void testPropagation() throws Exception {
-
- Session session = new SessionImpl();
-
- session.setNum(7);
- wikittyProxy.getWikitty(session).addExtension(
- new WikittyExtension("ouaf", "2.0", null,
- WikittyUtil.buildFieldMapExtension(
- "Numeric a",
- "Numeric b",
- "String c")));
- session.setSessionDate(new Date());
-
- session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue());
-
- session = wikittyProxy.store(session);
-
- session.setField("ouaf", "a", 1);
- session.setField("ouaf", "b", 1.0);
- session.setField("ouaf", "c", "Ouaf");
- session.setNum(1);
- session.setSessionDate(DateUtils.addMinutes(new Date(), 15));
- Session sessionService = wikittyProxy.store(session);
-
- if (session.getWikittyId().equals(sessionService.getWikittyId())) {
- int scInt = wikittyProxy.getWikitty(sessionService).getFieldAsInt("ouaf", "a");
- int lcInt = wikittyProxy.getWikitty(session).getFieldAsInt("ouaf", "a");
-
- Float scFloat = wikittyProxy.getWikitty(sessionService).getFieldAsFloat("ouaf", "b");
- Float lcFloat = wikittyProxy.getWikitty(session).getFieldAsFloat("ouaf", "b");
-
- String scString = wikittyProxy.getWikitty(sessionService).getFieldAsString("ouaf", "c");
- String lcString = wikittyProxy.getWikitty(session).getFieldAsString("ouaf", "c");
-
- log.info("testPropagation result, local : " + session.getNum() + " serveur : " + sessionService.getNum());
- log.info("testPropagation result as int, local : " + lcInt + " serveur : " + scInt);
- log.info("testPropagation result as float, local : " + lcFloat + " serveur : " + scFloat);
- log.info("testPropagation result as String, local : " + lcString + " serveur : " + scString);
- log.info("testPropagation result, local : " + session.getSessionDate() + " serveur : " + sessionService.getSessionDate());
-
- Assert.assertEquals(session.getNum(), sessionService.getNum());
- Assert.assertEquals(lcInt, scInt);
- Assert.assertEquals(lcFloat, scFloat);
- Assert.assertEquals(lcString, scString);
- Assert.assertEquals(session.getSessionDate(), sessionService.getSessionDate());
- }
-
- wikittyProxy.delete(session.getWikittyId());
- }
-
-}
Modified: trunk/vradi-swing/pom.xml
===================================================================
--- trunk/vradi-swing/pom.xml 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-swing/pom.xml 2011-05-26 13:39:50 UTC (rev 54)
@@ -86,12 +86,6 @@
</dependency>
<dependency>
- <groupId>org.nuiton.wikitty</groupId>
- <artifactId>wikitty-hessian-client</artifactId>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
@@ -112,11 +106,6 @@
</dependency>
<dependency>
- <groupId>com.caucho</groupId>
- <artifactId>hessian</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>runtime</scope>
Modified: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfig.java
===================================================================
--- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfig.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfig.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -170,12 +170,6 @@
_("vradi.config.password"),
"", String.class, true, true),
- // achitecture client serveur
- REMOTE_ENDPOINT(
- "vradi.remote.endpoint",
- _("vradi.config.remote.endpoint.description"),
- "", String.class, false, false),
-
// user datas
QUERIES(
"vradi.queries",
Modified: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfigHelper.java
===================================================================
--- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfigHelper.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfigHelper.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -165,19 +165,6 @@
}
/**
- * Get remote endpoint base url.
- * <p/>
- * If not valid url, embedded mode is used.
- *
- * @param config vradi swing configuration
- * @return remote endpoint base url
- */
- public static String getRemoteEndpoint(ApplicationConfig config) {
- String endpoint = config.getOption(VradiConfig.VradiSwingOption.REMOTE_ENDPOINT.key);
- return endpoint;
- }
-
- /**
* Get user queries (comma separated).
* <p/>
* Warning to inner comma in queries, use {@link StringUtil#split(String, String)}
@@ -372,15 +359,4 @@
config.setOption(VradiConfig.VradiSwingOption.THESAURUS_EXPANDED.key, String.valueOf(state));
config.saveForUser();
}
-
- /**
- * Change remote endpoint url.
- *
- * @param config vradi swing configuration
- * @param newEndpoint new base url
- */
- public static void setRemoteEndPoint(ApplicationConfig config, String newEndpoint) {
- config.setOption(VradiConfig.VradiSwingOption.REMOTE_ENDPOINT.key, newEndpoint);
- }
-
}
Modified: trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java
===================================================================
--- trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -23,23 +23,14 @@
*/
package org.chorem.vradi.services;
-import com.caucho.hessian.client.HessianProxyFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.vradi.VradiConfigHelper;
import org.nuiton.util.ApplicationConfig;
-import org.nuiton.wikitty.WikittyConfig;
-import org.nuiton.wikitty.WikittyConfigOption;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.WikittyService;
-import org.nuiton.wikitty.WikittyServiceFactory;
-import java.net.MalformedURLException;
-
/**
* Vradi service management.
- * <p/>
- * Can handle embedded server or remote hessian service.
*
* @author $Author$
* @version $Revision$ $Date$
@@ -72,91 +63,18 @@
*/
public static void initServiceProxies(ApplicationConfig configuration) {
- String serviceEndpoint = VradiConfigHelper.getRemoteEndpoint(configuration);
+ vradiStorageService = VradiServiceFactory.getVradiServiceStorage(configuration);
- // check is it's valid url
- if (serviceEndpoint != null && serviceEndpoint.startsWith("http://")) {
- if (log.isInfoEnabled()) {
- log.info("Use remote mode with url : " + serviceEndpoint);
- }
+ wikittyService = VradiServiceFactory.getWikittyService(vradiStorageService);
- HessianProxyFactory factory = new HessianProxyFactory();
- // Fix : com.caucho.hessian.io.HessianProtocolException: '���' is an unknown code
- factory.setHessian2Request(true);
- // pour que les méthodes aux noms dupliquées fonctionnent (arguments different)
- factory.setOverloadEnabled(true);
+ fileService = VradiServiceFactory.getFileService(configuration);
- try {
+ wikittyProxy = VradiServiceFactory.getProxy(wikittyService);
- // vradi service
- vradiStorageService = (VradiStorageService) factory.create(VradiStorageService.class,
- getServiceURL(serviceEndpoint, "vradiservice"));
-
- wikittyService = initLocalWikittyService(configuration);
-
- // file service
- fileService = new FileServiceProxy(getServiceURL(serviceEndpoint, "file"));
-
- } catch (MalformedURLException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't init remote proxy", eee);
- }
- }
- } else {
- if (log.isWarnEnabled()) {
- log.warn("Can't parse remote serveur endpoint as valid url (" + serviceEndpoint + ")");
- log.warn("Use local embedded mode");
- }
-
- vradiStorageService = new VradiStorageServiceImpl();
- wikittyService = ServiceFactory.getWikittyService(configuration);
- fileService = new FileServiceImpl();
- }
-
- // wrap service local/remote to a proxy
- wikittyProxy = new WikittyProxy();
- wikittyProxy.setWikittyService(wikittyService);
-
- // init data service on local cached wikitty proxy
- vradiDataService = new VradiDataServiceImpl(wikittyProxy);
+ vradiDataService = VradiServiceFactory.getVradiDataService(configuration, wikittyProxy);
}
/**
- * Create a new wikitty service with cache support that use
- * provided WikittyService for non cached data.
- *
- * @param configuration vradi server configuration
- * @return local wikitty service
- */
- protected static WikittyService initLocalWikittyService(ApplicationConfig configuration) {
-
- log.info("Propagation event is set to : " + VradiConfigHelper.getWikittyEventPropagate(configuration));
- log.info("XMPP server is set to : " + VradiConfigHelper.getWikittyEventTransporterXMPPServer(configuration));
- log.info("XMPP room is set to : " + VradiConfigHelper.getWikittyEventTransporterXMPPRoom(configuration));
-
- WikittyService wikittyServiceLocal = WikittyServiceFactory.buildWikittyService(configuration);
- return wikittyServiceLocal;
- }
-
- /**
- * Get service full url.
- *
- * @param serviceEndpoint end point (can't be null)
- * @param serviceEndUrl service small name
- * @return service full url
- */
- protected static String getServiceURL(String serviceEndpoint, String serviceEndUrl) {
- String fullUrl = serviceEndpoint;
-
- // Warn hessian won't work with double /
- if (!fullUrl.endsWith("/")) {
- fullUrl += "/";
- }
- fullUrl += serviceEndUrl;
- return fullUrl;
- }
-
- /**
* Get remote vradi service (execute code on server).s
*
* @return vradi storage service proxy
Modified: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUIHandler.java
===================================================================
--- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUIHandler.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUIHandler.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -386,9 +386,9 @@
modelBuilder.addOption(VradiConfig.VradiSwingOption.LOCALE);
// category 3
- modelBuilder.addCategory(n_("vradi.config.category.remote"),
- n_("vradi.config.category.remote.description"));
- modelBuilder.addOption(VradiConfig.VradiSwingOption.REMOTE_ENDPOINT);
+// modelBuilder.addCategory(n_("vradi.config.category.remote"),
+// n_("vradi.config.category.remote.description"));
+// modelBuilder.addOption(VradiConfig.VradiSwingOption.REMOTE_ENDPOINT);
modelBuilder.buildUI(context, "vradi.config.category.directories");
Modified: trunk/vradi-swing/src/main/resources/vradi.properties
===================================================================
--- trunk/vradi-swing/src/main/resources/vradi.properties 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-swing/src/main/resources/vradi.properties 2011-05-26 13:39:50 UTC (rev 54)
@@ -31,8 +31,7 @@
application.organisation.url=${project.organization.url}
# Wikitty
-wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceHessianClient,\
-org.nuiton.wikitty.services.WikittyServiceNotifier,\
+wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceNotifier,\
org.nuiton.wikitty.services.WikittyServiceCached,\
org.nuiton.wikitty.services.WikittyServiceSecurity
wikitty.service.cache.allwaysRestoreCopies=false
Modified: trunk/vradi-web/pom.xml
===================================================================
--- trunk/vradi-web/pom.xml 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-web/pom.xml 2011-05-26 13:39:50 UTC (rev 54)
@@ -186,12 +186,6 @@
</dependency>
<dependency>
- <groupId>org.nuiton.wikitty</groupId>
- <artifactId>wikitty-hessian-client</artifactId>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>runtime</scope>
Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/VradiProxy.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/VradiProxy.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/VradiProxy.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -4,10 +4,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.vradi.entities.Attachment;
+import org.chorem.vradi.services.VradiServiceFactory;
+import org.chorem.vradi.services.VradiStorageService;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.WikittyService;
-import org.nuiton.wikitty.WikittyServiceFactory;
import org.nuiton.wikitty.search.Criteria;
import org.nuiton.wikitty.search.PagedResult;
import org.nuiton.wikitty.search.Search;
@@ -37,9 +38,11 @@
* @param token
* @return
*/
- static public VradiProxy getInstance(String token) {
+ static public VradiProxy getInstance(VradiStorageService vradiStorageService, String token) {
ApplicationConfig config = VradiWebConfig.getConfig();
- WikittyService ws = getWikittyService(config);
+ if (ws == null) {
+ ws = VradiServiceFactory.getWikittyService(vradiStorageService);
+ }
VradiProxy result = new VradiProxy(config, ws);
result.setSecurityToken(token);
@@ -47,35 +50,17 @@
}
/**
- * Returns WikittyService to use. This WikittyService is singleton.
- *
- * @param config
- * @return WikittyService instance
- */
- static protected WikittyService getWikittyService(ApplicationConfig config) {
- if (ws == null) {
- synchronized(VradiProxy.class) {
- if (ws == null) {
- ws = WikittyServiceFactory.buildWikittyService(config);
- }
- }
- }
- return ws;
- }
-
- /**
* Returns the attachments linked with a wikitty id ordered descending
* by date
*
* @param formNoteId
* @return the list of attachments
*/
- static public List<Attachment> getAttachments(String formNoteId) {
+ public List<Attachment> getAttachments(String formNoteId) {
Criteria criteria = Search.query().
eq(Attachment.FQ_FIELD_ATTACHMENT_FORMNOTE, formNoteId)
.criteria().addSortDescending(Attachment.FQ_FIELD_ATTACHMENT_DATE);
- PagedResult<Attachment> result = getInstance(null).
- findAllByCriteria(Attachment.class, criteria);
+ PagedResult<Attachment> result = findAllByCriteria(Attachment.class, criteria);
List<Attachment> attachments = result.getAll();
return attachments;
}
Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/VradiSession.java 2011-05-26 13:39:50 UTC (rev 54)
@@ -1,6 +1,5 @@
package org.chorem.vradi;
-import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -8,15 +7,11 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.vradi.entities.VradiUser;
import org.chorem.vradi.services.VradiDataService;
-import org.chorem.vradi.services.VradiDataServiceImpl;
+import org.chorem.vradi.services.VradiServiceFactory;
+import org.chorem.vradi.services.VradiStorageService;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.util.ApplicationConfig;
-import org.nuiton.wikitty.WikittyConfigOption;
-import org.nuiton.wikitty.WikittyProxy;
-import org.nuiton.wikitty.WikittyService;
-import org.nuiton.wikitty.WikittyServiceFactory;
-import org.nuiton.wikitty.entities.WikittyUser;
/**
* Classe utilisee pour stocker les objets utils en session utilisateur
@@ -39,6 +34,7 @@
transient protected VradiProxy proxy = null;
transient protected VradiDataService dataService;
+ transient protected VradiStorageService vradiServiceStorage;
public VradiSession() {
// FIXME poussin 20110521 ?
@@ -64,7 +60,7 @@
public VradiProxy getProxy() {
if (proxy == null) {
- proxy = VradiProxy.getInstance(securityToken);
+ proxy = VradiProxy.getInstance(getVradiStorageService(), securityToken);
}
return proxy;
}
@@ -101,13 +97,25 @@
return result;
}
+ public VradiStorageService getVradiStorageService() {
+ if (vradiServiceStorage == null) {
+ synchronized(VradiSession.class) {
+ if (vradiServiceStorage == null) {
+ ApplicationConfig config = VradiWebConfig.getConfig();
+ vradiServiceStorage = VradiServiceFactory.getVradiServiceStorage(config);
+ }
+ }
+ }
+ return vradiServiceStorage;
+ }
+
public VradiDataService getDataService() {
if (dataService == null) {
synchronized(VradiSession.class) {
if (dataService == null) {
ApplicationConfig config = VradiWebConfig.getConfig();
VradiProxy proxy = getProxy();
- dataService = new VradiDataServiceImpl(config, proxy);
+ dataService = VradiServiceFactory.getVradiDataService(config, proxy);
}
}
}
Modified: trunk/vradi-web/src/main/resources/vradi-web.properties
===================================================================
--- trunk/vradi-web/src/main/resources/vradi-web.properties 2011-05-26 09:47:13 UTC (rev 53)
+++ trunk/vradi-web/src/main/resources/vradi-web.properties 2011-05-26 13:39:50 UTC (rev 54)
@@ -37,7 +37,6 @@
wikitty.service.event.listen=true
wikitty.service.event.propagate.transporter=org.nuiton.wikitty.services.XMPPNotifierTransporter
wikitty.WikittyServiceCached.components=org.nuiton.wikitty.services.WikittyCacheJCS
-wikitty.service.server.url=${vradi.remote.endpoint}/wikittyservice
wikitty.service.cache.priority.extensions=Thesaurus, User, Status, XmlStream
jcs.default=
jcs.default.cacheattributes.MaxObjects=1000
1
0
Author: bpoussin
Date: 2011-05-26 11:47:13 +0200 (Thu, 26 May 2011)
New Revision: 53
Url: http://chorem.org/repositories/revision/vradi/53
Log:
- add jquery plugin (better than dojo)
- add rst action (generate from rst and set field if necessary)
- add AbstractEditAction used for EditAction and RSTAction to filter acceptable wikitty field
Modified:
trunk/vradi-web/src/main/resources/struts.xml
Modified: trunk/vradi-web/src/main/resources/struts.xml
===================================================================
--- trunk/vradi-web/src/main/resources/struts.xml 2011-05-26 09:46:08 UTC (rev 52)
+++ trunk/vradi-web/src/main/resources/struts.xml 2011-05-26 09:47:13 UTC (rev 53)
@@ -4,11 +4,18 @@
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
- <constant name="struts.devMode" value="true"/>
+ <constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.ognl.allowStaticMethodAccess" value="true"/>
- <constant name="struts.enable.SlashesInActionNames" value="true"/>
<!--
+ | next constant is for development process, in production this constants
+ | must be removed
+ +-->
+ <constant name="struts.devMode" value="true"/>
+ <constant name="struts.ognl.logMissingProperties" value="true" />
+ <constant name="struts.el.throwExceptionOnFailure" value="true" />
+
+ <!--
| Definition d'un package pour l'espace public
| - surcharge de parametre de certain intercepteur
+-->
@@ -112,5 +119,28 @@
<result type="wikitty-json"/>
</action>
</package>
-
+
+ <package name="ajax" namespace="/ajax" extends="restrictedArea">
+ <!--
+ | Essai de generer du HTML a partir d'un champs d'un objet ou du
+ | parametre 'rst'
+ +-->
+ <action name="rst" class="org.chorem.vradi.actions.RSTAction">
+ <param name="includes">FormNote\.summary,FormNote\.content</param>
+ <result type="stream">
+ <param name="contentType">${mimeType}</param>
+ <param name="inputName">rstResult</param>
+ </result>
+ </action>
+ <!--
+ | Edit n'importe qu'elle objet en modifiant les valeurs des champs retrouve
+ | en parametre
+ +-->
+ <action name="edit/*" class="org.chorem.vradi.actions.EditAction">
+ <param name="id">{1}</param>
+ <param name="includes">FormNote\..*</param>
+ <result type="wikitty-json"/>
+ </action>
+ </package>
+
</struts>
1
0
r52 - in trunk: . vradi-web vradi-web/src/main/java/org/chorem/vradi/actions vradi-web/src/main/resources vradi-web/src/main/webapp/WEB-INF/jsp
by bpoussin@users.chorem.org 26 May '11
by bpoussin@users.chorem.org 26 May '11
26 May '11
Author: bpoussin
Date: 2011-05-26 11:46:08 +0200 (Thu, 26 May 2011)
New Revision: 52
Url: http://chorem.org/repositories/revision/vradi/52
Log:
- add jquery plugin (better than dojo)
- add rst action (generate from rst and set field if necessary)
- add AbstractEditAction used for EditAction and RSTAction to filter acceptable wikitty field
Added:
trunk/vradi-web/src/main/java/org/chorem/vradi/actions/AbstractEditAction.java
trunk/vradi-web/src/main/java/org/chorem/vradi/actions/RSTAction.java
Modified:
trunk/pom.xml
trunk/vradi-web/pom.xml
trunk/vradi-web/src/main/java/org/chorem/vradi/actions/EditAction.java
trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormNoteAction.java
trunk/vradi-web/src/main/resources/struts.properties
trunk/vradi-web/src/main/webapp/WEB-INF/jsp/formNote.jsp
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-05-25 16:58:41 UTC (rev 51)
+++ trunk/pom.xml 2011-05-26 09:46:08 UTC (rev 52)
@@ -120,6 +120,7 @@
<javamailVersion>1.4.3</javamailVersion>
<slf4jVersion>1.6.1</slf4jVersion>
<struts2Version>2.2.3</struts2Version>
+ <struts2jqueryVersion>3.0.1</struts2jqueryVersion>
<servletApiVersion>2.5</servletApiVersion>
<jspApiVersion>2.0</jspApiVersion>
@@ -421,6 +422,32 @@
</dependency>
<dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-plugin</artifactId>
+ <version>${struts2jqueryVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-grid-plugin</artifactId>
+ <version>${struts2jqueryVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-richtext-plugin</artifactId>
+ <version>${struts2jqueryVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-tree-plugin</artifactId>
+ <version>${struts2jqueryVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-mobile-plugin</artifactId>
+ <version>${struts2jqueryVersion}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dojo-plugin</artifactId>
<version>${struts2Version}</version>
Modified: trunk/vradi-web/pom.xml
===================================================================
--- trunk/vradi-web/pom.xml 2011-05-25 16:58:41 UTC (rev 51)
+++ trunk/vradi-web/pom.xml 2011-05-26 09:46:08 UTC (rev 52)
@@ -86,6 +86,27 @@
</dependency>
<dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-plugin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-grid-plugin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-richtext-plugin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-tree-plugin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jgeppert.struts2.jquery</groupId>
+ <artifactId>struts2-jquery-mobile-plugin</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dojo-plugin</artifactId>
<scope>runtime</scope>
Added: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/AbstractEditAction.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/AbstractEditAction.java (rev 0)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/AbstractEditAction.java 2011-05-26 09:46:08 UTC (rev 52)
@@ -0,0 +1,99 @@
+package org.chorem.vradi.actions;
+
+import java.util.Arrays;
+import java.util.List;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Looking for if fqfield match excludes and includes pattern list.
+ * <p>
+ * action param:
+ * <li>excludes: comma separated list of pattern
+ * <li>includes: comma separated list of pattern
+ *
+ * <p>
+ * sub classes can use isAcceptable(String) to know if field is accepted or not
+ *
+ * Exclude property expressions take precedence over includes property
+ * expressions. That is, if you use includes and excludes property expressions
+ * on the same result, includes property expressions will not be applied if an
+ * excludes excludes property expression matches a property first.
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public abstract class AbstractEditAction extends VradiBaseAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(AbstractEditAction.class);
+
+ protected List<String> excludes;
+ protected List<String> includes;
+
+ /**
+ *
+ * @param includes comma seperated list of pattern
+ */
+ public void setExcludes(String excludeString) {
+ // remove all blank and newline
+ excludeString = excludeString.replaceAll("\\s", "");
+ String[] excludeTab = excludeString.split(",");
+ this.excludes = Arrays.asList(excludeTab);
+ }
+
+ /**
+ *
+ * @param includes comma seperated list of pattern
+ */
+ public void setIncludes(String includeString) {
+ // remove all blank and newline
+ includeString = includeString.replaceAll("\\s", "");
+ String[] includeTab = includeString.split(",");
+ this.includes = Arrays.asList(includeTab);
+ }
+
+ protected boolean isAcceptable(String fqfield) {
+ Boolean result = null;
+ if (CollectionUtils.isEmpty(includes) && CollectionUtils.isEmpty(excludes)) {
+ // si pas de precission, on accepte tout
+ result = Boolean.TRUE;
+ } else {
+ // les excludes sont prioritaires
+ if (!CollectionUtils.isEmpty(excludes)) {
+ for (String ex : excludes) {
+ if (fqfield.matches(ex)) {
+ result = Boolean.FALSE;
+ break;
+ }
+ }
+ }
+ if (result == null) {
+ if (!CollectionUtils.isEmpty(includes)) {
+ // si pas dans les excludes, on regarde dans les includes
+ // vu qu'on a des includes, par defaut si on ne trouve pas
+ // d'includes qui match le fqfield, on retourne false
+ result = Boolean.FALSE;
+ for (String in : includes) {
+ if (fqfield.matches(in)) {
+ result = Boolean.TRUE;
+ break;
+ }
+ }
+ } else {
+ // pas de includes, donc tout est vrai
+ result = Boolean.TRUE;
+ }
+ }
+ }
+ log.debug(String.format(
+ "Accept field '%s' is %s with excludes: %s and includes: %s",
+ fqfield, result, excludes, includes));
+ return result;
+ }
+
+}
Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/EditAction.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/EditAction.java 2011-05-25 16:58:41 UTC (rev 51)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/EditAction.java 2011-05-26 09:46:08 UTC (rev 52)
@@ -1,7 +1,6 @@
package org.chorem.vradi.actions;
import com.opensymphony.xwork2.ActionContext;
-import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -19,7 +18,7 @@
* Last update: $Date$
* by : $Author$
*/
-public class EditAction extends VradiBaseAction implements ServletRequestAware {
+public class EditAction extends AbstractEditAction implements ServletRequestAware {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(EditAction.class);
@@ -29,19 +28,10 @@
}
/** restraint les modifications possibles sur certaine extension */
- protected String restrictedExtension;
protected HttpServletRequest request;
protected String id;
protected Wikitty wikitty;
- public String getRestrictedExtension() {
- return restrictedExtension;
- }
-
- public void setRestrictedExtension(String restrictedExtension) {
- this.restrictedExtension = restrictedExtension;
- }
-
@Override
public void setServletRequest(HttpServletRequest request) {
this.request = request;
@@ -59,21 +49,6 @@
return wikitty;
}
- protected boolean isAcceptableExtension(String fqfield) {
- boolean result = false;
- if (StringUtils.isBlank(restrictedExtension)) {
- result = true;
- } else {
- try {
- String extName = WikittyExtension.extractExtensionName(fqfield);
- result = restrictedExtension.contains(extName);
- } catch(Exception eee) {
- log.debug("Not acceptable extension format", eee);
- }
- }
- return result;
- }
-
@Override
public String execute() throws Exception {
String result = SUCCESS;
@@ -84,7 +59,7 @@
for (Object key : request.getParameterMap().keySet()) {
String k = String.valueOf(key);
log.debug(String.format("Look for field(%s)", k));
- if (wikitty.hasField(k) && isAcceptableExtension(k)) {
+ if (wikitty.hasField(k) && isAcceptable(k)) {
Object v = request.getParameter(k);
log.debug(String.format("Put value(%s) in field(%s)", v, k));
wikitty.setFqField(k, v);
Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormNoteAction.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormNoteAction.java 2011-05-25 16:58:41 UTC (rev 51)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormNoteAction.java 2011-05-26 09:46:08 UTC (rev 52)
@@ -114,13 +114,13 @@
// Render JRST in HTML
try {
- summary = JRST.generate(JRST.TYPE_HTML, formNote.getSummary());
+ summary = JRST.generate(JRST.TYPE_HTML_INNER_BODY, formNote.getSummary());
} catch(Exception eee) {
log.info("Can't generate HTML from RST", eee);
summary = formNote.getSummary();
}
try {
- content = JRST.generate(JRST.TYPE_HTML, formNote.getContent());
+ content = JRST.generate(JRST.TYPE_HTML_INNER_BODY, formNote.getContent());
} catch(Exception eee) {
log.info("Can't generate HTML from RST", eee);
content = formNote.getContent();
Added: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/RSTAction.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/RSTAction.java (rev 0)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/RSTAction.java 2011-05-26 09:46:08 UTC (rev 52)
@@ -0,0 +1,122 @@
+package org.chorem.vradi.actions;
+
+import java.io.InputStream;
+import java.io.StringBufferInputStream;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.jrst.JRST;
+import org.nuiton.wikitty.WikittyProxy;
+import org.nuiton.wikitty.entities.Wikitty;
+import org.nuiton.wikitty.entities.WikittyExtension;
+
+/**
+ * Convert rst string in other format. Default format is
+ * {@link JRST#TYPE_HTML_INNER_BODY}
+ * <p>
+ * algo:
+ * <li> if {@link #id} and {@link #field} is present and {@link #rst} is present
+ * this field is set with rst value.
+ * <li> rst is set with field value (if field is present)
+ * <li> rst is converted in rstResultType and result is put in rstResult
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class RSTAction extends AbstractEditAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(RSTAction.class);
+
+ /** optional: wikitty id */
+ protected String id;
+ /** optional: fq wikitty field */
+ protected String field;
+ /** optionnal rst string */
+ protected String rst;
+ /** result stream */
+ protected InputStream rstResult;
+ /** rstResultType */
+ protected String rstResultType = JRST.TYPE_HTML_INNER_BODY;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getField() {
+ return field;
+ }
+
+ public void setField(String field) {
+ this.field = field;
+ }
+
+ public String getRst() {
+ return rst;
+ }
+
+ public void setRst(String rst) {
+ this.rst = rst;
+ }
+
+ public String getRstResultType() {
+ return rstResultType;
+ }
+
+ public void setRstResultType(String rstResultType) {
+ this.rstResultType = rstResultType;
+ }
+
+ public InputStream getRstResult() {
+ return rstResult;
+ }
+
+ public String getMimeType() {
+ String result = JRST.getMimeType(getRstResultType());
+ return result;
+ }
+
+ @Override
+ public String execute() throws Exception {
+ // si on arrive pas a lire l'objet ou le champs on renvoie ca
+ try {
+ if (isAcceptable(field)) {
+ WikittyProxy proxy = getProxy();
+ Wikitty w = proxy.restore(getId());
+ String ext = WikittyExtension.extractExtensionName(field);
+ String fieldName = WikittyExtension.extractFieldName(field);
+
+ if (rst != null) {
+ // rst est renseigne, on commence par mettre a jour le champs
+ w.setField(ext, fieldName, rst);
+ proxy.store(w);
+ }
+ // on recupere la valeur du champs
+ rst = w.getFieldAsString(ext, fieldName);
+
+ // si on arrive pas a faire la generation a partir du champs
+ // on renvoi le champs en brut
+ rst = JRST.generate(rstResultType, rst);
+ } else {
+ rst = "<pre>Not acceptable field</pre>";
+ }
+ } catch(Exception eee) {
+ log.info("Can't generate HTML from RST", eee);
+ // on a pas reussi a genere le HTML, le texte doit donc etre mis
+ // dans un element <pre> pour une meilleur presentation
+ if (rst == null) {
+ rst = "Can't be generate";
+ }
+ rst = "<pre>" + rst + "</pre>";
+ }
+ rstResult = new StringBufferInputStream(rst);
+ return SUCCESS;
+ }
+
+}
Modified: trunk/vradi-web/src/main/resources/struts.properties
===================================================================
--- trunk/vradi-web/src/main/resources/struts.properties 2011-05-25 16:58:41 UTC (rev 51)
+++ trunk/vradi-web/src/main/resources/struts.properties 2011-05-26 09:46:08 UTC (rev 52)
@@ -24,7 +24,7 @@
struts.i18n.reload=true
-struts.ui.theme=xhtml
+struts.ui.theme=css_xhtml
struts.ui.templateDir=template
#sets the default template type. Either ftl, vm, or jsp
struts.ui.templateSuffix=ftl
Modified: trunk/vradi-web/src/main/webapp/WEB-INF/jsp/formNote.jsp
===================================================================
--- trunk/vradi-web/src/main/webapp/WEB-INF/jsp/formNote.jsp 2011-05-25 16:58:41 UTC (rev 51)
+++ trunk/vradi-web/src/main/webapp/WEB-INF/jsp/formNote.jsp 2011-05-26 09:46:08 UTC (rev 52)
@@ -8,18 +8,24 @@
<%@page import="org.chorem.vradi.entities.Attachment"%>
<%@page import="org.chorem.vradi.entities.FormNote"%>
<%@page import="org.chorem.vradi.actions.FormNoteAction"%>
+
<%@page contentType="text/html" pageEncoding="UTF-8"%>
+
<%@taglib prefix="s" uri="/struts-tags"%>
-<%@taglib prefix="sx" uri="/struts-dojo-tags"%>
+<%@taglib prefix="sj" uri="/struts-jquery-tags"%>
<%
FormNoteAction action = FormNoteAction.getAction();
FormNote formNote = action.getFormNote();
ActionContext.getContext().put("localNoteId", formNote.getWikittyId());
+ActionContext.getContext().put("localFieldSeekingPartner", FormNote.FQ_FIELD_FORMNOTE_SEEKINGPARTNER);
ActionContext.getContext().put("localFieldSummary", FormNote.FQ_FIELD_FORMNOTE_SUMMARY);
ActionContext.getContext().put("localFieldContent", FormNote.FQ_FIELD_FORMNOTE_CONTENT);
ActionContext.getContext().put("localNote", formNote);
+ActionContext.getContext().put("localSeekingPartner", formNote.getSeekingPartner());
+ActionContext.getContext().put("localSummary", formNote.getSummary());
+ActionContext.getContext().put("localContent", formNote.getContent());
%>
<!DOCTYPE html>
@@ -27,7 +33,8 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><s:text name="vradi.formNote.title" /></title>
- <sx:head />
+ <s:head/>
+ <sj:head jquerytheme="sunny"/>
</head>
<body>
<h1><s:text name="vradi.formNote.title" /></h1>
@@ -46,37 +53,55 @@
<div>
<s:select size="5" list="partners" listKey="wikittyId" listValue="login"/>
<s:a action="seekPartners/%{localNoteId}"><s:text name="vradi.formNote.seekPartners" /></s:a>
- <s:checkbox label="seeking partners" name="formNote.seekingPartners"
- onchange="var xhr=new XMLHttpRequest(); xhr.open('GET', 'edit/%{localNoteId}.action?seekingPartners='+this.checked, true);xhr.send(null);"/>
+ <s:checkbox label="seeking partners" name="formNote.seekingPartners" value="%{localSeekingPartner}"
+ onchange="var url='/ajax/edit/%{localNoteId}.action?%{localFieldSeekingPartner}='+this.checked; var xhr=new XMLHttpRequest(); xhr.open('GET', url, true);xhr.send(null); alert(url);"/>
</div>
<div>
- <sx:tabbedpanel id="tabContainer">
- <sx:div label="Summary" >
- <iframe>
+ <sj:tabbedpanel id="tabContainerSummary" animate="true"
+ collapsible="true" useSelectedTabCookie="true">
+ <sj:tab id="tabHtmlSummary" target="htmlSummary" label="Summary"/>
+ <sj:tab id="tabHtmlSummaryEdit" target="htmlSummaryEdit" label="Edit"/>
+ <div id="htmlSummary">
<%=action.getSummary()%>
- </iframe>
- </sx:div>
- <sx:div label="Edit" >
- <s:textarea><%=formNote.getSummary()%></s:textarea>
- </sx:div>
- </sx:tabbedpanel>
- <div>
- <s:a action="editText?id=%{localNoteId}&field=%{localFieldSummary}">
- <s:text name="vradi.text.edit"/>
- </s:a>
- </div>
+ </div>
+ <div id="htmlSummaryEdit">
+ <s:form id="htmlSummaryEditForm" action="/ajax/rst.action">
+ <s:hidden name="id" value="%{localNoteId}"/>
+ <s:hidden name="field" value="%{localFieldSummary}"/>
+ <s:textarea name="rst" value="%{localSummary}"/>
+ </s:form>
+ <sj:a id="htmlSummaryEditSubmit" formIds="htmlSummaryEditForm"
+ targets="htmlSummary" indicator="indicator"
+ button="true" buttonIcon="ui-icon-gear">
+ <s:text name="vradi.edit.save"/>
+ </sj:a>
+ <img id="indicator" src="images/indicator.gif" alt="Loading..." style="display:none"/>
+ </div>
+ </sj:tabbedpanel>
</div>
<div>
- <iframe>
- <%=action.getContent()%>
- </iframe>
- <div>
- <s:a action="editText?id=%{localNoteId}&field=%{localFieldContent}">
- <s:text name="vradi.text.edit"/>
- </s:a>
- </div>
+ <sj:tabbedpanel id="tabContainerContent" animate="true"
+ collapsible="true" useSelectedTabCookie="true">
+ <sj:tab id="tabHtmlContent" target="htmlContent" label="Summary"/>
+ <sj:tab id="tabHtmlContentEdit" target="htmlContentEdit" label="Edit"/>
+ <div id="htmlContent" >
+ <%=action.getContent()%>
+ </div>
+ <div id="htmlContentEdit" >
+ <s:form id="htmlContentEditForm" action="/ajax/edit.action">
+ <s:hidden name="id" value="%{localNoteId}"/>
+ <s:hidden name="field" value="%{localFieldSummary}"/>
+ <s:textarea name="content" value="%{localContent}"/>
+ </s:form>
+ <sj:a id="htmlContentEditSubmit" formIds="htmlContentEditForm"
+ targets="htmlContent" indicator="indicator"
+ button="true" buttonIcon="ui-icon-gear">
+ <s:text name="vradi.edit.save"/>
+ </sj:a>
+ </div>
+ </sj:tabbedpanel>
</div>
<div>
1
0
r51 - in trunk/vradi-web/src/main: resources/i18n webapp/WEB-INF/jsp
by sletellier@users.chorem.org 25 May '11
by sletellier@users.chorem.org 25 May '11
25 May '11
Author: sletellier
Date: 2011-05-25 18:58:41 +0200 (Wed, 25 May 2011)
New Revision: 51
Url: http://chorem.org/repositories/revision/vradi/51
Log:
- Don't use ognl
- Add link to edit forms notes
Modified:
trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties
trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties
trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp
Modified: trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties
===================================================================
--- trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties 2011-05-25 13:54:55 UTC (rev 50)
+++ trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties 2011-05-25 16:58:41 UTC (rev 51)
@@ -26,3 +26,4 @@
vradi.search.title=Search
vradi.form.object=Object
vradi.form.creationDate=Creation date
+vradi.search.formNoteEdit=Notes edition
\ No newline at end of file
Modified: trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties
===================================================================
--- trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties 2011-05-25 13:54:55 UTC (rev 50)
+++ trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties 2011-05-25 16:58:41 UTC (rev 51)
@@ -25,5 +25,6 @@
vradi.register.pwdDontMatch=Les mots de passe sont différents
vradi.register.submit=S'enregistrer
vradi.register.title=S'enregistrer
+vradi.search.formNoteEdit=Edition des notes
vradi.search.submit=Rechercher
vradi.search.title=Recherche
Modified: trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp
===================================================================
--- trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp 2011-05-25 13:54:55 UTC (rev 50)
+++ trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp 2011-05-25 16:58:41 UTC (rev 51)
@@ -1,11 +1,12 @@
<%@page import="org.chorem.vradi.entities.Infogene"%>
+<%@page import="org.chorem.vradi.decorators.EscapeScriptColomnDecorator" %>
+<%@page import="org.chorem.vradi.entities.Form" %>
+<%@page import="org.chorem.vradi.decorators.DateFormatColumnDecorator" %>
<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="displaytag" uri="http://displaytag.sf.net"%>
-<script type="text/javascript" src="/js/jquery-1.6.1.min.js"></script>
-<html xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
- xmlns:jsp="http://java.sun.com/JSP/Page">
+<html>
<head>
<s:url var="css" value="/css/search.css" />
<link href="${css}" rel="stylesheet" type="text/css" />
@@ -26,13 +27,18 @@
property="<%=Infogene.FIELD_INFOGENE_CREATIONDATE%>"
sortable="true"
sortProperty="<%=Infogene.FQ_FIELD_INFOGENE_CREATIONDATE%>"
- decorator="org.chorem.vradi.decorators.DateFormatColumnDecorator"/>
+ decorator="<%=DateFormatColumnDecorator.class.getName()%>"/>
<displaytag:column titleKey="vradi.form.object"
property="<%=Infogene.FIELD_INFOGENE_OBJET%>"
sortable="true"
sortProperty="<%=Infogene.FQ_FIELD_INFOGENE_OBJET%>"
- decorator="org.chorem.vradi.decorators.EscapeScriptColomnDecorator"/>
+ decorator="<%=EscapeScriptColomnDecorator.class.getName()%>"/>
+
+ <displaytag:column titleKey="common.action" class="action">
+ <s:set name="formNoteListURl"><%="formNoteList/" + ((Form)f).getWikittyId()%></s:set>
+ <s:a action="%{formNoteListURl}"><s:text name="vradi.search.formNoteEdit"/></s:a>
+ </displaytag:column>
</displaytag:table>
</body>
</html>
\ No newline at end of file
1
0
r50 - in trunk/vradi-web/src: main/i18n main/java/org/chorem/vradi main/java/org/chorem/vradi/actions main/java/org/chorem/vradi/decorators main/resources main/resources/i18n main/webapp main/webapp/WEB-INF/jsp main/webapp/css main/webapp/img test/java test/java/org test/java/org/chorem test/java/org/chorem/vradi
by sletellier@users.chorem.org 25 May '11
by sletellier@users.chorem.org 25 May '11
25 May '11
Author: sletellier
Date: 2011-05-25 15:54:55 +0200 (Wed, 25 May 2011)
New Revision: 50
Url: http://chorem.org/repositories/revision/vradi/50
Log:
- Add table css
- Add image for render sort
- Fix pagination
- Add escape scipt balise decorator -> add unit test
- Fix i18n
Added:
trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebHelper.java
trunk/vradi-web/src/main/java/org/chorem/vradi/decorators/
trunk/vradi-web/src/main/java/org/chorem/vradi/decorators/DateFormatColumnDecorator.java
trunk/vradi-web/src/main/java/org/chorem/vradi/decorators/EscapeScriptColomnDecorator.java
trunk/vradi-web/src/main/resources/displaytag.properties
trunk/vradi-web/src/main/webapp/css/
trunk/vradi-web/src/main/webapp/css/search.css
trunk/vradi-web/src/main/webapp/img/
trunk/vradi-web/src/main/webapp/img/arrow_down.png
trunk/vradi-web/src/main/webapp/img/arrow_off.png
trunk/vradi-web/src/main/webapp/img/arrow_up.png
trunk/vradi-web/src/test/java/org/
trunk/vradi-web/src/test/java/org/chorem/
trunk/vradi-web/src/test/java/org/chorem/vradi/
trunk/vradi-web/src/test/java/org/chorem/vradi/VradiWebHelperTest.java
Modified:
trunk/vradi-web/src/main/i18n/jsp.rules
trunk/vradi-web/src/main/java/org/chorem/vradi/FormPaginatedList.java
trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormNoteAction.java
trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SearchAction.java
trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties
trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties
trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp
Modified: trunk/vradi-web/src/main/i18n/jsp.rules
===================================================================
--- trunk/vradi-web/src/main/i18n/jsp.rules 2011-05-25 13:51:42 UTC (rev 49)
+++ trunk/vradi-web/src/main/i18n/jsp.rules 2011-05-25 13:54:55 UTC (rev 50)
@@ -11,3 +11,6 @@
//s:select/@key
//sx:datetimepicker/@key
+
+//displaytag:column/@title
+//displaytag:column/@titleKey
Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/FormPaginatedList.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/FormPaginatedList.java 2011-05-25 13:51:42 UTC (rev 49)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/FormPaginatedList.java 2011-05-25 13:54:55 UTC (rev 50)
@@ -1,11 +1,15 @@
package org.chorem.vradi;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.vradi.beans.FormPagedResult;
import org.chorem.vradi.entities.Form;
+import org.chorem.vradi.entities.Infogene;
import org.displaytag.pagination.PaginatedList;
import org.displaytag.properties.SortOrderEnum;
import org.nuiton.wikitty.WikittyProxy;
+import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@@ -13,14 +17,35 @@
*/
public class FormPaginatedList implements PaginatedList {
+ protected static final Log log = LogFactory.getLog(FormPaginatedList.class);
+
+ public static final int NB_FORMS_TO_SHOW = 100;
+ public static final String DISPLAY_URL_PAGE = "page";
+ public static final String DISPLAY_URL_SORT = "sort";
+ public static final String DISPLAY_URL_DIR = "dir";
+
protected FormPagedResult result;
protected WikittyProxy proxy;
- public FormPaginatedList(WikittyProxy proxy, FormPagedResult result) {
- this.result = result;
+ public FormPaginatedList(WikittyProxy proxy) {
this.proxy = proxy;
+ result = new FormPagedResult();
+ result.setNbFormsToShow(NB_FORMS_TO_SHOW);
+ result.setPageToShow(1);
+
+ // Sort by default by fate descending
+ result.setAscending(false);
+ result.setFieldToSort(Infogene.FIELD_INFOGENE_CREATIONDATE);
}
+ public FormPagedResult getResult() {
+ return result;
+ }
+
+ public void setResult(FormPagedResult result) {
+ this.result = result;
+ }
+
@Override
public List<Form> getList() {
List<String> formsIdsToShow = result.getFormsIdsToShow();
@@ -45,16 +70,64 @@
@Override
public String getSortCriterion() {
- return null;
+ return result.getFieldToSort();
}
@Override
public SortOrderEnum getSortDirection() {
- return null;
+ if (result.isAscending()) {
+ return SortOrderEnum.ASCENDING;
+ } else {
+ return SortOrderEnum.DESCENDING;
+ }
}
@Override
public String getSearchId() {
+
+ // Not used
return null;
}
+
+ /**
+ * Recupere les parametres depuis une requete de servlet.
+ *
+ * @param request la requete utilisee pour recuperee les valeur du POJO
+ * @return l'instance
+ */
+ public FormPaginatedList fromRequest(HttpServletRequest request) {
+
+ // Number of forms by pages
+ String page = request.getParameter(DISPLAY_URL_PAGE);
+ if (page != null && !page.trim().isEmpty()) {
+ Integer pageNumber = Integer.valueOf(page);
+ if (log.isDebugEnabled()) {
+ log.debug("change pageNumber : " + pageNumber);
+ }
+ result.setPageToShow(pageNumber);
+ }
+
+ // Search field criteria
+ String criterion = request.getParameter(DISPLAY_URL_SORT);
+ if (criterion != null && !criterion.trim().isEmpty()) {
+ if (log.isDebugEnabled()) {
+ log.debug("change sortCriterion : " + criterion);
+ }
+ result.setFieldToSort(criterion);
+ }
+
+ // attention, on supose ici qu'on a defini les variables suivantes dans displaytag.properties :
+ // pagination.sort.asc.value=ascending
+ // pagination.sort.desc.value=descending
+ String direction = request.getParameter(DISPLAY_URL_DIR);
+ if (direction != null && !direction.trim().isEmpty()) {
+ SortOrderEnum orderEnum = SortOrderEnum.fromName(direction);
+ if (log.isDebugEnabled()) {
+ log.debug("change sortDirection : " + orderEnum);
+ }
+ boolean ascending = orderEnum.equals(SortOrderEnum.ASCENDING);
+ result.setAscending(ascending);
+ }
+ return this;
+ }
}
Added: trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebHelper.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebHelper.java (rev 0)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/VradiWebHelper.java 2011-05-25 13:54:55 UTC (rev 50)
@@ -0,0 +1,15 @@
+package org.chorem.vradi;
+
+/**
+ * Utilities class
+ *
+ * @author sletellier
+ */
+public class VradiWebHelper {
+
+ public static String escapeSciptBalises(String txt) {
+
+ // (?s) activ dotall (http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#D…)
+ return txt.replaceAll("(?s)<script>.*</script>", "");
+ }
+}
Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormNoteAction.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormNoteAction.java 2011-05-25 13:51:42 UTC (rev 49)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormNoteAction.java 2011-05-25 13:54:55 UTC (rev 50)
@@ -111,8 +111,8 @@
}
partners = proxy.restore(VradiUser.class, formNote.getPartners());
-
- // TODO evolution JRST: permettre l'entre String/StringBuffer/Reader, et la sortie String/StringBuffer/Writer pour generate
+
+ // Render JRST in HTML
try {
summary = JRST.generate(JRST.TYPE_HTML, formNote.getSummary());
} catch(Exception eee) {
Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SearchAction.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SearchAction.java 2011-05-25 13:51:42 UTC (rev 49)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SearchAction.java 2011-05-25 13:54:55 UTC (rev 50)
@@ -17,11 +17,9 @@
public class SearchAction extends VradiBaseAction implements ServletRequestAware {
private static final long serialVersionUID = -3735250067223062719L;
+ public static final String REQUEST_ATTRIBUTE_FORMS = "forms";
- public static final int NB_FORMS_TO_SHOW = 100;
-
protected String query;
- protected FormPagedResult result;
protected HttpServletRequest request;
public String getQuery() {
@@ -42,23 +40,23 @@
*/
public String execute() {
- if (result == null) {
- result = new FormPagedResult();
- result.setNbFormsToShow(NB_FORMS_TO_SHOW);
- }
+ FormPaginatedList paginatedList = new FormPaginatedList(getProxy());
+ paginatedList.fromRequest(request);
+
QueryParameters queryParameters = new QueryParameters(query);
try {
- result = getDataService().findForms(queryParameters, result);
- log.info(result.getTotalFoundFormNb() + " forms found");
+ FormPagedResult result = paginatedList.getResult();
+ FormPagedResult forms = getDataService().findForms(queryParameters, result);
+ paginatedList.setResult(forms);
} catch (VradiException eee) {
log.error("Failed to execute query", eee);
} catch (UnsupportedQueryException eee) {
log.error("Unsuported query", eee);
}
- request.setAttribute("forms", new FormPaginatedList(getProxy(), result));
+ request.setAttribute(REQUEST_ATTRIBUTE_FORMS, paginatedList);
return SUCCESS;
}
Added: trunk/vradi-web/src/main/java/org/chorem/vradi/decorators/DateFormatColumnDecorator.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/decorators/DateFormatColumnDecorator.java (rev 0)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/decorators/DateFormatColumnDecorator.java 2011-05-25 13:54:55 UTC (rev 50)
@@ -0,0 +1,27 @@
+package org.chorem.vradi.decorators;
+
+import org.displaytag.decorator.DisplaytagColumnDecorator;
+import org.displaytag.exception.DecoratorException;
+import org.displaytag.properties.MediaTypeEnum;
+import org.nuiton.util.DateUtil;
+
+import javax.servlet.jsp.PageContext;
+import java.util.Date;
+
+/**
+ * Decorator used to display tooltip on form lines
+ *
+ * @author sletellier
+ */
+public class DateFormatColumnDecorator implements DisplaytagColumnDecorator {
+
+ @Override
+ public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media) throws DecoratorException {
+
+ if (columnValue == null) {
+ return null;
+ }
+ String txt = DateUtil.formatDate((Date)columnValue, "dd-MM-yyyy");
+ return txt;
+ }
+}
Added: trunk/vradi-web/src/main/java/org/chorem/vradi/decorators/EscapeScriptColomnDecorator.java
===================================================================
--- trunk/vradi-web/src/main/java/org/chorem/vradi/decorators/EscapeScriptColomnDecorator.java (rev 0)
+++ trunk/vradi-web/src/main/java/org/chorem/vradi/decorators/EscapeScriptColomnDecorator.java 2011-05-25 13:54:55 UTC (rev 50)
@@ -0,0 +1,28 @@
+package org.chorem.vradi.decorators;
+
+import org.chorem.vradi.VradiWebHelper;
+import org.displaytag.decorator.DisplaytagColumnDecorator;
+import org.displaytag.exception.DecoratorException;
+import org.displaytag.properties.MediaTypeEnum;
+
+import javax.servlet.jsp.PageContext;
+
+/**
+ * This decorator is used to remove all scipts balises found in content of columns (to prevent attacks)
+ *
+ * @author sletellier
+ */
+public class EscapeScriptColomnDecorator implements DisplaytagColumnDecorator {
+
+ @Override
+ public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media) throws DecoratorException {
+
+ if (columnValue == null) {
+ return null;
+ }
+ String txt = columnValue.toString();
+ txt = VradiWebHelper.escapeSciptBalises(txt);
+
+ return txt;
+ }
+}
Added: trunk/vradi-web/src/main/resources/displaytag.properties
===================================================================
--- trunk/vradi-web/src/main/resources/displaytag.properties (rev 0)
+++ trunk/vradi-web/src/main/resources/displaytag.properties 2011-05-25 13:54:55 UTC (rev 50)
@@ -0,0 +1,20 @@
+basic.empty.showtable=true
+basic.msg.empty_list=Vide
+basic.msg.empty_list_row=<tr class="empty"><td colspan="{0}">Vide</td></tr></tr>
+
+sort.amount=list
+
+paging.banner.placement=bottom
+paging.banner.item_name=\u00e9l\u00e9ment
+paging.banner.items_name=\u00e9l\u00e9ments
+paging.banner.no_items_found=<span class="pagebanner">Aucun {0} trouv\u00e9.</span>
+paging.banner.one_item_found=<span class="pagebanner">Un seul {0} trouv\u00e9.</span>
+paging.banner.all_items_found=<span class="pagebanner">{0} {1} trouv\u00e9s, tout afficher {2}.</span>
+paging.banner.some_items_found=<span class="pagebanner">{0} {1} trouv\u00e9s, affich\u00e9 de {2} \u00e0 {3}.</span>
+paging.banner.full=<span class="pagelinks">[<a href="{1}">Premier</a>/<a href="{2}">Pr\u00e9c\u00e9dent</a>]{0} [<a href="{3}">Suivant</a>/<a href="{4}">Dernier</a>]</span>
+paging.banner.first=<span class="pagelinks">[Permier/Pr\u00e9c\u00e9dent] {0} [<a href="{3}">Suivant</a>/<a href="{4}">Dernier</a>]</span>
+paging.banner.last=<span class="pagelinks">[<a href="{1}">Premier</a>/<a href="{2}">Pr\u00e9c\u00e9dent</a>]{0} [Suivant/Dernier]</span>
+paging.banner.page.link=<a href="{1}" title="Aller \u00e0 {0}">{0}</a>
+
+pagination.sort.asc.value=ascending
+pagination.sort.desc.value=descending
Modified: trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties
===================================================================
--- trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties 2011-05-25 13:51:42 UTC (rev 49)
+++ trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties 2011-05-25 13:54:55 UTC (rev 50)
@@ -24,3 +24,5 @@
vradi.register.title=Login
vradi.search.submit=Search
vradi.search.title=Search
+vradi.form.object=Object
+vradi.form.creationDate=Creation date
Modified: trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties
===================================================================
--- trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties 2011-05-25 13:51:42 UTC (rev 49)
+++ trunk/vradi-web/src/main/resources/i18n/vradi-web_fr_FR.properties 2011-05-25 13:54:55 UTC (rev 50)
@@ -1,4 +1,4 @@
-vradi.authentification.error=
+vradi.authentification.error=Erreur lors de l'authentification
vradi.config.configFileName.description=Fichier de configuration de Vradi web
vradi.config.database.version.description=Version de la base de donnée
vradi.config.last.version.description=Dernière version de Vradi web lancée
@@ -9,6 +9,8 @@
vradi.forgotPassword.emailDoesntExist=Cette adresse email n'existe pas
vradi.forgotpwd.submit=Envoyer
vradi.forgotpwd.title=Vous avez oublié votre mot de passe ?
+vradi.form.creationDate=Date de création
+vradi.form.object=Objet
vradi.login.email=Email
vradi.login.password=Mot de passe
vradi.login.repeatPassword=Confiramtion
Modified: trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp
===================================================================
--- trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp 2011-05-25 13:51:42 UTC (rev 49)
+++ trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp 2011-05-25 13:54:55 UTC (rev 50)
@@ -1,21 +1,38 @@
-<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
+<%@page import="org.chorem.vradi.entities.Infogene"%>
+<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="displaytag" uri="http://displaytag.sf.net"%>
+<script type="text/javascript" src="/js/jquery-1.6.1.min.js"></script>
+
<html xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
xmlns:jsp="http://java.sun.com/JSP/Page">
<head>
+ <s:url var="css" value="/css/search.css" />
+ <link href="${css}" rel="stylesheet" type="text/css" />
<title><s:text name="vradi.search.title" /></title>
<s:head />
</head>
<body>
<s:form id="searchForm" action="search" method="post">
<s:textarea id="searchArea" name="query"/>
- <s:submit key="vradi.search.submit" name="submit" />
+ <s:submit key="vradi.search.submit" name="submit"/>
</s:form>
- <displaytag:table name="forms" id="f" requestURI="search.action">
- <displaytag:column titleKey="vradi.form.title" property="creationDate"/>
- <displaytag:column titleKey="vradi.form.title" property="objet"/>
- <displaytag:column titleKey="vradi.form.title" property="sourceURL"/>
+ <displaytag:table name="forms"
+ sort="list"
+ id="f"
+ requestURI="search.action">
+
+ <displaytag:column titleKey="vradi.form.creationDate"
+ property="<%=Infogene.FIELD_INFOGENE_CREATIONDATE%>"
+ sortable="true"
+ sortProperty="<%=Infogene.FQ_FIELD_INFOGENE_CREATIONDATE%>"
+ decorator="org.chorem.vradi.decorators.DateFormatColumnDecorator"/>
+
+ <displaytag:column titleKey="vradi.form.object"
+ property="<%=Infogene.FIELD_INFOGENE_OBJET%>"
+ sortable="true"
+ sortProperty="<%=Infogene.FQ_FIELD_INFOGENE_OBJET%>"
+ decorator="org.chorem.vradi.decorators.EscapeScriptColomnDecorator"/>
</displaytag:table>
</body>
</html>
\ No newline at end of file
Added: trunk/vradi-web/src/main/webapp/css/search.css
===================================================================
--- trunk/vradi-web/src/main/webapp/css/search.css (rev 0)
+++ trunk/vradi-web/src/main/webapp/css/search.css 2011-05-25 13:54:55 UTC (rev 50)
@@ -0,0 +1,42 @@
+
+/* Tableau */
+table {border-collapse:collapse; width: 100%;}
+.subTable th {font-weight: normal;}
+
+td {
+ border: 1px solid black;
+ padding:5px;}
+td.action {text-align: right; white-space:nowrap;}
+th {
+ background-color: #eee;
+ border: 1px solid black;
+ padding: 4px;
+}
+
+th a:hover {color: black;}
+th a,th a:visited {
+ text-decoration: none;
+ font-weight:bold;
+ color: black;
+ background-repeat: no-repeat;
+}
+
+/* Tri sur une table */
+th.sorted a,th.sortable a {background-position: right; display: block;}
+th.sortable a {background-image: url(../img/arrow_off.png);}
+th.order1 a {background-image: url(../img/arrow_down.png);}
+th.order2 a {background-image: url(../img/arrow_up.png);}
+tr.odd:hover, tr.even:hover { background-color:#deecf1; cursor: pointer;}
+
+/* Pagination sur une table */
+span.pagebanner, span.pagelinks {
+ background-color: #eee;
+ border: 1px solid black;
+ padding: 2px;
+ display: block;
+ text-align: center;
+}
+
+span.pagebanner{margin-top: 10px; border-bottom: none;}
+span.pagelinks {border-top: none; margin-bottom: 10px;}
+span.pagelinks a, span.pagelinks a:visited{color:black;}
Added: trunk/vradi-web/src/main/webapp/img/arrow_down.png
===================================================================
(Binary files differ)
Property changes on: trunk/vradi-web/src/main/webapp/img/arrow_down.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vradi-web/src/main/webapp/img/arrow_off.png
===================================================================
(Binary files differ)
Property changes on: trunk/vradi-web/src/main/webapp/img/arrow_off.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vradi-web/src/main/webapp/img/arrow_up.png
===================================================================
(Binary files differ)
Property changes on: trunk/vradi-web/src/main/webapp/img/arrow_up.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vradi-web/src/test/java/org/chorem/vradi/VradiWebHelperTest.java
===================================================================
--- trunk/vradi-web/src/test/java/org/chorem/vradi/VradiWebHelperTest.java (rev 0)
+++ trunk/vradi-web/src/test/java/org/chorem/vradi/VradiWebHelperTest.java 2011-05-25 13:54:55 UTC (rev 50)
@@ -0,0 +1,72 @@
+package org.chorem.vradi;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+/**
+ * @author sletellier
+ */
+public class VradiWebHelperTest {
+
+ @Test
+ public void testEscapeSciptBalises() {
+ String content = "aaa <p> ppp <br> <script>toRemove</script> </p>";
+
+ String result = VradiWebHelper.escapeSciptBalises(content);
+ Assert.assertNotSame(content, result);
+ Assert.assertFalse(result.contains("toRemove"));
+ }
+
+ @Test
+ public void testEscapeSciptBalisesMultiLine() {
+ String content = "\n" +
+ "<script>\n" +
+ " function openPublicAliasForm(bookmarkId) {\n" +
+ " $(\"#publicAliasFormBookmarkId\")[0].value = bookmarkId;\n" +
+ " $(\"#setPublicAliasPopup\").dialog(\"open\");\n" +
+ " return false;\n" +
+ " }\n" +
+ " \n" +
+ " $(function() {\n" +
+ " $( \"#setPublicAliasPopup\" ).dialog({\n" +
+ " autoOpen: false,\n" +
+ " width: 300,\n" +
+ " modal: true,\n" +
+ "// buttons: {\n" +
+ "// \"Validate\": function() {\n" +
+ "// $(\"#setPublicAliasForm\").submit();\n" +
+ "// $( this ).dialog( \"close\" );\n" +
+ "// },\n" +
+ "// Cancel: function() {\n" +
+ "// $( this ).dialog( \"close\" );\n" +
+ "// }\n" +
+ "// },\n" +
+ " close: function() {\n" +
+ " //allFields.val( \"\" ).removeClass( \"ui-state-error\" );\n" +
+ " }\n" +
+ " });\n" +
+ " });\n" +
+ " function submitPublicAlias() {\n" +
+ " $(\"#setPublicAliasForm\").submit();\n" +
+ " closePopupAddUrl();\n" +
+ " }\n" +
+ "\n" +
+ " function closePopupPublicAlias() {\n" +
+ " $( \"#setPublicAliasPopup\" ).dialog( \"close\" )\n" +
+ " }\n" +
+ "</script>\n" +
+ "\n" +
+ "<div xmlns:s=\"http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd\"\n" +
+ " id=\"setPublicAliasPopup\" title=\"Entrer un alias public\">\n" +
+ " <form id=\"setPublicAliasForm\" name=\"setPublicAliasForm\" action=\"createAlias\" method=\"post\">\n" +
+ "<table class=\"wwFormTable\"><tr>\n" +
+ " <td class=\"tdLabel\"><label for=\"setPublicAliasForm_alias\" class=\"label\">ALIAS:</label></td>\n" +
+ " <td\n" +
+ "><input type=\"text\" name=\"alias\" value=\"\" id=\"setPublicAliasForm_alias\" class=\"class java.util.HashMap\"/></td>\n" +
+ "</tr>\n" +
+ "<input type=\"hidden\" name=\"bookmarkId\" value=\"\" id=\"publicAliasFormBookmarkId\"/></table></form>";
+ String result = VradiWebHelper.escapeSciptBalises(content);
+ Assert.assertNotSame(content, result);
+ Assert.assertFalse(result.contains("<script>"));
+ }
+}
1
0
r49 - in trunk: vradi-services/src/main/java/org/chorem/vradi/beans vradi-services/src/main/java/org/chorem/vradi/services/managers vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers
by sletellier@users.chorem.org 25 May '11
by sletellier@users.chorem.org 25 May '11
25 May '11
Author: sletellier
Date: 2011-05-25 15:51:42 +0200 (Wed, 25 May 2011)
New Revision: 49
Url: http://chorem.org/repositories/revision/vradi/49
Log:
[Search] Return same but filled FormPagedResult passed on param
Modified:
trunk/vradi-services/src/main/java/org/chorem/vradi/beans/FormPagedResult.java
trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/SearchManager.java
trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/SendingViewManager.java
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/FormPagedResult.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/beans/FormPagedResult.java 2011-05-24 23:38:12 UTC (rev 48)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/beans/FormPagedResult.java 2011-05-25 13:51:42 UTC (rev 49)
@@ -92,6 +92,10 @@
this.nbFormsToShow = nbFormsToShow;
}
+ public void setFormsToShow(List<Form> formsToShow) {
+ setFormsIdsToShow(extractIds(formsToShow));
+ }
+
protected List<String> extractIds(List<Form> formsToShow) {
List<String> formsIds = new ArrayList<String>();
if (formsToShow != null) {
@@ -108,7 +112,7 @@
return formsIdsToShow;
}
- public void setFormsToShow(List<String> formsIdsToShow) {
+ public void setFormsIdsToShow(List<String> formsIdsToShow) {
List<String> oldValue = this.formsIdsToShow;
this.formsIdsToShow = formsIdsToShow;
propertyChange.firePropertyChange(FORMS_TO_SHOW_PROPERTY, oldValue, formsIdsToShow);
Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/SearchManager.java
===================================================================
--- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/SearchManager.java 2011-05-24 23:38:12 UTC (rev 48)
+++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/SearchManager.java 2011-05-25 13:51:42 UTC (rev 49)
@@ -26,7 +26,6 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.vradi.VradiServiceAction;
import org.chorem.vradi.beans.FormPagedResult;
import org.chorem.vradi.beans.QueryBean;
import org.chorem.vradi.beans.QueryParameters;
@@ -178,11 +177,10 @@
}
List<Form> result = new ArrayList<Form>(queryResult.getAll());
- FormPagedResult formPageResult = new FormPagedResult(result,
- queryResult.getNumFound(), formPagedResult.getPageToShow(),
- formPagedResult.getNbFormsToShow());
+ formPagedResult.setFormsToShow(result);
+ formPagedResult.setTotalFoundFormNb(queryResult.getNumFound());
- return formPageResult;
+ return formPagedResult;
}
public FormPagedResult findForms(QueryParameters queryParameters, FormPagedResult formPagedResult)
Modified: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/SendingViewManager.java
===================================================================
--- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/SendingViewManager.java 2011-05-24 23:38:12 UTC (rev 48)
+++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/SendingViewManager.java 2011-05-25 13:51:42 UTC (rev 49)
@@ -172,7 +172,7 @@
formsIdsToDisplay.addAll(deletedForms);
}
if (!formsIdsToDisplay.isEmpty()) {
- formPage.setFormsToShow(new ArrayList<String>(formsIdsToDisplay));
+ formPage.setFormsIdsToShow(new ArrayList<String>(formsIdsToDisplay));
}
emailFormsHighlighter.setFormsAdded(addedForms);
1
0