use of org.apache.sling.ide.osgi.OsgiClientException in project sling by apache.
the class HttpOsgiClient method getBundleVersion.
@Override
public Version getBundleVersion(String bundleSymbolicName) throws OsgiClientException {
GetMethod method = new GetMethod(repositoryInfo.appendPath("system/console/bundles.json"));
HttpClient client = getHttpClient();
try {
int result = client.executeMethod(method);
if (result != HttpStatus.SC_OK) {
throw new HttpException("Got status code " + result + " for call to " + method.getURI());
}
try (InputStream input = method.getResponseBodyAsStream();
Reader reader = new InputStreamReader(input, StandardCharsets.US_ASCII)) {
return getBundleVersionFromReader(bundleSymbolicName, reader);
}
} catch (IOException e) {
throw new OsgiClientException(e);
} finally {
method.releaseConnection();
}
}
use of org.apache.sling.ide.osgi.OsgiClientException in project sling by apache.
the class TracingOsgiClient method logInstallLocalBundle.
private void logInstallLocalBundle(InputStream input, String explodedBundleLocation) throws OsgiClientException {
Map<String, Object> props = new HashMap<>();
long start = System.currentTimeMillis();
if (input != null) {
props.put(CommandExecutionProperties.ACTION_TYPE, "InstallJarredBundle");
} else {
props.put(CommandExecutionProperties.ACTION_TYPE, "InstallLocalBundle");
}
props.put(CommandExecutionProperties.ACTION_TARGET, explodedBundleLocation);
props.put(CommandExecutionProperties.TIMESTAMP_START, start);
try {
if (input != null) {
osgiClient.installLocalBundle(input, explodedBundleLocation);
} else {
osgiClient.installLocalBundle(explodedBundleLocation);
}
props.put(CommandExecutionProperties.RESULT_TEXT, "OK");
props.put(CommandExecutionProperties.RESULT_STATUS, Boolean.TRUE);
} catch (Throwable t) {
props.put(CommandExecutionProperties.RESULT_TEXT, "FAILED");
props.put(CommandExecutionProperties.RESULT_STATUS, Boolean.FALSE);
props.put(CommandExecutionProperties.RESULT_THROWABLE, t);
if (t instanceof OsgiClientException) {
throw (OsgiClientException) t;
} else if (t instanceof Error) {
throw (Error) t;
} else if (t instanceof RuntimeException) {
throw (RuntimeException) t;
} else {
// should never happen
throw new Error(t);
}
} finally {
props.put(CommandExecutionProperties.TIMESTAMP_END, System.currentTimeMillis());
Event event = new Event(CommandExecutionProperties.REPOSITORY_TOPIC, props);
eventAdmin.postEvent(event);
}
}
Aggregations