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 class
GatewayService.ServiceAgreementResult
static class
GatewayService.ServiceExecutionResult
-
Field Summary
Fields Modifier and Type Field Description private static String
ACCESS_HEADER_CONSUMER_ADDRESS
private static String
ACCESS_HEADER_DID
private static String
ACCESS_HEADER_SIGNATURE
private static String
ENCRYPT_URI
private static org.apache.logging.log4j.Logger
log
-
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.DownloadResult
consumeUrl(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String url, String destinationPath)
Calls a Gateway´s endpoint to download an assetstatic void
downloadToPath(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 InputStream
downloadUrl(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 void
downloadUrl(String serviceEndpoint, String consumerAddress, String serviceAgreementId, String url, String destinationPath)
Calls a Gateway endpoint to download an assetstatic EncryptionResponse
encrypt(String gatewayUrl, String message, AuthorizationService.AuthTypes authType)
Calls a Gateway endpoint to request the execution of a Compute Servicestatic EncryptionResponse
encrypt(String gatewayUrl, String message, AuthorizationService.AuthTypes authType, String did)
Calls a Gateway endpoint to request the execution of a Compute Serviceprivate static String
getExecutionId(String bodyResponse)
static Status
getStatus(String serviceEndpoint)
Calls a Gateway endpoint to download an assetstatic GatewayService.ServiceAgreementResult
initializeAccessServiceAgreement(String url, InitializeAccessSLA payload)
Deprecated.static GatewayService.ServiceExecutionResult
initializeServiceExecution(String serviceEndpoint, ExecuteService payload)
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
-
ACCESS_HEADER_CONSUMER_ADDRESS
private static final String ACCESS_HEADER_CONSUMER_ADDRESS
- See Also:
- Constant Field Values
-
ACCESS_HEADER_DID
private static final String ACCESS_HEADER_DID
- See Also:
- Constant Field Values
-
ACCESS_HEADER_SIGNATURE
private static final String ACCESS_HEADER_SIGNATURE
- 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
-
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
-
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 payload)
Calls a Gateway endpoint to request the execution of a Compute Service- Parameters:
serviceEndpoint
- the serviceEndpointpayload
- 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
-
-