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.keymaster.rest.cxf.service;
20  
21  import java.net.URI;
22  import java.util.List;
23  import javax.ws.rs.core.Context;
24  import javax.ws.rs.core.Response;
25  import javax.ws.rs.core.UriInfo;
26  import org.apache.syncope.common.keymaster.client.api.model.Domain;
27  import org.apache.syncope.common.keymaster.rest.api.service.DomainService;
28  import org.apache.syncope.common.lib.types.CipherAlgorithm;
29  import org.apache.syncope.common.rest.api.RESTHeaders;
30  import org.apache.syncope.core.logic.DomainLogic;
31  import org.springframework.stereotype.Service;
32  
33  @Service
34  public class DomainServiceImpl implements DomainService {
35  
36      private static final long serialVersionUID = -375255764389240615L;
37  
38      @Context
39      protected UriInfo uriInfo;
40  
41      protected final DomainLogic logic;
42  
43      public DomainServiceImpl(final DomainLogic logic) {
44          this.logic = logic;
45      }
46  
47      @Override
48      public List<Domain> list() {
49          return logic.list();
50      }
51  
52      @Override
53      public Domain read(final String key) {
54          return logic.read(key);
55      }
56  
57      @Override
58      public Response create(final Domain domain) {
59          Domain created = logic.create(domain);
60          URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
61          return Response.created(location).
62                  header(RESTHeaders.RESOURCE_KEY, created.getKey()).
63                  build();
64      }
65  
66      @Override
67      public void changeAdminPassword(final String key, final String password, final CipherAlgorithm cipherAlgorithm) {
68          logic.changeAdminPassword(key, password, cipherAlgorithm);
69      }
70  
71      @Override
72      public void adjustPoolSize(final String key, final int poolMaxActive, final int poolMinIdle) {
73          logic.adjustPoolSize(key, poolMaxActive, poolMinIdle);
74      }
75  
76      @Override
77      public void delete(final String key) {
78          logic.delete(key);
79      }
80  }