Class ContentSync

java.lang.Object
com.adobe.acs.commons.contentsync.ContentSync

public class ContentSync extends Object
  • Constructor Details

    • ContentSync

      public ContentSync(RemoteInstance remoteInstance, org.apache.sling.api.resource.ResourceResolver resourceResolver, org.apache.sling.jcr.contentloader.ContentImporter importer)
  • Method Details

    • sort

      public List<String> sort(javax.jcr.Node node) throws javax.jcr.RepositoryException, IOException, URISyntaxException
      Ensure that the order of child nodes matches the order on the remote instance.

      The method makes an HTTP call to the remote instance to fetch the ordered list of child nodes and re-sorts the given node to match it.

      Parameters:
      node - the node to sort
      Returns:
      children after sort
      Throws:
      javax.jcr.RepositoryException
      IOException
      URISyntaxException
    • sort

      public void sort(javax.jcr.Node node, List<String> children) throws javax.jcr.RepositoryException
      Sort child nodes of a JCR node
      Parameters:
      node - the node to sort
      children - the desired order of children
      Throws:
      javax.jcr.RepositoryException
    • copyBinaries

      public void copyBinaries(List<String> propertyPaths) throws IOException, javax.jcr.RepositoryException, URISyntaxException
      Copy binary data from remote instance and update local resource. Performs an HTT call for each property path
      Parameters:
      propertyPaths - list of binary properties to update, e.g.
                            [
                               "/content/contentsync/jcr:content/image/file/jcr:content/jcr:data",
                               "/content/contentsync/jcr:content/image/file/jcr:content/dam:thumbnails/dam:thumbnail_48.png/jcr:content/jcr:data",
                            ]
                            
      Throws:
      IOException
      javax.jcr.RepositoryException
      URISyntaxException
    • getImportOptions

      public org.apache.sling.jcr.contentloader.ImportOptions getImportOptions()
    • clearContent

      public void clearContent(javax.jcr.Node node) throws javax.jcr.RepositoryException
      Clear jcr:content and remove all properties except protected ones
      Parameters:
      node - the node to clear
      Throws:
      javax.jcr.RepositoryException
    • ensureParent

      public javax.jcr.Node ensureParent(String path) throws javax.jcr.RepositoryException, IOException, URISyntaxException
      Ensure parent node exists before importing content. Parent can be null, for example, if a user is sync-ing /content/my-site/en/one and the /content/my-site tree does not exist on the local instance. In such a case the method would fetch the primary type of the parent node (/content/my-site/en) and use it as intermediate node type to ensure parent.
      Parameters:
      path - the path to ensure if the parent exists
      Returns:
      the parent node
      Throws:
      javax.jcr.RepositoryException
      IOException
      URISyntaxException
    • ensureContentNode

      public javax.jcr.Node ensureContentNode(CatalogItem catalogItem) throws javax.jcr.RepositoryException, IOException, URISyntaxException
      importContent("/content/contentsync/page", "jcr:content.json", .... ) where /content/contentsync/page is an existing cq:Page resource importContent("/content/dam/contentsync/asset", "jcr:content.json", .... ) where /content/contentsync/asset is an existing dam:Asset resource importContent("/content/dam/contentsync", "folderName.json", .... ) importContent("/content/misc", "nodeName.json", .... )
      Parameters:
      catalogItem -
      Returns:
      Throws:
      javax.jcr.RepositoryException
      IOException
      URISyntaxException
    • importData

      public void importData(CatalogItem catalogItem, javax.json.JsonObject jsonObject) throws javax.jcr.RepositoryException, IOException, URISyntaxException
      Throws:
      javax.jcr.RepositoryException
      IOException
      URISyntaxException
    • createVersion

      public String createVersion(org.apache.sling.api.resource.Resource resource) throws Exception
      Throws:
      Exception
    • runWorkflows

      public void runWorkflows(String workflowModel, List<String> paths) throws com.adobe.granite.workflow.WorkflowException
      Throws:
      com.adobe.granite.workflow.WorkflowException