Package com.oceanprotocol.squid.core.sla
Class ServiceAgreementHandler
- java.lang.Object
-
- com.oceanprotocol.squid.core.sla.ServiceAgreementHandler
-
public class ServiceAgreementHandler extends Object
Handles functionality related with the execution of a Service Agreement
-
-
Field Summary
Fields Modifier and Type Field Description private static String
ACCESS_CONDITIONS_FILE_TEMPLATE
private String
conditionsTemplate
static String
FUNCTION_ACCESSSECRETSTORE_DEF
static String
FUNCTION_ESCROWREWARD_DEF
static String
FUNCTION_LOCKREWARD_DEF
private static org.apache.logging.log4j.Logger
log
-
Constructor Summary
Constructors Constructor Description ServiceAgreementHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Boolean
checkAgreementStatus(String agreementId, String consumerAddress, com.oceanprotocol.keeper.contracts.EscrowAccessSecretStoreTemplate escrowAccessSecretStoreTemplate, Integer retries, Integer waitInMill)
static String
generateSlaId()
Generates a new and random Service Agreement Idprivate static org.web3j.tuples.generated.Tuple2<String,String>
getAgreementData(String agreementId, com.oceanprotocol.keeper.contracts.EscrowAccessSecretStoreTemplate escrowAccessSecretStoreTemplate)
static Map<String,Object>
getFunctionsFingerprints()
Compose the different function fingerprint hashesList<Condition>
initializeConditions(Map<String,Object> params)
Gets and Initializes all the conditions associated with a templatestatic io.reactivex.Flowable<com.oceanprotocol.keeper.contracts.EscrowAccessSecretStoreTemplate.AgreementCreatedEventResponse>
listenExecuteAgreement(com.oceanprotocol.keeper.contracts.EscrowAccessSecretStoreTemplate slaContract, String serviceAgreementId)
Define and execute a Filter over the Service Agreement Contract to listen for an AgreementInitialized eventstatic io.reactivex.Flowable<com.oceanprotocol.keeper.contracts.AccessSecretStoreCondition.FulfilledEventResponse>
listenForFulfilledEvent(com.oceanprotocol.keeper.contracts.AccessSecretStoreCondition accessCondition, String serviceAgreementId)
Define and execute a Filter over the AccessSecretStoreCondition Contract to listen for an Fulfilled event
-
-
-
Field Detail
-
log
private static final org.apache.logging.log4j.Logger log
-
ACCESS_CONDITIONS_FILE_TEMPLATE
private static final String ACCESS_CONDITIONS_FILE_TEMPLATE
- See Also:
- Constant Field Values
-
conditionsTemplate
private String conditionsTemplate
-
FUNCTION_LOCKREWARD_DEF
public static final String FUNCTION_LOCKREWARD_DEF
- See Also:
- Constant Field Values
-
FUNCTION_ACCESSSECRETSTORE_DEF
public static final String FUNCTION_ACCESSSECRETSTORE_DEF
- See Also:
- Constant Field Values
-
FUNCTION_ESCROWREWARD_DEF
public static final String FUNCTION_ESCROWREWARD_DEF
- See Also:
- Constant Field Values
-
-
Method Detail
-
generateSlaId
public static String generateSlaId()
Generates a new and random Service Agreement Id- Returns:
- a String with the new Service Agreement Id
-
listenExecuteAgreement
public static io.reactivex.Flowable<com.oceanprotocol.keeper.contracts.EscrowAccessSecretStoreTemplate.AgreementCreatedEventResponse> listenExecuteAgreement(com.oceanprotocol.keeper.contracts.EscrowAccessSecretStoreTemplate slaContract, String serviceAgreementId)
Define and execute a Filter over the Service Agreement Contract to listen for an AgreementInitialized event- Parameters:
slaContract
- the address of the service agreement contractserviceAgreementId
- the service agreement Id- Returns:
- a Flowable over the Event to handle it in an asynchronous fashion
-
listenForFulfilledEvent
public static io.reactivex.Flowable<com.oceanprotocol.keeper.contracts.AccessSecretStoreCondition.FulfilledEventResponse> listenForFulfilledEvent(com.oceanprotocol.keeper.contracts.AccessSecretStoreCondition accessCondition, String serviceAgreementId)
Define and execute a Filter over the AccessSecretStoreCondition Contract to listen for an Fulfilled event- Parameters:
accessCondition
- the address of the AccessSecretStoreCondition contractserviceAgreementId
- the serviceAgreement Id- Returns:
- a Flowable over the Event to handle it in an asynchronous fashion
-
getAgreementData
private static org.web3j.tuples.generated.Tuple2<String,String> getAgreementData(String agreementId, com.oceanprotocol.keeper.contracts.EscrowAccessSecretStoreTemplate escrowAccessSecretStoreTemplate) throws Exception
- Throws:
Exception
-
checkAgreementStatus
public static Boolean checkAgreementStatus(String agreementId, String consumerAddress, com.oceanprotocol.keeper.contracts.EscrowAccessSecretStoreTemplate escrowAccessSecretStoreTemplate, Integer retries, Integer waitInMill) throws Exception
- Throws:
Exception
-
initializeConditions
public List<Condition> initializeConditions(Map<String,Object> params) throws InitializeConditionsException
Gets and Initializes all the conditions associated with a template- Parameters:
params
- params to fill the conditions- Returns:
- a List with all the conditions of the template
- Throws:
InitializeConditionsException
- InitializeConditionsException
-
getFunctionsFingerprints
public static Map<String,Object> getFunctionsFingerprints() throws UnsupportedEncodingException
Compose the different function fingerprint hashes- Returns:
- Map of (varible name, function fingerprint)
- Throws:
UnsupportedEncodingException
- UnsupportedEncodingException
-
-