r55 - in trunk: . vradi-services vradi-services/src/main/java/org/chorem/vradi/services vradi-services/src/main/resources vradi-services-web vradi-services-web/src/main/java/org/chorem/vradi/services vradi-services-web/src/main/webapp/WEB-INF vradi-services-web/src/test/java/org/chorem/vradi/services vradi-services-web/src/test/java/org/chorem/vradi/services/util vradi-services-web/src/test/resources vradi-swing vradi-swing/src/main/java/org/chorem/vradi/services vradi-swing/src/main/resourc
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) {
participants (1)
-
sletellier@users.chorem.org