ServiceDescriptionSerializer.serializeToServiceXML(
ruleServiceDescription, parent, AXIOM_XPATH_SERIALIZER);
servicesXML.build();
servicesXML.serialize(os);
} catch (Exception e) {
throw new RuleServiceManagementException("Cannot write services XML", e, log);
}
} else {
if (serviceXMLFile.exists()) {
serviceXMLFile.delete();
}
}
String rslFileName = ruleServiceDescription.getName() + "." +
RuleConstants.RULE_FILE_EXTENSION;
File ruleFile = new File(paths.getWorkingDirPath() + File.separator + "META-INF" +
File.separator + rslFileName);
File absoluteFile = ruleFile.getAbsoluteFile();
if (absoluteFile.exists()) {
absoluteFile.delete();
}
try {
absoluteFile.createNewFile();
} catch (IOException e) {
throw new RuleServiceManagementException("Error creating a rule service file : " +
absoluteFile, log);
}
try {
OutputStream os = new FileOutputStream(ruleFile);
OMElement ruleServiceXML =
ServiceDescriptionSerializer.serializeToRuleServiceConfiguration(
ruleServiceDescription, NULL_NS,
AXIOM_XPATH_SERIALIZER, CONFIGURATION_EXTENSION_SERIALIZER);
ruleServiceXML.build();
ruleServiceXML.serialize(os);
} catch (Exception e) {
throw new RuleServiceManagementException("Cannot write to the rule service file : " +
ruleFile, e, log);
}
ArchiveManipulator archiveManipulator = new ArchiveManipulator();
try {
String servicePath = paths.getServicePath();
if (!servicePath.endsWith(RuleConstants.RULE_SERVICE_ARCHIVE_EXTENSION)) {
File serviceFile = new File(servicePath);
File absoluteServiceFile = serviceFile.getAbsoluteFile();
if (absoluteServiceFile.exists()) {
absoluteServiceFile.delete();
}
servicePath = servicePath.substring(0, servicePath.lastIndexOf(".") + 1) +
RuleConstants.RULE_SERVICE_ARCHIVE_EXTENSION;
}
archiveManipulator.archiveDir(servicePath, paths.getWorkingDirPath());
} catch (IOException e) {
throw new RuleServiceManagementException("Error creating a archive a rule service ", e,
log);
}
// saveToRegistry(paths, ruleServiceDescription.getName());
cleanUp(paths);
}