Commit 857f5394 authored by Michel Dirix's avatar Michel Dirix

- Refactoring

- Remove unused resources
- Display a message when connection failed
parent f052e005
......@@ -68,6 +68,7 @@
<hibernate.connection.password></hibernate.connection.password>
<!-- <hibernate.connection.url>jdbc:mysql://mysql-studio-frascati.jelastic.com/easysoa?autoReconnect=true</hibernate.connection.url> -->
<!-- <hibernate.connection.username>root</hibernate.connection.username> -->
<!-- <hibernate.connection.password></hibernate.connection.password> -->
</properties>
......@@ -312,6 +313,11 @@
<artifactId>mysql-connector-java</artifactId>
<version>5.1.14</version>
</dependency>
<dependency>
<groupId>org.scribe</groupId>
<artifactId>scribe</artifactId>
<version>1.3.0</version>
</dependency>
<!-- TODO find a solution to remove these dependencies (used just in some
applications, not for the studio) -->
......@@ -331,7 +337,7 @@
<profiles>
<!-- To execute an SCA composite type 'mvn -Prun'. -->
<!-- To execute an SCA composite type 'mvn -Prun'. -->
<profile>
<id>run</id>
<build>
......@@ -368,11 +374,11 @@
</build>
</profile>
<!-- To execute an SCA composite with FraSCAti Explorer type 'mvn -Pexplorer'. -->
<!-- To execute an SCA composite with FraSCAti Explorer type 'mvn -Pexplorer'. -->
<profile>
<id>explorer</id>
<dependencies>
<!-- here FraSCAti Explorer is put in the classpath. -->
<!-- here FraSCAti Explorer is put in the classpath. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-explorer-core</artifactId>
......@@ -399,8 +405,8 @@
</build>
</profile>
<!-- To execute an SCA composite with FraSCAti Remote Introspection with -->
<!-- FScript type 'mvn -Premote-fscript'. -->
<!-- To execute an SCA composite with FraSCAti Remote Introspection with -->
<!-- FScript type 'mvn -Premote-fscript'. -->
<profile>
<id>remote-fscript</id>
<dependencies>
......@@ -415,7 +421,7 @@
</properties>
</profile>
<!-- To execute an SCA composite with FraSCAti Remote Introspection type 'mvn -Premote'. -->
<!-- To execute an SCA composite with FraSCAti Remote Introspection type 'mvn -Premote'. -->
<profile>
<id>remote</id>
<dependencies>
......@@ -430,7 +436,7 @@
</properties>
</profile>
<!-- To execute an SCA composite with FraSCAti Web Explorer type 'mvn -Pweb'. -->
<!-- To execute an SCA composite with FraSCAti Web Explorer type 'mvn -Pweb'. -->
<profile>
<id>web</id>
<dependencies>
......
......@@ -34,7 +34,7 @@ import org.easysoa.utils.WsdlInformations;
public interface CodeGenerator {
void generate(String userId, String service, String port,String wsdlLocation);
String generate(String userId, String service, String port,String wsdlLocation);
WsdlInformations loadWsdl(String wsdl) throws FileNotFoundException;
......
......@@ -39,8 +39,8 @@ public interface CompositeTemplateProcessorItf {
String getForm(String templateName);
void doActionBeforeCreation(String templateName, Map<String, Object> params);
String doActionBeforeCreation(String templateName, Map<String, Object> params);
void doActionAfterCreation(String templateName, Map<String, Object> params);
String doActionAfterCreation(String templateName, Map<String, Object> params);
}
/**
* EasySOA
*
* Copyright (C) 2011-2012 Inria, University of Lille 1
*
* 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Michel Dirix
*
* Contributor(s):
*
*/
package org.easysoa.api;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.osoa.sca.annotations.Service;
@Service
public interface DeploymentRest {
@GET
@Path("/deploy")
@Produces("text/plain")
boolean deploy(@FormParam("userId")String userId, @FormParam("ids")String ids);
@GET
@Path("/undeploy")
@Produces("text/plain")
boolean undeploy(@FormParam("userId")String userId, @FormParam("ids")String ids);
}
/**
* EasySOA
*
* Copyright (C) 2011-2012 Inria, University of Lille 1
*
* 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Michel Dirix
*
* Contributor(s):
*
*/
package org.easysoa.api;
import org.eclipse.emf.ecore.EObject;
import org.osoa.sca.annotations.Service;
@Service
public interface EMFModelUtils {
EObject getComponent(String userId, String id);
void addElement(String userId, String id, String action);
}
......@@ -28,8 +28,6 @@
package org.easysoa.api;
import java.io.FileNotFoundException;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
......@@ -39,29 +37,10 @@ import javax.ws.rs.Produces;
import org.osoa.sca.annotations.Service;
/**
*
* @author Michel Dirix
*/
@Service
public interface RESTCall {
@GET
@Path("/tree")
@Produces("text/plain")
String getCompositeTree(@FormParam("userId")String userId);
@GET
@Path("/componentContent")
@Produces("text/plain")
String getComponentContent(@FormParam("userId")String userId, @FormParam("id")String id);
@GET
@Path("/componentMenu")
@Produces("text/plain")
String getComponentMenu(@FormParam("userId")String userId, @FormParam("id")String id);
@POST
@Path("/addElement")
@Produces("text/plain")
......@@ -72,16 +51,6 @@ public interface RESTCall {
@Produces("text/plain")
void saveElement(@FormParam("userId")String userId, @FormParam("params")String params);
@GET
@Path("/templateForm")
@Produces("text/plain")
String getTemplateForm(@FormParam("templateName")String templateName);
@POST
@Path("/createApplication")
@Produces("text/plain")
void createApplication(@FormParam("params")String params);
@GET
@Path("/implementationContent")
@Produces("text/plain")
......@@ -127,27 +96,11 @@ public interface RESTCall {
@Produces("text/plain")
void createNewInterface(@FormParam("userId")String userId, @FormParam("id")String id, @FormParam("className")String className, @FormParam("interfaceType")String interfaceType,@FormParam("createFile")boolean createFile,@FormParam("choice")String choice);
@GET
@Path("/deploy")
@Produces("text/plain")
boolean deploy(@FormParam("userId")String userId, @FormParam("ids")String ids);
@GET
@Path("/undeploy")
@Produces("text/plain")
boolean undeploy(@FormParam("userId")String userId, @FormParam("ids")String ids);
@POST
@Path("/createNewBinding")
@Produces("text/plain")
void createNewBinding(@FormParam("userId")String userId, @FormParam("id")String id, @FormParam("bindingType")String bindingType);
@GET
@Path("/loadWSDL")
@Produces("text/plain")
String loadWSDL(@FormParam("wsdlPath")String wsdlPath) throws FileNotFoundException;
@GET
@Path("/isExistingTown")
@Produces("text/plain")
......
......@@ -43,9 +43,9 @@ import org.osoa.sca.annotations.Service;
@Service
public interface ServiceManager {
void createService(User user,String name, String descrption, String packageName, String templateName, Map<String, Object> params);
String createApplication(User user,String name, String descrption, String packageName, String templateName, Map<String, Object> params);
Composite searchService(String name, User user);
Composite searchComposite(String name, User user);
void saveFile(String fileName,String fileContent);
......@@ -53,7 +53,7 @@ public interface ServiceManager {
Object launchService(User user,Application application);
List<Application> searchService(String keywords);
List<Application> searchApplications(String keywords);
void reloadComposite(String userId);
......
/**
* EasySOA
*
* Copyright (C) 2011-2012 Inria, University of Lille 1
*
* 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Michel Dirix
*
* Contributor(s):
*
*/
package org.easysoa.api;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.osoa.sca.annotations.Service;
@Service
public interface StudioGUIRest {
@GET
@Path("/tree")
@Produces("text/plain")
String getCompositeTree(@FormParam("userId")String userId);
@GET
@Path("/componentContent")
@Produces("text/plain")
String getComponentContent(@FormParam("userId")String userId, @FormParam("id")String id);
@GET
@Path("/componentMenu")
@Produces("text/plain")
String getComponentMenu(@FormParam("userId")String userId, @FormParam("id")String id);
}
/**
* EasySOA
*
* Copyright (C) 2011-2012 Inria, University of Lille 1
*
* 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Michel Dirix
*
* Contributor(s):
*
*/
package org.easysoa.api;
import java.util.Map;
public interface TemplateActionItf {
String getId();
String doActionBeforeCreation(Map<String, Object> params);
String doActionAfterCreation(Map<String, Object> params);
}
/**
* EasySOA
*
* Copyright (C) 2011-2012 Inria, University of Lille 1
*
* 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Michel Dirix
*
* Contributor(s):
*
*/
package org.easysoa.api;
import java.io.FileNotFoundException;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.osoa.sca.annotations.Service;
@Service
public interface TemplateRest {
@GET
@Path("/templateForm")
@Produces("text/plain")
String getTemplateForm(@FormParam("templateName")String templateName);
@POST
@Path("/createApplication")
@Produces("text/plain")
String createApplication(@FormParam("params")String params);
@GET
@Path("/loadWSDL")
@Produces("text/plain")
String loadWSDL(@FormParam("wsdlPath")String wsdlPath) throws FileNotFoundException;
}
......@@ -35,6 +35,7 @@ import java.util.Map;
import org.easysoa.api.CompositeTemplateItf;
import org.easysoa.api.CompositeTemplateProcessorItf;
import org.easysoa.api.TemplateActionItf;
import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Reference;
......@@ -42,7 +43,10 @@ public class CompositeTemplate implements CompositeTemplateProcessorItf {
@Reference
protected List<CompositeTemplateItf> templates;
@Reference
protected List<TemplateActionItf> actionsTemplate;
protected Map<String, CompositeTemplateItf> templateMap;
protected Map<String, TemplateActionItf> templateActionMap;
@Init
public final void initializeProcessorsByID() {
......@@ -50,11 +54,20 @@ public class CompositeTemplate implements CompositeTemplateProcessorItf {
for (CompositeTemplateItf compositeTemplate : this.templates) {
this.templateMap.put(compositeTemplate.getId(), compositeTemplate);
}
this.templateActionMap = new HashMap<String, TemplateActionItf>();
for (TemplateActionItf compositeActionTemplate : this.actionsTemplate) {
this.templateActionMap.put(compositeActionTemplate.getId(), compositeActionTemplate);
}
}
protected CompositeTemplateItf getProcessorById(String templateName) {
return this.templateMap.get(templateName);
}
protected TemplateActionItf getTemplateActionProcessorById(String templateName) {
return this.templateActionMap.get(templateName);
}
@Override
public String getTemplate(String templateName, Map<String, Object> params) {
......@@ -75,12 +88,14 @@ public class CompositeTemplate implements CompositeTemplateProcessorItf {
}
@Override
public void doActionAfterCreation(String templateName, Map<String, Object> params){
this.getProcessorById(templateName).doActionAfterCreation(params);
public String doActionAfterCreation(String templateName, Map<String, Object> params){
return this.getTemplateActionProcessorById(templateName).doActionAfterCreation(params);
}
@Override
public void doActionBeforeCreation(String templateName, Map<String, Object> params){
this.getProcessorById(templateName).doActionBeforeCreation(params);
public String doActionBeforeCreation(String templateName, Map<String, Object> params){
String res = this.getTemplateActionProcessorById(templateName).doActionBeforeCreation(params);
System.out.println("doActionBeforeCreation message : "+res);
return res;
}
}
package org.easysoa.compositeTemplates;
import java.util.Map;
import org.easysoa.api.TemplateActionItf;
public class TemplateActionEmpty implements TemplateActionItf {
@Override
public String getId() {
return "Empty";
}
@Override
public String doActionBeforeCreation(Map<String, Object> params) {
return null;
}
@Override
public String doActionAfterCreation(Map<String, Object> params) {
return null;
}
}
package org.easysoa.compositeTemplates;
import java.util.Map;
import org.easysoa.api.CodeGenerator;
import org.easysoa.api.TemplateActionItf;
import org.osoa.sca.annotations.Reference;
public class TemplateActionProxyWS implements TemplateActionItf {
@Reference
protected CodeGenerator wsdlGenerator;
@Override
public String getId() {
return "ProxyWS";
}
@Override
public String doActionBeforeCreation(Map<String, Object> params) {
System.out.println("doActionBeforeCreation ProxyWS : "+(String)params.get("userId") + " "+ (String)params.get("service") + " " + (String)params.get("port") + " " + (String)params.get("url"));
return wsdlGenerator.generate((String)params.get("userId"),(String)params.get("service"),(String)params.get("port"),(String)params.get("url"));
}
@Override
public String doActionAfterCreation(Map<String, Object> params) {
return null;
}
}
......@@ -28,10 +28,9 @@
package org.easysoa.impl;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.Set;
......@@ -41,6 +40,7 @@ import javax.wsdl.WSDLException;
import javax.xml.namespace.QName;
import org.apache.cxf.tools.common.ToolContext;
import org.apache.cxf.tools.common.ToolException;
import org.apache.cxf.tools.wsdlto.WSDLToJava;
import org.easysoa.api.CodeGenerator;
import org.easysoa.api.ServiceManager;
......@@ -63,40 +63,52 @@ public class CodeGeneratorWsdlToJSImpl implements CodeGenerator {
@Override
public void generate(String userId, String service, String port, String wsdlLocation) {
public String generate(String userId, String service, String port, String wsdlLocation){
System.out.println("generate");
this.compile(userId, wsdlLocation);
String result = "";
try{
this.compile(userId, wsdlLocation);
}
catch(ToolException te){
te.printStackTrace();
System.out.println("MESSAGE : "+"wsdl not supported by cxf");
return "wsdl not supported by cxf";
}
String generatedPackage = serviceManager.getCurrentApplication(userId).getPackageName()+".impl.generated";
PrintWriter printWriter = null;
try {
ClassLoader cl = membraneGeneration.compileJavaSource();
Class<?> interfaceClass = cl.loadClass(generatedPackage+"."+port);
File jsFile = this.createJSFile(userId, service);
FileWriter fw = new FileWriter(jsFile, false);
BufferedWriter writer = new BufferedWriter(fw);
printWriter = new PrintWriter(jsFile);
for(Method method : interfaceClass.getMethods()){
writer.write("function "+method.getName()+"(");
printWriter.print("function "+method.getName()+"(");
for (int paramIndex = 1; paramIndex <= method.getParameterTypes().length; paramIndex++) {
if(paramIndex == 1) writer.write("param"+paramIndex);
else writer.write(",param"+paramIndex);
if(paramIndex == 1) printWriter.print("param"+paramIndex);
else printWriter.print(",param"+paramIndex);
}
writer.write("){"+System.getProperty("line.separator"));
writer.write("return wsdlReference."+method.getName()+"(");
printWriter.println("){");
printWriter.print("return wsdlReference."+method.getName()+"(");
for (int paramIndex = 1; paramIndex <= method.getParameterTypes().length; paramIndex++) {
if(paramIndex == 1) writer.write("param"+paramIndex);
else writer.write(",param"+paramIndex);
if(paramIndex == 1) printWriter.print("param"+paramIndex);
else printWriter.print(",param"+paramIndex);
}
writer.write(");"+System.getProperty("line.separator")+"}"+System.getProperty("line.separator")+System.getProperty("line.separator"));
printWriter.println(");");