Commit fb7a23ea authored by Arnaud Saval's avatar Arnaud Saval

WEBLAB-764 add weblab-client support

git-svn-id: svn://svn.forge.objectweb.org/svnroot/weblab/trunk/WebLabServices/Portlets/metadata-portlet@3001 a803c184-d8de-4a0e-a52b-d3eef88212b6
parent fdf883bf
......@@ -29,6 +29,11 @@
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.weblab.incubation.components</groupId>
<artifactId>weblab-client</artifactId>
<version>0.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
......
......@@ -19,7 +19,6 @@
package org.ow2.weblab.portlet;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
......@@ -38,10 +37,10 @@ import javax.portlet.ResourceResponse;
import org.apache.commons.logging.Log;
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.ontologies.WebLabRetrieval;
import org.ow2.weblab.core.extended.util.ResourceUtil;
import org.ow2.weblab.core.extended.util.ServiceUtil;
import org.ow2.weblab.core.helper.impl.AdvancedSelector;
import org.ow2.weblab.core.helper.impl.RDFSelectorFactory;
import org.ow2.weblab.core.helper.impl.Statements;
......@@ -51,7 +50,6 @@ import org.ow2.weblab.core.model.MediaUnit;
import org.ow2.weblab.core.model.PieceOfKnowledge;
import org.ow2.weblab.core.model.Resource;
import org.ow2.weblab.core.services.ResourceContainer;
import org.ow2.weblab.core.services.ResourceContainer_Service;
import org.ow2.weblab.core.services.resourcecontainer.LoadResourceArgs;
import org.ow2.weblab.portlet.bean.AnnotationsDescBean;
import org.ow2.weblab.portlet.bean.MetaConfBean;
......@@ -68,7 +66,11 @@ import org.springframework.core.io.ClassPathResource;
*/
public class MetaDataPortlet extends WebLabPortlet {
/**
* Repository Service URI
*/
private static final String REPO_SERVICE_URI = "repo_service_uri";
/**
* Namespace property used in PieceOkKnowledge to get the Document to
* display URI
......@@ -134,14 +136,6 @@ public class MetaDataPortlet extends WebLabPortlet {
*/
private final static String CURRENT_RESSOURCE_IS_LOADED = "user_resource_is_loaded";
/**
* Map of resource container services
*/
private Map<URL, ResourceContainer> repoMap;
/**
* Default AnnotationsDescBean
*/
......@@ -166,7 +160,7 @@ public class MetaDataPortlet extends WebLabPortlet {
/*
* creating map of repo service
*/
this.repoMap = new HashMap<URL, ResourceContainer>();
//this.repoMap = new HashMap<URL, ResourceContainer>();
/*
* getting meta-data description list from a XML bean, using Spring
......@@ -187,7 +181,6 @@ public class MetaDataPortlet extends WebLabPortlet {
@Override
public void destroy() {
this.repoMap = null;
this.rdfProperties = null;
super.destroy();
......@@ -417,11 +410,11 @@ public class MetaDataPortlet extends WebLabPortlet {
*/
if (request.getPortletSession().getAttribute(MetaDataPortlet.USER_REPO_CONF, PortletSession.APPLICATION_SCOPE) == null) {
final RepoServiceConfigBean repo_conf = new RepoServiceConfigBean();
repo_conf.setServiceURL(this.getInitParameter("repo_service_url"));
repo_conf.setServiceURI(this.getInitParameter(REPO_SERVICE_URI));
request.getPortletSession().setAttribute(MetaDataPortlet.USER_REPO_CONF, repo_conf, PortletSession.APPLICATION_SCOPE);
}
final URL repoURL = new URL(((RepoServiceConfigBean) request.getPortletSession().getAttribute(MetaDataPortlet.USER_REPO_CONF,
PortletSession.APPLICATION_SCOPE)).getServiceURL());
final String repoURL = ((RepoServiceConfigBean) request.getPortletSession().getAttribute(MetaDataPortlet.USER_REPO_CONF,
PortletSession.APPLICATION_SCOPE)).getServiceURI();
this.logger.info("use repository: " + repoURL.toString());
try {
/*
......@@ -556,27 +549,13 @@ public class MetaDataPortlet extends WebLabPortlet {
/**
* Method to get Respository service from it URL
* Method to get Respository service from it URI
*
* @param serviceURL
* url of the service
* @param serviceURI uri of the service
* @return corresponding service
*/
private ResourceContainer getRepoService(final URL serviceURL) {
if (!this.repoMap.containsKey(serviceURL)) {
/*
* web service doesn't exist, create it and add it to service map
*/
this.logger.info("Building repo at [" + serviceURL + "]");
final ResourceContainer repo = new ResourceContainer_Service().getResourceContainerPort();
ServiceUtil.setEndpointAddress(repo, serviceURL.toString(), "loadResource");
this.repoMap.put(serviceURL, repo);
}
return this.repoMap.get(serviceURL);
private ResourceContainer getRepoService(final String serviceURI) throws WebLabCheckedException {
return WebLabClient.getResourceContainer("useless", "parameter is useless", serviceURI);
}
......
......@@ -27,7 +27,7 @@ package org.ow2.weblab.portlet.bean;
public class RepoServiceConfigBean {
private String serviceURL;
private String serviceURI;
public RepoServiceConfigBean() {
......@@ -35,13 +35,13 @@ public class RepoServiceConfigBean {
}
public String getServiceURL() {
return this.serviceURL;
public String getServiceURI() {
return this.serviceURI;
}
public void setServiceURL(final String serviceURL) {
this.serviceURL = serviceURL;
public void setServiceURI(final String serviceURL) {
this.serviceURI = serviceURL;
}
}
/**
* WEBLAB: Service oriented integration platform for media mining and intelligence applications
*
* Copyright (C) 2004 - 2012 Cassidian, an EADS Company
*
* 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.tool;
import java.net.URL;
import javax.xml.namespace.QName;
import org.apache.commons.logging.LogFactory;
import org.ow2.weblab.core.extended.util.ServiceUtil;
import org.ow2.weblab.core.services.ResourceContainer;
import org.ow2.weblab.core.services.ResourceContainer_Service;
public class ResourceContainerUtil {
/**
* Build a Searcher service from WSDL and web Service URL.
* @param WSDLLocation
* @param searcher_url
* @return Searcher web service corresponding urls.
*/
public static ResourceContainer getResourceContainerService(URL WSDLLocation, URL resource_container_url) {
ResourceContainer container;
LogFactory.getLog(ResourceContainerUtil.class).info("Resource Container URL : " + WSDLLocation);
ResourceContainer_Service container_service = new ResourceContainer_Service(
WSDLLocation,
new QName(
"http://weblab.ow2.org/core/1.2/services",
"ResourceContainer"));
container = container_service.getResourceContainerPort();
ServiceUtil.setEndpointAddress(container, resource_container_url.toString(),"getResource");
return container;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans> <bean id="servicesConfig" class="org.ow2.weblab.components.client.config.ServiceConfigMap"> <description> This is the main bean that will handle the weblab-client configuration. The principle is simple: for each service port (ie implementation of one generic interface) the configuration will have the implementation URI (in general linked to the application service taxonomy) and will link it to the actual URL to be used. </description> <constructor-arg> <map> <entry key="http://weblab.ow2.org/core/1.2/services/resourceContainer#Load_Resource"> <value>http://localhost:8084/petals/services/weblab-repository</value> </entry> </map> </constructor-arg> </bean></beans>
\ No newline at end of file
......@@ -28,8 +28,8 @@
<!-- service configuration -->
<init-param>
<name>repo_service_url</name>
<value>http://localhost:8084/petals/services/weblab-repository</value>
<name>repo_service_uri</name>
<value>http://weblab.ow2.org/core/1.2/services/resourceContainer#Load_Resource</value>
</init-param>
<!-- set if the portlet use redirection for action -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment