+ "The repository in use is " + axis2Repo;
log.error(message);
throw new AxisFault(message);
}
String uuid = String.valueOf(System.currentTimeMillis() + Math.random()) + ".aar";
AxisServiceGroup axisServiceGroup = configurationContext.getAxisConfiguration()
.getServiceGroup(serviceGroupName);
if (axisServiceGroup == null) {
String error = "Service group " + serviceGroupName + " not found!";
log.error(error);
throw new AxisFault(error);
}
//TODO until a proper way to find the service type from Axis2, following workaround has
// TODO been applied to JIRA - 378
if (serviceGroupName.indexOf(".jar") > -1 || serviceGroupName.indexOf(".class") > -1) {
String message = "Archive creation not supported for " + serviceGroupName;
log.error(message);
throw new AxisFault(message);
}
URL axisServiceGroupURL = null;
// Filtering axis1 services and data services from creating archives
//TODO AxisServiceGroup should have a getFileURL method;
for (Iterator iterator = axisServiceGroup.getServices(); iterator.hasNext();) {
AxisService as = (AxisService) iterator.next();
for (Parameter parameter : as.getParameters()) {
String name = parameter.getName();
Object obj = parameter.getValue();
String value = "";
if (obj != null) {
value = obj.toString();
}
if (name.equals("serviceType")
&& (value.equals("axis1") ||
value.equals("data_service") ||
value.equals("jaxws") ||
value.equals("proxy") ||
value.equals("bpel") ||
value.equals("bpelmgt"))) {
String message = "WSO2 Carbon does not "
+ "support creating archive for " + value + " services.";
log.warn(message);
throw new AxisFault(message);
}
}
if (axisServiceGroupURL == null) {
if (as.getFileName() == null) {
String msg = "Request to create a service archive file for a " +
"service group not found in side repo";
log.warn(msg);
throw new AxisFault(msg);
}
axisServiceGroupURL = as.getFileName();
}
}
if (axisServiceGroupURL == null) {
String error = ServiceArchiveCreator.class.getName() + " AxisServiceGroup "
+ serviceGroupName + " location couldn't be found.";
log.error(error);
throw new AxisFault(error);
}
String workdir = (String) configurationContext.getProperty(ServerConstants.WORK_DIR);
if (workdir == null) {
String msg = "Work dir does not exist. Please make sure that the " +
ServerConstants.WORK_DIR + " property points to a proper workdir.";
log.error(msg);
throw new AxisFault(msg);
}
File f = new File(workdir + File.separator + "dump_aar" + File.separator + uuid);
if (!f.exists() && !f.mkdirs()) {
log.warn("Could not create " + f.getAbsolutePath());
}
try {
File file = new File(axisServiceGroupURL.getPath());
ArchiveManipulator am = new ArchiveManipulator();
if (file.isDirectory()) {
FileManipulator.copyDir(file, f);
} else if (file.isFile() && axisServiceGroupURL.getPath().endsWith(".class")) {
FileManipulator.copyFileToDir(file, f);
} else {
am.extract(axisServiceGroupURL.getPath(), f.getAbsolutePath());
}
File servicesF =
new File(f.getAbsolutePath() + File.separator + "META-INF", "services.xml");
String servicesXmlPath = servicesF.getAbsolutePath();
// delete the existing services.xml file
if (servicesF.exists() && !servicesF.delete()) {
log.warn("Could not delete the existing services.xml at : " +
servicesF.getAbsolutePath());
}
// create the new serices.xml file using the created xml infoset
File newServicesXml = new File(servicesXmlPath);
OMElement axisServiceGroupXMLInfoset = createServiceGroupXMLInfoset(axisServiceGroup);
OutputStream os = new FileOutputStream(newServicesXml);
axisServiceGroupXMLInfoset.serializeAndConsume(os);
File[] oldWsdls = f.listFiles(new FileFilter() {
public boolean accept(File fw) {
return fw.getName().endsWith(".wsdl");
}
});
if (oldWsdls != null) {
for (int i = 0; i < oldWsdls.length; i++) {
File oldWsdl = oldWsdls[i];
if (oldWsdl.exists() && !oldWsdl.delete()) {
log.warn("Could not delete " + oldWsdl.getAbsolutePath());
}
}
}
//Creating wsdls
for (Iterator iterator = axisServiceGroup.getServices(); iterator.hasNext();) {
AxisService axisService = (AxisService) iterator.next();
boolean isRpcMessageReceiver = false;
for (Iterator ops = axisService.getOperations(); ops.hasNext();) {
MessageReceiver receiver =