return fileContents.toString();
}
private void setServiceFileHashInRegistry(String serviceGroupName, String hash)
throws Exception {
Registry registry = this.getConfigSystemRegistry();
if (registry == null) {
throw new Exception("WSO2 Registry is not available");
}
boolean transactionStarted = Transaction.isStarted();
try {
if (transactionStarted) {
registry.beginTransaction();
}
String serviceResourcePath = RegistryResources.SERVICE_GROUPS + serviceGroupName;
/* the resource should already exist */
if (registry.resourceExists(serviceResourcePath)) {
Resource serviceResource = registry.get(serviceResourcePath);
serviceResource.setProperty(RegistryResources.ServiceGroupProperties.HASH_VALUE,
hash);
registry.put(serviceResourcePath, serviceResource);
serviceResource.discard();
}
if (transactionStarted) {
registry.commitTransaction();
}
} catch (Throwable e) {
if (transactionStarted) {
registry.rollbackTransaction();
}
log.error("Unable to set the hash value property to service group "
+ serviceGroupName);
throw new Exception(e);
}