syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject svn commit: r1443475 - in /syncope/trunk: client/src/main/java/org/apache/syncope/client/services/proxy/ 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...
Date Thu, 07 Feb 2013 13:53:06 GMT
Author: fmartelli
Date: Thu Feb  7 13:53:05 2013
New Revision: 1443475

URL: http://svn.apache.org/viewvc?rev=1443475&view=rev
Log:
Fix for SYNCOPE-258

Added:
    syncope/trunk/common/src/main/java/org/apache/syncope/common/to/CorrelationRuleClassTO.java
      - copied, changed from r1443398, syncope/trunk/common/src/main/java/org/apache/syncope/common/to/PropagationActionClassTO.java
Modified:
    syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/PolicyServiceProxy.java
    syncope/trunk/common/src/main/java/org/apache/syncope/common/services/PolicyService.java
    syncope/trunk/common/src/main/java/org/apache/syncope/common/types/   (props changed)
    syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ConflictResolutionAction.java
    syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/PolicyBeanPanel.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
    syncope/trunk/core/src/test/resources/content.xml

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/PolicyServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/PolicyServiceProxy.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/PolicyServiceProxy.java
(original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/PolicyServiceProxy.java
Thu Feb  7 13:53:05 2013
@@ -20,16 +20,18 @@ package org.apache.syncope.client.servic
 
 import java.net.URI;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
-
+import java.util.Set;
 import javax.ws.rs.core.Response;
-
 import org.apache.syncope.common.services.PolicyService;
 import org.apache.syncope.common.to.AccountPolicyTO;
+import org.apache.syncope.common.to.CorrelationRuleClassTO;
 import org.apache.syncope.common.to.PasswordPolicyTO;
 import org.apache.syncope.common.to.PolicyTO;
 import org.apache.syncope.common.to.SyncPolicyTO;
 import org.apache.syncope.common.types.PolicyType;
+import org.apache.syncope.common.util.CollectionWrapper;
 import org.springframework.web.client.RestTemplate;
 
 @SuppressWarnings("unchecked")
@@ -120,4 +122,18 @@ public class PolicyServiceProxy extends 
             return url;
         }
     }
