Package com.oceanprotocol.squid.api.impl
Class AssetsImpl
- java.lang.Object
-
- com.oceanprotocol.squid.api.impl.AssetsImpl
-
-
Field Summary
Fields Modifier and Type Field Description private AssetsManager
assetsManager
private static int
DEFAULT_OFFSET
private static int
DEFAULT_PAGE
private OceanManager
oceanManager
-
Constructor Summary
Constructors Constructor Description AssetsImpl(OceanManager oceanManager, AssetsManager assetsManager)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Boolean
consume(String serviceAgreementId, DID did, String serviceDefinitionId, Integer index, String basePath)
Downloads a single file of an Asset previously ordered through a Service AgreementBoolean
consume(String serviceAgreementId, DID did, String serviceDefinitionId, Integer index, String basePath, int threshold)
Downloads a single file of an Asset previously ordered through a Service AgreementBoolean
consume(String serviceAgreementId, DID did, String serviceDefinitionId, String basePath)
Downloads an Asset previously ordered through a Service AgreementBoolean
consume(String serviceAgreementId, DID did, String serviceDefinitionId, String basePath, int threshold)
Downloads an Asset previously ordered through a Service AgreementInputStream
consumeBinary(String serviceAgreementId, DID did, String serviceDefinitionId, Integer index)
Gets the input stream of one file of the assetInputStream
consumeBinary(String serviceAgreementId, DID did, String serviceDefinitionId, Integer index, int threshold)
Gets the input stream of one file of the assetInputStream
consumeBinary(String serviceAgreementId, DID did, String serviceDefinitionId, Integer index, Integer rangeStart, Integer rangeEnd)
Gets a range of bytes of the input stream of one file of the assetInputStream
consumeBinary(String serviceAgreementId, DID did, String serviceDefinitionId, Integer index, Integer rangeStart, Integer rangeEnd, int threshold)
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 consumerAddressDDO
create(AssetMetadata metadata, ProviderConfig providerConfig)
Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in AquariusDDO
create(AssetMetadata metadata, ProviderConfig providerConfig, int threshold)
Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in AquariusList<AssetMetadata.File>
getMetadataFiles(DID did)
Gets the list of the files that belongs to a DDOio.reactivex.Flowable<OrderResult>
order(DID did, String serviceDefinitionId)
Purchases an Asset represented by a DID.String
owner(DID did)
Return the owner of the asset.List<DID>
ownerAssets(String ownerAddress)
List of Asset objects published by ownerAddressSearchResult
query(Map<String,Object> params)
Gets all the DDOs that match the parameters of the querySearchResult
query(Map<String,Object> params, int offset, int page, int sort)
Gets all the DDOs that match the parameters of the queryDDO
resolve(DID did)
Gets a DDO from a DIDBoolean
retire(DID did)
Retire this did of AquariusSearchResult
search(String text)
Gets all the DDO that match the search criteriaSearchResult
search(String text, int offset, int page)
Gets all the DDOs that match the search criteriaBoolean
validate(AssetMetadata metadata)
Validate the asset metadata.
-
-
-
Field Detail
-
oceanManager
private OceanManager oceanManager
-
assetsManager
private AssetsManager assetsManager
-
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(OceanManager oceanManager, AssetsManager assetsManager)
Constructor- Parameters:
oceanManager
- the oceanManagerassetsManager
- the assetsManager
-
-
Method Detail
-
create
public DDO create(AssetMetadata metadata, ProviderConfig providerConfig, int threshold) throws DDOException
Description copied from interface:AssetsAPI
Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in Aquarius- Specified by:
create
in interfaceAssetsAPI
- Parameters:
metadata
- the metadata of the DDOproviderConfig
- the endpoints of the DDO's servicesthreshold
- the secret store threshold- Returns:
- an instance of the DDO created
- Throws:
DDOException
- DDOException
-
create
public DDO create(AssetMetadata metadata, ProviderConfig providerConfig) throws DDOException
Description copied from interface:AssetsAPI
Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in Aquarius- Specified by:
create
in 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
-
resolve
public DDO resolve(DID did) throws EthereumException, DDOException
Description copied from interface:AssetsAPI
Gets a DDO from a DID- Specified by:
resolve
in interfaceAssetsAPI
- Parameters:
did
- the DID to resolve- Returns:
- an instance of the DDO represented by the DID
- Throws:
EthereumException
- EthereumExceptionDDOException
- DDOException
-
getMetadataFiles
public List<AssetMetadata.File> getMetadataFiles(DID did) throws DDOException
Description copied from interface:AssetsAPI
Gets the list of the files that belongs to a DDO- Specified by:
getMetadataFiles
in 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:AssetsAPI
Gets all the DDO that match the search criteria- Specified by:
search
in 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:AssetsAPI
Gets all the DDOs that match the search criteria- Specified by:
search
in 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:AssetsAPI
Gets all the DDOs that match the parameters of the query- Specified by:
query
in 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:AssetsAPI
Gets all the DDOs that match the parameters of the query- Specified by:
query
in interfaceAssetsAPI
- Parameters:
params
- the criteria- Returns:
- a List with all the DDOs found
- Throws:
DDOException
- DDOException
-
consume
public Boolean consume(String serviceAgreementId, DID did, String serviceDefinitionId, String basePath, int threshold) throws ConsumeServiceException
Description copied from interface:AssetsAPI
Downloads an Asset previously ordered through a Service Agreement- Specified by:
consume
in interfaceAssetsAPI
- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idbasePath
- the path where the asset will be downloadedthreshold
- secret store threshold to decrypt the urls of the asset- Returns:
- a flag that indicates if the consume flow was executed correctly
- Throws:
ConsumeServiceException
- ConsumeServiceException
-
consume
public Boolean consume(String serviceAgreementId, DID did, String serviceDefinitionId, String basePath) throws ConsumeServiceException
Description copied from interface:AssetsAPI
Downloads an Asset previously ordered through a Service Agreement- Specified by:
consume
in 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, String serviceDefinitionId, Integer index, String basePath) throws ConsumeServiceException
Description copied from interface:AssetsAPI
Downloads a single file of an Asset previously ordered through a Service Agreement- Specified by:
consume
in interfaceAssetsAPI
- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idindex
- of the file inside the files definition in metadatabasePath
- 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, String serviceDefinitionId, Integer index, String basePath, int threshold) throws ConsumeServiceException
Description copied from interface:AssetsAPI
Downloads a single file of an Asset previously ordered through a Service Agreement- Specified by:
consume
in interfaceAssetsAPI
- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idindex
- of the file inside the files definition in metadatabasePath
- the path where the asset will be downloadedthreshold
- secret store threshold to decrypt the urls of the asset- Returns:
- a flag that indicates if the consume flow was executed correctly
- Throws:
ConsumeServiceException
- ConsumeServiceException
-
consumeBinary
public InputStream consumeBinary(String serviceAgreementId, DID did, String serviceDefinitionId, Integer index) throws ConsumeServiceException
Description copied from interface:AssetsAPI
Gets the input stream of one file of the asset- Specified by:
consumeBinary
in interfaceAssetsAPI
- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idindex
- 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, String serviceDefinitionId, Integer index, int threshold) throws ConsumeServiceException
Description copied from interface:AssetsAPI
Gets the input stream of one file of the asset- Specified by:
consumeBinary
in interfaceAssetsAPI
- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idindex
- the index of the filethreshold
- secret store threshold to decrypt the urls of the asset- Returns:
- the input stream wit the binary content of the file
- Throws:
ConsumeServiceException
- ConsumeServiceException
-
consumeBinary
public InputStream consumeBinary(String serviceAgreementId, DID did, String serviceDefinitionId, Integer index, Integer rangeStart, Integer rangeEnd) throws ConsumeServiceException
Description copied from interface:AssetsAPI
Gets a range of bytes of the input stream of one file of the asset- Specified by:
consumeBinary
in interfaceAssetsAPI
- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idindex
- 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
-
consumeBinary
public InputStream consumeBinary(String serviceAgreementId, DID did, String serviceDefinitionId, Integer index, Integer rangeStart, Integer rangeEnd, int threshold) throws ConsumeServiceException
Description copied from interface:AssetsAPI
Gets a range of bytes of the input stream of one file of the asset- Specified by:
consumeBinary
in interfaceAssetsAPI
- Parameters:
serviceAgreementId
- the service agreement id of the assetdid
- the didserviceDefinitionId
- the service definition idindex
- the index of the filerangeStart
- the start of the bytes rangerangeEnd
- the end of the bytes rangethreshold
- secret store threshold to decrypt the urls of the asset- Returns:
- the input stream wit the binary content of the specified range
- Throws:
ConsumeServiceException
- ConsumeServiceException
-
order
public io.reactivex.Flowable<OrderResult> order(DID did, String serviceDefinitionId) throws OrderException
Description copied from interface:AssetsAPI
Purchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer- Specified by:
order
in 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
-
retire
public Boolean retire(DID did) throws DDOException
Description copied from interface:AssetsAPI
Retire this did of Aquarius- Specified by:
retire
in 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:AssetsAPI
List of Asset objects published by ownerAddress- Specified by:
ownerAssets
in 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:AssetsAPI
List of Asset objects purchased by consumerAddress- Specified by:
consumerAssets
in interfaceAssetsAPI
- Parameters:
consumerAddress
- ethereum address of consumer- Returns:
- list of dids
- Throws:
ServiceException
- ServiceException
-
owner
public String owner(DID did) throws Exception
Description copied from interface:AssetsAPI
Return the owner of the asset.
-
validate
public Boolean validate(AssetMetadata metadata) throws DDOException
Description copied from interface:AssetsAPI
Validate the asset metadata.- Specified by:
validate
in interfaceAssetsAPI
- Parameters:
metadata
- the metadata of the DDO- Returns:
- a flag that indicates if the metadata is valid
- Throws:
DDOException
- DDOException
-
-