use of io.vertigo.vega.webservice.stereotype.ServerSideSave 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.ServerSideSave in project vertigo by KleeGroup.
the class AdvancedTestWebServices method testInnerBody.
@Doc("Test ws returning UiContext. Send a body with an object of to field : contactId1, contactId2. Each one should be an json of long. You get partial Contacts with clientId in each one")
@ServerSideSave
@ExcludedFields({ "conId", "email", "birthday", "address", "tels" })
@POST("/uiContext")
public UiContext testInnerBody(@InnerBodyParam("contactId1") final long contactIdFrom, @InnerBodyParam("contactId2") final long contactIdTo) {
final UiContext uiContext = new UiContext();
uiContext.put("contactFrom", contactDao.get(contactIdFrom));
uiContext.put("contactTo", contactDao.get(contactIdTo));
uiContext.put("testLong", 12);
uiContext.put("testString", "the String test");
uiContext.put("testDate", DateUtil.newDate());
uiContext.put("testEscapedString", "the EscapedString \",} test");
// code 200
return uiContext;
}
Aggregations