Commit baf8972d authored by Alonso Ibarra, Juncal's avatar Alonso Ibarra, Juncal

ADAPT monitoring M24

parent 8df826a5
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>eu.decideh2020.adapt.monitoring.server</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
# Swagger Jersey generated server
## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
is an example of building a swagger-enabled JAX-RS server.
This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework.
To run the server, please execute the following:
```
mvn clean package jetty:run
```
You can then view the swagger listing here:
```
http://localhost:8080/monitoringmanager/swagger.json
```
Note that if you have configured the `host` to be something other than localhost, the calls through
swagger-ui will be directed to that host and not localhost!
\ No newline at end of file
......@@ -3,9 +3,8 @@
<groupId>eu.decideh2020</groupId>
<artifactId>seu.decideh2020.adapt.monitoring.server</artifactId>
<packaging>jar</packaging>
<name>swagger-jaxrs-server</name>
<name>adapt.monitoring.server</name>
<version>1.0.0</version>
<licenses>
<license>
<name>Unlicense</name>
......@@ -13,7 +12,6 @@
<distribution>repo</distribution>
</license>
</licenses>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
......@@ -99,6 +97,21 @@
</resources>
</build>
<dependencies>
<!-- <dependency>
<groupId>eu.decideh2020</groupId>
<artifactId>eu.decideh2020.ACSmI.monitoring.client</artifactId>
<version>1.0.0</version>
</dependency>-->
<!-- <dependency>
<groupId>eu.decideh2020</groupId>
<artifactId>eu.decideh2020.ACSmI.monitoring.client</artifactId>
<version>1.0.0</version>
</dependency>-->
<dependency>
<groupId>eu.decideh2020</groupId>
<artifactId>eu.decideh2020.telegraf.configparser</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.DECIDEh2020</groupId>
<artifactId>mcsla-core</artifactId>
......@@ -151,12 +164,12 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
<version>${jackson-jaxrs-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
<version>${jackson-jaxrs-version}</version>
</dependency>
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
......@@ -187,10 +200,12 @@
<java.version>1.7</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<swagger-core-version>1.5.15</swagger-core-version>
<swagger-core-version>1.5.18</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<jersey2-version>2.22.2</jersey2-version>
<jackson-version>2.8.9</jackson-version>
<cxf-version>3.1.11</cxf-version>
<!-- <jackson-version>2.8.9</jackson-version> -->
<jackson-jaxrs-version>2.9.1</jackson-jaxrs-version>
<junit-version>4.12</junit-version>
<logback-version>1.1.7</logback-version>
<servlet-api-version>2.5</servlet-api-version>
......
package eu.decideh2020.adapt.monitoring.server.api;
import io.swagger.annotations.ApiParam;
import io.swagger.jaxrs.*;
import java.util.Map;
import java.util.List;
import java.io.InputStream;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import eu.decideh2020.adapt.monitoring.server.api.ApiApiService;
import eu.decideh2020.adapt.monitoring.server.api.NotFoundException;
import eu.decideh2020.adapt.monitoring.server.api.factories.ApiApiServiceFactory;
import eu.decideh2020.adapt.monitoring.server.model.*;
import javax.servlet.ServletConfig;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*;
import javax.validation.constraints.*;
@Path("/api")
@io.swagger.annotations.Api(description = "the api API")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2018-03-26T08:06:54.399Z")
public class ApiApi {
private final ApiApiService delegate;
public ApiApi(@Context ServletConfig servletContext) {
ApiApiService delegate = null;
if (servletContext != null) {
String implClass = servletContext.getInitParameter("ApiApi.implementation");
if (implClass != null && !"".equals(implClass.trim())) {
try {
delegate = (ApiApiService) Class.forName(implClass).newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
if (delegate == null) {
delegate = ApiApiServiceFactory.getApiApi();
}
this.delegate = delegate;
}
@POST
@Path("/alert")
@Consumes({ "alert/json" })
@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "createAlert", notes = "Creates an alert to be included in ADAPT monitoring", response = Alert.class, tags={ "alert", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "Alert Created", response = Alert.class),
@io.swagger.annotations.ApiResponse(code = 401, message = "Unauthorized", response = Void.class) })
public Response createAlertUsingPOST(@ApiParam(value = "" ,required=true) Alert alert
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.createAlertUsingPOST(alert,securityContext);
}
@POST
@Path("/applications")
@Consumes({ "application/json" })
@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "createApplication", notes = "Creates an application to be included in ADAPT monitoring", response = Application.class, tags={ "application", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "Application monitoring Created", response = Application.class),
@io.swagger.annotations.ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Not Found", response = Void.class) })
public Response createApplicationUsingPOST(@ApiParam(value = "" ,required=true) Application application
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.createApplicationUsingPOST(application,securityContext);
}
@DELETE
@Path("/applications/{appdescuri}")
@Consumes({ "application/json" })
@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "deleteApplication", notes = "", response = Void.class, tags={ "application", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "App deleted form the monitoring list", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 204, message = "No Content", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 403, message = "Forbidden", response = Void.class) })
public Response deleteApplicationUsingDELETE(@ApiParam(value = "id",required=true) @PathParam("appdescuri") String appdescuri
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.deleteApplicationUsingDELETE(appdescuri,securityContext);
}
@GET
@Path("/applications")
@Consumes({ "application/json" })
@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "getAllApplications", notes = "Gets the list of all the applications in ADAPT monitoring, including their id and the status", response = Application.class, responseContainer = "List", tags={ "application", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "the list of simulations is being returned", response = Application.class, responseContainer = "List"),
@io.swagger.annotations.ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Not Found", response = Void.class) })
public Response getAllApplicationsUsingGET(@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.getAllApplicationsUsingGET(securityContext);
}
@GET
@Path("/applications/{appdescuri}")
@Consumes({ "application/json" })
@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "getApplicationstatus", notes = "Gets the status wrt monitoring of a given application", response = Application.class, tags={ "application", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "Specific app monitoring is returned", response = Application.class),
@io.swagger.annotations.ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Not Found", response = Void.class) })
public Response getApplicationUsingGET(@ApiParam(value = "id",required=true) @PathParam("appdescuri") String appdescuri
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.getApplicationUsingGET(appdescuri,securityContext);
}
@PUT
@Path("/applications/{appdescuri}")
@Consumes({ "application/json" })
@Produces({ "*/*" })
@io.swagger.annotations.ApiOperation(value = "updateApplication", notes = "Updates the monitoring status of a given application", response = Application.class, tags={ "application", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "Status updated", response = Application.class),
@io.swagger.annotations.ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Not Found", response = Void.class) })
public Response updateApplicationUsingPUT(@ApiParam(value = "id",required=true) @PathParam("appdescuri") String appdescuri
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.updateApplicationUsingPUT(appdescuri,securityContext);
}
}
package eu.decideh2020.adapt.monitoring.server.api;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import eu.decideh2020.adapt.monitoring.server.api.*;
import eu.decideh2020.adapt.monitoring.server.model.*;
import java.util.List;
import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.validation.constraints.*;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2018-03-26T08:06:54.399Z")
public abstract class ApiApiService {
public abstract Response createAlertUsingPOST(Alert alert,SecurityContext securityContext) throws NotFoundException;
public abstract Response createApplicationUsingPOST(Application application,SecurityContext securityContext) throws NotFoundException;
public abstract Response deleteApplicationUsingDELETE(String appdescuri,SecurityContext securityContext) throws NotFoundException;
public abstract Response getAllApplicationsUsingGET(SecurityContext securityContext) throws NotFoundException;
public abstract Response getApplicationUsingGET(String appdescuri,SecurityContext securityContext) throws NotFoundException;
public abstract Response updateApplicationUsingPUT(String appdescuri,SecurityContext securityContext) throws NotFoundException;
}
package eu.decideh2020.adapt.monitoring.server.api;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2018-05-15T15:32:55.738Z")
public class ApiException extends Exception{
private int code;
public ApiException (int code, String msg) {
super(msg);
this.code = code;
}
}
package eu.decideh2020.adapt.monitoring.server.api;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2018-05-15T15:32:55.738Z")
public class ApiOriginFilter implements javax.servlet.Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response);
}
public void destroy() {}
public void init(FilterConfig filterConfig) throws ServletException {}
}
\ No newline at end of file
package eu.decideh2020.adapt.monitoring.server.api;
import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2018-05-15T15:32:55.738Z")
public class ApiResponseMessage {
public static final int ERROR = 1;
public static final int WARNING = 2;
public static final int INFO = 3;
public static final int OK = 4;
public static final int TOO_BUSY = 5;
int code;
String type;
String message;
public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){
this.code = code;
switch(code){
case ERROR:
setType("error");
break;
case WARNING:
setType("warning");
break;
case INFO:
setType("info");
break;
case OK:
setType("ok");
break;
case TOO_BUSY:
setType("too busy");
break;
default:
setType("unknown");
break;
}
this.message = message;
}
@XmlTransient
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package eu.decideh2020.adapt.monitoring.server.api;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.joda.*;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.Provider;
@Provider
@Produces({MediaType.APPLICATION_JSON})
public class JacksonJsonProvider extends JacksonJaxbJsonProvider {
public JacksonJsonProvider() {
ObjectMapper objectMapper = new ObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.registerModule(new JodaModule())
.setDateFormat(new RFC3339DateFormat());
setMapper(objectMapper);
}
}
\ No newline at end of file
package eu.decideh2020.adapt.monitoring.server.api;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2018-03-26T08:06:54.399Z")
public class NotFoundException extends ApiException {
private int code;
public NotFoundException (int code, String msg) {
super(code, msg);
this.code = code;
}
}
package eu.decideh2020.adapt.monitoring.server.api;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}
\ No newline at end of file
package eu.decideh2020.adapt.monitoring.server.api;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2018-03-26T08:06:54.399Z")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
*
* @param array The array
* @param value The value to search
* @return true if the array contains the value
*/
public static boolean containsIgnoreCase(String[] array, String value) {
for (String str : array) {
if (value == null && str == null) return true;
if (value != null && value.equalsIgnoreCase(str)) return true;
}
return false;
}
/**
* Join an array of strings with the given separator.
* <p>
* Note: This might be replaced by utility method from commons-lang or guava someday
* if one of those libraries is added as dependency.
* </p>
*
* @param array The array of strings
* @param separator The separator
* @return the resulting string
*/
public static String join(String[] array, String separator) {
int len = array.length;
if (len == 0) return "";
StringBuilder out = new StringBuilder();
out.append(array[0]);
for (int i = 1; i < len; i++) {
out.append(separator).append(array[i]);
}
return out.toString();
}
}
/*
* adapt monitoring API
* adapt monitoring API documentation.This API describes the methods to access the ADAPT monitoring functionalities
*
* OpenAPI spec version: 0.0.1
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package eu.decideh2020.adapt.monitoring.server.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.*;
/**
* Alert
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2018-05-02T12:11:42.283Z")
public class Alert {
@JsonProperty("alid")
private String alid = null;
@JsonProperty("altype")
private String altype = null;
@JsonProperty("appdescuri")
private String appdescuri = null;
public Alert alid(String alid) {
this.alid = alid;
return this;
}
/**
* Get alid
* @return alid
**/
@JsonProperty("alid")
@ApiModelProperty(required = true, value = "")
@NotNull
public String getAlid() {
return alid;
}
public void setAlid(String alid) {
this.alid = alid;
}
public Alert altype(String altype) {
this.altype = altype;
return this;
}
/**
* Get altype
* @return altype
**/
@JsonProperty("altype")
@ApiModelProperty(required = true, value = "")
@NotNull
public String getAltype() {
return altype;
}
public void setAltype(String altype) {
this.altype = altype;
}
public Alert appdescuri(String appdescuri) {
this.appdescuri = appdescuri;
return this;
}
/**
* Get appdescuri
* @return appdescuri
**/
@JsonProperty("appdescuri")
@ApiModelProperty(required = true, value = "")
@NotNull