Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)

123162 jvonka: ACE-5113: Platform - OwnableService - when setting owner check that username currently exists (at time of property update)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126530 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-05-10 11:21:36 +00:00
parent 2341e9f573
commit 56fdd2741a
3 changed files with 92 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2014 Alfresco Software Limited.
* Copyright (C) 2005-2016 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -44,7 +44,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.NoSuchPersonException;
import org.alfresco.service.cmr.security.OwnableService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper;
import org.alfresco.util.PropertyCheck;
@@ -69,6 +71,7 @@ public class OwnableServiceImpl implements
private TenantService tenantService;
private Set<String> storesToIgnorePolicies = Collections.emptySet();
private RenditionService renditionService;
private PersonService personService;
public OwnableServiceImpl()
{
@@ -120,6 +123,11 @@ public class OwnableServiceImpl implements
this.renditionService = renditionService;
}
public void setPersonService(PersonService personService)
{
this.personService = personService;
}
public void afterPropertiesSet() throws Exception
{
PropertyCheck.mandatory(this, "nodeService", nodeService);
@@ -127,6 +135,7 @@ public class OwnableServiceImpl implements
PropertyCheck.mandatory(this, "nodeOwnerCache", nodeOwnerCache);
PropertyCheck.mandatory(this, "policyComponent", policyComponent);
PropertyCheck.mandatory(this, "renditionService", renditionService);
PropertyCheck.mandatory(this, "personService", personService);
}
public void init()
@@ -271,6 +280,25 @@ public class OwnableServiceImpl implements
if (!EqualsHelper.nullSafeEquals(pb, pa))
{
if (pa != null)
{
String username = (String) pa;
NodeRef personNodeRef = null;
// validate that user authentication exists
if (authenticationService.authenticationExists(username))
{
// validate that person exists
// note: will attempt to create missing person, if allowed - may throw NoSuchPersonException
personNodeRef = personService.getPerson(username, true);
}
if (personNodeRef == null)
{
throw new NoSuchPersonException(username);
}
}
nodeOwnerCache.remove(nodeRef);
return;
}