mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
Merged HEAD (5.1) to 5.1.N (5.1.1)
117537 bhorje: CM-690 reverted AMD DAO trait extension git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@117578 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,8 +26,6 @@ import java.util.Map;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.domain.node.NodeIdAndAclId;
|
||||
import org.alfresco.repo.domain.permissions.traitextender.AccessControlListDAOExtension;
|
||||
import org.alfresco.repo.domain.permissions.traitextender.AccessControlListDAOTrait;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.security.permissions.ACLType;
|
||||
import org.alfresco.repo.security.permissions.AccessControlList;
|
||||
@@ -38,11 +36,6 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.traitextender.AJExtender;
|
||||
import org.alfresco.traitextender.Extend;
|
||||
import org.alfresco.traitextender.ExtendedTrait;
|
||||
import org.alfresco.traitextender.Extensible;
|
||||
import org.alfresco.traitextender.Trait;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
@@ -52,7 +45,7 @@ import org.springframework.dao.ConcurrencyFailureException;
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class ADMAccessControlListDAO implements AccessControlListDAO, Extensible
|
||||
public class ADMAccessControlListDAO implements AccessControlListDAO
|
||||
{
|
||||
/**
|
||||
* The DAO for Nodes.
|
||||
@@ -63,14 +56,7 @@ public class ADMAccessControlListDAO implements AccessControlListDAO, Extensible
|
||||
|
||||
private BehaviourFilter behaviourFilter;
|
||||
private boolean preserveAuditableData = true;
|
||||
|
||||
private final ExtendedTrait<AccessControlListDAOTrait> accessControlListDAOTrait;
|
||||
|
||||
public ADMAccessControlListDAO()
|
||||
{
|
||||
accessControlListDAOTrait=new ExtendedTrait<AccessControlListDAOTrait>(createAccessControlListDAOTrait());
|
||||
}
|
||||
|
||||
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
@@ -111,8 +97,6 @@ public class ADMAccessControlListDAO implements AccessControlListDAO, Extensible
|
||||
return nodePair.getFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Extend(traitAPI = AccessControlListDAOTrait.class, extensionAPI = AccessControlListDAOExtension.class)
|
||||
public Acl getAccessControlList(NodeRef nodeRef)
|
||||
{
|
||||
Long nodeId = getNodeIdNotNull(nodeRef);
|
||||
@@ -491,104 +475,76 @@ public class ADMAccessControlListDAO implements AccessControlListDAO, Extensible
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Counter for each type of ACL change
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public static class CounterSet extends HashMap<ACLType, Counter>
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3682278258679211481L;
|
||||
|
||||
CounterSet()
|
||||
{
|
||||
super();
|
||||
this.put(ACLType.DEFINING, new Counter());
|
||||
this.put(ACLType.FIXED, new Counter());
|
||||
this.put(ACLType.GLOBAL, new Counter());
|
||||
this.put(ACLType.LAYERED, new Counter());
|
||||
this.put(ACLType.OLD, new Counter());
|
||||
this.put(ACLType.SHARED, new Counter());
|
||||
}
|
||||
|
||||
void add(ACLType type, Counter c)
|
||||
{
|
||||
Counter counter = get(type);
|
||||
counter.add(c.getCounter());
|
||||
}
|
||||
|
||||
void increment(ACLType type)
|
||||
{
|
||||
Counter counter = get(type);
|
||||
counter.increment();
|
||||
}
|
||||
|
||||
void add(CounterSet other)
|
||||
{
|
||||
add(ACLType.DEFINING, other.get(ACLType.DEFINING));
|
||||
add(ACLType.FIXED, other.get(ACLType.FIXED));
|
||||
add(ACLType.GLOBAL, other.get(ACLType.GLOBAL));
|
||||
add(ACLType.LAYERED, other.get(ACLType.LAYERED));
|
||||
add(ACLType.OLD, other.get(ACLType.OLD));
|
||||
add(ACLType.SHARED, other.get(ACLType.SHARED));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple counter
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public static class Counter
|
||||
{
|
||||
int counter;
|
||||
|
||||
void increment()
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
|
||||
int getCounter()
|
||||
{
|
||||
return counter;
|
||||
}
|
||||
|
||||
void add(int i)
|
||||
{
|
||||
counter += i;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <M extends Trait> ExtendedTrait<M> getTrait(Class<? extends M> traitAPI)
|
||||
{
|
||||
return (ExtendedTrait<M>) accessControlListDAOTrait;
|
||||
}
|
||||
|
||||
public AccessControlListDAOTrait createAccessControlListDAOTrait()
|
||||
{
|
||||
return new AccessControlListDAOTrait()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Acl getAccessControlList(final NodeRef nodeRef)
|
||||
{
|
||||
return AJExtender.run(new AJExtender.ExtensionBypass<Acl>()
|
||||
{
|
||||
@Override
|
||||
public Acl run()
|
||||
{
|
||||
return ADMAccessControlListDAO.this.getAccessControlList(nodeRef);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Counter for each type of ACL change
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public static class CounterSet extends HashMap<ACLType, Counter>
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3682278258679211481L;
|
||||
|
||||
CounterSet()
|
||||
{
|
||||
super();
|
||||
this.put(ACLType.DEFINING, new Counter());
|
||||
this.put(ACLType.FIXED, new Counter());
|
||||
this.put(ACLType.GLOBAL, new Counter());
|
||||
this.put(ACLType.LAYERED, new Counter());
|
||||
this.put(ACLType.OLD, new Counter());
|
||||
this.put(ACLType.SHARED, new Counter());
|
||||
}
|
||||
|
||||
void add(ACLType type, Counter c)
|
||||
{
|
||||
Counter counter = get(type);
|
||||
counter.add(c.getCounter());
|
||||
}
|
||||
|
||||
void increment(ACLType type)
|
||||
{
|
||||
Counter counter = get(type);
|
||||
counter.increment();
|
||||
}
|
||||
|
||||
void add(CounterSet other)
|
||||
{
|
||||
add(ACLType.DEFINING, other.get(ACLType.DEFINING));
|
||||
add(ACLType.FIXED, other.get(ACLType.FIXED));
|
||||
add(ACLType.GLOBAL, other.get(ACLType.GLOBAL));
|
||||
add(ACLType.LAYERED, other.get(ACLType.LAYERED));
|
||||
add(ACLType.OLD, other.get(ACLType.OLD));
|
||||
add(ACLType.SHARED, other.get(ACLType.SHARED));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple counter
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public static class Counter
|
||||
{
|
||||
int counter;
|
||||
|
||||
void increment()
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
|
||||
int getCounter()
|
||||
{
|
||||
return counter;
|
||||
}
|
||||
|
||||
void add(int i)
|
||||
{
|
||||
counter += i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.virtual.bundle;
|
||||
|
||||
import org.alfresco.repo.domain.permissions.Acl;
|
||||
import org.alfresco.repo.domain.permissions.traitextender.AccessControlListDAOExtension;
|
||||
import org.alfresco.repo.domain.permissions.traitextender.AccessControlListDAOTrait;
|
||||
import org.alfresco.repo.virtual.ActualEnvironment;
|
||||
import org.alfresco.repo.virtual.ref.GetActualNodeRefMethod;
|
||||
import org.alfresco.repo.virtual.ref.Reference;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.traitextender.SpringBeanExtension;
|
||||
|
||||
public class VirtualAccessControlListDAOExtension
|
||||
extends SpringBeanExtension<AccessControlListDAOExtension, AccessControlListDAOTrait>
|
||||
implements AccessControlListDAOExtension
|
||||
{
|
||||
private ActualEnvironment environment;
|
||||
|
||||
public VirtualAccessControlListDAOExtension()
|
||||
{
|
||||
super(AccessControlListDAOTrait.class);
|
||||
}
|
||||
|
||||
public void setEnvironment(ActualEnvironment environment)
|
||||
{
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Acl getAccessControlList(NodeRef nodeRef)
|
||||
{
|
||||
|
||||
if (Reference.isReference(nodeRef))
|
||||
{
|
||||
Reference vRef = Reference.fromNodeRef(nodeRef);
|
||||
NodeRef actual = vRef.execute(new GetActualNodeRefMethod(environment));
|
||||
return getTrait().getAccessControlList(actual);
|
||||
}
|
||||
return getTrait().getAccessControlList(nodeRef);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user