|
|
@ -108,25 +108,29 @@ public abstract class AbstractService {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
* @throws AxisFault
|
|
|
|
* @throws AxisFault
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected byte[] writeTemplate(String templateName, serverObjects args)
|
|
|
|
protected byte[] writeTemplate(String templateName, serverObjects args) throws AxisFault {
|
|
|
|
throws AxisFault {
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// determining the proper class that should be invoked
|
|
|
|
// invoke servlet
|
|
|
|
File file = new File(this.rootPath, templateName);
|
|
|
|
serverObjects tp = invokeServlet(templateName,args);
|
|
|
|
File rc = rewriteClassFile(file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// invoke the desired method
|
|
|
|
// generate output
|
|
|
|
serverObjects tp = (serverObjects) rewriteMethod(rc).invoke(null, new Object[] {this.requestHeader, args, this.switchboard});
|
|
|
|
byte[] result = buildServletOutput(templateName, tp);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
if (e instanceof AxisFault) throw (AxisFault) e;
|
|
|
|
|
|
|
|
|
|
|
|
// testing if a authentication was needed by the invoked method
|
|
|
|
// create a new AxisFault Object
|
|
|
|
validateAuthentication(tp);
|
|
|
|
throw new AxisFault(e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// adding all available templates
|
|
|
|
protected byte[] buildServletOutput(String templateName, serverObjects tp) throws AxisFault {
|
|
|
|
tp.putAll(this.templates);
|
|
|
|
try {
|
|
|
|
|
|
|
|
File templateFile = getTemplateFile(templateName);
|
|
|
|
|
|
|
|
|
|
|
|
// generating the output document
|
|
|
|
// generating the output document
|
|
|
|
ByteArrayOutputStream o = new ByteArrayOutputStream();
|
|
|
|
ByteArrayOutputStream o = new ByteArrayOutputStream();
|
|
|
|
FileInputStream fis = new FileInputStream(file);
|
|
|
|
FileInputStream fis = new FileInputStream(templateFile);
|
|
|
|
httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
|
|
|
|
httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
|
|
|
|
o.close();
|
|
|
|
o.close();
|
|
|
|
fis.close();
|
|
|
|
fis.close();
|
|
|
@ -135,10 +139,54 @@ public abstract class AbstractService {
|
|
|
|
byte[] result = o.toByteArray();
|
|
|
|
byte[] result = o.toByteArray();
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
if (e instanceof AxisFault) throw (AxisFault) e;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create a new AxisFault Object
|
|
|
|
|
|
|
|
throw new AxisFault(e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected serverObjects invokeServlet(String templateName, serverObjects args) throws AxisFault {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// getting the template class file
|
|
|
|
|
|
|
|
File rc = getServletClassFile(templateName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// invoke the desired method
|
|
|
|
|
|
|
|
serverObjects tp = (serverObjects) rewriteMethod(rc).invoke(null, new Object[] {this.requestHeader, args, this.switchboard});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// testing if a authentication was needed by the invoked method
|
|
|
|
|
|
|
|
validateAuthentication(tp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// adding all available templates
|
|
|
|
|
|
|
|
tp.putAll(this.templates);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return result
|
|
|
|
|
|
|
|
return tp;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
if (e instanceof AxisFault) throw (AxisFault) e;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create a new AxisFault Object
|
|
|
|
throw new AxisFault(e.getMessage());
|
|
|
|
throw new AxisFault(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected File getTemplateFile(String templateName) {
|
|
|
|
|
|
|
|
// determining the proper class that should be invoked
|
|
|
|
|
|
|
|
File file = new File(this.rootPath, templateName);
|
|
|
|
|
|
|
|
return file;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected File getServletClassFile(String templateName) {
|
|
|
|
|
|
|
|
File templateFile = getTemplateFile(templateName);
|
|
|
|
|
|
|
|
File templateClassFile = getServletClassFile(templateFile);
|
|
|
|
|
|
|
|
return templateClassFile;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected File getServletClassFile(File templateFile) {
|
|
|
|
|
|
|
|
File templateClassFile = rewriteClassFile(templateFile);
|
|
|
|
|
|
|
|
return templateClassFile;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This function is used to test if an invoked method requires authentication
|
|
|
|
* This function is used to test if an invoked method requires authentication
|
|
|
|