Search in sources :

Example 6 with WebServiceParam

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);
}
Also used : WebServiceDefinition(io.vertigo.vega.webservice.metamodel.WebServiceDefinition) WebServiceParam(io.vertigo.vega.webservice.metamodel.WebServiceParam) ValidationUserException(io.vertigo.vega.webservice.validation.ValidationUserException) ExtendedObject(io.vertigo.vega.webservice.model.ExtendedObject) DtObject(io.vertigo.dynamo.domain.model.DtObject) UiObject(io.vertigo.vega.webservice.model.UiObject) UiMessageStack(io.vertigo.vega.webservice.validation.UiMessageStack)

Example 7 with WebServiceParam

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;
}
Also used : WebServiceDefinition(io.vertigo.vega.webservice.metamodel.WebServiceDefinition) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) WebServiceParam(io.vertigo.vega.webservice.metamodel.WebServiceParam) ArrayList(java.util.ArrayList)

Aggregations

WebServiceParam (io.vertigo.vega.webservice.metamodel.WebServiceParam)7 DtObject (io.vertigo.dynamo.domain.model.DtObject)4 WebServiceDefinition (io.vertigo.vega.webservice.metamodel.WebServiceDefinition)4 DtListState (io.vertigo.dynamo.domain.model.DtListState)2 ValidationUserException (io.vertigo.vega.webservice.validation.ValidationUserException)2 Type (java.lang.reflect.Type)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Home (io.vertigo.app.Home)1 DtList (io.vertigo.dynamo.domain.model.DtList)1 VUserException (io.vertigo.lang.VUserException)1 ClassUtil (io.vertigo.util.ClassUtil)1 WebServiceHandlerPlugin (io.vertigo.vega.impl.webservice.WebServiceHandlerPlugin)1 WebServices (io.vertigo.vega.webservice.WebServices)1 SessionException (io.vertigo.vega.webservice.exception.SessionException)1 VSecurityException (io.vertigo.vega.webservice.exception.VSecurityException)1 WebServiceDefinitionBuilder (io.vertigo.vega.webservice.metamodel.WebServiceDefinitionBuilder)1 WebServiceParamType (io.vertigo.vega.webservice.metamodel.WebServiceParam.WebServiceParamType)1 ExtendedObject (io.vertigo.vega.webservice.model.ExtendedObject)1