Class AssetsManager


  • public class AssetsManager
    extends BaseManager
    Manages the functionality related with Assets
    • Constructor Detail

      • AssetsManager

        public AssetsManager​(io.keyko.common.web3.KeeperService keeperService,
                             MetadataApiService metadataApiService)
    • Method Detail

      • getInstance

        public static AssetsManager getInstance​(io.keyko.common.web3.KeeperService keeperService,
                                                MetadataApiService metadataApiService)
        Gets an instance of AssetManager
        Parameters:
        keeperService - instance of keeperService
        metadataApiService - instance of MetadataApiService
        Returns:
        an initialized instance of AssetManager
      • publishMetadata

        public DDO publishMetadata​(DDO ddo)
                            throws Exception
        Publishes in Metadata Api the metadata of a DDO
        Parameters:
        ddo - the DDO to publish
        Returns:
        the published DDO
        Throws:
        Exception - if Metadata Api service fails publishing the DDO
      • getByDID

        public DDO getByDID​(String id)
                     throws Exception
        Gets a DDO from the DID
        Parameters:
        id - the did of the DDO
        Returns:
        an instance of the DDO represented by the DID
        Throws:
        Exception - if Metadata Api service fails publishing the metadata
      • updateMetadata

        public boolean updateMetadata​(String id,
                                      DDO ddo)
                               throws Exception
        Updates the metadata of a DDO
        Parameters:
        id - the did of the DDO
        ddo - the DDO
        Returns:
        A flag that indicates if the update was executed correctly
        Throws:
        Exception - if Metadata Api service fails updating the metadata
      • searchAssets

        public SearchResult searchAssets​(String text,
                                         int offset,
                                         int page)
                                  throws DDOException
        Gets all the DDOs that match the search criteria
        Parameters:
        text - contains the criteria
        offset - parameter to paginate the results
        page - parameter to paginate the results
        Returns:
        SearchResult including the list of DDOs
        Throws:
        DDOException - if Aquairus fails searching the assets
      • searchAssets

        public SearchResult searchAssets​(Map<String,​Object> params,
                                         int offset,
                                         int page,
                                         int sort)
                                  throws DDOException
        Gets all the DDOs that match the parameters of the query
        Parameters:
        params - contains the criteria
        offset - parameter to paginate the results
        page - parameter to paginate the results
        sort - parameter to sort the results
        Returns:
        a List with all the DDOs found
        Throws:
        DDOException - if Aquairus fails searching the assets
      • deleteAsset

        public Boolean deleteAsset​(DID did)
                            throws DDOException
        Retire the asset ddo from Metadata Api.
        Parameters:
        did - the did
        Returns:
        a flag that indicates if the retire operation was executed correctly
        Throws:
        DDOException - DDOException
      • validateMetadata

        public Boolean validateMetadata​(AssetMetadata metadata)
                                 throws DDOException
        Check that the metadata has a valid formUrl.
        Parameters:
        metadata - the metadata of the DDO
        Returns:
        a flag that indicates if the metadata is valid
        Throws:
        DDOException - DDOException
      • getDIDOwner

        public String getDIDOwner​(DID did)
                           throws Exception
        Get the owner of a did already registered.
        Parameters:
        did - the did
        Returns:
        owner address
        Throws:
        Exception - Exception
      • getOwnerAssets

        public List<DID> getOwnerAssets​(String ownerAddress)
                                 throws ServiceException
        List of Asset objects published by ownerAddress
        Parameters:
        ownerAddress - ethereum address of owner/publisher
        Returns:
        list of dids
        Throws:
        ServiceException - ServiceException
      • transferOwnership

        public Boolean transferOwnership​(DID did,
                                         String newOwnerAddress)
                                  throws DDOException
        Transfer the ownsership of a DID
        Parameters:
        did - the did
        newOwnerAddress - the address of the new owner
        Returns:
        a flag indicates if the operation has been executed correctly
        Throws:
        DDOException - DDOException
      • revokePermission

        public Boolean revokePermission​(DID did,
                                        String subjectAddress)
                                 throws DDOException
        revoke the permission over an DID for a subject address
        Parameters:
        did - the did
        subjectAddress - the address
        Returns:
        a flag indicates if the operation has been executed correctly
        Throws:
        DDOException - DDOException