Commit 68c8f0f7 authored by Yann Mombrun's avatar Yann Mombrun

New version 2.2.3-SNAPSHOT

WEBLAB-1516 - Enable in the configuration the use of OpenStreetMap and use this conf by default
WEBLAB-1518 - Replace save method by a REST based call
WEBLAB-1517 - Lots of refactoring of the code. Remove unused JS/CSS/images files, remove weblab client and replace it by Spring JAXWS proxy, use a single configuration file and remove autowiring, 


git-svn-id: svn://svn.forge.objectweb.org/svnroot/weblab/trunk/WebLabServices/Portlets/metadata-portlet@4384 a803c184-d8de-4a0e-a52b-d3eef88212b6
parent 15bb781b
...@@ -4,27 +4,19 @@ ...@@ -4,27 +4,19 @@
<parent> <parent>
<groupId>org.ow2.weblab.portlets</groupId> <groupId>org.ow2.weblab.portlets</groupId>
<artifactId>parent</artifactId> <artifactId>parent</artifactId>
<version>1.2.8</version> <version>1.2.8.1-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath> <relativePath>../parent/pom.xml</relativePath>
</parent> </parent>
<groupId>org.ow2.weblab.portlets</groupId> <groupId>org.ow2.weblab.portlets</groupId>
<artifactId>weblab-metaview</artifactId> <artifactId>weblab-metaview</artifactId>
<version>2.2.2</version> <version>2.2.3-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>WebLab Metaview</name> <name>WebLab Metaview</name>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<weblab.snapshot.repositoryId>weblab.snapshot</weblab.snapshot.repositoryId>
<weblab.release.repositoryId>weblab.release</weblab.release.repositoryId>
<weblab.snapshot.url>sftp://weblab-project.org/home/ipccproj/public_html/maven-snapshot</weblab.snapshot.url>
<weblab.release.url>sftp://weblab-project.org/home/ipccproj/public_html/maven</weblab.release.url>
<weblab.repositoryId>${weblab.release.repositoryId}</weblab.repositoryId>
<weblab.url>${weblab.release.url}</weblab.url>
<spring.version>3.0.7.RELEASE</spring.version> <spring.version>3.0.7.RELEASE</spring.version>
</properties> </properties>
...@@ -55,11 +47,6 @@ ...@@ -55,11 +47,6 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.ow2.weblab.components</groupId>
<artifactId>weblab-taglib</artifactId>
<version>0.1.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId> <artifactId>spring-beans</artifactId>
...@@ -113,26 +100,4 @@ ...@@ -113,26 +100,4 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<distributionManagement>
<site>
<id>WebLab</id>
<name>WebLab Web Site</name>
<url>http://weblab.ow2.org</url>
</site>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>weblab.release</id>
<name>WebLab Repository</name>
<url>${weblab.release.url}</url>
<layout>default</layout>
</repository>
<snapshotRepository>
<uniqueVersion>false</uniqueVersion>
<id>weblab.snapshot</id>
<name>WebLab Snapshot Repository</name>
<url>${weblab.snapshot.url}</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
</project> </project>
...@@ -21,18 +21,23 @@ import java.util.Map; ...@@ -21,18 +21,23 @@ import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
/** /**
* Class representing a result configuration for meta. * Class containing the configuration of the metadata properties to be displayed.
* *
* @author emilien * @author emilien
*
*/ */
public class DisplayMetaConfBean { public class DisplayMetaConfBean {
private boolean useGeoserverExposedMap;
private Map<String, Boolean> properties; private Map<String, Boolean> properties;
public DisplayMetaConfBean() { public DisplayMetaConfBean() {
this.properties = new TreeMap<>(); this.properties = new TreeMap<>();
this.useGeoserverExposedMap = false;
} }
...@@ -47,4 +52,21 @@ public class DisplayMetaConfBean { ...@@ -47,4 +52,21 @@ public class DisplayMetaConfBean {
this.properties = properties; this.properties = properties;
} }
/**
* @return the useGeoserverExposedMap
*/
public boolean isUseGeoserverExposedMap() {
return this.useGeoserverExposedMap;
}
/**
* @param useGeoserverExposedMap the useGeoserverExposedMap to set
*/
public void setUseGeoserverExposedMap(boolean useGeoserverExposedMap) {
this.useGeoserverExposedMap = useGeoserverExposedMap;
}
} }
...@@ -20,9 +20,17 @@ package org.ow2.weblab.portlet.business.bean; ...@@ -20,9 +20,17 @@ package org.ow2.weblab.portlet.business.bean;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/**
* Contains edition configuration
*
* @author kdesir
*/
public class EditMetaConfBean { public class EditMetaConfBean {
private boolean useGeoserverExposedMap;
private Map<String, List<String>> properties; private Map<String, List<String>> properties;
...@@ -35,4 +43,21 @@ public class EditMetaConfBean { ...@@ -35,4 +43,21 @@ public class EditMetaConfBean {
this.properties = properties; this.properties = properties;
} }
/**
* @return the useGeoserverExposedMap
*/
public boolean isUseGeoserverExposedMap() {
return this.useGeoserverExposedMap;
}
/**
* @param useGeoserverExposedMap
* the useGeoserverExposedMap to set
*/
public void setUseGeoserverExposedMap(boolean useGeoserverExposedMap) {
this.useGeoserverExposedMap = useGeoserverExposedMap;
}
} }
...@@ -21,24 +21,28 @@ package org.ow2.weblab.portlet.business.bean; ...@@ -21,24 +21,28 @@ package org.ow2.weblab.portlet.business.bean;
* A service description bean. * A service description bean.
* *
* @author emilienbondu * @author emilienbondu
*
*/ */
public class ServiceDescription { public class ServiceDescription {
private String uri,label;
private String uri, label;
public String getUri() { public String getUri() {
return this.uri; return this.uri;
} }
public void setUri(String uri) { public void setUri(String uri) {
this.uri = uri; this.uri = uri;
} }
public String getLabel() { public String getLabel() {
return this.label; return this.label;
} }
public void setLabel(String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
......
...@@ -53,5 +53,4 @@ public class DataTaglib { ...@@ -53,5 +53,4 @@ public class DataTaglib {
} }
} }
/** /**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications * WEBLAB: Service oriented integration platform for media mining and intelligence applications
* *
* Copyright (C) 2004 - 2016 Airbus Defence and Space * Copyright (C) 2004 - 2016 Airbus Defence and Space
* *
* This library is free software; you can redistribute it and/or modify it under the terms of * This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either * the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * This library 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. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details. * See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with this * You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA * Floor, Boston, MA 02110-1301 USA
*/ */
package org.ow2.weblab.portlet.business.service.impl; package org.ow2.weblab.portlet.business.service;
import java.io.File; import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.ow2.weblab.core.extended.exception.WebLabCheckedException; import org.ow2.weblab.core.extended.exception.WebLabCheckedException;
import org.ow2.weblab.core.extended.jaxb.WebLabMarshaller;
import org.ow2.weblab.core.model.Resource; import org.ow2.weblab.core.model.Resource;
/** /**
* A class to process weblab resource in order to reindex it by metaDataprocessing routes. * Interface defining the service is charge of saving the resource back
* *
* @author kdesir * @author ymombrun
*/ */
public interface ResourceSaverService {
public class SaveMeta {
private final Log logger = LogFactory.getLog(this.getClass());
public SaveMeta() {
}
/** /**
* This method uses the current resource to save it in the repository
*
* @param resource * @param resource
* the resource which will be saved as a WL xml document. * The resource to be saved
* @return Whether or not we are sure that the resource has been saved. <code>false</code> can be used when we are not sure
* @throws IOException
* If an error occurred saving the resource
* @throws WebLabCheckedException
* If the resource cannot be serialised as XML
*/ */
public void sendToReIndexFolder(final Resource resource) { public boolean saveResource(final Resource resource) throws IOException, WebLabCheckedException;
final WebLabMarshaller wlm = new WebLabMarshaller();
try {
wlm.marshalResource(resource, new File(System.getProperty("files.to.reIndex") + "/" + System.nanoTime() + ".xml"));
this.logger.info("Save the resource : " + resource.getUri() + " : " + System.getProperty("files.to.reIndex"));
} catch (final WebLabCheckedException e) {
this.logger.error("Unable to save the File for Reindexing", e);
}
}
} }
...@@ -167,7 +167,6 @@ public class EditMetaServices { ...@@ -167,7 +167,6 @@ public class EditMetaServices {
ba.applyOperator(Operator.WRITE, prefix, propertyURI, localname, clazz, null); ba.applyOperator(Operator.WRITE, prefix, propertyURI, localname, clazz, null);
ba.applyOperator(Operator.WRITE, prefix, propertyURI, localname, clazz, val); ba.applyOperator(Operator.WRITE, prefix, propertyURI, localname, clazz, val);
} }
} }
} }
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2016 Airbus Defence and Space
*
* This library is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package org.ow2.weblab.portlet.business.service.impl;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.ProxySelector;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Consts;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.impl.conn.ProxySelectorRoutePlanner;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.ow2.weblab.core.extended.exception.WebLabCheckedException;
import org.ow2.weblab.core.extended.util.ResourceUtil;
import org.ow2.weblab.core.model.Resource;
import org.ow2.weblab.portlet.business.service.ResourceSaverService;
import org.springframework.stereotype.Service;
/**
* Implementation of {@link ResourceSaverService} that calls a REST endpoint to post the resource as XML.
*
* @author ymombrun
*/
@Service
public class RestResourceSaverService implements ResourceSaverService {
private final URI url;
private final PoolingClientConnectionManager cm;
private final HttpParams httpParams;
private final Log logger;
private static final ContentType APPLICATION_XML = ContentType.create("application/xml", Consts.UTF_8);
/**
* @param url
* The URL of the rest service to be called in order to save the edition
* @throws MalformedURLException
* If the URL is not valid
* @throws URISyntaxException
*/
public RestResourceSaverService(final String url) throws MalformedURLException, URISyntaxException {
super();
this.logger = LogFactory.getLog(this.getClass());
this.url = new URL(url).toURI();
this.cm = new PoolingClientConnectionManager();
this.cm.setMaxTotal(10);
this.cm.setDefaultMaxPerRoute(10);
this.httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(this.httpParams, 4000);
HttpConnectionParams.setSoTimeout(this.httpParams, 30000);
this.logger.debug("RestResourceSaverService created for " + url);
}
@Override
public boolean saveResource(final Resource resource) throws IOException, WebLabCheckedException {
final DefaultHttpClient httpClient = new DefaultHttpClient(this.cm, this.httpParams);
if ((System.getProperty("http.proxyHost") != null) || "true".equals(System.getProperty("java.net.useSystemProxies"))) {
this.logger.debug("Proxy information found in system properties. Use default proxy selector.");
httpClient.setRoutePlanner(new ProxySelectorRoutePlanner(this.cm.getSchemeRegistry(), ProxySelector.getDefault()));
} else {
this.logger.trace("No proxy configured.");
}
final HttpPost httpPost = new HttpPost(this.url);
final StringEntity xmlEntity = new StringEntity(ResourceUtil.saveToXMLString(resource), APPLICATION_XML);
httpPost.setEntity(xmlEntity);
final HttpResponse response = httpClient.execute(httpPost);
final int statusCode = response.getStatusLine().getStatusCode();
if (((statusCode >= 200) && (statusCode < 300)) || (statusCode == 304)) {
return true;
}
this.logger.warn("Received an error HTTP code (" + statusCode + ") when accessing saving resource " + resource.getUri() + ".");
return false;
}
}
...@@ -25,7 +25,6 @@ import java.util.UUID; ...@@ -25,7 +25,6 @@ import java.util.UUID;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.ow2.weblab.components.client.WebLabClient;
import org.ow2.weblab.core.extended.exception.WebLabCheckedException; import org.ow2.weblab.core.extended.exception.WebLabCheckedException;
import org.ow2.weblab.core.extended.factory.ExceptionFactory; import org.ow2.weblab.core.extended.factory.ExceptionFactory;
import org.ow2.weblab.core.helper.impl.SemanticResource; import org.ow2.weblab.core.helper.impl.SemanticResource;
...@@ -48,7 +47,7 @@ import com.hp.hpl.jena.query.QuerySolutionMap; ...@@ -48,7 +47,7 @@ import com.hp.hpl.jena.query.QuerySolutionMap;
import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.sparql.resultset.ResultSetMem; import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
@Service(value = "metaviewBusinessService") @Service
public class WSBusinessServicesImpl implements MetaViewBusinessServices { public class WSBusinessServicesImpl implements MetaViewBusinessServices {
...@@ -74,10 +73,10 @@ public class WSBusinessServicesImpl implements MetaViewBusinessServices { ...@@ -74,10 +73,10 @@ public class WSBusinessServicesImpl implements MetaViewBusinessServices {
/** /**
* Standard constructor of the class, setting the resource container URI to find it in the weblab-client. * Standard constructor of the class, setting the resource container and some parameters
* *
* @param resourceContainerUri * @param service
* The identifier of the resource container * The the resource container client
* @param linkedToQuery * @param linkedToQuery
* The query that search the linked resource URI inside the received pok * The query that search the linked resource URI inside the received pok
* @param translationsQueryTemplate * @param translationsQueryTemplate
...@@ -85,13 +84,8 @@ public class WSBusinessServicesImpl implements MetaViewBusinessServices { ...@@ -85,13 +84,8 @@ public class WSBusinessServicesImpl implements MetaViewBusinessServices {
* @throws WebLabCheckedException * @throws WebLabCheckedException
* If the resource container cannot be loaded * If the resource container cannot be loaded
*/ */
public WSBusinessServicesImpl(final String resourceContainerUri, final String linkedToQuery, final String translationsQueryTemplate) throws WebLabCheckedException { public WSBusinessServicesImpl(final ResourceContainer service, final String linkedToQuery, final String translationsQueryTemplate) throws WebLabCheckedException {
this.service = WebLabClient.getResourceContainer("Not used", "Not used", resourceContainerUri); this.service = service;
if (this.service == null) {
final String message = "Unable to initialise the resource container needed for metadata.";
this.logger.fatal(message);
throw new WebLabCheckedException(message);
}
this.linkedToQuery = linkedToQuery; this.linkedToQuery = linkedToQuery;
this.translationsQueryTemplate = translationsQueryTemplate; this.translationsQueryTemplate = translationsQueryTemplate;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
package org.ow2.weblab.portlet.mvc.spring.controller; package org.ow2.weblab.portlet.mvc.spring.controller;
import java.io.IOException;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -28,12 +29,13 @@ import javax.portlet.ResourceResponse; ...@@ -28,12 +29,13 @@ import javax.portlet.ResourceResponse;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.ow2.weblab.core.extended.exception.WebLabCheckedException;
import org.ow2.weblab.core.model.Resource; import org.ow2.weblab.core.model.Resource;
import org.ow2.weblab.portlet.business.bean.EditMetaConfBean; import org.ow2.weblab.portlet.business.bean.EditMetaConfBean;
import org.ow2.weblab.portlet.business.bean.TimeConfig; import org.ow2.weblab.portlet.business.bean.TimeConfig;
import org.ow2.weblab.portlet.business.bean.taglib.DataTaglib; import org.ow2.weblab.portlet.business.bean.taglib.DataTaglib;
import org.ow2.weblab.portlet.business.service.ResourceSaverService;
import org.ow2.weblab.portlet.business.service.impl.EditMetaServices; import org.ow2.weblab.portlet.business.service.impl.EditMetaServices;
import org.ow2.weblab.portlet.business.service.impl.SaveMeta;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -42,50 +44,94 @@ import org.springframework.web.portlet.ModelAndView; ...@@ -42,50 +44,94 @@ import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.bind.annotation.ActionMapping; import org.springframework.web.portlet.bind.annotation.ActionMapping;
import org.springframework.web.portlet.bind.annotation.ResourceMapping; import org.springframework.web.portlet.bind.annotation.ResourceMapping;
/**
* The controller in charge of the edition.
*
* @author kdesir, ymombrun
*/
@Controller @Controller
@RequestMapping(value = "VIEW") @RequestMapping(value = "VIEW")
@SessionAttributes({ "resource", "isEmptyModel", "isLoadedResource", "rdfProperties", "translations", "metaDisplay", "editMetaData", "timeConfig", "dataTaglib", "dataLanguage" }) @SessionAttributes({ "resource", "isEmptyModel", "isLoadedResource", "rdfProperties", "translations", "metaDisplay", "editMetaData", "timeConfig", "dataTaglib", "dataLanguage",
"useGeoserverExposedMap" })
public class EditMetaController { public class EditMetaController {
private static final String USE_GEOSERVER_EXPOSED_MAP = "useGeoserverExposedMap";
private static final String RESOURCE = "resource";
private static final String TIME_CONFIG = "timeConfig";
private static final String EDIT_META_DATA = "editMetaData";
private static final String DATA_LANGUAGE = "dataLanguage";
private static final String DATA_TAGLIB = "dataTaglib";
private static final String UTF_8 = "UTF-8";
private static final String TEXT_HTML = "text/html";
private final Log logger = LogFactory.getLog(this.getClass()); private final Log logger = LogFactory.getLog(this.getClass());
private EditMetaConfBean editMetaData; private final EditMetaConfBean editMetaData;
private DataTaglib dataTaglib; private final DataTaglib dataTaglib;
private final ResourceSaverService resourceSaverService;
public EditMetaController(final EditMetaConfBean editMetaData, final DataTaglib dataTaglib, final ResourceSaverService resourceSaverService) {
super();
this.editMetaData = editMetaData;
this.dataTaglib = dataTaglib;
this.resourceSaverService = resourceSaverService;
}
@ResourceMapping("editmeta") @ResourceMapping("editmeta")
public ModelAndView displayEditMenu(final ResourceRequest request, final ResourceResponse response, ModelMap model) { public ModelAndView displayEditMenu(final ResourceRequest request, final ResourceResponse response) {
response.setContentType("text/html"); response.setContentType(EditMetaController.TEXT_HTML);
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding(EditMetaController.UTF_8);
this.logger.debug("ShowView EditMetaController called"); this.logger.debug("ShowView EditMetaController called");
final ModelAndView mav = new ModelAndView(); final ModelAndView mav = new ModelAndView();
model = (ModelMap) request.getPortletSession().getAttribute("model"); final ModelMap model = (ModelMap) request.getPortletSession().getAttribute("model");
if (!model.containsAttribute("timeConfig")) {