+
+    @Override
+    public Set<CorrelationRuleClassTO> getCorrelationRuleClasses(final PolicyType type)
{
+        switch (type) {
+            case SYNC:
+            case GLOBAL_SYNC:
+                final Set<String> classes = new HashSet<String>(Arrays.asList(getRestTemplate().getForObject(
+                        baseUrl + "policy/correlationRuleClasses.json", String[].class)));
+
+                return CollectionWrapper.wrapCorrelationRuleClasses(classes);
+            default:
+                throw new IllegalArgumentException("Cannot retrieve correlation rule classes
for type " + type);
+        }
+    }
 }

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/services/PolicyService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/PolicyService.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/services/PolicyService.java
(original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/services/PolicyService.java
Thu Feb  7 13:53:05 2013
@@ -19,6 +19,7 @@
 package org.apache.syncope.common.services;
 
 import java.util.List;
+import java.util.Set;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
@@ -26,7 +27,7 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.core.Response;
-
+import org.apache.syncope.common.to.CorrelationRuleClassTO;
 import org.apache.syncope.common.to.PolicyTO;
 import org.apache.syncope.common.types.PolicyType;
 
@@ -83,4 +84,11 @@ public interface PolicyService {
     <T extends PolicyTO> void update(@PathParam("type") PolicyType type, @PathParam("policyId")
Long policyId,
             T policyTO);
 
+    /**
+     * @param type PolicyType (just SYNC is supported).
+     * @return Returns correlation rules java classes.
+     */
+    @GET
+    @Path("correlationRuleClasses")
+    Set<CorrelationRuleClassTO> getCorrelationRuleClasses(@PathParam("type") PolicyType
type);
 }

Copied: syncope/trunk/common/src/main/java/org/apache/syncope/common/to/CorrelationRuleClassTO.java
(from r1443398, syncope/trunk/common/src/main/java/org/apache/syncope/common/to/PropagationActionClassTO.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/to/CorrelationRuleClassTO.java?p2=syncope/trunk/common/src/main/java/org/apache/syncope/common/to/CorrelationRuleClassTO.java&p1=syncope/trunk/common/src/main/java/org/apache/syncope/common/to/PropagationActionClassTO.java&r1=1443398&r2=1443475&rev=1443475&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/to/PropagationActionClassTO.java
(original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/to/CorrelationRuleClassTO.java
Thu Feb  7 13:53:05 2013
@@ -20,19 +20,18 @@ package org.apache.syncope.common.to;
 
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
-
 import org.apache.syncope.common.AbstractBaseBean;
 
-@XmlRootElement(name = "propagationActionClass")
+@XmlRootElement(name = "correlationRuleClass")
 @XmlType
-public class PropagationActionClassTO extends AbstractBaseBean {
+public class CorrelationRuleClassTO extends AbstractBaseBean {
 
-    private static final long serialVersionUID = 2187654394121198308L;
+    private static final long serialVersionUID = -6715106427060816725L;
 
     private String name;
 
-    public static PropagationActionClassTO instance(final String name) {
-        PropagationActionClassTO instance = new PropagationActionClassTO();
+    public static CorrelationRuleClassTO instance(final String name) {
+        CorrelationRuleClassTO instance = new CorrelationRuleClassTO();
         instance.setName(name);
         return instance;
     }

Propchange: syncope/trunk/common/src/main/java/org/apache/syncope/common/types/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Feb  7 13:53:05 2013
@@ -0,0 +1 @@
+.SyncPolicySpec.java.swp

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ConflictResolutionAction.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ConflictResolutionAction.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ConflictResolutionAction.java
(original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ConflictResolutionAction.java
Thu Feb  7 13:53:05 2013
@@ -23,12 +23,12 @@ import javax.xml.bind.annotation.XmlEnum
 @XmlEnum
 public enum ConflictResolutionAction {
 
+    // ignore sync
+    IGNORE,
     // sync first matcgh
     FIRSTMATCH,
     // sync last match
     LASTMATCH,
-    // ignore sync
-    IGNORE,
     // sync all
     ALL;
 

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
(original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
Thu Feb  7 13:53:05 2013
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import org.apache.syncope.common.to.CorrelationRuleClassTO;
 
 import org.apache.syncope.common.to.EntitlementTO;
 import org.apache.syncope.common.to.JobClassTO;
@@ -186,6 +187,22 @@ public final class CollectionWrapper {
         return respons;
     }
 
+    public static Set<CorrelationRuleClassTO> wrapCorrelationRuleClasses(Set<String>
classes) {
+        Set<CorrelationRuleClassTO> respons = new HashSet<CorrelationRuleClassTO>();
+        for (String cl : classes) {
+            respons.add(CorrelationRuleClassTO.instance(cl));
+        }
+        return respons;
+    }
+
+    public static List<String> unwrapCorrelationRuleClasses(Set<CorrelationRuleClassTO>
actions) {
+        List<String> respons = new ArrayList<String>();
+        for (CorrelationRuleClassTO e : actions) {
+            respons.add(e.getName());
+        }
+        return respons;
+    }
+
     @SuppressWarnings("unchecked")
     public static List<String> wrapStrings(final ModelAndView modelAndView) {
         return (List<String>) modelAndView.getModel().values().iterator().next();

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/PolicyBeanPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/PolicyBeanPanel.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/PolicyBeanPanel.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/PolicyBeanPanel.java
Thu Feb  7 13:53:05 2013
@@ -25,11 +25,12 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
+import org.apache.syncope.common.annotation.ClassList;
 import org.apache.syncope.common.annotation.SchemaList;
 import org.apache.syncope.common.types.AbstractPolicySpec;
 import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.common.types.ConflictResolutionAction;
 import org.apache.syncope.console.markup.html.list.AltListView;
+import org.apache.syncope.console.rest.PolicyRestClient;
 import org.apache.syncope.console.rest.SchemaRestClient;
 import org.apache.syncope.console.wicket.markup.html.form.AbstractFieldPanel;
 import org.apache.syncope.console.wicket.markup.html.form.AjaxCheckBoxPanel;
@@ -67,6 +68,9 @@ public class PolicyBeanPanel extends Pan
     @SpringBean
     private SchemaRestClient schemaRestClient;
 
+    @SpringBean
+    private PolicyRestClient policyRestClient;
+
     final IModel<List<String>> userSchemas = new LoadableDetachableModel<List<String>>()
{
 
         private static final long serialVersionUID = -2012833443695917883L;
@@ -87,6 +91,14 @@ public class PolicyBeanPanel extends Pan
         }
     };
 
+    final IModel<List<String>> correlationRules = new LoadableDetachableModel<List<String>>()
{
+
+        @Override
+        protected List<String> load() {
+            return policyRestClient.getCorrelationRuleClasses();
+        }
+    };
+
     public PolicyBeanPanel(final String id, final AbstractPolicySpec policy) {
         super(id);
 
@@ -101,6 +113,9 @@ public class PolicyBeanPanel extends Pan
                 final SchemaList schemaList = field.getAnnotation(SchemaList.class);
                 fieldWrapper.setSchemaList(schemaList);
 
+                final ClassList classList = field.getAnnotation(ClassList.class);
+                fieldWrapper.setClassList(classList);
+
                 items.add(fieldWrapper);
             }
         }
@@ -120,18 +135,41 @@ public class PolicyBeanPanel extends Pan
 
                 final AbstractFieldPanel component;
                 try {
-                    if (field.getType().equals(ConflictResolutionAction.class)) {
+                    if (field.getClassList() != null) {
                         component = new AjaxDropDownChoicePanel("field", field.getName(),
new PropertyModel(policy,
                                 field.getName()));
 
-                        ((AjaxDropDownChoicePanel) component).setChoices(
-                                Arrays.asList(ConflictResolutionAction.values()));
+                        final List<String> rules = correlationRules.getObject();
+
+                        if (rules != null && !rules.isEmpty()) {
+                            ((AjaxDropDownChoicePanel) component).setChoices(correlationRules.getObject());
+                        }
 
                         item.add(component);
 
-                        item.add(getActivationControl(component,
+                        item.add(getActivationControl(
+                                component,
+                                propDesc.getReadMethod().invoke(policy, new Object[]{}) !=
null,
+                                null,
+                                null));
+
+                    } else if (field.getType().isEnum()) {
+                        component = new AjaxDropDownChoicePanel("field", field.getName(),
new PropertyModel(policy,
+                                field.getName()));
+
+                        final Serializable[] values = (Serializable[]) field.getType().getEnumConstants();
+
+                        if (values != null && values.length > 0) {
+                            ((AjaxDropDownChoicePanel) component).setChoices(Arrays.asList(values));
+                        }
+
+                        item.add(component);
+
+                        item.add(getActivationControl(
+                                component,
                                 (Enum<?>) propDesc.getReadMethod().invoke(policy, new
Object[]{}) != null,
-                                ConflictResolutionAction.IGNORE, ConflictResolutionAction.IGNORE));
+                                values[0],
+                                values[0]));
 
                     } else if (field.getType().equals(boolean.class) || field.getType().equals(Boolean.class))
{
                         item.add(new AjaxCheckBoxPanel("check", field.getName(), new PropertyModel(policy,
@@ -158,6 +196,7 @@ public class PolicyBeanPanel extends Pan
 
                             Collection collection =
                                     (Collection) propDesc.getReadMethod().invoke(policy,
new Object[]{});
+
                             if (collection == null) {
                                 collection = new ArrayList();
                                 propDesc.getWriteMethod().invoke(policy, collection);
@@ -246,6 +285,8 @@ public class PolicyBeanPanel extends Pan
 
         private transient SchemaList schemaList;
 
+        private transient ClassList classList;
+
         public String getName() {
             return name;
         }
@@ -269,5 +310,13 @@ public class PolicyBeanPanel extends Pan
         public void setSchemaList(final SchemaList schemaList) {
             this.schemaList = schemaList;
         }
+
+        public ClassList getClassList() {
+            return classList;
+        }
+
+        public void setClassList(ClassList classList) {
+            this.classList = classList;
+        }
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
Thu Feb  7 13:53:05 2013
@@ -20,13 +20,14 @@ package org.apache.syncope.console.rest;
 
 import java.util.ArrayList;
 import java.util.List;
-
 import org.apache.syncope.common.services.PolicyService;
 import org.apache.syncope.common.to.AccountPolicyTO;
 import org.apache.syncope.common.to.PasswordPolicyTO;
 import org.apache.syncope.common.to.PolicyTO;
 import org.apache.syncope.common.to.SyncPolicyTO;
 import org.apache.syncope.common.types.PolicyType;
+import org.apache.syncope.common.util.CollectionWrapper;
+import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
 import org.springframework.stereotype.Component;
 
 /**
@@ -85,6 +86,19 @@ public class PolicyRestClient extends Ba
         getService(PolicyService.class).delete(getPolicyType(policyClass), id);
     }
 
+    public List<String> getCorrelationRuleClasses() {
+        List<String> rules = null;
+
+        try {
+            rules = CollectionWrapper.unwrapCorrelationRuleClasses(
+                    getService(PolicyService.class).getCorrelationRuleClasses(PolicyType.SYNC));
+        } catch (Exception e) {
+            LOG.error("While getting all correlation rule classes", e);
+        }
+
+        return rules;
+    }
+
     private PolicyType getPolicyType(final Class<? extends PolicyTO> clazz) {
         if (AccountPolicyTO.class.equals(clazz)) {
             return PolicyType.ACCOUNT;

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java
(original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/PolicyController.java
Thu Feb  7 13:53:05 2013
@@ -22,9 +22,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
-
 import javax.servlet.http.HttpServletResponse;
-
 import org.apache.syncope.common.to.AccountPolicyTO;
 import org.apache.syncope.common.to.PasswordPolicyTO;
 import org.apache.syncope.common.to.PolicyTO;
@@ -264,12 +262,12 @@ public class PolicyController extends Ab
     @PreAuthorize("hasRole('POLICY_LIST')")
     @RequestMapping(method = RequestMethod.GET, value = "/correlationRuleClasses")
     public ModelAndView getCorrelationRuleClasses() {
-        final Set<String> actionsClasses =
+        final Set<String> correlationRules =
                 classNamesLoader.getClassNames(ImplementationClassNamesLoader.Type.SYNC_CORRELATION_RULES);
 
         auditManager.audit(Category.policy, AuditElements.PolicySubCategory.getCorrelationRuleClasses,
-                Result.success, "Successfully listed all correlation rule classes: " + actionsClasses.size());
+                Result.success, "Successfully listed all correlation rule classes: " + correlationRules.size());
 
-        return new ModelAndView().addObject(actionsClasses);
+        return new ModelAndView().addObject(correlationRules);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java
(original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java
Thu Feb  7 13:53:05 2013
@@ -20,6 +20,7 @@ package org.apache.syncope.core.services
 
 import java.net.URI;
 import java.util.List;
+import java.util.Set;
 
 import javax.ws.rs.BadRequestException;
 import javax.ws.rs.core.Response;
@@ -31,7 +32,9 @@ import org.apache.syncope.common.to.Acco
 import org.apache.syncope.common.to.PasswordPolicyTO;
 import org.apache.syncope.common.to.PolicyTO;
 import org.apache.syncope.common.to.SyncPolicyTO;
+import org.apache.syncope.common.to.CorrelationRuleClassTO;
 import org.apache.syncope.common.types.PolicyType;
+import org.apache.syncope.common.util.CollectionWrapper;
 import org.apache.syncope.core.rest.controller.PolicyController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -48,9 +51,7 @@ public class PolicyServiceImpl implement
     public <T extends PolicyTO> Response create(final PolicyType type, final T policyTO)
{
         PolicyTO policy = policyController.createInternal(policyTO);
         URI location = uriInfo.getAbsolutePathBuilder().path(policy.getId() + "").build();
-        return Response.created(location)
-                .header(SyncopeConstants.REST_HEADER_ID, policy.getId())
-                .build();
+        return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, policy.getId()).build();
     }
 
     @Override
@@ -119,4 +120,19 @@ public class PolicyServiceImpl implement
         this.uriInfo = ui;
     }
 
+    @Override
+    public Set<CorrelationRuleClassTO> getCorrelationRuleClasses(PolicyType type) {
+        switch (type) {
+            case SYNC:
+            case GLOBAL_SYNC:
+                
+                @SuppressWarnings("unchecked")
+                final Set<String> classes =
+                        (Set<String>) policyController.getCorrelationRuleClasses().getModel().values().iterator().next();
+                return CollectionWrapper.wrapCorrelationRuleClasses(classes);
+                
+            default:
+                throw new IllegalArgumentException("Cannot retrieve correlation rule classes
for type " + type);
+        }
+    }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java Thu
Feb  7 13:53:05 2013
@@ -166,6 +166,11 @@ public class PolicyTestITCase extends Ab
         assertNotNull(t);
     }
 
+    @Test
+    public void getCorrelationRules() {
+        assertEquals(1, policyService.getCorrelationRuleClasses(PolicyType.SYNC).size());
+    }
+
     private SyncPolicyTO buildSyncPolicyTO() {
         SyncPolicyTO policy = new SyncPolicyTO();
 

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Thu
Feb  7 13:53:05 2013
@@ -48,11 +48,15 @@ import org.apache.syncope.common.to.Task
 import org.apache.syncope.common.to.TaskTO;
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.mod.UserMod;
+import org.apache.syncope.common.to.SyncPolicyTO;
 import org.apache.syncope.common.types.IntMappingType;
+import org.apache.syncope.common.types.PolicyType;
 import org.apache.syncope.common.types.PropagationTaskExecStatus;
+import org.apache.syncope.common.types.SyncPolicySpec;
 import org.apache.syncope.common.types.TaskType;
 import org.apache.syncope.common.types.TraceLevel;
 import org.apache.syncope.core.sync.TestSyncActions;
+import org.apache.syncope.core.sync.TestSyncRule;
 import org.apache.syncope.core.sync.impl.SyncJob;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
@@ -781,6 +785,15 @@ public class TaskTestITCase extends Abst
 
     @Test
     public void issueSYNCOPE258() {
+        // -----------------------------
+        // Add a custom correlation rule
+        // -----------------------------
+        SyncPolicyTO policyTO = policyService.read(PolicyType.SYNC, 9L);
+        ((SyncPolicySpec)policyTO.getSpecification()).setUserJavaRule(TestSyncRule.class.getName());
+        
+        policyService.update(PolicyType.SYNC, policyTO.getId(), policyTO);
+        // -----------------------------
+        
         SyncTaskTO task = new SyncTaskTO();
         task.setName("Test Sync Rule");
         task.setResource("ws-target-resource-2");

Modified: syncope/trunk/core/src/test/resources/content.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/content.xml?rev=1443475&r1=1443474&r2=1443475&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/content.xml (original)
+++ syncope/trunk/core/src/test/resources/content.xml Thu Feb  7 13:53:05 2013
@@ -40,7 +40,7 @@ under the License.
   <Policy DTYPE="AccountPolicy" id="6" description="sample account policy" type="ACCOUNT"
specification="%3Corg.apache.syncope.common.types.AccountPolicySpec%3E%0A++%3CmaxLength%3E0%3C%2FmaxLength%3E%0A++%3CminLength%3E4%3C%2FminLength%3E%0A++%3CprefixesNotPermitted%3E%0A++++%3Cstring%3Enotpermitted1%3C%2Fstring%3E%0A++++%3Cstring%3Enotpermitted2%3C%2Fstring%3E%0A++%3C%2FprefixesNotPermitted%3E%0A++%3CallUpperCase%3Efalse%3C%2FallUpperCase%3E%0A++%3CallLowerCase%3Efalse%3C%2FallLowerCase%3E%0A++%3CpropagateSuspension%3Efalse%3C%2FpropagateSuspension%3E%0A++%3CpermittedLoginRetries%3E3%3C%2FpermittedLoginRetries%3E%0A%3C%2Forg.apache.syncope.common.types.AccountPolicySpec%3E"/>
   <Policy DTYPE="SyncPolicy" id="7" description="sync policy 1" type="SYNC" specification="%3Corg.apache.syncope.common.types.SyncPolicySpec%2F%3E"/>
   <Policy DTYPE="PasswordPolicy" id="8" description="sample password policy" type="PASSWORD"
specification="%3Corg.apache.syncope.common.types.PasswordPolicySpec%3E%0A++%3ChistoryLength%3E0%3C%2FhistoryLength%3E%0A++%3CmaxLength%3E0%3C%2FmaxLength%3E%0A++%3CminLength%3E10%3C%2FminLength%3E%0A++%3CnonAlphanumericRequired%3Etrue%3C%2FnonAlphanumericRequired%3E%0A++%3CalphanumericRequired%3Efalse%3C%2FalphanumericRequired%3E%0A++%3CdigitRequired%3Etrue%3C%2FdigitRequired%3E%0A++%3ClowercaseRequired%3Etrue%3C%2FlowercaseRequired%3E%0A++%3CuppercaseRequired%3Etrue%3C%2FuppercaseRequired%3E%0A++%3CmustStartWithDigit%3Etrue%3C%2FmustStartWithDigit%3E%0A++%3CmustntStartWithDigit%3Efalse%3C%2FmustntStartWithDigit%3E%0A++%3CmustEndWithDigit%3Etrue%3C%2FmustEndWithDigit%3E%0A++%3CmustntEndWithDigit%3Efalse%3C%2FmustntEndWithDigit%3E%0A++%3CmustStartWithNonAlpha%3Efalse%3C%2FmustStartWithNonAlpha%3E%0A++%3CmustStartWithAlpha%3Efalse%3C%2FmustStartWithAlpha%3E%0A++%3CmustntStartWithNonAl
 pha%3Efalse%3C%2FmustntStartWithNonAlpha%3E%0A++%3CmustntStartWithAlpha%3Efalse%3C%2FmustntStartWithAlpha%3E%0A++%3CmustEndWithNonAlpha%3Efalse%3C%2FmustEndWithNonAlpha%3E%0A++%3CmustEndWithAlpha%3Efalse%3C%2FmustEndWithAlpha%3E%0A++%3CmustntEndWithNonAlpha%3Efalse%3C%2FmustntEndWithNonAlpha%3E%0A++%3CmustntEndWithAlpha%3Efalse%3C%2FmustntEndWithAlpha%3E%0A++%3CprefixesNotPermitted%3E%0A++++%3Cstring%3Enotpermitted1%3C%2Fstring%3E%0A++++%3Cstring%3Enotpermitted2%3C%2Fstring%3E%0A++%3C%2FprefixesNotPermitted%3E%0A%3C%2Forg.apache.syncope.common.types.PasswordPolicySpec%3E"/>
-  <Policy DTYPE="SyncPolicy" id="9" description="sync policy with a rule" type="SYNC"
specification="%3Corg.apache.syncope.common.types.SyncPolicySpec%3E%0A++%3CuserJavaRule%3Eorg.apache.syncope.core.sync.TestSyncRule%3C/userJavaRule%3E%0A++%3CroleJavaRule%3E%3C/roleJavaRule%3E%0A++%3CconflictResolutionAction%3EIGNORE%3C/conflictResolutionAction%3E%0A%3C/org.apache.syncope.common.types.SyncPolicySpec%3E"/>
+  <Policy DTYPE="SyncPolicy" id="9" description="sync policy for java rule" type="SYNC"
specification="%3Corg.apache.syncope.common.types.SyncPolicySpec%3E%0A++%3CconflictResolutionAction%3EIGNORE%3C/conflictResolutionAction%3E%0A%3C/org.apache.syncope.common.types.SyncPolicySpec%3E"/>
     
   <SyncopeUser id="1" workflowId="0" status="active" password="5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8"
cipherAlgorithm="SHA1"
                username="user1" creationDate="2010-10-20 11:00:00" suspended="0"/>



Mime
View raw message