Search in sources :

Example 1 with IncludedFields

use of io.vertigo.vega.webservice.stereotype.IncludedFields in project vertigo by KleeGroup.

the class AnnotationsWebServiceScannerUtil method buildWebServiceDefinition.

private static Optional<WebServiceDefinition> buildWebServiceDefinition(final Method method) {
    final WebServiceDefinitionBuilder builder = WebServiceDefinition.builder(method);
    final PathPrefix pathPrefix = method.getDeclaringClass().getAnnotation(PathPrefix.class);
    if (pathPrefix != null) {
        builder.withPathPrefix(pathPrefix.value());
    }
    for (final Annotation annotation : method.getAnnotations()) {
        if (annotation instanceof GET) {
            builder.with(Verb.GET, ((GET) annotation).value());
        } else if (annotation instanceof POST) {
            builder.with(Verb.POST, ((POST) annotation).value());
        } else if (annotation instanceof PUT) {
            builder.with(Verb.PUT, ((PUT) annotation).value());
        } else if (annotation instanceof PATCH) {
            builder.with(Verb.PATCH, ((PATCH) annotation).value());
        } else if (annotation instanceof DELETE) {
            builder.with(Verb.DELETE, ((DELETE) annotation).value());
        } else if (annotation instanceof AnonymousAccessAllowed) {
            builder.withNeedAuthentication(false);
        } else if (annotation instanceof SessionLess) {
            builder.withNeedSession(false);
        } else if (annotation instanceof SessionInvalidate) {
            builder.withSessionInvalidate(true);
        } else if (annotation instanceof ExcludedFields) {
            builder.addExcludedFields(((ExcludedFields) annotation).value());
        } else if (annotation instanceof IncludedFields) {
            builder.addIncludedFields(((IncludedFields) annotation).value());
        } else if (annotation instanceof AccessTokenPublish) {
            builder.withAccessTokenPublish(true);
        } else if (annotation instanceof AccessTokenMandatory) {
            builder.withAccessTokenMandatory(true);
        } else if (annotation instanceof AccessTokenConsume) {
            builder.withAccessTokenMandatory(true);
            builder.withAccessTokenConsume(true);
        } else if (annotation instanceof ServerSideSave) {
            builder.withServerSideSave(true);
        } else if (annotation instanceof AutoSortAndPagination) {
            builder.withAutoSortAndPagination(true);
        } else if (annotation instanceof Doc) {
            builder.withDoc(((Doc) annotation).value());
        }
    }
    if (builder.hasVerb()) {
        final Type[] paramType = method.getGenericParameterTypes();
        final Annotation[][] parameterAnnotation = method.getParameterAnnotations();
        for (int i = 0; i < paramType.length; i++) {
            final WebServiceParam webServiceParam = buildWebServiceParam(parameterAnnotation[i], paramType[i]);
            builder.addWebServiceParam(webServiceParam);
        }
        // ---
        return Optional.of(builder.build());
    }
    return Optional.empty();
}
Also used : SessionLess(io.vertigo.vega.webservice.stereotype.SessionLess) IncludedFields(io.vertigo.vega.webservice.stereotype.IncludedFields) AutoSortAndPagination(io.vertigo.vega.webservice.stereotype.AutoSortAndPagination) AccessTokenMandatory(io.vertigo.vega.webservice.stereotype.AccessTokenMandatory) POST(io.vertigo.vega.webservice.stereotype.POST) ServerSideSave(io.vertigo.vega.webservice.stereotype.ServerSideSave) SessionInvalidate(io.vertigo.vega.webservice.stereotype.SessionInvalidate) Annotation(java.lang.annotation.Annotation) PUT(io.vertigo.vega.webservice.stereotype.PUT) PATCH(io.vertigo.vega.webservice.stereotype.PATCH) AccessTokenConsume(io.vertigo.vega.webservice.stereotype.AccessTokenConsume) AccessTokenPublish(io.vertigo.vega.webservice.stereotype.AccessTokenPublish) DELETE(io.vertigo.vega.webservice.stereotype.DELETE) WebServiceParamType(io.vertigo.vega.webservice.metamodel.WebServiceParam.WebServiceParamType) Type(java.lang.reflect.Type) WebServiceParam(io.vertigo.vega.webservice.metamodel.WebServiceParam) GET(io.vertigo.vega.webservice.stereotype.GET) WebServiceDefinitionBuilder(io.vertigo.vega.webservice.metamodel.WebServiceDefinitionBuilder) Doc(io.vertigo.vega.webservice.stereotype.Doc) AnonymousAccessAllowed(io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed) PathPrefix(io.vertigo.vega.webservice.stereotype.PathPrefix) ExcludedFields(io.vertigo.vega.webservice.stereotype.ExcludedFields)

Aggregations

WebServiceDefinitionBuilder (io.vertigo.vega.webservice.metamodel.WebServiceDefinitionBuilder)1 WebServiceParam (io.vertigo.vega.webservice.metamodel.WebServiceParam)1 WebServiceParamType (io.vertigo.vega.webservice.metamodel.WebServiceParam.WebServiceParamType)1 AccessTokenConsume (io.vertigo.vega.webservice.stereotype.AccessTokenConsume)1 AccessTokenMandatory (io.vertigo.vega.webservice.stereotype.AccessTokenMandatory)1 AccessTokenPublish (io.vertigo.vega.webservice.stereotype.AccessTokenPublish)1 AnonymousAccessAllowed (io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed)1 AutoSortAndPagination (io.vertigo.vega.webservice.stereotype.AutoSortAndPagination)1 DELETE (io.vertigo.vega.webservice.stereotype.DELETE)1 Doc (io.vertigo.vega.webservice.stereotype.Doc)1 ExcludedFields (io.vertigo.vega.webservice.stereotype.ExcludedFields)1 GET (io.vertigo.vega.webservice.stereotype.GET)1 IncludedFields (io.vertigo.vega.webservice.stereotype.IncludedFields)1 PATCH (io.vertigo.vega.webservice.stereotype.PATCH)1 POST (io.vertigo.vega.webservice.stereotype.POST)1 PUT (io.vertigo.vega.webservice.stereotype.PUT)1 PathPrefix (io.vertigo.vega.webservice.stereotype.PathPrefix)1 ServerSideSave (io.vertigo.vega.webservice.stereotype.ServerSideSave)1 SessionInvalidate (io.vertigo.vega.webservice.stereotype.SessionInvalidate)1 SessionLess (io.vertigo.vega.webservice.stereotype.SessionLess)1