Skip to content

Commit

Permalink
FISH-1274 Validate parameter name
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Pielage <[email protected]>
  • Loading branch information
Pandrex247 committed Apr 13, 2021
1 parent e7933ff commit ee5e35b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,11 @@ private boolean validateParameterName(List<Parameter> params) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOM_NAME(info.operation.getName(), param.getCustomName()));
return false;
}
// Custom name should be a valid variable name
if (!param.getCustomName().matches("^[_$a-zA-Z][_$\\w]*$")) {
error(param.getEntity(), "Invalid operation \"" + info.operation.getName() + "\", can't generate java method. Parameter,customized name \"" + param.getCustomName() + "\" is not a valid java variable name.");
return false;
}
return true;
}
//process doclit wrapper style
Expand All @@ -921,12 +926,22 @@ private boolean validateParameterName(List<Parameter> params) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_WRAPPER_STYLE(info.operation.getName(), param.getName(), param.getBlock().getName()));
return false;
}
// Custom name should be a valid variable name
if (!param.getCustomName().matches("^[_$a-zA-Z][_$\\w]*$")) {
error(param.getEntity(), "Invalid operation \"" + info.operation.getName() + "\", can't generate java method. Local name of the wrapper child \"" + param.getName() + "\" in the global element \"" + param.getBlock().getName() + "\" is not a valid java variable name. Use customization to change the parameter name.");
return false;
}
} else {
//non-wrapper style and rpclit
if (Names.isJavaReservedWord(param.getName())) {
error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_NON_WRAPPER_STYLE(info.operation.getName(), msg.getName(), param.getName()));
return false;
}
// Custom name should be a valid variable name
if (!param.getCustomName().matches("^[_$a-zA-Z][_$\\w]*$")) {
error(param.getEntity(), "Invalid operation \"" + info.operation.getName() + "\", can't generate java method. Parameter: part \"" + param.getName() + "\" in wsdl:message \"" + msg.getName() + "\" is not a valid java variable name. Use customization to change the parameter name.");
return false;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ protected boolean generateCode(Listener listener, Receiver receiver,

TJavaGeneratorExtension[] genExtn = ServiceFinder.find(TJavaGeneratorExtension.class).toArray();
CustomExceptionGenerator.generate(wsdlModel, options, receiver);
SeiGenerator.generate(wsdlModel, options, receiver, genExtn);
SeiGenerator.generate(wsdlModel, options, receiver, genExtn);
if(receiver.hadError()){
throw new AbortException();
}
Expand Down

0 comments on commit ee5e35b

Please sign in to comment.