Class ContentSync
java.lang.Object
com.adobe.acs.commons.contentsync.ContentSync
-
Constructor Summary
ConstructorsConstructorDescriptionContentSync(RemoteInstance remoteInstance, org.apache.sling.api.resource.ResourceResolver resourceResolver, org.apache.sling.jcr.contentloader.ContentImporter importer) -
Method Summary
Modifier and TypeMethodDescriptionvoidclearContent(javax.jcr.Node node) Clear jcr:content and remove all properties except protected onesvoidcopyBinaries(List<String> propertyPaths) Copy binary data from remote instance and update local resource.createVersion(org.apache.sling.api.resource.Resource resource) javax.jcr.NodeensureContentNode(CatalogItem catalogItem) importContent("/content/contentsync/page", "jcr:content.json", ....javax.jcr.NodeensureParent(String path) Ensure parent node exists before importing content.org.apache.sling.jcr.contentloader.ImportOptionsvoidimportData(CatalogItem catalogItem, javax.json.JsonObject jsonObject) voidrunWorkflows(String workflowModel, List<String> paths) sort(javax.jcr.Node node) Ensure that the order of child nodes matches the order on the remote instance.voidSort child nodes of a JCR node
-
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.RepositoryExceptionIOExceptionURISyntaxException
-
sort
Sort child nodes of a JCR node- Parameters:
node- the node to sortchildren- 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:
IOExceptionjavax.jcr.RepositoryExceptionURISyntaxException
-
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.RepositoryExceptionIOExceptionURISyntaxException
-
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.RepositoryExceptionIOExceptionURISyntaxException
-
importData
public void importData(CatalogItem catalogItem, javax.json.JsonObject jsonObject) throws javax.jcr.RepositoryException, IOException, URISyntaxException - Throws:
javax.jcr.RepositoryExceptionIOExceptionURISyntaxException
-
createVersion
- Throws:
Exception
-
runWorkflows
public void runWorkflows(String workflowModel, List<String> paths) throws com.adobe.granite.workflow.WorkflowException - Throws:
com.adobe.granite.workflow.WorkflowException
-