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:16 UTC
[37/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/server/persistence/api/entity/task/NotificationTask.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/NotificationTask.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/NotificationTask.java
new file mode 100644
index 0000000..41ec8e6
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/NotificationTask.java
@@ -0,0 +1,55 @@
+/*
+ * 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.entity.task;
+
+import java.util.Set;
+import org.apache.syncope.common.lib.types.TraceLevel;
+
+public interface NotificationTask extends Task {
+
+ String getHtmlBody();
+
+ Set<String> getRecipients();
+
+ String getSender();
+
+ String getSubject();
+
+ String getTextBody();
+
+ TraceLevel getTraceLevel();
+
+ boolean isExecuted();
+
+ void setExecuted(boolean executed);
+
+ void setHtmlBody(String htmlBody);
+
+ boolean addRecipient(String recipient);
+
+ boolean removeRecipient(String recipient);
+
+ void setSender(String sender);
+
+ void setSubject(String subject);
+
+ void setTextBody(String textBody);
+
+ void setTraceLevel(TraceLevel traceLevel);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/PropagationTask.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/PropagationTask.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/PropagationTask.java
new file mode 100644
index 0000000..62e5b1a
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/PropagationTask.java
@@ -0,0 +1,65 @@
+/*
+ * 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.entity.task;
+
+import java.util.Set;
+import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.common.lib.types.PropagationMode;
+import org.apache.syncope.common.lib.types.ResourceOperation;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+import org.identityconnectors.framework.common.objects.Attribute;
+
+public interface PropagationTask extends Task {
+
+ String getAccountId();
+
+ Set<Attribute> getAttributes();
+
+ String getObjectClassName();
+
+ String getOldAccountId();
+
+ PropagationMode getPropagationMode();
+
+ ResourceOperation getPropagationOperation();
+
+ ExternalResource getResource();
+
+ Long getSubjectKey();
+
+ AttributableType getSubjectType();
+
+ void setAccountId(String accountId);
+
+ void setAttributes(Set<Attribute> attributes);
+
+ void setObjectClassName(String objectClassName);
+
+ void setOldAccountId(String oldAccountId);
+
+ void setPropagationMode(PropagationMode propagationMode);
+
+ void setPropagationOperation(ResourceOperation operation);
+
+ void setResource(ExternalResource resource);
+
+ void setSubjectKey(Long subjectKey);
+
+ void setSubjectType(AttributableType subjectType);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/ProvisioningTask.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/ProvisioningTask.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/ProvisioningTask.java
new file mode 100644
index 0000000..112acdb
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/ProvisioningTask.java
@@ -0,0 +1,58 @@
+/*
+ * 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.entity.task;
+
+import java.util.List;
+import org.apache.syncope.common.lib.types.MatchingRule;
+import org.apache.syncope.common.lib.types.UnmatchingRule;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+
+public interface ProvisioningTask extends SchedTask {
+
+ List<String> getActionsClassNames();
+
+ MatchingRule getMatchingRule();
+
+ ExternalResource getResource();
+
+ UnmatchingRule getUnmatchingRule();
+
+ boolean isPerformCreate();
+
+ boolean isPerformDelete();
+
+ boolean isPerformUpdate();
+
+ boolean isSyncStatus();
+
+ void setMatchingRule(MatchingRule matchigRule);
+
+ void setPerformCreate(boolean performCreate);
+
+ void setPerformDelete(boolean performDelete);
+
+ void setPerformUpdate(boolean performUpdate);
+
+ void setResource(ExternalResource resource);
+
+ void setSyncStatus(boolean syncStatus);
+
+ void setUnmatchingRule(UnmatchingRule unmatchigRule);
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/PushTask.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/PushTask.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/PushTask.java
new file mode 100644
index 0000000..d58bd87
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/PushTask.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.entity.task;
+
+public interface PushTask extends ProvisioningTask {
+
+ String getRoleFilter();
+
+ String getUserFilter();
+
+ void setRoleFilter(String roleFilter);
+
+ void setUserFilter(String filter);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/SchedTask.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/SchedTask.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/SchedTask.java
new file mode 100644
index 0000000..39ad301
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/SchedTask.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.entity.task;
+
+public interface SchedTask extends Task {
+
+ String getCronExpression();
+
+ String getDescription();
+
+ String getJobClassName();
+
+ String getName();
+
+ void setCronExpression(String cronExpression);
+
+ void setDescription(String description);
+
+ void setJobClassName(String jobClassName);
+
+ void setName(String name);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/SyncTask.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/SyncTask.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/SyncTask.java
new file mode 100644
index 0000000..cd06f96
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/SyncTask.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.entity.task;
+
+import org.apache.syncope.common.lib.to.RoleTO;
+import org.apache.syncope.common.lib.to.UserTO;
+
+public interface SyncTask extends ProvisioningTask {
+
+ RoleTO getRoleTemplate();
+
+ UserTO getUserTemplate();
+
+ boolean isFullReconciliation();
+
+ void setFullReconciliation(boolean condition);
+
+ void setRoleTemplate(RoleTO roleTemplate);
+
+ void setUserTemplate(UserTO userTemplate);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/Task.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/Task.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/Task.java
new file mode 100644
index 0000000..3c74931
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/Task.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.entity.task;
+
+import java.util.List;
+import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.server.persistence.api.entity.Entity;
+
+public interface Task extends Entity<Long> {
+
+ TaskType getType();
+
+ boolean addExec(TaskExec exec);
+
+ boolean removeExec(TaskExec exec);
+
+ List<? extends TaskExec> getExecs();
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskExec.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskExec.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskExec.java
new file mode 100644
index 0000000..d0da49f
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskExec.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.entity.task;
+
+import org.apache.syncope.server.persistence.api.entity.Exec;
+
+public interface TaskExec extends Exec {
+
+ Task getTask();
+
+ void setTask(Task task);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskUtil.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskUtil.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskUtil.java
new file mode 100644
index 0000000..47f877b
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskUtil.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.entity.task;
+
+import org.apache.syncope.common.lib.to.AbstractTaskTO;
+import org.apache.syncope.common.lib.types.TaskType;
+
+public interface TaskUtil {
+
+ TaskType getType();
+
+ <T extends Task> T newTask();
+
+ <T extends AbstractTaskTO> T newTaskTO();
+
+ <T extends Task> Class<T> taskClass();
+
+ <T extends AbstractTaskTO> Class<T> taskTOClass();
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskUtilFactory.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskUtilFactory.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskUtilFactory.java
new file mode 100644
index 0000000..971c163
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/task/TaskUtilFactory.java
@@ -0,0 +1,33 @@
+/*
+ * 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.entity.task;
+
+import org.apache.syncope.common.lib.to.AbstractTaskTO;
+import org.apache.syncope.common.lib.types.TaskType;
+
+public interface TaskUtilFactory {
+
+ TaskUtil getInstance(TaskType type);
+
+ TaskUtil getInstance(Task task);
+
+ TaskUtil getInstance(Class<? extends AbstractTaskTO> taskClass);
+
+ TaskUtil getInstance(AbstractTaskTO taskTO);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/SecurityQuestion.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/SecurityQuestion.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/SecurityQuestion.java
new file mode 100644
index 0000000..233be3c
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/SecurityQuestion.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.entity.user;
+
+import org.apache.syncope.server.persistence.api.entity.Entity;
+
+public interface SecurityQuestion extends Entity<Long> {
+
+ String getContent();
+
+ void setContent(String content);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UDerAttr.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UDerAttr.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UDerAttr.java
new file mode 100644
index 0000000..e561f8d
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UDerAttr.java
@@ -0,0 +1,31 @@
+/*
+ * 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.entity.user;
+
+import org.apache.syncope.server.persistence.api.entity.DerAttr;
+
+public interface UDerAttr extends DerAttr {
+
+ @Override
+ User getOwner();
+
+ @Override
+ UDerSchema getSchema();
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UDerSchema.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UDerSchema.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UDerSchema.java
new file mode 100644
index 0000000..0979027
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UDerSchema.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.entity.user;
+
+import org.apache.syncope.server.persistence.api.entity.DerSchema;
+
+public interface UDerSchema extends DerSchema {
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UMapping.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UMapping.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UMapping.java
new file mode 100644
index 0000000..9b66711
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UMapping.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.entity.user;
+
+import org.apache.syncope.server.persistence.api.entity.Mapping;
+
+public interface UMapping extends Mapping<UMappingItem> {
+
+ UMappingItem getPasswordItem();
+
+ boolean setPasswordItem(UMappingItem item);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UMappingItem.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UMappingItem.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UMappingItem.java
new file mode 100644
index 0000000..ec20fbb
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UMappingItem.java
@@ -0,0 +1,29 @@
+/*
+ * 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.entity.user;
+
+import org.apache.syncope.server.persistence.api.entity.Mapping;
+import org.apache.syncope.server.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/server/persistence/api/entity/user/UPlainAttr.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainAttr.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainAttr.java
new file mode 100644
index 0000000..196750e
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainAttr.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.entity.user;
+
+import java.util.List;
+import org.apache.syncope.server.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/server/persistence/api/entity/user/UPlainAttrUniqueValue.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainAttrUniqueValue.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainAttrUniqueValue.java
new file mode 100644
index 0000000..df79a66
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainAttrUniqueValue.java
@@ -0,0 +1,31 @@
+/*
+ * 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.entity.user;
+
+import org.apache.syncope.server.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/server/persistence/api/entity/user/UPlainAttrValue.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainAttrValue.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainAttrValue.java
new file mode 100644
index 0000000..c20cb60
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainAttrValue.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.entity.user;
+
+import org.apache.syncope.server.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/server/persistence/api/entity/user/UPlainSchema.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainSchema.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainSchema.java
new file mode 100644
index 0000000..bd1774f
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UPlainSchema.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.entity.user;
+
+import org.apache.syncope.server.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/server/persistence/api/entity/user/UVirAttr.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UVirAttr.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UVirAttr.java
new file mode 100644
index 0000000..8b31c82
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UVirAttr.java
@@ -0,0 +1,31 @@
+/*
+ * 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.entity.user;
+
+import org.apache.syncope.server.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/server/persistence/api/entity/user/UVirSchema.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UVirSchema.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UVirSchema.java
new file mode 100644
index 0000000..3455740
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/UVirSchema.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.entity.user;
+
+import org.apache.syncope.server.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/server/persistence/api/entity/user/User.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/User.java b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/User.java
new file mode 100644
index 0000000..918937c
--- /dev/null
+++ b/syncope620/server/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/user/User.java
@@ -0,0 +1,150 @@
+/*
+ * 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.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.server.persistence.api.entity.ExternalResource;
+import org.apache.syncope.server.persistence.api.entity.Subject;
+import org.apache.syncope.server.persistence.api.entity.membership.Membership;
+import org.apache.syncope.server.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-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/pom.xml b/syncope620/server/persistence-jpa/pom.xml
index b5f0bbe..53ca552 100644
--- a/syncope620/server/persistence-jpa/pom.xml
+++ b/syncope620/server/persistence-jpa/pom.xml
@@ -91,30 +91,15 @@ under the License.
<dependency>
<groupId>org.apache.syncope.server</groupId>
- <artifactId>syncope-provisioning-common</artifactId>
+ <artifactId>syncope-workflow-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.syncope.server</groupId>
- <artifactId>syncope-persistence-api</artifactId>
+ <artifactId>syncope-server-misc</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.syncope.server</groupId>
- <artifactId>syncope-server-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.syncope.server</groupId>
- <artifactId>syncope-server-spring</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.syncope.server</groupId>
- <artifactId>syncope-server-security</artifactId>
- <version>${project.version}</version>
- </dependency>
-
+
<!-- TEST -->
<dependency>
<groupId>org.slf4j</groupId>
@@ -154,7 +139,7 @@ under the License.
</dependencies>
<configuration>
<persistenceXmlFile>${project.basedir}/src/main/resources/META-INF/spring-persistence.xml</persistenceXmlFile>
- <includes>org/apache/syncope/persistence/jpa/entity/**/*.class</includes>
+ <includes>org/apache/syncope/server/persistence/jpa/entity/**/*.class</includes>
<connectionDriverName>org.springframework.jdbc.datasource.DriverManagerDataSource</connectionDriverName>
<connectionProperties>
driverClassName=org.h2.Driver,
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/AbstractValidator.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/AbstractValidator.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/AbstractValidator.java
deleted file mode 100644
index 637f923..0000000
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/AbstractValidator.java
+++ /dev/null
@@ -1,54 +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.jpa.attrvalue.validation;
-
-import java.io.Serializable;
-import org.apache.syncope.persistence.api.attrvalue.validation.InvalidPlainAttrValueException;
-import org.apache.syncope.persistence.api.attrvalue.validation.ParsingValidationException;
-import org.apache.syncope.persistence.api.attrvalue.validation.Validator;
-import org.apache.syncope.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.persistence.api.entity.PlainSchema;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractValidator implements Validator, Serializable {
-
- private static final long serialVersionUID = -5439345166669502493L;
-
- /*
- * Logger
- */
- protected static final Logger LOG = LoggerFactory.getLogger(AbstractValidator.class);
-
- protected final PlainSchema schema;
-
- public AbstractValidator(final PlainSchema schema) {
- this.schema = schema;
- }
-
- @Override
- public void validate(String value, PlainAttrValue attrValue)
- throws ParsingValidationException, InvalidPlainAttrValueException {
-
- attrValue.parseValue(schema, value);
- doValidate(attrValue);
- }
-
- protected abstract void doValidate(PlainAttrValue attrValue) throws InvalidPlainAttrValueException;
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/AlwaysTrueValidator.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/AlwaysTrueValidator.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/AlwaysTrueValidator.java
deleted file mode 100644
index 919da6d..0000000
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/AlwaysTrueValidator.java
+++ /dev/null
@@ -1,40 +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.jpa.attrvalue.validation;
-
-import org.apache.syncope.persistence.api.attrvalue.validation.InvalidPlainAttrValueException;
-import org.apache.syncope.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.persistence.api.entity.PlainSchema;
-
-public class AlwaysTrueValidator extends AbstractValidator {
-
- private static final long serialVersionUID = 872107345555773183L;
-
- public AlwaysTrueValidator(final PlainSchema schema) {
- super(schema);
- }
-
- @Override
- protected void doValidate(final PlainAttrValue attrValue) throws InvalidPlainAttrValueException {
- Boolean value = attrValue.getValue();
- if (!value) {
- throw new InvalidPlainAttrValueException("This attribute must be set to \"true\"");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/BasicValidator.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/BasicValidator.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/BasicValidator.java
deleted file mode 100644
index a2b9731..0000000
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/BasicValidator.java
+++ /dev/null
@@ -1,54 +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.jpa.attrvalue.validation;
-
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.types.AttrSchemaType;
-import org.apache.syncope.persistence.api.attrvalue.validation.InvalidPlainAttrValueException;
-import org.apache.syncope.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.persistence.api.entity.PlainSchema;
-
-public class BasicValidator extends AbstractValidator {
-
- private static final long serialVersionUID = -2606728447694223607L;
-
- public BasicValidator(final PlainSchema schema) {
- super(schema);
- }
-
- @Override
- protected void doValidate(final PlainAttrValue attrValue) throws InvalidPlainAttrValueException {
- if (AttrSchemaType.Enum == schema.getType()) {
- final String[] enumeration = schema.getEnumerationValues().split(SyncopeConstants.ENUM_VALUES_SEPARATOR);
- final String value = attrValue.getStringValue();
-
- boolean found = false;
- for (int i = 0; i < enumeration.length && !found; i++) {
- if (enumeration[i].trim().equals(value)) {
- found = true;
- }
- }
-
- if (!found) {
- throw new InvalidPlainAttrValueException(
- "'" + value + "' is not one of: " + schema.getEnumerationValues());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/EmailAddressValidator.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/EmailAddressValidator.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/EmailAddressValidator.java
deleted file mode 100644
index d334b65..0000000
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/attrvalue/validation/EmailAddressValidator.java
+++ /dev/null
@@ -1,42 +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.jpa.attrvalue.validation;
-
-import java.util.regex.Matcher;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.persistence.api.attrvalue.validation.InvalidPlainAttrValueException;
-import org.apache.syncope.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.persistence.api.entity.PlainSchema;
-
-public class EmailAddressValidator extends AbstractValidator {
-
- private static final long serialVersionUID = 792457177290331518L;
-
- public EmailAddressValidator(final PlainSchema schema) {
- super(schema);
- }
-
- @Override
- protected void doValidate(final PlainAttrValue attrValue) throws InvalidPlainAttrValueException {
- Matcher matcher = SyncopeConstants.EMAIL_PATTERN.matcher(attrValue.<CharSequence>getValue());
- if (!matcher.matches()) {
- throw new InvalidPlainAttrValueException("\"" + attrValue.getValue() + "\" is not a valid email address");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/AbstractContentDealer.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/AbstractContentDealer.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/AbstractContentDealer.java
deleted file mode 100644
index e3ad2d4..0000000
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/AbstractContentDealer.java
+++ /dev/null
@@ -1,88 +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.jpa.content;
-
-import java.io.IOException;
-import java.util.Properties;
-import javax.annotation.Resource;
-import javax.sql.DataSource;
-import org.apache.syncope.server.spring.ResourceWithFallbackLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.support.PropertiesLoaderUtils;
-import org.springframework.dao.DataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-public abstract class AbstractContentDealer {
-
- protected static final Logger LOG = LoggerFactory.getLogger(AbstractContentDealer.class);
-
- protected static final String ROOT_ELEMENT = "dataset";
-
- @Resource(name = "database.schema")
- protected String dbSchema;
-
- @Resource(name = "indexesXML")
- private ResourceWithFallbackLoader indexesXML;
-
- @Resource(name = "viewsXML")
- private ResourceWithFallbackLoader viewsXML;
-
- @Autowired
- protected DataSource dataSource;
-
- protected void createIndexes() throws IOException {
- LOG.debug("Creating indexes");
-
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
-
- Properties indexes = PropertiesLoaderUtils.loadProperties(indexesXML.getResource());
- for (String idx : indexes.stringPropertyNames()) {
- LOG.debug("Creating index {}", indexes.get(idx).toString());
-
- try {
- jdbcTemplate.execute(indexes.get(idx).toString());
- } catch (DataAccessException e) {
- LOG.error("Could not create index ", e);
- }
- }
-
- LOG.debug("Indexes created");
- }
-
- protected void createViews() throws IOException {
- LOG.debug("Creating views");
-
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
-
- Properties views = PropertiesLoaderUtils.loadProperties(viewsXML.getResource());
- for (String idx : views.stringPropertyNames()) {
- LOG.debug("Creating view {}", views.get(idx).toString());
-
- try {
- jdbcTemplate.execute(views.get(idx).toString().replaceAll("\\n", " "));
- } catch (DataAccessException e) {
- LOG.error("Could not create view ", e);
- }
- }
-
- LOG.debug("Views created");
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/ContentLoaderHandler.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/ContentLoaderHandler.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/ContentLoaderHandler.java
deleted file mode 100644
index 2b3bd4a..0000000
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/ContentLoaderHandler.java
+++ /dev/null
@@ -1,199 +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.jpa.content;
-
-import org.apache.syncope.server.utils.DataFormat;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.text.ParseException;
-import java.util.HashMap;
-import java.util.Map;
-import javax.sql.DataSource;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Hex;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.dao.DataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.ResultSetExtractor;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * SAX handler for generating SQL INSERT statements out of given XML file.
- */
-class ContentLoaderHandler extends DefaultHandler {
-
- private static final Logger LOG = LoggerFactory.getLogger(ContentLoaderHandler.class);
-
- private final DataSource dataSource;
-
- private final String rootElement;
-
- public ContentLoaderHandler(final DataSource dataSource, final String rootElement) {
- this.dataSource = dataSource;
- this.rootElement = rootElement;
- }
-
- private Object[] getParameters(final String tableName, final Attributes attrs) {
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
-
- Map<String, Integer> colTypes = jdbcTemplate.query("SELECT * FROM " + tableName,
- new ResultSetExtractor<Map<String, Integer>>() {
-
- @Override
- public Map<String, Integer> extractData(final ResultSet rs) throws SQLException, DataAccessException {
- Map<String, Integer> colTypes = new HashMap<String, Integer>();
- for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
- colTypes.put(rs.getMetaData().getColumnName(i).toUpperCase(),
- rs.getMetaData().getColumnType(i));
- }
- return colTypes;
- }
- });
-
- Object[] parameters = new Object[attrs.getLength()];
- for (int i = 0; i < attrs.getLength(); i++) {
- Integer colType = colTypes.get(attrs.getQName(i).toUpperCase());
- if (colType == null) {
- LOG.warn("No column type found for {}", attrs.getQName(i).toUpperCase());
- colType = Types.VARCHAR;
- }
-
- switch (colType) {
- case Types.INTEGER:
- case Types.TINYINT:
- case Types.SMALLINT:
- try {
- parameters[i] = Integer.valueOf(attrs.getValue(i));
- } catch (NumberFormatException e) {
- LOG.error("Unparsable Integer '{}'", attrs.getValue(i));
- parameters[i] = attrs.getValue(i);
- }
- break;
-
- case Types.NUMERIC:
- case Types.DECIMAL:
- case Types.BIGINT:
- try {
- parameters[i] = Long.valueOf(attrs.getValue(i));
- } catch (NumberFormatException e) {
- LOG.error("Unparsable Long '{}'", attrs.getValue(i));
- parameters[i] = attrs.getValue(i);
- }
- break;
-
- case Types.DOUBLE:
- try {
- parameters[i] = Double.valueOf(attrs.getValue(i));
- } catch (NumberFormatException e) {
- LOG.error("Unparsable Double '{}'", attrs.getValue(i));
- parameters[i] = attrs.getValue(i);
- }
- break;
-
- case Types.REAL:
- case Types.FLOAT:
- try {
- parameters[i] = Float.valueOf(attrs.getValue(i));
- } catch (NumberFormatException e) {
- LOG.error("Unparsable Float '{}'", attrs.getValue(i));
- parameters[i] = attrs.getValue(i);
- }
- break;
-
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- try {
- parameters[i] = DataFormat.parseDate(attrs.getValue(i));
- } catch (ParseException e) {
- LOG.error("Unparsable Date '{}'", attrs.getValue(i));
- parameters[i] = attrs.getValue(i);
- }
- break;
-
- case Types.BIT:
- case Types.BOOLEAN:
- parameters[i] = "1".equals(attrs.getValue(i)) ? Boolean.TRUE : Boolean.FALSE;
- break;
-
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- try {
- parameters[i] = Hex.decodeHex(attrs.getValue(i).toCharArray());
- } catch (DecoderException | IllegalArgumentException e) {
- parameters[i] = attrs.getValue(i);
- }
- break;
-
- case Types.BLOB:
- try {
- parameters[i] = Hex.decodeHex(attrs.getValue(i).toCharArray());
- } catch (DecoderException | IllegalArgumentException e) {
- LOG.warn("Error decoding hex string to specify a blob parameter", e);
- parameters[i] = attrs.getValue(i);
- } catch (Exception e) {
- LOG.warn("Error creating a new blob parameter", e);
- }
- break;
-
- default:
- parameters[i] = attrs.getValue(i);
- }
- }
-
- return parameters;
- }
-
- @Override
- public void startElement(final String uri, final String localName, final String qName, final Attributes atts)
- throws SAXException {
-
- // skip root element
- if (rootElement.equals(qName)) {
- return;
- }
-
- StringBuilder query = new StringBuilder("INSERT INTO ").append(qName).append('(');
-
- StringBuilder values = new StringBuilder();
-
- for (int i = 0; i < atts.getLength(); i++) {
- query.append(atts.getQName(i));
- values.append('?');
- if (i < atts.getLength() - 1) {
- query.append(',');
- values.append(',');
- }
- }
- query.append(") VALUES (").append(values).append(')');
-
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
-
- try {
- jdbcTemplate.update(query.toString(), getParameters(qName, atts));
- } catch (DataAccessException e) {
- LOG.error("While trying to perform {}", query, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/XMLContentLoader.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/XMLContentLoader.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/XMLContentLoader.java
deleted file mode 100644
index e222501..0000000
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/content/XMLContentLoader.java
+++ /dev/null
@@ -1,89 +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.jpa.content;
-
-import java.io.IOException;
-import java.io.InputStream;
-import javax.annotation.Resource;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import org.apache.commons.io.IOUtils;
-import org.apache.syncope.persistence.api.content.ContentLoader;
-import org.apache.syncope.persistence.jpa.entity.conf.JPAConf;
-import org.apache.syncope.server.spring.ResourceWithFallbackLoader;
-import org.springframework.dao.DataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Initialize Database with default content if no data is present already.
- */
-@Component
-public class XMLContentLoader extends AbstractContentDealer implements ContentLoader {
-
- @Resource(name = "contentXML")
- private ResourceWithFallbackLoader contentXML;
-
- @Transactional
- @Override
- public void load() {
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
-
- boolean existingData;
- try {
- existingData = jdbcTemplate.queryForObject("SELECT COUNT(0) FROM " + JPAConf.TABLE, Integer.class) > 0;
- } catch (DataAccessException e) {
- LOG.error("Could not access to table " + JPAConf.TABLE, e);
- existingData = true;
- }
-
- if (existingData) {
- LOG.info("Data found in the database, leaving untouched");
- } else {
- LOG.info("Empty database found, loading default content");
-
- try {
- loadDefaultContent();
- } catch (Exception e) {
- LOG.error("While loading default content", e);
- }
- try {
- createIndexes();
- createViews();
- } catch (IOException e) {
- LOG.error("While creating indexes and views", e);
- }
- }
- }
-
- private void loadDefaultContent() throws Exception {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- InputStream in = null;
- try {
- in = contentXML.getResource().getInputStream();
-
- SAXParser parser = factory.newSAXParser();
- parser.parse(in, new ContentLoaderHandler(dataSource, ROOT_ELEMENT));
- LOG.debug("Default content successfully loaded");
- } finally {
- IOUtils.closeQuietly(in);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/AbstractDAO.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/AbstractDAO.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/AbstractDAO.java
deleted file mode 100644
index b7b1f5d..0000000
--- a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/dao/AbstractDAO.java
+++ /dev/null
@@ -1,117 +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.jpa.dao;
-
-import java.util.List;
-import javax.persistence.CacheRetrieveMode;
-import javax.persistence.CacheStoreMode;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceContextType;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.persistence.api.dao.DAO;
-import org.apache.syncope.persistence.api.dao.search.OrderByClause;
-import org.apache.syncope.persistence.api.entity.Entity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Configurable;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.util.ReflectionUtils;
-
-@Configurable
-public abstract class AbstractDAO<E extends Entity<KEY>, KEY> implements DAO<E, KEY> {
-
- /**
- * Logger.
- */
- protected static final Logger LOG = LoggerFactory.getLogger(DAO.class);
-
- private static final String CACHE_STORE_MODE = "javax.persistence.cache.storeMode";
-
- private static final String CACHE_RETRIEVE_MODE = "javax.persistence.cache.retrieveMode";
-
- @Value("#{entityManager}")
- @PersistenceContext(type = PersistenceContextType.TRANSACTION)
- protected EntityManager entityManager;
-
- protected CacheRetrieveMode getCacheRetrieveMode() {
- return entityManager.getProperties().containsKey(CACHE_RETRIEVE_MODE)
- ? (CacheRetrieveMode) entityManager.getProperties().get(CACHE_RETRIEVE_MODE)
- : CacheRetrieveMode.BYPASS;
- }
-
- protected void setCacheRetrieveMode(final CacheRetrieveMode retrieveMode) {
- if (retrieveMode != null) {
- entityManager.getProperties().put(CACHE_RETRIEVE_MODE, retrieveMode);
- }
- }
-
- protected CacheStoreMode getCacheStoreMode() {
- return entityManager.getProperties().containsKey(CACHE_STORE_MODE)
- ? (CacheStoreMode) entityManager.getProperties().get(CACHE_STORE_MODE)
- : CacheStoreMode.BYPASS;
- }
-
- protected void setCacheStoreMode(final CacheStoreMode storeMode) {
- if (storeMode != null) {
- entityManager.getProperties().put(CACHE_STORE_MODE, storeMode);
- }
- }
-
- protected String toOrderByStatement(final Class<? extends Entity<KEY>> beanClass, final String prefix,
- final List<OrderByClause> orderByClauses) {
-
- StringBuilder statement = new StringBuilder();
-
- for (OrderByClause clause : orderByClauses) {
- String field = clause.getField().trim();
- if (ReflectionUtils.findField(beanClass, field) != null) {
- if (StringUtils.isNotBlank(prefix)) {
- statement.append(prefix).append('.');
- }
- statement.append(field).append(' ').append(clause.getDirection().name());
- }
- }
-
- if (statement.length() > 0) {
- statement.insert(0, "ORDER BY ");
- }
- return statement.toString();
- }
-
- @Override
- public void refresh(final E entity) {
- entityManager.refresh(entity);
- }
-
- @Override
- public void detach(final E entity) {
- entityManager.detach(entity);
- }
-
- @Override
- public void flush() {
- entityManager.flush();
- }
-
- @Override
- public void clear() {
- entityManager.clear();
- }
-}