treatParam(p);
}
}
// get the http method name and the request name
MethodNode thisRequestsMethod = ((MethodNode) request.getParent());
String httpMethodName = thisRequestsMethod.getName();
String absoluteAddress = null;
String name = null;
Object thisRequestsMethodsParent = (Object) thisRequestsMethod.getParent();
if (thisRequestsMethodsParent instanceof ResourceNode) {
ResourceNode resource = (ResourceNode) thisRequestsMethodsParent;
name = resource.getPath();
absoluteAddress = resource.getAbsolutePath() + resource.getPath();
// check if we have template parameters
while (resource.getPath().matches(Analyzer.templateParamRegExp)) {
// don't confuse: param is from the WADL, parameter is for code generation
String path = resource.getPath();
int indexOfOpen = path.indexOf(Analyzer.templateParamOpenChar);
int indexOfClose = path.indexOf(Analyzer.templateParamCloseChar);
while(indexOfOpen >= 0 &&
indexOfClose > 0 &&
indexOfOpen < indexOfClose) {
String templateParamName = path.substring(indexOfOpen + 1, indexOfClose);
// from all the potential params find the one that matches the template {name}
Vector templateParams = resource.getAllParams();
Iterator templateParamsIterator = templateParams.iterator();
ParamNode templateParam = null;
if (templateParamsIterator.hasNext()) {
templateParam = (ParamNode) templateParamsIterator.next();
}
while(!templateParam.getName().equals(templateParamName)) {
templateParam = (ParamNode) templateParamsIterator.next();
}
// now generate the code generation parameter
Parameter templateParameter = new Parameter(
templateParamName + SettingsDialog.templateSuffix,
templateParam.getType(),
Parameter.accessPrivate,
templateParam.getIsRequired(),
language,
true);
variables.insertElementAt(templateParameter, 0);
path = path.substring(indexOfClose + 1);
indexOfOpen = path.indexOf(Analyzer.templateParamOpenChar);
indexOfClose = path.indexOf(Analyzer.templateParamCloseChar);
}
if (resource.getParent().getParent() instanceof ResourceNode) {
resource = (ResourceNode) resource.getParent().getParent();
}
else {
break;
}
}
}
else if (thisRequestsMethodsParent instanceof ResourceTypeNode) {
// TODO
}
else if (thisRequestsMethodsParent instanceof ApplicationNode) {
// find the reference method of this referenced method
getMethodById(
application.getResources(),
thisRequestsMethod.getId(),
httpMethodName,
request);
return;
}