You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by mm...@apache.org on 2020/03/07 15:49:45 UTC
[syncope] 01/06: working on attribute release policies
This is an automated email from the ASF dual-hosted git repository.
mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git
commit e7f6843c96d738ae83b21440c5a5edf8c18cb958
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Thu Mar 5 19:30:12 2020 +0330
working on attribute release policies
---
.../lib/attrs/AbstractAttrReleasePolicyConf.java | 46 ++++++++++++
.../common/lib/attrs/AllAttrReleasePolicyConf.java | 28 ++++++++
.../lib/attrs/AllowedAttrReleasePolicyConf.java | 41 +++++++++++
.../common/lib/attrs/AttrReleasePolicyConf.java | 34 +++++++++
.../syncope/common/lib/to/AttrReleasePolicyTO.java | 45 ++++++++++++
.../api/entity/policy/AttrReleasePolicy.java | 36 ++++++++++
.../jpa/entity/policy/JPAAttrReleasePolicy.java | 81 ++++++++++++++++++++++
7 files changed, 311 insertions(+)
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AbstractAttrReleasePolicyConf.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AbstractAttrReleasePolicyConf.java
new file mode 100644
index 0000000..608943a
--- /dev/null
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AbstractAttrReleasePolicyConf.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.syncope.common.lib.attrs;
+
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
+
+import java.io.Serializable;
+
+@XmlType
+@XmlSeeAlso({AllAttrReleasePolicyConf.class, AllowedAttrReleasePolicyConf.class})
+public abstract class AbstractAttrReleasePolicyConf implements Serializable, AttrReleasePolicyConf {
+
+ private static final long serialVersionUID = 1153200197344709778L;
+
+ private String name;
+
+ public AbstractAttrReleasePolicyConf() {
+ setName(getClass().getName());
+ }
+
+ @Override
+ public final String getName() {
+ return name;
+ }
+
+ public final void setName(final String name) {
+ this.name = name;
+ }
+}
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AllAttrReleasePolicyConf.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AllAttrReleasePolicyConf.java
new file mode 100644
index 0000000..3f097e2
--- /dev/null
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AllAttrReleasePolicyConf.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.syncope.common.lib.attrs;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "AllAttrReleasePolicyConf")
+@XmlType
+public class AllAttrReleasePolicyConf extends AbstractAttrReleasePolicyConf implements AttrReleasePolicyConf {
+ private static final long serialVersionUID = -1969836661359025380L;
+}
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AllowedAttrReleasePolicyConf.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AllowedAttrReleasePolicyConf.java
new file mode 100644
index 0000000..7d241bc
--- /dev/null
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AllowedAttrReleasePolicyConf.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.syncope.common.lib.attrs;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlRootElement(name = "AllowedAttrReleasePolicyConf")
+@XmlType
+public class AllowedAttrReleasePolicyConf extends AbstractAttrReleasePolicyConf implements AttrReleasePolicyConf {
+ private static final long serialVersionUID = -1969836661359025380L;
+
+ private List<String> allowedAttributes = new ArrayList<>();
+
+ public List<String> getAllowedAttributes() {
+ return allowedAttributes;
+ }
+
+ public void setAllowedAttributes(final List<String> allowedAttributes) {
+ this.allowedAttributes = allowedAttributes;
+ }
+}
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AttrReleasePolicyConf.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AttrReleasePolicyConf.java
new file mode 100644
index 0000000..d57d745
--- /dev/null
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/attrs/AttrReleasePolicyConf.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.common.lib.attrs;
+
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+
+import java.io.Serializable;
+
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
+public interface AttrReleasePolicyConf extends Serializable {
+ /**
+ * Give name of related attr release policy.
+ *
+ * @return name of this attr release policy
+ */
+ String getName();
+}
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AttrReleasePolicyTO.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AttrReleasePolicyTO.java
new file mode 100644
index 0000000..e0f8144
--- /dev/null
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/to/AttrReleasePolicyTO.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.common.lib.to;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import org.apache.syncope.common.lib.policy.PolicyTO;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "attrReleasePolicy")
+@XmlType
+public class AttrReleasePolicyTO extends PolicyTO {
+
+ private static final long serialVersionUID = -1432411162433533300L;
+
+ @XmlTransient
+ @JsonProperty("@class")
+ @Schema(name = "@class", required = true,
+ example = "org.apache.syncope.common.lib.to.AttrReleasePolicyTO")
+ @Override
+ public String getDiscriminator() {
+ return getClass().getName();
+ }
+}
+
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AttrReleasePolicy.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AttrReleasePolicy.java
new file mode 100644
index 0000000..2a6cec1
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AttrReleasePolicy.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.persistence.api.entity.policy;
+
+import org.apache.syncope.core.persistence.api.entity.Implementation;
+
+import java.util.List;
+
+public interface AttrReleasePolicy extends Policy {
+
+ String getName();
+
+ void setName(String name);
+
+ List<? extends Implementation> getConfigurations();
+
+ boolean addConfiguration(Implementation configuration);
+}
+
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAttrReleasePolicy.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAttrReleasePolicy.java
new file mode 100644
index 0000000..e5f65c6
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAttrReleasePolicy.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.entity.policy;
+
+import org.apache.syncope.common.lib.types.AMImplementationType;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
+import org.apache.syncope.core.persistence.api.entity.policy.AttrReleasePolicy;
+import org.apache.syncope.core.persistence.jpa.entity.JPAImplementation;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@Table(name = JPAAttrReleasePolicy.TABLE)
+public class JPAAttrReleasePolicy extends AbstractPolicy implements AttrReleasePolicy {
+
+ public static final String TABLE = "AttrReleasePolicy";
+
+ private static final long serialVersionUID = -4190607669908888884L;
+
+ @Column(unique = true, nullable = false)
+ private String name;
+
+ @ManyToMany(fetch = FetchType.EAGER)
+ @JoinTable(name = TABLE + "Conf",
+ joinColumns =
+ @JoinColumn(name = "attr_release_policy_id"),
+ inverseJoinColumns =
+ @JoinColumn(name = "implementation_id"),
+ uniqueConstraints =
+ @UniqueConstraint(columnNames = {"attr_release_policy_id", "implementation_id"}))
+ private List<JPAImplementation> configurations = new ArrayList<>();
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public List<? extends Implementation> getConfigurations() {
+ return configurations;
+ }
+
+ @Override
+ public boolean addConfiguration(final Implementation configuration) {
+ checkType(configuration, JPAImplementation.class);
+ checkImplementationType(configuration, AMImplementationType.ATTR_RELEASE_POLICY_CONFIGURATIONS);
+ return configurations.contains((JPAImplementation) configuration)
+ || configurations.add((JPAImplementation) configuration);
+ }
+}