You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/01/12 17:32:19 UTC

[40/52] [abbrv] [partial] syncope git commit: [SYNCOPE-620] Unit tests all in

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UMappingItem.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UMappingItem.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UMappingItem.java
deleted file mode 100644
index 2352130..0000000
--- a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UMappingItem.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.persistence.api.entity.user;
-
-import org.apache.syncope.persistence.api.entity.Mapping;
-import org.apache.syncope.persistence.api.entity.MappingItem;
-
-public interface UMappingItem extends MappingItem {
-
-    @Override
-    Mapping<UMappingItem> getMapping();
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttr.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttr.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttr.java
deleted file mode 100644
index 59a9863..0000000
--- a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttr.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.persistence.api.entity.user;
-
-import java.util.List;
-import org.apache.syncope.persistence.api.entity.PlainAttr;
-
-public interface UPlainAttr extends PlainAttr {
-
-    @Override
-    User getOwner();
-
-    @Override
-    UPlainSchema getSchema();
-
-    @Override
-    List<? extends UPlainAttrValue> getValues();
-
-    @Override
-    UPlainAttrUniqueValue getUniqueValue();
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttrUniqueValue.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttrUniqueValue.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttrUniqueValue.java
deleted file mode 100644
index 078da52..0000000
--- a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttrUniqueValue.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.persistence.api.entity.user;
-
-import org.apache.syncope.persistence.api.entity.PlainAttrUniqueValue;
-
-public interface UPlainAttrUniqueValue extends PlainAttrUniqueValue {
-
-    @Override
-    UPlainAttr getAttr();
-
-    @Override
-    UPlainSchema getSchema();
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttrValue.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttrValue.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttrValue.java
deleted file mode 100644
index bab1fde..0000000
--- a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainAttrValue.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.persistence.api.entity.user;
-
-import org.apache.syncope.persistence.api.entity.PlainAttrValue;
-
-public interface UPlainAttrValue extends PlainAttrValue {
-
-    @Override
-    UPlainAttr getAttr();
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainSchema.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainSchema.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainSchema.java
deleted file mode 100644
index 1ec236e..0000000
--- a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UPlainSchema.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.persistence.api.entity.user;
-
-import org.apache.syncope.persistence.api.entity.PlainSchema;
-
-public interface UPlainSchema extends PlainSchema {
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UVirAttr.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UVirAttr.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UVirAttr.java
deleted file mode 100644
index 78f6882..0000000
--- a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UVirAttr.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.persistence.api.entity.user;
-
-import org.apache.syncope.persistence.api.entity.VirAttr;
-
-public interface UVirAttr extends VirAttr {
-
-    @Override
-    User getOwner();
-
-    @Override
-    UVirSchema getSchema();
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UVirSchema.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UVirSchema.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UVirSchema.java
deleted file mode 100644
index 78575f7..0000000
--- a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/UVirSchema.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.persistence.api.entity.user;
-
-import org.apache.syncope.persistence.api.entity.VirSchema;
-
-public interface UVirSchema extends VirSchema {
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/User.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/User.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/User.java
deleted file mode 100644
index 6eece4d..0000000
--- a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/persistence/api/entity/user/User.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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.persistence.api.entity.user;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-import org.apache.syncope.common.lib.types.CipherAlgorithm;
-import org.apache.syncope.persistence.api.entity.ExternalResource;
-import org.apache.syncope.persistence.api.entity.Subject;
-import org.apache.syncope.persistence.api.entity.membership.Membership;
-import org.apache.syncope.persistence.api.entity.role.Role;
-
-public interface User extends Subject<UPlainAttr, UDerAttr, UVirAttr> {
-
-    boolean addMembership(Membership membership);
-
-    boolean canDecodePassword();
-
-    boolean checkToken(String token);
-
-    void generateToken(int tokenLength, int tokenExpireTime);
-
-    Date getChangePwdDate();
-
-    CipherAlgorithm getCipherAlgorithm();
-
-    String getClearPassword();
-
-    Integer getFailedLogins();
-
-    Date getLastLoginDate();
-
-    Membership getMembership(Long syncopeRoleId);
-
-    List<? extends Membership> getMemberships();
-
-    Set<? extends ExternalResource> getOwnResources();
-
-    String getPassword();
-
-    List<String> getPasswordHistory();
-
-    Set<Long> getRoleIds();
-
-    List<Role> getRoles();
-
-    String getSecurityAnswer();
-
-    SecurityQuestion getSecurityQuestion();
-
-    String getStatus();
-
-    String getToken();
-
-    Date getTokenExpireTime();
-
-    String getUsername();
-
-    String getWorkflowId();
-
-    boolean hasTokenExpired();
-
-    Boolean isSuspended();
-
-    void removeClearPassword();
-
-    boolean removeMembership(Membership membership);
-
-    void removeToken();
-
-    void setChangePwdDate(Date changePwdDate);
-
-    void setCipherAlgorithm(CipherAlgorithm cipherAlgorithm);
-
-    void setEncodedPassword(String password, CipherAlgorithm cipherAlgoritm);
-
-    void setFailedLogins(Integer failedLogins);
-
-    void setLastLoginDate(Date lastLoginDate);
-
-    void setPassword(String password, CipherAlgorithm cipherAlgoritm);
-
-    void setSecurityAnswer(String securityAnswer);
-
-    void setSecurityQuestion(SecurityQuestion securityQuestion);
-
-    void setStatus(String status);
-
-    void setSuspended(Boolean suspended);
-
-    void setUsername(String username);
-
-    void setWorkflowId(String workflowId);
-
-    boolean verifyPasswordHistory(String password, int size);
-
-    @Override
-    boolean addPlainAttr(UPlainAttr attr);
-
-    @Override
-    boolean removePlainAttr(UPlainAttr attr);
-
-    @Override
-    boolean addDerAttr(UDerAttr attr);
-
-    @Override
-    boolean removeDerAttr(UDerAttr derAttr);
-
-    @Override
-    boolean addVirAttr(UVirAttr attr);
-
-    @Override
-    boolean removeVirAttr(UVirAttr virAttr);
-
-    @Override
-    UPlainAttr getPlainAttr(String plainSchemaName);
-
-    @Override
-    List<? extends UPlainAttr> getPlainAttrs();
-
-    @Override
-    UDerAttr getDerAttr(String derSchemaName);
-
-    @Override
-    List<? extends UDerAttr> getDerAttrs();
-
-    @Override
-    UVirAttr getVirAttr(String virSchemaName);
-
-    @Override
-    List<? extends UVirAttr> getVirAttrs();
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/RoleEntitlementUtil.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/RoleEntitlementUtil.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/RoleEntitlementUtil.java
new file mode 100644
index 0000000..fc9eb1a
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/RoleEntitlementUtil.java
@@ -0,0 +1,88 @@
+/*
+ * 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.server.persistence.api;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+import org.apache.syncope.server.persistence.api.entity.Entitlement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Utility class for manipulating entitlements.
+ */
+public final class RoleEntitlementUtil {
+
+    private static final Pattern ROLE_ENTITLEMENT_NAME_PATTERN = Pattern.compile("^ROLE_([\\d])+");
+
+    private static final Logger LOG = LoggerFactory.getLogger(RoleEntitlementUtil.class);
+
+    public static String getEntitlementNameFromRoleKey(final Long roleKey) {
+        return "ROLE_" + roleKey;
+    }
+
+    public static boolean isRoleEntitlement(final String entitlementName) {
+        return ROLE_ENTITLEMENT_NAME_PATTERN.matcher(entitlementName).matches();
+    }
+
+    public static Long getRoleKey(final String entitlementName) {
+        Long result = null;
+
+        if (isRoleEntitlement(entitlementName)) {
+            try {
+                result = Long.valueOf(entitlementName.substring(entitlementName.indexOf('_') + 1));
+            } catch (Exception e) {
+                LOG.error("unable to parse {} to Long", entitlementName, e);
+            }
+        }
+
+        return result;
+    }
+
+    public static Set<Long> getRoleKeys(final Set<String> entitlements) {
+        Set<Long> result = new HashSet<>();
+
+        for (String entitlement : entitlements) {
+            if (isRoleEntitlement(entitlement)) {
+                Long roleId = getRoleKey(entitlement);
+                if (roleId != null) {
+                    result.add(roleId);
+                }
+            }
+        }
+
+        return result;
+    }
+
+    public static Set<Long> getRoleKeys(final List<Entitlement> entitlements) {
+        Set<String> names = new HashSet<>(entitlements.size());
+        for (Entitlement entitlement : entitlements) {
+            names.add(entitlement.getKey());
+        }
+        return getRoleKeys(names);
+    }
+
+    /**
+     * Private default constructor, for static-only classes.
+     */
+    private RoleEntitlementUtil() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/InvalidEntityException.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/InvalidEntityException.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/InvalidEntityException.java
new file mode 100644
index 0000000..c1daa31
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/InvalidEntityException.java
@@ -0,0 +1,129 @@
+/*
+ * 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.server.persistence.api.attrvalue.validation;
+
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.ValidationException;
+import org.apache.syncope.common.lib.types.EntityViolationType;
+
+/**
+ * Exception thrown when any JPA entity fails bean validation.
+ */
+public class InvalidEntityException extends ValidationException {
+
+    private static final long serialVersionUID = 3249297275444409691L;
+
+    private final String entityClassSimpleName;
+
+    private final Map<Class<?>, Set<EntityViolationType>> violations = new HashMap<>();
+
+    /**
+     * Constructs a singleton map of violations from given parameters.
+     *
+     * @param entityClass class of invalid entity
+     * @param entityViolationType type of violation found
+     * @param message message to be associated to the violation
+     */
+    public InvalidEntityException(final Class<?> entityClass,
+            final EntityViolationType entityViolationType, final String message) {
+
+        super();
+
+        this.entityClassSimpleName = entityClass.getSimpleName();
+
+        entityViolationType.setMessage(message.trim());
+
+        this.violations.put(entityClass, EnumSet.noneOf(EntityViolationType.class));
+        this.violations.get(entityClass).add(entityViolationType);
+    }
+
+    /**
+     * Constructs a map of violations out of given <tt>ConstraintViolation</tt> set.
+     *
+     * @param entityClassSimpleName simple class name of invalid entity
+     * @param violations as returned by bean validation
+     */
+    public InvalidEntityException(final String entityClassSimpleName,
+            final Set<ConstraintViolation<Object>> violations) {
+
+        super();
+
+        this.entityClassSimpleName = entityClassSimpleName;
+
+        for (ConstraintViolation<Object> violation : violations) {
+            int firstComma = violation.getMessageTemplate().indexOf(';');
+
+            final String key = violation.getMessageTemplate().substring(
+                    0, firstComma > 0 ? firstComma : violation.getMessageTemplate().length());
+
+            final String message = violation.getMessageTemplate().substring(firstComma > 0 ? firstComma + 1 : 0);
+
+            EntityViolationType entityViolationType;
+
+            try {
+                entityViolationType = EntityViolationType.valueOf(key.trim());
+            } catch (IllegalArgumentException e) {
+                entityViolationType = EntityViolationType.Standard;
+            }
+
+            entityViolationType.setMessage(message.trim());
+
+            if (!this.violations.containsKey(violation.getLeafBean().getClass())) {
+                this.violations.put(violation.getLeafBean().getClass(), EnumSet.noneOf(EntityViolationType.class));
+            }
+
+            this.violations.get(violation.getLeafBean().getClass()).add(entityViolationType);
+        }
+    }
+
+    public final boolean hasViolation(final EntityViolationType type) {
+        boolean found = false;
+        for (Class<?> entity : violations.keySet()) {
+            if (violations.get(entity).contains(type)) {
+                found = true;
+            }
+        }
+
+        return found;
+    }
+
+    public String getEntityClassSimpleName() {
+        return entityClassSimpleName;
+    }
+
+    public final Map<Class<?>, Set<EntityViolationType>> getViolations() {
+        return violations;
+    }
+
+    @Override
+    public String getMessage() {
+        StringBuilder sb = new StringBuilder();
+
+        for (Class<?> entity : violations.keySet()) {
+            sb.append(entity.getSimpleName()).append(" ").append(violations.get(entity).toString()).append(", ");
+        }
+        sb.delete(sb.lastIndexOf(", "), sb.length());
+
+        return sb.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/InvalidPlainAttrValueException.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/InvalidPlainAttrValueException.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/InvalidPlainAttrValueException.java
new file mode 100644
index 0000000..aa0b85d
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/InvalidPlainAttrValueException.java
@@ -0,0 +1,43 @@
+/*
+ * 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.server.persistence.api.attrvalue.validation;
+
+import javax.validation.ValidationException;
+import org.apache.syncope.server.persistence.api.entity.PlainAttrValue;
+
+public class InvalidPlainAttrValueException extends ValidationException {
+
+    private static final long serialVersionUID = -5023202610580202148L;
+
+    public InvalidPlainAttrValueException(final String errorMessage) {
+        super(errorMessage);
+    }
+
+    public InvalidPlainAttrValueException(final String errorMessage, final Throwable cause) {
+        super(errorMessage, cause);
+    }
+
+    public InvalidPlainAttrValueException(final PlainAttrValue value) {
+        this("Could not validate " + value.getValue());
+    }
+
+    public InvalidPlainAttrValueException(final PlainAttrValue value, Throwable cause) {
+        this("Could not validate " + value.getValue(), cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/ParsingValidationException.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/ParsingValidationException.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/ParsingValidationException.java
new file mode 100644
index 0000000..44af974
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/ParsingValidationException.java
@@ -0,0 +1,30 @@
+/*
+ * 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.server.persistence.api.attrvalue.validation;
+
+import javax.validation.ValidationException;
+
+public class ParsingValidationException extends ValidationException {
+
+    private static final long serialVersionUID = 5669262895008285522L;
+
+    public ParsingValidationException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/Validator.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/Validator.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/Validator.java
new file mode 100644
index 0000000..7732fd9
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/attrvalue/validation/Validator.java
@@ -0,0 +1,27 @@
+/*
+ * 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.server.persistence.api.attrvalue.validation;
+
+import org.apache.syncope.server.persistence.api.entity.PlainAttrValue;
+
+public interface Validator {
+
+    void validate(String value, PlainAttrValue attrValue)
+            throws ParsingValidationException, InvalidPlainAttrValueException;
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/content/ContentExporter.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/content/ContentExporter.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/content/ContentExporter.java
new file mode 100644
index 0000000..c5b3866
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/content/ContentExporter.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.server.persistence.api.content;
+
+import java.io.OutputStream;
+import javax.xml.transform.TransformerConfigurationException;
+import org.xml.sax.SAXException;
+
+public interface ContentExporter {
+
+    void export(OutputStream output, String wfTablePrefix) throws SAXException, TransformerConfigurationException;
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/content/ContentLoader.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/content/ContentLoader.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/content/ContentLoader.java
new file mode 100644
index 0000000..8e351b5
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/content/ContentLoader.java
@@ -0,0 +1,25 @@
+/*
+ * 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.server.persistence.api.content;
+
+public interface ContentLoader {
+
+    void load();
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/AttrTemplateDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/AttrTemplateDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/AttrTemplateDAO.java
new file mode 100644
index 0000000..7069f94
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/AttrTemplateDAO.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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.entity.AttrTemplate;
+import org.apache.syncope.server.persistence.api.entity.Schema;
+
+public interface AttrTemplateDAO<K extends Schema> extends DAO<AttrTemplate<K>, Long> {
+
+    <T extends AttrTemplate<K>> T find(Long key, Class<T> reference);
+
+    <T extends AttrTemplate<K>> List<Number> findBySchemaName(String schemaName, Class<T> reference);
+
+    <T extends AttrTemplate<K>> void delete(Long key, Class<T> reference);
+
+    <T extends AttrTemplate<K>> void delete(T attrTemplate);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ConfDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ConfDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ConfDAO.java
new file mode 100644
index 0000000..98b463f
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ConfDAO.java
@@ -0,0 +1,35 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import org.apache.syncope.server.persistence.api.entity.conf.CPlainAttr;
+import org.apache.syncope.server.persistence.api.entity.conf.Conf;
+
+public interface ConfDAO extends DAO<Conf, Long> {
+
+    CPlainAttr find(String key);
+
+    CPlainAttr find(String key, String defaultValue);
+
+    Conf get();
+
+    Conf save(CPlainAttr attr);
+
+    Conf delete(String key);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ConnInstanceDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ConnInstanceDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ConnInstanceDAO.java
new file mode 100644
index 0000000..73362f7
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ConnInstanceDAO.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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.ConnInstance;
+
+public interface ConnInstanceDAO extends DAO<ConnInstance, Long> {
+
+    ConnInstance find(Long key);
+
+    List<ConnInstance> findAll();
+
+    ConnInstance save(ConnInstance connector) throws InvalidEntityException;
+
+    void delete(Long key);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DAO.java
new file mode 100644
index 0000000..a32e5a6
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DAO.java
@@ -0,0 +1,32 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import org.apache.syncope.server.persistence.api.entity.Entity;
+
+public interface DAO<E extends Entity<KEY>, KEY> {
+
+    void refresh(E entity);
+
+    void detach(E entity);
+
+    void flush();
+
+    void clear();
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DerAttrDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DerAttrDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DerAttrDAO.java
new file mode 100644
index 0000000..fd3e827
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DerAttrDAO.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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.DerAttr;
+
+public interface DerAttrDAO extends DAO<DerAttr, Long> {
+
+    <T extends DerAttr> T find(Long key, Class<T> reference);
+
+    <T extends DerAttr> List<T> findAll(Class<T> reference);
+
+    <T extends DerAttr> T save(T derAttr) throws InvalidEntityException;
+
+    <T extends DerAttr> void delete(Long key, Class<T> reference);
+
+    <T extends DerAttr> void delete(T derAttr);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DerSchemaDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DerSchemaDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DerSchemaDAO.java
new file mode 100644
index 0000000..be22c90
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DerSchemaDAO.java
@@ -0,0 +1,38 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.AttributableUtil;
+import org.apache.syncope.server.persistence.api.entity.DerAttr;
+import org.apache.syncope.server.persistence.api.entity.DerSchema;
+
+public interface DerSchemaDAO extends DAO<DerSchema, String> {
+
+    <T extends DerSchema> T find(String name, Class<T> reference);
+
+    <T extends DerSchema> List<T> findAll(Class<T> reference);
+
+    <T extends DerAttr> List<T> findAttrs(DerSchema schema, Class<T> reference);
+
+    <T extends DerSchema> T save(T derSchema) throws InvalidEntityException;
+
+    void delete(String name, AttributableUtil attributableUtil);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DuplicateException.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DuplicateException.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DuplicateException.java
new file mode 100644
index 0000000..4d5300b
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/DuplicateException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.server.persistence.api.dao;
+
+/**
+ * Thrown when something is not found.
+ */
+public class DuplicateException extends RuntimeException {
+
+    private static final long serialVersionUID = -8200698688516957508L;
+
+    public DuplicateException(final String msg) {
+        super(msg);
+    }
+
+    public DuplicateException(final String msg, final Exception cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/EntitlementDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/EntitlementDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/EntitlementDAO.java
new file mode 100644
index 0000000..f7d9461
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/EntitlementDAO.java
@@ -0,0 +1,39 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.Entitlement;
+import org.apache.syncope.server.persistence.api.entity.role.Role;
+
+public interface EntitlementDAO extends DAO<Entitlement, String> {
+
+    Entitlement find(String key);
+
+    List<Entitlement> findAll();
+
+    Entitlement save(Entitlement entitlement) throws InvalidEntityException;
+
+    Entitlement saveRoleEntitlement(Role role);
+
+    void delete(String key);
+
+    void delete(Entitlement entitlement);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ExternalResourceDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ExternalResourceDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ExternalResourceDAO.java
new file mode 100644
index 0000000..2028040
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ExternalResourceDAO.java
@@ -0,0 +1,47 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.common.lib.types.IntMappingType;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+import org.apache.syncope.server.persistence.api.entity.MappingItem;
+import org.apache.syncope.server.persistence.api.entity.Policy;
+
+public interface ExternalResourceDAO extends DAO<ExternalResource, String> {
+
+    ExternalResource find(String key);
+
+    List<ExternalResource> findByPolicy(Policy policy);
+
+    List<ExternalResource> findWithoutPolicy(PolicyType type);
+
+    List<ExternalResource> findAll();
+
+    List<ExternalResource> findAllByPriority();
+
+    ExternalResource save(ExternalResource resource) throws InvalidEntityException;
+
+    <T extends MappingItem> void deleteMapping(
+            String schemaName, IntMappingType intMappingType, Class<T> reference);
+
+    void delete(String key);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/LoggerDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/LoggerDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/LoggerDAO.java
new file mode 100644
index 0000000..c558e38
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/LoggerDAO.java
@@ -0,0 +1,37 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.common.lib.types.LoggerType;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.Logger;
+
+public interface LoggerDAO extends DAO<Logger, String> {
+
+    Logger find(String key);
+
+    List<Logger> findAll(LoggerType type);
+
+    Logger save(Logger logger) throws InvalidEntityException;
+
+    void delete(String key);
+
+    void delete(Logger logger);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/MembershipDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/MembershipDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/MembershipDAO.java
new file mode 100644
index 0000000..79201f5
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/MembershipDAO.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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.membership.Membership;
+import org.apache.syncope.server.persistence.api.entity.role.Role;
+import org.apache.syncope.server.persistence.api.entity.user.User;
+
+public interface MembershipDAO extends DAO<Membership, Long> {
+
+    Membership find(Long key);
+
+    Membership find(User user, Role role);
+
+    List<Membership> findAll();
+
+    Membership save(Membership membership) throws InvalidEntityException;
+
+    void delete(Long key);
+
+    Membership authFetch(Long key);
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/NotFoundException.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/NotFoundException.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/NotFoundException.java
new file mode 100644
index 0000000..4e8b14d
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/NotFoundException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.server.persistence.api.dao;
+
+/**
+ * Thrown when something is not found.
+ */
+public class NotFoundException extends RuntimeException {
+
+    private static final long serialVersionUID = 4810651769126663581L;
+
+    public NotFoundException(final String msg) {
+        super(msg);
+    }
+
+    public NotFoundException(final String msg, final Exception cause) {
+        super(msg, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/NotificationDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/NotificationDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/NotificationDAO.java
new file mode 100644
index 0000000..44b4f5a
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/NotificationDAO.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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.Notification;
+
+public interface NotificationDAO extends DAO<Notification, Long> {
+
+    Notification find(Long key);
+
+    List<Notification> findAll();
+
+    Notification save(Notification notification) throws InvalidEntityException;
+
+    void delete(Long key);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainAttrDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainAttrDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainAttrDAO.java
new file mode 100644
index 0000000..a35c46a
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainAttrDAO.java
@@ -0,0 +1,30 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import org.apache.syncope.server.persistence.api.entity.PlainAttr;
+
+public interface PlainAttrDAO extends DAO<PlainAttr, Long> {
+
+    <T extends PlainAttr> T find(Long key, Class<T> reference);
+
+    <T extends PlainAttr> void delete(Long key, Class<T> reference);
+
+    <T extends PlainAttr> void delete(T attr);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainAttrValueDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainAttrValueDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainAttrValueDAO.java
new file mode 100644
index 0000000..c0dd825
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainAttrValueDAO.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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.PlainAttrValue;
+
+public interface PlainAttrValueDAO extends DAO<PlainAttrValue, Long> {
+
+    <T extends PlainAttrValue> T find(Long key, Class<T> reference);
+
+    <T extends PlainAttrValue> List<T> findAll(Class<T> reference);
+
+    <T extends PlainAttrValue> T save(T attributeValue) throws InvalidEntityException;
+
+    <T extends PlainAttrValue> void delete(Long key, Class<T> reference);
+
+    <T extends PlainAttrValue> void delete(T attributeValue);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainSchemaDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainSchemaDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainSchemaDAO.java
new file mode 100644
index 0000000..3d6c9cc
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PlainSchemaDAO.java
@@ -0,0 +1,38 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.AttributableUtil;
+import org.apache.syncope.server.persistence.api.entity.PlainAttr;
+import org.apache.syncope.server.persistence.api.entity.PlainSchema;
+
+public interface PlainSchemaDAO extends DAO<PlainSchema, String> {
+
+    <T extends PlainSchema> T find(String key, Class<T> reference);
+
+    <T extends PlainSchema> List<T> findAll(Class<T> reference);
+
+    <T extends PlainAttr> List<T> findAttrs(PlainSchema schema, Class<T> reference);
+
+    <T extends PlainSchema> T save(T schema) throws InvalidEntityException;
+
+    void delete(String name, AttributableUtil attributableUtil);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PolicyDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PolicyDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PolicyDAO.java
new file mode 100644
index 0000000..863dad3
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/PolicyDAO.java
@@ -0,0 +1,48 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.syncope.server.persistence.api.entity.AccountPolicy;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+import org.apache.syncope.server.persistence.api.entity.PasswordPolicy;
+import org.apache.syncope.server.persistence.api.entity.Policy;
+import org.apache.syncope.server.persistence.api.entity.SyncPolicy;
+
+public interface PolicyDAO extends DAO<Policy, Long> {
+
+    <T extends Policy> T find(Long key);
+
+    <T extends Policy> List<T> find(PolicyType type);
+
+    List<AccountPolicy> findByResource(ExternalResource resource);
+
+    PasswordPolicy getGlobalPasswordPolicy();
+
+    AccountPolicy getGlobalAccountPolicy();
+
+    SyncPolicy getGlobalSyncPolicy();
+
+    List<Policy> findAll();
+
+    <T extends Policy> T save(T policy);
+
+    <T extends Policy> void delete(T policy);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ReportDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ReportDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ReportDAO.java
new file mode 100644
index 0000000..d4499b4
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ReportDAO.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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.dao.search.OrderByClause;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.Report;
+
+public interface ReportDAO extends DAO<Report, Long> {
+
+    Report find(Long key);
+
+    List<Report> findAll();
+
+    List<Report> findAll(int page, int itemsPerPage, List<OrderByClause> orderByClauses);
+
+    int count();
+
+    Report save(Report report) throws InvalidEntityException;
+
+    void delete(Long key);
+
+    void delete(Report report);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ReportExecDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ReportExecDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ReportExecDAO.java
new file mode 100644
index 0000000..83895ba
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/ReportExecDAO.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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.Report;
+import org.apache.syncope.server.persistence.api.entity.ReportExec;
+
+public interface ReportExecDAO extends DAO<ReportExec, Long> {
+
+    ReportExec find(Long key);
+
+    ReportExec findLatestStarted(Report report);
+
+    ReportExec findLatestEnded(Report report);
+
+    List<ReportExec> findAll();
+
+    ReportExec save(ReportExec execution) throws InvalidEntityException;
+
+    void delete(Long key);
+
+    void delete(ReportExec execution);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/RoleDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/RoleDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/RoleDAO.java
new file mode 100644
index 0000000..778443e
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/RoleDAO.java
@@ -0,0 +1,92 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.syncope.common.lib.types.PropagationByResource;
+import org.apache.syncope.server.persistence.api.dao.search.OrderByClause;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.Entitlement;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+import org.apache.syncope.server.persistence.api.entity.Policy;
+import org.apache.syncope.server.persistence.api.entity.membership.Membership;
+import org.apache.syncope.server.persistence.api.entity.role.RDerAttr;
+import org.apache.syncope.server.persistence.api.entity.role.RPlainAttr;
+import org.apache.syncope.server.persistence.api.entity.role.RPlainAttrValue;
+import org.apache.syncope.server.persistence.api.entity.role.RVirAttr;
+import org.apache.syncope.server.persistence.api.entity.role.Role;
+
+public interface RoleDAO extends SubjectDAO<RPlainAttr, RDerAttr, RVirAttr> {
+
+    Role find(Long key);
+
+    List<Role> find(String name);
+
+    Role find(String name, Long parent);
+
+    List<Role> findOwnedByUser(Long userId);
+
+    List<Role> findOwnedByRole(Long roleId);
+
+    List<Role> findByEntitlement(Entitlement entitlement);
+
+    List<Role> findByPolicy(Policy policy);
+
+    List<Role> findWithoutPolicy(PolicyType type);
+
+    List<Role> findAncestors(Role role);
+
+    List<Role> findChildren(Role role);
+
+    List<Role> findDescendants(Role role);
+
+    List<Role> findByDerAttrValue(String schemaName, String value);
+
+    List<Role> findByAttrValue(String schemaName, RPlainAttrValue attrValue);
+
+    Role findByAttrUniqueValue(String schemaName, RPlainAttrValue attrUniqueValue);
+
+    List<Role> findByResource(ExternalResource resource);
+
+    List<Role> findAll();
+
+    List<Role> findAll(int page, int itemsPerPage, List<OrderByClause> orderBy);
+
+    List<Membership> findMemberships(Role role);
+
+    int count();
+
+    Role save(Role syncopeRole) throws InvalidEntityException;
+
+    void delete(Role role);
+
+    void delete(Long key);
+
+    Role authFetch(Long key);
+
+    /**
+     * Finds users having resources assigned exclusively because of memberships of the given role.
+     *
+     * @param roleKey role key
+     * @return map containing pairs with user key and operations to be performed on those resources (DELETE, typically).
+     */
+    Map<Long, PropagationByResource> findUsersWithIndirectResources(Long roleKey);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/SecurityQuestionDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/SecurityQuestionDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/SecurityQuestionDAO.java
new file mode 100644
index 0000000..b6cad4f
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/SecurityQuestionDAO.java
@@ -0,0 +1,35 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.entity.user.SecurityQuestion;
+
+public interface SecurityQuestionDAO extends DAO<SecurityQuestion, Long> {
+
+    SecurityQuestion find(Long key);
+
+    List<SecurityQuestion> findAll();
+
+    SecurityQuestion save(SecurityQuestion securityQuestion) throws InvalidEntityException;
+
+    void delete(Long key);
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/SubjectDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/SubjectDAO.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/SubjectDAO.java
new file mode 100644
index 0000000..da32c9c
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/SubjectDAO.java
@@ -0,0 +1,44 @@
+/*
+ * 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.server.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.entity.AttributableUtil;
+import org.apache.syncope.server.persistence.api.entity.DerAttr;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+import org.apache.syncope.server.persistence.api.entity.PlainAttr;
+import org.apache.syncope.server.persistence.api.entity.PlainAttrValue;
+import org.apache.syncope.server.persistence.api.entity.Subject;
+import org.apache.syncope.server.persistence.api.entity.VirAttr;
+
+public interface SubjectDAO<P extends PlainAttr, D extends DerAttr, V extends VirAttr>
+        extends DAO<Subject<P, D, V>, Long> {
+
+    List<? extends Subject<P, D, V>> findByAttrValue(
+            String schemaName, PlainAttrValue attrValue, AttributableUtil attrUtil);
+
+    Subject<P, D, V> findByAttrUniqueValue(
+            String schemaName, PlainAttrValue attrUniqueValue, AttributableUtil attrUtil);
+
+    List<? extends Subject<P, D, V>> findByDerAttrValue(
+            String schemaName, String value, AttributableUtil attrUtil);
+
+    List<? extends Subject<P, D, V>> findByResource(
+            ExternalResource resource, AttributableUtil attrUtil);
+}