public class OsgiConsoleClient extends SlingClient
SlingClient.Builder, SlingClient.InternalBuilder<T extends SlingClient>
Modifier and Type | Field and Description |
---|---|
static String |
JSON_KEY_DATA |
static String |
JSON_KEY_ID |
static String |
JSON_KEY_STATE |
static String |
JSON_KEY_VERSION |
DEFAULT_NODE_TYPE
Constructor and Description |
---|
OsgiConsoleClient(org.apache.http.impl.client.CloseableHttpClient http,
SlingClientConfig config)
Constructor used by adaptTo() and InternalBuilder classes.
|
OsgiConsoleClient(URI serverUrl,
String userName,
String password)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkBundleInstalled(String symbolicName,
int waitTime,
int retries)
Deprecated.
does not respect polling practices; use
waitBundleInstalled(String, long, long) instead |
SlingHttpResponse |
deleteConfiguration(String pid,
int... expectedStatus)
Delete the config referenced by the PID
|
String |
editConfiguration(String PID,
String factoryPID,
Map<String,Object> configProperties,
int... expectedStatus)
Sets properties of a config referenced by its PID.
|
String |
editConfigurationWithWait(int waitCount,
String PID,
String factoryPID,
Map<String,Object> configProperties,
int... expectedStatus)
Deprecated.
|
long |
getBundleId(String symbolicName)
Get the id of the bundle
|
BundleInfo |
getBundleInfo(String id,
int... expectedStatus)
Returns the wrapper for the bundle info json
|
BundlesInfo |
getBundlesInfo(int... expectedStatus)
Returns the wrapper for the bundles info json
|
String |
getBundleState(String symbolicName)
Get the state of the bundle
|
static String |
getBundleSymbolicName(File bundleFile)
Get the symbolic name from a bundle file by looking at the manifest
|
String |
getBundleVersion(String symbolicName)
Get the version of the bundle
|
static String |
getBundleVersionFromFile(File bundleFile)
Get the version form a bundle file by looking at the manifest
|
ComponentInfo |
getComponentInfo(String id,
int expectedStatus)
Returns the wrapper for the component info json
|
ComponentsInfo |
getComponentsInfo(int... expectedStatus)
Returns the wrapper for the components info json
|
Map<String,Object> |
getConfiguration(String pid,
int... expectedStatus)
Returns a map of all properties set for the config referenced by the PID, where the map keys
are the property names.
|
Map<String,Object> |
getConfigurationWithWait(long waitCount,
String pid,
int... expectedStatus)
Deprecated.
|
SlingHttpResponse |
installBundle(File f,
boolean startBundle)
Install a bundle using the Felix webconsole HTTP interface
|
SlingHttpResponse |
installBundle(File f,
boolean startBundle,
int startLevel)
Install a bundle using the Felix webconsole HTTP interface, with a specific start level
|
boolean |
installBundleWithRetry(File f,
boolean startBundle,
int startLevel,
int waitTime,
int retries)
|
void |
refreshPackages()
Calls PackageAdmin.refreshPackages to force re-wiring of all the bundles.
|
void |
startBundle(String symbolicName)
Starts a bundle
|
void |
startBundlewithWait(String symbolicName,
int waitTime,
int retries)
Deprecated.
|
void |
stopBundle(String symbolicName)
Stop a bundle
|
SlingHttpResponse |
uninstallBundle(String symbolicName)
Uninstall a bundle
|
void |
waitBundleInstalled(String symbolicName,
long timeout,
long delay)
Wait until the bundle is installed.
|
void |
waitBundleStarted(String symbolicName,
long timeout,
long delay)
Wait until the bundle is started
|
void |
waitComponentRegistered(String componentName,
long timeout,
long delay)
Wait until the component with the given name is registered.
|
String |
waitEditConfiguration(long timeout,
String PID,
String factoryPID,
Map<String,Object> configProperties,
int... expectedStatus)
Sets properties of a config referenced by its PID.
|
Map<String,Object> |
waitGetConfiguration(long timeout,
String pid,
int... expectedStatus)
Returns a map of all properties set for the config referenced by the PID, where the map keys
are the property names.
|
void |
waitInstallBundle(File f,
boolean startBundle,
int startLevel,
long timeout,
long delay)
Install a bundle using the Felix webconsole HTTP interface and wait for it to be installed.
|
void |
waitServiceRegistered(String type,
String bundleSymbolicName,
long timeout,
long delay)
Wait until the service with the given name is registered.
|
void |
waitStartBundle(String symbolicName,
long timeout,
long delay)
Starts a bundle and waits for it to be started
|
createFolder, createNode, createNodeRecursive, deletePath, doGetJson, exists, getJsonNode, getJsonNode, getNodeNameFromPath, getParentPath, getUUId, getUUID, importContent, importContent, importJson, move, setPropertiesString, setPropertyString, setPropertyStringArray, upload, waitExists, waitUntilExists
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, getUser, getValue, getValues, hasValue
public static final String JSON_KEY_ID
public static final String JSON_KEY_VERSION
public static final String JSON_KEY_DATA
public static final String JSON_KEY_STATE
public OsgiConsoleClient(URI serverUrl, String userName, String password) throws ClientException
SlingClient.SlingClient(URI, String, String)
serverUrl
- the URL to the server under testuserName
- the user name used for authenticationpassword
- the password for this userClientException
- if the client cannot be instantiatedpublic OsgiConsoleClient(org.apache.http.impl.client.CloseableHttpClient http, SlingClientConfig config) throws ClientException
http
- http client to be used for requestsconfig
- sling specific configsClientException
- if the client cannot be instantiatedpublic BundlesInfo getBundlesInfo(int... expectedStatus) throws ClientException
expectedStatus
- list of accepted statuses of the responseClientException
- if the response status does not match any of the expectedStatuspublic BundleInfo getBundleInfo(String id, int... expectedStatus) throws ClientException
id
- the id of the bundleexpectedStatus
- list of accepted statuses of the responseClientException
- if the response status does not match any of the expectedStatuspublic ComponentsInfo getComponentsInfo(int... expectedStatus) throws ClientException
expectedStatus
- list of accepted statuses of the responseClientException
- if the response status does not match any of the expectedStatuspublic ComponentInfo getComponentInfo(String id, int expectedStatus) throws ClientException
id
- the id of the componentexpectedStatus
- list of accepted statuses of the responseClientException
- if the response status does not match any of the expectedStatuspublic void waitComponentRegistered(String componentName, long timeout, long delay) throws TimeoutException, InterruptedException
componentName
- the component's nametimeout
- how long to wait for the component to become registered before throwing a TimeoutException
in millisecondsdelay
- time to wait between checks of the state in millisecondsTimeoutException
- if the component did not become registered before timeout was reachedInterruptedException
- if interruptedpublic void waitServiceRegistered(String type, String bundleSymbolicName, long timeout, long delay) throws TimeoutException, InterruptedException
type
- the type of the service (usually the name of a Java interface)bundleSymbolicName
- the symbolic name of the bundle supposed to register that service.
May be null
in which case this method just waits for any service with the requested type being registered (independent of the registering bundle).timeout
- how long to wait for the component to become registered before throwing a TimeoutException
in millisecondsdelay
- time to wait between checks of the state in millisecondsTimeoutException
- if the component did not become registered before timeout was reachedInterruptedException
- if interruptedpublic Map<String,Object> getConfiguration(String pid, int... expectedStatus) throws ClientException
pid
- the pid of the configurationexpectedStatus
- list of accepted statuses of the responseClientException
- if the response status does not match any of the expectedStatus@Deprecated public Map<String,Object> getConfigurationWithWait(long waitCount, String pid, int... expectedStatus) throws ClientException, InterruptedException
waitGetConfiguration(long, String, int...)
waitCount
- The number of maximum wait intervals of 500ms.
Between each wait interval, the method polls the backend to see if the configuration ahs been set.pid
- pidexpectedStatus
- expected response statusClientException
- if the response status does not match any of the expectedStatusInterruptedException
- to mark this operation as "waiting"public Map<String,Object> waitGetConfiguration(long timeout, String pid, int... expectedStatus) throws ClientException, InterruptedException, TimeoutException
timeout
- Maximum time to wait for the configuration to be available, in ms.pid
- service pidexpectedStatus
- expected response statusClientException
- if the response status does not match any of the expectedStatusInterruptedException
- to mark this operation as "waiting"TimeoutException
- if the timeout was reachedpublic String editConfiguration(String PID, String factoryPID, Map<String,Object> configProperties, int... expectedStatus) throws ClientException
PID
- Persistent identity stringfactoryPID
- Factory persistent identity string or null
configProperties
- map of propertiesexpectedStatus
- expected response statusClientException
- if the response status does not match any of the expectedStatus@Deprecated public String editConfigurationWithWait(int waitCount, String PID, String factoryPID, Map<String,Object> configProperties, int... expectedStatus) throws ClientException, InterruptedException
waitEditConfiguration(long, String, String, Map, int...)
waitCount
- The number of maximum wait intervals of 500ms.
Between each wait interval, the method polls the backend to see if the configuration ahs been set.PID
- Persistent identity stringfactoryPID
- Factory persistent identity string or null
configProperties
- map of propertiesexpectedStatus
- expected response statusClientException
- if the response status does not match any of the expectedStatusInterruptedException
- to mark this operation as "waiting"public String waitEditConfiguration(long timeout, String PID, String factoryPID, Map<String,Object> configProperties, int... expectedStatus) throws ClientException, InterruptedException, TimeoutException
timeout
- Max time to wait for the configuration to be set, in msPID
- Persistent identity stringfactoryPID
- Factory persistent identity string or null
configProperties
- map of propertiesexpectedStatus
- expected response statusClientException
- if the response status does not match any of the expectedStatusInterruptedException
- to mark this operation as "waiting"TimeoutException
- if the timeout was reachedpublic SlingHttpResponse deleteConfiguration(String pid, int... expectedStatus) throws ClientException
pid
- pidexpectedStatus
- expected response statusClientException
- if the response status does not match any of the expectedStatuspublic SlingHttpResponse uninstallBundle(String symbolicName) throws ClientException
symbolicName
- bundle symbolic nameClientException
- if something went wrong with the requestpublic SlingHttpResponse installBundle(File f, boolean startBundle) throws ClientException
f
- the bundle filestartBundle
- whether to start the bundle or notClientException
- if the request failedpublic SlingHttpResponse installBundle(File f, boolean startBundle, int startLevel) throws ClientException
f
- bundle filestartBundle
- whether to start or just install the bundlestartLevel
- start levelClientException
- if the request failed@Deprecated public boolean checkBundleInstalled(String symbolicName, int waitTime, int retries) throws InterruptedException
waitBundleInstalled(String, long, long)
insteadsymbolicName
- the name of the bundlewaitTime
- How many milliseconds to wait between retriesretries
- the number of retriesInterruptedException
- if interrupted@Deprecated public boolean installBundleWithRetry(File f, boolean startBundle, int startLevel, int waitTime, int retries) throws ClientException, InterruptedException
f
- the bundle filestartBundle
- whether to start the bundle or notstartLevel
- the start level of the bundle. negative values mean default start levelwaitTime
- how long to wait between retries of checking the bundleretries
- how many times to check for the bundle to be installed, until giving upClientException
- if the request failedInterruptedException
- if interruptedpublic void waitInstallBundle(File f, boolean startBundle, int startLevel, long timeout, long delay) throws ClientException, InterruptedException, TimeoutException
f
- the bundle filestartBundle
- whether to start the bundle or notstartLevel
- the start level of the bundle. negative values mean default start leveltimeout
- how long to wait for the bundle to be installed before throwing a TimeoutException
in millisecondsdelay
- time to wait between checks of the state in millisecondsClientException
- if the request failedTimeoutException
- if the bundle did not install before timeout was reachedInterruptedException
- if interruptedpublic void waitBundleInstalled(String symbolicName, long timeout, long delay) throws TimeoutException, InterruptedException
symbolicName
- symbolic name of bundletimeout
- how long to wait for the bundle to be installed before throwing a TimeoutException
in millisecondsdelay
- time to wait between checks of the state in millisecondsTimeoutException
- if the bundle did not install before timeout was reachedInterruptedException
- if interruptedpublic void waitBundleStarted(String symbolicName, long timeout, long delay) throws TimeoutException, InterruptedException
symbolicName
- symbolic name of bundletimeout
- how long to wait for the bundle to be installed before throwing a TimeoutException
in milliseconds.delay
- time to wait between checks of the state in milliseconds.TimeoutException
- if the bundle did not install before timeout was reachedInterruptedException
- if interruptedpublic long getBundleId(String symbolicName) throws ClientException
symbolicName
- bundle symbolic nameClientException
- if the id cannot be retrievedpublic String getBundleVersion(String symbolicName) throws ClientException
symbolicName
- bundle symbolic nameClientException
- if the version is not retrievedpublic String getBundleState(String symbolicName) throws ClientException
symbolicName
- bundle symbolic nameClientException
- if the state cannot be retrievedpublic void startBundle(String symbolicName) throws ClientException
symbolicName
- the name of the bundleClientException
- if the request failedpublic void stopBundle(String symbolicName) throws ClientException
symbolicName
- the name of the bundleClientException
- if the request failed@Deprecated public void startBundlewithWait(String symbolicName, int waitTime, int retries) throws ClientException, InterruptedException
waitStartBundle(String, long, long)
symbolicName
- the name of the bundlewaitTime
- How many milliseconds to wait between retriesretries
- the number of retriesClientException
- if the request failedInterruptedException
- if interruptedpublic void waitStartBundle(String symbolicName, long timeout, long delay) throws ClientException, InterruptedException, TimeoutException
symbolicName
- the name of the bundletimeout
- max time to wait for the bundle to start, in msdelay
- time to wait between status checks, in msClientException
- if the request failedInterruptedException
- if interruptedTimeoutException
- if starting timed outpublic void refreshPackages() throws ClientException
ClientException
- if the request failedpublic static String getBundleSymbolicName(File bundleFile) throws IOException
bundleFile
- bundle fileIOException
- if reading the jar failedpublic static String getBundleVersionFromFile(File bundleFile) throws IOException
bundleFile
- bundle fileIOException
- if reading the bundle jar failedCopyright © 2007–2018 The Apache Software Foundation. All rights reserved.