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.rest.cxf.service;
20  
21  import java.util.List;
22  import javax.ws.rs.core.Response;
23  import org.apache.syncope.common.lib.request.GroupCR;
24  import org.apache.syncope.common.lib.request.GroupUR;
25  import org.apache.syncope.common.lib.to.ExecTO;
26  import org.apache.syncope.common.lib.to.GroupTO;
27  import org.apache.syncope.common.lib.to.ProvisioningResult;
28  import org.apache.syncope.common.lib.types.ProvisionAction;
29  import org.apache.syncope.common.rest.api.service.GroupService;
30  import org.apache.syncope.core.logic.AbstractAnyLogic;
31  import org.apache.syncope.core.logic.GroupLogic;
32  import org.apache.syncope.core.persistence.api.dao.AnyDAO;
33  import org.apache.syncope.core.persistence.api.dao.GroupDAO;
34  import org.apache.syncope.core.persistence.api.search.SearchCondVisitor;
35  import org.springframework.stereotype.Service;
36  
37  @Service
38  public class GroupServiceImpl extends AbstractAnyService<GroupTO, GroupCR, GroupUR> implements GroupService {
39  
40      protected final GroupDAO groupDAO;
41  
42      protected final GroupLogic logic;
43  
44      public GroupServiceImpl(
45              final SearchCondVisitor searchCondVisitor,
46              final GroupDAO groupDAO,
47              final GroupLogic logic) {
48  
49          super(searchCondVisitor);
50          this.groupDAO = groupDAO;
51          this.logic = logic;
52      }
53  
54      @Override
55      protected AnyDAO<?> getAnyDAO() {
56          return groupDAO;
57      }
58  
59      @Override
60      protected AbstractAnyLogic<GroupTO, GroupCR, GroupUR> getAnyLogic() {
61          return logic;
62      }
63  
64      @Override
65      protected GroupUR newUpdateReq(final String key) {
66          return new GroupUR.Builder(key).build();
67      }
68  
69      @Override
70      public Response create(final GroupCR createReq) {
71          ProvisioningResult<GroupTO> created = logic.create(createReq, isNullPriorityAsync());
72          return createResponse(created);
73      }
74  
75      @Override
76      public Response update(final GroupUR updateReq) {
77          return doUpdate(updateReq);
78      }
79  
80      @Override
81      public List<GroupTO> own() {
82          return logic.own();
83      }
84  
85      @Override
86      public ExecTO provisionMembers(final String key, final ProvisionAction action) {
87          return logic.provisionMembers(key, action);
88      }
89  }