public static void applyThemeForDomain(String themeName, UserRegistry systemTenantRegistry)
throws RegistryException {
String sourcePath = StratosConstants.ALL_THEMES_PATH + "/" + themeName; // tenant 0s path
String targetPath = THEME_PATH;
UserRegistry systemZeroRegistry = registryService.getGovernanceSystemRegistry();
// if the themes doesn't exist we would exclude applying it
if (!systemZeroRegistry.resourceExists(sourcePath)) {
log.info("The theme source path: " + sourcePath + " doesn't exist.");
return;
}
// first delete the old one, or we can backup it if required
// we are anyway getting a backup of the logo
Resource logoR = null;
String logoPath = targetPath + "/admin/" + "logo.gif";
if (systemTenantRegistry.resourceExists(targetPath)) {
if (systemTenantRegistry.resourceExists(logoPath)) {
logoR = systemTenantRegistry.get(logoPath);
}
if (logoR != null) {
logoR.getContent(); // we will load the content as well.
}
systemTenantRegistry.delete(targetPath);
}
// get a dump of source
Writer writer = new StringWriter();
systemZeroRegistry.dump(sourcePath, writer);
// put the dump to the target
Reader reader = new StringReader(writer.toString());
systemTenantRegistry.restore(targetPath, reader);