Skip to content

Commit

Permalink
Merge remote-tracking branch 'eclipse/main' into fix/provider-agent-d…
Browse files Browse the repository at this point in the history
…ocker-user
  • Loading branch information
drcgjung committed Oct 20, 2023
2 parents 82f2421 + d93ef01 commit baec622
Show file tree
Hide file tree
Showing 61 changed files with 4,572 additions and 2,267 deletions.
1,168 changes: 1,168 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions conforming/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>

</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,67 @@
// SPDX-License-Identifier: Apache-2.0
package org.eclipse.tractusx.agents.conforming.api;

import org.eclipse.tractusx.agents.conforming.model.CxWarning;
import org.eclipse.tractusx.agents.conforming.model.XmlResultset;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.headers.Header;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;

import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.eclipse.tractusx.agents.conforming.model.CxWarning;
import org.eclipse.tractusx.agents.conforming.model.JsonResultset;
import org.eclipse.tractusx.agents.conforming.model.XmlResultset;

import java.util.List;

import javax.ws.rs.core.*;
import javax.ws.rs.*;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;

@Path("/")
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaJerseyServerCodegen", date = "2023-03-23T11:28:11.277776230Z[GMT]")public abstract class AgentApi {
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaJerseyServerCodegen", date = "2023-03-23T11:28:11.277776230Z[GMT]")
public abstract class AgentApi {

@Context public SecurityContext securityContext;
@Context public Application application;
@Context public HttpHeaders headers;
@Context public Request request;
@Context public Response response;
@Context public UriInfo uri;
@Context
public SecurityContext securityContext;
@Context
public Application application;
@Context
public HttpHeaders headers;
@Context
public Request request;
@Context
public Response response;
@Context
public UriInfo uri;

@GET
@Produces({ "application/sparql-results+json",
"application/sparql-results+xml"
"application/sparql-results+xml"
})
@Operation(summary = "Invoke a Skill or Query (Simple)", description = "", tags={ "agent" })
@Operation(summary = "Invoke a Skill or Query (Simple)", description = "", tags = { "agent" })
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The SparQL query has been processed successfully.",
content = {
@Content(mediaType = "application/sparql-results+json", schema = @Schema(implementation = JsonResultset.class)),
@Content(mediaType = "application/sparql-results+xml", schema = @Schema(implementation = XmlResultset.class))
}),
}),
@ApiResponse(responseCode = "203", description = "The SparQL query has been processed successfully but warnings did occur.",
headers = { @Header(name="cx_warnings",schema=@Schema(type="array",implementation=CxWarning.class))},
content = {
@Content(mediaType = "application/sparql-results+json", schema = @Schema(implementation = JsonResultset.class)),
@Content(mediaType = "application/sparql-results+xml", schema = @Schema(implementation = XmlResultset.class))
}),
headers = { @Header(name = "cx_warnings", schema = @Schema(type = "array", implementation = CxWarning.class)) },
content = {
@Content(mediaType = "application/sparql-results+json", schema = @Schema(implementation = JsonResultset.class)),
@Content(mediaType = "application/sparql-results+xml", schema = @Schema(implementation = XmlResultset.class))
}),
@ApiResponse(responseCode = "400", description = "Bad request or malformed SPARQL"),
@ApiResponse(responseCode = "500", description = "Fatal error")
})
Expand All @@ -72,23 +88,23 @@ public abstract Response getAgent(
@Parameter(in = ParameterIn.QUERY, description = "The SPARQL query")
@QueryParam("query") String query,
@Parameter(in = ParameterIn.QUERY, description = "A sample bound parameter 'vin' which opens a new input tuple")
@QueryParam("(vin") String _vin,
@QueryParam("(vin") String vin,
@Parameter(in = ParameterIn.QUERY, description = "A sample multi-bound parameter 'troubleCode' which closes the tuple")
@QueryParam("troubleCode") List<String> troubleCode)
throws org.eclipse.tractusx.agents.conforming.api.NotFoundException;
throws org.eclipse.tractusx.agents.conforming.api.NotFoundException;

