use of io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed 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.AnonymousAccessAllowed 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.AnonymousAccessAllowed in project vertigo by KleeGroup.
the class SwaggerWebServices method getSwapperUi.
/**
* Return a swagger static resources.
* @param resourceUrl Resource name
* @param response HttpResponse
* @throws IOException Exception
*/
@SessionLess
@AnonymousAccessAllowed
@GET("/swaggerUi/{resourceUrl}")
public void getSwapperUi(@PathParam("resourceUrl") final String resourceUrl, final HttpServletResponse response) throws IOException {
FileUtil.checkUserFileName(resourceUrl);
// ----
if (resourceUrl.isEmpty()) {
response.sendRedirect("./index.html");
}
final URL url = SwaggerWebServices.class.getResource("/swagger-site/" + resourceUrl);
sendFile(url, resolveContentType(resourceUrl), response, resourceUrl);
}
use of io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed in project vertigo by KleeGroup.
the class ComponentCmdWebServices method getModuleConfig.
@AnonymousAccessAllowed
@GET("/vertigo/components/modules/{moduleName}")
public String getModuleConfig(@PathParam("moduleName") final String moduleName) {
Assertion.checkArgNotEmpty(moduleName);
// -----
final JsonArray jsonModuleConfigs = doGetModuleConfigs();
for (int i = 0; i < jsonModuleConfigs.size(); i++) {
final JsonObject jsonModuleConfig = (JsonObject) jsonModuleConfigs.get(i);
if (moduleName.equalsIgnoreCase(jsonModuleConfig.get("name").getAsString())) {
return jsonEngine.toJson(jsonModuleConfig);
}
}
throw new VSystemException("NotFoundException");
}
use of io.vertigo.vega.webservice.stereotype.AnonymousAccessAllowed in project vertigo by KleeGroup.
the class ComponentCmdWebServices method getComponentConfig.
@AnonymousAccessAllowed
@GET("/vertigo/components/{componentId}")
public String getComponentConfig(@PathParam("componentId") final String componentId) {
Assertion.checkArgNotEmpty(componentId);
// -----
final JsonArray jsonModuleConfigs = doGetModuleConfigs();
for (int i = 0; i < jsonModuleConfigs.size(); i++) {
final JsonObject jsonModuleConfig = (JsonObject) jsonModuleConfigs.get(i);
final JsonArray jsonComponentConfigs = jsonModuleConfig.get("componentConfigs").getAsJsonArray();
for (int j = 0; j < jsonComponentConfigs.size(); j++) {
final JsonObject jsonComponentConfig = (JsonObject) jsonComponentConfigs.get(j);
if (componentId.equalsIgnoreCase(jsonComponentConfig.get("id").getAsString())) {
return jsonEngine.toJson(jsonComponentConfig);
}
}
}
throw new VSystemException("NotFoundException");
}
Aggregations