use of com.twinsoft.convertigo.beans.core.UrlMappingParameter.Type in project convertigo by convertigo.
the class AbstractRestOperation method addParameter.
@Override
protected void addParameter(UrlMappingParameter parameter) throws EngineException {
List<UrlMappingParameter> l = getParameterList();
if (hasBodyParameter) {
Type type = parameter.getType();
if (type != Type.Path && type != Type.Header) {
if (type == Type.Body) {
throw new EngineException("The REST operation already contains a 'body' parameter");
} else {
if (!isChangeTo || (isChangeTo && l.size() != 1)) {
throw new EngineException("The REST operation contains a 'body' parameter. You can only add 'header' parameters");
}
}
}
} else if (parameter.getType() == Type.Body) {
for (UrlMappingParameter param : l) {
Type type = param.getType();
if (type == Type.Query || type == Type.Form) {
if (!isChangeTo || (isChangeTo && l.size() != 1)) {
throw new EngineException("The REST operation contains a '" + type + "' parameter. You can not add a 'body' parameter");
}
}
}
}
super.addParameter(parameter);
if (!hasBodyParameter && parameter.getType() == Type.Body) {
hasBodyParameter = true;
}
}
use of com.twinsoft.convertigo.beans.core.UrlMappingParameter.Type in project convertigo by convertigo.
the class AbstractRestOperation method canAddParameter.
@Override
protected boolean canAddParameter(UrlMappingParameter parameter) {
Type type = parameter.getType();
String method = getMethod();
if (method.equalsIgnoreCase(HttpMethodType.GET.name()) || method.equalsIgnoreCase(HttpMethodType.HEAD.name()) || method.equalsIgnoreCase(HttpMethodType.DELETE.name())) {
if (type != Type.Path && type != Type.Query && type != Type.Header) {
return false;
}
}
return true;
}
Aggregations