use of org.wso2.carbon.localentry.LocalEntryAdminException in project carbon-apimgt by wso2.
the class GoogleAnalyticsConfigDeployer method deployAsLocalEntry.
private void deployAsLocalEntry(CloseableHttpResponse closeableHttpResponse, LocalEntryServiceProxy localEntryServiceProxy) throws IOException, ArtifactSynchronizerException {
if (closeableHttpResponse.getStatusLine().getStatusCode() == 200) {
try (InputStream content = closeableHttpResponse.getEntity().getContent()) {
MessageContext.setCurrentMessageContext(GatewayUtils.createAxis2MessageContext());
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
String resourceContent = IOUtils.toString(content);
if (localEntryServiceProxy.localEntryExists(APIConstants.GA_CONF_KEY)) {
localEntryServiceProxy.deleteEntry(APIConstants.GA_CONF_KEY);
}
DataHolder.getInstance().addGoogleAnalyticsConfig(tenantDomain, resourceContent);
localEntryServiceProxy.addLocalEntry("<localEntry key=\"" + APIConstants.GA_CONF_KEY + "\">" + resourceContent + "</localEntry>");
} catch (LocalEntryAdminException e) {
log.error("Error while deploying LocalEntry ga-config", e);
} finally {
MessageContext.destroyCurrentMessageContext();
PrivilegedCarbonContext.endTenantFlow();
}
} else {
throw new ArtifactSynchronizerException("Error while deploying localEntry status code : " + closeableHttpResponse.getStatusLine().getStatusCode());
}
}
Aggregations