Author: ilgrosso
Date: Wed Dec 5 16:21:26 2012
New Revision: 1417507
URL: http://svn.apache.org/viewvc?rev=1417507view=rev
Log:
Some UMapping / UMappingItems left in Resource DataBinder now fixed + added a
dedicated IT
Modified:
syncope/branches/DEV_ROLE_PROVISIONING/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java
syncope/branches/DEV_ROLE_PROVISIONING/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
Modified:
syncope/branches/DEV_ROLE_PROVISIONING/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java
URL:
http://svn.apache.org/viewvc/syncope/branches/DEV_ROLE_PROVISIONING/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java?rev=1417507r1=1417506r2=1417507view=diff
==
---
syncope/branches/DEV_ROLE_PROVISIONING/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java
(original)
+++
syncope/branches/DEV_ROLE_PROVISIONING/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java
Wed Dec 5 16:21:26 2012
@@ -39,6 +39,7 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.beans.PasswordPolicy;
import org.apache.syncope.core.persistence.beans.SyncPolicy;
import org.apache.syncope.core.persistence.beans.role.RMapping;
+import org.apache.syncope.core.persistence.beans.role.RMappingItem;
import org.apache.syncope.core.persistence.beans.user.UMapping;
import org.apache.syncope.core.persistence.beans.user.UMappingItem;
import org.apache.syncope.core.persistence.dao.ConnInstanceDAO;
@@ -109,12 +110,12 @@ public class ResourceDataBinder {
if (resourceTO.getUmapping() != null) {
UMapping mapping = new UMapping();
resource.setUmapping(mapping);
-populateMapping(resourceTO.getUmapping(), mapping);
+populateMapping(resourceTO.getUmapping(), mapping, new
UMappingItem());
}
if (resourceTO.getRmapping() != null) {
RMapping mapping = new RMapping();
resource.setRmapping(mapping);
-populateMapping(resourceTO.getRmapping(), mapping);
+populateMapping(resourceTO.getRmapping(), mapping, new
RMappingItem());
}
resource.setCreateTraceLevel(resourceTO.getCreateTraceLevel());
@@ -145,10 +146,12 @@ public class ResourceDataBinder {
return resource;
}
-private void populateMapping(final MappingTO mappingTO, final
AbstractMapping mapping) {
+private void populateMapping(final MappingTO mappingTO, final
AbstractMapping mapping,
+final AbstractMappingItem prototype) {
+
mapping.setAccountLink(mappingTO.getAccountLink());
-for (AbstractMappingItem item : getMappingItems(mappingTO.getItems()))
{
+for (AbstractMappingItem item : getMappingItems(mappingTO.getItems(),
prototype)) {
if (item.isAccountid()) {
mapping.setAccountIdItem(item);
} else if (item.isPassword()) {
@@ -159,16 +162,18 @@ public class ResourceDataBinder {
}
}
-private SetAbstractMappingItem getMappingItems(final
CollectionMappingItemTO itemTOs) {
+private SetAbstractMappingItem getMappingItems(final
CollectionMappingItemTO itemTOs,
+final AbstractMappingItem prototype) {
+
SetAbstractMappingItem items = new
HashSetAbstractMappingItem(itemTOs.size());
for (MappingItemTO itemTO : itemTOs) {
-items.add(getMappingItem(itemTO));
+items.add(getMappingItem(itemTO, prototype));
}
return items;
}
-private AbstractMappingItem getMappingItem(final MappingItemTO itemTO)
+private AbstractMappingItem getMappingItem(final MappingItemTO itemTO,
final AbstractMappingItem prototype)
throws SyncopeClientCompositeErrorException {
SyncopeClientCompositeErrorException scce = new
SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
@@ -213,7 +218,7 @@ public class ResourceDataBinder {
throw scce;
}
-UMappingItem item = new UMappingItem();
+AbstractMappingItem item = (AbstractMappingItem)
SerializationUtils.clone(prototype);
BeanUtils.copyProperties(itemTO, item, MAPPINGITEM_IGNORE_PROPERTIES);
return item;
}
Modified:
syncope/branches/DEV_ROLE_PROVISIONING/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
URL:
http://svn.apache.org/viewvc/syncope/branches/DEV_ROLE_PROVISIONING/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java?rev=1417507r1=1417506r2=1417507view=diff
==
---
syncope/branches/DEV_ROLE_PROVISIONING/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
(original)
+++