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/11/06 11:00:46 UTC
[1/5] syncope git commit: Upgrading codemirror
Repository: syncope
Updated Branches:
refs/heads/master 518d0c506 -> eec662457
Upgrading codemirror
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/b845cf52
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/b845cf52
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/b845cf52
Branch: refs/heads/master
Commit: b845cf52cf5fbb16fe14e9c517d21e5e1669f713
Parents: 518d0c5
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Nov 5 14:49:55 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Nov 5 14:49:55 2015 +0100
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/b845cf52/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b1e7be1..a82b427 100644
--- a/pom.xml
+++ b/pom.xml
@@ -384,7 +384,7 @@ under the License.
<font-awesome.version>4.4.0</font-awesome.version>
<ionicons.version>2.0.1</ionicons.version>
<highlightjs.version>8.7</highlightjs.version>
- <codemirror.version>5.7</codemirror.version>
+ <codemirror.version>5.8</codemirror.version>
<jsplumb.version>1.7.5</jsplumb.version>
<wicket.version>7.1.0</wicket.version>
[3/5] syncope git commit: [SYNCOPE-725] Refactoring completed
Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
index 20baa6b..7e71cfd 100644
--- a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
@@ -331,6 +331,7 @@ under the License.
<DerSchema name="csvuserid" expression="firstname + ',' + surname" anyTypeClass_name="csv"/>
<DerSchema name="cn" expression="surname + ', ' + firstname" anyTypeClass_name="minimal user"/>
<DerSchema name="noschema" expression="surname + ', ' + notfound" anyTypeClass_name="other"/>
+ <DerSchema name="info" expression="username + ' - ' + creationDate + '[' + failedLogins + ']'" anyTypeClass_name="minimal user"/>
<PlainSchema name="icon" type="String" anyTypeClass_name="minimal group"
mandatoryCondition="false" multivalue="0" uniqueConstraint="0" readonly="0"/>
@@ -443,10 +444,7 @@ under the License.
<UPlainAttrValue id="36" attribute_id="125" stringValue="vivaldi@syncope.org"/>
<UPlainAttr id="126" owner_id="3" schema_name="type"/>
<UPlainAttrValue id="37" attribute_id="126" stringValue="F"/>
-
- <UDerAttr id="100" schema_name="cn" owner_id="3"/>
- <UDerAttr id="101" schema_name="cn" owner_id="1"/>
-
+
<GPlainAttr id="600" owner_id="1" schema_name="icon"/>
<GPlainAttrValue attribute_id="600" id="40" stringValue="niceIcon"/>
@@ -474,14 +472,6 @@ under the License.
<GPlainAttr id="995" owner_id="13" schema_name="title"/>
<GPlainAttrValue attribute_id="995" id="95" stringValue="r13"/>
- <GDerAttr id="100" owner_id="1" schema_name="rderiveddata"/>
-
- <GDerAttr id="101" owner_id="1" schema_name="displayProperty"/>
-
- <GDerAttr id="102" owner_id="4" schema_name="displayProperty"/>
-
- <GDerAttr id="103" owner_id="1" schema_name="rderToBePropagated"/>
-
<ConnInstance id="100" displayName="ConnInstance100"
location="${connid.location}"
bundleName="net.tirasa.connid.bundles.soap"
@@ -765,7 +755,7 @@ under the License.
connObjectKey="0" password="0" purpose="PROPAGATION"/>
<MappingItem id="111" extAttrName="fullname" mapping_id="1"
intAttrName="cn" intMappingType="UserDerivedSchema" mandatoryCondition="true"
- connObjectKey="0" password="0" purpose="BOTH"/>
+ connObjectKey="0" password="0" purpose="PROPAGATION"/>
<Provision id="2" resource_name="ws-target-resource-update" anyType_name="USER" objectClass="__ACCOUNT__"/>
<Mapping id="2" provision_id="2"/>
@@ -846,7 +836,7 @@ under the License.
connObjectKey="0" password="0" purpose="SYNCHRONIZATION"/>
<MappingItem id="207" extAttrName="__NAME__" mapping_id="9"
intAttrName="csvuserid" intMappingType="UserDerivedSchema" mandatoryCondition="true"
- connObjectKey="1" password="0" purpose="BOTH"/>
+ connObjectKey="1" password="0" purpose="PROPAGATION"/>
<MappingItem id="208" extAttrName="theirgroup" mapping_id="9"
intAttrName="rderToBePropagated" intMappingType="GroupDerivedSchema" mandatoryCondition="false"
connObjectKey="0" password="0" purpose="PROPAGATION"/>
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/DerAttrHandler.java
----------------------------------------------------------------------
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/DerAttrHandler.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/DerAttrHandler.java
new file mode 100644
index 0000000..bc70fb8
--- /dev/null
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/DerAttrHandler.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.core.provisioning.api;
+
+import java.util.Map;
+import org.apache.syncope.core.persistence.api.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
+
+public interface DerAttrHandler {
+
+ /**
+ * Calculates derived attribute value associated to the given any, for the given derived schema.
+ *
+ * @param any any object
+ * @param schema derived schema
+ * @return derived attribute value
+ */
+ String getValue(Any<?> any, DerSchema schema);
+
+ /**
+ * Calculates derived attributes values associated to the given any.
+ *
+ * @param any any object
+ * @return derived attribute values, either for local cache or external resources
+ */
+ Map<DerSchema, String> getValues(Any<?> any);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/VirAttrHandler.java
----------------------------------------------------------------------
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/VirAttrHandler.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/VirAttrHandler.java
index 2e31204..0b8d60f 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/VirAttrHandler.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/VirAttrHandler.java
@@ -34,7 +34,7 @@ public interface VirAttrHandler {
* @return virtual attribute values, either for local cache or external resource, if resource is owned by the given
* any and associated to the given virtual schema; empty list otherwise.
*/
- List<String> getValues(Any<?, ?> any, VirSchema schema);
+ List<String> getValues(Any<?> any, VirSchema schema);
/**
* Query external resources (or cache, if configured) associated to the given any for values associated to all
@@ -44,6 +44,6 @@ public interface VirAttrHandler {
* @param any any object
* @return virtual attribute values, either for local cache or external resources
*/
- Map<VirSchema, List<String>> getValues(Any<?, ?> any);
+ Map<VirSchema, List<String>> getValues(Any<?> any);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/PushActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/PushActions.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/PushActions.java
index fee3a45..9a3c15b 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/PushActions.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/sync/PushActions.java
@@ -37,7 +37,7 @@ public interface PushActions extends ProvisioningActions {
* @return any.
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> A beforeAssign(
+ <A extends Any<?>> A beforeAssign(
ProvisioningProfile<?, ?> profile,
A any) throws JobExecutionException;
@@ -50,7 +50,7 @@ public interface PushActions extends ProvisioningActions {
* @return any.
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> A beforeProvision(
+ <A extends Any<?>> A beforeProvision(
ProvisioningProfile<?, ?> profile,
A any) throws JobExecutionException;
@@ -63,7 +63,7 @@ public interface PushActions extends ProvisioningActions {
* @return any.
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> A beforeUpdate(
+ <A extends Any<?>> A beforeUpdate(
ProvisioningProfile<?, ?> profile,
A any) throws JobExecutionException;
@@ -76,7 +76,7 @@ public interface PushActions extends ProvisioningActions {
* @return any.
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> A beforeLink(
+ <A extends Any<?>> A beforeLink(
ProvisioningProfile<?, ?> profile,
A any) throws JobExecutionException;
@@ -89,7 +89,7 @@ public interface PushActions extends ProvisioningActions {
* @return any.
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> A beforeUnlink(
+ <A extends Any<?>> A beforeUnlink(
ProvisioningProfile<?, ?> profile,
A any) throws JobExecutionException;
@@ -102,7 +102,7 @@ public interface PushActions extends ProvisioningActions {
* @return any.
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> A beforeUnassign(
+ <A extends Any<?>> A beforeUnassign(
ProvisioningProfile<?, ?> profile,
A any) throws JobExecutionException;
@@ -115,7 +115,7 @@ public interface PushActions extends ProvisioningActions {
* @return any.
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> A beforeDeprovision(
+ <A extends Any<?>> A beforeDeprovision(
ProvisioningProfile<?, ?> profile,
A any) throws JobExecutionException;
@@ -128,7 +128,7 @@ public interface PushActions extends ProvisioningActions {
* @return any.
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> A beforeDelete(
+ <A extends Any<?>> A beforeDelete(
ProvisioningProfile<?, ?> profile,
A any) throws JobExecutionException;
@@ -142,7 +142,7 @@ public interface PushActions extends ProvisioningActions {
* @param error error being reported
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> void onError(
+ <A extends Any<?>> void onError(
ProvisioningProfile<?, ?> profile,
A any,
ProvisioningReport result,
@@ -157,7 +157,7 @@ public interface PushActions extends ProvisioningActions {
* @param result operation result.
* @throws JobExecutionException in case of generic failure
*/
- <A extends Any<?, ?>> void after(
+ <A extends Any<?>> void after(
ProvisioningProfile<?, ?> profile,
A any,
ProvisioningReport result) throws JobExecutionException;
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DerAttrHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DerAttrHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DerAttrHandlerImpl.java
new file mode 100644
index 0000000..2711fc0
--- /dev/null
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DerAttrHandlerImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.java;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.jexl2.JexlContext;
+import org.apache.commons.jexl2.MapContext;
+import org.apache.syncope.core.misc.jexl.JexlUtils;
+import org.apache.syncope.core.persistence.api.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
+import org.apache.syncope.core.provisioning.api.DerAttrHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+@Component
+public class DerAttrHandlerImpl implements DerAttrHandler {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DerAttrHandler.class);
+
+ @Autowired
+ private AnyUtilsFactory anyUtilsFactory;
+
+ private Map<DerSchema, String> getValues(final Any<?> any, final Set<DerSchema> schemas) {
+ Map<DerSchema, String> result = new HashMap<>(schemas.size());
+
+ for (DerSchema schema : schemas) {
+ JexlContext jexlContext = new MapContext();
+ JexlUtils.addPlainAttrsToContext(any.getPlainAttrs(), jexlContext);
+ JexlUtils.addFieldsToContext(any, jexlContext);
+
+ result.put(schema, JexlUtils.evaluate(schema.getExpression(), jexlContext));
+ }
+
+ return result;
+ }
+
+ @Transactional(readOnly = true)
+ @Override
+ public String getValue(final Any<?> any, final DerSchema schema) {
+ if (!anyUtilsFactory.getInstance(any).getAllowedSchemas(any, DerSchema.class).contains(schema)) {
+ LOG.debug("{} not allowed for {}", schema, any);
+ return null;
+ }
+
+ return getValues(any, Collections.singleton(schema)).get(schema);
+ }
+
+ @Transactional(readOnly = true)
+ @Override
+ public Map<DerSchema, String> getValues(final Any<?> any) {
+ return getValues(any, anyUtilsFactory.getInstance(any).getAllowedSchemas(any, DerSchema.class));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/VirAttrHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/VirAttrHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/VirAttrHandlerImpl.java
index 182d3cf..ca50635 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/VirAttrHandlerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/VirAttrHandlerImpl.java
@@ -18,7 +18,6 @@
*/
package org.apache.syncope.core.provisioning.java;
-import org.apache.syncope.core.provisioning.api.VirAttrHandler;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -29,18 +28,15 @@ import java.util.Set;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.core.misc.utils.MappingUtils;
-import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
import org.apache.syncope.core.persistence.api.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
import org.apache.syncope.core.persistence.api.entity.VirSchema;
-import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.provisioning.api.Connector;
import org.apache.syncope.core.provisioning.api.ConnectorFactory;
+import org.apache.syncope.core.provisioning.api.VirAttrHandler;
import org.apache.syncope.core.provisioning.api.cache.VirAttrCache;
import org.apache.syncope.core.provisioning.api.cache.VirAttrCacheValue;
import org.identityconnectors.framework.common.objects.Attribute;
@@ -58,32 +54,19 @@ public class VirAttrHandlerImpl implements VirAttrHandler {
private static final Logger LOG = LoggerFactory.getLogger(VirAttrHandler.class);
@Autowired
- private AnyObjectDAO anyObjectDAO;
-
- @Autowired
- private UserDAO userDAO;
-
- @Autowired
private ConnectorFactory connFactory;
- /**
- * Virtual attribute cache.
- */
@Autowired
private VirAttrCache virAttrCache;
@Autowired
private MappingUtils mappingUtils;
- private Map<VirSchema, List<String>> getValues(final Any<?, ?> any, final Set<VirSchema> schemas) {
- Collection<? extends ExternalResource> ownedResources;
- if (any instanceof User) {
- ownedResources = userDAO.findAllResources((User) any);
- } else if (any instanceof AnyObject) {
- ownedResources = anyObjectDAO.findAllResources((AnyObject) any);
- } else {
- ownedResources = ((Group) any).getResources();
- }
+ @Autowired
+ private AnyUtilsFactory anyUtilsFactory;
+
+ private Map<VirSchema, List<String>> getValues(final Any<?> any, final Set<VirSchema> schemas) {
+ Collection<? extends ExternalResource> ownedResources = anyUtilsFactory.getInstance(any).getAllResources(any);
Map<VirSchema, List<String>> result = new HashMap<>();
@@ -159,8 +142,8 @@ public class VirAttrHandlerImpl implements VirAttrHandler {
@Transactional(readOnly = true)
@Override
- public List<String> getValues(final Any<?, ?> any, final VirSchema schema) {
- if (!any.getAllowedVirSchemas().contains(schema)) {
+ public List<String> getValues(final Any<?> any, final VirSchema schema) {
+ if (!anyUtilsFactory.getInstance(any).getAllowedSchemas(any, VirSchema.class).contains(schema)) {
LOG.debug("{} not allowed for {}", schema, any);
return Collections.emptyList();
}
@@ -170,7 +153,7 @@ public class VirAttrHandlerImpl implements VirAttrHandler {
@Transactional(readOnly = true)
@Override
- public Map<VirSchema, List<String>> getValues(final Any<?, ?> any) {
- return getValues(any, any.getAllowedVirSchemas());
+ public Map<VirSchema, List<String>> getValues(final Any<?> any) {
+ return getValues(any, anyUtilsFactory.getInstance(any).getAllowedSchemas(any, VirSchema.class));
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
index bd7fb02..281fc69 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -42,10 +41,8 @@ import org.apache.syncope.common.lib.to.RelationshipTO;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.lib.types.IntMappingType;
import org.apache.syncope.common.lib.types.MappingPurpose;
-import org.apache.syncope.common.lib.types.PatchOperation;
import org.apache.syncope.common.lib.types.ResourceOperation;
import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidPlainAttrValueException;
-import org.apache.syncope.core.persistence.api.dao.DerAttrDAO;
import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
@@ -55,7 +52,6 @@ import org.apache.syncope.core.persistence.api.dao.PolicyDAO;
import org.apache.syncope.core.persistence.api.dao.GroupDAO;
import org.apache.syncope.core.persistence.api.dao.UserDAO;
import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.EntityFactory;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
@@ -84,6 +80,7 @@ import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
import org.apache.syncope.core.persistence.api.entity.resource.Provision;
import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.DerAttrHandler;
import org.apache.syncope.core.provisioning.api.VirAttrHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -126,9 +123,6 @@ abstract class AbstractAnyDataBinder {
protected PlainAttrDAO plainAttrDAO;
@Autowired
- protected DerAttrDAO derAttrDAO;
-
- @Autowired
protected PlainAttrValueDAO plainAttrValueDAO;
@Autowired
@@ -147,6 +141,9 @@ abstract class AbstractAnyDataBinder {
protected AnyUtilsFactory anyUtilsFactory;
@Autowired
+ protected DerAttrHandler derAttrHandler;
+
+ @Autowired
protected VirAttrHandler virAttrHander;
@Autowired
@@ -155,7 +152,7 @@ abstract class AbstractAnyDataBinder {
@Autowired
protected MappingUtils mappingUtils;
- protected void setRealm(final Any<?, ?> any, final AnyPatch anyPatch) {
+ protected void setRealm(final Any<?> any, final AnyPatch anyPatch) {
if (anyPatch.getRealm() != null && StringUtils.isNotBlank(anyPatch.getRealm().getValue())) {
Realm newRealm = realmDAO.find(anyPatch.getRealm().getValue());
if (newRealm == null) {
@@ -221,7 +218,7 @@ abstract class AbstractAnyDataBinder {
}
}
- private List<String> evaluateMandatoryCondition(final Provision provision, final Any<?, ?> any) {
+ private List<String> evaluateMandatoryCondition(final Provision provision, final Any<?> any) {
List<String> missingAttrNames = new ArrayList<>();
if (provision != null) {
@@ -231,7 +228,7 @@ abstract class AbstractAnyDataBinder {
|| item.getPurpose() == MappingPurpose.BOTH)) {
List<PlainAttrValue> values = mappingUtils.getIntValues(
- provision, item, Collections.<Any<?, ?>>singletonList(any));
+ provision, item, Collections.<Any<?>>singletonList(any));
if (values.isEmpty() && JexlUtils.evaluateMandatoryCondition(item.getMandatoryCondition(), any)) {
missingAttrNames.add(item.getIntAttrName());
}
@@ -243,7 +240,7 @@ abstract class AbstractAnyDataBinder {
}
private SyncopeClientException checkMandatoryOnResources(
- final Any<?, ?> any, final Set<ExternalResource> resources) {
+ final Any<?> any, final Set<ExternalResource> resources) {
SyncopeClientException reqValMissing = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
@@ -262,14 +259,14 @@ abstract class AbstractAnyDataBinder {
return reqValMissing;
}
- private SyncopeClientException checkMandatory(final Any<?, ?> any) {
+ private SyncopeClientException checkMandatory(final Any<?> any, final AnyUtils anyUtils) {
SyncopeClientException reqValMissing = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
// Check if there is some mandatory schema defined for which no value has been provided
- for (PlainSchema schema : any.getAllowedPlainSchemas()) {
+ for (PlainSchema schema : anyUtils.getAllowedSchemas(any, PlainSchema.class)) {
if (any.getPlainAttr(schema.getKey()) == null
&& !schema.isReadonly()
- && (JexlUtils.evaluateMandatoryCondition(schema.getMandatoryCondition(), any))) {
+ && JexlUtils.evaluateMandatoryCondition(schema.getMandatoryCondition(), any)) {
LOG.error("Mandatory schema " + schema.getKey() + " not provided with values");
@@ -280,20 +277,6 @@ abstract class AbstractAnyDataBinder {
return reqValMissing;
}
- private Set<ExternalResource> getAllResources(final Any<?, ?> any) {
- Set<ExternalResource> resources = new HashSet<>();
-
- if (any instanceof User) {
- resources.addAll(userDAO.findAllResources((User) any));
- } else if (any instanceof Group) {
- resources.addAll(((Group) any).getResources());
- } else if (any instanceof AnyObject) {
- resources.addAll(anyObjectDAO.findAllResources((AnyObject) any));
- }
-
- return resources;
- }
-
@SuppressWarnings({ "unchecked", "rawtypes" })
private void processAttrPatch(final Any any, final AttrPatch patch, final PlainSchema schema,
final AnyUtils anyUtils, final Set<ExternalResource> resources, final PropagationByResource propByRes,
@@ -331,11 +314,11 @@ abstract class AbstractAnyDataBinder {
Collection<Long> valuesToBeRemoved = CollectionUtils.collect(attr.getValues(),
new Transformer<PlainAttrValue, Long>() {
- @Override
- public Long transform(final PlainAttrValue input) {
- return input.getKey();
- }
- });
+ @Override
+ public Long transform(final PlainAttrValue input) {
+ return input.getKey();
+ }
+ });
for (Long attrValueKey : valuesToBeRemoved) {
plainAttrValueDAO.delete(attrValueKey, anyUtils.plainAttrValueClass());
}
@@ -377,48 +360,7 @@ abstract class AbstractAnyDataBinder {
}
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void processAttrPatch(final Any any, final AttrPatch patch, final DerSchema schema,
- final AnyUtils anyUtils, final Set<ExternalResource> resources, final PropagationByResource propByRes) {
-
- DerAttr<?> attr = any.getDerAttr(schema.getKey());
- if (attr == null) {
- LOG.debug("No plain attribute found for schema {}", schema);
-
- switch (patch.getOperation()) {
- case ADD_REPLACE:
- attr = anyUtils.newDerAttr();
- ((DerAttr) attr).setOwner(any);
- attr.setSchema(schema);
- any.add(attr);
- break;
-
- case DELETE:
- default:
- return;
- }
- }
-
- if (patch.getOperation() == PatchOperation.DELETE) {
- derAttrDAO.delete(attr);
- }
-
- for (ExternalResource resource : resources) {
- for (MappingItem mapItem : MappingUtils.getPropagationMappingItems(resource.getProvision(any.getType()))) {
- if (schema.getKey().equals(mapItem.getIntAttrName())
- && mapItem.getIntMappingType() == anyUtils.derIntMappingType()) {
-
- propByRes.add(ResourceOperation.UPDATE, resource.getKey());
-
- if (mapItem.isConnObjectKey() && !attr.getValue(any.getPlainAttrs()).isEmpty()) {
- propByRes.addOldConnObjectKey(resource.getKey(), attr.getValue(any.getPlainAttrs()));
- }
- }
- }
- }
- }
-
- protected PropagationByResource fill(final Any<?, ?> any, final AnyPatch anyPatch, final AnyUtils anyUtils,
+ protected PropagationByResource fill(final Any<?> any, final AnyPatch anyPatch, final AnyUtils anyUtils,
final SyncopeClientCompositeException scce) {
PropagationByResource propByRes = new PropagationByResource();
@@ -461,7 +403,7 @@ abstract class AbstractAnyDataBinder {
}
}
- Set<ExternalResource> resources = getAllResources(any);
+ Set<ExternalResource> resources = anyUtils.getAllResources(any);
SyncopeClientException invalidValues = SyncopeClientException.build(ClientExceptionType.InvalidValues);
// 3. plain attributes
@@ -480,20 +422,7 @@ abstract class AbstractAnyDataBinder {
scce.addException(invalidValues);
}
- // 4. derived attributes
- for (AttrPatch patch : anyPatch.getDerAttrs()) {
- if (patch.getAttrTO() != null) {
- DerSchema schema = getDerSchema(patch.getAttrTO().getSchema());
- if (schema == null) {
- LOG.debug("Invalid " + DerSchema.class.getSimpleName()
- + "{}, ignoring...", patch.getAttrTO().getSchema());
- } else {
- processAttrPatch(any, patch, schema, anyUtils, resources, propByRes);
- }
- }
- }
-
- SyncopeClientException requiredValuesMissing = checkMandatory(any);
+ SyncopeClientException requiredValuesMissing = checkMandatory(any, anyUtils);
if (!requiredValuesMissing.isEmpty()) {
scce.addException(requiredValuesMissing);
}
@@ -554,23 +483,12 @@ abstract class AbstractAnyDataBinder {
scce.addException(invalidValues);
}
- // 2. derived attributes
- for (AttrTO attributeTO : anyTO.getDerAttrs()) {
- DerSchema derSchema = getDerSchema(attributeTO.getSchema());
- if (derSchema != null) {
- DerAttr derAttr = anyUtils.newDerAttr();
- derAttr.setOwner(any);
- derAttr.setSchema(derSchema);
- any.add(derAttr);
- }
- }
-
- SyncopeClientException requiredValuesMissing = checkMandatory(any);
+ SyncopeClientException requiredValuesMissing = checkMandatory(any, anyUtils);
if (!requiredValuesMissing.isEmpty()) {
scce.addException(requiredValuesMissing);
}
- // 3. realm & resources
+ // 2. realm & resources
Realm realm = realmDAO.find(anyTO.getRealm());
if (realm == null) {
SyncopeClientException noRealm = SyncopeClientException.build(ClientExceptionType.InvalidRealm);
@@ -588,7 +506,7 @@ abstract class AbstractAnyDataBinder {
}
}
- requiredValuesMissing = checkMandatoryOnResources(any, getAllResources(any));
+ requiredValuesMissing = checkMandatoryOnResources(any, anyUtils.getAllResources(any));
if (!requiredValuesMissing.isEmpty()) {
scce.addException(requiredValuesMissing);
}
@@ -602,8 +520,8 @@ abstract class AbstractAnyDataBinder {
protected void fillTO(final AnyTO anyTO,
final String realmFullPath,
final Collection<? extends AnyTypeClass> auxClasses,
- final Collection<? extends PlainAttr<?>> attrs,
- final Collection<? extends DerAttr<?>> derAttrs,
+ final Collection<? extends PlainAttr<?>> plainAttrs,
+ final Map<DerSchema, String> derAttrs,
final Map<VirSchema, List<String>> virAttrs,
final Collection<? extends ExternalResource> resources) {
@@ -617,19 +535,19 @@ abstract class AbstractAnyDataBinder {
}
}, anyTO.getAuxClasses());
- for (PlainAttr<?> attr : attrs) {
+ for (PlainAttr<?> plainAttr : plainAttrs) {
AttrTO attrTO = new AttrTO();
- attrTO.setSchema(attr.getSchema().getKey());
- attrTO.getValues().addAll(attr.getValuesAsStrings());
- attrTO.setReadonly(attr.getSchema().isReadonly());
+ attrTO.setSchema(plainAttr.getSchema().getKey());
+ attrTO.getValues().addAll(plainAttr.getValuesAsStrings());
+ attrTO.setReadonly(plainAttr.getSchema().isReadonly());
anyTO.getPlainAttrs().add(attrTO);
}
- for (DerAttr<?> derAttr : derAttrs) {
+ for (Map.Entry<DerSchema, String> entry : derAttrs.entrySet()) {
AttrTO attrTO = new AttrTO();
- attrTO.setSchema(derAttr.getSchema().getKey());
- attrTO.getValues().add(derAttr.getValue(attrs));
+ attrTO.setSchema(entry.getKey().getKey());
+ attrTO.getValues().add(entry.getValue());
attrTO.setReadonly(true);
anyTO.getDerAttrs().add(attrTO);
@@ -649,21 +567,21 @@ abstract class AbstractAnyDataBinder {
}
}
- protected RelationshipTO getRelationshipTO(final Relationship<? extends Any<?, ?>, AnyObject> relationship) {
+ protected RelationshipTO getRelationshipTO(final Relationship<? extends Any<?>, AnyObject> relationship) {
return new RelationshipTO.Builder().
left(relationship.getLeftEnd().getType().getKey(), relationship.getLeftEnd().getKey()).
right(relationship.getRightEnd().getType().getKey(), relationship.getRightEnd().getKey()).
build();
}
- protected MembershipTO getMembershipTO(final Membership<? extends Any<?, ?>> membership) {
+ protected MembershipTO getMembershipTO(final Membership<? extends Any<?>> membership) {
return new MembershipTO.Builder().
left(membership.getLeftEnd().getType().getKey(), membership.getLeftEnd().getKey()).
group(membership.getRightEnd().getKey(), membership.getRightEnd().getName()).
build();
}
- protected Map<String, String> getConnObjectKeys(final Any<?, ?> any) {
+ protected Map<String, String> getConnObjectKeys(final Any<?> any) {
Map<String, String> connObjectKeys = new HashMap<>();
Iterable<? extends ExternalResource> iterable = any instanceof User
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java
index 2dca6e4..a8ebe0c 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyObjectDataBinderImpl.java
@@ -42,6 +42,7 @@ import org.apache.syncope.common.lib.types.ResourceOperation;
import org.apache.syncope.core.misc.spring.BeanUtils;
import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
import org.apache.syncope.core.persistence.api.entity.AnyType;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.RelationshipType;
import org.apache.syncope.core.persistence.api.entity.VirSchema;
import org.apache.syncope.core.persistence.api.entity.anyobject.AMembership;
@@ -78,13 +79,12 @@ public class AnyObjectDataBinderImpl extends AbstractAnyDataBinder implements An
BeanUtils.copyProperties(anyObject, anyObjectTO, IGNORE_PROPERTIES);
+ Map<DerSchema, String> derAttrValues = derAttrHandler.getValues(anyObject);
Map<VirSchema, List<String>> virAttrValues = details
? virAttrHander.getValues(anyObject)
: Collections.<VirSchema, List<String>>emptyMap();
-
fillTO(anyObjectTO, anyObject.getRealm().getFullPath(), anyObject.getAuxClasses(),
- anyObject.getPlainAttrs(), anyObject.getDerAttrs(), virAttrValues,
- anyObjectDAO.findAllResources(anyObject));
+ anyObject.getPlainAttrs(), derAttrValues, virAttrValues, anyObjectDAO.findAllResources(anyObject));
if (details) {
// relationships
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
index 620cdf8..680cf4a 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
@@ -35,6 +35,7 @@ import org.apache.syncope.common.lib.types.PropagationByResource;
import org.apache.syncope.core.provisioning.api.data.GroupDataBinder;
import org.apache.syncope.core.misc.search.SearchCondConverter;
import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.DynGroupMembership;
import org.apache.syncope.core.persistence.api.entity.VirSchema;
import org.apache.syncope.core.persistence.api.entity.anyobject.ADynGroupMembership;
@@ -206,12 +207,12 @@ public class GroupDataBinderImpl extends AbstractAnyDataBinder implements GroupD
groupTO.setGroupOwner(group.getGroupOwner().getKey());
}
+ Map<DerSchema, String> derAttrValues = derAttrHandler.getValues(group);
Map<VirSchema, List<String>> virAttrValues = details
? virAttrHander.getValues(group)
: Collections.<VirSchema, List<String>>emptyMap();
-
fillTO(groupTO, group.getRealm().getFullPath(), group.getAuxClasses(),
- group.getPlainAttrs(), group.getDerAttrs(), virAttrValues, group.getResources());
+ group.getPlainAttrs(), derAttrValues, virAttrValues, group.getResources());
if (group.getADynMembership() != null) {
groupTO.setADynMembershipCond(group.getADynMembership().getFIQLCond());
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
index 49527b9..5bf13c5 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
@@ -57,6 +57,7 @@ import org.apache.syncope.core.misc.security.Encryptor;
import org.apache.syncope.core.misc.spring.BeanUtils;
import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
import org.apache.syncope.core.persistence.api.dao.RoleDAO;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.RelationshipType;
import org.apache.syncope.core.persistence.api.entity.Role;
import org.apache.syncope.core.persistence.api.entity.VirSchema;
@@ -442,12 +443,12 @@ public class UserDataBinderImpl extends AbstractAnyDataBinder implements UserDat
userTO.setSecurityQuestion(user.getSecurityQuestion().getKey());
}
+ Map<DerSchema, String> derAttrValues = derAttrHandler.getValues(user);
Map<VirSchema, List<String>> virAttrValues = details
? virAttrHander.getValues(user)
: Collections.<VirSchema, List<String>>emptyMap();
-
fillTO(userTO, user.getRealm().getFullPath(), user.getAuxClasses(),
- user.getPlainAttrs(), user.getDerAttrs(), virAttrValues, userDAO.findAllResources(user));
+ user.getPlainAttrs(), derAttrValues, virAttrValues, userDAO.findAllResources(user));
if (details) {
// roles
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java
index c6f08a3..820c5f3 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java
@@ -49,7 +49,6 @@ import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.group.Group;
import org.apache.syncope.core.persistence.api.entity.task.NotificationTask;
import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
-import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.provisioning.api.data.GroupDataBinder;
@@ -57,11 +56,14 @@ import org.apache.syncope.core.provisioning.api.data.UserDataBinder;
import org.apache.syncope.core.misc.search.SearchCondConverter;
import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
+import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.persistence.api.entity.AnyAbout;
import org.apache.syncope.core.persistence.api.entity.AnyType;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.VirSchema;
+import org.apache.syncope.core.provisioning.api.DerAttrHandler;
import org.apache.syncope.core.provisioning.api.VirAttrHandler;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
@@ -87,6 +89,9 @@ public class NotificationManagerImpl implements NotificationManager {
public static final String MAIL_TEMPLATE_TEXT_SUFFIX = ".txt.vm";
@Autowired
+ private DerSchemaDAO derSchemaDAO;
+
+ @Autowired
private VirSchemaDAO virSchemaDAO;
/**
@@ -144,6 +149,9 @@ public class NotificationManagerImpl implements NotificationManager {
private ToolManager velocityToolManager;
@Autowired
+ private DerAttrHandler derAttrHander;
+
+ @Autowired
private VirAttrHandler virAttrHander;
@Autowired
@@ -171,7 +179,7 @@ public class NotificationManagerImpl implements NotificationManager {
*/
private NotificationTask getNotificationTask(
final Notification notification,
- final Any<?, ?> any,
+ final Any<?> any,
final Map<String, Object> model) {
if (any != null) {
@@ -269,7 +277,7 @@ public class NotificationManagerImpl implements NotificationManager {
final Object output,
final Object... input) {
- Any<?, ?> any = null;
+ Any<?> any = null;
if (before instanceof UserTO) {
any = userDAO.find(((UserTO) before).getKey());
@@ -358,18 +366,20 @@ public class NotificationManagerImpl implements NotificationManager {
break;
case UserDerivedSchema:
- UDerAttr derAttr = user.getDerAttr(recipientAttrName);
- if (derAttr != null) {
- email = derAttr.getValue(user.getPlainAttrs());
+ DerSchema schema = derSchemaDAO.find(recipientAttrName);
+ if (schema == null) {
+ LOG.warn("Ignoring non existing {} {}", DerSchema.class.getSimpleName(), recipientAttrName);
+ } else {
+ email = derAttrHander.getValue(user, schema);
}
break;
case UserVirtualSchema:
- VirSchema schema = virSchemaDAO.find(recipientAttrName);
- if (schema == null) {
+ VirSchema virSchema = virSchemaDAO.find(recipientAttrName);
+ if (virSchema == null) {
LOG.warn("Ignoring non existing {} {}", VirSchema.class.getSimpleName(), recipientAttrName);
} else {
- List<String> virAttrValues = virAttrHander.getValues(user, schema);
+ List<String> virAttrValues = virAttrHander.getValues(user, virSchema);
email = virAttrValues.isEmpty() ? null : virAttrValues.get(0);
}
break;
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java
index cbc26f5..37dc851 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java
@@ -266,8 +266,8 @@ public abstract class AbstractPropagationTaskExecutor implements PropagationTask
}
}
- protected Any<?, ?> getAny(final PropagationTask task) {
- Any<?, ?> any = null;
+ protected Any<?> getAny(final PropagationTask task) {
+ Any<?> any = null;
if (task.getAnyKey() != null) {
switch (task.getAnyTypeKind()) {
@@ -325,7 +325,7 @@ public abstract class AbstractPropagationTaskExecutor implements PropagationTask
* update, this any object used to have the current resource assigned by more than one mean (for example,
* two different memberships with the same resource).
*/
- Any<?, ?> any = getAny(task);
+ Any<?> any = getAny(task);
Collection<String> resources = any instanceof User
? userDAO.findAllResourceNames((User) any)
: any instanceof AnyObject
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java
index 6dbd0eb..0ab0e25 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java
@@ -86,7 +86,7 @@ public class LDAPMembershipPropagationActions extends DefaultPropagationActions
JexlContext jexlContext = new MapContext();
JexlUtils.addFieldsToContext(group, jexlContext);
JexlUtils.addPlainAttrsToContext(group.getPlainAttrs(), jexlContext);
- JexlUtils.addDerAttrsToContext(group.getDerAttrs(), group.getPlainAttrs(), jexlContext);
+ JexlUtils.addDerAttrsToContext(group, jexlContext);
String groupConnObjectLinkLink =
JexlUtils.evaluate(provision.getMapping().getConnObjectLink(), jexlContext);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/PropagationManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/PropagationManagerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/PropagationManagerImpl.java
index 192b26d..f816228 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/PropagationManagerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/PropagationManagerImpl.java
@@ -50,6 +50,7 @@ import org.apache.syncope.core.persistence.api.dao.AnyDAO;
import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
import org.apache.syncope.core.persistence.api.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
import org.apache.syncope.core.persistence.api.entity.VirSchema;
import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
import org.apache.syncope.core.persistence.api.entity.group.Group;
@@ -109,8 +110,11 @@ public class PropagationManagerImpl implements PropagationManager {
@Autowired
protected MappingUtils mappingUtils;
- protected Any<?, ?> find(final AnyTypeKind kind, final Long key) {
- AnyDAO<? extends Any<?, ?>> dao;
+ @Autowired
+ protected AnyUtilsFactory anyUtilsFactory;
+
+ protected Any<?> find(final AnyTypeKind kind, final Long key) {
+ AnyDAO<? extends Any<?>> dao;
switch (kind) {
case ANY_OBJECT:
dao = anyObjectDAO;
@@ -152,7 +156,7 @@ public class PropagationManagerImpl implements PropagationManager {
}
protected List<PropagationTask> getCreateTasks(
- final Any<?, ?> any,
+ final Any<?> any,
final String password,
final Boolean enable,
final PropagationByResource propByRes,
@@ -227,11 +231,11 @@ public class PropagationManagerImpl implements PropagationManager {
toBeExcluded.addAll(CollectionUtils.collect(userPatch.getResources(),
new Transformer<StringPatchItem, String>() {
- @Override
- public String transform(final StringPatchItem input) {
- return input.getValue();
- }
- }));
+ @Override
+ public String transform(final StringPatchItem input) {
+ return input.getValue();
+ }
+ }));
toBeExcluded.removeAll(pwdResourceNames);
tasks.addAll(getUserUpdateTasks(wfResult, true, toBeExcluded));
}
@@ -249,7 +253,7 @@ public class PropagationManagerImpl implements PropagationManager {
}
protected List<PropagationTask> getUpdateTasks(
- final Any<?, ?> any,
+ final Any<?> any,
final String password,
final boolean changePwd,
final Boolean enable,
@@ -271,7 +275,7 @@ public class PropagationManagerImpl implements PropagationManager {
final PropagationByResource propByRes,
final Collection<String> noPropResourceNames) {
- Any<?, ?> any = find(kind, key);
+ Any<?> any = find(kind, key);
PropagationByResource localPropByRes = new PropagationByResource();
@@ -289,7 +293,7 @@ public class PropagationManagerImpl implements PropagationManager {
}
protected List<PropagationTask> getDeleteTasks(
- final Any<?, ?> any,
+ final Any<?> any,
final PropagationByResource propByRes,
final Collection<String> noPropResourceNames) {
@@ -308,7 +312,7 @@ public class PropagationManagerImpl implements PropagationManager {
* @param vAttrs virtual attributes to be set
* @return list of propagation tasks created
*/
- protected List<PropagationTask> createTasks(final Any<?, ?> any,
+ protected List<PropagationTask> createTasks(final Any<?> any,
final String password, final boolean changePwd,
final Boolean enable, final boolean deleteOnResource, final PropagationByResource propByRes,
final Collection<AttrTO> vAttrs) {
@@ -338,22 +342,20 @@ public class PropagationManagerImpl implements PropagationManager {
LOG.warn("Ignoring invalid {} {}", VirSchema.class.getSimpleName(), vAttr.getSchema());
} else if (schema.isReadonly()) {
LOG.warn("Ignoring read-only {} {}", VirSchema.class.getSimpleName(), vAttr.getSchema());
- } else {
- if (any.getAllowedVirSchemas().contains(schema)
- && virtualResources.contains(schema.getProvision().getResource().getKey())) {
+ } else if (anyUtilsFactory.getInstance(any).getAllowedSchemas(any, VirSchema.class).contains(schema)
+ && virtualResources.contains(schema.getProvision().getResource().getKey())) {
- Set<Attribute> values = vAttrMap.get(schema.getProvision().getResource().getKey());
- if (values == null) {
- values = new HashSet<>();
- vAttrMap.put(schema.getProvision().getResource().getKey(), values);
- }
- values.add(AttributeBuilder.build(schema.getExtAttrName(), vAttr.getValues()));
-
- propByRes.add(ResourceOperation.UPDATE, schema.getProvision().getResource().getKey());
- } else {
- LOG.warn("{} not owned by or {} not allowed for {}",
- schema.getProvision().getResource(), schema, any);
+ Set<Attribute> values = vAttrMap.get(schema.getProvision().getResource().getKey());
+ if (values == null) {
+ values = new HashSet<>();
+ vAttrMap.put(schema.getProvision().getResource().getKey(), values);
}
+ values.add(AttributeBuilder.build(schema.getExtAttrName(), vAttr.getValues()));
+
+ propByRes.add(ResourceOperation.UPDATE, schema.getProvision().getResource().getKey());
+ } else {
+ LOG.warn("{} not owned by or {} not allowed for {}",
+ schema.getProvision().getResource(), schema, any);
}
}
LOG.debug("With virtual attributes {}:\n{}\n{}", any, propByRes, vAttrMap);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractPushResultHandler.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractPushResultHandler.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractPushResultHandler.java
index 5daea51..fa3d332 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractPushResultHandler.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractPushResultHandler.java
@@ -61,9 +61,9 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
@Autowired
protected MappingUtils mappingUtils;
- protected abstract String getName(Any<?, ?> any);
+ protected abstract String getName(Any<?> any);
- protected void deprovision(final Any<?, ?> any) {
+ protected void deprovision(final Any<?> any) {
AnyTO before = getAnyTO(any.getKey());
List<String> noPropResources = new ArrayList<>(before.getResources());
@@ -76,7 +76,7 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
noPropResources));
}
- protected void provision(final Any<?, ?> any, final Boolean enabled) {
+ protected void provision(final Any<?> any, final Boolean enabled) {
AnyTO before = getAnyTO(any.getKey());
List<String> noPropResources = new ArrayList<>(before.getResources());
@@ -94,7 +94,7 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
}
@SuppressWarnings("unchecked")
- protected void link(final Any<?, ?> any, final Boolean unlink) {
+ protected void link(final Any<?> any, final Boolean unlink) {
AnyPatch patch = newPatch(any.getKey());
patch.getResources().add(new StringPatchItem.Builder().
operation(unlink ? PatchOperation.DELETE : PatchOperation.ADD_REPLACE).
@@ -104,7 +104,7 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
}
@SuppressWarnings("unchecked")
- protected void unassign(final Any<?, ?> any) {
+ protected void unassign(final Any<?> any) {
AnyPatch patch = newPatch(any.getKey());
patch.getResources().add(new StringPatchItem.Builder().
operation(PatchOperation.DELETE).
@@ -115,7 +115,7 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
deprovision(any);
}
- protected void assign(final Any<?, ?> any, final Boolean enabled) {
+ protected void assign(final Any<?> any, final Boolean enabled) {
AnyPatch patch = newPatch(any.getKey());
patch.getResources().add(new StringPatchItem.Builder().
operation(PatchOperation.ADD_REPLACE).
@@ -148,7 +148,7 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public boolean handle(final long anyKey) {
- Any<?, ?> any = null;
+ Any<?> any = null;
try {
any = getAny(anyKey);
doHandle(any);
@@ -169,7 +169,7 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
}
}
- protected final void doHandle(final Any<?, ?> any) throws JobExecutionException {
+ protected final void doHandle(final Any<?> any) throws JobExecutionException {
AnyUtils anyUtils = anyUtilsFactory.getInstance(any);
ProvisioningReport result = new ProvisioningReport();
@@ -399,7 +399,7 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
}
}
- protected Any<?, ?> update(final Any<?, ?> any, final Boolean enabled) {
+ protected Any<?> update(final Any<?> any, final Boolean enabled) {
boolean changepwd;
Collection<String> resourceNames;
if (any instanceof User) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncopeResultHandler.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncopeResultHandler.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncopeResultHandler.java
index d4bef63..4e6f2eb 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncopeResultHandler.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncopeResultHandler.java
@@ -137,7 +137,7 @@ public abstract class AbstractSyncopeResultHandler<T extends ProvisioningTask, A
protected abstract AnyTO getAnyTO(long key);
- protected abstract Any<?, ?> getAny(long key);
+ protected abstract Any<?> getAny(long key);
protected abstract AnyPatch newPatch(final long key);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectPushResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectPushResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectPushResultHandlerImpl.java
index 7d9ab24..f9546cc 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectPushResultHandlerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectPushResultHandlerImpl.java
@@ -36,12 +36,12 @@ public class AnyObjectPushResultHandlerImpl extends AbstractPushResultHandler im
}
@Override
- protected String getName(final Any<?, ?> any) {
+ protected String getName(final Any<?> any) {
return StringUtils.EMPTY;
}
@Override
- protected Any<?, ?> getAny(final long key) {
+ protected Any<?> getAny(final long key) {
try {
return anyObjectDAO.authFind(key);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectSyncResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectSyncResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectSyncResultHandlerImpl.java
index 75703b3..d194a25 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectSyncResultHandlerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectSyncResultHandlerImpl.java
@@ -54,7 +54,7 @@ public class AnyObjectSyncResultHandlerImpl extends AbstractSyncResultHandler im
}
@Override
- protected Any<?, ?> getAny(final long key) {
+ protected Any<?> getAny(final long key) {
try {
return anyObjectDAO.authFind(key);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultPushActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultPushActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultPushActions.java
index bb75f66..a005493 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultPushActions.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultPushActions.java
@@ -34,49 +34,49 @@ public abstract class DefaultPushActions implements PushActions {
}
@Override
- public <A extends Any<?, ?>> A beforeAssign(final ProvisioningProfile<?, ?> profile, final A any)
+ public <A extends Any<?>> A beforeAssign(final ProvisioningProfile<?, ?> profile, final A any)
throws JobExecutionException {
return any;
}
@Override
- public <A extends Any<?, ?>> A beforeProvision(final ProvisioningProfile<?, ?> profile, final A any)
+ public <A extends Any<?>> A beforeProvision(final ProvisioningProfile<?, ?> profile, final A any)
throws JobExecutionException {
return any;
}
@Override
- public <A extends Any<?, ?>> A beforeLink(final ProvisioningProfile<?, ?> profile, final A any)
+ public <A extends Any<?>> A beforeLink(final ProvisioningProfile<?, ?> profile, final A any)
throws JobExecutionException {
return any;
}
@Override
- public <A extends Any<?, ?>> A beforeUnassign(final ProvisioningProfile<?, ?> profile, final A any)
+ public <A extends Any<?>> A beforeUnassign(final ProvisioningProfile<?, ?> profile, final A any)
throws JobExecutionException {
return any;
}
@Override
- public <A extends Any<?, ?>> A beforeDeprovision(final ProvisioningProfile<?, ?> profile, final A any)
+ public <A extends Any<?>> A beforeDeprovision(final ProvisioningProfile<?, ?> profile, final A any)
throws JobExecutionException {
return any;
}
@Override
- public <A extends Any<?, ?>> A beforeUnlink(final ProvisioningProfile<?, ?> profile, final A any)
+ public <A extends Any<?>> A beforeUnlink(final ProvisioningProfile<?, ?> profile, final A any)
throws JobExecutionException {
return any;
}
@Override
- public <A extends Any<?, ?>> void onError(
+ public <A extends Any<?>> void onError(
final ProvisioningProfile<?, ?> profile, final A any, final ProvisioningReport result,
final Exception error) throws JobExecutionException {
@@ -84,7 +84,7 @@ public abstract class DefaultPushActions implements PushActions {
}
@Override
- public <A extends Any<?, ?>> void after(
+ public <A extends Any<?>> void after(
final ProvisioningProfile<?, ?> profile, final A any, final ProvisioningReport result)
throws JobExecutionException {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupPushResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupPushResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupPushResultHandlerImpl.java
index 212eb84..571fc47 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupPushResultHandlerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupPushResultHandlerImpl.java
@@ -36,12 +36,12 @@ public class GroupPushResultHandlerImpl extends AbstractPushResultHandler implem
}
@Override
- protected String getName(final Any<?, ?> any) {
+ protected String getName(final Any<?> any) {
return Group.class.cast(any).getName();
}
@Override
- protected Any<?, ?> getAny(final long key) {
+ protected Any<?> getAny(final long key) {
try {
return groupDAO.authFind(key);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupSyncResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupSyncResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupSyncResultHandlerImpl.java
index db05ccd..c3c63fb 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupSyncResultHandlerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupSyncResultHandlerImpl.java
@@ -63,7 +63,7 @@ public class GroupSyncResultHandlerImpl extends AbstractSyncResultHandler implem
}
@Override
- protected Any<?, ?> getAny(final long key) {
+ protected Any<?> getAny(final long key) {
try {
return groupDAO.authFind(key);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
index e13407d..65b0cf7 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
@@ -145,13 +145,13 @@ public class PushJobDelegate extends AbstractProvisioningJobDelegate<PushTask> {
int count = anyDAO.count(SyncopeConstants.FULL_ADMIN_REALMS);
for (int page = 1; page <= (count / PAGE_SIZE) + 1; page++) {
- List<? extends Any<?, ?>> localAnys = StringUtils.isBlank(filter)
+ List<? extends Any<?>> localAnys = StringUtils.isBlank(filter)
? anyDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, page, PAGE_SIZE)
: searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
SearchCondConverter.convert(filter),
Collections.<OrderByClause>emptyList(), provision.getAnyType().getKind());
- for (Any<?, ?> any : localAnys) {
+ for (Any<?> any : localAnys) {
SyncopePushResultHandler handler;
switch (provision.getAnyType().getKind()) {
case USER:
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
index b0c4161..1c01497 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
@@ -199,9 +199,9 @@ public class SyncUtils {
}
}
- List<? extends Any<?, ?>> anys =
+ List<? extends Any<?>> anys =
getAnyDAO(connObjectKeyItem).findByAttrValue(connObjectKeyItem.getIntAttrName(), value);
- for (Any<?, ?> any : anys) {
+ for (Any<?> any : anys) {
result.add(any.getKey());
}
break;
@@ -210,7 +210,7 @@ public class SyncUtils {
case GroupDerivedSchema:
case AnyObjectDerivedSchema:
anys = getAnyDAO(connObjectKeyItem).findByDerAttrValue(connObjectKeyItem.getIntAttrName(), transfUid);
- for (Any<?, ?> any : anys) {
+ for (Any<?> any : anys) {
result.add(any.getKey());
}
break;
@@ -218,7 +218,7 @@ public class SyncUtils {
case UserKey:
case GroupKey:
case AnyObjectKey:
- Any<?, ?> any = getAnyDAO(connObjectKeyItem).find(Long.parseLong(transfUid));
+ Any<?> any = getAnyDAO(connObjectKeyItem).find(Long.parseLong(transfUid));
if (any != null) {
result.add(any.getKey());
}
@@ -249,7 +249,7 @@ public class SyncUtils {
final ConnectorObject connObj, final SyncCorrelationRule rule, final AnyTypeKind type) {
List<Long> result = new ArrayList<>();
- for (Any<?, ?> any : searchDAO.search(
+ for (Any<?> any : searchDAO.search(
SyncopeConstants.FULL_ADMIN_REALMS,
rule.getSearchCond(connObj),
Collections.<OrderByClause>emptyList(),
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserPushResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserPushResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserPushResultHandlerImpl.java
index 8f70560..03865d7 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserPushResultHandlerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserPushResultHandlerImpl.java
@@ -41,7 +41,7 @@ public class UserPushResultHandlerImpl extends AbstractPushResultHandler impleme
}
@Override
- protected void provision(final Any<?, ?> any, final Boolean enabled) {
+ protected void provision(final Any<?> any, final Boolean enabled) {
AnyTO before = getAnyTO(any.getKey());
List<String> noPropResources = new ArrayList<>(before.getResources());
@@ -60,12 +60,12 @@ public class UserPushResultHandlerImpl extends AbstractPushResultHandler impleme
}
@Override
- protected String getName(final Any<?, ?> any) {
+ protected String getName(final Any<?> any) {
return User.class.cast(any).getUsername();
}
@Override
- protected Any<?, ?> getAny(final long key) {
+ protected Any<?> getAny(final long key) {
try {
return userDAO.authFind(key);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserSyncResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserSyncResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserSyncResultHandlerImpl.java
index 530319e..2a222d0 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserSyncResultHandlerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserSyncResultHandlerImpl.java
@@ -54,7 +54,7 @@ public class UserSyncResultHandlerImpl extends AbstractSyncResultHandler impleme
}
@Override
- protected Any<?, ?> getAny(final long key) {
+ protected Any<?> getAny(final long key) {
try {
return userDAO.authFind(key);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/DerAttrTest.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/DerAttrTest.java b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/DerAttrTest.java
new file mode 100644
index 0000000..076d7bc
--- /dev/null
+++ b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/DerAttrTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.java;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.DerAttrHandler;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional("Master")
+public class DerAttrTest extends AbstractTest {
+
+ @Autowired
+ private DerSchemaDAO derSchemaDAO;
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private DerAttrHandler derAttrHandler;
+
+ @Test
+ public void derAttrFromSpecialAttrs() {
+ DerSchema info = derSchemaDAO.find("info");
+ assertEquals("username + ' - ' + creationDate + '[' + failedLogins + ']'", info.getExpression());
+
+ User user = userDAO.find(3L);
+ assertNotNull("did not get expected user", user);
+
+ String value = derAttrHandler.getValue(user, info);
+ assertNotNull(value);
+ assertFalse(value.isEmpty());
+ assertTrue(value.startsWith("vivaldi - 2010-10-20"));
+ assertTrue(value.endsWith("[0]"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
index fff8469..87770a6 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
@@ -51,7 +51,6 @@ import org.apache.syncope.core.persistence.api.attrvalue.validation.ParsingValid
import org.apache.syncope.core.persistence.api.dao.DuplicateException;
import org.apache.syncope.core.persistence.api.dao.MalformedPathException;
import org.apache.syncope.core.persistence.api.dao.NotFoundException;
-import org.apache.syncope.core.persistence.api.dao.UnallowedSchemaException;
import org.apache.syncope.core.workflow.api.WorkflowException;
import org.identityconnectors.framework.common.exceptions.ConfigurationException;
import org.identityconnectors.framework.common.exceptions.ConnectorException;
@@ -114,8 +113,6 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception>, R
header(RESTHeaders.ERROR_INFO, ex.getMessage());
} else if (ex instanceof DelegatedAdministrationException) {
builder = builder(ClientExceptionType.DelegatedAdministration, ExceptionUtils.getRootCauseMessage(ex));
- } else if (ex instanceof UnallowedSchemaException) {
- builder = builder(ClientExceptionType.UnallowedSchemas, ExceptionUtils.getRootCauseMessage(ex));
} else if (ex instanceof EntityExistsException || ex instanceof DuplicateException) {
builder = builder(ClientExceptionType.EntityExists, getJPAMessage(ex));
} else if (ex instanceof DataIntegrityViolationException || ex instanceof JpaSystemException) {
@@ -134,7 +131,7 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception>, R
builder = builder(validationEM.toResponse((ValidationException) ex)).
header(RESTHeaders.ERROR_CODE, ClientExceptionType.RESTValidation.name()).
header(RESTHeaders.ERROR_INFO, ClientExceptionType.RESTValidation.getInfoHeaderValue(
- ExceptionUtils.getRootCauseMessage(ex)));
+ ExceptionUtils.getRootCauseMessage(ex)));
ErrorTO error = new ErrorTO();
error.setStatus(ClientExceptionType.RESTValidation.getResponseStatus().getStatusCode());
@@ -147,7 +144,7 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception>, R
if (builder == null) {
builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).
header(RESTHeaders.ERROR_INFO, ClientExceptionType.Unknown.getInfoHeaderValue(
- ExceptionUtils.getRootCauseMessage(ex)));
+ ExceptionUtils.getRootCauseMessage(ex)));
ErrorTO error = new ErrorTO();
error.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
index 97f2876..07dba6e 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java
@@ -181,17 +181,16 @@ public abstract class AbstractAnyService<TO extends AnyTO, P extends AnyPatch>
P patch = newPatch(key);
switch (schemaType) {
- case DERIVED:
- patch.getDerAttrs().add(new AttrPatch.Builder().operation(operation).attrTO(attrTO).build());
- break;
-
case VIRTUAL:
patch.getVirAttrs().add(attrTO);
break;
case PLAIN:
- default:
patch.getPlainAttrs().add(new AttrPatch.Builder().operation(operation).attrTO(attrTO).build());
+ break;
+
+ case DERIVED:
+ default:
}
update(patch);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Create.java
----------------------------------------------------------------------
diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Create.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Create.java
index e911f98..eb22c06 100644
--- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Create.java
+++ b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Create.java
@@ -39,8 +39,7 @@ public class Create extends AbstractActivitiServiceTask {
protected void doExecute(final String executionId) {
UserTO userTO = engine.getRuntimeService().
getVariable(executionId, ActivitiUserWorkflowAdapter.USER_TO, UserTO.class);
- Boolean storePassword =
- engine.getRuntimeService().
+ Boolean storePassword = engine.getRuntimeService().
getVariable(executionId, ActivitiUserWorkflowAdapter.STORE_PASSWORD, Boolean.class);
// create and set workflow id
User user = entityFactory.newEntity(User.class);
[4/5] syncope git commit: [SYNCOPE-725] Refactoring completed
Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
index d4bce14..aa38d77 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
@@ -18,7 +18,6 @@
*/
package org.apache.syncope.core.persistence.jpa.dao;
-import java.util.Collections;
import java.util.List;
import javax.persistence.TypedQuery;
import org.apache.syncope.common.lib.types.AnyTypeKind;
@@ -27,7 +26,6 @@ import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
import org.apache.syncope.core.persistence.api.entity.AnyUtils;
import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
-import org.apache.syncope.core.persistence.api.entity.Attr;
import org.apache.syncope.core.persistence.api.entity.VirSchema;
import org.apache.syncope.core.persistence.api.entity.resource.Provision;
import org.apache.syncope.core.persistence.jpa.entity.JPAAnyUtilsFactory;
@@ -78,11 +76,6 @@ public class JPAVirSchemaDAO extends AbstractDAO<VirSchema, String> implements V
}
@Override
- public <T extends Attr<VirSchema, ?>> List<T> findAttrs(final VirSchema schema, final Class<T> reference) {
- return Collections.emptyList();
- }
-
- @Override
public VirSchema save(final VirSchema virSchema) {
return entityManager().merge(virSchema);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractAny.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractAny.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractAny.java
index 041c54f..ba02c45 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractAny.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractAny.java
@@ -21,7 +21,6 @@ package org.apache.syncope.core.persistence.jpa.entity;
import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResource;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.Column;
@@ -34,23 +33,19 @@ import org.apache.commons.collections4.Predicate;
import org.apache.commons.collections4.Transformer;
import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.Realm;
import org.apache.syncope.core.persistence.api.entity.VirSchema;
-import org.apache.syncope.core.persistence.api.entity.anyobject.AMembership;
-import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
-import org.apache.syncope.core.persistence.api.entity.group.TypeExtension;
import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.user.UMembership;
-import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.persistence.jpa.validation.entity.AnyCheck;
+@AnyCheck
@MappedSuperclass
-public abstract class AbstractAny<P extends PlainAttr<?>, D extends DerAttr<?>>
+public abstract class AbstractAny<P extends PlainAttr<?>>
extends AbstractAnnotatedEntity<Long>
- implements Any<P, D> {
+ implements Any<P> {
private static final long serialVersionUID = -2666540708092702810L;
@@ -114,18 +109,6 @@ public abstract class AbstractAny<P extends PlainAttr<?>, D extends DerAttr<?>>
});
}
- @Override
- public D getDerAttr(final String derSchemaName) {
- return CollectionUtils.find(getDerAttrs(), new Predicate<D>() {
-
- @Override
- public boolean evaluate(final D derAttr) {
- return derAttr != null && derAttr.getSchema() != null
- && derSchemaName.equals(derAttr.getSchema().getKey());
- }
- });
- }
-
protected abstract List<JPAExternalResource> internalGetResources();
@Override
@@ -159,70 +142,8 @@ public abstract class AbstractAny<P extends PlainAttr<?>, D extends DerAttr<?>>
private void populateAllowedSchemas(final Collection<? extends AnyTypeClass> anyTypeClasses) {
for (AnyTypeClass anyTypeClass : anyTypeClasses) {
allowedPlainSchemas.addAll(anyTypeClass.getPlainSchemas());
- }
-
- for (AnyTypeClass anyTypeClass : anyTypeClasses) {
allowedDerSchemas.addAll(anyTypeClass.getDerSchemas());
- }
-
- for (AnyTypeClass anyTypeClass : anyTypeClasses) {
allowedVirSchemas.addAll(anyTypeClass.getVirSchemas());
}
}
-
- private void populateAllowedSchemas() {
- synchronized (this) {
- if (allowedPlainSchemas == null) {
- allowedPlainSchemas = new HashSet<>();
- } else {
- allowedPlainSchemas.clear();
- }
- if (allowedDerSchemas == null) {
- allowedDerSchemas = new HashSet<>();
- } else {
- allowedDerSchemas.clear();
- }
- if (allowedVirSchemas == null) {
- allowedVirSchemas = new HashSet<>();
- } else {
- allowedVirSchemas.clear();
- }
-
- populateAllowedSchemas(getType().getClasses());
- populateAllowedSchemas(getAuxClasses());
- if (this instanceof User) {
- for (UMembership memb : ((User) this).getMemberships()) {
- for (TypeExtension typeExtension : memb.getRightEnd().getTypeExtensions()) {
- populateAllowedSchemas(typeExtension.getAuxClasses());
- }
- }
- }
- if (this instanceof AnyObject) {
- for (AMembership memb : ((AnyObject) this).getMemberships()) {
- for (TypeExtension typeExtension : memb.getRightEnd().getTypeExtensions()) {
- populateAllowedSchemas(typeExtension.getAuxClasses());
- }
- }
- }
- }
- }
-
- @Override
- public Set<PlainSchema> getAllowedPlainSchemas() {
- populateAllowedSchemas();
- return allowedPlainSchemas;
- }
-
- @Override
- public Set<DerSchema> getAllowedDerSchemas() {
- populateAllowedSchemas();
- return allowedDerSchemas;
- }
-
- @Override
- public Set<VirSchema> getAllowedVirSchemas() {
- populateAllowedSchemas();
- return allowedVirSchemas;
- }
-
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractAttr.java
deleted file mode 100644
index 694b18f..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractAttr.java
+++ /dev/null
@@ -1,60 +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.core.persistence.jpa.entity;
-
-import java.util.Collections;
-import java.util.Set;
-import org.apache.syncope.core.persistence.api.dao.UnallowedSchemaException;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.Attr;
-import org.apache.syncope.core.persistence.api.entity.DerSchema;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.api.entity.Schema;
-import org.apache.syncope.core.persistence.api.entity.VirSchema;
-
-public abstract class AbstractAttr<S extends Schema, O extends Any<?, ?>>
- extends AbstractEntity<Long> implements Attr<S, O> {
-
- private static final long serialVersionUID = -7722134717360731874L;
-
- @SuppressWarnings("unchecked")
- private Set<S> getAllowedSchemas(final O any) {
- Set<S> result = Collections.emptySet();
-
- if (getSchema() instanceof PlainSchema) {
- result = (Set<S>) any.getAllowedPlainSchemas();
- } else if (getSchema() instanceof DerSchema) {
- result = (Set<S>) any.getAllowedDerSchemas();
- } else if (getSchema() instanceof VirSchema) {
- result = (Set<S>) any.getAllowedVirSchemas();
- }
-
- return result;
- }
-
- protected void checkSchema(final S schema) {
- if (schema == null || getOwner() == null) {
- throw new IllegalStateException("First set owner then schema and finally add values");
- }
-
- if (!getAllowedSchemas(getOwner()).contains(schema)) {
- throw new UnallowedSchemaException(schema.getKey());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractDerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractDerAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractDerAttr.java
deleted file mode 100644
index 59f390d..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractDerAttr.java
+++ /dev/null
@@ -1,62 +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.core.persistence.jpa.entity;
-
-import java.util.Collection;
-import javax.persistence.Column;
-import javax.persistence.FetchType;
-import javax.persistence.ManyToOne;
-import javax.persistence.MappedSuperclass;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.misc.jexl.JexlUtils;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.DerSchema;
-
-@MappedSuperclass
-public abstract class AbstractDerAttr<O extends Any<?, ?>>
- extends AbstractAttr<DerSchema, O> implements DerAttr<O> {
-
- private static final long serialVersionUID = 4740924251090424771L;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @Column(name = "schema_name")
- private JPADerSchema schema;
-
- @Override
- public DerSchema getSchema() {
- return schema;
- }
-
- @Override
- public void setSchema(final DerSchema schema) {
- checkType(schema, JPADerSchema.class);
- this.schema = (JPADerSchema) schema;
- checkSchema(this.schema);
- }
-
- /**
- * @param attributes the set of attributes against which evaluate this derived attribute
- * @return the value of this derived attribute
- */
- @Override
- public String getValue(final Collection<? extends PlainAttr<?>> attributes) {
- return JexlUtils.evaluate(getSchema().getExpression(), getOwner(), attributes);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractDynMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractDynMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractDynMembership.java
index c7110d5..0b77dac 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractDynMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractDynMembership.java
@@ -24,7 +24,7 @@ import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.persistence.api.entity.DynMembership;
@MappedSuperclass
-public abstract class AbstractDynMembership<A extends Any<?, ?>>
+public abstract class AbstractDynMembership<A extends Any<?>>
extends AbstractEntity<Long> implements DynMembership<A> {
private static final long serialVersionUID = 921821654690948787L;
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java
index fdd257e..f892a8d 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java
@@ -25,6 +25,7 @@ import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
+import javax.validation.constraints.NotNull;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Transformer;
import org.apache.syncope.core.persistence.api.entity.Any;
@@ -37,11 +38,11 @@ import org.apache.syncope.core.persistence.jpa.validation.entity.PlainAttrCheck;
@MappedSuperclass
@PlainAttrCheck
-public abstract class AbstractPlainAttr<O extends Any<?, ?>>
- extends AbstractAttr<PlainSchema, O> implements PlainAttr<O> {
+public abstract class AbstractPlainAttr<O extends Any<?>> extends AbstractEntity<Long> implements PlainAttr<O> {
private static final long serialVersionUID = -9115431608821806124L;
+ @NotNull
@ManyToOne(fetch = FetchType.EAGER)
@Column(name = "schema_name")
protected JPAPlainSchema schema;
@@ -55,13 +56,20 @@ public abstract class AbstractPlainAttr<O extends Any<?, ?>>
public void setSchema(final PlainSchema schema) {
checkType(schema, JPAPlainSchema.class);
this.schema = (JPAPlainSchema) schema;
- checkSchema(this.schema);
}
protected abstract boolean addForMultiValue(PlainAttrValue attrValue);
+ private void checkNonNullSchema() {
+ if (schema == null) {
+ throw new IllegalStateException("First set owner then schema and finally add values");
+ }
+ }
+
@Override
public void add(final String value, final PlainAttrValue attrValue) {
+ checkNonNullSchema();
+
attrValue.setAttr(this);
getSchema().getValidator().validate(value, attrValue);
@@ -77,6 +85,8 @@ public abstract class AbstractPlainAttr<O extends Any<?, ?>>
@Override
public void add(final String value, final AnyUtils anyUtils) {
+ checkNonNullSchema();
+
PlainAttrValue attrValue;
if (getSchema().isUniqueConstraint()) {
attrValue = anyUtils.newPlainAttrUniqueValue();
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtils.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtils.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtils.java
index 7de2fbe..22c632a 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtils.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtils.java
@@ -18,38 +18,55 @@
*/
package org.apache.syncope.core.persistence.jpa.entity;
+import java.util.HashSet;
+import java.util.Set;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.AnyTO;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.common.lib.types.IntMappingType;
+import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
+import org.apache.syncope.core.persistence.api.dao.GroupDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAADerAttr;
+import org.apache.syncope.core.persistence.api.entity.Schema;
+import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
+import org.apache.syncope.core.persistence.api.entity.group.Group;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAPlainAttr;
import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAPlainAttrValue;
import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAnyObject;
-import org.apache.syncope.core.persistence.jpa.entity.group.JPAGDerAttr;
import org.apache.syncope.core.persistence.jpa.entity.group.JPAGPlainAttr;
import org.apache.syncope.core.persistence.jpa.entity.group.JPAGPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.jpa.entity.group.JPAGPlainAttrValue;
import org.apache.syncope.core.persistence.jpa.entity.group.JPAGroup;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPAUDerAttr;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUPlainAttr;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUPlainAttrValue;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
@SuppressWarnings({ "unchecked", "rawtypes" })
public class JPAAnyUtils implements AnyUtils {
private final AnyTypeKind anyTypeKind;
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private GroupDAO groupDAO;
+
+ @Autowired
+ private AnyObjectDAO anyObjectDAO;
+
protected JPAAnyUtils(final AnyTypeKind typeKind) {
this.anyTypeKind = typeKind;
}
@@ -60,7 +77,7 @@ public class JPAAnyUtils implements AnyUtils {
}
@Override
- public <T extends Any<?, ?>> Class<T> anyClass() {
+ public <T extends Any<?>> Class<T> anyClass() {
Class result;
switch (anyTypeKind) {
@@ -216,52 +233,6 @@ public class JPAAnyUtils implements AnyUtils {
}
@Override
- public <T extends DerAttr<?>> Class<T> derAttrClass() {
- Class result = null;
-
- switch (anyTypeKind) {
- case USER:
- result = JPAUDerAttr.class;
- break;
-
- case GROUP:
- result = JPAGDerAttr.class;
- break;
-
- case ANY_OBJECT:
- result = JPAADerAttr.class;
- break;
-
- default:
- }
-
- return result;
- }
-
- @Override
- public <T extends DerAttr<?>> T newDerAttr() {
- T result = null;
-
- switch (anyTypeKind) {
- case USER:
- result = (T) new JPAUDerAttr();
- break;
-
- case GROUP:
- result = (T) new JPAGDerAttr();
- break;
-
- case ANY_OBJECT:
- result = (T) new JPAADerAttr();
- break;
-
- default:
- }
-
- return result;
- }
-
- @Override
public IntMappingType plainIntMappingType() {
IntMappingType result = null;
@@ -352,4 +323,36 @@ public class JPAAnyUtils implements AnyUtils {
return result;
}
+
+ @Transactional(readOnly = true)
+ @Override
+ public Set<ExternalResource> getAllResources(final Any<?> any) {
+ Set<ExternalResource> resources = new HashSet<>();
+
+ if (any instanceof User) {
+ resources.addAll(userDAO.findAllResources((User) any));
+ } else if (any instanceof Group) {
+ resources.addAll(((Group) any).getResources());
+ } else if (any instanceof AnyObject) {
+ resources.addAll(anyObjectDAO.findAllResources((AnyObject) any));
+ }
+
+ return resources;
+ }
+
+ @Transactional(readOnly = true)
+ @Override
+ public <S extends Schema> Set<S> getAllowedSchemas(final Any<?> any, final Class<S> reference) {
+ Set<S> schemas = new HashSet<>();
+
+ if (any instanceof User) {
+ schemas.addAll(userDAO.findAllowedSchemas((User) any, reference));
+ } else if (any instanceof Group) {
+ schemas.addAll(groupDAO.findAllowedSchemas((Group) any, reference));
+ } else if (any instanceof AnyObject) {
+ schemas.addAll(anyObjectDAO.findAllowedSchemas((AnyObject) any, reference));
+ }
+
+ return schemas;
+ }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtilsFactory.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtilsFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtilsFactory.java
index 38e08b4..6aaf62d 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtilsFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyUtilsFactory.java
@@ -18,7 +18,10 @@
*/
package org.apache.syncope.core.persistence.jpa.entity;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.persistence.api.entity.AnyUtils;
import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
@@ -30,18 +33,25 @@ import org.springframework.stereotype.Component;
@Component
public class JPAAnyUtilsFactory implements AnyUtilsFactory {
+ private final Map<AnyTypeKind, AnyUtils> instances = new HashMap<>(3);
+
@Override
public AnyUtils getInstance(final AnyTypeKind anyTypeKind) {
- return new JPAAnyUtils(anyTypeKind);
- }
+ AnyUtils instance;
+ synchronized (instances) {
+ instance = instances.get(anyTypeKind);
+ if (instance == null) {
+ instance = new JPAAnyUtils(anyTypeKind);
+ ApplicationContextProvider.getBeanFactory().autowireBean(instance);
+ instances.put(anyTypeKind, instance);
+ }
+ }
- @Override
- public AnyUtils getInstance(final String anyTypeKind) {
- return new JPAAnyUtils(AnyTypeKind.valueOf(anyTypeKind));
+ return instance;
}
@Override
- public AnyUtils getInstance(final Any<?, ?> any) {
+ public AnyUtils getInstance(final Any<?> any) {
AnyTypeKind type = null;
if (any instanceof User) {
type = AnyTypeKind.USER;
@@ -55,7 +65,7 @@ public class JPAAnyUtilsFactory implements AnyUtilsFactory {
throw new IllegalArgumentException("Any type not supported: " + any.getClass().getName());
}
- return new JPAAnyUtils(type);
+ return getInstance(type);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
index 372e062..a31392f 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
@@ -60,7 +60,6 @@ import org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr;
import org.apache.syncope.core.persistence.api.entity.conf.CPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.conf.CPlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.conf.Conf;
-import org.apache.syncope.core.persistence.api.entity.group.GDerAttr;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrValue;
@@ -77,7 +76,6 @@ import org.apache.syncope.core.persistence.api.entity.task.SchedTask;
import org.apache.syncope.core.persistence.api.entity.task.SyncTask;
import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
import org.apache.syncope.core.persistence.api.entity.user.SecurityQuestion;
-import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
import org.apache.syncope.core.persistence.api.entity.user.UDynGroupMembership;
import org.apache.syncope.core.persistence.api.entity.user.UMembership;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
@@ -96,7 +94,6 @@ import org.apache.syncope.core.persistence.jpa.entity.conf.JPACPlainAttr;
import org.apache.syncope.core.persistence.jpa.entity.conf.JPACPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.jpa.entity.conf.JPACPlainAttrValue;
import org.apache.syncope.core.persistence.jpa.entity.conf.JPAConf;
-import org.apache.syncope.core.persistence.jpa.entity.group.JPAGDerAttr;
import org.apache.syncope.core.persistence.jpa.entity.group.JPAGPlainAttr;
import org.apache.syncope.core.persistence.jpa.entity.group.JPAGPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.jpa.entity.group.JPAGPlainAttrValue;
@@ -112,7 +109,6 @@ import org.apache.syncope.core.persistence.jpa.entity.task.JPAPushTask;
import org.apache.syncope.core.persistence.jpa.entity.task.JPASchedTask;
import org.apache.syncope.core.persistence.jpa.entity.task.JPASyncTask;
import org.apache.syncope.core.persistence.jpa.entity.task.JPATaskExec;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPAUDerAttr;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUDynGroupMembership;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUMembership;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUPlainAttr;
@@ -194,8 +190,6 @@ public class JPAEntityFactory implements EntityFactory {
result = (T) new JPAUPlainAttrUniqueValue();
} else if (reference.equals(DerSchema.class)) {
result = (T) new JPADerSchema();
- } else if (reference.equals(UDerAttr.class)) {
- result = (T) new JPAUDerAttr();
} else if (reference.equals(VirSchema.class)) {
result = (T) new JPAVirSchema();
} else if (reference.equals(Mapping.class)) {
@@ -208,8 +202,6 @@ public class JPAEntityFactory implements EntityFactory {
result = (T) new JPAGPlainAttrValue();
} else if (reference.equals(GPlainAttrUniqueValue.class)) {
result = (T) new JPAGPlainAttrUniqueValue();
- } else if (reference.equals(GDerAttr.class)) {
- result = (T) new JPAGDerAttr();
} else if (reference.equals(CPlainAttr.class)) {
result = (T) new JPACPlainAttr();
} else if (reference.equals(CPlainAttrValue.class)) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADerAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADerAttr.java
deleted file mode 100644
index 1525de9..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADerAttr.java
+++ /dev/null
@@ -1,59 +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.core.persistence.jpa.entity.anyobject;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import org.apache.syncope.core.persistence.api.entity.anyobject.ADerAttr;
-import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractDerAttr;
-
-@Entity
-@Table(name = JPAADerAttr.TABLE)
-public class JPAADerAttr extends AbstractDerAttr<AnyObject> implements ADerAttr {
-
- private static final long serialVersionUID = 5828533701103533330L;
-
- public static final String TABLE = "ADerAttr";
-
- @Id
- private Long id;
-
- @ManyToOne
- private JPAAnyObject owner;
-
- @Override
- public Long getKey() {
- return id;
- }
-
- @Override
- public AnyObject getOwner() {
- return owner;
- }
-
- @Override
- public void setOwner(final AnyObject owner) {
- checkType(owner, JPAAnyObject.class);
- this.owner = (JPAAnyObject) owner;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
index 9d69735..10ba2fb 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
@@ -33,12 +33,12 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.syncope.core.persistence.api.entity.AnyType;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
import org.apache.syncope.core.persistence.api.entity.RelationshipType;
-import org.apache.syncope.core.persistence.api.entity.anyobject.ADerAttr;
import org.apache.syncope.core.persistence.api.entity.anyobject.AMembership;
import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
import org.apache.syncope.core.persistence.api.entity.anyobject.ARelationship;
@@ -51,7 +51,7 @@ import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResour
@Entity
@Table(name = JPAAnyObject.TABLE)
@Cacheable
-public class JPAAnyObject extends AbstractAny<APlainAttr, ADerAttr> implements AnyObject {
+public class JPAAnyObject extends AbstractAny<APlainAttr> implements AnyObject {
private static final long serialVersionUID = 9063766472970643492L;
@@ -60,6 +60,7 @@ public class JPAAnyObject extends AbstractAny<APlainAttr, ADerAttr> implements A
@Id
private Long id;
+ @NotNull
@ManyToOne(fetch = FetchType.EAGER, optional = false)
private JPAAnyType type;
@@ -67,10 +68,6 @@ public class JPAAnyObject extends AbstractAny<APlainAttr, ADerAttr> implements A
@Valid
private List<JPAAPlainAttr> plainAttrs = new ArrayList<>();
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
- @Valid
- private List<JPAADerAttr> derAttrs = new ArrayList<>();
-
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(joinColumns =
@JoinColumn(name = "anyObject_id"),
@@ -127,23 +124,6 @@ public class JPAAnyObject extends AbstractAny<APlainAttr, ADerAttr> implements A
}
@Override
- public boolean add(final ADerAttr attr) {
- checkType(attr, JPAADerAttr.class);
- return derAttrs.add((JPAADerAttr) attr);
- }
-
- @Override
- public boolean remove(final ADerAttr attr) {
- checkType(attr, JPAADerAttr.class);
- return derAttrs.remove((JPAADerAttr) attr);
- }
-
- @Override
- public List<? extends ADerAttr> getDerAttrs() {
- return derAttrs;
- }
-
- @Override
protected List<JPAExternalResource> internalGetResources() {
return resources;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPAConf.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPAConf.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPAConf.java
index ac5616a..b481fb0 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPAConf.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPAConf.java
@@ -21,7 +21,6 @@ package org.apache.syncope.core.persistence.jpa.entity.conf;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Set;
import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
@@ -33,11 +32,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.syncope.core.persistence.api.entity.AnyType;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
-import org.apache.syncope.core.persistence.api.entity.DerSchema;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.Realm;
-import org.apache.syncope.core.persistence.api.entity.VirSchema;
import org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr;
import org.apache.syncope.core.persistence.api.entity.conf.Conf;
import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
@@ -99,26 +94,6 @@ public class JPAConf extends AbstractAnnotatedEntity<Long> implements Conf {
}
@Override
- public boolean add(final DerAttr<?> attr) {
- return false;
- }
-
- @Override
- public boolean remove(final DerAttr<?> derAttr) {
- return false;
- }
-
- @Override
- public DerAttr<?> getDerAttr(final String derSchemaName) {
- return null;
- }
-
- @Override
- public List<? extends DerAttr<?>> getDerAttrs() {
- return Collections.emptyList();
- }
-
- @Override
public boolean add(final ExternalResource resource) {
return false;
}
@@ -192,19 +167,4 @@ public class JPAConf extends AbstractAnnotatedEntity<Long> implements Conf {
public void setType(final AnyType type) {
// nothing to do
}
-
- @Override
- public Set<PlainSchema> getAllowedPlainSchemas() {
- return Collections.emptySet();
- }
-
- @Override
- public Set<DerSchema> getAllowedDerSchemas() {
- return Collections.emptySet();
- }
-
- @Override
- public Set<VirSchema> getAllowedVirSchemas() {
- return Collections.emptySet();
- }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGDerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGDerAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGDerAttr.java
deleted file mode 100644
index 73911f8..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGDerAttr.java
+++ /dev/null
@@ -1,59 +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.core.persistence.jpa.entity.group;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import org.apache.syncope.core.persistence.api.entity.group.GDerAttr;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractDerAttr;
-
-@Entity
-@Table(name = JPAGDerAttr.TABLE)
-public class JPAGDerAttr extends AbstractDerAttr<Group> implements GDerAttr {
-
- private static final long serialVersionUID = 8007080005675899946L;
-
- public static final String TABLE = "GDerAttr";
-
- @Id
- private Long id;
-
- @ManyToOne
- private JPAGroup owner;
-
- @Override
- public Long getKey() {
- return id;
- }
-
- @Override
- public Group getOwner() {
- return owner;
- }
-
- @Override
- public void setOwner(final Group owner) {
- checkType(owner, JPAGroup.class);
- this.owner = (JPAGroup) owner;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
index 2fb84b5..d41ef3a 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
@@ -42,7 +42,6 @@ import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
import org.apache.syncope.core.persistence.api.entity.AnyType;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
import org.apache.syncope.core.persistence.api.entity.anyobject.ADynGroupMembership;
-import org.apache.syncope.core.persistence.api.entity.group.GDerAttr;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
import org.apache.syncope.core.persistence.api.entity.group.Group;
import org.apache.syncope.core.persistence.api.entity.group.TypeExtension;
@@ -60,7 +59,7 @@ import org.apache.syncope.core.persistence.jpa.entity.user.JPAUser;
@Table(name = JPAGroup.TABLE)
@Cacheable
@GroupCheck
-public class JPAGroup extends AbstractAny<GPlainAttr, GDerAttr> implements Group {
+public class JPAGroup extends AbstractAny<GPlainAttr> implements Group {
private static final long serialVersionUID = -5281258853142421875L;
@@ -83,10 +82,6 @@ public class JPAGroup extends AbstractAny<GPlainAttr, GDerAttr> implements Group
@Valid
private List<JPAGPlainAttr> plainAttrs = new ArrayList<>();
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
- @Valid
- private List<JPAGDerAttr> derAttrs = new ArrayList<>();
-
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(joinColumns =
@JoinColumn(name = "group_id"),
@@ -183,23 +178,6 @@ public class JPAGroup extends AbstractAny<GPlainAttr, GDerAttr> implements Group
}
@Override
- public boolean add(final GDerAttr attr) {
- checkType(attr, JPAGDerAttr.class);
- return derAttrs.add((JPAGDerAttr) attr);
- }
-
- @Override
- public boolean remove(final GDerAttr attr) {
- checkType(attr, JPAGDerAttr.class);
- return derAttrs.remove((JPAGDerAttr) attr);
- }
-
- @Override
- public List<? extends GDerAttr> getDerAttrs() {
- return derAttrs;
- }
-
- @Override
public ADynGroupMembership getADynMembership() {
return aDynMembership;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDerAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDerAttr.java
deleted file mode 100644
index 754fd59..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDerAttr.java
+++ /dev/null
@@ -1,59 +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.core.persistence.jpa.entity.user;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractDerAttr;
-
-@Entity
-@Table(name = JPAUDerAttr.TABLE)
-public class JPAUDerAttr extends AbstractDerAttr<User> implements UDerAttr {
-
- private static final long serialVersionUID = 4723044452807292060L;
-
- public static final String TABLE = "UDerAttr";
-
- @Id
- private Long id;
-
- @ManyToOne
- private JPAUser owner;
-
- @Override
- public Long getKey() {
- return id;
- }
-
- @Override
- public User getOwner() {
- return owner;
- }
-
- @Override
- public void setOwner(final User owner) {
- checkType(owner, JPAUser.class);
- this.owner = (JPAUser) owner;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
index 9ba4fea..26fd229 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
@@ -52,7 +52,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.syncope.common.lib.types.CipherAlgorithm;
import org.apache.syncope.core.persistence.api.entity.user.SecurityQuestion;
-import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResource;
@@ -74,7 +73,7 @@ import org.apache.syncope.core.persistence.jpa.entity.JPARole;
@Entity
@Table(name = JPAUser.TABLE)
@Cacheable
-public class JPAUser extends AbstractAny<UPlainAttr, UDerAttr> implements User {
+public class JPAUser extends AbstractAny<UPlainAttr> implements User {
private static final long serialVersionUID = -3905046855521446823L;
@@ -100,10 +99,6 @@ public class JPAUser extends AbstractAny<UPlainAttr, UDerAttr> implements User {
@Valid
private List<JPAUPlainAttr> plainAttrs = new ArrayList<>();
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
- @Valid
- private List<JPAUDerAttr> derAttrs = new ArrayList<>();
-
private String workflowId;
@Column(nullable = true)
@@ -300,23 +295,6 @@ public class JPAUser extends AbstractAny<UPlainAttr, UDerAttr> implements User {
}
@Override
- public boolean add(final UDerAttr attr) {
- checkType(attr, JPAUDerAttr.class);
- return derAttrs.add((JPAUDerAttr) attr);
- }
-
- @Override
- public boolean remove(final UDerAttr attr) {
- checkType(attr, JPAUDerAttr.class);
- return derAttrs.remove((JPAUDerAttr) attr);
- }
-
- @Override
- public List<? extends UDerAttr> getDerAttrs() {
- return derAttrs;
- }
-
- @Override
public String getWorkflowId() {
return workflowId;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyCheck.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyCheck.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyCheck.java
new file mode 100644
index 0000000..57a84e7
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyCheck.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.core.persistence.jpa.validation.entity;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+@Target({ ElementType.TYPE })
+@Retention(RetentionPolicy.RUNTIME)
+@Constraint(validatedBy = AnyValidator.class)
+@Documented
+public @interface AnyCheck {
+
+ String message() default "{org.apache.syncope.core.persistence.validation.any}";
+
+ Class<?>[] groups() default {};
+
+ Class<? extends Payload>[] payload() default {};
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyValidator.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyValidator.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyValidator.java
new file mode 100644
index 0000000..fb28c4e
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/AnyValidator.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.validation.entity;
+
+import java.util.Collection;
+import javax.validation.ConstraintValidatorContext;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
+import org.apache.syncope.common.lib.types.EntityViolationType;
+import org.apache.syncope.core.persistence.api.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.PlainAttr;
+import org.apache.syncope.core.persistence.api.entity.PlainSchema;
+import org.apache.syncope.core.persistence.api.entity.conf.Conf;
+import org.apache.syncope.core.persistence.jpa.entity.JPAAnyUtilsFactory;
+
+@SuppressWarnings("rawtypes")
+public class AnyValidator extends AbstractValidator<AnyCheck, Any> {
+
+ @Override
+ public boolean isValid(final Any any, final ConstraintValidatorContext context) {
+ context.disableDefaultConstraintViolation();
+
+ if (!(any instanceof Conf)) {
+ Collection<String> allowedPlainSchemas = CollectionUtils.collect(new JPAAnyUtilsFactory().
+ getInstance(any.getType().getKind()).getAllowedSchemas(any, PlainSchema.class),
+ new Transformer<PlainSchema, String>() {
+
+ @Override
+ public String transform(final PlainSchema schema) {
+ return schema.getKey();
+ }
+ });
+
+ for (PlainAttr<?> attr : ((Any<?>) any).getPlainAttrs()) {
+ if (attr != null && !allowedPlainSchemas.contains(attr.getSchema().getKey())) {
+ context.buildConstraintViolationWithTemplate(
+ getTemplate(EntityViolationType.InvalidPlainSchema,
+ attr.getSchema().getKey() + " not allowed for this instance")).
+ addPropertyNode("plainAttrs").addConstraintViolation();
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/EntityValidationListener.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/EntityValidationListener.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/EntityValidationListener.java
index f1df70c..0b60c5e 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/EntityValidationListener.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/EntityValidationListener.java
@@ -28,7 +28,6 @@ import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntit
import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
import org.apache.syncope.core.persistence.api.entity.AnnotatedEntity;
import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.Attr;
import org.apache.syncope.core.persistence.api.entity.Entity;
import org.apache.syncope.core.persistence.api.entity.Policy;
import org.apache.syncope.core.persistence.api.entity.Schema;
@@ -59,7 +58,6 @@ public class EntityValidationListener {
if (!Entity.class.equals(interf)
&& !AnnotatedEntity.class.equals(interf)
&& !Schema.class.equals(interf)
- && !Attr.class.equals(interf)
&& !Task.class.equals(interf)
&& !Policy.class.equals(interf)
&& !Any.class.equals(interf)
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
index e7f3a85..d328eac 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
@@ -66,6 +66,20 @@ public class ExternalResourceValidator extends AbstractValidator<ExternalResourc
return false;
}
+ if (item.getIntMappingType() == IntMappingType.AnyObjectDerivedSchema
+ || item.getIntMappingType() == IntMappingType.GroupDerivedSchema
+ || item.getIntMappingType() == IntMappingType.UserDerivedSchema) {
+
+ if (item.getPurpose() != MappingPurpose.PROPAGATION) {
+ context.buildConstraintViolationWithTemplate(
+ getTemplate(EntityViolationType.InvalidMapping,
+ " - only " + MappingPurpose.PROPAGATION.name() + " allowed for derived")).
+ addPropertyNode("purpose").addConstraintViolation();
+
+ return false;
+ }
+ }
+
if (item.getIntMappingType() == IntMappingType.AnyObjectVirtualSchema
|| item.getIntMappingType() == IntMappingType.GroupVirtualSchema
|| item.getIntMappingType() == IntMappingType.UserVirtualSchema) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
index 5ddee8c..15ff3aa 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
@@ -312,31 +312,6 @@ under the License.
</attributes>
</entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAADerAttr">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_ADerAttr" strategy="TABLE"/>
- <table-generator name="SEQ_ADerAttr" pk-column-value="SEQ_ADerAttr" initial-value="1000"/>
- </id>
- </attributes>
- </entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.user.JPAUDerAttr">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_UDerAttr" strategy="TABLE"/>
- <table-generator name="SEQ_UDerAttr" pk-column-value="SEQ_UDerAttr" initial-value="1000"/>
- </id>
- </attributes>
- </entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.group.JPAGDerAttr">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_GDerAttr" strategy="TABLE"/>
- <table-generator name="SEQ_GDerAttr" pk-column-value="SEQ_GDerAttr" initial-value="1000"/>
- </id>
- </attributes>
- </entity>
-
<entity class="org.apache.syncope.core.persistence.jpa.entity.JPAAnyTemplateRealm">
<attributes>
<id name="id">
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
index 5ddee8c..15ff3aa 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
@@ -312,31 +312,6 @@ under the License.
</attributes>
</entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAADerAttr">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_ADerAttr" strategy="TABLE"/>
- <table-generator name="SEQ_ADerAttr" pk-column-value="SEQ_ADerAttr" initial-value="1000"/>
- </id>
- </attributes>
- </entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.user.JPAUDerAttr">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_UDerAttr" strategy="TABLE"/>
- <table-generator name="SEQ_UDerAttr" pk-column-value="SEQ_UDerAttr" initial-value="1000"/>
- </id>
- </attributes>
- </entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.group.JPAGDerAttr">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_GDerAttr" strategy="TABLE"/>
- <table-generator name="SEQ_GDerAttr" pk-column-value="SEQ_GDerAttr" initial-value="1000"/>
- </id>
- </attributes>
- </entity>
-
<entity class="org.apache.syncope.core.persistence.jpa.entity.JPAAnyTemplateRealm">
<attributes>
<id name="id">
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
index f4f2b07..aeb24ee 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
@@ -359,31 +359,6 @@ under the License.
</id>
</attributes>
</entity>
-
- <entity class="org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAADerAttr">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_ADerAttr" strategy="TABLE"/>
- <table-generator name="SEQ_ADerAttr" pk-column-value="SEQ_ADerAttr" initial-value="1000"/>
- </id>
- </attributes>
- </entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.user.JPAUDerAttr">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_UDerAttr" strategy="TABLE"/>
- <table-generator name="SEQ_UDerAttr" pk-column-value="SEQ_UDerAttr" initial-value="1000"/>
- </id>
- </attributes>
- </entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.group.JPAGDerAttr">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_GDerAttr" strategy="TABLE"/>
- <table-generator name="SEQ_GDerAttr" pk-column-value="SEQ_GDerAttr" initial-value="1000"/>
- </id>
- </attributes>
- </entity>
<entity class="org.apache.syncope.core.persistence.jpa.entity.JPAAnyTemplateRealm">
<attributes>
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/resources/indexes.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/indexes.xml b/core/persistence-jpa/src/main/resources/indexes.xml
index a2d4c62..3807b35 100644
--- a/core/persistence-jpa/src/main/resources/indexes.xml
+++ b/core/persistence-jpa/src/main/resources/indexes.xml
@@ -64,9 +64,5 @@ under the License.
<entry key="GPlainAttr_owner_id_index">CREATE INDEX GPlainAttr_owner_id_index on GPlainAttr(owner_id)</entry>
<entry key="APlainAttr_owner_id_index">CREATE INDEX APlainAttr_owner_id_index on APlainAttr(owner_id)</entry>
- <entry key="UDerAttr_owner_id_index">CREATE INDEX UDerAttr_owner_id_index on UDerAttr(owner_id)</entry>
- <entry key="GDerAttr_owner_id_index">CREATE INDEX GDerAttr_owner_id_index on GDerAttr(owner_id)</entry>
- <entry key="ADerAttr_owner_id_index">CREATE INDEX ADerAttr_owner_id_index on ADerAttr(owner_id)</entry>
-
<entry key="Task_executedIndex">CREATE INDEX Task_executedIndex ON Task(executed)</entry>
</properties>
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java
index 38332b6..c361614 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java
@@ -83,6 +83,7 @@ public class ConfTest extends AbstractTest {
// 2. create conf
CPlainAttr newConf = entityFactory.newEntity(CPlainAttr.class);
+ newConf.setOwner(confDAO.get());
newConf.setSchema(useless);
add(newConf, "2014-06-20");
confDAO.save(newConf);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerAttrTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerAttrTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerAttrTest.java
deleted file mode 100644
index 3fb15b7..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerAttrTest.java
+++ /dev/null
@@ -1,220 +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.core.persistence.jpa.inner;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import org.apache.syncope.core.persistence.api.dao.AnyTypeClassDAO;
-import org.apache.syncope.core.persistence.api.dao.DerAttrDAO;
-import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
-import org.apache.syncope.core.persistence.api.entity.DerSchema;
-import org.apache.syncope.core.persistence.api.entity.group.GDerAttr;
-import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional("Master")
-public class DerAttrTest extends AbstractTest {
-
- @Autowired
- private DerAttrDAO derAttrDAO;
-
- @Autowired
- private UserDAO userDAO;
-
- @Autowired
- private GroupDAO groupDAO;
-
- @Autowired
- private DerSchemaDAO derSchemaDAO;
-
- @Autowired
- private AnyTypeClassDAO anyTypeClassDAO;
-
- @Test
- public void findAll() {
- List<UDerAttr> list = derAttrDAO.findAll(UDerAttr.class);
- assertEquals("did not get expected number of derived attributes ", 2, list.size());
- }
-
- @Test
- public void findById() {
- UDerAttr attribute = derAttrDAO.find(100L, UDerAttr.class);
- assertNotNull("did not find expected attribute schema", attribute);
- }
-
- @Test
- public void saveUDerAttribute() {
- DerSchema cnSchema = derSchemaDAO.find("cn");
- assertNotNull(cnSchema);
-
- User owner = userDAO.find(3L);
- assertNotNull("did not get expected user", owner);
-
- UDerAttr derAttr = entityFactory.newEntity(UDerAttr.class);
- derAttr.setOwner(owner);
- derAttr.setSchema(cnSchema);
-
- derAttr = derAttrDAO.save(derAttr);
-
- UDerAttr actual = derAttrDAO.find(derAttr.getKey(), UDerAttr.class);
- assertNotNull("expected save to work", actual);
- assertEquals(derAttr, actual);
-
- UPlainAttrValue firstname = owner.getPlainAttr("firstname").getValues().iterator().next();
- UPlainAttrValue surname = owner.getPlainAttr("surname").getValues().iterator().next();
-
- assertEquals(surname.getValue() + ", " + firstname.getValue(), derAttr.getValue(owner.getPlainAttrs()));
- }
-
- @Test
- public void saveGDerAttribute() {
- DerSchema schema = derSchemaDAO.find("rderiveddata");
- assertNotNull(schema);
-
- Group owner = groupDAO.find(1L);
- assertNotNull("did not get expected user", owner);
-
- GDerAttr derAttr = entityFactory.newEntity(GDerAttr.class);
- derAttr.setOwner(owner);
- derAttr.setSchema(schema);
-
- derAttr = derAttrDAO.save(derAttr);
-
- GDerAttr actual = derAttrDAO.find(derAttr.getKey(), GDerAttr.class);
- assertNotNull("expected save to work", actual);
- assertEquals(derAttr, actual);
-
- GPlainAttrValue sx = owner.getPlainAttr("rderived_sx").getValues().iterator().next();
- GPlainAttrValue dx = owner.getPlainAttr("rderived_dx").getValues().iterator().next();
-
- assertEquals(sx.getValue() + "-" + dx.getValue(), derAttr.getValue(owner.getPlainAttrs()));
- }
-
- @Test
- public void delete() {
- UDerAttr attribute = derAttrDAO.find(100L, UDerAttr.class);
- String schemaName = attribute.getSchema().getKey();
-
- derAttrDAO.delete(attribute.getKey(), UDerAttr.class);
-
- UDerAttr actual = derAttrDAO.find(100L, UDerAttr.class);
- assertNull("delete did not work", actual);
-
- DerSchema attributeSchema = derSchemaDAO.find(schemaName);
- assertNotNull("user derived attribute schema deleted when deleting values", attributeSchema);
- }
-
- @Test
- public void issueSYNCOPE134User() {
- AnyTypeClass other = anyTypeClassDAO.find("other");
-
- DerSchema sderived = entityFactory.newEntity(DerSchema.class);
- sderived.setKey("sderived");
- sderived.setExpression("status + ' - ' + username + ' - ' + creationDate + '[' + failedLogins + ']'");
-
- sderived = derSchemaDAO.save(sderived);
-
- derSchemaDAO.flush();
-
- other.add(sderived);
- sderived.setAnyTypeClass(other);
-
- derSchemaDAO.flush();
-
- sderived = derSchemaDAO.find("sderived");
- assertNotNull("expected save to work", sderived);
- assertEquals(other, sderived.getAnyTypeClass());
-
- User owner = userDAO.find(3L);
- assertNotNull("did not get expected user", owner);
- owner.add(other);
-
- UDerAttr derAttr = entityFactory.newEntity(UDerAttr.class);
- derAttr.setOwner(owner);
- derAttr.setSchema(sderived);
-
- derAttr = derAttrDAO.save(derAttr);
- derAttrDAO.flush();
-
- derAttr = derAttrDAO.find(derAttr.getKey(), UDerAttr.class);
- assertNotNull("expected save to work", derAttr);
-
- String value = derAttr.getValue(owner.getPlainAttrs());
- assertNotNull(value);
- assertFalse(value.isEmpty());
- assertTrue(value.startsWith("active - vivaldi - 2010-10-20"));
- assertTrue(value.endsWith("[0]"));
- }
-
- @Test
- public void issueSYNCOPE134Group() {
- AnyTypeClass genericMembership = anyTypeClassDAO.find("generic membership");
-
- DerSchema sderived = entityFactory.newEntity(DerSchema.class);
- sderived.setKey("sderived");
- sderived.setExpression("name");
-
- sderived = derSchemaDAO.save(sderived);
-
- derSchemaDAO.flush();
-
- genericMembership.add(sderived);
- sderived.setAnyTypeClass(genericMembership);
-
- derSchemaDAO.flush();
-
- sderived = derSchemaDAO.find("sderived");
- assertNotNull("expected save to work", sderived);
- assertEquals(genericMembership, sderived.getAnyTypeClass());
-
- Group owner = groupDAO.find(7L);
- assertNotNull("did not get expected group", owner);
- owner.add(genericMembership);
-
- GDerAttr derAttr = entityFactory.newEntity(GDerAttr.class);
- derAttr.setOwner(owner);
- derAttr.setSchema(sderived);
-
- derAttr = derAttrDAO.save(derAttr);
- derAttrDAO.flush();
-
- derAttr = derAttrDAO.find(derAttr.getKey(), GDerAttr.class);
- assertNotNull("expected save to work", derAttr);
-
- String value = derAttr.getValue(owner.getPlainAttrs());
- assertNotNull(value);
- assertFalse(value.isEmpty());
- assertTrue(value.startsWith("managingDirector"));
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java
index abe3de3..7907381 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java
@@ -43,7 +43,7 @@ public class DerSchemaTest extends AbstractTest {
@Test
public void findAll() {
List<DerSchema> list = derSchemaDAO.findAll();
- assertEquals(9, list.size());
+ assertEquals(10, list.size());
}
@Test
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ResourceTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ResourceTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ResourceTest.java
index be37d88..3cc3efa 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ResourceTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ResourceTest.java
@@ -338,7 +338,7 @@ public class ResourceTest extends AbstractTest {
item.setIntAttrName("mderiveddata");
item.setExtAttrName("mderiveddata");
item.setIntMappingType(IntMappingType.AnyObjectDerivedSchema);
- item.setPurpose(MappingPurpose.BOTH);
+ item.setPurpose(MappingPurpose.PROPAGATION);
mapping.add(item);
// save the resource
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/DerSchemaTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/DerSchemaTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/DerSchemaTest.java
deleted file mode 100644
index f4529f8..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/DerSchemaTest.java
+++ /dev/null
@@ -1,57 +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.core.persistence.jpa.outer;
-
-import static org.junit.Assert.assertNull;
-
-import org.apache.syncope.core.persistence.api.dao.DerAttrDAO;
-import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.DerSchema;
-import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional("Master")
-public class DerSchemaTest extends AbstractTest {
-
- @Autowired
- private UserDAO userDAO;
-
- @Autowired
- private DerSchemaDAO derSchemaDAO;
-
- @Autowired
- private DerAttrDAO derAttrDAO;
-
- @Test
- public void test() {
- DerSchema schema = derSchemaDAO.find("cn");
-
- derSchemaDAO.delete(schema.getKey());
-
- derSchemaDAO.flush();
-
- assertNull(derSchemaDAO.find(schema.getKey()));
- assertNull(derAttrDAO.find(100L, UDerAttr.class));
- assertNull(userDAO.find(3L).getDerAttr(schema.getKey()));
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/PlainAttrTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/PlainAttrTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/PlainAttrTest.java
index 82147a2..331c4ca 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/PlainAttrTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/PlainAttrTest.java
@@ -19,29 +19,12 @@
package org.apache.syncope.core.persistence.jpa.outer;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.AttrSchemaType;
-import org.apache.syncope.common.lib.types.CipherAlgorithm;
-import org.apache.syncope.core.persistence.api.dao.AnyTypeClassDAO;
-import org.apache.syncope.core.persistence.api.dao.DerAttrDAO;
-import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
import org.apache.syncope.core.persistence.api.dao.PlainAttrValueDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
-import org.apache.syncope.core.persistence.api.entity.DerSchema;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.persistence.jpa.AbstractTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -54,23 +37,8 @@ public class PlainAttrTest extends AbstractTest {
private PlainAttrDAO plainAttrDAO;
@Autowired
- private DerAttrDAO derAttrDAO;
-
- @Autowired
private PlainAttrValueDAO plainAttrValueDAO;
- @Autowired
- private PlainSchemaDAO plainSchemaDAO;
-
- @Autowired
- private DerSchemaDAO derSchemaDAO;
-
- @Autowired
- private UserDAO userDAO;
-
- @Autowired
- private AnyTypeClassDAO anyTypeClassDAO;
-
@Test
public void deleteAttribute() {
plainAttrDAO.delete(117L, UPlainAttr.class);
@@ -95,85 +63,4 @@ public class PlainAttrTest extends AbstractTest {
UPlainAttr attribute = plainAttrDAO.find(104L, UPlainAttr.class);
assertEquals(attribute.getValues().size(), attributeValueNumber - 1);
}
-
- @Test
- public void checkForEnumType() {
- User user = userDAO.find(1L);
- user.setPassword("password123", CipherAlgorithm.SHA);
- assertNotNull(user);
-
- AnyTypeClass other = anyTypeClassDAO.find("other");
-
- PlainSchema color = entityFactory.newEntity(PlainSchema.class);
- color.setType(AttrSchemaType.Enum);
- color.setKey("color");
- color.setEnumerationValues("red" + SyncopeConstants.ENUM_VALUES_SEPARATOR + "yellow");
-
- color = plainSchemaDAO.save(color);
-
- other.add(color);
- color.setAnyTypeClass(other);
-
- plainSchemaDAO.flush();
-
- color = plainSchemaDAO.find("color");
- assertNotNull("expected save to work", color);
- assertEquals(other, color.getAnyTypeClass());
-
- UPlainAttr attr = entityFactory.newEntity(UPlainAttr.class);
- attr.setOwner(user);
- attr.setSchema(color);
- attr.add("yellow", anyUtilsFactory.getInstance(AnyTypeKind.USER));
- user.add(attr);
-
- userDAO.save(user);
- userDAO.flush();
-
- user = userDAO.find(1L);
- assertNotNull(user);
- assertNotNull(user.getPlainAttr(color.getKey()));
- assertNotNull(user.getPlainAttr(color.getKey()).getValues());
- assertEquals(user.getPlainAttr(color.getKey()).getValues().size(), 1);
- }
-
- @Test
- public void derAttrFromSpecialAttrs() {
- AnyTypeClass other = anyTypeClassDAO.find("other");
-
- DerSchema sderived = entityFactory.newEntity(DerSchema.class);
- sderived.setKey("sderived");
- sderived.setExpression("username + ' - ' + creationDate + '[' + failedLogins + ']'");
-
- sderived = derSchemaDAO.save(sderived);
-
- derSchemaDAO.flush();
-
- other.add(sderived);
- sderived.setAnyTypeClass(other);
-
- derSchemaDAO.flush();
-
- sderived = derSchemaDAO.find("sderived");
- assertNotNull("expected save to work", sderived);
- assertEquals(other, sderived.getAnyTypeClass());
-
- User owner = userDAO.find(3L);
- assertNotNull("did not get expected user", owner);
-
- UDerAttr derAttr = entityFactory.newEntity(UDerAttr.class);
- derAttr.setOwner(owner);
- derAttr.setSchema(sderived);
-
- derAttr = derAttrDAO.save(derAttr);
- derAttrDAO.flush();
-
- derAttr = derAttrDAO.find(derAttr.getKey(), UDerAttr.class);
- assertNotNull("expected save to work", derAttr);
-
- String value = derAttr.getValue(owner.getPlainAttrs());
- assertNotNull(value);
- assertFalse(value.isEmpty());
- assertTrue(value.startsWith("vivaldi - 2010-10-20"));
- assertTrue(value.endsWith("[0]"));
- }
}
[5/5] syncope git commit: [SYNCOPE-725] Refactoring completed
Posted by il...@apache.org.
[SYNCOPE-725] Refactoring completed
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/eec66245
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/eec66245
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/eec66245
Branch: refs/heads/master
Commit: eec662457fa05cb9a7bf3980fe18b059434bd69d
Parents: b845cf5
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Nov 6 11:00:19 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Nov 6 11:00:19 2015 +0100
----------------------------------------------------------------------
.../syncope/common/lib/AnyOperations.java | 34 +--
.../syncope/common/lib/patch/AnyPatch.java | 15 +-
.../common/lib/types/ClientExceptionType.java | 1 -
.../org/apache/syncope/common/lib/JSONTest.java | 6 -
.../syncope/core/logic/ResourceLogic.java | 2 +-
.../syncope/core/misc/jexl/JexlUtils.java | 58 ++---
.../syncope/core/misc/utils/MappingUtils.java | 98 +++++----
.../core/persistence/api/dao/AnyDAO.java | 6 +-
.../core/persistence/api/dao/AnySearchDAO.java | 10 +-
.../core/persistence/api/dao/DerAttrDAO.java | 35 ---
.../core/persistence/api/dao/DerSchemaDAO.java | 3 +-
.../persistence/api/dao/PlainSchemaDAO.java | 5 +-
.../core/persistence/api/dao/SchemaDAO.java | 5 +-
.../api/dao/UnallowedSchemaException.java | 29 ---
.../core/persistence/api/dao/VirSchemaDAO.java | 3 +-
.../core/persistence/api/entity/Any.java | 17 +-
.../core/persistence/api/entity/AnyUtils.java | 12 +-
.../persistence/api/entity/AnyUtilsFactory.java | 4 +-
.../core/persistence/api/entity/Attr.java | 30 ---
.../core/persistence/api/entity/DerAttr.java | 26 ---
.../api/entity/DynGroupMembership.java | 2 +-
.../persistence/api/entity/DynMembership.java | 2 +-
.../core/persistence/api/entity/Membership.java | 2 +-
.../core/persistence/api/entity/PlainAttr.java | 10 +-
.../persistence/api/entity/Relationship.java | 2 +-
.../api/entity/anyobject/ADerAttr.java | 24 --
.../api/entity/anyobject/AnyObject.java | 2 +-
.../core/persistence/api/entity/conf/Conf.java | 3 +-
.../persistence/api/entity/group/GDerAttr.java | 25 ---
.../persistence/api/entity/group/Group.java | 14 +-
.../persistence/api/entity/user/UDerAttr.java | 25 ---
.../core/persistence/api/entity/user/User.java | 14 +-
.../jpa/content/XMLContentExporter.java | 4 -
.../persistence/jpa/dao/AbstractAnyDAO.java | 47 +++-
.../persistence/jpa/dao/JPAAnySearchDAO.java | 12 +-
.../core/persistence/jpa/dao/JPADerAttrDAO.java | 86 --------
.../persistence/jpa/dao/JPADerSchemaDAO.java | 26 +--
.../core/persistence/jpa/dao/JPAGroupDAO.java | 2 +-
.../persistence/jpa/dao/JPAPlainAttrDAO.java | 2 +-
.../persistence/jpa/dao/JPAVirSchemaDAO.java | 7 -
.../persistence/jpa/entity/AbstractAny.java | 87 +-------
.../persistence/jpa/entity/AbstractAttr.java | 60 -----
.../persistence/jpa/entity/AbstractDerAttr.java | 62 ------
.../jpa/entity/AbstractDynMembership.java | 2 +-
.../jpa/entity/AbstractPlainAttr.java | 16 +-
.../persistence/jpa/entity/JPAAnyUtils.java | 105 ++++-----
.../jpa/entity/JPAAnyUtilsFactory.java | 24 +-
.../jpa/entity/JPAEntityFactory.java | 8 -
.../jpa/entity/anyobject/JPAADerAttr.java | 59 -----
.../jpa/entity/anyobject/JPAAnyObject.java | 26 +--
.../persistence/jpa/entity/conf/JPAConf.java | 40 ----
.../jpa/entity/group/JPAGDerAttr.java | 59 -----
.../persistence/jpa/entity/group/JPAGroup.java | 24 +-
.../jpa/entity/user/JPAUDerAttr.java | 59 -----
.../persistence/jpa/entity/user/JPAUser.java | 24 +-
.../jpa/validation/entity/AnyCheck.java | 41 ++++
.../jpa/validation/entity/AnyValidator.java | 63 ++++++
.../entity/EntityValidationListener.java | 2 -
.../entity/ExternalResourceValidator.java | 14 ++
.../resources/META-INF/spring-orm-oracle.xml | 25 ---
.../resources/META-INF/spring-orm-sqlserver.xml | 25 ---
.../src/main/resources/META-INF/spring-orm.xml | 25 ---
.../src/main/resources/indexes.xml | 4 -
.../core/persistence/jpa/inner/ConfTest.java | 1 +
.../core/persistence/jpa/inner/DerAttrTest.java | 220 -------------------
.../persistence/jpa/inner/DerSchemaTest.java | 2 +-
.../persistence/jpa/inner/ResourceTest.java | 2 +-
.../persistence/jpa/outer/DerSchemaTest.java | 57 -----
.../persistence/jpa/outer/PlainAttrTest.java | 113 ----------
.../test/resources/domains/MasterContent.xml | 18 +-
.../core/provisioning/api/DerAttrHandler.java | 43 ++++
.../core/provisioning/api/VirAttrHandler.java | 4 +-
.../core/provisioning/api/sync/PushActions.java | 20 +-
.../provisioning/java/DerAttrHandlerImpl.java | 77 +++++++
.../provisioning/java/VirAttrHandlerImpl.java | 39 +---
.../java/data/AbstractAnyDataBinder.java | 150 +++----------
.../java/data/AnyObjectDataBinderImpl.java | 6 +-
.../java/data/GroupDataBinderImpl.java | 5 +-
.../java/data/UserDataBinderImpl.java | 5 +-
.../notification/NotificationManagerImpl.java | 28 ++-
.../AbstractPropagationTaskExecutor.java | 6 +-
.../LDAPMembershipPropagationActions.java | 2 +-
.../propagation/PropagationManagerImpl.java | 54 ++---
.../java/sync/AbstractPushResultHandler.java | 18 +-
.../java/sync/AbstractSyncopeResultHandler.java | 2 +-
.../sync/AnyObjectPushResultHandlerImpl.java | 4 +-
.../sync/AnyObjectSyncResultHandlerImpl.java | 2 +-
.../java/sync/DefaultPushActions.java | 16 +-
.../java/sync/GroupPushResultHandlerImpl.java | 4 +-
.../java/sync/GroupSyncResultHandlerImpl.java | 2 +-
.../provisioning/java/sync/PushJobDelegate.java | 4 +-
.../core/provisioning/java/sync/SyncUtils.java | 10 +-
.../java/sync/UserPushResultHandlerImpl.java | 6 +-
.../java/sync/UserSyncResultHandlerImpl.java | 2 +-
.../core/provisioning/java/DerAttrTest.java | 61 +++++
.../rest/cxf/RestServiceExceptionMapper.java | 7 +-
.../rest/cxf/service/AbstractAnyService.java | 9 +-
.../core/workflow/activiti/task/Create.java | 3 +-
.../syncope/fit/core/reference/GroupITCase.java | 34 +--
.../syncope/fit/core/reference/UserITCase.java | 52 ++---
100 files changed, 769 insertions(+), 1883 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
index d2d6891..f7cd2e8 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
@@ -136,33 +136,11 @@ public final class AnyOperations {
}
}
- // 4. derived attributes
- updatedAttrs = updated.getDerAttrMap();
- originalAttrs = original.getDerAttrMap();
-
- result.getDerAttrs().clear();
-
- if (!incremental) {
- for (String schema : CollectionUtils.subtract(originalAttrs.keySet(), updatedAttrs.keySet())) {
- result.getDerAttrs().add(new AttrPatch.Builder().
- operation(PatchOperation.DELETE).
- attrTO(new AttrTO.Builder().schema(schema).build()).
- build());
- }
- }
-
- for (String schema : CollectionUtils.subtract(updatedAttrs.keySet(), originalAttrs.keySet())) {
- result.getDerAttrs().add(new AttrPatch.Builder().
- operation(PatchOperation.ADD_REPLACE).
- attrTO(new AttrTO.Builder().schema(schema).build()).
- build());
- }
-
- // 5. virtual attributes
+ // 4. virtual attributes
result.getVirAttrs().clear();
result.getVirAttrs().addAll(updated.getVirAttrs());
- // 6. resources
+ // 5. resources
result.getResources().clear();
if (!incremental) {
@@ -431,15 +409,11 @@ public final class AnyOperations {
result.getPlainAttrs().clear();
result.getPlainAttrs().addAll(AnyOperations.patch(to.getPlainAttrMap(), patch.getPlainAttrs()));
- // 3. derived attributes
- result.getDerAttrs().clear();
- result.getDerAttrs().addAll(AnyOperations.patch(to.getDerAttrMap(), patch.getDerAttrs()));
-
- // 4. virtual attributes
+ // 3. virtual attributes
result.getVirAttrs().clear();
result.getVirAttrs().addAll(patch.getVirAttrs());
- // 5. resources
+ // 4. resources
for (StringPatchItem resourcePatch : patch.getResources()) {
switch (resourcePatch.getOperation()) {
case ADD_REPLACE:
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AnyPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AnyPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AnyPatch.java
index a6c4323..48d7778 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AnyPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/AnyPatch.java
@@ -42,8 +42,6 @@ public abstract class AnyPatch extends AbstractBaseBean {
private final Set<AttrPatch> plainAttrs = new HashSet<>();
- private final Set<AttrPatch> derAttrs = new HashSet<>();
-
private final Set<AttrTO> virAttrs = new HashSet<>();
private final Set<StringPatchItem> resources = new HashSet<>();
@@ -79,13 +77,6 @@ public abstract class AnyPatch extends AbstractBaseBean {
return plainAttrs;
}
- @XmlElementWrapper(name = "derAttrs")
- @XmlElement(name = "attribute")
- @JsonProperty("derAttrs")
- public Set<AttrPatch> getDerAttrs() {
- return derAttrs;
- }
-
@XmlElementWrapper(name = "virAttrs")
@XmlElement(name = "attribute")
@JsonProperty("virAttrs")
@@ -105,7 +96,9 @@ public abstract class AnyPatch extends AbstractBaseBean {
*/
@JsonIgnore
public boolean isEmpty() {
- return realm == null && auxClasses.isEmpty() && plainAttrs.isEmpty() && derAttrs.isEmpty()
- && virAttrs.isEmpty() && resources.isEmpty();
+ return realm == null
+ && auxClasses.isEmpty()
+ && plainAttrs.isEmpty() && virAttrs.isEmpty()
+ && resources.isEmpty();
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java b/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
index e4a0f10..9d6770f 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
@@ -67,7 +67,6 @@ public enum ClientExceptionType {
GroupOwnership(Response.Status.BAD_REQUEST),
Scheduling(Response.Status.BAD_REQUEST),
DelegatedAdministration(Response.Status.FORBIDDEN),
- UnallowedSchemas(Response.Status.BAD_REQUEST),
Unknown(Response.Status.BAD_REQUEST),
Workflow(Response.Status.BAD_REQUEST);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java
----------------------------------------------------------------------
diff --git a/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java b/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java
index 711ce74..e0f8093 100644
--- a/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java
+++ b/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java
@@ -24,13 +24,11 @@ import static org.junit.Assert.assertNotNull;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.StringWriter;
-import org.apache.syncope.common.lib.patch.AttrPatch;
import org.apache.syncope.common.lib.patch.PasswordPatch;
import org.apache.syncope.common.lib.patch.LongPatchItem;
import org.apache.syncope.common.lib.patch.StringReplacePatchItem;
import org.apache.syncope.common.lib.patch.UserPatch;
import org.apache.syncope.common.lib.report.UserReportletConf;
-import org.apache.syncope.common.lib.to.AttrTO;
import org.apache.syncope.common.lib.to.ReportTO;
import org.apache.syncope.common.lib.to.WorkflowFormPropertyTO;
import org.apache.syncope.common.lib.types.PatchOperation;
@@ -82,10 +80,6 @@ public class JSONTest {
build());
assertNotNull(patch.getPassword().getValue());
patch.getRoles().add(new LongPatchItem.Builder().operation(PatchOperation.DELETE).value(7L).build());
- patch.getDerAttrs().add(new AttrPatch.Builder().
- operation(PatchOperation.ADD_REPLACE).
- attrTO(new AttrTO.Builder().schema("derived").build()).
- build());
ObjectMapper mapper = new ObjectMapper();
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
index c392058..b4795f6 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
@@ -218,7 +218,7 @@ public class ResourceLogic extends AbstractTransactionalLogic<ResourceTO> {
Triple<ExternalResource, AnyType, Provision> init = connObjectInit(key, anyTypeKey);
// 1. find any
- Any<?, ?> any = init.getMiddle().getKind() == AnyTypeKind.USER
+ Any<?> any = init.getMiddle().getKind() == AnyTypeKind.USER
? userDAO.find(anyKey)
: init.getMiddle().getKind() == AnyTypeKind.ANY_OBJECT
? anyObjectDAO.find(anyKey)
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java b/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java
index 2870eae..986adf4 100644
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java
@@ -25,6 +25,7 @@ import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import org.apache.commons.jexl2.Expression;
import org.apache.commons.jexl2.JexlContext;
import org.apache.commons.jexl2.JexlEngine;
@@ -34,10 +35,12 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.to.AnyTO;
import org.apache.syncope.common.lib.to.AttrTO;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
import org.apache.syncope.core.misc.utils.FormatUtils;
import org.apache.syncope.core.persistence.api.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
+import org.apache.syncope.core.provisioning.api.DerAttrHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -139,7 +142,7 @@ public final class JexlUtils {
}
if (object instanceof Any) {
- Any<?, ?> any = (Any<?, ?>) object;
+ Any<?> any = (Any<?>) object;
if (any.getRealm() != null) {
context.set("realm", any.getRealm().getName());
}
@@ -148,12 +151,8 @@ public final class JexlUtils {
return context;
}
- public static JexlContext addPlainAttrsToContext(final Collection<? extends PlainAttr<?>> attrs,
- final JexlContext jexlContext) {
-
- JexlContext context = jexlContext == null
- ? new MapContext()
- : jexlContext;
+ public static void addPlainAttrsToContext(
+ final Collection<? extends PlainAttr<?>> attrs, final JexlContext jexlContext) {
for (PlainAttr<?> attr : attrs) {
if (attr.getSchema() != null) {
@@ -164,55 +163,28 @@ public final class JexlUtils {
LOG.debug("Add attribute {} with value {}", attr.getSchema().getKey(), expressionValue);
- context.set(attr.getSchema().getKey(), expressionValue);
+ jexlContext.set(attr.getSchema().getKey(), expressionValue);
}
}
-
- return context;
}
- public static JexlContext addDerAttrsToContext(final Collection<? extends DerAttr> derAttrs,
- final Collection<? extends PlainAttr<?>> attrs, final JexlContext jexlContext) {
-
- JexlContext context = jexlContext == null
- ? new MapContext()
- : jexlContext;
-
- for (DerAttr<?> derAttr : derAttrs) {
- if (derAttr.getSchema() != null) {
- String expressionValue = derAttr.getValue(attrs);
- if (expressionValue == null) {
- expressionValue = StringUtils.EMPTY;
- }
-
- LOG.debug("Add derived attribute {} with value {}", derAttr.getSchema().getKey(), expressionValue);
+ public static void addDerAttrsToContext(final Any<?> any, final JexlContext jexlContext) {
+ Map<DerSchema, String> derAttrs =
+ ApplicationContextProvider.getBeanFactory().getBean(DerAttrHandler.class).getValues(any);
- context.set(derAttr.getSchema().getKey(), expressionValue);
- }
+ for (Map.Entry<DerSchema, String> entry : derAttrs.entrySet()) {
+ jexlContext.set(entry.getKey().getKey(), entry.getValue());
}
-
- return context;
}
- public static boolean evaluateMandatoryCondition(final String mandatoryCondition, final Any<?, ?> any) {
+ public static boolean evaluateMandatoryCondition(final String mandatoryCondition, final Any<?> any) {
JexlContext jexlContext = new MapContext();
addPlainAttrsToContext(any.getPlainAttrs(), jexlContext);
- addDerAttrsToContext(any.getDerAttrs(), any.getPlainAttrs(), jexlContext);
+ addDerAttrsToContext(any, jexlContext);
return Boolean.parseBoolean(evaluate(mandatoryCondition, jexlContext));
}
- public static String evaluate(final String expression,
- final Any<?, ?> any, final Collection<? extends PlainAttr<?>> attributes) {
-
- JexlContext jexlContext = new MapContext();
- JexlUtils.addPlainAttrsToContext(attributes, jexlContext);
- JexlUtils.addFieldsToContext(any, jexlContext);
-
- // Evaluate expression using the context prepared before
- return evaluate(expression, jexlContext);
- }
-
public static String evaluate(final String expression, final AnyTO anyTO) {
final JexlContext context = new MapContext();
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java b/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java
index bc7c6b8..2886231 100644
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java
@@ -44,7 +44,6 @@ import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
import org.apache.syncope.core.persistence.api.entity.AnyUtils;
import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
import org.apache.syncope.core.persistence.api.entity.EntityFactory;
import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
@@ -60,8 +59,10 @@ import org.apache.syncope.core.misc.security.PasswordGenerator;
import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
import org.apache.syncope.core.persistence.api.attrvalue.validation.ParsingValidationException;
import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
+import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
import org.apache.syncope.core.persistence.api.dao.UserDAO;
import org.apache.syncope.core.persistence.api.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.Schema;
@@ -69,6 +70,7 @@ import org.apache.syncope.core.persistence.api.entity.VirSchema;
import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
import org.apache.syncope.core.persistence.api.entity.resource.Mapping;
import org.apache.syncope.core.persistence.api.entity.resource.Provision;
+import org.apache.syncope.core.provisioning.api.DerAttrHandler;
import org.apache.syncope.core.provisioning.api.VirAttrHandler;
import org.apache.syncope.core.provisioning.api.data.MappingItemTransformer;
import org.identityconnectors.framework.common.FrameworkUtil;
@@ -95,18 +97,24 @@ public class MappingUtils {
private static final Encryptor ENCRYPTOR = Encryptor.getInstance();
@Autowired
- private UserDAO userDAO;
-
- @Autowired
private AnyTypeDAO anyTypeDAO;
@Autowired
private PlainSchemaDAO plainSchemaDAO;
@Autowired
+ private DerSchemaDAO derSchemaDAO;
+
+ @Autowired
private VirSchemaDAO virSchemaDAO;
@Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private DerAttrHandler derAttrHandler;
+
+ @Autowired
private VirAttrHandler virAttrHandler;
@Autowired
@@ -204,7 +212,7 @@ public class MappingUtils {
* @param connObjectKey connector object key
* @return the value to be propagated as __NAME__
*/
- public static Name evaluateNAME(final Any<?, ?> any, final Provision provision, final String connObjectKey) {
+ public static Name evaluateNAME(final Any<?> any, final Provision provision, final String connObjectKey) {
if (StringUtils.isBlank(connObjectKey)) {
// LOG error but avoid to throw exception: leave it to the external resource
LOG.error("Missing ConnObjectKey for '{}': ", provision.getResource());
@@ -219,7 +227,7 @@ public class MappingUtils {
JexlContext jexlContext = new MapContext();
JexlUtils.addFieldsToContext(any, jexlContext);
JexlUtils.addPlainAttrsToContext(any.getPlainAttrs(), jexlContext);
- JexlUtils.addDerAttrsToContext(any.getDerAttrs(), any.getPlainAttrs(), jexlContext);
+ JexlUtils.addDerAttrsToContext(any, jexlContext);
evalConnObjectLink = JexlUtils.evaluate(connObjectLink, jexlContext);
}
@@ -299,7 +307,7 @@ public class MappingUtils {
*/
@Transactional(readOnly = true)
public Pair<String, Set<Attribute>> prepareAttrs(
- final Any<?, ?> any,
+ final Any<?> any,
final String password,
final boolean changePwd,
final Boolean enable,
@@ -371,9 +379,9 @@ public class MappingUtils {
* @return connObjectLink + prepared attribute
*/
private Pair<String, Attribute> prepareAttr(
- final Provision provision, final MappingItem mapItem, final Any<?, ?> any, final String password) {
+ final Provision provision, final MappingItem mapItem, final Any<?> any, final String password) {
- List<Any<?, ?>> anys = new ArrayList<>();
+ List<Any<?>> anys = new ArrayList<>();
switch (mapItem.getIntMappingType().getAnyTypeKind()) {
case USER:
@@ -480,26 +488,24 @@ public class MappingUtils {
result = new ImmutablePair<>(
null, AttributeBuilder.buildPassword(passwordAttrValue.toCharArray()));
}
- } else {
- if ((schema != null && schema.isMultivalue())
- || anyUtilsFactory.getInstance(any).getAnyTypeKind()
- != mapItem.getIntMappingType().getAnyTypeKind()) {
+ } else if ((schema != null && schema.isMultivalue())
+ || anyUtilsFactory.getInstance(any).getAnyTypeKind()
+ != mapItem.getIntMappingType().getAnyTypeKind()) {
- result = new ImmutablePair<>(
- null, AttributeBuilder.build(extAttrName, objValues));
- } else {
- result = new ImmutablePair<>(
- null, objValues.isEmpty()
- ? AttributeBuilder.build(extAttrName)
- : AttributeBuilder.build(extAttrName, objValues.iterator().next()));
- }
+ result = new ImmutablePair<>(
+ null, AttributeBuilder.build(extAttrName, objValues));
+ } else {
+ result = new ImmutablePair<>(
+ null, objValues.isEmpty()
+ ? AttributeBuilder.build(extAttrName)
+ : AttributeBuilder.build(extAttrName, objValues.iterator().next()));
}
}
return result;
}
- private String getGroupOwnerValue(final Provision provision, final Any<?, ?> any) {
+ private String getGroupOwnerValue(final Provision provision, final Any<?> any) {
Pair<String, Attribute> preparedAttr = prepareAttr(provision, getConnObjectKeyItem(provision), any, null);
String connObjectKey = preparedAttr.getKey();
@@ -516,7 +522,7 @@ public class MappingUtils {
*/
@Transactional(readOnly = true)
public List<PlainAttrValue> getIntValues(final Provision provision,
- final MappingItem mappingItem, final List<Any<?, ?>> anys) {
+ final MappingItem mappingItem, final List<Any<?>> anys) {
LOG.debug("Get attributes for '{}' and mapping type '{}'", anys, mappingItem.getIntMappingType());
@@ -527,7 +533,7 @@ public class MappingUtils {
case UserPlainSchema:
case GroupPlainSchema:
case AnyObjectPlainSchema:
- for (Any<?, ?> any : anys) {
+ for (Any<?> any : anys) {
PlainAttr<?> attr = any.getPlainAttr(mappingItem.getIntAttrName());
if (attr != null) {
if (attr.getUniqueValue() != null) {
@@ -555,20 +561,24 @@ public class MappingUtils {
case UserDerivedSchema:
case GroupDerivedSchema:
case AnyObjectDerivedSchema:
- for (Any<?, ?> any : anys) {
- AnyUtils anyUtils = anyUtilsFactory.getInstance(any);
- DerAttr<?> attr = any.getDerAttr(mappingItem.getIntAttrName());
- if (attr != null) {
- PlainAttrValue attrValue = anyUtils.newPlainAttrValue();
- attrValue.setStringValue(attr.getValue(any.getPlainAttrs()));
- values.add(attrValue);
- }
+ DerSchema derSchema = derSchemaDAO.find(mappingItem.getIntAttrName());
+ if (derSchema != null) {
+ for (Any<?> any : anys) {
+ String value = derAttrHandler.getValue(any, derSchema);
+ if (value != null) {
+ AnyUtils anyUtils = anyUtilsFactory.getInstance(any);
+ PlainAttrValue attrValue = anyUtils.newPlainAttrValue();
+ attrValue.setStringValue(value);
+ values.add(attrValue);
- LOG.debug("Retrieved attribute {}"
- + "\n* IntAttrName {}"
- + "\n* IntMappingType {}"
- + "\n* Attribute values {}",
- attr, mappingItem.getIntAttrName(), mappingItem.getIntMappingType(), values);
+ LOG.debug("Retrieved values for {}"
+ + "\n* IntAttrName {}"
+ + "\n* IntMappingType {}"
+ + "\n* Attribute values {}",
+ derSchema.getKey(), mappingItem.getIntAttrName(), mappingItem.getIntMappingType(),
+ values);
+ }
+ }
}
break;
@@ -580,7 +590,7 @@ public class MappingUtils {
VirSchema virSchema = virSchemaDAO.find(mappingItem.getIntAttrName());
if (virSchema != null) {
- for (Any<?, ?> any : anys) {
+ for (Any<?> any : anys) {
LOG.debug("Expire entry cache {}-{}", any.getKey(), mappingItem.getIntAttrName());
virAttrCache.expire(any.getType().getKey(), any.getKey(), mappingItem.getIntAttrName());
@@ -604,7 +614,7 @@ public class MappingUtils {
case UserKey:
case GroupKey:
case AnyObjectKey:
- for (Any<?, ?> any : anys) {
+ for (Any<?> any : anys) {
AnyUtils anyUtils = anyUtilsFactory.getInstance(any);
PlainAttrValue attrValue = anyUtils.newPlainAttrValue();
attrValue.setStringValue(any.getKey().toString());
@@ -613,7 +623,7 @@ public class MappingUtils {
break;
case Username:
- for (Any<?, ?> any : anys) {
+ for (Any<?> any : anys) {
if (any instanceof User) {
UPlainAttrValue attrValue = entityFactory.newEntity(UPlainAttrValue.class);
attrValue.setStringValue(((User) any).getUsername());
@@ -623,7 +633,7 @@ public class MappingUtils {
break;
case GroupName:
- for (Any<?, ?> any : anys) {
+ for (Any<?> any : anys) {
if (any instanceof Group) {
GPlainAttrValue attrValue = entityFactory.newEntity(GPlainAttrValue.class);
attrValue.setStringValue(((Group) any).getName());
@@ -640,7 +650,7 @@ public class MappingUtils {
? null
: provision.getMapping();
- for (Any<?, ?> any : anys) {
+ for (Any<?> any : anys) {
if (any instanceof Group) {
Group group = (Group) any;
String groupOwnerValue = null;
@@ -686,9 +696,9 @@ public class MappingUtils {
* @return connObjectKey internal value
*/
@Transactional(readOnly = true)
- public String getConnObjectKeyValue(final Any<?, ?> any, final Provision provision) {
+ public String getConnObjectKeyValue(final Any<?> any, final Provision provision) {
List<PlainAttrValue> values = getIntValues(provision, provision.getMapping().getConnObjectKeyItem(),
- Collections.<Any<?, ?>>singletonList(any));
+ Collections.<Any<?>>singletonList(any));
return values == null || values.isEmpty()
? null
: values.get(0).getValueAsString();
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
index bfda35f..3d8162b 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
@@ -18,14 +18,16 @@
*/
package org.apache.syncope.core.persistence.api.dao;
+import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
+import org.apache.syncope.core.persistence.api.entity.Schema;
-public interface AnyDAO<A extends Any<?, ?>> extends DAO<A, Long> {
+public interface AnyDAO<A extends Any<?>> extends DAO<A, Long> {
A authFind(Long key);
@@ -55,6 +57,8 @@ public interface AnyDAO<A extends Any<?, ?>> extends DAO<A, Long> {
List<A> findAll(Set<String> adminRealms, int page, int itemsPerPage, List<OrderByClause> orderBy);
+ <S extends Schema> Collection<S> findAllowedSchemas(A any, Class<S> reference);
+
int count(Set<String> adminRealms);
A save(A any);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java
index 00471e0..a442890 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java
@@ -25,7 +25,7 @@ import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
import org.apache.syncope.core.persistence.api.entity.Any;
-public interface AnySearchDAO extends DAO<Any<?, ?>, Long> {
+public interface AnySearchDAO extends DAO<Any<?>, Long> {
/**
* @param adminRealms realms for which the caller owns the proper entitlement(s)
@@ -42,7 +42,7 @@ public interface AnySearchDAO extends DAO<Any<?, ?>, Long> {
* @param <T> any
* @return the list of any objects matching the given search condition
*/
- <T extends Any<?, ?>> List<T> search(
+ <T extends Any<?>> List<T> search(
Set<String> adminRealms, SearchCond searchCondition, AnyTypeKind kind);
/**
@@ -53,7 +53,7 @@ public interface AnySearchDAO extends DAO<Any<?, ?>, Long> {
* @param <T> any
* @return the list of any objects matching the given search condition
*/
- <T extends Any<?, ?>> List<T> search(
+ <T extends Any<?>> List<T> search(
Set<String> adminRealms, SearchCond searchCondition, List<OrderByClause> orderBy, AnyTypeKind kind);
/**
@@ -66,7 +66,7 @@ public interface AnySearchDAO extends DAO<Any<?, ?>, Long> {
* @param <T> any
* @return the list of any objects matching the given search condition (in the given page)
*/
- <T extends Any<?, ?>> List<T> search(
+ <T extends Any<?>> List<T> search(
Set<String> adminRealms, SearchCond searchCondition, int page, int itemsPerPage,
List<OrderByClause> orderBy, AnyTypeKind kind);
@@ -79,5 +79,5 @@ public interface AnySearchDAO extends DAO<Any<?, ?>, Long> {
* @param <T> any
* @return true if any matches searchCondition
*/
- <T extends Any<?, ?>> boolean matches(T any, SearchCond searchCondition, AnyTypeKind kind);
+ <T extends Any<?>> boolean matches(T any, SearchCond searchCondition, AnyTypeKind kind);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DerAttrDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DerAttrDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DerAttrDAO.java
deleted file mode 100644
index d087f20..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DerAttrDAO.java
+++ /dev/null
@@ -1,35 +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.core.persistence.api.dao;
-
-import java.util.List;
-import org.apache.syncope.core.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);
-
- <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/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DerSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DerSchemaDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DerSchemaDAO.java
index 70161f9..ddf0fb5 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DerSchemaDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/DerSchemaDAO.java
@@ -18,9 +18,8 @@
*/
package org.apache.syncope.core.persistence.api.dao;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
import org.apache.syncope.core.persistence.api.entity.DerSchema;
-public interface DerSchemaDAO extends SchemaDAO<DerSchema, DerAttr<?>> {
+public interface DerSchemaDAO extends SchemaDAO<DerSchema> {
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java
index df51db4..c832cdc 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java
@@ -18,9 +18,12 @@
*/
package org.apache.syncope.core.persistence.api.dao;
+import java.util.List;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-public interface PlainSchemaDAO extends SchemaDAO<PlainSchema, PlainAttr<?>> {
+public interface PlainSchemaDAO extends SchemaDAO<PlainSchema> {
+
+ <T extends PlainAttr<?>> List<T> findAttrs(PlainSchema schema, Class<T> reference);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java
index 4b36115..9e350fb 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java
@@ -20,10 +20,9 @@ package org.apache.syncope.core.persistence.api.dao;
import java.util.List;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
-import org.apache.syncope.core.persistence.api.entity.Attr;
import org.apache.syncope.core.persistence.api.entity.Schema;
-public interface SchemaDAO<S extends Schema, A extends Attr<S, ?>> extends DAO<S, String> {
+public interface SchemaDAO<S extends Schema> extends DAO<S, String> {
S find(String name);
@@ -31,8 +30,6 @@ public interface SchemaDAO<S extends Schema, A extends Attr<S, ?>> extends DAO<S
List<S> findAll();
- <T extends A> List<T> findAttrs(S schema, Class<T> reference);
-
S save(S derSchema);
void delete(String key);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UnallowedSchemaException.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UnallowedSchemaException.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UnallowedSchemaException.java
deleted file mode 100644
index 04f67dd..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UnallowedSchemaException.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.core.persistence.api.dao;
-
-public class UnallowedSchemaException extends RuntimeException {
-
- private static final long serialVersionUID = -9206535191442808016L;
-
- public UnallowedSchemaException(final String schemaName) {
- super(schemaName + " not allowed");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java
index 9479428..1cf6475 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java
@@ -19,11 +19,10 @@
package org.apache.syncope.core.persistence.api.dao;
import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.Attr;
import org.apache.syncope.core.persistence.api.entity.VirSchema;
import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-public interface VirSchemaDAO extends SchemaDAO<VirSchema, Attr<VirSchema, ?>> {
+public interface VirSchemaDAO extends SchemaDAO<VirSchema> {
List<VirSchema> findByProvision(Provision provision);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Any.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Any.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Any.java
index f56485e..d14d3b0 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Any.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Any.java
@@ -20,9 +20,8 @@ package org.apache.syncope.core.persistence.api.entity;
import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
import java.util.List;
-import java.util.Set;
-public interface Any<P extends PlainAttr<?>, D extends DerAttr<?>> extends AnnotatedEntity<Long> {
+public interface Any<P extends PlainAttr<?>> extends AnnotatedEntity<Long> {
AnyType getType();
@@ -48,14 +47,6 @@ public interface Any<P extends PlainAttr<?>, D extends DerAttr<?>> extends Annot
List<? extends P> getPlainAttrs();
- boolean add(D derAttr);
-
- boolean remove(D derAttr);
-
- D getDerAttr(String derSchemaName);
-
- List<? extends D> getDerAttrs();
-
boolean add(ExternalResource resource);
boolean remove(ExternalResource resource);
@@ -69,10 +60,4 @@ public interface Any<P extends PlainAttr<?>, D extends DerAttr<?>> extends Annot
boolean remove(AnyTypeClass auxClass);
List<? extends AnyTypeClass> getAuxClasses();
-
- Set<PlainSchema> getAllowedPlainSchemas();
-
- Set<DerSchema> getAllowedDerSchemas();
-
- Set<VirSchema> getAllowedVirSchemas();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtils.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtils.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtils.java
index 702e7a6..377f7fe 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtils.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtils.java
@@ -18,15 +18,17 @@
*/
package org.apache.syncope.core.persistence.api.entity;
+import java.util.Set;
import org.apache.syncope.common.lib.to.AnyTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.common.lib.types.IntMappingType;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
public interface AnyUtils {
AnyTypeKind getAnyTypeKind();
- <T extends Any<?, ?>> Class<T> anyClass();
+ <T extends Any<?>> Class<T> anyClass();
<T extends PlainAttr<?>> Class<T> plainAttrClass();
@@ -40,10 +42,6 @@ public interface AnyUtils {
<T extends PlainAttrValue> T newPlainAttrUniqueValue();
- <T extends DerAttr<?>> Class<T> derAttrClass();
-
- <T extends DerAttr<?>> T newDerAttr();
-
IntMappingType plainIntMappingType();
IntMappingType derIntMappingType();
@@ -51,4 +49,8 @@ public interface AnyUtils {
IntMappingType virIntMappingType();
<T extends AnyTO> T newAnyTO();
+
+ Set<ExternalResource> getAllResources(Any<?> any);
+
+ <S extends Schema> Set<S> getAllowedSchemas(Any<?> any, Class<S> reference);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtilsFactory.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtilsFactory.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtilsFactory.java
index d64e7e1..d3cbfb6 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtilsFactory.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtilsFactory.java
@@ -24,7 +24,5 @@ public interface AnyUtilsFactory {
AnyUtils getInstance(AnyTypeKind anyTypeKind);
- AnyUtils getInstance(String anyTypeKind);
-
- AnyUtils getInstance(Any<?, ?> any);
+ AnyUtils getInstance(Any<?> any);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attr.java
deleted file mode 100644
index 500b835..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attr.java
+++ /dev/null
@@ -1,30 +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.core.persistence.api.entity;
-
-public interface Attr<S extends Schema, O extends Any<?, ?>> extends Entity<Long> {
-
- O getOwner();
-
- void setOwner(O owner);
-
- S getSchema();
-
- void setSchema(S schema);
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DerAttr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DerAttr.java
deleted file mode 100644
index ff15a4a..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DerAttr.java
+++ /dev/null
@@ -1,26 +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.core.persistence.api.entity;
-
-import java.util.Collection;
-
-public interface DerAttr<O extends Any<?, ?>> extends Attr<DerSchema, O> {
-
- String getValue(Collection<? extends PlainAttr<?>> attrs);
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java
index ebb7cf8..cae2ad0 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java
@@ -20,7 +20,7 @@ package org.apache.syncope.core.persistence.api.entity;
import org.apache.syncope.core.persistence.api.entity.group.Group;
-public interface DynGroupMembership<A extends Any<?, ?>> extends DynMembership<A> {
+public interface DynGroupMembership<A extends Any<?>> extends DynMembership<A> {
Group getGroup();
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java
index 24c6309..2ad2425 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java
@@ -20,7 +20,7 @@ package org.apache.syncope.core.persistence.api.entity;
import java.util.List;
-public interface DynMembership<A extends Any<?, ?>> extends Entity<Long> {
+public interface DynMembership<A extends Any<?>> extends Entity<Long> {
String getFIQLCond();
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Membership.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Membership.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Membership.java
index 9d1466c..aae422f 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Membership.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Membership.java
@@ -20,7 +20,7 @@ package org.apache.syncope.core.persistence.api.entity;
import org.apache.syncope.core.persistence.api.entity.group.Group;
-public interface Membership<L extends Any<?, ?>> extends Relationship<L, Group> {
+public interface Membership<L extends Any<?>> extends Relationship<L, Group> {
@Override
MembershipType getType();
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java
index 8d8a7c1..5107f54 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java
@@ -20,7 +20,15 @@ package org.apache.syncope.core.persistence.api.entity;
import java.util.List;
-public interface PlainAttr<O extends Any<?, ?>> extends Attr<PlainSchema, O> {
+public interface PlainAttr<A extends Any<?>> extends Entity<Long> {
+
+ A getOwner();
+
+ void setOwner(A owner);
+
+ PlainSchema getSchema();
+
+ void setSchema(PlainSchema schema);
void add(String value, AnyUtils anyUtils);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Relationship.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Relationship.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Relationship.java
index b87563e..0114908 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Relationship.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Relationship.java
@@ -18,7 +18,7 @@
*/
package org.apache.syncope.core.persistence.api.entity;
-public interface Relationship<L extends Any<?, ?>, R extends Any<?, ?>> extends Entity<Long> {
+public interface Relationship<L extends Any<?>, R extends Any<?>> extends Entity<Long> {
RelationshipType getType();
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADerAttr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADerAttr.java
deleted file mode 100644
index ca5854a..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADerAttr.java
+++ /dev/null
@@ -1,24 +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.core.persistence.api.entity.anyobject;
-
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
-
-public interface ADerAttr extends DerAttr<AnyObject> {
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/AnyObject.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/AnyObject.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/AnyObject.java
index 1e10257..666b82c 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/AnyObject.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/AnyObject.java
@@ -23,7 +23,7 @@ import java.util.List;
import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.persistence.api.entity.RelationshipType;
-public interface AnyObject extends Any<APlainAttr, ADerAttr> {
+public interface AnyObject extends Any<APlainAttr> {
boolean add(ARelationship relationship);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/conf/Conf.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/conf/Conf.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/conf/Conf.java
index f4ca14d..f31b21a 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/conf/Conf.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/conf/Conf.java
@@ -20,9 +20,8 @@ package org.apache.syncope.core.persistence.api.entity.conf;
import java.util.List;
import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
-public interface Conf extends Any<CPlainAttr, DerAttr<?>> {
+public interface Conf extends Any<CPlainAttr> {
void setKey(Long key);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/GDerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/GDerAttr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/GDerAttr.java
deleted file mode 100644
index 04d1f85..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/GDerAttr.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.core.persistence.api.entity.group;
-
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
-
-public interface GDerAttr extends DerAttr<Group> {
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java
index 0afddba..56fe5db 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java
@@ -25,7 +25,7 @@ import org.apache.syncope.core.persistence.api.entity.anyobject.ADynGroupMembers
import org.apache.syncope.core.persistence.api.entity.user.UDynGroupMembership;
import org.apache.syncope.core.persistence.api.entity.user.User;
-public interface Group extends Any<GPlainAttr, GDerAttr> {
+public interface Group extends Any<GPlainAttr> {
String getName();
@@ -51,18 +51,6 @@ public interface Group extends Any<GPlainAttr, GDerAttr> {
@Override
List<? extends GPlainAttr> getPlainAttrs();
- @Override
- boolean add(GDerAttr attr);
-
- @Override
- boolean remove(GDerAttr derAttr);
-
- @Override
- GDerAttr getDerAttr(String derSchemaName);
-
- @Override
- List<? extends GDerAttr> getDerAttrs();
-
ADynGroupMembership getADynMembership();
void setADynMembership(ADynGroupMembership aDynMembership);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/UDerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/UDerAttr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/UDerAttr.java
deleted file mode 100644
index b3ebdec..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/UDerAttr.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.core.persistence.api.entity.user;
-
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
-
-public interface UDerAttr extends DerAttr<User> {
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/User.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/User.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/User.java
index 0a51c48..cbec1c9 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/User.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/User.java
@@ -26,7 +26,7 @@ import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.persistence.api.entity.RelationshipType;
import org.apache.syncope.core.persistence.api.entity.Role;
-public interface User extends Any<UPlainAttr, UDerAttr> {
+public interface User extends Any<UPlainAttr> {
String getUsername();
@@ -104,18 +104,6 @@ public interface User extends Any<UPlainAttr, UDerAttr> {
@Override
List<? extends UPlainAttr> getPlainAttrs();
- @Override
- boolean add(UDerAttr attr);
-
- @Override
- boolean remove(UDerAttr derAttr);
-
- @Override
- UDerAttr getDerAttr(String derSchemaName);
-
- @Override
- List<? extends UDerAttr> getDerAttrs();
-
boolean add(Role role);
boolean remove(Role role);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
index 3c8b0ad..c70c7c7 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
@@ -54,7 +54,6 @@ import org.apache.syncope.core.misc.utils.FormatUtils;
import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
import org.apache.syncope.core.persistence.api.content.ContentExporter;
import org.apache.syncope.core.persistence.jpa.entity.JPAReportExec;
-import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAADerAttr;
import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAMembership;
import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAPlainAttr;
import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAPlainAttrUniqueValue;
@@ -62,7 +61,6 @@ import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAPlainAttrVal
import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAARelationship;
import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAnyObject;
import org.apache.syncope.core.persistence.jpa.entity.task.JPATaskExec;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPAUDerAttr;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUMembership;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUPlainAttr;
import org.apache.syncope.core.persistence.jpa.entity.user.JPAUPlainAttrUniqueValue;
@@ -85,9 +83,7 @@ public class XMLContentExporter extends AbstractContentDealer implements Content
new HashSet<>(Arrays.asList(new String[] {
"QRTZ_", "LOGGING", JPAReportExec.TABLE, JPATaskExec.TABLE,
JPAUser.TABLE, JPAUPlainAttr.TABLE, JPAUPlainAttrValue.TABLE, JPAUPlainAttrUniqueValue.TABLE,
- JPAUDerAttr.TABLE,
JPAAnyObject.TABLE, JPAAPlainAttr.TABLE, JPAAPlainAttrValue.TABLE, JPAAPlainAttrUniqueValue.TABLE,
- JPAADerAttr.TABLE,
JPAARelationship.TABLE, JPAAMembership.TABLE, JPAURelationship.TABLE, JPAUMembership.TABLE
}));
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
index 960251f..30fcf2f 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
@@ -20,6 +20,7 @@ package org.apache.syncope.core.persistence.jpa.dao;
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -43,17 +44,25 @@ import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
import org.apache.syncope.core.persistence.api.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
import org.apache.syncope.core.persistence.api.entity.AnyUtils;
import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
+import org.apache.syncope.core.persistence.api.entity.Schema;
+import org.apache.syncope.core.persistence.api.entity.VirSchema;
+import org.apache.syncope.core.persistence.api.entity.anyobject.AMembership;
+import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
+import org.apache.syncope.core.persistence.api.entity.group.TypeExtension;
import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.user.UMembership;
import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
-public abstract class AbstractAnyDAO<A extends Any<?, ?>> extends AbstractDAO<A, Long> implements AnyDAO<A> {
+public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A, Long> implements AnyDAO<A> {
@Autowired
protected PlainSchemaDAO plainSchemaDAO;
@@ -407,6 +416,42 @@ public abstract class AbstractAnyDAO<A extends Any<?, ?>> extends AbstractDAO<A,
getAnyUtils().getAnyTypeKind());
}
+ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
+ @Override
+ @SuppressWarnings("unchecked")
+ public <S extends Schema> Collection<S> findAllowedSchemas(final A any, final Class<S> reference) {
+ Set<AnyTypeClass> classes = new HashSet<>();
+ classes.addAll(any.getType().getClasses());
+ classes.addAll(any.getAuxClasses());
+ if (any instanceof User) {
+ for (UMembership memb : ((User) any).getMemberships()) {
+ for (TypeExtension typeExtension : memb.getRightEnd().getTypeExtensions()) {
+ classes.addAll(typeExtension.getAuxClasses());
+ }
+ }
+ } else if (any instanceof AnyObject) {
+ for (AMembership memb : ((AnyObject) any).getMemberships()) {
+ for (TypeExtension typeExtension : memb.getRightEnd().getTypeExtensions()) {
+ classes.addAll(typeExtension.getAuxClasses());
+ }
+ }
+ }
+
+ Set<S> result = new HashSet<>();
+
+ for (AnyTypeClass typeClass : classes) {
+ if (reference.equals(PlainSchema.class)) {
+ result.addAll((Collection<? extends S>) typeClass.getPlainSchemas());
+ } else if (reference.equals(DerSchema.class)) {
+ result.addAll((Collection<? extends S>) typeClass.getDerSchemas());
+ } else if (reference.equals(VirSchema.class)) {
+ result.addAll((Collection<? extends S>) typeClass.getVirSchemas());
+ }
+ }
+
+ return result;
+ }
+
@Override
public final int count(final Set<String> adminRealms) {
return searchDAO.count(adminRealms, getAllMatchingCond(), getAnyUtils().getAnyTypeKind());
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
index f02b4ba..7b1df89 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
@@ -67,7 +67,7 @@ import org.springframework.stereotype.Repository;
import org.springframework.util.ReflectionUtils;
@Repository
-public class JPAAnySearchDAO extends AbstractDAO<Any<?, ?>, Long> implements AnySearchDAO {
+public class JPAAnySearchDAO extends AbstractDAO<Any<?>, Long> implements AnySearchDAO {
private static final String EMPTY_ATTR_QUERY = "SELECT any_id FROM user_search_attr WHERE 1=2";
@@ -150,14 +150,14 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?, ?>, Long> implements Any
}
@Override
- public <T extends Any<?, ?>> List<T> search(
+ public <T extends Any<?>> List<T> search(
final Set<String> adminRealms, final SearchCond searchCondition, final AnyTypeKind typeKind) {
return search(adminRealms, searchCondition, Collections.<OrderByClause>emptyList(), typeKind);
}
@Override
- public <T extends Any<?, ?>> List<T> search(
+ public <T extends Any<?>> List<T> search(
final Set<String> adminRealms, final SearchCond searchCondition, final List<OrderByClause> orderBy,
final AnyTypeKind typeKind) {
@@ -165,7 +165,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?, ?>, Long> implements Any
}
@Override
- public <T extends Any<?, ?>> List<T> search(
+ public <T extends Any<?>> List<T> search(
final Set<String> adminRealms, final SearchCond searchCondition, final int page, final int itemsPerPage,
final List<OrderByClause> orderBy, final AnyTypeKind typeKind) {
@@ -189,7 +189,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?, ?>, Long> implements Any
}
@Override
- public <T extends Any<?, ?>> boolean matches(
+ public <T extends Any<?>> boolean matches(
final T any, final SearchCond searchCondition, final AnyTypeKind typeKind) {
List<Object> parameters = Collections.synchronizedList(new ArrayList<>());
@@ -347,7 +347,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?, ?>, Long> implements Any
}
@SuppressWarnings("unchecked")
- private <T extends Any<?, ?>> List<T> doSearch(final Set<String> adminRealms,
+ private <T extends Any<?>> List<T> doSearch(final Set<String> adminRealms,
final SearchCond nodeCond, final int page, final int itemsPerPage, final List<OrderByClause> orderBy,
final AnyTypeKind typeKind) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerAttrDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerAttrDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerAttrDAO.java
deleted file mode 100644
index 99b9014..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerAttrDAO.java
+++ /dev/null
@@ -1,86 +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.core.persistence.jpa.dao;
-
-import java.util.List;
-import javax.persistence.TypedQuery;
-import org.apache.syncope.core.persistence.api.dao.DerAttrDAO;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
-import org.apache.syncope.core.persistence.api.entity.anyobject.ADerAttr;
-import org.apache.syncope.core.persistence.api.entity.group.GDerAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractDerAttr;
-import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAADerAttr;
-import org.apache.syncope.core.persistence.jpa.entity.group.JPAGDerAttr;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPAUDerAttr;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class JPADerAttrDAO extends AbstractDAO<DerAttr<?>, Long> implements DerAttrDAO {
-
- public <T extends DerAttr<?>> Class<? extends AbstractDerAttr<?>> getJPAEntityReference(
- final Class<T> reference) {
-
- return GDerAttr.class.isAssignableFrom(reference)
- ? JPAGDerAttr.class
- : ADerAttr.class.isAssignableFrom(reference)
- ? JPAADerAttr.class
- : UDerAttr.class.isAssignableFrom(reference)
- ? JPAUDerAttr.class
- : null;
- }
-
- @Override
- public <T extends DerAttr<?>> T find(final Long key, final Class<T> reference) {
- return reference.cast(entityManager().find(getJPAEntityReference(reference), key));
- }
-
- @Override
- public <T extends DerAttr<?>> List<T> findAll(final Class<T> reference) {
- TypedQuery<T> query = entityManager().createQuery(
- "SELECT e FROM " + getJPAEntityReference(reference).getSimpleName() + " e", reference);
- return query.getResultList();
- }
-
- @Override
- public <T extends DerAttr<?>> T save(final T derAttr) {
- return entityManager().merge(derAttr);
- }
-
- @Override
- public <T extends DerAttr<?>> void delete(final Long key, final Class<T> reference) {
- T derAttr = find(key, reference);
- if (derAttr == null) {
- return;
- }
-
- delete(derAttr);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T extends DerAttr<?>> void delete(final T derAttr) {
- if (derAttr.getOwner() != null) {
- ((Any<?, T>) derAttr.getOwner()).remove(derAttr);
- }
-
- entityManager().remove(derAttr);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
index 4ed17ca..8221493 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
@@ -21,13 +21,10 @@ package org.apache.syncope.core.persistence.jpa.dao;
import java.util.List;
import javax.persistence.TypedQuery;
import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.core.persistence.api.dao.DerAttrDAO;
import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
import org.apache.syncope.core.persistence.api.entity.DerSchema;
import org.apache.syncope.core.persistence.jpa.entity.JPAAnyUtilsFactory;
import org.apache.syncope.core.persistence.jpa.entity.JPADerSchema;
@@ -38,9 +35,6 @@ import org.springframework.stereotype.Repository;
public class JPADerSchemaDAO extends AbstractDAO<DerSchema, String> implements DerSchemaDAO {
@Autowired
- private DerAttrDAO derAttrDAO;
-
- @Autowired
private ExternalResourceDAO resourceDAO;
@Override
@@ -68,18 +62,6 @@ public class JPADerSchemaDAO extends AbstractDAO<DerSchema, String> implements D
}
@Override
- public <T extends DerAttr<?>> List<T> findAttrs(final DerSchema schema, final Class<T> reference) {
- StringBuilder queryString = new StringBuilder("SELECT e FROM ").
- append(((JPADerAttrDAO) derAttrDAO).getJPAEntityReference(reference).getSimpleName()).
- append(" e WHERE e.schema=:schema");
-
- TypedQuery<T> query = entityManager().createQuery(queryString.toString(), reference);
- query.setParameter("schema", schema);
-
- return query.getResultList();
- }
-
- @Override
public DerSchema save(final DerSchema derSchema) {
return entityManager().merge(derSchema);
}
@@ -93,13 +75,7 @@ public class JPADerSchemaDAO extends AbstractDAO<DerSchema, String> implements D
AnyUtilsFactory anyUtilsFactory = new JPAAnyUtilsFactory();
for (AnyTypeKind anyTypeKind : AnyTypeKind.values()) {
- AnyUtils anyUtils = anyUtilsFactory.getInstance(anyTypeKind);
-
- for (DerAttr<?> attr : findAttrs(schema, anyUtils.derAttrClass())) {
- derAttrDAO.delete(attr.getKey(), anyUtils.derAttrClass());
- }
-
- resourceDAO.deleteMapping(key, anyUtils.derIntMappingType());
+ resourceDAO.deleteMapping(key, anyUtilsFactory.getInstance(anyTypeKind).derIntMappingType());
}
if (schema.getAnyTypeClass() != null) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
index 86e6275..66f7290 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
@@ -203,7 +203,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
}
private void populateTransitiveResources(
- final Group group, final Any<?, ?> any, final Map<Long, PropagationByResource> result) {
+ final Group group, final Any<?> any, final Map<Long, PropagationByResource> result) {
PropagationByResource propByRes = new PropagationByResource();
for (ExternalResource resource : group.getResources()) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainAttrDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainAttrDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainAttrDAO.java
index cec3d5b..975b6e9 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainAttrDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainAttrDAO.java
@@ -68,7 +68,7 @@ public class JPAPlainAttrDAO extends AbstractDAO<PlainAttr<?>, Long> implements
@SuppressWarnings("unchecked")
public <T extends PlainAttr<?>> void delete(final T plainAttr) {
if (plainAttr.getOwner() != null) {
- ((Any<T, ?>) plainAttr.getOwner()).remove(plainAttr);
+ ((Any<T>) plainAttr.getOwner()).remove(plainAttr);
}
entityManager().remove(plainAttr);
[2/5] syncope git commit: [SYNCOPE-725] Refactoring completed
Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
index 170ca91..d580152 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
@@ -51,7 +51,6 @@ import org.apache.syncope.common.lib.patch.LongReplacePatchItem;
import org.apache.syncope.common.lib.patch.StringReplacePatchItem;
import org.apache.syncope.common.lib.to.AnyTypeClassTO;
import org.apache.syncope.common.lib.to.AnyTypeTO;
-import org.apache.syncope.common.lib.to.AttrTO;
import org.apache.syncope.common.lib.to.BulkActionResult;
import org.apache.syncope.common.lib.to.ConnInstanceTO;
import org.apache.syncope.common.lib.to.ConnObjectTO;
@@ -222,33 +221,13 @@ public class GroupITCase extends AbstractITCase {
assertEquals(modName, groupTO.getName());
assertEquals(2, groupTO.getPlainAttrs().size());
-
- groupTO.getPlainAttrMap().get("show").getValues().clear();
-
- groupTO = groupService.update(groupTO).readEntity(new GenericType<ProvisioningResult<GroupTO>>(){}).getAny();
-
- assertFalse(groupTO.getPlainAttrMap().containsKey("show"));
- }
-
- @Test
- public void updateRemovingDerAttribute() {
- GroupTO groupTO = getBasicSampleTO("withderived" + getUUIDString());
- groupTO.getDerAttrs().add(attrTO("rderivedschema", null));
- groupTO = createGroup(groupTO).getAny();
-
- assertNotNull(groupTO);
- assertEquals(1, groupTO.getDerAttrs().size());
+ groupTO.getPlainAttrMap().get("show").getValues().clear();
- GroupPatch groupPatch = new GroupPatch();
- groupPatch.setKey(groupTO.getKey());
- groupPatch.getDerAttrs().add(new AttrPatch.Builder().operation(PatchOperation.DELETE).
- attrTO(new AttrTO.Builder().schema("rderivedschema").build()).
- build());
+ groupTO = groupService.update(groupTO).readEntity(new GenericType<ProvisioningResult<GroupTO>>() {
+ }).getAny();
- groupTO = updateGroup(groupPatch).getAny();
- assertNotNull(groupTO);
- assertTrue(groupTO.getDerAttrs().isEmpty());
+ assertFalse(groupTO.getPlainAttrMap().containsKey("show"));
}
@Test
@@ -680,7 +659,7 @@ public class GroupITCase extends AbstractITCase {
assertEquals(RESOURCE_NAME_LDAP, result.getPropagationStatuses().get(0).getResource());
assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
group = result.getAny();
-
+
// 3. set capability override with only search allowed, but not enable
ldap.getCapabilitiesOverride().add(ConnectorCapability.SEARCH);
resourceService.update(ldap);
@@ -748,6 +727,7 @@ public class GroupITCase extends AbstractITCase {
MappingItemTO connObjectKey = mapping.getConnObjectKeyItem();
connObjectKey.setIntMappingType(IntMappingType.GroupDerivedSchema);
connObjectKey.setIntAttrName("displayProperty");
+ connObjectKey.setPurpose(MappingPurpose.PROPAGATION);
mapping.setConnObjectKeyItem(connObjectKey);
mapping.setConnObjectLink("'cn=' + displayProperty + ',ou=groups,o=isp'");
@@ -873,5 +853,5 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(groupTO);
assertEquals("11.23", groupTO.getPlainAttrMap().get(doubleSchemaName).getValues().get(0));
}
-
+
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec66245/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
index 94e51d7..c502ed1 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
@@ -272,23 +272,27 @@ public class UserITCase extends AbstractITCase {
resourceTO = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
assertNotNull(resourceTO);
- UserTO userTO = getUniqueSampleTO("syncope222@apache.org");
- userTO.getResources().add(resourceTO.getKey());
- userTO.setPassword("newPassword12");
-
try {
- userTO = createUser(userTO).getAny();
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
- }
+ UserTO userTO = getUniqueSampleTO("syncope222@apache.org");
+ userTO.getResources().add(resourceTO.getKey());
+ userTO.setPassword("newPassword12");
- userTO.getAuxClasses().add("csv");
- userTO.getDerAttrs().add(attrTO("csvuserid", null));
+ try {
+ userTO = createUser(userTO).getAny();
+ fail();
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
+ }
- userTO = createUser(userTO).getAny();
- assertNotNull(userTO);
- assertEquals(Collections.singleton("resource-csv-enforcing"), userTO.getResources());
+ userTO.getAuxClasses().add("csv");
+ userTO.getDerAttrs().add(new AttrTO.Builder().schema("csvuserid").build());
+
+ userTO = createUser(userTO).getAny();
+ assertNotNull(userTO);
+ assertEquals(Collections.singleton(resourceTO.getKey()), userTO.getResources());
+ } finally {
+ resourceService.delete(resourceTO.getKey());
+ }
}
@Test
@@ -590,7 +594,7 @@ public class UserITCase extends AbstractITCase {
}
@Test
- public void updateWithouPassword() {
+ public void updateWithoutPassword() {
UserTO userTO = getUniqueSampleTO("updatewithout@password.com");
userTO = createUser(userTO).getAny();
@@ -599,15 +603,15 @@ public class UserITCase extends AbstractITCase {
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
- userPatch.getDerAttrs().add(new AttrPatch.Builder().operation(PatchOperation.DELETE).
- attrTO(new AttrTO.Builder().schema("cn").build()).
+ userPatch.getPlainAttrs().add(new AttrPatch.Builder().operation(PatchOperation.DELETE).
+ attrTO(new AttrTO.Builder().schema("type").build()).
build());
userTO = updateUser(userPatch).getAny();
assertNotNull(userTO);
assertNotNull(userTO.getDerAttrMap());
- assertFalse(userTO.getDerAttrMap().containsKey("cn"));
+ assertFalse(userTO.getPlainAttrMap().containsKey("type"));
}
@Test(expected = SyncopeClientException.class)
@@ -660,8 +664,6 @@ public class UserITCase extends AbstractITCase {
String newFullName = getUUIDString() + "g.h@t.com";
userPatch.getPlainAttrs().add(attrAddReplacePatch("fullname", newFullName));
- userPatch.getDerAttrs().add(new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).
- attrTO(new AttrTO.Builder().schema("cn").build()).build());
userPatch.getMemberships().add(new MembershipPatch.Builder().operation(PatchOperation.ADD_REPLACE).
membershipTO(new MembershipTO.Builder().group(8L).build()).build());
userPatch.getMemberships().add(new MembershipPatch.Builder().operation(PatchOperation.ADD_REPLACE).
@@ -972,9 +974,9 @@ public class UserITCase extends AbstractITCase {
});
assertEquals(PropagationTaskExecStatus.SUCCESS, byResource.get(RESOURCE_NAME_LDAP).getStatus());
assertTrue(byResource.get(RESOURCE_NAME_TESTDB).getStatus() == PropagationTaskExecStatus.CREATED
- || byResource.get(RESOURCE_NAME_TESTDB).getStatus() == PropagationTaskExecStatus.SUCCESS);
+ || byResource.get(RESOURCE_NAME_TESTDB).getStatus() == PropagationTaskExecStatus.SUCCESS);
assertTrue(byResource.get(RESOURCE_NAME_TESTDB2).getStatus() == PropagationTaskExecStatus.CREATED
- || byResource.get(RESOURCE_NAME_TESTDB2).getStatus() == PropagationTaskExecStatus.SUCCESS);
+ || byResource.get(RESOURCE_NAME_TESTDB2).getStatus() == PropagationTaskExecStatus.SUCCESS);
}
@Test
@@ -989,7 +991,7 @@ public class UserITCase extends AbstractITCase {
ProvisioningResult<UserTO> result = asyncService.create(user).readEntity(
new GenericType<ProvisioningResult<UserTO>>() {
- });
+ });
assertNotNull(result);
verifyAsyncResult(result.getPropagationStatuses());
@@ -1001,13 +1003,13 @@ public class UserITCase extends AbstractITCase {
result = asyncService.update(userPatch).readEntity(
new GenericType<ProvisioningResult<UserTO>>() {
- });
+ });
assertNotNull(result);
verifyAsyncResult(result.getPropagationStatuses());
result = asyncService.delete(result.getAny().getKey()).readEntity(
new GenericType<ProvisioningResult<UserTO>>() {
- });
+ });
assertNotNull(result);
verifyAsyncResult(result.getPropagationStatuses());
}