@POST
@Consumes({ "application/sparql-results+json", "application/sparql-results+xml", "application/sparql-query" })
@Produces({ "application/sparql-results+json", "application/sparql-results+xml" })
@Operation(summary = "Invoke a Skill or Query (Flexible)", description = "", tags={ "agent" })
@Operation(summary = "Invoke a Skill or Query (Flexible)", description = "", tags = { "agent" })
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The SparQL query has been processed successfully.",
content = {
@Content(mediaType = "application/sparql-results+json", schema = @Schema(implementation = JsonResultset.class)),
@Content(mediaType = "application/sparql-results+xml", schema = @Schema(implementation = XmlResultset.class))
}),
@ApiResponse(responseCode = "203", description = "The SparQL query has been processed successfully but warnings did occur.",
headers = { @Header(name="cx_warnings",schema=@Schema(type="array",implementation=CxWarning.class))},
headers = { @Header(name = "cx_warnings", schema = @Schema(type = "array", implementation = CxWarning.class)) },
content = {
@Content(mediaType = "application/sparql-results+json", schema = @Schema(implementation = JsonResultset.class)),
@Content(mediaType = "application/sparql-results+xml", schema = @Schema(implementation = XmlResultset.class))
Expand All @@ -97,7 +113,7 @@ public abstract Response getAgent(
@ApiResponse(responseCode = "500", description = "Fatal error")
})
public abstract Response postAgent(
@Parameter(in = ParameterIn.DEFAULT, description = "The body either contains the query or a binding data set when a skill is invoked" ,required=true)
@Parameter(in = ParameterIn.DEFAULT, description = "The body either contains the query or a binding data set when a skill is invoked", required = true)
Object body,
@Parameter(in = ParameterIn.QUERY, description = "The Target Asset of the Query (targets the complete dataspace if empty)")
@QueryParam("asset") String asset,
Expand All @@ -106,25 +122,25 @@ public abstract Response postAgent(
@Parameter(in = ParameterIn.QUERY, description = "The SPARQL query")
@QueryParam("query") String query,
@Parameter(in = ParameterIn.QUERY, description = "A sample bound parameter 'vin' which opens a new input tuple")
@QueryParam("(vin") String _vin,
@QueryParam("(vin") String vin,
@Parameter(in = ParameterIn.QUERY, description = "A sample multi-bound parameter 'troubleCode' which closes the tuple")
@QueryParam("troubleCode") List<String> troubleCode)
throws org.eclipse.tractusx.agents.conforming.api.NotFoundException;
throws org.eclipse.tractusx.agents.conforming.api.NotFoundException;

@POST
@Path("/skill")
@Consumes({ "application/sparql-query" })
@Operation(summary = "Register a Skill", description = "", tags={ "agent" })
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Skill has been registered"),
@ApiResponse(responseCode = "204", description = "Skill has been updated"),
@ApiResponse(responseCode = "400", description = "Bad request or malformed SPARQL"),
@ApiResponse(responseCode = "500", description = "Fatal error") })
@Operation(summary = "Register a Skill", description = "", tags = { "agent" })
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Skill has been registered"),
@ApiResponse(responseCode = "204", description = "Skill has been updated"),
@ApiResponse(responseCode = "400", description = "Bad request or malformed SPARQL"),
@ApiResponse(responseCode = "500", description = "Fatal error") })
public abstract Response postSkill(
@Parameter(in = ParameterIn.DEFAULT, description = "The body either contains the parameterized query" ,required=true)
@Parameter(in = ParameterIn.DEFAULT, description = "The body either contains the parameterized query", required = true)
String body,
@Parameter(in = ParameterIn.QUERY, description = "The Target Asset of the Query (targets the complete dataspace if empty)",required=true)
@Parameter(in = ParameterIn.QUERY, description = "The Target Asset of the Query (targets the complete dataspace if empty)", required = true)
@QueryParam("asset") String asset)
throws NotFoundException;
throws org.eclipse.tractusx.agents.conforming.api.NotFoundException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
// SPDX-License-Identifier: Apache-2.0
package org.eclipse.tractusx.agents.conforming.api;

