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();
}
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);
}
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;
}
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;
}
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;
}
Aggregations