public class ResourceCleanUpTask
extends info.magnolia.module.delta.AbstractRepositoryTask
Since 5.4, a side effect of the new Resources API + app is that previously installed resources appear twice in the new app (one from the classpath with extension, one from JCR without extension).
Installing resources was traditionally how resources used to be accessed, over URI2ResourcesRepositoryMapping
, at /resources
.
This is still working and supported, but not encouraged in favor of the new resource loading cascade.
ResourceCleanUpTask tries to restore extension in JCR node names to resolve this problem.
Modifier and Type | Field and Description |
---|---|
protected static String |
BINARY_RESOURCES_TEMPLATE |
protected static String |
PROPERTY_EXTENSION |
protected static String |
PROPERTY_REFERENCE |
protected static String |
PROPERTY_TEMPLATE |
protected static String |
PROPERTY_TEXT |
protected static String |
REFERENCES_RESOURCES_TEMPLATE |
protected static String |
RESOURCE_PROCESSED |
protected static String |
RESOURCES_PREFIX |
Constructor and Description |
---|
ResourceCleanUpTask(String name,
String description,
Pattern pathPattern,
UpdateResourceReferencesTask onSuccess)
Restores resource extension in JCR node names, for resources matching a given pattern.
|
ResourceCleanUpTask(String name,
String description,
Set<String> absPaths,
UpdateResourceReferencesTask onSuccess)
Restores resource extension in JCR node names, for a set of specific resources.
|
ResourceCleanUpTask(String name,
String description,
String parentPath,
UpdateResourceReferencesTask onSuccess)
Restores resource extension in JCR node names, by visiting a JCR sub-tree recursively, from the given parent path.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doExecute(info.magnolia.module.InstallContext installContext) |
protected Iterator<javax.jcr.Node> |
findResourceNodes() |
protected Map<String,String> |
getChangedPaths() |
protected static final String PROPERTY_TEMPLATE
protected static final String PROPERTY_EXTENSION
protected static final String PROPERTY_TEXT
protected static final String PROPERTY_REFERENCE
protected static final String RESOURCES_PREFIX
protected static final String BINARY_RESOURCES_TEMPLATE
protected static final String REFERENCES_RESOURCES_TEMPLATE
protected static final String RESOURCE_PROCESSED
public ResourceCleanUpTask(String name, String description, String parentPath, UpdateResourceReferencesTask onSuccess)
extension
property, binary node extension
property, or resource templateIf resources already exist *in JCR* with extension and same content, they are considered redundant and are removed.
If resources already exist on classpath or file-system with extension and same content, they are renamed to restore extension;
mind that they are kept in JCR so that bypassed resources keep working via URI2RepositoryMapping.
parentPath
- a path in JCR resources workspace, to start visiting fromonSuccess
- an UpdateResourceReferencesTask
might be needed to update resource references for renamed resourcespublic ResourceCleanUpTask(String name, String description, Pattern pathPattern, UpdateResourceReferencesTask onSuccess)
If resources already exist *in JCR* with extension and same content, they are considered redundant and are removed.
If resources already exist on classpath or file-system with extension and same content, they are renamed to restore extension;
mind that they are kept in JCR so that bypassed resources keep working via URI2RepositoryMapping.
pathPattern
- a Pattern
to match resource paths in module resources, including extension.onSuccess
- an UpdateResourceReferencesTask
might be needed to update resource references for renamed resourcespublic ResourceCleanUpTask(String name, String description, Set<String> absPaths, UpdateResourceReferencesTask onSuccess)
If resources already exist *in JCR* with extension and same content, they are considered redundant and are removed.
If resources already exist on classpath or file-system with extension and same content, they are renamed to restore extension;
mind that they are kept in JCR so that bypassed resources keep working via URI2RepositoryMapping.
absPaths
- a set of existing resource paths in module resources, including extension.onSuccess
- an UpdateResourceReferencesTask
might be needed to update resource references for renamed resourcesprotected void doExecute(info.magnolia.module.InstallContext installContext) throws javax.jcr.RepositoryException, info.magnolia.module.delta.TaskExecutionException
doExecute
in class info.magnolia.module.delta.AbstractRepositoryTask
javax.jcr.RepositoryException
info.magnolia.module.delta.TaskExecutionException
protected Iterator<javax.jcr.Node> findResourceNodes() throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
Copyright © 2016 Magnolia International Ltd.. All rights reserved.