Class AssetRestServer
java.lang.Object
de.iip_ecosphere.platform.support.aas.basyx2.apps.asset.AssetRestServer
- All Implemented Interfaces:
de.iip_ecosphere.platform.support.Server
Implements a simple Asset REST server as alternative to the (usually Tomcat-based) BaSyX-like implementation. The
implementation is based on the REST plugin abstraction of oktoflow (assuming a non-Tomcat-based implementation to
avoid conflicts with the singleton call of
URL.setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory)) but re-using BaSyx components
where adequate.- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.fasterxml.jackson.databind.ObjectMapperprivate AasOperationsProviderprivate static final Stringprivate static final Stringprivate de.iip_ecosphere.platform.support.rest.Rest.RestServerprivate de.iip_ecosphere.platform.support.aas.SetupSpec.ComponentSetupprivate Map<String, de.iip_ecosphere.platform.support.aas.AuthenticationDescriptor.IdentityTokenWithRole> -
Constructor Summary
ConstructorsConstructorDescriptionAssetRestServer(AasOperationsProvider opProvider, de.iip_ecosphere.platform.support.aas.SetupSpec.ComponentSetup setup) Creates an Asset REST server instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate StringAppends a JSON key totext.private StringappendValue(String key, Number value, String text) Appends a JSON key-value pair totext.private StringappendValue(String key, String value, String text) Appends a JSON key-value pair totext.private StringcreateErrorObject(de.iip_ecosphere.platform.support.rest.Rest.Request req, de.iip_ecosphere.platform.support.rest.Rest.Response res, org.springframework.http.HttpStatus status, String error) Creates an error object (not usingmapperto avoid further exception handling).private Stringhandle(de.iip_ecosphere.platform.support.rest.Rest.Request req, de.iip_ecosphere.platform.support.rest.Rest.Response res, String opName, String category) Handles an operation call request.private voidsetupAuthentication(de.iip_ecosphere.platform.support.aas.AuthenticationDescriptor auth) Sets up the authentication.de.iip_ecosphere.platform.support.Serverstart()voidstop(boolean dispose)
-
Field Details
-
PREFIX_AUTH_BASIC
- See Also:
-
PREFIX_AUTH_BEARER
- See Also:
-
opProvider
-
setup
private de.iip_ecosphere.platform.support.aas.SetupSpec.ComponentSetup setup -
server
private de.iip_ecosphere.platform.support.rest.Rest.RestServer server -
mapper
private com.fasterxml.jackson.databind.ObjectMapper mapper -
users
-
-
Constructor Details
-
AssetRestServer
public AssetRestServer(AasOperationsProvider opProvider, de.iip_ecosphere.platform.support.aas.SetupSpec.ComponentSetup setup) Creates an Asset REST server instance.- Parameters:
opProvider- the operations providersetup- the component setup
-
-
Method Details
-
start
public de.iip_ecosphere.platform.support.Server start()- Specified by:
startin interfacede.iip_ecosphere.platform.support.Server
-
setupAuthentication
private void setupAuthentication(de.iip_ecosphere.platform.support.aas.AuthenticationDescriptor auth) Sets up the authentication.- Parameters:
auth- the authentication descriptor
-
handle
private String handle(de.iip_ecosphere.platform.support.rest.Rest.Request req, de.iip_ecosphere.platform.support.rest.Rest.Response res, String opName, String category) Handles an operation call request.- Parameters:
req- the HTTP requestres- the HTTP responseopName- the operation namecategory- the category, may be null then a service function is determined based onopName- Returns:
- the result body
-
appendKey
Appends a JSON key totext.- Parameters:
key- the keytext- the text to append to- Returns:
- the appended text
-
appendValue
Appends a JSON key-value pair totext.- Parameters:
key- the keyvalue- the value- Returns:
- the appended text
-
appendValue
Appends a JSON key-value pair totext.- Parameters:
key- the keyvalue- the value- Returns:
- the appended text
-
createErrorObject
private String createErrorObject(de.iip_ecosphere.platform.support.rest.Rest.Request req, de.iip_ecosphere.platform.support.rest.Rest.Response res, org.springframework.http.HttpStatus status, String error) Creates an error object (not usingmapperto avoid further exception handling).- Parameters:
req- the request objectres- the response objectstatus- the status code (to be set onres)error- the error description- Returns:
- the error object as JSON string
-
stop
public void stop(boolean dispose) - Specified by:
stopin interfacede.iip_ecosphere.platform.support.Server
-