Package com.orchestranetworks.addon.dama.ext.drivemanager


package com.orchestranetworks.addon.dama.ext.drivemanager

Provides the interface to perform actions on digital assets contained in a drive.

  1. Get an instance of DriveManager:

            //Provide DriveContext with the information referring to a specific drive.
            DriveContext driveContext = new DriveContext(
                    this.userDataset,
                    this.table,
                    this.mediaPath,
                    this.session);
    
            DriveFactory driveFactory = DriveFactoryProvider.getDriveFactory();
            DriveManager driveManager = driveFactory.getDriveManager(driveContext);
    
  2. Actions: create, update, delete and download digital asset:

            //Create a new DigitalAsset
            File uploadFile = new File("sampleFile.png");
            FileResource fileResource = new FileResource(uploadFile);
            DigitalAssetSpec digitalAssetSpec = new DigitalAssetSpec(fileResource);
            digitalAssetSpec.setLabel(UserMessage.createInfo("new label"));
            digitalAssetSpec.setDescription(UserMessage.createInfo("new description"));
            DigitalAsset newAsset = driveManager.create(digitalAssetSpec);
    
            //Update a digital asset
            newAsset.setState(DigitalAssetState.DEACTIVATED);
            newAsset.setLabel(UserMessage.createInfo("updated label"));
            newAsset.setDescription(UserMessage.createInfo("updated label"));
            driveManager.update(newAsset);
    
            //Delete a digital asset
            driveManager.delete(newAsset.getKey());
    
            //Download asset - current version of asset
            MediaContent mediaContent = driveManager.getMediaContent(newAsset);
            mediaContent.getInputStream();
            mediaContent.getContentLength();
    
  3. Actions: create, update, delete and download digital asset version:

            //Create a new version for a digital asset
            DigitalAssetKey assetKey = new DigitalAssetKey(PrimaryKey.parseString("assetKey"));
            File uploadFile = new File("sampleFile.png");
            FileResource fileResource = new FileResource(uploadFile);
            DigitalAssetVersionSpec versionSpec = new DigitalAssetVersionSpec(assetKey, fileResource);
            versionSpec.setCurrentVersion(true);
            versionSpec.setComment("comment");
            versionSpec.setVersionName("versionName");
            DigitalAssetVersion newVersion = driveManager.create(versionSpec);
    
            //Update a version
            newVersion.setComment("new comment");
            newVersion.setVersionName("new version name");
            driveManager.update(newVersion);
    
            //Delete a version
            driveManager.delete(newVersion.getKey());
    
            //Download version
            MediaContent mediaContent = driveManager.getMediaContent(newVersion);
            mediaContent.getInputStream();
            mediaContent.getContentLength();
    
  4. Browsing digital assets in a drive:

            //Create a new instance of SearchFilter to search digital asset
            SearchFilter searchFilter = new SearchFilter();
            searchFilter.setKeyword("anAssetName");
            searchFilter.setExtension("png");
            searchFilter.setType("image");
    
            //Filter by creation and updated DateRange
            DateRange creationDateRange = new DateRange();
            DateRange updatedDateRange = new DateRange();
            searchFilter.setCreationDateRange(creationDateRange);
            searchFilter.setUpdateDateRange(updatedDateRange);
    
            //Filter by tags
            List<String> tags = new ArrayList<String>();
            tags.add("tag");
            searchFilter.setTags(tags);
    
            //Result of filter will be sorted by SortBy
            SortCriteria creationDateSort = new SortCriteria(SortBy.CREATION_DATE, true);
            SortCriteria physicalNameSort = new SortCriteria(SortBy.PHYSICAL_NAME, true);
            List<SortCriteria> sortCriterias = new ArrayList<SortCriteria>();
            sortCriterias.add(physicalNameSort);
            sortCriterias.add(creationDateSort);
            searchFilter.setSortCriterias(sortCriterias);
    
            //Search digital asset by 'searchFilter'
            List<DigitalAsset> digitalAssets = driveManager.search(searchFilter);
    
            //Get all active digital assets in Drive
            List<DigitalAsset> digitalAssetsInDrive = driveManager.getDigitalAssets();
    
            //Look up asset by DigitalAssetKey
            DigitalAssetKey assetKey = new DigitalAssetKey(PrimaryKey.parseString("assetKey"));
            DigitalAsset digitalAsset = driveManager.getDigitalAsset(assetKey);