mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged V2.2 to HEAD
7575: Permission changes for AVM. 7577: Incorporated most of the feedback provided by Kevin C earlier today 7578: Removed directory not removed by patch 7579: EmailServer bug fixes AR-1902: Double posts when emailing to a document AR-1904: Attachments via email should be allowed on forum posts AR-1903: (Partial Fix) Text attachments should be treated the same way as other attachments 7583: Fixed WCM-961 & WCM-962: Added confirm dialog for 'Delete All Deployment Reports' and 'Release Server' actions git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8434 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,6 +27,8 @@ package org.alfresco.repo.security.permissions.dynamic;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.permissions.DynamicAuthority;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
@@ -34,6 +36,7 @@ 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.PermissionService;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
@@ -46,33 +49,41 @@ public class LockOwnerDynamicAuthority implements DynamicAuthority, Initializing
|
||||
private NodeService nodeService;
|
||||
|
||||
|
||||
public boolean hasAuthority(NodeRef nodeRef, String userName)
|
||||
public boolean hasAuthority(final NodeRef nodeRef, final String userName)
|
||||
{
|
||||
if (lockService.getLockStatus(nodeRef) == LockStatus.LOCK_OWNER)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
NodeRef original = null;
|
||||
Serializable reference = nodeService.getProperty(nodeRef, ContentModel.PROP_COPY_REFERENCE);
|
||||
if (reference != null)
|
||||
return AuthenticationUtil.runAs(new RunAsWork<Boolean>(){
|
||||
|
||||
public Boolean doWork() throws Exception
|
||||
{
|
||||
original = DefaultTypeConverter.INSTANCE.convert(NodeRef.class, reference);
|
||||
}
|
||||
if (original != null && nodeService.exists(original))
|
||||
{
|
||||
return (lockService.getLockStatus(original) == LockStatus.LOCK_OWNER);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (lockService.getLockStatus(nodeRef, userName) == LockStatus.LOCK_OWNER)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
NodeRef original = null;
|
||||
Serializable reference = nodeService.getProperty(nodeRef, ContentModel.PROP_COPY_REFERENCE);
|
||||
if (reference != null)
|
||||
{
|
||||
original = DefaultTypeConverter.INSTANCE.convert(NodeRef.class, reference);
|
||||
}
|
||||
if (original != null && nodeService.exists(original))
|
||||
{
|
||||
return (lockService.getLockStatus(original, userName) == LockStatus.LOCK_OWNER);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public String getAuthority()
|
||||
|
@@ -24,6 +24,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.security.permissions.dynamic;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.permissions.DynamicAuthority;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.OwnableService;
|
||||
@@ -53,9 +55,16 @@ public class OwnerDynamicAuthority implements DynamicAuthority, InitializingBean
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasAuthority(NodeRef nodeRef, String userName)
|
||||
public boolean hasAuthority(final NodeRef nodeRef, final String userName)
|
||||
{
|
||||
return EqualsHelper.nullSafeEquals(ownableService.getOwner(nodeRef), userName);
|
||||
return AuthenticationUtil.runAs(new RunAsWork<Boolean>(){
|
||||
|
||||
public Boolean doWork() throws Exception
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return EqualsHelper.nullSafeEquals(ownableService.getOwner(nodeRef), userName);
|
||||
}}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
}
|
||||
|
||||
public String getAuthority()
|
||||
|
Reference in New Issue
Block a user