Class ImporterUtil
java.lang.Object
com.day.cq.wcm.designimporter.util.ImporterUtil
Utility class for Importer component related stuff
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckCanvasPrimary(Resource resource) Checks if the passed canvas is primary.static booleancheckCanvasSecondary(Resource resource) Checks if the passed canvas is secondary.static voidcleanupDanglingAscendants(Resource resource) This method traverses up the hierarchy (uptil canvas dir) of the passed resource and deletes all nodes without children.static voiddeleteCanvasArtifact(Resource resource) Deletes the canvas artifact along with any dangling ascendants.static voiddeleteCanvasArtifact(Resource resource, boolean cleanupDanglingAscendants) Deletes the canvas artifactstatic ResourcefindImporter(Resource resource) Looks up importer in the passed page resourcefindImporters(Resource resource) Finds importer resources within the page resource passed.findImporters(Resource resource, boolean recursive) Finds importer resources within the passed page resource.static ResourceConvenience method to get canvas from the importer.static ResourcegetCanvasDesign(Resource resource) Returns the resource corresponding to the canvas designstatic ResourcegetDanglingAscendantRoot(Resource resource) For internal usestatic booleanChecks if the passed resource corresponds to a generated canvas node based on the following heuristics: Its parent has the resource typeImporterConstants.RESOURCE_TYPE_IMPORTERstatic booleanisImporter(Resource resource) Checks if the passed resource corresponds to importerstatic booleanisImporterPage(Page page) Checks if the passed page is created using theImporterConstants.PAGE_TEMPLATE_IMPORTER_PAGEtemplatestatic booleanisImporterPage(Resource resource) Checks if the passed resource is a, or belongs to a page created using theImporterConstants.PAGE_TEMPLATE_IMPORTER_PAGEtemplate
-
Constructor Details
-
ImporterUtil
public ImporterUtil()
-
-
Method Details
-
findImporter
Looks up importer in the passed page resource- Parameters:
resource- The page resource which needs to be searched for importer resource- Returns:
- The found importer resource. In case of multiple, the first found importer resource is returned
-
findImporters
Finds importer resources within the page resource passed. Doesn't look into sub pages.- Parameters:
resource- The page resource which needs to be searched for importer resource- Returns:
- The list of importer resources found
-
findImporters
Finds importer resources within the passed page resource. Looks into sub pages if the recursive param is passed true- Parameters:
resource- The page resource which needs to be searched for importer resourcerecursive- if true, all sub pages are looked up as well- Returns:
- The list of importer resources found
-
checkCanvasPrimary
Checks if the passed canvas is primary.- Parameters:
resource- The resource corresponding to a canvas- Returns:
- true if the passed canvas resource is primary in nature
- Throws:
IllegalArgumentException- When the passed resource is not a valid canvas resource
-
checkCanvasSecondary
Checks if the passed canvas is secondary.Note: A design import typically results in one primary canvas accompanied by zero or more secondary canvases.
- Parameters:
resource- The resource corresponding to a canvas- Returns:
- true if the passed canvas resource is secondary in nature
- Throws:
IllegalArgumentException- When the passed resource is not a valid canvas resource
-
getCanvasDesign
Returns the resource corresponding to the canvas design- Parameters:
resource- The resource corresponding to a canvas or its container importer component node- Returns:
- Resource corresponding to the canvas design
-
getCanvas
Convenience method to get canvas from the importer. If a canvas resource is passed, it's returned back- Parameters:
resource-- Returns:
-
isCanvas
Checks if the passed resource corresponds to a generated canvas node based on the following heuristics:- Its parent has the resource type
ImporterConstants.RESOURCE_TYPE_IMPORTER
- Parameters:
resource-- Returns:
- Its parent has the resource type
-
isImporter
Checks if the passed resource corresponds to importer- Parameters:
resource-- Returns:
-
isImporterPage
Checks if the passed page is created using theImporterConstants.PAGE_TEMPLATE_IMPORTER_PAGEtemplate- Parameters:
page-- Returns:
-
isImporterPage
Checks if the passed resource is a, or belongs to a page created using theImporterConstants.PAGE_TEMPLATE_IMPORTER_PAGEtemplate- Parameters:
resource- The page resource or a resource contained within the page- Returns:
-
deleteCanvasArtifact
Deletes the canvas artifact along with any dangling ascendants.- Parameters:
resource- Resource corresponding to a canvas artifact like canvas design or canvas component- Throws:
RepositoryException
-
deleteCanvasArtifact
public static void deleteCanvasArtifact(Resource resource, boolean cleanupDanglingAscendants) throws RepositoryException Deletes the canvas artifact- Parameters:
resource- Resource corresponding to a canvas artifact like canvas design or canvas componentcleanupDanglingAscendants- flag to indicate if ascendants left dangling, because of the deleted canvas, also need to be cleaned up.- Throws:
RepositoryException
-
cleanupDanglingAscendants
This method traverses up the hierarchy (uptil canvas dir) of the passed resource and deletes all nodes without children. Since the canvas artifacts are created in convention based structured folders, deletion of artifacts requires cleanup of the folders that were created to contain the artifact.- Throws:
RepositoryException
-
getDanglingAscendantRoot
For internal use- Throws:
RepositoryException
-