Search in sources :

Example 1 with GET

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

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

the class FileDownloadWebServices method testDownloadFile.

@AnonymousAccessAllowed
@GET("/downloadFileContentType")
public VFile testDownloadFile(@QueryParam("id") final Integer id) {
    final URL imageUrl = resourcetManager.resolve("npi2loup.png");
    final File imageFile = asFile(imageUrl);
    return fileManager.createFile("image" + id + generateSpecialChars(id) + ".png", "image/png", imageFile);
}
Also used : VFile(io.vertigo.dynamo.file.model.VFile) File(java.io.File) URL(java.net.URL) GET(io.vertigo.vega.webservice.stereotype.GET) AnonymousAccessAllowed(io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed)

Example 3 with GET

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

the class AdvancedTestWebServices method testExportContact.

@GET("/export/pdf/{conId}")
public VFile testExportContact(@PathParam("conId") final long conId) throws URISyntaxException {
    final URL tempFile = resourcetManager.resolve("io/vertigo/vega/webservice/data/ws/contact2.pdf");
    final VFile result = fileManager.createFile(new File(tempFile.toURI()));
    // 200
    return result;
}
Also used : VFile(io.vertigo.dynamo.file.model.VFile) File(java.io.File) URL(java.net.URL) VFile(io.vertigo.dynamo.file.model.VFile) GET(io.vertigo.vega.webservice.stereotype.GET)

Example 4 with GET

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

the class AdvancedTestWebServices method testGetExtended.

@GET("/contactExtended/{conId}")
public ExtendedObject<Contact> testGetExtended(@PathParam("conId") final long conId) {
    final Contact contact = contactDao.get(conId);
    final ExtendedObject<Contact> result = new ExtendedObject<>(contact);
    result.put("vanillaUnsupportedMultipleIds", new int[] { 1, 2, 3 });
    // 200
    return result;
}
Also used : ExtendedObject(io.vertigo.vega.webservice.model.ExtendedObject) Contact(io.vertigo.vega.webservice.data.domain.Contact) GET(io.vertigo.vega.webservice.stereotype.GET)

Example 5 with GET

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

the class AdvancedTestWebServices method testDownloadFile.

@GET("/downloadFile")
public VFile testDownloadFile(@QueryParam("id") final Integer id) {
    final URL imageUrl = resourcetManager.resolve("npi2loup.png");
    final File imageFile = asFile(imageUrl);
    final VFile imageVFile = fileManager.createFile("image" + id + ".png", "image/png", imageFile);
    return imageVFile;
}
Also used : VFile(io.vertigo.dynamo.file.model.VFile) File(java.io.File) URL(java.net.URL) VFile(io.vertigo.dynamo.file.model.VFile) GET(io.vertigo.vega.webservice.stereotype.GET)

Aggregations

GET (io.vertigo.vega.webservice.stereotype.GET)12 AnonymousAccessAllowed (io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed)5 URL (java.net.URL)5 VFile (io.vertigo.dynamo.file.model.VFile)4 File (java.io.File)4 Contact (io.vertigo.vega.webservice.data.domain.Contact)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 VSystemException (io.vertigo.lang.VSystemException)2 SessionLess (io.vertigo.vega.webservice.stereotype.SessionLess)2 DtList (io.vertigo.dynamo.domain.model.DtList)1 VUserException (io.vertigo.lang.VUserException)1 UiContext (io.vertigo.vega.engines.webservice.json.UiContext)1 Address (io.vertigo.vega.webservice.data.domain.Address)1 ContactView (io.vertigo.vega.webservice.data.domain.ContactView)1 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 ExtendedObject (io.vertigo.vega.webservice.model.ExtendedObject)1 AccessTokenConsume (io.vertigo.vega.webservice.stereotype.AccessTokenConsume)1