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.persistence.jpa.entity.policy;
20  
21  import java.util.Optional;
22  import javax.persistence.Entity;
23  import javax.persistence.EnumType;
24  import javax.persistence.Enumerated;
25  import javax.persistence.Table;
26  import javax.validation.constraints.Min;
27  import javax.validation.constraints.NotNull;
28  import org.apache.syncope.common.lib.types.BackOffStrategy;
29  import org.apache.syncope.core.persistence.api.entity.policy.PropagationPolicy;
30  
31  @Entity
32  @Table(name = JPAPropagationPolicy.TABLE)
33  public class JPAPropagationPolicy extends AbstractPolicy implements PropagationPolicy {
34  
35      private static final long serialVersionUID = 17400846199535L;
36  
37      public static final String TABLE = "PropagationPolicy";
38  
39      @NotNull
40      private Boolean fetchAroundProvisioning = true;
41  
42      @NotNull
43      private Boolean updateDelta = false;
44  
45      @Enumerated(EnumType.STRING)
46      @NotNull
47      private BackOffStrategy backOffStrategy;
48  
49      private String backOffParams;
50  
51      @Min(1)
52      @NotNull
53      private Integer maxAttempts = 3;
54  
55      @Override
56      public boolean isFetchAroundProvisioning() {
57          return fetchAroundProvisioning;
58      }
59  
60      @Override
61      public void setFetchAroundProvisioning(final boolean fetchAroundProvisioning) {
62          this.fetchAroundProvisioning = fetchAroundProvisioning;
63      }
64  
65      @Override
66      public boolean isUpdateDelta() {
67          return updateDelta;
68      }
69  
70      @Override
71      public void setUpdateDelta(final boolean updateDelta) {
72          this.updateDelta = updateDelta;
73      }
74  
75      @Override
76      public BackOffStrategy getBackOffStrategy() {
77          return backOffStrategy;
78      }
79  
80      @Override
81      public void setBackOffStrategy(final BackOffStrategy backOffStrategy) {
82          this.backOffStrategy = backOffStrategy;
83      }
84  
85      @Override
86      public String getBackOffParams() {
87          return backOffParams;
88      }
89  
90      @Override
91      public void setBackOffParams(final String backOffParams) {
92          this.backOffParams = backOffParams;
93      }
94  
95      @Override
96      public int getMaxAttempts() {
97          return Optional.ofNullable(maxAttempts).orElse(3);
98      }
99  
100     @Override
101     public void setMaxAttempts(final int maxAttempts) {
102         this.maxAttempts = maxAttempts;
103     }
104 }