}
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 =
((AxisOperation) ops.next()).getMessageReceiver();
isRpcMessageReceiver =
receiver instanceof RPCMessageReceiver || receiver instanceof RPCInOnlyMessageReceiver;
}
// If an RpcMessageReceiver is used, it does not make sense to store the WSDL in the AAR
if (!isRpcMessageReceiver) {
File wsdlF = new File(f.getAbsolutePath() + File.separator + "META-INF",
formatServiceName(axisService.getName()) + ".wsdl");
OutputStream wbOut = new FileOutputStream(wsdlF);
axisService.printWSDL(wbOut, NetworkUtils.getLocalHostname());
}
}
File fout = new File(workdir + File.separator + "dump_aar_output" + File.separator
+ uuid);
if(!fout.exists() && !fout.mkdirs()){
log.warn("Could not create " + fout.getAbsolutePath());
}
String outAARFilename = fout.getAbsolutePath() + File.separator +
formatServiceName(serviceGroupName) + ".aar";
am.archiveDir(outAARFilename, f.getPath());
// TODO : This is a hack. storing file resources in the super tenant config context
// this is because, currently File download servlet is only registered under super
// tenat. all other places like wsdl2code work using the super tenant CC
ConfigurationContext superTenantConfigContext = MessageContext