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.client.console.rest;
20  
21  import java.util.List;
22  import javax.ws.rs.core.GenericType;
23  import javax.ws.rs.core.Response;
24  import org.apache.syncope.common.lib.request.AnyCR;
25  import org.apache.syncope.common.lib.request.AnyUR;
26  import org.apache.syncope.common.lib.to.AnyTO;
27  import org.apache.syncope.common.lib.to.ProvisioningResult;
28  import org.apache.syncope.common.lib.to.RemediationTO;
29  import org.apache.syncope.common.rest.api.beans.RemediationQuery;
30  import org.apache.syncope.common.rest.api.service.RemediationService;
31  import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
32  
33  public class RemediationRestClient extends BaseRestClient {
34  
35      private static final long serialVersionUID = -7033745375669316378L;
36  
37      public int countRemediations() {
38          return getService(RemediationService.class).
39                  list(new RemediationQuery.Builder().page(1).size(0).build()).
40                  getTotalCount();
41      }
42  
43      public List<RemediationTO> getRemediations(final int page, final int size, final SortParam<String> sort) {
44          return getService(RemediationService.class).
45                  list(new RemediationQuery.Builder().page(page).size(size).orderBy(toOrderBy(sort)).build()).
46                  getResult();
47      }
48  
49      public RemediationTO getRemediation(final String key) {
50          return getService(RemediationService.class).read(key);
51      }
52  
53      public <C extends AnyCR, A extends AnyTO> ProvisioningResult<A> remedy(final String key, final C anyCR) {
54          Response response = getService(RemediationService.class).remedy(key, anyCR);
55          return response.readEntity(new GenericType<>() {
56          });
57      }
58  
59      public <T extends AnyTO> ProvisioningResult<T> remedy(final String key, final AnyUR anyUR) {
60          Response response = getService(RemediationService.class).remedy(key, anyUR);
61          return response.readEntity(new GenericType<>() {
62          });
63      }
64  
65      public ProvisioningResult<? extends AnyTO> remedy(final String key, final String anyKey) {
66          Response response = getService(RemediationService.class).remedy(key, anyKey);
67          return response.readEntity(new GenericType<>() {
68          });
69      }
70  
71      public void delete(final String remediation) {
72          getService(RemediationService.class).delete(remediation);
73      }
74  }