mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
57147: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 56930: Merged V4.1-BUG-FIX (4.1.7) to V4.2-BUG-FIX (4.2.1) 56876: MNT-9414: LDAP synchronization fails if a user with trailing dots in user name is encountered Apply cm:fileName constraint on personNames during LDAP synchronization batch processing to avoid import of persons with invalid names. Move logic for name validation to separate bean. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61772 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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<ImportFilter> importFilters;
|
||||
private DictionaryService dictionaryService;
|
||||
private Constraint filenameConstraint;
|
||||
private NameChecker nameChecker;
|
||||
|
||||
|
||||
public DirectoryAnalyserImpl(MetadataLoader metadataLoader, BulkImportStatusImpl importStatus, List<ImportFilter> 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)
|
||||
{
|
||||
|
@@ -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<QName, Serializable> personProperties = new HashMap<QName, Serializable>(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<String> zones = ChainingUserRegistrySynchronizer.this.authorityService
|
||||
.getAuthorityZones(personName);
|
||||
if (zones == null)
|
||||
|
Reference in New Issue
Block a user