use of com.mercedesbenz.sechub.docgen.usecase.UseCaseModel.UseCaseEntry in project sechub by mercedes-benz.
the class UseCaseModelDataCollector method collectAnnotationInfo.
private <T extends Annotation> void collectAnnotationInfo(UseCaseModel model, Class<T> useCaseAnnotationClazz) {
if (DEBUG) {
LOG.info("start collecting annotation info:{}", useCaseAnnotationClazz);
}
Set<Method> methodsAnnotated = reflections.getMethodsAnnotatedWith(useCaseAnnotationClazz);
if (DEBUG) {
LOG.info("found methods annotated with:{} - {}", useCaseAnnotationClazz, methodsAnnotated);
}
for (Method method : methodsAnnotated) {
List<RolesAllowed> rolesAllowed = fetchAllAllowedRoles(method);
T[] annosFound = method.getAnnotationsByType(useCaseAnnotationClazz);
if (DEBUG) {
LOG.info("inspect method:{}\n - roles found:{}\n - annos found:{}", method, rolesAllowed, annosFound);
}
for (T anno : annosFound) {
UseCaseEntry useCaseEntry = model.ensureUseCase(anno.getClass());
try {
Method valueMethod = anno.getClass().getMethod("value");
Object value = valueMethod.invoke(anno);
if (value instanceof Step) {
String location = "method `" + method.getName() + "` in class `" + method.getDeclaringClass().getName() + "`";
useCaseEntry.addStep((Step) value, rolesAllowed, location);
}
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}
}
use of com.mercedesbenz.sechub.docgen.usecase.UseCaseModel.UseCaseEntry in project sechub by mercedes-benz.
the class UseCaseRestDocModelAsciiDocGenerator method createEntriesForGroup.
private void createEntriesForGroup(UseCaseRestDocModel model, Context context, List<List<UseCaseRestDocEntry>> found, SortedSet<UseCaseEntry> entriesForGroup, StringBuilder linksToRestDocs) {
for (UseCaseEntry entry : entriesForGroup) {
if (!context.usecasesToInspect.contains(entry.getIdentifierEnumName())) {
continue;
}
entry.getIdentifierEnumName();
List<UseCaseRestDocEntry> restDocEntries = model.getRestDocEntries(entry);
if (restDocEntries == null || restDocEntries.isEmpty()) {
continue;
/* use case has no rest doc so ignore */
}
linksToRestDocs.append("- " + UseCaseAsciiDocFactory.createLinkToUseCaseRestDoc(entry, "REST API for " + entry.getId() + "-" + entry.getTitle()) + "\n");
found.add(restDocEntries);
}
}
Aggregations