Class ImporterUtil


  • public class ImporterUtil
    extends java.lang.Object
    Utility class for Importer component related stuff
    • Constructor Detail

      • ImporterUtil

        public ImporterUtil()
    • Method Detail

      • findImporter

        public static Resource findImporter​(Resource resource)
        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

        public static java.util.List<Resource> findImporters​(Resource resource)
        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

        public static java.util.List<Resource> findImporters​(Resource resource,
                                                             boolean recursive)
        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 resource
        recursive - if true, all sub pages are looked up as well
        Returns:
        The list of importer resources found
      • checkCanvasPrimary

        public static boolean checkCanvasPrimary​(Resource resource)
                                          throws java.lang.IllegalArgumentException
        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:
        java.lang.IllegalArgumentException - When the passed resource is not a valid canvas resource
      • checkCanvasSecondary

        public static boolean checkCanvasSecondary​(Resource resource)
                                            throws java.lang.IllegalArgumentException
        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:
        java.lang.IllegalArgumentException - When the passed resource is not a valid canvas resource
      • getCanvasDesign

        public static Resource getCanvasDesign​(Resource resource)
        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

        public static Resource getCanvas​(Resource resource)
        Convenience method to get canvas from the importer. If a canvas resource is passed, it's returned back
        Parameters:
        resource -
        Returns:
      • isCanvas

        public static boolean isCanvas​(Resource resource)
        Checks if the passed resource corresponds to a generated canvas node based on the following heuristics:
        Parameters:
        resource -
        Returns:
      • isImporter

        public static boolean isImporter​(Resource resource)
        Checks if the passed resource corresponds to importer
        Parameters:
        resource -
        Returns:
      • isImporterPage

        public static boolean isImporterPage​(Resource resource)
        Checks if the passed resource is a, or belongs to a page created using the ImporterConstants.PAGE_TEMPLATE_IMPORTER_PAGE template
        Parameters:
        resource - The page resource or a resource contained within the page
        Returns:
      • deleteCanvasArtifact

        public static void deleteCanvasArtifact​(Resource resource)
                                         throws RepositoryException
        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 component
        cleanupDanglingAscendants - flag to indicate if ascendants left dangling, because of the deleted canvas, also need to be cleaned up.
        Throws:
        RepositoryException
      • cleanupDanglingAscendants

        public static void cleanupDanglingAscendants​(Resource resource)
                                              throws RepositoryException
        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