@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaJerseyServerCodegen", date = "2023-03-23T11:28:11.277776230Z[GMT]")public class ApiException extends Exception{
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaJerseyServerCodegen", date = "2023-03-23T11:28:11.277776230Z[GMT]")
public class ApiException extends Exception {
private int code;
public ApiException (int code, String msg) {

public ApiException(int code, String msg) {
super(msg);
this.code = code;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@
package org.eclipse.tractusx.agents.conforming.api;

import java.io.IOException;

import javax.servlet.*;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaJerseyServerCodegen", date = "2023-03-23T11:28:11.277776230Z[GMT]")public class ApiOriginFilter implements javax.servlet.Filter {
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaJerseyServerCodegen", date = "2023-03-23T11:28:11.277776230Z[GMT]")
public class ApiOriginFilter implements javax.servlet.Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}

@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
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");
Expand All @@ -33,8 +41,6 @@ public void doFilter(ServletRequest request, ServletResponse response,
}

@Override
public void destroy() {}

@Override
public void init(FilterConfig filterConfig) throws ServletException {}
public void destroy() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,40 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.tractusx.agents.conforming.ConformingAgent;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

@Provider
public class JsonProvider implements MessageBodyReader, MessageBodyWriter {

ObjectMapper objectMapper=new ObjectMapper();
ObjectMapper objectMapper = new ObjectMapper();

@Override
public boolean isReadable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) {
public boolean isReadable(Class aclass, Type type, Annotation[] annotations, MediaType mediaType) {
return mediaType.isCompatible(ConformingAgent.srj);
}

@Override
public Object readFrom(Class aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
public Object readFrom(Class aclass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
return objectMapper.readTree(inputStream);
}

@Override
public boolean isWriteable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) {
public boolean isWriteable(Class aclass, Type type, Annotation[] annotations, MediaType mediaType) {
return mediaType.isCompatible(ConformingAgent.srj);
}

@Override
public void writeTo(Object o, Class aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException {
objectMapper.writeValue(outputStream,o);
public void writeTo(Object o, Class aclass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException {
objectMapper.writeValue(outputStream, o);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
// SPDX-License-Identifier: Apache-2.0
package org.eclipse.tractusx.agents.conforming.api;

@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaJerseyServerCodegen", date = "2023-03-23T11:28:11.277776230Z[GMT]")public class NotFoundException extends ApiException {
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaJerseyServerCodegen", date = "2023-03-23T11:28:11.277776230Z[GMT]")
public class NotFoundException extends ApiException {
private int code;
public NotFoundException (int code, String msg) {

public NotFoundException(int code, String msg) {
super(code, msg);
this.code = code;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.text.FieldPosition;
import java.util.Date;

public class RFC3339DateFormat extends ISO8601DateFormat {
public class Rfc3339DateFormat extends ISO8601DateFormat {

// Same as ISO8601DateFormat but serializing milliseconds.
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,46 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.tractusx.agents.conforming.ConformingAgent;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.stream.Collectors;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import java.io.*;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.stream.Collectors;

@Provider
public class SparqlProvider implements MessageBodyReader, MessageBodyWriter {

ObjectMapper objectMapper=new ObjectMapper();
ObjectMapper objectMapper = new ObjectMapper();

@Override
public boolean isReadable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) {
public boolean isReadable(Class aclass, Type type, Annotation[] annotations, MediaType mediaType) {
return mediaType.isCompatible(ConformingAgent.sq);
}

@Override
public Object readFrom(Class aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
try (BufferedReader reader=new BufferedReader(new InputStreamReader(inputStream))) {
public Object readFrom(Class aclass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
return reader.lines().collect(Collectors.joining("\n"));
}
}

@Override
public boolean isWriteable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) {
public boolean isWriteable(Class aclass, Type type, Annotation[] annotations, MediaType mediaType) {
return mediaType.isCompatible(ConformingAgent.sq);
}

@Override
public void writeTo(Object o, Class aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException {
public void writeTo(Object o, Class aclass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException {
new OutputStreamWriter(outputStream).append(String.valueOf(o));
}
}
Loading

0 comments on commit baec622

Please sign in to comment.