use of io.vertigo.vega.webservice.metamodel.WebServiceParam in project vertigo by KleeGroup.
the class ValidatorWebServiceHandlerPlugin method handle.
/**
* {@inheritDoc}
*/
@Override
public Object handle(final Request request, final Response response, final WebServiceCallContext routeContext, final HandlerChain chain) throws SessionException {
final WebServiceDefinition webServiceDefinition = routeContext.getWebServiceDefinition();
final UiMessageStack uiMessageStack = routeContext.getUiMessageStack();
for (final WebServiceParam webServiceParam : webServiceDefinition.getWebServiceParams()) {
final Object value = routeContext.getParamValue(webServiceParam);
validateParam(value, uiMessageStack, webServiceParam, routeContext);
}
if (uiMessageStack.hasErrors()) {
throw new ValidationUserException();
}
return chain.handle(request, response, routeContext);
}
use of io.vertigo.vega.webservice.metamodel.WebServiceParam in project vertigo by KleeGroup.
the class CatalogWebServices method publishCatalog.
private static List<String> publishCatalog(final Collection<WebServiceDefinition> webServiceDefinitions) {
final List<String> result = new ArrayList<>();
final StringBuilder sb = new StringBuilder();
for (final WebServiceDefinition webServiceDefinition : webServiceDefinitions) {
final String doc = webServiceDefinition.getDoc();
if (!doc.isEmpty()) {
sb.append(" /*").append(webServiceDefinition.getDoc()).append("*/").append('\n');
}
sb.append(webServiceDefinition.getVerb().name()).append(' ').append(webServiceDefinition.getPath()).append(" (");
String sep = "";
for (final WebServiceParam webServiceParam : webServiceDefinition.getWebServiceParams()) {
sb.append(sep);
sb.append(webServiceParam);
sep = ", ";
}
sb.append(')');
final Type returnType = webServiceDefinition.getMethod().getGenericReturnType();
if (!void.class.isAssignableFrom(webServiceDefinition.getMethod().getReturnType())) {
sb.append(" -> ");
appendTypeToString(sb, returnType);
}
result.add(sb.toString());
sb.setLength(0);
}
return result;
}
Aggregations