diff --git a/config/alfresco/bulk-import-context.xml b/config/alfresco/bulk-import-context.xml
index 285d0a50e7..f1ebeaa955 100644
--- a/config/alfresco/bulk-import-context.xml
+++ b/config/alfresco/bulk-import-context.xml
@@ -46,7 +46,7 @@
-
+
diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml
index a272162a48..f604ca354a 100644
--- a/config/alfresco/core-services-context.xml
+++ b/config/alfresco/core-services-context.xml
@@ -1389,4 +1389,8 @@
+
+
+
+
diff --git a/config/alfresco/subsystems/Synchronization/default/default-synchronization-context.xml b/config/alfresco/subsystems/Synchronization/default/default-synchronization-context.xml
index 99dcb48771..f9a5290c26 100644
--- a/config/alfresco/subsystems/Synchronization/default/default-synchronization-context.xml
+++ b/config/alfresco/subsystems/Synchronization/default/default-synchronization-context.xml
@@ -77,6 +77,7 @@
${synchronization.allowDeletions}
+
diff --git a/source/java/org/alfresco/repo/bulkimport/impl/DirectoryAnalyserImpl.java b/source/java/org/alfresco/repo/bulkimport/impl/DirectoryAnalyserImpl.java
index aa10103aaf..f575291fbb 100644
--- a/source/java/org/alfresco/repo/bulkimport/impl/DirectoryAnalyserImpl.java
+++ b/source/java/org/alfresco/repo/bulkimport/impl/DirectoryAnalyserImpl.java
@@ -34,23 +34,16 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.bulkimport.AnalysedDirectory;
import org.alfresco.repo.bulkimport.DirectoryAnalyser;
import org.alfresco.repo.bulkimport.ImportFilter;
import org.alfresco.repo.bulkimport.ImportableItem;
import org.alfresco.repo.bulkimport.ImportableItem.FileType;
import org.alfresco.repo.bulkimport.MetadataLoader;
-import org.alfresco.service.cmr.dictionary.Constraint;
-import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
+import org.alfresco.repo.dictionary.constraint.NameChecker;
import org.alfresco.service.cmr.dictionary.ConstraintException;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
-import org.alfresco.service.namespace.NamespaceService;
-import org.alfresco.service.namespace.QName;
-import org.alfresco.util.PropertyCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.InitializingBean;
import org.springframework.extensions.surf.exception.PlatformRuntimeException;
import org.springframework.extensions.surf.util.ISO8601DateFormat;
@@ -61,7 +54,7 @@ import org.springframework.extensions.surf.util.ISO8601DateFormat;
* @since 4.0
*
*/
-public class DirectoryAnalyserImpl implements DirectoryAnalyser, InitializingBean
+public class DirectoryAnalyserImpl implements DirectoryAnalyser
{
private final static Log log = LogFactory.getLog(DirectoryAnalyserImpl.class);
@@ -70,50 +63,25 @@ public class DirectoryAnalyserImpl implements DirectoryAnalyser, InitializingBea
private MetadataLoader metadataLoader;
private BulkImportStatusImpl importStatus;
private List importFilters;
- private DictionaryService dictionaryService;
- private Constraint filenameConstraint;
+ private NameChecker nameChecker;
+
public DirectoryAnalyserImpl(MetadataLoader metadataLoader, BulkImportStatusImpl importStatus, List importFilters,
- DictionaryService dictionaryService)
+ NameChecker nameChecker)
{
this.metadataLoader = metadataLoader;
this.importStatus = importStatus;
this.importFilters = importFilters;
- this.dictionaryService = dictionaryService;
+ this.nameChecker = nameChecker;
}
public DirectoryAnalyserImpl()
{
}
- public DictionaryService getDictionaryService()
+ public void setNameChecker(NameChecker nameChecker)
{
- return dictionaryService;
- }
-
- public void setDictionaryService(DictionaryService dictionaryService)
- {
- this.dictionaryService = dictionaryService;
- }
-
- /**
- * Loads filename constraint from dictionary
- */
- public void afterPropertiesSet() throws Exception
- {
- PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
-
- QName qNameConstraint = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "filename");
- ConstraintDefinition constraintDef = dictionaryService.getConstraint(qNameConstraint);
- if (constraintDef == null)
- {
- throw new AlfrescoRuntimeException("Constraint definition does not exist: " + qNameConstraint);
- }
- filenameConstraint = constraintDef.getConstraint();
- if (filenameConstraint == null)
- {
- throw new AlfrescoRuntimeException("Constraint does not exist: " + qNameConstraint);
- }
+ this.nameChecker = nameChecker;
}
public void setMetadataLoader(MetadataLoader metadataLoader)
@@ -205,7 +173,7 @@ public class DirectoryAnalyserImpl implements DirectoryAnalyser, InitializingBea
{
try
{
- filenameConstraint.evaluate(file.getName());
+ nameChecker.evaluate(file.getName());
}
catch (ConstraintException e)
{
diff --git a/source/java/org/alfresco/repo/security/sync/ChainingUserRegistrySynchronizer.java b/source/java/org/alfresco/repo/security/sync/ChainingUserRegistrySynchronizer.java
index 2f28d84ef2..639a5cf420 100644
--- a/source/java/org/alfresco/repo/security/sync/ChainingUserRegistrySynchronizer.java
+++ b/source/java/org/alfresco/repo/security/sync/ChainingUserRegistrySynchronizer.java
@@ -56,6 +56,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.admin.SysAdminParams;
import org.alfresco.repo.batch.BatchProcessor;
import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorker;
+import org.alfresco.repo.dictionary.constraint.NameChecker;
import org.alfresco.repo.lock.JobLockService;
import org.alfresco.repo.lock.LockAcquisitionException;
import org.alfresco.repo.management.subsystems.ActivateableBean;
@@ -207,7 +208,10 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
/** Allow a full sync to perform deletions? */
private boolean allowDeletions = true;
-
+
+ /** Validates person names over cm:filename constraint **/
+ private NameChecker nameChecker;
+
private SysAdminParams sysAdminParams;
public void init()
@@ -222,6 +226,14 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
PropertyCheck.mandatory(this, "sysAdminParams", sysAdminParams);
}
+ /**
+ * Sets name checker
+ */
+ public void setNameChecker(NameChecker nameChecker)
+ {
+ this.nameChecker = nameChecker;
+ }
+
/**
* Sets the application context manager.
*
@@ -1813,6 +1825,8 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
// Make a mutable copy of the person properties, since they get written back to by person service
HashMap personProperties = new HashMap(person.getProperties());
String personName = (String) personProperties.get(ContentModel.PROP_USERNAME);
+ // for invalid names will throw ConstraintException that will be catched by BatchProcessor$TxnCallback
+ nameChecker.evaluate(personName);
Set zones = ChainingUserRegistrySynchronizer.this.authorityService
.getAuthorityZones(personName);
if (zones == null)