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 2014/06/24 15:25:21 UTC

svn commit: r1605077 [4/5] - in /syncope/trunk: ./ common/src/main/java/org/apache/syncope/common/services/ common/src/main/java/org/apache/syncope/common/to/ common/src/main/java/org/apache/syncope/common/types/ common/src/test/java/org/apache/syncope...

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java Tue Jun 24 13:25:18 2014
@@ -20,19 +20,16 @@ package org.apache.syncope.core.services
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.net.URI;
 import java.util.List;
 import javax.ws.rs.core.HttpHeaders;
-
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.StreamingOutput;
-
 import org.apache.syncope.common.services.ConfigurationService;
-import org.apache.syncope.common.to.ConfigurationTO;
+import org.apache.syncope.common.to.AttributeTO;
+import org.apache.syncope.common.to.ConfTO;
 import org.apache.syncope.common.wrap.MailTemplate;
 import org.apache.syncope.common.wrap.Validator;
-import org.apache.syncope.common.types.RESTHeaders;
 import org.apache.syncope.common.util.CollectionWrapper;
 import org.apache.syncope.core.persistence.dao.impl.ContentLoader;
 import org.apache.syncope.core.rest.controller.ConfigurationController;
@@ -46,15 +43,6 @@ public class ConfigurationServiceImpl ex
     private ConfigurationController controller;
 
     @Override
