1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.resources;
20
21 import javax.ws.rs.NotFoundException;
22 import org.apache.syncope.client.console.rest.BpmnProcessRestClient;
23 import org.apache.syncope.client.ui.commons.Constants;
24 import org.apache.syncope.common.lib.to.BpmnProcess;
25 import org.apache.wicket.request.resource.AbstractResource;
26 import org.apache.wicket.util.string.StringValue;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 abstract class AbstractBpmnProcessResource extends AbstractResource {
31
32 private static final long serialVersionUID = 5163553843196539019L;
33
34 protected static final Logger LOG = LoggerFactory.getLogger(AbstractBpmnProcessResource.class);
35
36 protected final BpmnProcessRestClient bpmnProcessRestClient;
37
38 protected AbstractBpmnProcessResource(final BpmnProcessRestClient bpmnProcessRestClient) {
39 this.bpmnProcessRestClient = bpmnProcessRestClient;
40 }
41
42 protected BpmnProcess getBpmnProcess(final Attributes attributes) {
43 StringValue modelId = attributes.getRequest().getQueryParameters().getParameterValue(Constants.MODEL_ID_PARAM);
44
45 BpmnProcess bpmnProcess = modelId == null || modelId.isNull()
46 ? null
47 : bpmnProcessRestClient.getDefinitions().stream().
48 filter(object -> modelId.toString().equals(object.getModelId())).findAny().orElse(null);
49 if (bpmnProcess == null) {
50 throw new NotFoundException("BPMN process with modelId " + modelId);
51 }
52
53 return bpmnProcess;
54 }
55 }