public abstract class AbstractPackageManagerClient extends Object implements PackageManagerClient
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractPackageManagerClient.Either<T,U> |
protected static class |
AbstractPackageManagerClient.ResponseBuilder |
Constructor and Description |
---|
AbstractPackageManagerClient() |
Modifier and Type | Method and Description |
---|---|
DetailedResponse |
build(PackId packageId)
Builds the specified package
|
DetailedResponse |
build(PackId packageId,
ResponseProgressListener listener)
Builds the specified package
|
protected abstract AbstractPackageManagerClient.Either<? extends Exception,Boolean> |
checkServiceAvailability(boolean checkTimeout,
long timeoutRemaining)
The CRX PackageManagerServlet does not support GET requests.
|
protected String |
constructUrl(String path,
String query,
String fragment) |
DetailedResponse |
contents(PackId packageId)
Prints the contents of the package to the response
|
DetailedResponse |
contents(PackId packageId,
ResponseProgressListener listener)
Prints the contents of the package to the response
|
SimpleResponse |
create(PackId packageId)
Create a package with the specified packageId
|
protected static DownloadResponse |
createDownloadResponse(File outputFile) |
SimpleResponse |
delete(PackId packageId)
Delete a package from the server.
|
DownloadResponse |
download(PackId packageId,
File toFile)
Downloads the package identified by
packageId to the absolute path specified by toFile |
DownloadResponse |
downloadToDirectory(PackId packageId,
File toDirectory)
Downloads the package to a qualified relative path under
toDirectory |
DetailedResponse |
dryRun(PackId packageId)
Performs a dryRun of an installation of the specified package
|
DetailedResponse |
dryRun(PackId packageId,
ResponseProgressListener listener)
Performs a dryRun of an installation of the specified package
|
boolean |
existsOnServer(PackId packageId)
Checks if a package with the specified packageId has already been uploaded to the server.
|
String |
getBaseUrl() |
Charset |
getCharset() |
String |
getConsoleUiUrl() |
String |
getConsoleUiUrl(PackId packageId)
Return the Console UI Url for the specified package, which is useful for creating HTML links.
|
protected String |
getDownloadUrl() |
protected String |
getHtmlUrl() |
protected String |
getHtmlUrl(PackId packageId) |
protected String |
getJsonUrl() |
protected String |
getJsonUrl(PackId packageId) |
protected String |
getListUrl() |
String |
getLoginUrl() |
long |
getRequestTimeout() |
protected abstract AbstractPackageManagerClient.ResponseBuilder |
getResponseBuilder() |
long |
getServiceTimeout() |
protected String |
getUpdateUrl() |
long |
getWaitDelay() |
PackId |
identify(File file)
Identify a CRX package based on its metadata.
|
PackId |
identify(File file,
boolean strict)
Identify a CRX package based on its metadata
|
DetailedResponse |
install(PackId packageId,
boolean recursive,
int autosave,
ACHandling acHandling)
Install a package that has already been uploaded to the server.
|
DetailedResponse |
install(PackId packageId,
boolean recursive,
int autosave,
ACHandling acHandling,
ResponseProgressListener listener)
Install a package that has already been uploaded to the server.
|
protected static <T,U> AbstractPackageManagerClient.Either<T,U> |
left(T left,
Class<U> right) |
ListResponse |
list()
List all packages
|
ListResponse |
list(PackId packageId,
boolean includeVersions)
List one package matching
packageId or many packages matching the package group and name
up to the first hyphen. |
ListResponse |
list(String query)
List all packages and filter by
query |
abstract boolean |
login(String username,
String password)
Login to CRX using a POST request /crx/j_security_check.
|
SimpleResponse |
move(PackId packageId,
PackId moveToId)
Move/Rename a package on the server
|
protected static DetailedResponse |
parseDetailedResponse(int statusCode,
String statusText,
InputStream stream,
String charset,
ResponseProgressListener listener) |
protected static DownloadResponse |
parseDownloadResponse(int statusCode,
String statusText,
InputStream stream,
File outputFile) |
protected static ListResponse |
parseListResponse(int statusCode,
String statusText,
InputStream stream,
String charset) |
protected static SimpleResponse |
parseSimpleResponse(int statusCode,
String statusText,
InputStream stream,
String charset) |
protected static SimpleResponse |
parseSimpleResponse(int statusCode,
String statusText,
InputStream stream,
String charset,
boolean nullOnNonIOError) |
abstract void |
preemptLogin(String username,
String password)
Enable preemptive authentication using Basic Auth credentials.
|
SimpleResponse |
replicate(PackId packageId)
Replicates the package using the server's default replication agents
|
DetailedResponse |
rewrap(PackId packageId)
Rewraps the specified package
|
DetailedResponse |
rewrap(PackId packageId,
ResponseProgressListener listener)
Rewraps the specified package
|
protected static <T,U> AbstractPackageManagerClient.Either<T,U> |
right(Class<T> left,
U right) |
void |
setBaseUrl(String baseUrl) |
void |
setCharset(Charset charset) |
void |
setRequestTimeout(long requestTimeout)
Set the amount of time in milliseconds to wait for a response for any given
request.
|
void |
setServiceTimeout(long serviceTimeout)
Set the amount of time in milliseconds to wait for service availability,
which may span multiple retry requests.
|
void |
setWaitDelay(long waitDelay)
Set a delay in milliseconds for calls to the
PackageManagerClient.waitForService() method. |
DetailedResponse |
uninstall(PackId packageId)
Uninstalls the specified package
|
DetailedResponse |
uninstall(PackId packageId,
ResponseProgressListener listener)
Uninstalls the specified package
|
SimpleResponse |
updateFilter(PackId packageId,
WspFilter filter)
Update a package definition with the specified
WspFilter |
SimpleResponse |
upload(File file,
boolean force,
PackId packageId)
Upload a package to the server.
|
boolean |
waitForService()
Wait for service availability.
|
public static final ResponseProgressListener DEFAULT_LISTENER
public static final String CONSOLE_UI_BASE_PATH
public static final String CONSOLE_UI_LIST_PATH
public static final String CONSOLE_UI_DOWNLOAD_PATH
public static final String CONSOLE_UI_UPDATE_PATH
public static final String SERVICE_BASE_PATH
public static final String HTML_SERVICE_PATH
public static final String JSON_SERVICE_PATH
public static final String DEFAULT_BASE_URL
public static final String DEFAULT_USERNAME
public static final String DEFAULT_PASSWORD
public static final String DEFAULT_CHARSET
public static final int MIN_AUTOSAVE
public static final String MIME_ZIP
public static final String KEY_CMD
public static final String KEY_FORCE
public static final String KEY_PACKAGE
public static final String KEY_SUCCESS
public static final String KEY_MESSAGE
public static final String KEY_PATH
public static final String KEY_RECURSIVE
public static final String KEY_AUTOSAVE
public static final String KEY_ACHANDLING
public static final String KEY_RESULTS
public static final String KEY_TOTAL
public static final String KEY_GROUP
public static final String KEY_NAME
public static final String KEY_VERSION
public static final String KEY_HAS_SNAPSHOT
public static final String KEY_NEEDS_REWRAP
public static final String KEY_INCLUDE_VERSIONS
public static final String KEY_QUERY
public static final String KEY_GROUP_NAME
public static final String KEY_PACKAGE_NAME
public static final String KEY_PACKAGE_VERSION
public static final String KEY_FILTER
public static final String KEY_CHARSET
public static final String KEY_NO_SLING
public static final String VAL_NO_SLING
public static final PackId NO_SUCH_PACK_ID
public static final String CMD_CONTENTS
public static final String CMD_INSTALL
public static final String CMD_UNINSTALL
public static final String CMD_UPLOAD
public static final String CMD_CREATE
public static final String CMD_BUILD
public static final String CMD_REWRAP
public static final String CMD_DRY_RUN
public static final String CMD_DELETE
public static final String CMD_REPLICATE
public static final String LOGIN_PATH
public static final String LOGIN_PARAM_USERNAME
public static final String LOGIN_PARAM_PASSWORD
public static final String LOGIN_PARAM_VALIDATE
public static final String LOGIN_VALUE_VALIDATE
public static final String LOGIN_PARAM_CHARSET
public static final String LOGIN_VALUE_CHARSET
public static final String LEGACY_PATH
public static final String LEGACY_PARAM_USERID
public static final String LEGACY_PARAM_PASSWORD
public static final String LEGACY_PARAM_WORKSPACE
public static final String LEGACY_VALUE_WORKSPACE
public static final String LEGACY_PARAM_TOKEN
public static final String LEGACY_VALUE_TOKEN
public Charset getCharset()
public void setCharset(Charset charset)
public void setBaseUrl(String baseUrl)
public final String getBaseUrl()
getBaseUrl
in interface PackageManagerClient
public long getRequestTimeout()
public void setRequestTimeout(long requestTimeout)
PackageManagerClient
setRequestTimeout
in interface PackageManagerClient
requestTimeout
- timeout in millisecondspublic long getServiceTimeout()
public void setServiceTimeout(long serviceTimeout)
PackageManagerClient
setServiceTimeout
in interface PackageManagerClient
serviceTimeout
- timeout in millisecondspublic long getWaitDelay()
public void setWaitDelay(long waitDelay)
PackageManagerClient
PackageManagerClient.waitForService()
method.
Increase this value to account for delayed OSGi bundle cycling on the server after
installing packages with embedded bundles.
Set this to a negative number or zero for no delay.setWaitDelay
in interface PackageManagerClient
waitDelay
- delay in millisecondsprotected final String getHtmlUrl()
public String getLoginUrl()
protected final String getJsonUrl()
protected final String getListUrl()
protected final String getDownloadUrl()
protected final String getUpdateUrl()
public final String getConsoleUiUrl()
public final String getConsoleUiUrl(PackId packageId)
PackageManagerClient
getConsoleUiUrl
in interface PackageManagerClient
packageId
- the PackId
representing the packagepublic abstract boolean login(String username, String password) throws IOException
username
- the usernamepassword
- the passwordIOException
- for "a failure to communicate"public abstract void preemptLogin(String username, String password)
username
- the usernamepassword
- the passwordprotected abstract AbstractPackageManagerClient.Either<? extends Exception,Boolean> checkServiceAvailability(boolean checkTimeout, long timeoutRemaining)
checkTimeout
- set to true to enforce a timeouttimeoutRemaining
- remaining timeout in millisecondsprotected abstract AbstractPackageManagerClient.ResponseBuilder getResponseBuilder()
protected static DetailedResponse parseDetailedResponse(int statusCode, String statusText, InputStream stream, String charset, ResponseProgressListener listener) throws IOException
IOException
protected static SimpleResponse parseSimpleResponse(int statusCode, String statusText, InputStream stream, String charset) throws IOException
IOException
protected static SimpleResponse parseSimpleResponse(int statusCode, String statusText, InputStream stream, String charset, boolean nullOnNonIOError) throws IOException
IOException
protected static ListResponse parseListResponse(int statusCode, String statusText, InputStream stream, String charset) throws IOException
IOException
protected static DownloadResponse parseDownloadResponse(int statusCode, String statusText, InputStream stream, File outputFile) throws IOException
IOException
protected static DownloadResponse createDownloadResponse(File outputFile) throws IOException
IOException
protected static <T,U> AbstractPackageManagerClient.Either<T,U> left(T left, Class<U> right)
protected static <T,U> AbstractPackageManagerClient.Either<T,U> right(Class<T> left, U right)
public final PackId identify(File file) throws IOException
identify
in interface PackageManagerClient
file
- a File
representing the packagePackId
object if the file represents a package, or null
otherwiseIOException
- if the file can not be read, or it is not a zip filepublic final PackId identify(File file, boolean strict) throws IOException
identify
in interface PackageManagerClient
file
- a File
representing the packagestrict
- set to true to require a META-INF/vault/properties.xml file.PackId
object if the file represents a package, or null
otherwiseIOException
- if the file can not be read, or it is not a zip filepublic final boolean waitForService() throws Exception
waitForService
in interface PackageManagerClient
Exception
- on timeout, interruption, or IOExceptionpublic final boolean existsOnServer(PackId packageId) throws Exception
existsOnServer
in interface PackageManagerClient
packageId
- the PackId
representing the packagetrue
if a package exists, false
otherwiseException
- for unknown errorspublic final ListResponse list() throws Exception
list
in interface PackageManagerClient
Exception
- for unknown errorspublic final ListResponse list(String query) throws Exception
query
list
in interface PackageManagerClient
query
- can be null or empty stringquery
Exception
- for unknown errorspublic final ListResponse list(PackId packageId, boolean includeVersions) throws Exception
packageId
or many packages matching the package group and name
up to the first hyphen.list
in interface PackageManagerClient
packageId
- the PackId
representing the group:name(:version)? to matchincludeVersions
- set to true to match on group:name up to the first hyphen in the "name-version"
string, which effectively matches against all versions of the packageException
- for unknown errorspublic final SimpleResponse upload(File file, boolean force, PackId packageId) throws Exception
upload
in interface PackageManagerClient
file
- the package file to be uploadedforce
- set to true
for the uploaded file to replace an existing package on the
server that has the same id. Has no effect if no existing package is found.packageId
- optional PackId
providing the installation path. If null
,
the file
will be identified and that PackId
will be used.Exception
- for unknown errorspublic final DownloadResponse download(PackId packageId, File toFile) throws Exception
packageId
to the absolute path specified by toFile
download
in interface PackageManagerClient
packageId
- PackId
representing package to be downloadedtoFile
- the file to save the downloaded binary data to.Exception
- for unknown errorspublic final DownloadResponse downloadToDirectory(PackId packageId, File toDirectory) throws Exception
toDirectory
downloadToDirectory
in interface PackageManagerClient
packageId
- PackId
representing package to be downloadedtoDirectory
- a base directory under which packages will be saved at a relative path matching
their CRX installation path, starting with "./etc/packages"Exception
- for unknown errorspublic final SimpleResponse delete(PackId packageId) throws Exception
delete
in interface PackageManagerClient
packageId
- PackId
representing package to be deletedException
- for unknown errorspublic final SimpleResponse replicate(PackId packageId) throws Exception
replicate
in interface PackageManagerClient
packageId
- PackId
representing package to be replicatedException
- for unknown errorspublic final DetailedResponse contents(PackId packageId) throws Exception
contents
in interface PackageManagerClient
packageId
- PackId
representing packageException
- for unknown errorspublic final DetailedResponse contents(PackId packageId, ResponseProgressListener listener) throws Exception
contents
in interface PackageManagerClient
packageId
- PackId
representing packagelistener
- response progress listenerException
- for unknown errorspublic final DetailedResponse install(PackId packageId, boolean recursive, int autosave, ACHandling acHandling) throws Exception
install
in interface PackageManagerClient
packageId
- PackId
representing package to be installedrecursive
- set to true
to also install subpackagesautosave
- number of changes between session saves.acHandling
- Access Control Handling value ACHandling
. Unspecified if null
.Exception
- for unknown errorspublic final DetailedResponse install(PackId packageId, boolean recursive, int autosave, ACHandling acHandling, ResponseProgressListener listener) throws Exception
install
in interface PackageManagerClient
packageId
- PackId
representing package to be installedrecursive
- set to true
to also install subpackagesautosave
- number of changes between session saves.acHandling
- Access Control Handling value ACHandling
. Unspecified if null
.listener
- response progress listenerException
- for unknown errorspublic final DetailedResponse dryRun(PackId packageId) throws Exception
dryRun
in interface PackageManagerClient
packageId
- PackId
representing packageException
- for unknown errorspublic final DetailedResponse dryRun(PackId packageId, ResponseProgressListener listener) throws Exception
dryRun
in interface PackageManagerClient
packageId
- PackId
representing packagelistener
- response progress listenerException
- for unknown errorspublic final SimpleResponse create(PackId packageId) throws Exception
create
in interface PackageManagerClient
packageId
- PackId
representing new packageException
- for unknown errorspublic final SimpleResponse updateFilter(PackId packageId, WspFilter filter) throws Exception
WspFilter
updateFilter
in interface PackageManagerClient
packageId
- PackId
representing package to updatefilter
- new workspace filterException
- for unknown errorspublic final SimpleResponse move(PackId packageId, PackId moveToId) throws Exception
move
in interface PackageManagerClient
packageId
- PackId
representing package to move/renamemoveToId
- PackId
package ID to move toException
- for unknown errorspublic final DetailedResponse build(PackId packageId) throws Exception
build
in interface PackageManagerClient
packageId
- PackId
representing packageException
- for unknown errorspublic final DetailedResponse build(PackId packageId, ResponseProgressListener listener) throws Exception
build
in interface PackageManagerClient
packageId
- PackId
representing packagelistener
- response progress listenerException
- for unknown errorspublic final DetailedResponse rewrap(PackId packageId) throws Exception
rewrap
in interface PackageManagerClient
packageId
- PackId
representing packageException
- for unknown errorspublic final DetailedResponse rewrap(PackId packageId, ResponseProgressListener listener) throws Exception
rewrap
in interface PackageManagerClient
packageId
- PackId
representing packagelistener
- response progress listenerException
- for unknown errorspublic final DetailedResponse uninstall(PackId packageId) throws Exception
uninstall
in interface PackageManagerClient
packageId
- PackId
representing packageException
- for unknown errorspublic final DetailedResponse uninstall(PackId packageId, ResponseProgressListener listener) throws Exception
uninstall
in interface PackageManagerClient
packageId
- PackId
representing packagelistener
- response progress listenerException
- for unknown errorsCopyright © 2013-2017. All Rights Reserved.