Search in sources :

Example 1 with PUT

use of io.vertigo.vega.webservice.stereotype.PUT 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)

Example 2 with PUT

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

the class SimplerTestWebServices method putLocalDate.

@PUT("/localDate")
public UiContext putLocalDate(@QueryParam("date") final LocalDate localDate) {
    final UiContext result = new UiContext();
    result.put("input", localDate);
    result.put("inputAsString", localDate.toString());
    return result;
}
Also used : UiContext(io.vertigo.vega.engines.webservice.json.UiContext) PUT(io.vertigo.vega.webservice.stereotype.PUT)

Example 3 with PUT

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

the class SimplerTestWebServices method putInstant.

@PUT("/instant")
public UiContext putInstant(@QueryParam("date") final Instant instant) {
    final UiContext result = new UiContext();
    result.put("input", instant);
    result.put("inputAsString", instant.toString());
    return result;
}
Also used : UiContext(io.vertigo.vega.engines.webservice.json.UiContext) PUT(io.vertigo.vega.webservice.stereotype.PUT)

Example 4 with PUT

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

the class SimplerTestWebServices method putZonedDateTime.

@PUT("/zonedDateTime")
public UiContext putZonedDateTime(@QueryParam("date") final ZonedDateTime zonedDateTime) {
    final UiContext result = new UiContext();
    result.put("input", zonedDateTime);
    result.put("inputAsString", zonedDateTime.toString());
    return result;
}
Also used : UiContext(io.vertigo.vega.engines.webservice.json.UiContext) PUT(io.vertigo.vega.webservice.stereotype.PUT)

Aggregations

PUT (io.vertigo.vega.webservice.stereotype.PUT)4 UiContext (io.vertigo.vega.engines.webservice.json.UiContext)3 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 PathPrefix (io.vertigo.vega.webservice.stereotype.PathPrefix)1 ServerSideSave (io.vertigo.vega.webservice.stereotype.ServerSideSave)1 SessionInvalidate (io.vertigo.vega.webservice.stereotype.SessionInvalidate)1