info.magnolia.dam.setup.migration
Class ChangeDataDmsReferenceToDamMigrationTask

java.lang.Object
  extended by info.magnolia.module.delta.AbstractTask
      extended by info.magnolia.module.delta.AbstractRepositoryTask
          extended by info.magnolia.dam.setup.migration.ChangeDataDmsReferenceToDamMigrationTask
All Implemented Interfaces:
info.magnolia.module.delta.Task

public class ChangeDataDmsReferenceToDamMigrationTask
extends info.magnolia.module.delta.AbstractRepositoryTask

This task is responsible for changing the old DMS/Data/... references to DAM references.
Steps:

 Iterate the list of contentPathsList,
  Perform a JCR query that search for properties named 'imgUUID' and return the related node.
  Iterate the query result list
  For every Node,
   If the identifier exist in the dam repository as an Asset.
    Transform the identifier as an Asset composite id (assetProviderId:AssetIdentifier)
    Update the 'img' link to the corresponding path.
   Else
    Remove the property.
 
 Normal handling:
 Move from:
  property sv:name="img" sv:type="String"
  value = /demo-project/img/bk/Stage/v-light-4
  property sv:name="imgUUID" sv:type="String"
  value = 4c291aa5-9807-4bbe-b372-ce523f82e600
 To:
  property sv:name="imgUUID" sv:type="String"
  value = jcr:4c291aa5-9807-4bbe-b372-ce523f82e600
 
 OR
 Move from:
  property sv:name="img" sv:type="String"
  value = dms
  property sv:name="imgUUID" sv:type="String"
  value = 4c291aa5-9807-4bbe-b372-ce523f82e600
 To:
  property sv:name="img" sv:type="String"
  value = jcr:4c291aa5-9807-4bbe-b372-ce523f82e600
 
 Specific handling:
  In case of the UUID does not exist any more, remove properties.
 


Field Summary
 
Fields inherited from class info.magnolia.module.delta.AbstractTask
DO_NOTHING
 
Constructor Summary
ChangeDataDmsReferenceToDamMigrationTask(String taskName, String taskDescription, String contentRepository, List<String> contentPathsList, String identifierPropertyName, String pathPropertyName)
          Default constructor.
 
Method Summary
 void doExecute(info.magnolia.module.InstallContext ctx)
           
protected  void handleDataReference(javax.jcr.Property identifierProperty, javax.jcr.Property pathProperty, javax.jcr.Node assetNode, String compositeId)
          Set the composite id to the identifierProperty (imgUUID) value.
protected  void handleDmsReference(javax.jcr.Property identifierProperty, javax.jcr.Property pathProperty, javax.jcr.Node assetNode, String compositeId)
          Set the composite id to the pathProperty (img) value, and remove the identifierProperty (imgUUID).
 
Methods inherited from class info.magnolia.module.delta.AbstractRepositoryTask
execute
 
Methods inherited from class info.magnolia.module.delta.AbstractTask
getDescription, getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChangeDataDmsReferenceToDamMigrationTask

public ChangeDataDmsReferenceToDamMigrationTask(String taskName,
                                                String taskDescription,
                                                String contentRepository,
                                                List<String> contentPathsList,
                                                String identifierPropertyName,
                                                String pathPropertyName)
Default constructor.

Method Detail

doExecute

public void doExecute(info.magnolia.module.InstallContext ctx)
               throws info.magnolia.module.delta.TaskExecutionException
Specified by:
doExecute in class info.magnolia.module.delta.AbstractRepositoryTask
Throws:
info.magnolia.module.delta.TaskExecutionException

handleDataReference

protected void handleDataReference(javax.jcr.Property identifierProperty,
                                   javax.jcr.Property pathProperty,
                                   javax.jcr.Node assetNode,
                                   String compositeId)
                            throws javax.jcr.RepositoryException
Set the composite id to the identifierProperty (imgUUID) value.

Throws:
javax.jcr.RepositoryException

handleDmsReference

protected void handleDmsReference(javax.jcr.Property identifierProperty,
                                  javax.jcr.Property pathProperty,
                                  javax.jcr.Node assetNode,
                                  String compositeId)
                           throws javax.jcr.RepositoryException
Set the composite id to the pathProperty (img) value, and remove the identifierProperty (imgUUID).

Throws:
javax.jcr.RepositoryException


Copyright © 2014 Magnolia International Ltd.. All Rights Reserved.