Added support for page references

This commit is contained in:
Rick Rongen
2019-03-13 09:21:02 +01:00
parent b246f07340
commit bf6d737262

View File

@@ -24,6 +24,7 @@ download.jsp?path=%2Fcontent%2Fdam%2Fbeeldbank%2Fvrouw-direct-naar.jpg%2Fjcr%3Ac
CRX_SERVER_ROOT = '/crx/server/crx.default/jcr:root/' CRX_SERVER_ROOT = '/crx/server/crx.default/jcr:root/'
CRX_QUERY = '/crx/de/query.jsp' CRX_QUERY = '/crx/de/query.jsp'
WCM_REFERENCES = '/bin/wcm/references.json' WCM_REFERENCES = '/bin/wcm/references.json'
WCM_PAGE_REFERENCES = '/libs/wcm/core/content/reference.json'
WCM_REPLICATE = '/bin/replicate.json' WCM_REPLICATE = '/bin/replicate.json'
WORKFLOW_INSTANCES = '/etc/workflow/instances' WORKFLOW_INSTANCES = '/etc/workflow/instances'
@@ -122,6 +123,33 @@ class Connection:
}) })
return response.json()['pages'] return response.json()['pages']
def get_page_references(self, page_path: str):
"""
Check other item are referenced by the current page.
Args:
page_path: The page to check
Returns:
A list of dictionaries that represent the referenced items
Examples:
session.get_page_references('/content/....')
[{
"type": "asset",
"path": "/content/dam/beeldbank/jong-koppel-leest-liggend-op-de-vloer-met-voeten-op-de-bank.jpg",
"name": "jong-koppel-leest-liggend-op-de-vloer-met-voeten-op-de-bank.jpg",
"published": False,
"outdated": False,
"status": "not available",
"disabled": False,
"lastPublished": 0,
"lastModified": 1552398212196
}]
"""
response = self._session.get(self._host + WCM_PAGE_REFERENCES, params={'path': page_path})
return response.json()['assets']
def upload_asset(self, dam_directory: str, filename: str, data: bytes, content_type: str): def upload_asset(self, dam_directory: str, filename: str, data: bytes, content_type: str):
""" """
Upload an asset to the DAM as if it was uploaded through the GUI Upload an asset to the DAM as if it was uploaded through the GUI