...
 
Commits (34)
......@@ -2,6 +2,8 @@
bin/
target/
target2/
*target/
*target2/
*.class
*.project
*.classpath
......
......@@ -10,11 +10,8 @@
<name>artifact-generators</name>
<description>artifact-generators provides classes to generate a BC WAR and generic interface which each concrete protocol implementation MUST implement to generate its concrete endpoints or clients</description>
<repositories>
<repository>
<id>repository.jboss.org</id>
<name>JBoss Repository</name>
<url>http://mvnrepository.com/artifact/org.jboss.shrinkwrap</url>
</repository>
<!-- <repository> <id>repository.jboss.org</id> <name>JBoss Repository</name>
<url>http://mvnrepository.com/artifact/org.jboss.shrinkwrap</url> </repository> -->
<repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
......@@ -23,11 +20,13 @@
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>3.2.3.RELEASE</spring.version>
<cxf.version>3.1.4</cxf.version>
<spring.version>4.3.12.RELEASE</spring.version>
<cxf.version>3.1.11</cxf.version>
<jax.ws.rs>2.0.1</jax.ws.rs>
<version.shrinkwrap>1.2.6</version.shrinkwrap>
<version.shrinkwrap.resolvers>3.0.0</version.shrinkwrap.resolvers>
<vsb.version>2.1.1-SNAPSHOT</vsb.version>
</properties>
<build>
......@@ -48,37 +47,37 @@
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gmdl-utils</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>bc-manager</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-api</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-dpws</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-mqtt</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-websocket</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>compiler</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<!-- RestLet -->
......@@ -88,7 +87,6 @@
<version>2.3.1</version>
</dependency>
<!-- CodeModel -->
<dependency>
<groupId>com.sun.codemodel</groupId>
......@@ -108,20 +106,17 @@
<artifactId>shrinkwrap-impl-base</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-api-maven-embedded</artifactId>
<version>${version.shrinkwrap.resolvers}</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<version>${version.shrinkwrap.resolvers}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
......@@ -132,7 +127,12 @@
<artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
<version>${version.shrinkwrap.resolvers}</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
<version>${version.shrinkwrap.resolvers}</version>
</dependency>
<!-- jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
......@@ -147,7 +147,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.4</version>
<version>2.7.3</version>
</dependency>
<!-- Set invocation address dependencies -->
......@@ -177,22 +177,21 @@
<artifactId>javax.ws.rs-api</artifactId>
<version>${jax.ws.rs}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2-transport-http</artifactId>
<version>1.7.5</version> </dependency> -->
</dependencies>
</project>
......@@ -17,7 +17,13 @@ import eu.chorevolution.vsb.gmdl.utils.enums.ProtocolType;
public class Generator {
private JavaArchive archive;
public Generator(){}
private ProtocolType busProtocol;
private Class<?> bc = null;
public Generator(ProtocolType busProtocol){
this.busProtocol = busProtocol;
}
public void compileGeneratedClasses(Class[] classesOptions){
......@@ -25,50 +31,57 @@ public class Generator {
RunTimeCompiler compiler = new RunTimeCompiler(sourceFilesPath,Constants.generatedCodePath,classesOptions);
compiler.compile();
File sourceDir = new File(sourceFilesPath);
/*for(File f: sourceDir.listFiles()){
for(File f: sourceDir.listFiles()){
if(f.getName().endsWith("java")){
f.delete();
}
} */
}
PathResolver.setClassPath(Constants.generatedCodePath);
if(this.busProtocol != ProtocolType.SOAP) {
try {
Class<?> bc = null;
try {
bc = Class.forName(Constants.target_namespace + ".BindingComponentMain");
bc = Class.forName(Constants.target_namespace + ".BindingComponentMain");
} catch (ClassNotFoundException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
archive = ShrinkWrap.create(JavaArchive.class);
archive.addPackage(bc.getPackage());
archive.addPackage(eu.chorevolution.vsb.gmdl.tools.serviceparser.gidl.ParseGIDL.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.gmdl.tools.serviceparser.gmdl.ParseGMDL.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.gmdl.utils.Operation.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.gmdl.utils.enums.OperationType.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.bc.manager.BcManagerRestService.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.artifact.war.RestServlet.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.artifact.war.StartBcManagerServlet.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.artifact.generators.WarGenerator.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.bc.setinvaddrservice.BaseService.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.gm.protocols.Manageable.class.getPackage());
archive
.addPackage(eu.chorevolution.vsb.gmdl.tools.serviceparser.ServiceDescriptionParser.class.getPackage());
}
public VsbOutput generateWar(WarGenerator warGenerator, ProtocolType busProtocol){
warGenerator.addArchive(archive);
VsbOutput vsbOutput = warGenerator.generate(busProtocol == ProtocolType.SOAP);
return vsbOutput;
}
public byte[] generateJar(JarGenerator jarGenerator){
archive = ShrinkWrap.create(JavaArchive.class);
if(bc != null) {
archive.addPackage(bc.getPackage());
}
archive.addPackage(eu.chorevolution.vsb.gmdl.tools.serviceparser.gidl.ParseGIDL.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.gmdl.tools.serviceparser.gmdl.ParseGMDL.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.gmdl.utils.Operation.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.gmdl.utils.enums.OperationType.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.bc.manager.BcManagerRestService.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.artifact.war.RestServlet.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.artifact.war.StartBcManagerServlet.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.artifact.generators.WarGenerator.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.bc.setinvaddrservice.BaseService.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.gm.protocols.Manageable.class.getPackage());
archive.addPackage(eu.chorevolution.vsb.gmdl.tools.serviceparser.ServiceDescriptionParser.class.getPackage());
jarGenerator.addArchive(archive);
return jarGenerator.generate();
}
......
......@@ -18,7 +18,6 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl;
import org.jboss.shrinkwrap.resolver.api.maven.embedded.BuiltProject;
import org.jboss.shrinkwrap.resolver.api.maven.embedded.EmbeddedMaven;
import eu.chorevolution.vsb.gmdl.utils.Constants;
import eu.chorevolution.vsb.gmdl.utils.PathResolver;
import eu.chorevolution.vsb.gmdl.utils.enums.ProtocolType;
......
......@@ -16,11 +16,11 @@ import java.util.List;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl;
import org.jboss.shrinkwrap.resolver.api.maven.embedded.BuiltProject;
import org.jboss.shrinkwrap.resolver.api.maven.embedded.EmbeddedMaven;
import eu.chorevolution.vsb.bc.manager.VsbOutput;
import eu.chorevolution.vsb.gmdl.utils.Constants;
import eu.chorevolution.vsb.gmdl.utils.PathResolver;
......@@ -36,8 +36,8 @@ public class WarGenerator {
public WarGenerator() {
String warDestination = Constants.warDestination;
archive = ShrinkWrap.create(WebArchive.class, warDestination);
}
public void addPackage(Package pack){
......@@ -97,6 +97,21 @@ public class WarGenerator {
buidAndMergeArchives( hmapPomXml.get("dpws"));
}
}
public void addDependencyFiles(String pathToPom){
BuiltProject builtProject = EmbeddedMaven.forProject(new File(pathToPom))
.useMaven3Version("3.3.9")
.setGoals("package")
.build();
List<Archive> jars = builtProject.getArchives();
for(Archive jar : jars ){
archive = archive.merge(jar);
}
PathResolver.deleteTempDir(new File(builtProject.getTargetDirectory().getAbsolutePath()));
}
public VsbOutput generate(boolean isBusProtocolSoap){
......@@ -147,10 +162,11 @@ public class WarGenerator {
archive.addAsWebResource(f, "assets" + "/" + "js" + "/" + f.getName());
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
new ZipExporterImpl(archive).exportTo(bos);
new ZipExporterImpl(archive).exportTo(new File(archive.getName()), true);
new ZipExporterImpl(archive).exportTo(new File(archive.getName()), true);
VsbOutput vsbOutput = new VsbOutput();
vsbOutput.war = bos.toByteArray();
......@@ -167,7 +183,6 @@ public class WarGenerator {
}
}
return vsbOutput;
}
......
......@@ -3,11 +3,11 @@ package eu.chorevolution.vsb.artifact.generators;
import java.io.File;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
/**
* @author Georgios Bouloukakis (boulouk@gmail.com)
*
......
......@@ -10,7 +10,8 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.restlet.Client;
......@@ -68,7 +69,6 @@ public class RestServlet extends HttpServlet {
String message = result.getText();
if (!message.equals("empty")){
if(!message.equals(previousMsg)) {
System.err.println("message: " + message);
out.print(StringUtils.abbreviate(message, 480));
previousMsg = message;
}
......@@ -128,9 +128,9 @@ public class RestServlet extends HttpServlet {
private String getRestServicePort(){
String bc_rest_service_port = "";
String service_port = "";
File dir = new File(BcManagerRestService.class.getClassLoader().getResource("example.json").toExternalForm().substring(9)).getParentFile().getParentFile().getParentFile().getParentFile();
File configFilePath = new File(dir.getAbsolutePath() + File.separator + "config"+ File.separator + "config_block1_interface_1");
File configFilePath = new File(dir.getAbsolutePath() + File.separator + "config"+ File.separator + "config_block2_interface_1");
JSONParser parser = new JSONParser();
JSONObject jsonObject = new JSONObject();
try {
......@@ -139,9 +139,9 @@ public class RestServlet extends HttpServlet {
} catch (Exception _x) {
}
if(jsonObject.get("bc_rest_service_port") != null){
bc_rest_service_port = (String) jsonObject.get("bc_rest_service_port");
if(jsonObject.get("service_port") != null){
service_port = (String) jsonObject.get("service_port");
}
return bc_rest_service_port;
return service_port;
}
}
......@@ -23,6 +23,14 @@ public class StartBcManagerServlet extends HttpServlet {
BcManagerRestService server = null;
public StartBcManagerServlet(){
int portBcManagerServlet = Integer.valueOf(getPort());
server = new BcManagerRestService(portBcManagerServlet);
}
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
......@@ -44,7 +52,6 @@ public class StartBcManagerServlet extends HttpServlet {
this.getServletContext().setAttribute("role", "role--1");
this.getServletContext().setAttribute("name", "name--1");
this.getServletContext().setAttribute("endpoints", "endpoints--1");
System.out.println("Query "+request.getQueryString().toString());
String op = request.getParameter("op");
if(op.equals("start")){
......@@ -58,9 +65,18 @@ public class StartBcManagerServlet extends HttpServlet {
}
else if(op.equals("startbcm")){
int portBcManagerServlet = Integer.valueOf(getPort());
server = new BcManagerRestService(portBcManagerServlet);
response.getWriter().println("-> BC Manager started!");
if(!server.isBcSarted()){
server = new BcManagerRestService(portBcManagerServlet);
response.getWriter().println("-> BC Manager started!");
}else{
response.getWriter().println("-> BC Manager already started!");
}
}
else if(op.equals("stopbcm")){
......
......@@ -38,6 +38,7 @@
<servlet>
<servlet-name>StartBcManagerServlet</servlet-name>
<servlet-class>eu.chorevolution.vsb.artifact.war.StartBcManagerServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>StartBcManagerServlet</servlet-name>
......
......@@ -10,6 +10,9 @@
<name>bc-generators</name>
<description>bc-generators provides classes and web interfaces to generate artifacts for binding components</description>
<packaging>pom</packaging>
<properties>
<vsb.version>2.1.1-SNAPSHOT</vsb.version>
</properties>
<modules>
<module>artifact-generators</module>
</modules>
......
......@@ -13,6 +13,7 @@
<properties>
<axis2.version>1.7.5</axis2.version>
<axis2.stable.version>1.7.5</axis2.stable.version>
<vsb.version>2.1.1-SNAPSHOT</vsb.version>
</properties>
<dependencies>
......@@ -20,27 +21,27 @@
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gmdl-utils</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>service-parser</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-rest</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-mqtt</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-coap</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
......@@ -50,7 +51,25 @@
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-dpws</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-soap</artifactId>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-ant-plugin</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
......
......@@ -87,8 +87,6 @@ public class BcManagerRest implements Manageable{
e.printStackTrace();
}
System.out.println("rec: " + receivedText);
String returnMessage = "";
returnMessage = "Configuration Complete!";
return new StringRepresentation(returnMessage);
......
......@@ -4,6 +4,10 @@ import java.io.Serializable;
public class VsbOutput implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
public byte[] war;
public byte[] jar;
public byte[] wsdl;
......@@ -15,4 +19,7 @@ public class VsbOutput implements Serializable {
public String response_message;
public String generatedCodePath;
public String service_name;
public String printer_service_port;
public String subcomponent_port;
}
......@@ -28,7 +28,6 @@ import java.util.List;
import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.mail.MessageContext;
import javax.servlet.ServletContext;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
......@@ -40,10 +39,6 @@ import org.json.simple.parser.ParseException;
import eu.chorevolution.vsb.bc.manager.BcManagerRestService;
import eu.chorevolution.vsb.bc.setinvaddrservice.BaseService;
import eu.chorevolution.vsb.gmdl.utils.BcConfiguration;
import eu.chorevolution.vsb.gmdl.utils.Constants;
import eu.chorevolution.vsb.gmdl.utils.PathResolver;
@WebService(
name = "ConfigurableService",
......
......@@ -64,7 +64,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.4</version>
<version>2.7.3</version>
</dependency>
<!-- RestLet -->
<dependency>
......
......@@ -117,7 +117,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.4</version>
<version>2.7.3</version>
</dependency>
<!-- RestLet -->
<dependency>
......
......@@ -8,6 +8,11 @@
<artifactId>gm-api</artifactId>
<name>gm-api</name>
<description>gm-protocols provides generics interfaces which each concrete protocol implemention MUST implement</description>
<properties>
<vsb.version>2.1.1-SNAPSHOT</vsb.version>
</properties>
<build>
<plugins>
<plugin>
......@@ -26,7 +31,7 @@
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gmdl-utils</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<!-- JSON Parsing & Mapping -->
<dependency>
......@@ -52,7 +57,7 @@
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>logger</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
</dependencies>
</project>
......@@ -8,6 +8,9 @@
<artifactId>gmdl-utils</artifactId>
<name>gmdl-utils</name>
<description>GMDL Utils provides classes to parse and instantiate a GMDL representation of a system to be binded, based on its description file</description>
<properties>
<vsb.version>2.1.0</vsb.version>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
......
......@@ -104,7 +104,6 @@ public class BcConfiguration {
} catch (Exception _x) {
}
System.out.println(jsonObject.toString());
if(jsonObject.get("target_namespace") != null)
setTargetNamespace((String) jsonObject.get("target_namespace"));
......@@ -126,8 +125,7 @@ public class BcConfiguration {
setSubcomponentPort(subcomponentPortInt);
System.out.println("Done parsing config file");
}
}
\ No newline at end of file
......@@ -13,6 +13,15 @@ public class Constants {
public static String wsdlName;
public static String service_name;
public static String subcomponent_port;
public static int subcomponent_port_min_range = 1200;
public static int subcomponent_port_max_range = 1299;
public static String printer_service_port;
public static int printer_service_port_min_range = 1300;
public static int printer_service_port_max_range = 1399;
public static String service_port;
public static int service_port_min_range = 5000;
public static int service_port_max_range = 5999;
......
......@@ -288,7 +288,7 @@ public static String myFilePath(Class className, String fileName){
if (entry.isDirectory()) {
// if its a directory, create it
final boolean bMade = f.mkdir();
System.out.println((bMade ? " creating " : " unable to create ") + name);
// System.out.println((bMade ? " creating " : " unable to create ") + name);
} else {
final InputStream is = jar.getInputStream(entry);
......
......@@ -37,7 +37,6 @@
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
......
......@@ -19,7 +19,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<!-- REST library: Restlet -->
<repository>
......@@ -61,6 +60,7 @@
<artifactId>experiment</artifactId>
<version>2.1.1-SNAPSHOT</version>
</dependency> -->
</dependencies>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>vsb</artifactId>
<version>2.1.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>VSB (eVolution Service Bus)</name>
<description>VSB provides tools to generate and use Binding-Component</description>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<vsb.version>2.1.1-SNAPSHOT</vsb.version>
</properties>
<organization>
<name>Inria MiMove Team</name>
<url>https://mimove.inria.fr</url>
......@@ -74,13 +80,8 @@
<url>http://repository.ow2.org/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<vsb.version>2.1.2-SNAPSHOT</vsb.version>
</properties>
<modules>
<module>gm-api</module>
<module>protocol-pool</module>
......@@ -91,8 +92,8 @@
<module>tools</module>
<module>vsb-manager-api</module>
<module>playgrounds</module>
</modules>
<build>
<plugins>
<plugin>
......@@ -217,4 +218,4 @@
</build>
</profile>
</profiles>
</project>
</project>
\ No newline at end of file
......@@ -32,12 +32,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
......
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
......@@ -70,12 +69,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
......
......@@ -74,12 +74,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
......@@ -109,6 +109,5 @@
<artifactId>xercesImpl</artifactId>
<version>2.6.2-jaxb-1.0.6</version>
</dependency>
</dependencies>
</project>
......@@ -9,6 +9,9 @@
</parent>
<artifactId>gm-rest</artifactId>
<name>gm-rest</name>
<properties>
<vsb.version>2.1.1-SNAPSHOT</vsb.version>
</properties>
<repositories>
<!-- REST library: Restlet -->
<repository>
......@@ -38,18 +41,18 @@
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-api</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<!-- JSON Parsing & Mapping -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
......
......@@ -65,7 +65,6 @@ public class BcRestSubcomponent extends BcGmSubcomponent {
this.bcRestSubcomponent = this;
setGmServiceRepresentation(serviceRepresentation);
int restservicePort = Integer.valueOf(bcConfiguration.getServicePort());
switch (this.bcConfiguration.getSubcomponentRole()) {
case SERVER:
......@@ -217,13 +216,43 @@ public class BcRestSubcomponent extends BcGmSubcomponent {
switch (scope.getVerb()) {
case GET:
// Add in order to handle service for WP4 in Chorevolution Project
if (scope.getName().equals("TrafficverketRoadcondition")
|| scope.getName().equals("VasttrafikGenerateOAuth2token")
|| scope.getName().equals("TrafficverketRoadcondition")
|| scope.getName().equals("TrafficverketWeather")
|| scope.getName().equals("VasttrafikrequestDepartureBoard")){
request = CustomRestRequestBuilder.buildRestGetRequest(destination, scope, datas);
}
// Default
else {
request = RestRequestBuilder.buildRestGetRequest(destination, scope, datas);
request = RestRequestBuilder.buildRestGetRequest(destination, scope, datas);
}
break;
case POST:
// Add in order to handle service for WP4 in Chorevolution Project
if (scope.getName().equals("TrafficverketRoadcondition")
|| scope.getName().equals("VasttrafikGenerateOAuth2token")
|| scope.getName().equals("TrafficverketRoadcondition")
|| scope.getName().equals("TrafficverketWeather")
|| scope.getName().equals("VasttrafikrequestDepartureBoard")) {
request = RestRequestBuilder.buildRestPostRequest(destination, scope, datas);
request = CustomRestRequestBuilder.buildRestPostRequest(destination, scope, datas);
}
// Default
else {
request = RestRequestBuilder.buildRestPostRequest(destination, scope, datas);
}
break;
default:
......@@ -233,18 +262,25 @@ public class BcRestSubcomponent extends BcGmSubcomponent {
break;
}
printermsg = (request.toString());
if(request.getMethod().equals(Method.GET)){
printermsg = (request.toString());
}else{
printermsg = (request.getEntityAsText());
}
logger.i(this.getClass().getName() + "[request]", printermsg);
logger.i(this.getClass().getName() + "[request Entity]", request.getEntityAsText());
for(Header header : request.getHeaders()){
System.out.println(header.getName()+" : "+header.getValue());
}
Response response = this.client.handle(request);
System.out.print(response.getStatus().toString());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
printermsg = (response.getEntityAsText());
printermsg = response.getStatus().toString();
logger.i(this.getClass().getName() + "[response]", printermsg);
return (T) response.getEntityAsText();
......@@ -344,7 +380,7 @@ public class BcRestSubcomponent extends BcGmSubcomponent {
}
public static class RestServerResource extends ServerResource {
public static class RestServerResource extends ServerResource{
@Override
protected Representation post(Representation entity) throws ResourceException {
......@@ -353,6 +389,7 @@ public class BcRestSubcomponent extends BcGmSubcomponent {
receivedText = entity.getText();
} catch (IOException e1) {
e1.printStackTrace();
}
// System.err.println(receivedText);
......
package eu.chorevolution.vsb.gm.protocols.rest;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.ws.rs.core.UriBuilder;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.restlet.Request;
import org.restlet.data.Header;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
import org.restlet.representation.StringRepresentation;
import org.restlet.util.Series;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.nitorcreations.xmlutils.XMLUtil;
import eu.chorevolution.vsb.gmdl.utils.Data;
import eu.chorevolution.vsb.gmdl.utils.Scope;
import eu.chorevolution.vsb.gmdl.utils.Data.Context;
public class CustomRestRequestBuilder {
private static Scope scope = null;
public static Request buildRestPostRequest(final String destination, final Scope scope, final List<Data<?>> datas) {
return buildRestRequest(Method.POST, destination, scope, datas);
}
public static Request buildRestGetRequest(final String destination, final Scope scope, final List<Data<?>> datas) {
return buildRestRequest(Method.GET, destination, scope, datas);
}
private static Request buildRestRequest(final Method method, final String destination, final Scope sc,
final List<Data<?>> datas) {
scope = sc;
Request request = new Request();
request.setResourceRef("");
UriBuilder builder = UriBuilder.fromPath(destination + scope.getUri());
buildRequestHeaders(request, datas);
buildRequestPath(builder, datas);
buildRequestQuery(request, datas);
buildRequestForm(request, datas);
buildRequestBody(request, datas);
String params = request.getResourceRef().toString();
try {
// request.setResourceRef(java.net.URLDecoder.decode(builder.toString(),
// "UTF-8"));
request.setResourceRef(java.net.URLDecoder.decode(destination + scope.getUri() + params, "UTF-8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setMethod(method);
return request;
}
private static void buildRequestBody(final Request request, final List<Data<?>> datas) {
StringBuilder req = new StringBuilder();
for (Data<?> data : datas) {
if (data.getContext() == Context.BODY) {
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
if (scope.getName().equals("VasttrafikGenerateOAuth2token")) {
if (data.getName().equals("authorization")) {
Series<Header> requestHeaders = new Series(Header.class);
requestHeaders.add("Authorization", data.getObject().toString());
requestHeaders.add("Accept", "*/*");
requestHeaders.add("Content-Type", "application/x-www-form-urlencoded");
request.getAttributes().put("org.restlet.http.headers", requestHeaders);
} else {
req.append(ow.writeValueAsString(data.getObject()));
}
} else {
req.append(ow.writeValueAsString(data.getObject()));
}
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}
if (scope.getName().equals("VasttrafikGenerateOAuth2token")) {
String message = new String(req.toString().substring(1,req.toString().length()-1));
StringRepresentation entity = new StringRepresentation(message);
entity.setMediaType(MediaType.APPLICATION_WWW_FORM);
request.setEntity(entity);
} else if (scope.getName().equals("TrafficverketRoadcondition")
|| scope.getName().equals("TrafficverketWeather")) {
String req_str = new String(req.toString());
Matcher junkMatcher = (Pattern.compile("^([\\W]+)<")).matcher(req_str.trim());
req_str = junkMatcher.replaceFirst("<");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
Document document = null;
try {
builder = factory.newDocumentBuilder();
document = builder
.parse(new InputSource(new StringReader(req_str.substring(0, req_str.lastIndexOf('>') + 1))));
} catch (Exception e) {
e.printStackTrace();
}
StringRepresentation entity = new StringRepresentation(XMLUtil.documentToString(document));
entity.setCharacterSet(null);
entity.setMediaType(MediaType.TEXT_XML);
request.setEntity(entity);
} else {
request.setEntity(req.toString(), MediaType.APPLICATION_ALL_JSON);
}
}
private static void buildRequestForm(final Request request, final List<Data<?>> datas) {
for (Data<?> data : datas) {
if (data.getContext() == Context.FORM) {
// TODO
}
}
}
private static void buildRequestQuery(final Request request, final List<Data<?>> datas) {
for (Data<?> data : datas) {
if (data.getContext() == Context.QUERY) {
if (data.getName().equals("authorization")) {
if (scope.getName().equals("VasttrafikrequestDepartureBoard")) {
Series<Header> requestHeaders = new Series(Header.class);
requestHeaders.add("Authorization", data.getObject().toString());
request.getAttributes().put("org.restlet.http.headers", requestHeaders);
}
} else {
request.getResourceRef().addQueryParameter(data.getName(), data.getObject().toString());
}
}
}
}
private static void buildRequestPath(final UriBuilder builder, final List<Data<?>> datas) {
for (Data<?> data : datas) {
if (data.getContext() == Context.PATH) {
builder.resolveTemplate(data.getName(), data.getObject());
}
}
}
private static void buildRequestHeaders(final Request request, final List<Data<?>> datas) {
for (Data<?> data : datas) {
if (data.getContext() == Context.HEADER) {
// request.getOnSent();
}
}
}
}
package eu.chorevolution.vsb.gm.protocols.rest;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.UriBuilder;
import org.json.JSONObject;
import org.json.XML;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.json.JSONException;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.restlet.Request;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
......@@ -88,7 +98,7 @@ public class RestRequestBuilder implements RequestBuilder {
if(isXmlMediaType){
JSONObject jsonObject = new JSONObject(json.toString());
org.json.JSONObject jsonObject = new org.json.JSONObject(json.toString());
request.setEntity(XML.toString(jsonObject).toString(), MediaType.APPLICATION_ALL_XML);
}else{
......@@ -110,10 +120,30 @@ public class RestRequestBuilder implements RequestBuilder {
private static void buildRequestQuery(final Request request, final List<Data<?>> datas) {
for (Data<?> data : datas) {
if (data.getContext() == Context.QUERY){
request.getResourceRef().addQueryParameter(data.getName(), data.getObject().toString());
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
JSONParser parser = new JSONParser();
JSONObject jsonObject = null;
try{
jsonObject = (JSONObject) parser.parse(ow.writeValueAsString(data.getObject()));
Map<String, String> map = new HashMap<>(jsonObject.size());
for (Object jsonEntry : jsonObject.entrySet()) {
Map.Entry<?, ?> entry = ((Map.Entry<?, ?>) jsonEntry);
map.put(entry.getKey().toString(), entry.getValue().toString());
request.getResourceRef().addQueryParameter(entry.getKey().toString(), entry.getValue().toString());
}
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
......
......@@ -12,6 +12,7 @@
<properties>
<axis2.version>1.7.3</axis2.version>
<axis2.stable.version>1.7.3</axis2.stable.version>
<vsb.version>2.1.1-SNAPSHOT</vsb.version>
</properties>
<build>
<plugins>
......@@ -38,17 +39,17 @@
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-rest</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gmdl-utils</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.vsb</groupId>
<artifactId>gm-api</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>${vsb.version}</version>
</dependency>
<!-- CodeModel -->
<dependency>
......@@ -73,17 +74,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.2</version>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.2</version>
<version>2.7.3</version>
</dependency>
<dependency>
......@@ -104,22 +105,6 @@
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-java2wsdl -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>${axis2.stable.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-ant-plugin</artifactId>
<version>${axis2.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/axis2/axis2 -->
</dependencies>
</project>
......@@ -129,9 +129,7 @@ public class GidlToWSDL {
DOMSource source = new DOMSource(wsdlDocument);
StreamResult result = new StreamResult(new File(Constants.wsdlDestination + File.separator + Constants.wsdlName+".wsdl"));
transformer.transform(source, result);
// Output to console for testing
StreamResult consoleResult = new StreamResult(System.out);
transformer.transform(source, consoleResult);
} catch (TransformerException e) {
// TODO Auto-generated catch block
......
package eu.chorevolution.vsb.gm.protocols.soap;
import java.io.ByteArrayOutputStream;
......@@ -40,18 +43,15 @@ public class BcSoapGenerator extends BcSubcomponentGenerator {
private final String classComment = "This class was generated by the CHOReVOLUTION BindingComponent Generator using com.sun.codemodel 2.6";
private Logger logger = GLog.initLogger();
public BcSoapGenerator(GmServiceRepresentation serviceRepresentation, BcConfiguration bcConfiguration){
public BcSoapGenerator(GmServiceRepresentation serviceRepresentation, BcConfiguration bcConfiguration) {
super(serviceRepresentation, bcConfiguration);
}
private void includePackageReference(String attrType, JCodeModel codeModel){
int firstBracket = attrType.indexOf("<");
if (firstBracket != -1){
logger.i(this.getClass().getName().toString(), "trying " + attrType.substring(0, firstBracket));
JClass dataClass = codeModel.ref(attrType.substring(0, firstBracket));
includePackageReference(attrType.substring(firstBracket + 1, attrType.length() - 1), codeModel);
}
......@@ -176,10 +176,6 @@ public class BcSoapGenerator extends BcSubcomponentGenerator {
private JFieldVar generateAttribute(final JCodeModel codeModel, final JDefinedClass definedClass,
final JClass attrClass, final String attrName, final Boolean isFinal) {
if(attrName.equals("points")){
System.out.println("mbote");
}
JFieldVar attrField = definedClass.field(JMod.PRIVATE, attrClass, attrName);
attrField.mods().setFinal(isFinal);
......@@ -205,7 +201,9 @@ public class BcSoapGenerator extends BcSubcomponentGenerator {
}
try {
codeModel.build(new File(this.bcConfiguration.getGeneratedCodePath()));
} catch (IOException e) {
e.printStackTrace();
}
......@@ -227,7 +225,6 @@ public class BcSoapGenerator extends BcSubcomponentGenerator {
String directClassTmp = codeModel_directClass;
codeModel_directClass = operation.getPostDatas().get(postDataSize-1).getClassName();
System.out.println(" codeModel_directClass "+codeModel_directClass);
if(codeModel_directClass.equals("List<"+directClassTmp+">")){
JClass importedClass= codeModel.ref(java.util.List.class)
......@@ -378,7 +375,7 @@ public class BcSoapGenerator extends BcSubcomponentGenerator {
definitionClass.annotate(javax.xml.bind.annotation.XmlAccessorType.class).param("value",
javax.xml.bind.annotation.XmlAccessType.FIELD);
definitionClass.annotate(javax.xml.bind.annotation.XmlRootElement.class).param("name", "ROOT");
definitionClass.annotate(javax.xml.bind.annotation.XmlRootElement.class).param("name", "OUTPUTDATATYPE");
Collection<Operation> operations = this.componentDescription.getOperations();
......@@ -422,3 +419,5 @@ public class BcSoapGenerator extends BcSubcomponentGenerator {
}
package eu.chorevolution.vsb.java2wsdl;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.EmptyStackException;
import java.util.Map;
import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.java2wsdl.Java2WSDLCodegenEngine;
import org.apache.ws.java2wsdl.jaxws.JAXWS2WSDLCodegenEngine;
import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOption;
import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOptionParser;
import org.apache.ws.java2wsdl.utils.Java2WSDLOptionsValidator;
import org.json.simple.JSONObject;
import org.json.simple.pa