Package com.adobe.cq.testing.client
Class CQAssetsClient
- java.lang.Object
-
- org.apache.sling.testing.clients.AbstractSlingClient
-
- org.apache.sling.testing.clients.SlingClient
-
- com.adobe.cq.testing.client.CQClient
-
- com.adobe.cq.testing.client.CQAssetsClient
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.http.client.HttpClient
public class CQAssetsClient extends CQClient
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adobe.cq.testing.client.CQClient
CQClient.Builder, CQClient.InternalBuilder<T extends CQClient>
-
-
Field Summary
Fields Modifier and Type Field Description protected static long
ASSET_PROCESSED_DELAY
The default delay between polling for asset processing status, 500L milliseconds.protected static long
ASSET_PROCESSED_TIMEOUT
The default timeout for asset processing, 30000L milliseconds.-
Fields inherited from class com.adobe.cq.testing.client.CQClient
STATISTICS_ROOT, wcmCommands
-
-
Constructor Summary
Constructors Constructor Description CQAssetsClient(org.apache.http.impl.client.CloseableHttpClient http, org.apache.sling.testing.clients.SlingClientConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<FailedRendition>
getAssetProcessingFailures(String assetPath)
Retrieve any processing failures with an asset.List<String>
getAssetsProcessedRenditions(String assetPath)
Retrieve all processed renditions of an asset.String
getAssetStatus(String assetPath)
Retrieve the asset processing status.boolean
isDirectBinaryAccessSupported()
Check if Direct Binary Access is enabledorg.apache.sling.testing.clients.SlingHttpResponse
uploadAsset(String fileName, String resourcePath, String mimeType, String parentPath, int... expectedStatus)
Uploads an Asset to the repository.ProcessedAsset
waitAssetProcessed(String assetPath)
Wait for an asset to complete processing.ProcessedAsset
waitAssetProcessed(String assetPath, long timeout, long delay)
Wait for an asset to complete processing.-
Methods inherited from class com.adobe.cq.testing.client.CQClient
copyLanguages, copyPage, createPage, createPageWithRetry, createVersion, deletePage, deletePageWithRetry, getAuthorSitesPage, lockPage, movePage, movePage, pageExists, pageExistsWithRetry, pageExistsWithRetry, resetPageStatistics, restoreTree, restoreVersion, rolloutPage, searchAndReplaceInPages, searchInPages, setPageProperties, setPageProperty, setPagePropertyImage, unlockPage, uploadFileCQStyle
-
Methods inherited from class org.apache.sling.testing.clients.SlingClient
createFolder, createNode, createNodeRecursive, deletePath, doGetJson, endImpersonation, exists, getJsonNode, getJsonNode, getNodeNameFromPath, getParentPath, getUser, getUUId, getUUID, impersonate, importContent, importContent, importJson, move, setPropertiesString, setPropertyString, setPropertyStringArray, upload, waitExists, waitUntilExists
-
Methods inherited from class org.apache.sling.testing.clients.AbstractSlingClient
adaptTo, addValue, close, doDelete, doGet, doGet, doGet, doHead, doPatch, doPost, doPost, doPut, doRawRequest, doRequest, doStreamGet, doStreamPost, doStreamRequest, execute, execute, execute, execute, execute, execute, execute, execute, getClientId, getConnectionManager, getCookieStore, getCredentialsProvider, getParams, getPassword, getPath, getPath, getUrl, getUrl, getUrl, getValue, getValues, hasValue
-
-
-
-
Field Detail
-
ASSET_PROCESSED_TIMEOUT
protected static final long ASSET_PROCESSED_TIMEOUT
The default timeout for asset processing, 30000L milliseconds.- See Also:
- Constant Field Values
-
ASSET_PROCESSED_DELAY
protected static final long ASSET_PROCESSED_DELAY
The default delay between polling for asset processing status, 500L milliseconds.- See Also:
- Constant Field Values
-
-
Method Detail
-
isDirectBinaryAccessSupported
public boolean isDirectBinaryAccessSupported() throws org.apache.sling.testing.clients.ClientException
Check if Direct Binary Access is enabled- Returns:
- True if enabled, false otherwise
- Throws:
org.apache.sling.testing.clients.ClientException
- if something fails during the request/response cycle
-
uploadAsset
public org.apache.sling.testing.clients.SlingHttpResponse uploadAsset(String fileName, String resourcePath, String mimeType, String parentPath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
Uploads an Asset to the repository. Same as usingNew File...
in the DAM admin or when uploading a file belowDigital Assets
in the Site Admin.
This will upload the file and store it in a node typeddam:Asset
. This will trigger all DAM related workflows for generating rendition nodes, extract metadata etc.
To upload a file that is not to be handled as an asset useCQClient.uploadFileCQStyle(java.lang.String, java.lang.String, java.lang.String, java.lang.String, int...)
instead.
To upload a file directly using sling useSlingClient.upload(java.io.File, String, String, boolean, int...)
.
This implementation will pick Direct Binary Access upload when available or fallback to the original AEM implementation- Parameters:
fileName
- file nameresourcePath
- defines the path to the resourcemimeType
- MIME type of the image getting uploadedparentPath
- parent page (folder) that will contain the fileexpectedStatus
- list of expected HTTP Status to be returned, if not set, 200 is assumed.- Returns:
- the response
- Throws:
org.apache.sling.testing.clients.ClientException
- if something fails during the request/response cycle
-
waitAssetProcessed
public ProcessedAsset waitAssetProcessed(String assetPath) throws org.apache.sling.testing.clients.ClientException, TimeoutException, InterruptedException
Wait for an asset to complete processing. The total timeout is 30000L milliseconds. Polling the asset status occurs every 500L milliseconds.- Parameters:
assetPath
- Path to an asset- Returns:
- ProcessedAsset
- Throws:
org.apache.sling.testing.clients.ClientException
- if something fails during the request/response cycle, or if the asset failed to processTimeoutException
- if the wait times outInterruptedException
- if the wait is interrupted
-
waitAssetProcessed
public ProcessedAsset waitAssetProcessed(String assetPath, long timeout, long delay) throws org.apache.sling.testing.clients.ClientException, TimeoutException, InterruptedException
Wait for an asset to complete processing. The asset state will be checked at least once. If the timeout is 0 or less, then the asset state will be executed exactly once.- Parameters:
assetPath
- Path to an assettimeout
- total time to wait, in millisecondsdelay
- time to wait between polls of asset status, in milliseconds- Returns:
- ProcessedAsset
- Throws:
org.apache.sling.testing.clients.ClientException
- if something fails during the request/response cycle, or if the asset failed to processTimeoutException
- if the wait times outInterruptedException
- if the wait is interrupted
-
getAssetStatus
public String getAssetStatus(String assetPath) throws org.apache.sling.testing.clients.ClientException
Retrieve the asset processing status.- Parameters:
assetPath
- Asset path- Returns:
- dam:assetState value (i.e. unProcessed, processing, processed)
- Throws:
org.apache.sling.testing.clients.ClientException
- if something fails during the request/response cycle
-
getAssetProcessingFailures
public List<FailedRendition> getAssetProcessingFailures(String assetPath) throws org.apache.sling.testing.clients.ClientException
Retrieve any processing failures with an asset. Only able to find failures when Asset Compute is enabled, will return an emptyList
otherwise.- Parameters:
assetPath
- Asset path- Returns:
- List of
FailedRendition
- Throws:
org.apache.sling.testing.clients.ClientException
- if something fails during the request/response cycle
-
getAssetsProcessedRenditions
public List<String> getAssetsProcessedRenditions(String assetPath) throws org.apache.sling.testing.clients.ClientException
Retrieve all processed renditions of an asset.- Parameters:
assetPath
- Asset path- Returns:
- List of String
- Throws:
org.apache.sling.testing.clients.ClientException
- if something fails during the request/response cycle
-
-