-    public Response create(final ConfigurationTO configurationTO) {
-        ConfigurationTO created = controller.create(configurationTO);
-        URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
-        return Response.created(location).
-                header(RESTHeaders.RESOURCE_ID, created.getKey()).
-                build();
-    }
-
-    @Override
     public Response export() {
         StreamingOutput sout = new StreamingOutput() {
 
@@ -75,30 +63,28 @@ public class ConfigurationServiceImpl ex
     }
 
     @Override
-    @SuppressWarnings("unchecked")
     public List<MailTemplate> getMailTemplates() {
         return CollectionWrapper.wrap(controller.getMailTemplates(), MailTemplate.class);
     }
 
     @Override
-    @SuppressWarnings("unchecked")
     public List<Validator> getValidators() {
         return CollectionWrapper.wrap(controller.getValidators(), Validator.class);
     }
 
     @Override
-    public List<ConfigurationTO> list() {
+    public ConfTO list() {
         return controller.list();
     }
 
     @Override
-    public ConfigurationTO read(final String key) {
+    public AttributeTO read(final String key) {
         return controller.read(key);
-
     }
 
     @Override
-    public void update(final String key, final ConfigurationTO configurationTO) {
-        controller.update(configurationTO);
+    public void set(final String key, final AttributeTO value) {
+        value.setSchema(key);
+        controller.set(value);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserSelfServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserSelfServiceImpl.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserSelfServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserSelfServiceImpl.java Tue Jun 24 13:25:18 2014
@@ -20,9 +20,11 @@ package org.apache.syncope.core.services
 
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
+import org.apache.syncope.common.SyncopeClientException;
 import org.apache.syncope.common.mod.UserMod;
 import org.apache.syncope.common.services.UserSelfService;
 import org.apache.syncope.common.to.UserTO;
+import org.apache.syncope.common.types.ClientExceptionType;
 import org.apache.syncope.common.types.RESTHeaders;
 import org.apache.syncope.core.rest.controller.UserController;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +45,12 @@ public class UserSelfServiceImpl extends
 
     @Override
     public Response create(final UserTO userTO) {
+        if (!controller.isSelfRegistrationAllowed()) {
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unauthorized);
+            sce.getElements().add("SelfRegistration forbidden by configuration");
+            throw sce;
+        }
+
         UserTO created = controller.createSelf(userTO);
         return createResponse(created.getId(), created).build();
     }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/PushJob.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/PushJob.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/PushJob.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/PushJob.java Tue Jun 24 13:25:18 2014
@@ -23,15 +23,15 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import org.apache.commons.lang.StringUtils;
-import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.common.types.SyncPolicySpec;
 import org.apache.syncope.core.persistence.beans.PushTask;
 import org.apache.syncope.core.persistence.beans.role.RMapping;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
 import org.apache.syncope.core.persistence.beans.user.UMapping;
-import org.apache.syncope.core.persistence.dao.AttributableSearchDAO;
 import org.apache.syncope.core.persistence.dao.RoleDAO;
+import org.apache.syncope.core.persistence.dao.SubjectSearchDAO;
 import org.apache.syncope.core.persistence.dao.UserDAO;
 import org.apache.syncope.core.persistence.dao.search.OrderByClause;
 import org.apache.syncope.core.propagation.Connector;
@@ -39,7 +39,6 @@ import org.apache.syncope.core.rest.data
 import org.apache.syncope.core.sync.PushActions;
 import org.apache.syncope.core.sync.SyncResult;
 import org.apache.syncope.core.util.ApplicationContextProvider;
-import org.apache.syncope.core.util.AttributableUtil;
 import org.apache.syncope.core.util.EntitlementUtil;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -64,7 +63,7 @@ public class PushJob extends AbstractSyn
      * Search DAO.
      */
     @Autowired
-    private AttributableSearchDAO searchDAO;
+    private SubjectSearchDAO searchDAO;
 
     /**
      * Role DAO.
@@ -159,7 +158,7 @@ public class PushJob extends AbstractSyn
         } else {
             return searchDAO.<SyncopeUser>search(
                     authorizations, SearchCondConverter.convert(filter),
-                    Collections.<OrderByClause>emptyList(), AttributableUtil.getInstance(AttributableType.USER));
+                    Collections.<OrderByClause>emptyList(), SubjectType.USER);
         }
     }
 
@@ -170,7 +169,7 @@ public class PushJob extends AbstractSyn
         } else {
             return searchDAO.<SyncopeRole>search(
                     authorizations, SearchCondConverter.convert(filter),
-                    Collections.<OrderByClause>emptyList(), AttributableUtil.getInstance(AttributableType.ROLE));
+                    Collections.<OrderByClause>emptyList(), SubjectType.ROLE);
         }
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopePushResultHandler.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopePushResultHandler.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopePushResultHandler.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopePushResultHandler.java Tue Jun 24 13:25:18 2014
@@ -28,14 +28,14 @@ import org.apache.syncope.common.types.A
 import org.apache.syncope.common.types.AuditElements;
 import org.apache.syncope.common.types.AuditElements.Result;
 import org.apache.syncope.common.types.ResourceOperation;
-import org.apache.syncope.core.persistence.beans.AbstractAttributable;
+import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
 import org.apache.syncope.core.persistence.beans.PushTask;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
 import org.apache.syncope.core.propagation.TimeoutException;
 import org.apache.syncope.core.propagation.impl.AbstractPropagationTaskExecutor;
-import org.apache.syncope.core.rest.controller.AbstractAttributableController;
+import org.apache.syncope.core.rest.controller.AbstractSubjectController;
 import org.apache.syncope.core.sync.PushActions;
 import org.apache.syncope.core.sync.SyncResult;
 import org.apache.syncope.core.util.AttributableUtil;
@@ -56,9 +56,9 @@ public class SyncopePushResultHandler ex
     }
 
     @Transactional
-    public boolean handle(final AbstractAttributable attributable) {
+    public boolean handle(final AbstractSubject subject) {
         try {
-            doHandle(attributable);
+            doHandle(subject);
             return true;
         } catch (JobExecutionException e) {
             LOG.error("Synchronization failed", e);
@@ -66,40 +66,34 @@ public class SyncopePushResultHandler ex
         }
     }
 
-    /**
-     * Look into SyncDelta and take necessary actions (create / update / delete) on user(s).
-     *
-     * @param delta returned by the underlying connector
-     * @throws JobExecutionException in case of synchronization failure.
-     */
-    protected final void doHandle(final AbstractAttributable attributable)
+    protected final void doHandle(final AbstractSubject subject)
             throws JobExecutionException {
 
         if (results == null) {
             results = new ArrayList<SyncResult>();
         }
 
-        final AttributableUtil attrUtil = AttributableUtil.getInstance(attributable);
+        final AttributableUtil attrUtil = AttributableUtil.getInstance(subject);
 
         final SyncResult result = new SyncResult();
         results.add(result);
 
-        result.setId(attributable.getId());
+        result.setId(subject.getId());
         result.setSubjectType(attrUtil.getType());
 
-        final AbstractAttributableController<?, ?> controller;
-        final AbstractAttributable toBeHandled;
+        final AbstractSubjectController<?, ?> controller;
+        final AbstractSubject toBeHandled;
         final Boolean enabled;
 
         if (attrUtil.getType() == AttributableType.USER) {
-            toBeHandled = userDataBinder.getUserFromId(attributable.getId());
+            toBeHandled = userDataBinder.getUserFromId(subject.getId());
             result.setName(((SyncopeUser) toBeHandled).getUsername());
             enabled = getSyncTask().isSyncStatus()
                     ? ((SyncopeUser) toBeHandled).isSuspended() ? Boolean.FALSE : Boolean.TRUE
                     : null;
             controller = userController;
         } else {
-            toBeHandled = roleDataBinder.getRoleFromId(attributable.getId());
+            toBeHandled = roleDataBinder.getRoleFromId(subject.getId());
             result.setName(((SyncopeRole) toBeHandled).getName());
             enabled = null;
             controller = roleController;

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java Tue Jun 24 13:25:18 2014
@@ -31,10 +31,6 @@ import org.apache.commons.lang3.StringUt
 import org.apache.syncope.common.mod.AttributeMod;
 import org.apache.syncope.common.mod.RoleMod;
 import org.apache.syncope.common.mod.UserMod;
-import org.apache.syncope.core.persistence.dao.search.AttributableCond;
-import org.apache.syncope.core.persistence.dao.search.AttributeCond;
-import org.apache.syncope.core.persistence.dao.search.SearchCond;
-import org.apache.syncope.common.to.AbstractAttributableTO;
 import org.apache.syncope.common.to.AbstractSubjectTO;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.common.to.RoleTO;
@@ -44,35 +40,39 @@ import org.apache.syncope.common.types.A
 import org.apache.syncope.common.types.AuditElements.Result;
 import org.apache.syncope.common.types.MappingPurpose;
 import org.apache.syncope.common.types.ResourceOperation;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.common.types.SyncPolicySpec;
 import org.apache.syncope.core.persistence.beans.AbstractAttrValue;
-import org.apache.syncope.core.persistence.beans.AbstractAttributable;
 import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
 import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
+import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.PropagationTask;
 import org.apache.syncope.core.persistence.beans.SyncPolicy;
 import org.apache.syncope.core.persistence.beans.SyncTask;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
-import org.apache.syncope.core.persistence.dao.AttributableSearchDAO;
 import org.apache.syncope.core.persistence.dao.EntitlementDAO;
 import org.apache.syncope.core.persistence.dao.NotFoundException;
 import org.apache.syncope.core.persistence.dao.PolicyDAO;
 import org.apache.syncope.core.persistence.dao.RoleDAO;
 import org.apache.syncope.core.persistence.dao.SchemaDAO;
+import org.apache.syncope.core.persistence.dao.SubjectSearchDAO;
 import org.apache.syncope.core.persistence.dao.UserDAO;
+import org.apache.syncope.core.persistence.dao.search.AttributeCond;
 import org.apache.syncope.core.persistence.dao.search.OrderByClause;
+import org.apache.syncope.core.persistence.dao.search.SearchCond;
+import org.apache.syncope.core.persistence.dao.search.SubjectCond;
 import org.apache.syncope.core.persistence.validation.attrvalue.ParsingValidationException;
 import org.apache.syncope.core.propagation.PropagationByResource;
 import org.apache.syncope.core.propagation.PropagationException;
 import org.apache.syncope.core.propagation.PropagationTaskExecutor;
 import org.apache.syncope.core.propagation.impl.PropagationManager;
-import org.apache.syncope.core.rest.controller.AbstractAttributableController;
+import org.apache.syncope.core.rest.controller.AbstractSubjectController;
 import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
 import org.apache.syncope.core.rest.data.AttributableTransformer;
 import org.apache.syncope.core.sync.SyncActions;
-import org.apache.syncope.core.sync.SyncResult;
 import org.apache.syncope.core.sync.SyncCorrelationRule;
+import org.apache.syncope.core.sync.SyncResult;
 import org.apache.syncope.core.util.AttributableUtil;
 import org.apache.syncope.core.util.EntitlementUtil;
 import org.apache.syncope.core.workflow.WorkflowResult;
@@ -126,7 +126,7 @@ public class SyncopeSyncResultHandler ex
      * Search DAO.
      */
     @Autowired
-    protected AttributableSearchDAO searchDAO;
+    protected SubjectSearchDAO searchDAO;
 
     /**
      * Propagation Manager.
@@ -181,9 +181,9 @@ public class SyncopeSyncResultHandler ex
                     }
                 }
 
-                List<AbstractAttributable> subjects =
+                List<AbstractSubject> subjects =
                         userDAO.findByAttrValue(accountIdItem.getIntAttrName(), value, attrUtil);
-                for (AbstractAttributable subject : subjects) {
+                for (AbstractSubject subject : subjects) {
                     result.add(subject.getId());
                 }
                 break;
@@ -191,7 +191,7 @@ public class SyncopeSyncResultHandler ex
             case UserDerivedSchema:
             case RoleDerivedSchema:
                 subjects = userDAO.findByDerAttrValue(accountIdItem.getIntAttrName(), uid, attrUtil);
-                for (AbstractAttributable subject : subjects) {
+                for (AbstractSubject subject : subjects) {
                     result.add(subject.getId());
                 }
                 break;
@@ -231,13 +231,13 @@ public class SyncopeSyncResultHandler ex
         return result;
     }
 
-    protected List<Long> search(final SearchCond searchCond, final AttributableUtil attrUtil) {
+    protected List<Long> search(final SearchCond searchCond, final SubjectType type) {
         final List<Long> result = new ArrayList<Long>();
 
-        final List<AbstractAttributable> subjects = searchDAO.search(
+        final List<AbstractSubject> subjects = searchDAO.search(
                 EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
-                searchCond, Collections.<OrderByClause>emptyList(), attrUtil);
-        for (AbstractAttributable subject : subjects) {
+                searchCond, Collections.<OrderByClause>emptyList(), type);
+        for (AbstractSubject subject : subjects) {
             result.add(subject.getId());
         }
 
@@ -245,9 +245,9 @@ public class SyncopeSyncResultHandler ex
     }
 
     protected List<Long> findByCorrelationRule(
-            final ConnectorObject connObj, final SyncCorrelationRule rule, final AttributableUtil attrUtil) {
+            final ConnectorObject connObj, final SyncCorrelationRule rule, final SubjectType type) {
 
-        return search(rule.getSearchCond(connObj), attrUtil);
+        return search(rule.getSearchCond(connObj), type);
     }
 
     protected List<Long> findByAttributableSearch(
@@ -287,7 +287,7 @@ public class SyncopeSyncResultHandler ex
             if ("id".equalsIgnoreCase(schema) || "username".equalsIgnoreCase(schema)
                     || "name".equalsIgnoreCase(schema)) {
 
-                AttributableCond cond = new AttributableCond();
+                SubjectCond cond = new SubjectCond();
                 cond.setSchema(schema);
                 cond.setType(type);
                 cond.setExpression(expression);
@@ -307,7 +307,7 @@ public class SyncopeSyncResultHandler ex
                     : SearchCond.getAndCond(searchCond, nodeCond);
         }
 
-        return search(searchCond, attrUtil);
+        return search(searchCond, SubjectType.valueOf(attrUtil.getType().name()));
     }
 
     /**
@@ -342,7 +342,7 @@ public class SyncopeSyncResultHandler ex
         return syncRule == null ? altSearchSchemas == null || altSearchSchemas.isEmpty()
                 ? findByAccountIdItem(uid, attrUtil)
                 : findByAttributableSearch(connObj, altSearchSchemas, attrUtil)
-                : findByCorrelationRule(connObj, syncRule, attrUtil);
+                : findByCorrelationRule(connObj, syncRule, SubjectType.valueOf(attrUtil.getType().name()));
     }
 
     public Long findMatchingAttributableId(final ObjectClass objectClass, final String name) {
@@ -410,7 +410,7 @@ public class SyncopeSyncResultHandler ex
             final SyncDelta delta, final AttributableUtil attrUtil, final boolean dryRun)
             throws JobExecutionException {
 
-        final AbstractAttributableTO subjectTO =
+        final AbstractSubjectTO subjectTO =
                 connObjectUtil.getSubjectTO(delta.getObject(), syncTask, attrUtil);
 
         SyncDelta _delta = delta;
@@ -422,7 +422,7 @@ public class SyncopeSyncResultHandler ex
     }
 
     private List<SyncResult> create(
-            final AbstractAttributableTO subjectTO,
+            final AbstractSubjectTO subjectTO,
             final SyncDelta delta,
             final AttributableUtil attrUtil,
             final String operation,
@@ -440,7 +440,7 @@ public class SyncopeSyncResultHandler ex
         result.setStatus(SyncResult.Status.SUCCESS);
 
         // Attributable transformation (if configured)
-        AbstractAttributableTO actual = attrTransformer.transform(subjectTO);
+        AbstractSubjectTO actual = attrTransformer.transform(subjectTO);
         LOG.debug("Transformed: {}", actual);
 
         if (dryRun) {
@@ -668,7 +668,7 @@ public class SyncopeSyncResultHandler ex
             LOG.debug("About to update {}", id);
 
             Object output;
-            AbstractAttributableTO before = null;
+            AbstractSubjectTO before = null;
             Result resultStatus;
 
             final SyncResult result = new SyncResult();
@@ -678,7 +678,7 @@ public class SyncopeSyncResultHandler ex
             result.setId(id);
 
             try {
-                final AbstractAttributableTO updated;
+                final AbstractSubjectTO updated;
                 if (AttributableType.USER == attrUtil.getType()) {
                     final Map.Entry<UserTO, UserTO> res = updateUser(id, delta, dryRun, result);
                     before = res.getKey();
@@ -754,7 +754,7 @@ public class SyncopeSyncResultHandler ex
 
         final List<SyncResult> updResults = new ArrayList<SyncResult>();
 
-        final AbstractAttributableController<?, ?> controller;
+        final AbstractSubjectController<?, ?> controller;
         if (AttributableType.USER == attrUtil.getType()) {
             controller = userController;
         } else {
@@ -773,7 +773,7 @@ public class SyncopeSyncResultHandler ex
             result.setStatus(SyncResult.Status.SUCCESS);
             result.setId(id);
 
-            final AbstractAttributableTO before = controller.read(id);
+            final AbstractSubjectTO before = controller.read(id);
             result.setName(before instanceof UserTO ? UserTO.class.cast(before).getUsername()
                     : before instanceof RoleTO ? RoleTO.class.cast(before).getName() : null);
 
@@ -794,7 +794,7 @@ public class SyncopeSyncResultHandler ex
 
                     output = controller.read(id);
                     for (SyncActions action : actions) {
-                        action.after(this, delta, AbstractAttributableTO.class.cast(output), result);
+                        action.after(this, delta, AbstractSubjectTO.class.cast(output), result);
                     }
                 } else {
                     output = before;
@@ -861,7 +861,7 @@ public class SyncopeSyncResultHandler ex
 
         final List<SyncResult> updResults = new ArrayList<SyncResult>();
 
-        final AbstractAttributableController<?, ?> controller;
+        final AbstractSubjectController<?, ?> controller;
         if (AttributableType.USER == attrUtil.getType()) {
             controller = userController;
         } else {
@@ -880,7 +880,7 @@ public class SyncopeSyncResultHandler ex
             result.setStatus(SyncResult.Status.SUCCESS);
             result.setId(id);
 
-            final AbstractAttributableTO before = controller.read(id);
+            final AbstractSubjectTO before = controller.read(id);
             result.setName(before instanceof UserTO ? UserTO.class.cast(before).getUsername()
                     : before instanceof RoleTO ? RoleTO.class.cast(before).getName() : null);
 
@@ -900,7 +900,7 @@ public class SyncopeSyncResultHandler ex
 
                     output = controller.read(id);
                     for (SyncActions action : actions) {
-                        action.after(this, delta, AbstractAttributableTO.class.cast(output), result);
+                        action.after(this, delta, AbstractSubjectTO.class.cast(output), result);
                     }
                 } else {
                     output = before;
@@ -967,7 +967,7 @@ public class SyncopeSyncResultHandler ex
             Object output = null;
             Result resultStatus = Result.FAILURE;
 
-            AbstractAttributableTO before = null;
+            AbstractSubjectTO before = null;
 
             try {
                 before = AttributableType.USER == attrUtil.getType()
@@ -1059,7 +1059,7 @@ public class SyncopeSyncResultHandler ex
     }
 
     /**
-     * Look into SyncDelta and take necessary actions (create / update / delete) on user(s).
+     * Look into SyncDelta and take necessary actions (create / update / delete) on user(s) / role(s).
      *
      * @param delta returned by the underlying connector
      * @throws JobExecutionException in case of synchronization failure.

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java Tue Jun 24 13:25:18 2014
@@ -24,13 +24,13 @@ import java.util.List;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.to.AbstractAttributableTO;
 import org.apache.syncope.common.to.AbstractSubjectTO;
+import org.apache.syncope.common.to.ConfTO;
 import org.apache.syncope.common.to.MembershipTO;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.IntMappingType;
 import org.apache.syncope.common.types.MappingPurpose;
-import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.common.types.SyncPolicySpec;
 import org.apache.syncope.core.persistence.beans.AbstractAttr;
 import org.apache.syncope.core.persistence.beans.AbstractAttrTemplate;
@@ -43,6 +43,11 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
 import org.apache.syncope.core.persistence.beans.AbstractVirSchema;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
+import org.apache.syncope.core.persistence.beans.conf.CAttr;
+import org.apache.syncope.core.persistence.beans.conf.CAttrUniqueValue;
+import org.apache.syncope.core.persistence.beans.conf.CAttrValue;
+import org.apache.syncope.core.persistence.beans.conf.CSchema;
+import org.apache.syncope.core.persistence.beans.conf.SyncopeConf;
 import org.apache.syncope.core.persistence.beans.membership.MAttr;
 import org.apache.syncope.core.persistence.beans.membership.MAttrTemplate;
 import org.apache.syncope.core.persistence.beans.membership.MAttrUniqueValue;
@@ -128,6 +133,9 @@ public final class AttributableUtil {
         if (attributable instanceof Membership) {
             type = AttributableType.MEMBERSHIP;
         }
+        if (attributable instanceof SyncopeConf) {
+            type = AttributableType.CONFIGURATION;
+        }
 
         if (type == null) {
             throw new IllegalArgumentException("Attributable type not supported: " + attributable.getClass().getName());
@@ -152,6 +160,9 @@ public final class AttributableUtil {
                 result = Membership.class;
                 break;
 
+            case CONFIGURATION:
+                result = SyncopeConf.class;
+
             case USER:
             default:
                 result = SyncopeUser.class;
@@ -180,6 +191,7 @@ public final class AttributableUtil {
                     }
                     break;
                 case MEMBERSHIP:
+                case CONFIGURATION:
                 default:
             }
         }
@@ -278,7 +290,7 @@ public final class AttributableUtil {
     }
 
     public <T extends AbstractMappingItem> Class<T> mappingItemClass() {
-        Class result;
+        Class result = null;
 
         switch (type) {
             case USER:
@@ -288,15 +300,16 @@ public final class AttributableUtil {
                 result = RMappingItem.class;
                 break;
             case MEMBERSHIP:
-            default:
                 result = AbstractMappingItem.class;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
     }
 
     public IntMappingType intMappingType() {
-        IntMappingType result;
+        IntMappingType result = null;
 
         switch (type) {
             case ROLE:
@@ -306,16 +319,17 @@ public final class AttributableUtil {
                 result = IntMappingType.MembershipSchema;
                 break;
             case USER:
-            default:
                 result = IntMappingType.UserSchema;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
     }
 
     public IntMappingType derIntMappingType() {
-        IntMappingType result;
+        IntMappingType result = null;
 
         switch (type) {
             case ROLE:
@@ -325,16 +339,17 @@ public final class AttributableUtil {
                 result = IntMappingType.MembershipDerivedSchema;
                 break;
             case USER:
-            default:
                 result = IntMappingType.UserDerivedSchema;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
     }
 
     public IntMappingType virIntMappingType() {
-        IntMappingType result;
+        IntMappingType result = null;
 
         switch (type) {
             case ROLE:
@@ -344,9 +359,10 @@ public final class AttributableUtil {
                 result = IntMappingType.MembershipVirtualSchema;
                 break;
             case USER:
-            default:
                 result = IntMappingType.UserVirtualSchema;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -365,6 +381,10 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MSchema.class;
                 break;
+            case CONFIGURATION:
+                result = CSchema.class;
+                break;
+            default:
         }
 
         return result;
@@ -385,6 +405,12 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = (T) new MSchema();
                 break;
+
+            case CONFIGURATION:
+                result = (T) new CSchema();
+                break;
+
+            default:
         }
 
         return result;
@@ -403,6 +429,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MDerSchema.class;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -421,6 +449,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MVirSchema.class;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -439,6 +469,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = (T) new MDerSchema();
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -457,6 +489,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MAttrTemplate.class;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -475,6 +509,9 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MAttr.class;
                 break;
+            case CONFIGURATION:
+                result = CAttr.class;
+            default:
         }
 
         return result;
@@ -493,6 +530,9 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = (T) new MAttr();
                 break;
+            case CONFIGURATION:
+                result = (T) new CAttr();
+            default:
         }
 
         return result;
@@ -511,6 +551,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MDerAttrTemplate.class;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -529,6 +571,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MDerAttr.class;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -547,6 +591,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MVirAttrTemplate.class;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -565,6 +611,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MVirAttr.class;
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -583,6 +631,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = (T) new MDerAttr();
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -601,6 +651,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = (T) new MVirAttr();
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -619,6 +671,8 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = (T) new MVirSchema();
                 break;
+            case CONFIGURATION:
+            default:
         }
 
         return result;
@@ -637,6 +691,10 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MAttrValue.class;
                 break;
+            case CONFIGURATION:
+                result = CAttrValue.class;
+                break;
+            default:
         }
 
         return result;
@@ -655,6 +713,10 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = (T) new MAttrValue();
                 break;
+            case CONFIGURATION:
+                result = (T) new CAttrValue();
+                break;
+            default:
         }
 
         return result;
@@ -673,6 +735,10 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = MAttrUniqueValue.class;
                 break;
+            case CONFIGURATION:
+                result = CAttrUniqueValue.class;
+                break;
+            default:
         }
 
         return result;
@@ -691,6 +757,10 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = (T) new MAttrUniqueValue();
                 break;
+            case CONFIGURATION:
+                result = (T) new CAttrUniqueValue();
+                break;
+            default:
         }
 
         return result;
@@ -707,6 +777,7 @@ public final class AttributableUtil {
                 result = policySpec.getrAltSearchSchemas();
                 break;
             case MEMBERSHIP:
+            case CONFIGURATION:
             default:
         }
 
@@ -724,6 +795,7 @@ public final class AttributableUtil {
                 clazz = policySpec.getRoleJavaRule();
                 break;
             case MEMBERSHIP:
+            case CONFIGURATION:
             default:
                 clazz = null;
         }
@@ -754,6 +826,10 @@ public final class AttributableUtil {
             case MEMBERSHIP:
                 result = (T) new MembershipTO();
                 break;
+            case CONFIGURATION:
+                result = (T) new ConfTO();
+                break;
+            default:
         }
 
         return result;
@@ -770,6 +846,8 @@ public final class AttributableUtil {
                 result = (T) new RoleTO();
                 break;
             case MEMBERSHIP:
+            case CONFIGURATION:
+            default:
                 break;
         }
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/MappingUtil.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/MappingUtil.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/MappingUtil.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/MappingUtil.java Tue Jun 24 13:25:18 2014
@@ -43,6 +43,7 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
 import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
 import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
+import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
 import org.apache.syncope.core.persistence.beans.AbstractVirSchema;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
@@ -139,7 +140,7 @@ public final class MappingUtil {
      * @param resource target resource
      * @return account link + prepared attributes
      */
-    public static <T extends AbstractAttributable> Map.Entry<String, Set<Attribute>> prepareAttributes(
+    public static <T extends AbstractSubject> Map.Entry<String, Set<Attribute>> prepareAttributes(
             final AttributableUtil attrUtil, final T subject, final String password, final boolean changePwd,
             final Set<String> vAttrsToBeRemoved, final Map<String, AttributeMod> vAttrsToBeUpdated,
             final Set<String> membVAttrsToBeRemoved, final Map<String, AttributeMod> membVAttrsToBeUpdated,
@@ -640,7 +641,6 @@ public final class MappingUtil {
      * @param attributable attributable
      * @param accountIdItem accountId mapping item
      * @param resource external resource
-     * @param accountIdItem accountid mapping item
      * @return accountId internal value
      */
     public static String getAccountIdValue(final AbstractAttributable attributable, final ExternalResource resource,

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/task/GenerateToken.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/task/GenerateToken.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/task/GenerateToken.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/task/GenerateToken.java Tue Jun 24 13:25:18 2014
@@ -36,8 +36,8 @@ public class GenerateToken extends Abstr
                 (SyncopeUser) runtimeService.getVariable(executionId, ActivitiUserWorkflowAdapter.SYNCOPE_USER);
 
         user.generateToken(
-                Integer.parseInt(confDAO.find("token.length", "256").getValue()),
-                Integer.parseInt(confDAO.find("token.expireTime", "60").getValue()));
+                confDAO.find("token.length", "256").getValues().get(0).getLongValue().intValue(),
+                confDAO.find("token.expireTime", "60").getValues().get(0).getLongValue().intValue());
 
         runtimeService.setVariable(executionId, ActivitiUserWorkflowAdapter.SYNCOPE_USER, user);
     }

Modified: syncope/trunk/core/src/main/resources/META-INF/orm.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/META-INF/orm.xml?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/META-INF/orm.xml (original)
+++ syncope/trunk/core/src/main/resources/META-INF/orm.xml Tue Jun 24 13:25:18 2014
@@ -37,6 +37,7 @@ under the License.
   <table-generator name="SEQ_UAttrValue" pk-column-value="SEQ_UAttrValue" initial-value="100"/>
   <table-generator name="SEQ_RAttrValue" pk-column-value="SEQ_RAttrValue" initial-value="100"/>
   <table-generator name="SEQ_MAttrValue" pk-column-value="SEQ_MAttrValue" initial-value="100"/>
+  <table-generator name="SEQ_CAttrValue" pk-column-value="SEQ_CAttrValue" initial-value="100"/>
 
   <entity class="org.apache.syncope.core.persistence.beans.user.SyncopeUser">
     <attributes>
@@ -131,6 +132,14 @@ under the License.
       </id>
     </attributes>
   </entity>
+  <entity class="org.apache.syncope.core.persistence.beans.conf.CAttr">
+    <attributes>
+      <id name="id">
+        <generated-value generator="SEQ_CAttr" strategy="TABLE"/>
+        <table-generator name="SEQ_CAttr" pk-column-value="SEQ_CAttr" initial-value="1000"/>
+      </id>
+    </attributes>
+  </entity>
     
   <entity class="org.apache.syncope.core.persistence.beans.user.UAttrValue">
     <attributes>
@@ -240,6 +249,42 @@ under the License.
       </id>
     </attributes>
   </entity>
+  <entity class="org.apache.syncope.core.persistence.beans.conf.CAttrValue">
+    <attributes>
+      <id name="id">
+        <generated-value generator="SEQ_CAttrValue" strategy="TABLE"/>
+      </id>
+    </attributes>
+  </entity>
+  <entity class="org.apache.syncope.core.persistence.beans.conf.CAttrUniqueValue">
+    <table>
+      <unique-constraint>
+        <column-name>booleanValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+      <unique-constraint>
+        <column-name>dateValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+      <unique-constraint>
+        <column-name>stringValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+      <unique-constraint>
+        <column-name>doubleValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+      <unique-constraint>
+        <column-name>longValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+    </table>
+    <attributes>
+      <id name="id">
+        <generated-value generator="SEQ_CAttrValue" strategy="TABLE"/>
+      </id>
+    </attributes>
+  </entity>
 
   <entity class="org.apache.syncope.core.persistence.beans.Task">
     <attributes>

Modified: syncope/trunk/core/src/main/resources/META-INF/orm.xml.oracle
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/META-INF/orm.xml.oracle?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/META-INF/orm.xml.oracle (original)
+++ syncope/trunk/core/src/main/resources/META-INF/orm.xml.oracle Tue Jun 24 13:25:18 2014
@@ -38,6 +38,7 @@ under the License.
   <table-generator name="SEQ_UAttrValue" pk-column-value="SEQ_UAttrValue" initial-value="100"/>
   <table-generator name="SEQ_RAttrValue" pk-column-value="SEQ_RAttrValue" initial-value="100"/>
   <table-generator name="SEQ_MAttrValue" pk-column-value="SEQ_MAttrValue" initial-value="100"/>
+  <table-generator name="SEQ_CAttrValue" pk-column-value="SEQ_CAttrValue" initial-value="100"/>
 
   <entity class="org.apache.syncope.core.persistence.beans.user.SyncopeUser">
     <attributes>
@@ -132,6 +133,14 @@ under the License.
       </id>
     </attributes>
   </entity>
+  <entity class="org.apache.syncope.core.persistence.beans.conf.CAttr">
+    <attributes>
+      <id name="id">
+        <generated-value generator="SEQ_CAttr" strategy="TABLE"/>
+        <table-generator name="SEQ_CAttr" pk-column-value="SEQ_CAttr" initial-value="1000"/>
+      </id>
+    </attributes>
+  </entity>
 
   <entity class="org.apache.syncope.core.persistence.beans.user.UAttrValue">
     <attributes>
@@ -205,6 +214,30 @@ under the License.
       </id>
     </attributes>
   </entity>
+  <entity class="org.apache.syncope.core.persistence.beans.membership.CAttrValue">
+    <attributes>
+      <id name="id">
+        <generated-value generator="SEQ_CAttrValue" strategy="TABLE"/>
+      </id>
+    </attributes>
+  </entity>
+  <entity class="org.apache.syncope.core.persistence.beans.conf.CAttrUniqueValue">
+    <table>
+      <unique-constraint>
+        <column-name>booleanValue</column-name>
+        <column-name>dateValue</column-name>
+        <column-name>stringValue</column-name>
+        <column-name>doubleValue</column-name>
+        <column-name>longValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+    </table>
+    <attributes>
+      <id name="id">
+        <generated-value generator="SEQ_CAttrValue" strategy="TABLE"/>
+      </id>
+    </attributes>
+  </entity>
 
   <entity class="org.apache.syncope.core.persistence.beans.Task">
     <attributes>

Modified: syncope/trunk/core/src/main/resources/META-INF/orm.xml.sqlserver
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/META-INF/orm.xml.sqlserver?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/META-INF/orm.xml.sqlserver (original)
+++ syncope/trunk/core/src/main/resources/META-INF/orm.xml.sqlserver Tue Jun 24 13:25:18 2014
@@ -38,6 +38,7 @@ under the License.
   <table-generator name="SEQ_UAttrValue" pk-column-value="SEQ_UAttrValue" initial-value="100"/>
   <table-generator name="SEQ_RAttrValue" pk-column-value="SEQ_RAttrValue" initial-value="100"/>
   <table-generator name="SEQ_MAttrValue" pk-column-value="SEQ_MAttrValue" initial-value="100"/>
+  <table-generator name="SEQ_CAttrValue" pk-column-value="SEQ_CAttrValue" initial-value="100"/>
 
   <entity class="org.apache.syncope.core.persistence.beans.user.SyncopeUser">
     <attributes>
@@ -132,7 +133,15 @@ under the License.
       </id>
     </attributes>
   </entity>
-    
+  <entity class="org.apache.syncope.core.persistence.beans.conf.CAttr">
+    <attributes>
+      <id name="id">
+        <generated-value generator="SEQ_CAttr" strategy="TABLE"/>
+        <table-generator name="SEQ_CAttr" pk-column-value="SEQ_CAttr" initial-value="1000"/>
+      </id>
+    </attributes>
+  </entity>
+      
   <entity class="org.apache.syncope.core.persistence.beans.user.UAttrValue">
     <attributes>
       <id name="id">
@@ -229,6 +238,42 @@ under the License.
       </id>
     </attributes>
   </entity>
+  <entity class="org.apache.syncope.core.persistence.beans.conf.CAttrValue">
+    <attributes>
+      <id name="id">
+        <generated-value generator="SEQ_CAttrValue" strategy="TABLE"/>
+      </id>
+    </attributes>
+  </entity>
+  <entity class="org.apache.syncope.core.persistence.beans.conf.CAttrUniqueValue">
+    <table>
+      <unique-constraint>
+        <column-name>booleanValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+      <unique-constraint>
+        <column-name>dateValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+      <unique-constraint>
+        <column-name>stringValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+      <unique-constraint>
+        <column-name>doubleValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+      <unique-constraint>
+        <column-name>longValue</column-name>
+        <column-name>schema_name</column-name>
+      </unique-constraint>
+    </table>
+    <attributes>
+      <id name="id">
+        <generated-value generator="SEQ_CAttrValue" strategy="TABLE"/>
+      </id>
+    </attributes>
+  </entity>
 
   <entity class="org.apache.syncope.core.persistence.beans.Task">
     <attributes>

Modified: syncope/trunk/core/src/main/resources/content.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/content.xml?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/content.xml (original)
+++ syncope/trunk/core/src/main/resources/content.xml Tue Jun 24 13:25:18 2014
@@ -18,20 +18,54 @@ specific language governing permissions 
 under the License.
 -->
 <dataset>
-  <SyncopeConf confKey="password.cipher.algorithm" confValue="SHA1"/>
+  <SyncopeConf id="1" 
+               creator="admin" lastModifier="admin"
+               creationDate="2014-06-20 11:00:00" lastChangeDate="2014-06-20 11:00:00"/>
+
+  <CSchema name="password.cipher.algorithm" type="String"
+           mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+  <CAttr id="1" owner_id="1" schema_name="password.cipher.algorithm"/>
+  <CAttrValue id="1" attribute_id="1" stringValue="SHA1"/>
+
   <!-- notificationjob.cronExpression:
   + not existing: NotificationJob runs according to Notification.DEFAULT_CRON_EXP
   + provided as empty string: NotificationJob disabled
   + provided as non-empty string: NotificationJob runs according to the given value -->
-  <SyncopeConf confKey="notificationjob.cronExpression" confValue=""/>
-  <SyncopeConf confKey="notification.maxRetries" confValue="0"/>
-  <SyncopeConf confKey="token.length" confValue="256"/>
-  <SyncopeConf confKey="token.expireTime" confValue="60"/>
-  <SyncopeConf confKey="selfRegistration.allowed" confValue="true"/>
-  <!-- when needing to provide more values, use '|' as separator and no spaces -->
-  <SyncopeConf confKey="authentication.statuses" confValue="active"/>
+  <CSchema name="notificationjob.cronExpression" type="String"
+           mandatoryCondition="false" multivalue="0" uniqueConstraint="0" readonly="0"/>
+  <CAttr id="2" owner_id="1" schema_name="notificationjob.cronExpression"/>
+  <CAttrValue id="2" attribute_id="2" stringValue=""/>
+
+  <CSchema name="notification.maxRetries" type="Long"
+           mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+  <CAttr id="3" owner_id="1" schema_name="notification.maxRetries"/>
+  <CAttrValue id="3" attribute_id="3" longValue="0"/>
+
+  <CSchema name="token.length" type="Long"
+           mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+  <CAttr id="4" owner_id="1" schema_name="token.length"/>
+  <CAttrValue id="4" attribute_id="4" longValue="256"/>
+
+  <CSchema name="token.expireTime" type="Long"
+           mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+  <CAttr id="5" owner_id="1" schema_name="token.expireTime"/>
+  <CAttrValue id="5" attribute_id="5" longValue="60"/>
+
+  <CSchema name="selfRegistration.allowed" type="Boolean"
+           mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+  <CAttr id="6" owner_id="1" schema_name="selfRegistration.allowed"/>
+  <CAttrValue id="6" attribute_id="6" booleanValue="1"/>
+
+  <CSchema name="authentication.statuses" type="String"
+           mandatoryCondition="true" multivalue="1" uniqueConstraint="0" readonly="0"/>
+  <CAttr id="7" owner_id="1" schema_name="authentication.statuses"/>
+  <CAttrValue id="7" attribute_id="7" stringValue="active"/>
+
   <!-- Save user login date upon successful authentication -->
-  <SyncopeConf confKey="log.lastlogindate" confValue="true"/>
+  <CSchema name="log.lastlogindate" type="Boolean"
+           mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
+  <CAttr id="10" owner_id="1" schema_name="log.lastlogindate"/>
+  <CAttrValue id="10" attribute_id="10" booleanValue="1"/>
     
   <!-- Authentication and authorization -->
   <Entitlement name="SCHEMA_LIST"/>
@@ -62,10 +96,10 @@ under the License.
   <Entitlement name="CONNECTOR_UPDATE"/>
   <Entitlement name="CONNECTOR_DELETE"/>
   <Entitlement name="CONNECTOR_RELOAD"/>
+  <Entitlement name="CONFIGURATION_EXPORT"/>
   <Entitlement name="CONFIGURATION_LIST"/>
-  <Entitlement name="CONFIGURATION_CREATE"/>
   <Entitlement name="CONFIGURATION_READ"/>
-  <Entitlement name="CONFIGURATION_UPDATE"/>
+  <Entitlement name="CONFIGURATION_SET"/>
   <Entitlement name="CONFIGURATION_DELETE"/>
   <Entitlement name="TASK_LIST"/>
   <Entitlement name="TASK_CREATE"/>

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java Tue Jun 24 13:25:18 2014
@@ -19,17 +19,15 @@
 package org.apache.syncope.core.notification;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import com.icegreen.greenmail.util.GreenMail;
 import com.icegreen.greenmail.util.ServerSetup;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
 import java.util.Set;
-
 import javax.annotation.Resource;
 import javax.mail.Flags.Flag;
 import javax.mail.Folder;
@@ -43,12 +41,13 @@ import org.apache.syncope.common.to.Memb
 import org.apache.syncope.common.to.NotificationTaskTO;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.to.UserTO;
+import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.IntMappingType;
 import org.apache.syncope.common.types.TraceLevel;
 import org.apache.syncope.core.persistence.beans.Entitlement;
 import org.apache.syncope.core.persistence.beans.Notification;
 import org.apache.syncope.core.persistence.beans.NotificationTask;
-import org.apache.syncope.core.persistence.beans.SyncopeConf;
+import org.apache.syncope.core.persistence.beans.conf.CAttr;
 import org.apache.syncope.core.persistence.dao.ConfDAO;
 import org.apache.syncope.core.persistence.dao.EntitlementDAO;
 import org.apache.syncope.core.persistence.dao.NotificationDAO;
@@ -57,6 +56,7 @@ import org.apache.syncope.core.rest.User
 import org.apache.syncope.core.rest.controller.RoleController;
 import org.apache.syncope.core.rest.controller.TaskController;
 import org.apache.syncope.core.rest.controller.UserController;
+import org.apache.syncope.core.util.AttributableUtil;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -402,9 +402,10 @@ public class NotificationTest {
         userController.create(userTO);
 
         // 3. Set number of retries
-        SyncopeConf retryConf = confDAO.find("notification.maxRetries");
-        retryConf.setValue("5");
-        confDAO.save(retryConf);
+        CAttr maxRetries = confDAO.find("notification.maxRetries", "5");
+        maxRetries.getValues().clear();
+        maxRetries.addValue("5", AttributableUtil.getInstance(AttributableType.CONFIGURATION));
+        confDAO.save(maxRetries);
         confDAO.flush();
 
         // 4. Stop mail server to force error sending mail
@@ -430,8 +431,10 @@ public class NotificationTest {
         startGreenMail();
 
         // 8. reset number of retries
-        retryConf.setValue("0");
-        confDAO.save(retryConf);
+        maxRetries = confDAO.find("notification.maxRetries", "5");
+        maxRetries.getValues().clear();
+        maxRetries.addValue("0", AttributableUtil.getInstance(AttributableType.CONFIGURATION));
+        confDAO.save(maxRetries);
         confDAO.flush();
     }
 

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/AttributableSearchTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/AttributableSearchTest.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/AttributableSearchTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/AttributableSearchTest.java Tue Jun 24 13:25:18 2014
@@ -28,17 +28,15 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-
-import org.apache.syncope.core.persistence.dao.search.AttributableCond;
-import org.apache.syncope.core.persistence.dao.search.AttributeCond;
-import org.apache.syncope.core.persistence.dao.search.MembershipCond;
-import org.apache.syncope.core.persistence.dao.search.SearchCond;
-import org.apache.syncope.core.persistence.dao.search.ResourceCond;
-import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
+import org.apache.syncope.core.persistence.dao.search.AttributeCond;
+import org.apache.syncope.core.persistence.dao.search.MembershipCond;
 import org.apache.syncope.core.persistence.dao.search.OrderByClause;
-import org.apache.syncope.core.util.AttributableUtil;
+import org.apache.syncope.core.persistence.dao.search.ResourceCond;
+import org.apache.syncope.core.persistence.dao.search.SearchCond;
+import org.apache.syncope.core.persistence.dao.search.SubjectCond;
 import org.apache.syncope.core.util.EntitlementUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -59,7 +57,7 @@ public class AttributableSearchTest {
     private RoleDAO roleDAO;
 
     @Autowired
-    private AttributableSearchDAO searchDAO;
+    private SubjectSearchDAO searchDAO;
 
     @Autowired
     private EntitlementDAO entitlementDAO;
@@ -72,13 +70,11 @@ public class AttributableSearchTest {
         MembershipCond membershipCond = new MembershipCond();
         membershipCond.setRoleId(5L);
 
-        assertFalse(searchDAO.matches(user, SearchCond.getLeafCond(membershipCond),
-                AttributableUtil.getInstance(AttributableType.USER)));
+        assertFalse(searchDAO.matches(user, SearchCond.getLeafCond(membershipCond), SubjectType.USER));
 
         membershipCond.setRoleId(1L);
 
-        assertTrue(searchDAO.matches(user, SearchCond.getLeafCond(membershipCond),
-                AttributableUtil.getInstance(AttributableType.USER)));
+        assertTrue(searchDAO.matches(user, SearchCond.getLeafCond(membershipCond), SubjectType.USER));
     }
 
     @Test
@@ -90,8 +86,7 @@ public class AttributableSearchTest {
         attrCond.setSchema("show");
         attrCond.setType(AttributeCond.Type.ISNOTNULL);
 
-        assertTrue(searchDAO.matches(role, SearchCond.getLeafCond(attrCond),
-                AttributableUtil.getInstance(AttributableType.ROLE)));
+        assertTrue(searchDAO.matches(role, SearchCond.getLeafCond(attrCond), SubjectType.ROLE));
     }
 
     @Test
@@ -116,8 +111,8 @@ public class AttributableSearchTest {
 
         assertTrue(cond.isValid());
 
-        List<SyncopeUser> users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), cond,
-                AttributableUtil.getInstance(AttributableType.USER));
+        List<SyncopeUser> users =
+                searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), cond, SubjectType.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
     }
@@ -131,8 +126,8 @@ public class AttributableSearchTest {
         SearchCond cond = SearchCond.getNotLeafCond(fullnameLeafCond);
         assertTrue(cond.isValid());
 
-        List<SyncopeUser> users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), cond,
-                AttributableUtil.getInstance(AttributableType.USER));
+        List<SyncopeUser> users =
+                searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), cond, SubjectType.USER);
         assertNotNull(users);
         assertEquals(4, users.size());
 
@@ -153,8 +148,8 @@ public class AttributableSearchTest {
         SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
         assertTrue(cond.isValid());
 
-        List<SyncopeUser> users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), cond,
-                AttributableUtil.getInstance(AttributableType.USER));
+        List<SyncopeUser> users =
+                searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), cond, SubjectType.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
 
@@ -185,13 +180,13 @@ public class AttributableSearchTest {
 
         List<SyncopeUser> users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
                 cond, 1, 2, Collections.<OrderByClause>emptyList(),
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
 
         users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
                 cond, 2, 2, Collections.<OrderByClause>emptyList(),
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
         assertNotNull(users);
         assertTrue(users.isEmpty());
     }
@@ -203,7 +198,7 @@ public class AttributableSearchTest {
 
         List<SyncopeUser> users = searchDAO.search(
                 EntitlementUtil.getRoleIds(entitlementDAO.findAll()), SearchCond.getLeafCond(membershipCond),
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
         assertNotNull(users);
         assertEquals(2, users.size());
 
@@ -212,7 +207,7 @@ public class AttributableSearchTest {
 
         users = searchDAO.search(
                 EntitlementUtil.getRoleIds(entitlementDAO.findAll()), SearchCond.getNotLeafCond(membershipCond),
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
         assertNotNull(users);
         assertEquals(5, users.size());
     }
@@ -224,7 +219,7 @@ public class AttributableSearchTest {
 
         List<SyncopeUser> users = searchDAO.search(
                 EntitlementUtil.getRoleIds(entitlementDAO.findAll()), SearchCond.getLeafCond(coolLeafCond),
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
         assertNotNull(users);
         assertEquals(4, users.size());
 
@@ -233,7 +228,7 @@ public class AttributableSearchTest {
 
         users = searchDAO.search(
                 EntitlementUtil.getRoleIds(entitlementDAO.findAll()), SearchCond.getLeafCond(coolLeafCond),
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
     }
@@ -252,7 +247,7 @@ public class AttributableSearchTest {
 
         List<SyncopeUser> users = searchDAO.search(
                 EntitlementUtil.getRoleIds(entitlementDAO.findAll()), searchCondition,
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
 
         assertNotNull(users);
         assertEquals(1, users.size());
@@ -260,11 +255,11 @@ public class AttributableSearchTest {
 
     @Test
     public void searchByUsernameAndId() {
-        AttributableCond usernameLeafCond = new AttributableCond(AttributableCond.Type.EQ);
+        SubjectCond usernameLeafCond = new SubjectCond(SubjectCond.Type.EQ);
         usernameLeafCond.setSchema("username");
         usernameLeafCond.setExpression("rossini");
 
-        AttributableCond idRightCond = new AttributableCond(AttributableCond.Type.LT);
+        SubjectCond idRightCond = new SubjectCond(SubjectCond.Type.LT);
         idRightCond.setSchema("id");
         idRightCond.setExpression("2");
 
@@ -272,7 +267,7 @@ public class AttributableSearchTest {
                 SearchCond.getLeafCond(idRightCond));
 
         List<SyncopeUser> matchingUsers = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
-                searchCondition, AttributableUtil.getInstance(AttributableType.USER));
+                searchCondition, SubjectType.USER);
 
         assertNotNull(matchingUsers);
         assertEquals(1, matchingUsers.size());
@@ -282,11 +277,11 @@ public class AttributableSearchTest {
 
     @Test
     public void searchByRolenameAndId() {
-        AttributableCond rolenameLeafCond = new AttributableCond(AttributableCond.Type.EQ);
+        SubjectCond rolenameLeafCond = new SubjectCond(SubjectCond.Type.EQ);
         rolenameLeafCond.setSchema("name");
         rolenameLeafCond.setExpression("root");
 
-        AttributableCond idRightCond = new AttributableCond(AttributableCond.Type.LT);
+        SubjectCond idRightCond = new SubjectCond(SubjectCond.Type.LT);
         idRightCond.setSchema("id");
         idRightCond.setExpression("2");
 
@@ -296,7 +291,7 @@ public class AttributableSearchTest {
         assertTrue(searchCondition.isValid());
 
         List<SyncopeRole> matchingRoles = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
-                searchCondition, AttributableUtil.getInstance(AttributableType.ROLE));
+                searchCondition, SubjectType.ROLE);
 
         assertNotNull(matchingRoles);
         assertEquals(1, matchingRoles.size());
@@ -306,7 +301,7 @@ public class AttributableSearchTest {
 
     @Test
     public void searchByUsernameAndFullname() {
-        AttributableCond usernameLeafCond = new AttributableCond(AttributableCond.Type.EQ);
+        SubjectCond usernameLeafCond = new SubjectCond(SubjectCond.Type.EQ);
         usernameLeafCond.setSchema("username");
         usernameLeafCond.setExpression("rossini");
 
@@ -319,7 +314,7 @@ public class AttributableSearchTest {
 
         List<SyncopeUser> matchingUsers =
                 searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), searchCondition,
-                        AttributableUtil.getInstance(AttributableType.USER));
+                        SubjectType.USER);
 
         assertNotNull(matchingUsers);
         assertEquals(2, matchingUsers.size());
@@ -327,7 +322,7 @@ public class AttributableSearchTest {
 
     @Test
     public void searchById() {
-        AttributableCond idLeafCond = new AttributableCond(AttributableCond.Type.LT);
+        SubjectCond idLeafCond = new SubjectCond(SubjectCond.Type.LT);
         idLeafCond.setSchema("id");
         idLeafCond.setExpression("2");
 
@@ -336,13 +331,13 @@ public class AttributableSearchTest {
 
         List<SyncopeUser> users =
                 searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), searchCondition,
-                        AttributableUtil.getInstance(AttributableType.USER));
+                        SubjectType.USER);
 
         assertNotNull(users);
         assertEquals(1, users.size());
         assertEquals(1L, users.iterator().next().getId().longValue());
 
-        idLeafCond = new AttributableCond(AttributableCond.Type.LT);
+        idLeafCond = new SubjectCond(SubjectCond.Type.LT);
         idLeafCond.setSchema("id");
         idLeafCond.setExpression("4");
 
@@ -350,7 +345,7 @@ public class AttributableSearchTest {
         assertTrue(searchCondition.isValid());
 
         users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), searchCondition,
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
 
         assertNotNull(users);
         assertEquals(2, users.size());
@@ -365,7 +360,7 @@ public class AttributableSearchTest {
 
     @Test
     public void userOrderBy() {
-        AttributableCond usernameLeafCond = new AttributableCond(AttributableCond.Type.EQ);
+        SubjectCond usernameLeafCond = new SubjectCond(SubjectCond.Type.EQ);
         usernameLeafCond.setSchema("username");
         usernameLeafCond.setExpression("rossini");
         AttributeCond idRightCond = new AttributeCond(AttributeCond.Type.LIKE);
@@ -386,15 +381,15 @@ public class AttributableSearchTest {
 
         List<SyncopeUser> users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
                 searchCondition, Collections.singletonList(orderByClause),
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
         assertEquals(searchDAO.count(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
-                searchCondition, AttributableUtil.getInstance(AttributableType.USER)),
+                searchCondition, SubjectType.USER),
                 users.size());
     }
 
     @Test
     public void roleOrderBy() {
-        AttributableCond idLeafCond = new AttributableCond(AttributableCond.Type.LIKE);
+        SubjectCond idLeafCond = new SubjectCond(SubjectCond.Type.LIKE);
         idLeafCond.setSchema("name");
         idLeafCond.setExpression("%r");
         SearchCond searchCondition = SearchCond.getLeafCond(idLeafCond);
@@ -405,9 +400,9 @@ public class AttributableSearchTest {
 
         List<SyncopeRole> roles = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
                 searchCondition, Collections.singletonList(orderByClause),
-                AttributableUtil.getInstance(AttributableType.ROLE));
+                SubjectType.ROLE);
         assertEquals(searchDAO.count(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
-                searchCondition, AttributableUtil.getInstance(AttributableType.ROLE)),
+                searchCondition, SubjectType.ROLE),
                 roles.size());
     }
 
@@ -424,7 +419,7 @@ public class AttributableSearchTest {
         assertTrue(searchCondition.isValid());
 
         List<SyncopeUser> users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
-                searchCondition, AttributableUtil.getInstance(AttributableType.USER));
+                searchCondition, SubjectType.USER);
         assertNotNull(users);
         assertEquals(2, users.size());
         boolean found = false;
@@ -438,7 +433,7 @@ public class AttributableSearchTest {
 
     @Test
     public void issue242() {
-        AttributableCond cond = new AttributableCond(AttributeCond.Type.LIKE);
+        SubjectCond cond = new SubjectCond(AttributeCond.Type.LIKE);
         cond.setSchema("id");
         cond.setExpression("test%");
 
@@ -446,14 +441,14 @@ public class AttributableSearchTest {
         assertTrue(searchCondition.isValid());
 
         List<SyncopeUser> users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
-                searchCondition, AttributableUtil.getInstance(AttributableType.USER));
+                searchCondition, SubjectType.USER);
         assertNotNull(users);
         assertTrue(users.isEmpty());
     }
 
     @Test
     public void issueSYNCOPE46() {
-        AttributableCond cond = new AttributableCond(AttributeCond.Type.LIKE);
+        SubjectCond cond = new SubjectCond(AttributeCond.Type.LIKE);
         cond.setSchema("username");
         cond.setExpression("%ossin%");
 
@@ -461,7 +456,7 @@ public class AttributableSearchTest {
         assertTrue(searchCondition.isValid());
 
         List<SyncopeUser> users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()),
-                searchCondition, AttributableUtil.getInstance(AttributableType.USER));
+                searchCondition, SubjectType.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
     }
@@ -471,7 +466,7 @@ public class AttributableSearchTest {
         AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNULL);
         isNullCond.setSchema("loginDate");
 
-        AttributableCond likeCond = new AttributableCond(AttributeCond.Type.LIKE);
+        SubjectCond likeCond = new SubjectCond(AttributeCond.Type.LIKE);
         likeCond.setSchema("username");
         likeCond.setExpression("%ossin%");
 
@@ -479,7 +474,7 @@ public class AttributableSearchTest {
                 SearchCond.getLeafCond(isNullCond), SearchCond.getLeafCond(likeCond));
 
         Integer count = searchDAO.count(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), searchCond,
-                AttributableUtil.getInstance(AttributableType.USER));
+                SubjectType.USER);
         assertNotNull(count);
         assertTrue(count > 0);
     }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/ConfTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/ConfTest.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/ConfTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/ConfTest.java Tue Jun 24 13:25:18 2014
@@ -18,12 +18,19 @@
  */
 package org.apache.syncope.core.persistence.dao;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.AttributeSchemaType;
 import org.apache.syncope.common.types.EntityViolationType;
-import org.apache.syncope.core.persistence.beans.SyncopeConf;
+import org.apache.syncope.core.persistence.beans.conf.CAttr;
+import org.apache.syncope.core.persistence.beans.conf.CSchema;
 import org.apache.syncope.core.persistence.validation.entity.InvalidEntityException;
+import org.apache.syncope.core.util.AttributableUtil;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -34,13 +41,62 @@ public class ConfTest extends AbstractDA
     @Autowired
     private ConfDAO confDAO;
 
+    @Autowired
+    private SchemaDAO schemaDAO;
+
     @Test
-    public void issueSYNCOPE418() {
-        SyncopeConf conf = new SyncopeConf();
-        conf.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
+    public void read() {
+        CAttr conf = confDAO.find("selfRegistration.allowed");
+        assertNotNull(conf);
+        assertTrue(conf.getValues().get(0).getBooleanValue());
+
+        conf = confDAO.find("authentication.statuses");
+        assertNotNull(conf);
+        assertEquals(2, conf.getValues().size());
 
+        conf = confDAO.find("non.existing");
+        assertNull(conf);
+    }
+
+    @Test
+    public void setAndDelete() {
+        // 1. create CSChema
+        CSchema useless = new CSchema();
+        useless.setName("useless");
+        useless.setType(AttributeSchemaType.Date);
+        useless.setConversionPattern("yyyy-MM-dd");
+        useless = schemaDAO.save(useless);
+
+        // 2. create conf
+        CAttr newConf = new CAttr();
+        newConf.setSchema(useless);
+        newConf.addValue("2014-06-20", AttributableUtil.getInstance(AttributableType.CONFIGURATION));
+        confDAO.save(newConf);
+
+        CAttr actual = confDAO.find("useless");
+        assertEquals(actual.getValuesAsStrings(), newConf.getValuesAsStrings());
+
+        // 3. update conf
+        newConf.getValues().clear();
+        newConf.addValue("2014-06-20", AttributableUtil.getInstance(AttributableType.CONFIGURATION));
+        confDAO.save(newConf);
+
+        actual = confDAO.find("useless");
+        assertEquals(actual.getValuesAsStrings(), newConf.getValuesAsStrings());
+
+        // 4. delete conf
+        confDAO.delete("useless");
+        assertNull(confDAO.find("useless"));
+    }
+
+    @Test
+    public void issueSYNCOPE418() {
         try {
-            confDAO.save(conf);
+            CSchema failing = new CSchema();
+            failing.setName("http://schemas.examples.org/security/authorization/organizationUnit");
+            failing.setType(AttributeSchemaType.String);
+            schemaDAO.save(failing);
+
             fail();
         } catch (InvalidEntityException e) {
             assertTrue(e.hasViolation(EntityViolationType.InvalidName));

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/relationships/AttributableSearchTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/relationships/AttributableSearchTest.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/relationships/AttributableSearchTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/relationships/AttributableSearchTest.java Tue Jun 24 13:25:18 2014
@@ -28,13 +28,12 @@ import java.util.Set;
 
 import org.apache.syncope.core.persistence.dao.search.AttributeCond;
 import org.apache.syncope.core.persistence.dao.search.SearchCond;
-import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
-import org.apache.syncope.core.persistence.dao.AttributableSearchDAO;
+import org.apache.syncope.core.persistence.dao.SubjectSearchDAO;
 import org.apache.syncope.core.persistence.dao.EntitlementDAO;
 import org.apache.syncope.core.persistence.dao.RoleDAO;
-import org.apache.syncope.core.util.AttributableUtil;
 import org.apache.syncope.core.util.EntitlementUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -44,8 +43,8 @@ import org.springframework.test.context.
 import org.springframework.transaction.annotation.Transactional;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:syncopeContext.xml", "classpath:persistenceContext.xml",
-    "classpath:schedulingContext.xml", "classpath:workflowContext.xml"})
+@ContextConfiguration(locations = { "classpath:syncopeContext.xml", "classpath:persistenceContext.xml",
+    "classpath:schedulingContext.xml", "classpath:workflowContext.xml" })
 @Transactional
 public class AttributableSearchTest {
 
@@ -53,7 +52,7 @@ public class AttributableSearchTest {
     private RoleDAO roleDAO;
 
     @Autowired
-    private AttributableSearchDAO searchDAO;
+    private SubjectSearchDAO searchDAO;
 
     @Autowired
     private EntitlementDAO entitlementDAO;
@@ -73,8 +72,8 @@ public class AttributableSearchTest {
         final SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
         assertTrue(cond.isValid());
 
-        final List<SyncopeUser> users = searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), cond,
-                AttributableUtil.getInstance(AttributableType.USER));
+        final List<SyncopeUser> users =
+                searchDAO.search(EntitlementUtil.getRoleIds(entitlementDAO.findAll()), cond, SubjectType.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
 

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java?rev=1605077&r1=1605076&r2=1605077&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java Tue Jun 24 13:25:18 2014
@@ -27,19 +27,20 @@ import static org.junit.Assert.fail;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
-import java.util.List;
 import javax.ws.rs.core.HttpHeaders;
-
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-
 import org.apache.commons.io.IOUtils;
 import org.apache.syncope.common.SyncopeConstants;
-import org.apache.syncope.common.services.ConfigurationService;
-import org.apache.syncope.common.to.ConfigurationTO;
+import org.apache.syncope.common.to.ConfTO;
 import org.apache.syncope.common.types.EntityViolationType;
-import org.apache.syncope.common.types.ClientExceptionType;
 import org.apache.syncope.common.SyncopeClientException;
+import org.apache.syncope.common.to.AttributeTO;
+import org.apache.syncope.common.to.SchemaTO;
+import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.AttributeSchemaType;
+import org.apache.syncope.common.types.ClientExceptionType;
+import org.apache.syncope.common.types.SchemaType;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
@@ -49,16 +50,19 @@ public class ConfigurationTestITCase ext
 
     @Test
     public void create() {
-        ConfigurationTO configurationTO = new ConfigurationTO();
-        configurationTO.setKey("testKey");
-        configurationTO.setValue("testValue");
+        SchemaTO testKey = new SchemaTO();
+        testKey.setName("testKey");
+        testKey.setType(AttributeSchemaType.String);
+        createSchema(AttributableType.CONFIGURATION, SchemaType.NORMAL, testKey);
+
+        AttributeTO conf = new AttributeTO();
+        conf.setSchema("testKey");
+        conf.getValues().add("testValue");
 
-        Response response = configurationService.create(configurationTO);
-        assertNotNull(response);
-        assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
-        ConfigurationTO newConfigurationTO = getObject(response.getLocation(), ConfigurationService.class,
-                ConfigurationTO.class);
-        assertEquals(configurationTO, newConfigurationTO);
+        configurationService.set(conf.getSchema(), conf);
+
+        AttributeTO actual = configurationService.read(conf.getSchema());
+        assertEquals(actual, conf);
     }
 
     @Test
@@ -69,7 +73,7 @@ public class ConfigurationTestITCase ext
             assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
         }
 
-        ConfigurationTO tokenLengthTO = configurationService.read("token.length");
+        AttributeTO tokenLength = configurationService.read("token.length");
 
         configurationService.delete("token.length");
         try {
@@ -78,43 +82,38 @@ public class ConfigurationTestITCase ext
             assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
         }
 
-        Response response = configurationService.create(tokenLengthTO);
-        assertNotNull(response);
-        assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
-        ConfigurationTO newConfigurationTO = getObject(response.getLocation(), ConfigurationService.class,
-                ConfigurationTO.class);
-        assertEquals(tokenLengthTO, newConfigurationTO);
+        configurationService.set(tokenLength.getSchema(), tokenLength);
+
+        AttributeTO actual = configurationService.read(tokenLength.getSchema());
+        assertEquals(actual, tokenLength);
     }
 
     @Test
     public void list() {
-        List<ConfigurationTO> configurations = configurationService.list();
-        assertNotNull(configurations);
-        for (ConfigurationTO configuration : configurations) {
-            assertNotNull(configuration);
+        ConfTO wholeConf = configurationService.list();
+        assertNotNull(wholeConf);
+        for (AttributeTO conf : wholeConf.getAttrs()) {
+            assertNotNull(conf);
         }
     }
 
     @Test
     public void read() {
-        ConfigurationTO configurationTO = configurationService.read("token.expireTime");
-
-        assertNotNull(configurationTO);
+        AttributeTO conf = configurationService.read("token.expireTime");
+        assertNotNull(conf);
     }
 
     @Test
     public void update() {
-        ConfigurationTO configurationTO = configurationService.read("token.expireTime");
-        int value = Integer.parseInt(configurationTO.getValue());
+        AttributeTO expireTime = configurationService.read("token.expireTime");
+        int value = Integer.parseInt(expireTime.getValues().get(0));
         value++;
-        configurationTO.setValue(value + "");
+        expireTime.getValues().set(0, value + "");
 
-        configurationService.update(configurationTO.getKey(), configurationTO);
-        ConfigurationTO newConfigurationTO = configurationService.read(configurationTO.getKey());
-        assertEquals(configurationTO, newConfigurationTO);
+        configurationService.set(expireTime.getSchema(), expireTime);
 
-        newConfigurationTO = configurationService.read("token.expireTime");
-        assertEquals(configurationTO, newConfigurationTO);
+        AttributeTO newConfigurationTO = configurationService.read(expireTime.getSchema());
+        assertEquals(expireTime, newConfigurationTO);
     }
 
     @Test
@@ -135,18 +134,19 @@ public class ConfigurationTestITCase ext
 
     @Test
     public void issueSYNCOPE418() {
-        ConfigurationTO configurationTO = new ConfigurationTO();
-        configurationTO.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
+        SchemaTO failing = new SchemaTO();
+        failing.setName("http://schemas.examples.org/security/authorization/organizationUnit");
+        failing.setType(AttributeSchemaType.String);
 
         try {
-            configurationService.create(configurationTO);
+            createSchema(AttributableType.CONFIGURATION, SchemaType.NORMAL, failing);
             fail();
         } catch (SyncopeClientException e) {
-            assertEquals(ClientExceptionType.InvalidSyncopeConf, e.getType());
+            assertEquals(ClientExceptionType.InvalidCSchema, e.getType());
 
             assertNotNull(e.getElements());
             assertEquals(1, e.getElements().size());
-            assertTrue(e.getElements().iterator().next().toString().contains(EntityViolationType.InvalidName.name()));
+            assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
         }
     }
 }