Class AssetsImpl

  • All Implemented Interfaces:
    AssetsAPI

    public class AssetsImpl
    extends Object
    implements AssetsAPI
    Implementation of AssetsAPI
    • Constructor Detail

      • AssetsImpl

        public AssetsImpl​(NeverminedManager neverminedManager,
                          AssetsManager assetsManager,
                          AgreementsManager agreementsManager)
        Constructor
        Parameters:
        neverminedManager - the neverminedManager
        assetsManager - the assetsManager
        agreementsManager - the agreements Manager
    • Method Detail

      • create

        public DDO create​(AssetMetadata metadata,
                          ProviderConfig providerConfig,
                          AuthConfig authConfig)
                   throws DDOException
        Description copied from interface: AssetsAPI
        Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata
        Specified by:
        create in interface AssetsAPI
        Parameters:
        metadata - the metadata of the DDO
        providerConfig - the endpoints of the DDO's services
        authConfig - 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: AssetsAPI
        Creates a new DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata
        Specified by:
        create in interface AssetsAPI
        Parameters:
        metadata - the metadata of the DDO
        providerConfig - 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: AssetsAPI
        Creates a new ComputingService DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata
        Specified by:
        createComputeService in interface AssetsAPI
        Parameters:
        metadata - the metadata of the DDO
        providerConfig - 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: AssetsAPI
        Creates a new ComputingService DDO, registering it on-chain through DidRegistry contract and off-chain in Metadata
        Specified by:
        createComputeService in interface AssetsAPI
        Parameters:
        metadata - the metadata of the DDO
        providerConfig - the endpoints of the DDO's services
        computingProvider - 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: AssetsAPI
        Get the logs for the compute job with executionId and serviceAgreementId
        Specified by:
        getComputeLogs in interface AssetsAPI
        Parameters:
        serviceAgreementId - The service agreement id for the compute service
        executionId - The execution id of the compute job
        consumerAddress - 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: AssetsAPI
        Get the status for the compute job with executionId and serviceAgreementId
        Specified by:
        getComputeStatus in interface AssetsAPI
        Parameters:
        serviceAgreementId - The service agreement id for the compute service
        executionId - The execution id of the compute job
        consumerAddress - 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: AssetsAPI
        Gets a DDO from a DID
        Specified by:
        resolve in interface AssetsAPI
        Parameters:
        did - the DID to resolve
        Returns:
        an instance of the DDO represented by the DID
        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 interface AssetsAPI
        Parameters:
        text - the criteria
        offset - parameter to paginate
        page - 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 interface AssetsAPI
        Parameters:
        params - the criteria
        offset - parameter to paginate
        page - parameter to paginate
        sort - parameter to sort
        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: AssetsAPI
        Downloads an Asset previously ordered through a Service Agreement
        Specified by:
        consume in interface AssetsAPI
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        basePath - 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: AssetsAPI
        Downloads an Asset previously ordered through a Service Agreement
        Specified by:
        consume in interface AssetsAPI
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        fileIndex - index id of the file to consume
        basePath - 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: AssetsAPI
        Gets the input stream of one file of the asset
        Specified by:
        consumeBinary in interface AssetsAPI
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - 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: AssetsAPI
        Gets the input stream of one file of the asset
        Specified by:
        consumeBinary in interface AssetsAPI
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        fileIndex - 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: AssetsAPI
        Gets a range of bytes of the input stream of one file of the asset
        Specified by:
        consumeBinary in interface AssetsAPI
        Parameters:
        serviceAgreementId - the service agreement id of the asset
        did - the did
        serviceDefinitionId - the service definition id
        fileIndex - the index of the file
        rangeStart - the start of the bytes range
        rangeEnd - 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: AssetsAPI
        Purchases an Asset represented by a DID. It implies to initialize a Service Agreement between publisher and consumer
        Specified by:
        ownerDownload in interface AssetsAPI
        Parameters:
        did - the did of the DDO
        serviceIndex - the service definition id
        basePath - the path where the asset will be downloaded
        Returns:
        true if asset was downloaded correctly
        Throws:
        ServiceException - ServiceException
        ConsumeServiceException - ConsumeServiceException
      • order

        public io.reactivex.Flowable<OrderResult> order​(DID did,
                                                        int 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 interface AssetsAPI
        Parameters:
        did - the did of the DDO
        serviceDefinitionId - 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 Metadata
        Specified by:
        retire in interface AssetsAPI
        Parameters:
        did - the did
        Returns:
        a flag that indicates if the action was executed correctly
        Throws:
        DDOException - DDOException
      • owner

        public String owner​(DID did)
                     throws Exception
        Description copied from interface: AssetsAPI
        Return the owner of the asset.
        Specified by:
        owner in interface AssetsAPI
        Parameters:
        did - the did
        Returns:
        the ethereum address of the owner/publisher of given asset did
        Throws:
        Exception - Exception
      • transferOwnership

        public Boolean transferOwnership​(DID did,
                                         String newOwnerAddress)
                                  throws DDOException
        Description copied from interface: AssetsAPI
        Given a DID, transfer the ownership to a new owner. This function only will work if is called by the DID owner.
        Specified by:
        transferOwnership in interface AssetsAPI
        Parameters:
        did - the did
        newOwnerAddress - 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: AssetsAPI
        For a existing asset, the owner of the asset delegate to a subject read or access permiss
        Specified by:
        delegatePermissions in interface AssetsAPI
        Parameters:
        did - the did
        subjectAddress - 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: AssetsAPI
        For a existing asset, the owner of the asset revoke the access grants of a subject.
        Specified by:
        revokePermissions in interface AssetsAPI
        Parameters:
        did - the did
        subjectAddress - 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: AssetsAPI
        Check if an user has permissions in a specific DID
        Specified by:
        getPermissions in interface AssetsAPI
        Parameters:
        did - the did
        subjectAddress - the address
        Returns:
        a flag that indicates if the subject address has permissions
        Throws:
        DDOException - DDOException