Package io.keyko.nevermined.external
Class GatewayService
- java.lang.Object
-
- io.keyko.nevermined.external.GatewayService
-
public class GatewayService extends Object
Service for Gateway's Integration
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGatewayService.ServiceAgreementResultstatic classGatewayService.ServiceExecutionResult
-
Field Summary
Fields Modifier and Type Field Description private static StringENCRYPT_URIprivate static StringHEADER_CONSUMER_ADDRESSprivate static StringHEADER_DIDprivate static StringHEADER_SIGNATUREprivate static StringHEADER_WORKFLOW_DIDprivate static org.apache.logging.log4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description GatewayService()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static io.keyko.common.helpers.HttpHelper.DownloadResultconsumeUrl(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String url, String destinationPath)Calls a Gateway´s endpoint to download an assetstatic voiddownloadToPath(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String did, int index, String signature, String destinationPath, Boolean isRangeRequest, Integer startRange, Integer endRange)Calls a Gateway endpoint to download an assetstatic voiddownloadToPathByOwner(String serviceEndpoint, String consumerAddress, String did, int index, String signature, String destinationPath, Boolean isRangeRequest, Integer startRange, Integer endRange)Calls a Gateway endpoint to download an assetstatic InputStreamdownloadUrl(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String did, int index, String signature, Boolean isRangeRequest, Integer startRange, Integer endRange)Calls a Gateway endpoint to download an assetstatic voiddownloadUrl(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String url, String destinationPath)Calls a Gateway endpoint to download an assetstatic InputStreamdownloadUrlByOwner(String serviceEndpoint, String consumerAddress, String did, int index, String signature, Boolean isRangeRequest, Integer startRange, Integer endRange)Calls a Gateway endpoint by the owner of an asset to to download itstatic EncryptionResponseencrypt(String gatewayUrl, String message, AuthorizationService.AuthTypes authType)Calls a Gateway endpoint to request the execution of a Compute Servicestatic EncryptionResponseencrypt(String gatewayUrl, String message, AuthorizationService.AuthTypes authType, String did)Calls a Gateway endpoint to request the execution of a Compute Servicestatic List<ComputeLogs>getComputeLogs(String serviceEndpoint, String consumerAddress, String signature)Calls a gateway endpoint to get the compute logsstatic ComputeStatusgetComputeStatus(String serviceEndpoint, String consumerAddress, String signature)Calls a gateway endpoint to get the compute statusprivate static StringgetExecutionId(String bodyResponse)static StatusgetStatus(String serviceEndpoint)Calls a Gateway endpoint to download an assetstatic GatewayService.ServiceAgreementResultinitializeAccessServiceAgreement(String url, InitializeAccessSLA payload)Deprecated.static GatewayService.ServiceExecutionResultinitializeServiceExecution(String serviceEndpoint, ExecuteService executeService)Calls a Gateway endpoint to request the execution of a Compute Service
-
-
-
Field Detail
-
log
private static final org.apache.logging.log4j.Logger log
-
ENCRYPT_URI
private static final String ENCRYPT_URI
- See Also:
- Constant Field Values
-
HEADER_CONSUMER_ADDRESS
private static final String HEADER_CONSUMER_ADDRESS
- See Also:
- Constant Field Values
-
HEADER_SIGNATURE
private static final String HEADER_SIGNATURE
- See Also:
- Constant Field Values
-
HEADER_DID
private static final String HEADER_DID
- See Also:
- Constant Field Values
-
HEADER_WORKFLOW_DID
private static final String HEADER_WORKFLOW_DID
- See Also:
- Constant Field Values
-
-
Method Detail
-
initializeAccessServiceAgreement
@Deprecated public static GatewayService.ServiceAgreementResult initializeAccessServiceAgreement(String url, InitializeAccessSLA payload)
Deprecated.This method is Deprecated and will be removed in further versions Calls a Gateway's endpoint to request the initialization of a new Service Agreement- Parameters:
url- the urlpayload- the payload- Returns:
- an object that indicates if the Gateway initialized the Service Agreement correctly
-
consumeUrl
public static io.keyko.common.helpers.HttpHelper.DownloadResult consumeUrl(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String url, String destinationPath) throws IOException, URISyntaxException
Calls a Gateway´s endpoint to download an asset- Parameters:
serviceEndpoint- the service endpointconsumerAddress- the address of the consumerserviceAgreementId- the serviceAgreement Idurl- the urldestinationPath- the path to download the resource- Returns:
- DownloadResult Instance of DownloadResult that indicates if the download was correct
- Throws:
IOException- IOExceptionURISyntaxException- URISyntaxException
-
downloadUrl
public static void downloadUrl(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String url, String destinationPath) throws IOException
Calls a Gateway endpoint to download an asset- Parameters:
serviceEndpoint- the service endpointconsumerAddress- the address of the consumerserviceAgreementId- the serviceAgreement Idurl- the urldestinationPath- the path to download the resource- Throws:
IOException- Exception during the download process
-
downloadUrl
public static InputStream downloadUrl(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String did, int index, String signature, Boolean isRangeRequest, Integer startRange, Integer endRange) throws IOException
Calls a Gateway endpoint to download an asset- Parameters:
serviceEndpoint- the service endpointconsumerAddress- the address of the consumerserviceAgreementId- the serviceAgreement Iddid- asset decentralized identifierindex- index position of the file in the DDOsignature- User signature of the service agreementstartRange- the start of the bytes rangeendRange- the end of the bytes rangeisRangeRequest- indicates if is a range request- Returns:
- an InputStream that represents the binary content
- Throws:
IOException- Exception during the download process
-
downloadUrlByOwner
public static InputStream downloadUrlByOwner(String serviceEndpoint, String consumerAddress, String did, int index, String signature, Boolean isRangeRequest, Integer startRange, Integer endRange) throws IOException
Calls a Gateway endpoint by the owner of an asset to to download it- Parameters:
serviceEndpoint- the service endpointconsumerAddress- the address of the consumerdid- asset decentralized identifierindex- index position of the file in the DDOsignature- User signature of the service agreementstartRange- the start of the bytes rangeendRange- the end of the bytes rangeisRangeRequest- indicates if is a range request- Returns:
- an InputStream that represents the binary content
- Throws:
IOException- Exception during the download process
-
downloadToPath
public static void downloadToPath(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String did, int index, String signature, String destinationPath, Boolean isRangeRequest, Integer startRange, Integer endRange) throws IOException
Calls a Gateway endpoint to download an asset- Parameters:
serviceEndpoint- the service endpointconsumerAddress- the address of the consumerserviceAgreementId- the serviceAgreement Iddid- asset decentralized identifierindex- index position of the file in the DDOsignature- User signature of the service agreementdestinationPath- path where the downloaded asset will be storedstartRange- the start of the bytes rangeendRange- the end of the bytes rangeisRangeRequest- indicates if is a range request- Throws:
IOException- Exception during the download process
-
downloadToPathByOwner
public static void downloadToPathByOwner(String serviceEndpoint, String consumerAddress, String did, int index, String signature, String destinationPath, Boolean isRangeRequest, Integer startRange, Integer endRange) throws IOException
Calls a Gateway endpoint to download an asset- Parameters:
serviceEndpoint- the service endpointconsumerAddress- the address of the consumerdid- asset decentralized identifierindex- index position of the file in the DDOsignature- User signature of the service agreementdestinationPath- path where the downloaded asset will be storedstartRange- the start of the bytes rangeendRange- the end of the bytes rangeisRangeRequest- indicates if is a range request- Throws:
IOException- Exception during the download process
-
getStatus
public static Status getStatus(String serviceEndpoint) throws IOException
Calls a Gateway endpoint to download an asset- Parameters:
serviceEndpoint- the service endpoint- Returns:
- an InputStream that represents the binary content
- Throws:
IOException- Exception during the download process
-
encrypt
public static EncryptionResponse encrypt(String gatewayUrl, String message, AuthorizationService.AuthTypes authType) throws ServiceException
Calls a Gateway endpoint to request the execution of a Compute Service- Parameters:
gatewayUrl- encryption endpointmessage- the message to encryptauthType- AuthType to use for encryption- Returns:
- EncryptionResponse an object that indicates if Gateway initialized the Execution of the Service correctly
- Throws:
ServiceException- Service Exception
-
encrypt
public static EncryptionResponse encrypt(String gatewayUrl, String message, AuthorizationService.AuthTypes authType, String did) throws ServiceException
Calls a Gateway endpoint to request the execution of a Compute Service- Parameters:
gatewayUrl- encryption endpointmessage- the message to encryptauthType- AuthType to use for encryptiondid- DID used to encrypt when using SecretStore- Returns:
- EncryptionResponse an object with the gateway encryption response
- Throws:
ServiceException- Service Exception
-
initializeServiceExecution
public static GatewayService.ServiceExecutionResult initializeServiceExecution(String serviceEndpoint, ExecuteService executeService)
Calls a Gateway endpoint to request the execution of a Compute Service- Parameters:
serviceEndpoint- the serviceEndpointexecuteService- the payload- Returns:
- an object that indicates if Gateway initialized the Execution of the Service correctly
-
getExecutionId
private static String getExecutionId(String bodyResponse) throws IOException
- Throws:
IOException
-
getComputeLogs
public static List<ComputeLogs> getComputeLogs(String serviceEndpoint, String consumerAddress, String signature) throws ServiceException
Calls a gateway endpoint to get the compute logs- Parameters:
serviceEndpoint- the gateway service endpointconsumerAddress- the address of the consumer of the compute to the data jobsignature- the signature of the executionId- Returns:
- a list of compute logs.
- Throws:
ServiceException- ServiceException
-
getComputeStatus
public static ComputeStatus getComputeStatus(String serviceEndpoint, String consumerAddress, String signature) throws ServiceException
Calls a gateway endpoint to get the compute status- Parameters:
serviceEndpoint- the gateway service endpointconsumerAddress- the address of the consumer of the compute to the data jobsignature- the signature of the executionId- Returns:
- the current status of the compute job.
- Throws:
ServiceException- ServiceException
-
-