Package io.keyko.nevermined.api.impl
Class AssetsImpl
- java.lang.Object
-
- io.keyko.nevermined.api.impl.AssetsImpl
-
-
Field Summary
Fields Modifier and Type Field Description private AgreementsManageragreementsManagerprivate AssetsManagerassetsManagerprivate static intDEFAULT_OFFSETprivate static intDEFAULT_PAGEprivate NeverminedManagerneverminedManager
-
Constructor Summary
Constructors Constructor Description AssetsImpl(NeverminedManager neverminedManager, AssetsManager assetsManager, AgreementsManager agreementsManager)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Booleanconsume(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex, String basePath)Downloads an Asset previously ordered through a Service AgreementBooleanconsume(String serviceAgreementId, DID did, int serviceDefinitionId, String basePath)Downloads an Asset previously ordered through a Service AgreementInputStreamconsumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId)Gets the input stream of one file of the assetInputStreamconsumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex)Gets the input stream of one file of the assetInputStreamconsumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex, int rangeStart, int rangeEnd)Gets a range of bytes of the input stream of one file of the assetList<DID>consumerAssets(String consumerAddress)List of Asset objects purchased by consumerAddressDDOcreate(AssetMetadata metadata, ProviderConfig providerConfig)Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in MetadataDDOcreate(AssetMetadata metadata, ProviderConfig providerConfig, AuthConfig authConfig)Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in MetadataDDOcreateComputeService(AssetMetadata metadata, ProviderConfig providerConfig)Creates a new ComputingService DDO, registering it on-chain through DidRegistry contract and off-chain in MetadataDDOcreateComputeService(AssetMetadata metadata, ProviderConfig providerConfig, ComputingService.Provider computingProvider)Creates a new ComputingService DDO, registering it on-chain through DidRegistry contract and off-chain in MetadataBooleandelegatePermissions(DID did, String subjectAddress)For a existing asset, the owner of the asset delegate to a subject read or access permissGatewayService.ServiceExecutionResultexecute(String agreementId, DID did, int index, DID workflowDID)Executes a remote service associated with an asset and serviceAgreementIdList<ComputeLogs>getComputeLogs(String serviceAgreementId, String executionId, String consumerAddress, ProviderConfig providerConfig)Get the logs for the compute job with executionId and serviceAgreementIdComputeStatusgetComputeStatus(String serviceAgreementId, String executionId, String consumerAddress, ProviderConfig providerConfig)Get the status for the compute job with executionId and serviceAgreementIdList<AssetMetadata.File>getMetadataFiles(DID did)Gets the list of the files that belongs to a DDOBooleangetPermissions(DID did, String subjectAddress)Check if an user has permissions in a specific DIDio.reactivex.Flowable<OrderResult>order(DID did, int serviceDefinitionId)Purchases an Asset represented by a DID.OrderResultorderDirect(DID did)Purchases an Asset represented by a DID.OrderResultorderDirect(DID did, int serviceDefinitionId)Purchases an Asset represented by a DID.OrderResultorderDirect(DID did, int serviceDefinitionId, Service.ServiceTypes serviceTypes)Purchases an Asset represented by a DID.OrderResultorderDirect(DID did, Service.ServiceTypes serviceTypes)Purchases an Asset represented by a DID.Stringowner(DID did)Return the owner of the asset.List<DID>ownerAssets(String ownerAddress)List of Asset objects published by ownerAddressBooleanownerDownload(DID did, int serviceIndex, String basePath)Purchases an Asset represented by a DID.BooleanownerDownload(DID did, int serviceIndex, String basePath, int fileIndex)SearchResultquery(Map<String,Object> params)Gets all the DDOs that match the parameters of the querySearchResultquery(Map<String,Object> params, int offset, int page, int sort)Gets all the DDOs that match the parameters of the queryDDOresolve(DID did)Gets a DDO from a DIDBooleanretire(DID did)Retire this did of MetadataBooleanrevokePermissions(DID did, String subjectAddress)For a existing asset, the owner of the asset revoke the access grants of a subject.SearchResultsearch(String text)Gets all the DDO that match the search criteriaSearchResultsearch(String text, int offset, int page)Gets all the DDOs that match the search criteriaBooleantransferOwnership(DID did, String newOwnerAddress)Given a DID, transfer the ownership to a new owner.Booleanvalidate(AssetMetadata metadata)Validate the asset metadata.
-
-
-
Field Detail
-
neverminedManager
private NeverminedManager neverminedManager
-
assetsManager
private AssetsManager assetsManager
-
agreementsManager
private AgreementsManager agreementsManager
-
DEFAULT_OFFSET
private static final int DEFAULT_OFFSET
- See Also:
- Constant Field Values
-
DEFAULT_PAGE
private static final int DEFAULT_PAGE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AssetsImpl
public AssetsImpl(NeverminedManager neverminedManager, AssetsManager assetsManager, AgreementsManager agreementsManager)
Constructor- Parameters:
neverminedManager- the neverminedManagerassetsManager- the assetsManageragreementsManager- the agreements Manager
-
-
Method Detail
-
create
public DDO create(AssetMetadata metadata, ProviderConfig providerConfig, AuthConfig authConfig) throws DDOException
Description copied from interface:AssetsAPICreates a new DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata- Specified by:
createin interfaceAssetsAPI- Parameters:
metadata- the metadata of the DDOproviderConfig- the endpoints of the DDO's servicesauthConfig- Auth configuration- Returns:
- an instance of the DDO created
- Throws:
DDOException- DDOException
-
create
public DDO create(AssetMetadata metadata, ProviderConfig providerConfig) throws DDOException
Description copied from interface:AssetsAPICreates a new DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata- Specified by:
createin interfaceAssetsAPI- Parameters:
metadata- the metadata of the DDOproviderConfig- the endpoints of the DDO's services- Returns:
- an instance of the DDO created
- Throws:
DDOException- DDOException
-
createComputeService
public DDO createComputeService(AssetMetadata metadata, ProviderConfig providerConfig) throws DDOException
Description copied from interface:AssetsAPICreates a new ComputingService DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata- Specified by:
createComputeServicein interfaceAssetsAPI- Parameters:
metadata- the metadata of the DDOproviderConfig- the endpoints of the DDO's services- Returns:
- an instance of the DDO created
- Throws:
DDOException- DDOException
-
createComputeService
public DDO createComputeService(AssetMetadata metadata, ProviderConfig providerConfig, ComputingService.Provider computingProvider) throws DDOException
Description copied from interface:AssetsAPICreates a new ComputingService DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata- Specified by:
createComputeServicein interfaceAssetsAPI- Parameters:
metadata- the metadata of the DDOproviderConfig- the endpoints of the DDO's servicescomputingProvider- the computing provider configuration- Returns:
- an instance of the DDO created
- Throws:
DDOException- DDOException
-
getComputeLogs
public List<ComputeLogs> getComputeLogs(String serviceAgreementId, String executionId, String consumerAddress, ProviderConfig providerConfig) throws ServiceException
Description copied from interface:AssetsAPIGet the logs for the compute job with executionId and serviceAgreementId- Specified by:
getComputeLogsin interfaceAssetsAPI- Parameters:
serviceAgreementId- The service agreement id for the compute serviceexecutionId- The execution id of the compute jobconsumerAddress- The address of the consumer that executed the compute job- Returns:
- a list of compute logs
- Throws:
ServiceException- ServiceException
-
getComputeStatus
public ComputeStatus getComputeStatus(String serviceAgreementId, String executionId, String consumerAddress, ProviderConfig providerConfig) throws ServiceException
Description copied from interface:AssetsAPIGet the status for the compute job with executionId and serviceAgreementId- Specified by:
getComputeStatusin interfaceAssetsAPI- Parameters:
serviceAgreementId- The service agreement id for the compute serviceexecutionId- The execution id of the compute jobconsumerAddress- The address of the consumer that executed the compute job- Returns:
- The current status of the compute job
- Throws:
ServiceException- ServiceException
-
resolve
public DDO resolve(DID did) throws DDOException
Description copied from interface:AssetsAPIGets a DDO from a DID- Specified by:
resolvein interfaceAssetsAPI- Parameters:
did- the DID to resolve- Returns:
- an instance of the DDO represented by the DID
- Throws:
DDOException- DDOException
-
getMetadataFiles
public List<AssetMetadata.File> getMetadataFiles(DID did) throws DDOException
Description copied from interface:AssetsAPIGets the list of the files that belongs to a DDO- Specified by:
getMetadataFilesin interfaceAssetsAPI- Parameters:
did- the DID to resolve- Returns:
- a list of the Files
- Throws:
DDOException- EncryptionException
-
search
public SearchResult search(String text) throws DDOException
Description copied from interface:AssetsAPIGets all the DDO that match the search criteria- Specified by:
searchin interfaceAssetsAPI- Parameters:
text- the criteria- Returns:
- a List with all the DDOs found
- Throws:
DDOException- DDOException
-
search
public SearchResult search(String text, int offset, int page) throws DDOException
Description copied from interface:AssetsAPIGets all the DDOs that match the search criteria- Specified by:
searchin interfaceAssetsAPI- Parameters:
text- the criteriaoffset- parameter to paginatepage- parameter to paginate- Returns:
- a List with all the DDOs found
- Throws:
DDOException- DDOException
-
query
public SearchResult query(Map<String,Object> params, int offset, int page, int sort) throws DDOException
Description copied from interface:AssetsAPIGets all the DDOs that match the parameters of the query- Specified by:
queryin interfaceAssetsAPI- Parameters:
params- the criteriaoffset- parameter to paginatepage- parameter to paginatesort- parameter to sort- Returns:
- a List with all the DDOs found
- Throws:
DDOException- DDOException
-
query
public SearchResult query(Map<String,Object> params) throws DDOException
Description copied from interface:AssetsAPIGets all the DDOs that match the parameters of the query- Specified by:
queryin interfaceAssetsAPI- Parameters:
params- the criteria- Returns:
- a List with all the DDOs found
- Throws:
DDOException- DDOException
-
consume
public Boolean consume(String serviceAgreementId, DID did, int serviceDefinitionId, String basePath) throws ConsumeServiceException
Description copied from interface:AssetsAPIDownloads an Asset previously ordered through a Service Agreement- Specified by:
consumein interfaceAssetsAPI- Parameters:
serviceAgreementId- the service agreement id of the assetdid- the didserviceDefinitionId- the service definition idbasePath- the path where the asset will be downloaded- Returns:
- a flag that indicates if the consume flow was executed correctly
- Throws:
ConsumeServiceException- ConsumeServiceException
-
consume
public Boolean consume(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex, String basePath) throws ConsumeServiceException
Description copied from interface:AssetsAPIDownloads an Asset previously ordered through a Service Agreement- Specified by:
consumein interfaceAssetsAPI- Parameters:
serviceAgreementId- the service agreement id of the assetdid- the didserviceDefinitionId- the service definition idfileIndex- index id of the file to consumebasePath- the path where the asset will be downloaded- Returns:
- a flag that indicates if the consume flow was executed correctly
- Throws:
ConsumeServiceException- ConsumeServiceException
-
consumeBinary
public InputStream consumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId) throws ConsumeServiceException
Description copied from interface:AssetsAPIGets the input stream of one file of the asset- Specified by:
consumeBinaryin interfaceAssetsAPI- Parameters:
serviceAgreementId- the service agreement id of the assetdid- the didserviceDefinitionId- the service definition id- Returns:
- the input stream wit the binary content of the file
- Throws:
ConsumeServiceException- ConsumeServiceException
-
consumeBinary
public InputStream consumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex) throws ConsumeServiceException
Description copied from interface:AssetsAPIGets the input stream of one file of the asset- Specified by:
consumeBinaryin interfaceAssetsAPI- Parameters:
serviceAgreementId- the service agreement id of the assetdid- the didserviceDefinitionId- the service definition idfileIndex- the index of the file- Returns:
- the input stream wit the binary content of the file
- Throws:
ConsumeServiceException- ConsumeServiceException
-
consumeBinary
public InputStream consumeBinary(String serviceAgreementId, DID did, int serviceDefinitionId, int fileIndex, int rangeStart, int rangeEnd) throws ConsumeServiceException
Description copied from interface:AssetsAPIGets a range of bytes of the input stream of one file of the asset- Specified by:
consumeBinaryin interfaceAssetsAPI- Parameters:
serviceAgreementId- the service agreement id of the assetdid- the didserviceDefinitionId- the service definition idfileIndex- the index of the filerangeStart- the start of the bytes rangerangeEnd- the end of the bytes range- Returns:
- the input stream wit the binary content of the specified range
- Throws:
ConsumeServiceException- ConsumeServiceException
-
ownerDownload
public Boolean ownerDownload(DID did, int serviceIndex, String basePath) throws ServiceException, ConsumeServiceException
Description copied from interface:AssetsAPIPurchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer- Specified by:
ownerDownloadin interfaceAssetsAPI- Parameters:
did- the did of the DDOserviceIndex- the service definition idbasePath- the path where the asset will be downloaded- Returns:
- true if asset was downloaded correctly
- Throws:
ServiceException- ServiceExceptionConsumeServiceException- ConsumeServiceException
-
ownerDownload
public Boolean ownerDownload(DID did, int serviceIndex, String basePath, int fileIndex) throws ServiceException, ConsumeServiceException
-
order
public io.reactivex.Flowable<OrderResult> order(DID did, int serviceDefinitionId) throws OrderException
Description copied from interface:AssetsAPIPurchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer- Specified by:
orderin interfaceAssetsAPI- Parameters:
did- the did of the DDOserviceDefinitionId- the service definition id- Returns:
- a Flowable instance over an OrderResult to get the result of the flow in an asynchronous fashion
- Throws:
OrderException- OrderException
-
orderDirect
public OrderResult orderDirect(DID did) throws OrderException, ServiceException, EscrowRewardException
Description copied from interface:AssetsAPIPurchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer- Specified by:
orderDirectin interfaceAssetsAPI- Parameters:
did- the did of the DDO- Returns:
- OrderResult
- Throws:
OrderException- OrderExceptionServiceException- ServiceExceptionEscrowRewardException- EscrowRewardException
-
orderDirect
public OrderResult orderDirect(DID did, Service.ServiceTypes serviceTypes) throws OrderException, ServiceException, EscrowRewardException
Description copied from interface:AssetsAPIPurchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer- Specified by:
orderDirectin interfaceAssetsAPI- Parameters:
did- the did of the DDOserviceTypes- service type to order- Returns:
- OrderResult
- Throws:
OrderException- OrderExceptionServiceException- ServiceExceptionEscrowRewardException- EscrowRewardException
-
orderDirect
public OrderResult orderDirect(DID did, int serviceDefinitionId, Service.ServiceTypes serviceTypes) throws OrderException, ServiceException, EscrowRewardException
Description copied from interface:AssetsAPIPurchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer- Specified by:
orderDirectin interfaceAssetsAPI- Parameters:
did- the did of the DDOserviceDefinitionId- the service definition idserviceTypes- service type to order- Returns:
- OrderResult
- Throws:
OrderException- OrderExceptionServiceException- ServiceExceptionEscrowRewardException- EscrowRewardException
-
orderDirect
public OrderResult orderDirect(DID did, int serviceDefinitionId) throws OrderException, ServiceException, EscrowRewardException
Description copied from interface:AssetsAPIPurchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer- Specified by:
orderDirectin interfaceAssetsAPI- Parameters:
did- the did of the DDOserviceDefinitionId- the service definition id- Returns:
- OrderResult
- Throws:
OrderException- OrderExceptionServiceException- ServiceExceptionEscrowRewardException- EscrowRewardException
-
retire
public Boolean retire(DID did) throws DDOException
Description copied from interface:AssetsAPIRetire this did of Metadata- Specified by:
retirein interfaceAssetsAPI- Parameters:
did- the did- Returns:
- a flag that indicates if the action was executed correctly
- Throws:
DDOException- DDOException
-
ownerAssets
public List<DID> ownerAssets(String ownerAddress) throws ServiceException
Description copied from interface:AssetsAPIList of Asset objects published by ownerAddress- Specified by:
ownerAssetsin interfaceAssetsAPI- Parameters:
ownerAddress- ethereum address of owner/publisher- Returns:
- list of dids
- Throws:
ServiceException- ServiceException
-
consumerAssets
public List<DID> consumerAssets(String consumerAddress) throws ServiceException
Description copied from interface:AssetsAPIList of Asset objects purchased by consumerAddress- Specified by:
consumerAssetsin interfaceAssetsAPI- Parameters:
consumerAddress- ethereum address of consumer- Returns:
- list of dids
- Throws:
ServiceException- ServiceException
-
execute
public GatewayService.ServiceExecutionResult execute(String agreementId, DID did, int index, DID workflowDID) throws ServiceException
Description copied from interface:AssetsAPIExecutes a remote service associated with an asset and serviceAgreementId- Specified by:
executein interfaceAssetsAPI- Parameters:
agreementId- the agreement iddid- the didindex- the index of the serviceworkflowDID- the workflow did- Returns:
- an execution id
- Throws:
ServiceException- ServiceException
-
owner
public String owner(DID did) throws Exception
Description copied from interface:AssetsAPIReturn the owner of the asset.
-
validate
public Boolean validate(AssetMetadata metadata) throws DDOException
Description copied from interface:AssetsAPIValidate the asset metadata.- Specified by:
validatein interfaceAssetsAPI- Parameters:
metadata- the metadata of the DDO- Returns:
- a flag that indicates if the metadata is valid
- Throws:
DDOException- DDOException
-
transferOwnership
public Boolean transferOwnership(DID did, String newOwnerAddress) throws DDOException
Description copied from interface:AssetsAPIGiven a DID, transfer the ownership to a new owner. This function only will work if is called by the DID owner.- Specified by:
transferOwnershipin interfaceAssetsAPI- Parameters:
did- the didnewOwnerAddress- the address of the new ownership- Returns:
- a flag that indicates if the action was executed correctly
- Throws:
DDOException- DDOException
-
delegatePermissions
public Boolean delegatePermissions(DID did, String subjectAddress) throws DDOException
Description copied from interface:AssetsAPIFor a existing asset, the owner of the asset delegate to a subject read or access permiss- Specified by:
delegatePermissionsin interfaceAssetsAPI- Parameters:
did- the didsubjectAddress- the address we want to delegate to- Returns:
- a flag that indicates if the action was executed correctly
- Throws:
DDOException- DDOException
-
revokePermissions
public Boolean revokePermissions(DID did, String subjectAddress) throws DDOException
Description copied from interface:AssetsAPIFor a existing asset, the owner of the asset revoke the access grants of a subject.- Specified by:
revokePermissionsin interfaceAssetsAPI- Parameters:
did- the didsubjectAddress- the address we want to revoke to- Returns:
- a flag that indicates if the action was executed correctly
- Throws:
DDOException- DDOException
-
getPermissions
public Boolean getPermissions(DID did, String subjectAddress) throws DDOException
Description copied from interface:AssetsAPICheck if an user has permissions in a specific DID- Specified by:
getPermissionsin interfaceAssetsAPI- Parameters:
did- the didsubjectAddress- the address- Returns:
- a flag that indicates if the subject address has permissions
- Throws:
DDOException- DDOException
-
-