Package com.orchestranetworks.addon.dama.externalmanagement


package com.orchestranetworks.addon.dama.externalmanagement

Provides the API for a Drive that accesses an externally managed storage location.

Implementing a Drive that will access externally managed location that interacts with assets stored in an external location - External Google Manager

The example below is for a Drive that allows users to accesses assets located in externally managed storage. The storage could be cloud based or a location managed by a third-party tool. Your specific implementation requirements might require additional components not described below. The Developer Guide provides a high-level example of implementing a Drive that connects to a Google Drive.

  1. Implement ExternalManager:

    public class ExternalGoogleManager implements ExternalManager
    {
            public ExternalSearchAssetsResult searchAssets(ExternalSearchRequest searchRequest)
            {
                    ExternalSearchAssetsResult searchAssetsResult = new ExternalSearchAssetsResult();
                    SearchFilter searchFilter = searchRequest.getSearchFilter();
                    int pageIndex = searchRequest.getPageIndex();
                    int pageSize = searchRequest.getPageSize();
                    try
                    {
                            List<ExternalDigitalAsset> externalAssets = new ArrayList<>();
                            ExternalDigitalAsset externalAsset = new ExternalDigitalAsset();
                            externalAsset.setId("externalId");
                            externalAsset.setLabelDescription(this.getLabelDescription("label", searchRequest.getHome().getRepository().getLocales()));
                            externalAsset.setUrl("url");
                            externalAsset.setThumbnailUrl("thumbnailUrl");
                            externalAsset.setDownloadUrl("downloadUrl");
                            externalAsset.setExtension("extension");
                            externalAsset.setAssetType("assetType");
                            externalAsset.setPhysicalName("physicalName");
                            externalAsset.setWidth(new Integer(100));
                            externalAsset.setHeight(new Integer(100));
    
                            externalAssets.add(externalAsset);
                            searchAssetsResult.setAssets(externalAssets);
                    }
                    catch (Exception ex)
                    {
                            //Handle exception
                    }
    
                    return searchAssetsResult;
            }
    
            public ExternalDigitalAsset createAsset(ExternalUploadAssetRequest request)
            {
                    ExternalDigitalAsset externalDigitalAsset = new ExternalDigitalAsset();
                    externalDigitalAsset.setId("externalId");
                    externalDigitalAsset.setPhysicalName("physicalName");
                    externalDigitalAsset.setThumbnailUrl("thumbnailUrl");
                    externalDigitalAsset.setLabelDescription(this.getLabelDescription("label", request.getHome().getRepository().getLocales()));
                    
                    return externalDigitalAsset;
            }
    
            public ExternalDigitalAsset createAssetVersion(ExternalUploadResourceRequest request)
            {
                    ExternalDigitalAsset externalDigitalAsset = new ExternalDigitalAsset();
    
                    return externalDigitalAsset;
            }
    
            public OperationExecutionStatus updateAsset(
                    ExternalCommonRequest request,
                    ExternalDigitalAsset digitalAsset)
            {
                    OperationExecutionStatus operationExecutionStatus = new OperationExecutionStatus();
    
                    return operationExecutionStatus;
            }
    
            public OperationExecutionStatus updateAssetVersion(
                    ExternalCommonRequest request,
                    ExternalDigitalAsset digitalAssetVersion)
            {
                    OperationExecutionStatus operationExecutionStatus = new OperationExecutionStatus();
    
                    return operationExecutionStatus;
            }
    
            public OperationExecutionStatus deleteAsset(
                    ExternalSingularRequest request,
                    boolean isPhysicalDelete)
            {
                    OperationExecutionStatus operationExecutionStatus = new OperationExecutionStatus();
                    try
                    {
                            //Delete asset from 3rd party
                    }
                    catch (Exception ex)
                    {
                            operationExecutionStatus = new OperationExecutionStatus(
                                    new DAMException(ex.getMessage()));
                    }
    
                    return operationExecutionStatus;
            }
    
            public OperationExecutionStatus deleteAssetVersion(ExternalSingularRequest request)
            {
                    OperationExecutionStatus operationExecutionStatus = new OperationExecutionStatus();
                    try
                    {
                            //Delete asset version from 3rd party
                    }
                    catch (Exception ex)
                    {
                            operationExecutionStatus = new OperationExecutionStatus(
                                    new DAMException(ex.getMessage()));
                    }
    
                    return operationExecutionStatus;
            }
    
            public ExternalDigitalAsset getAsset(ExternalSingularRequest request) throws DAMException
            {
                    ExternalDigitalAsset externalDigitalAsset = new ExternalDigitalAsset();
                    try
                    {
                            externalDigitalAsset.setId(request.getExternalId());
                            externalDigitalAsset.setPhysicalName("physicalName");
                            externalDigitalAsset.setLabelDescription(this.getLabelDescription("label", request.getHome().getRepository().getLocales()));
                            externalDigitalAsset.setUrl("url");
                            externalDigitalAsset.setThumbnailUrl("thumbnailUrl");
                            externalDigitalAsset.setDownloadUrl("downloadUrl");
                            externalDigitalAsset.setAssetType("assetType");
                            externalDigitalAsset.setExtension("extension");
                            externalDigitalAsset.setWidth(new Integer(100));
                            externalDigitalAsset.setHeight(new Integer(100));
                    }
                    catch (Exception ex)
                    {
                            //Handle exception
                    }
    
                    return externalDigitalAsset;
            }
    
            public ExternalDigitalAssetVersionBean getAssetVersionByAssetId(
                    ExternalSingularRequest request)
            {
                    ExternalDigitalAsset externalDigitalAsset = new ExternalDigitalAsset();
                    ExternalDigitalAssetVersionBean externalDigitalAssetVersionBean;
                    try
                    {
                            externalDigitalAssetVersionBean = new ExternalDigitalAssetVersionBean(
                                    externalDigitalAsset);
                    }
                    catch (DAMException ex)
                    {
                            throw new RuntimeException(ex);
                    }
    
                    return externalDigitalAssetVersionBean;
            }
    
            public ExternalDigitalAsset getAssetVersion(ExternalSingularRequest request)
            {
                    ExternalDigitalAsset externalDigitalAsset = new ExternalDigitalAsset();
    
                    return externalDigitalAsset;
            }
    
            public MediaContent getMediaContentOfAsset(ExternalSingularRequest request)
            {
                    return null;
            }
    
            public MediaContent getMediaContentOfAssetVersion(ExternalSingularRequest request)
            {
                    return null;
            }
    
            public List<ExternalDigitalAsset> getAssets(ExternalPluralRequest assetRequest)
            {
                    List<ExternalDigitalAsset> externalDigitalAssets = new ArrayList<>();
                    for (String externalId : externalRequest.getExternalIds())
                    {
                            try
                            {
                                    ExternalDigitalAsset externalDigitalAsset = new ExternalDigitalAsset();
                                    externalDigitalAsset.setId(externalId);
                                    externalDigitalAsset.setPhysicalName("physicalName");
                                    externalDigitalAsset.setCreationDate(new Date());
                                    externalDigitalAsset.setLastUpdatedDate(new Date());
                                    externalDigitalAsset.setLabelDescription(this.getLabelDescription("label", assetRequest.getHome().getRepository().getLocales()));
                                    externalDigitalAsset.setUrl("url");
                                    externalDigitalAsset.setThumbnailUrl("thumbnailUrl");
                                    externalDigitalAsset.setWidth(new Integer(100));
                                    externalDigitalAsset.setHeight(new Integer(100));
                                    externalDigitalAsset.setDownloadUrl("downloadUrl");
                                    externalDigitalAsset.setAssetType("assetType");
                                    externalDigitalAsset.setExtension("extension");
    
                                    Map<String, String> metaDatas = new HashMap<>();
                                    metaDatas.put("metadata1", "metadata1");
                                    metaDatas.put("metadata2", "metadata2");
                                    externalDigitalAsset.setMetaDatas(metaDatas);
    
                                    externalDigitalAsset.setTags(Arrays.asList("tag1", "tag2"));
    
                                    externalDigitalAssets.add(externalDigitalAsset);
                            }
                            catch (Exception ex)
                            {
                                    //Handle exception
                            }
                    }
    
                    return externalDigitalAssets;
            }
    
            public ExternalTagResult getTags(ExternalCommonRequest request)
            {
                    ExternalTagResult externalTagResult = new ExternalTagResult();
    
                    Tag tag1 = new Tag();
                    tag1.setCode("tag1");
                    tag1.setFontSize("14");
                    externalTagResult.getTags().add(tag1);
    
                    Tag tag2 = new Tag();
                    tag2.setCode("tag2");
                    tag2.setFontSize("16");
                    externalTagResult.getTags().add(tag2);
    
                    return externalTagResult;
            }
            
            private LabelDescription getLabelDescription(String name, List<Locale> locales)
            {
                    if (AddonStringUtils.isEmpty(name))
                    {
                            name = "";
                    }
    
                    List<LabelDescriptionForLocale> labelDescriptionForLocales = new ArrayList<>();
                    for (Locale locale : locales)
                    {
                            LabelDescriptionForLocale labelDescriptionLocale = new LabelDescriptionForLocale();
                            labelDescriptionLocale.setLocale(locale);
                            labelDescriptionLocale.setLabel(name);
                            labelDescriptionLocale.setDescription(name);
                            labelDescriptionForLocales.add(labelDescriptionLocale);
                    }
    
                    LabelDescription labelDescription = new LabelDescription();
                    labelDescription.setLocalizedDocumentations(labelDescriptionForLocales);
    
                    return labelDescription;
            }
    }
    
  2. Implement ExternalManagerDefinition:

    public final class ExternalGoogleManagerDefinition implements ExternalManagerDefinition
    {
            public ExternalManager getExternalManager()
            {
                    return new ExternalGoogleManager();
            }
    }
    
  3. Register a new ExternalManagerDefinition for the ExternalManager

            //Register by handling ExternalManagerDefinition on Repository start or by user-run service 
            ExternalManagerCatalog.add(new ExternalGoogleManagerDefinition());
    
  4. Create a new Drive connecting to a third party storage.

    Whenever creating a new Drive, set Drive type as External management and choose External management class, which refers to the ExternalGoogleManagerDefinition above.  
    
  5. Create a new D.A.C. connecting to an external management Drive.

    Create a new D.A.C. with the above Drive.