Commit 9a5e0a73 authored by Kevin Robert's avatar Kevin Robert
Browse files

UNOTOPLYS-205 : Utilisation du orElseThrow.

parent 0186019a
......@@ -120,13 +120,9 @@ public class FilArianeController {
final List<FilArianeElement> filAriane = new LinkedList<>();
if (PermissionService.currentUserHasAuthority(AuthoritiesConstants.AUTHORITY_VIEW_FORM)) {
final Optional<ScreenDTO> screenOptional = screenService.findOne(idScreen);
if (screenOptional.isPresent()) {
final ScreenDTO screen = screenOptional.get();
filAriane.add(new FilArianeElement(screen.getFormName(), Path.WORKSPACE + "/" + screen.getFormId()));
addFilArianeWorkspace(filAriane, screen.getFormId());
} else {
throw new FilArianeException("L'écran n'existe pas.");
}
final ScreenDTO screen = screenOptional.orElseThrow(() -> new FilArianeException("L'écran n'existe pas."));
filAriane.add(new FilArianeElement(screen.getFormName(), Path.WORKSPACE + "/" + screen.getFormId()));
addFilArianeWorkspace(filAriane, screen.getFormId());
}
filAriane.add(filArianeHome);
Collections.reverse(filAriane);
......@@ -142,12 +138,8 @@ public class FilArianeController {
private void addFilArianeWorkspace(final List<FilArianeElement> filAriane, final Long formId) {
if (PermissionService.currentUserHasAuthority(AuthoritiesConstants.AUTHORITY_VIEW_WORKSPACE)) {
final Optional<FormDTO> formOptional = formService.findOne(formId);
if (formOptional.isPresent()) {
final FormDTO form = formOptional.get();
filAriane.add(new FilArianeElement(form.getWorkspaceName(), Path.WORKSPACE + "/" + form.getWorkspaceId()));
} else {
throw new FilArianeException("Le formulaire n'existe pas.");
}
final FormDTO form = formOptional.orElseThrow(() -> new FilArianeException("Le formulaire n'existe pas."));
filAriane.add(new FilArianeElement(form.getWorkspaceName(), Path.WORKSPACE + "/" + form.getWorkspaceId()));
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment