View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.core.logic;
20  
21  import java.io.OutputStream;
22  import java.lang.reflect.Method;
23  import java.util.List;
24  import org.apache.syncope.common.lib.to.BpmnProcess;
25  import org.apache.syncope.common.lib.types.BpmnProcessFormat;
26  import org.apache.syncope.common.lib.types.FlowableEntitlement;
27  import org.apache.syncope.core.flowable.api.BpmnProcessManager;
28  import org.springframework.security.access.prepost.PreAuthorize;
29  import org.springframework.transaction.annotation.Transactional;
30  
31  public class BpmnProcessLogic extends AbstractTransactionalLogic<BpmnProcess> {
32  
33      protected final BpmnProcessManager bpmnProcessManager;
34  
35      public BpmnProcessLogic(final BpmnProcessManager bpmnProcessManager) {
36          this.bpmnProcessManager = bpmnProcessManager;
37      }
38  
39      @PreAuthorize("isAuthenticated()")
40      @Transactional(readOnly = true)
41      public List<BpmnProcess> list() {
42          return bpmnProcessManager.getProcesses();
43      }
44  
45      @PreAuthorize("hasRole('" + FlowableEntitlement.BPMN_PROCESS_GET + "')")
46      @Transactional(readOnly = true)
47      public void exportDefinition(final String key, final BpmnProcessFormat format, final OutputStream os) {
48          bpmnProcessManager.exportProcess(key, format, os);
49      }
50  
51      @PreAuthorize("hasRole('" + FlowableEntitlement.BPMN_PROCESS_GET + "')")
52      @Transactional(readOnly = true)
53      public void exportDiagram(final String key, final OutputStream os) {
54          bpmnProcessManager.exportDiagram(key, os);
55      }
56  
57      @PreAuthorize("hasRole('" + FlowableEntitlement.BPMN_PROCESS_SET + "')")
58      public void importDefinition(final String key, final BpmnProcessFormat format, final String definition) {
59          bpmnProcessManager.importProcess(key, format, definition);
60      }
61  
62      @PreAuthorize("hasRole('" + FlowableEntitlement.BPMN_PROCESS_DELETE + "')")
63      public void delete(final String key) {
64          bpmnProcessManager.deleteProcess(key);
65      }
66  
67      @Override
68      protected BpmnProcess resolveReference(final Method method, final Object... args)
69              throws UnresolvedReferenceException {
70  
71          throw new UnresolvedReferenceException();
72      }
73  }