mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV to HEAD
31489: Fix MT NodeRef translation in policy filter (ALF-10178) 31452: Sync DEV branch with HEAD 30312: Reintegrated HEAD 30281: Comprehensive DEBUG logging to track behaviour enable/disable states for transactions - Part of ALF-10178: BehaviourFilter fails when nesting disable/enable calls 30280: Fixed importer's use of behaviour filter - The change in the BehaviourFilter contract means that all disable calls must be matched with an equivalent enable call. Enabling globally no longer wipes out vetos put in place by other code. - Part of ALF-10178: BehaviourFilter fails when nesting disable/enable calls 30279: Removed unnecessary behaviour enablement checks is VersionService (ALF-10178) 30278: Fixed behaviour re-enabling for StoreSelectorAspectContentStore (ALF-10178) 30240: Fixed ALF-10178: BehaviourFilter fails when nesting disable/enable calls - Behaviour enable/disable now uses reference counting to check the state of different behaviour levels - Added unit test to test - Re-enabled test for ALF-10177: Test disabled: CheckOutCheckInServiceImplTest.testalfrescoCheckoutDoesntModifyNode but renamed to CheckOutCheckInServiceImplTest.testAlfrescoCheckoutDoesNotModifyNode - Going into DEV branch to run through tests 30236: Branch for fixing BehaviourFilter nesting git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31619 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,6 +26,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.lang.mutable.MutableInt;
|
||||
|
||||
/**
|
||||
* Helper class that will look up or create transactional resources.
|
||||
* This shortcuts some of the "<i>if not existing, then create</i>" code.
|
||||
@@ -35,6 +37,83 @@ import java.util.TreeSet;
|
||||
*/
|
||||
public abstract class TransactionalResourceHelper
|
||||
{
|
||||
/**
|
||||
* Get the current count value for a named key
|
||||
*
|
||||
* @param resourceKey the key to count against
|
||||
* @return the current value for the named key
|
||||
*/
|
||||
public static final int getCount(Object resourceKey)
|
||||
{
|
||||
MutableInt counter = (MutableInt) AlfrescoTransactionSupport.getResource(resourceKey);
|
||||
return counter == null ? 0 : counter.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the current count value for a named key. After this operation, the effective
|
||||
* value will be 0.
|
||||
*
|
||||
* @param resourceKey the key to count against
|
||||
*/
|
||||
public static final void resetCount(Object resourceKey)
|
||||
{
|
||||
AlfrescoTransactionSupport.unbindResource(resourceKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment a count value for named key
|
||||
*
|
||||
* @param resourceKey the key to count against
|
||||
* @return the newly-incremented value
|
||||
*/
|
||||
public static final int incrementCount(Object resourceKey)
|
||||
{
|
||||
MutableInt counter = (MutableInt) AlfrescoTransactionSupport.getResource(resourceKey);
|
||||
if (counter == null)
|
||||
{
|
||||
counter = new MutableInt(0);
|
||||
AlfrescoTransactionSupport.bindResource(resourceKey, counter);
|
||||
}
|
||||
counter.increment();
|
||||
return counter.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement a count value for a named key
|
||||
*
|
||||
* @param resourceKey the key to count against
|
||||
* @param allowNegative <tt>true</tt> to allow negative values otherwise zero will be the floor
|
||||
* @return the newly-decremented value (negative, if allowed)
|
||||
*/
|
||||
public static final int decrementCount(Object resourceKey, boolean allowNegative)
|
||||
{
|
||||
MutableInt counter = (MutableInt) AlfrescoTransactionSupport.getResource(resourceKey);
|
||||
if (counter == null)
|
||||
{
|
||||
counter = new MutableInt(0);
|
||||
AlfrescoTransactionSupport.bindResource(resourceKey, counter);
|
||||
}
|
||||
if (counter.intValue() > 0 || allowNegative)
|
||||
{
|
||||
counter.decrement();
|
||||
}
|
||||
return counter.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Support method to determine if there is already a resource associated with the
|
||||
* given key. This method allows quick conditional checking of the key without
|
||||
* building a new collection.
|
||||
*
|
||||
* @param resourceKey the key of the resource to check
|
||||
* @return <tt>true</tt> if a resource is already present at the key
|
||||
*/
|
||||
public static final boolean isResourcePresent(Object resourceKey)
|
||||
{
|
||||
Object resource = AlfrescoTransactionSupport.getResource(resourceKey);
|
||||
return resource != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support method to retrieve or create and bind a <tt>HashMap</tt> to the current transaction.
|
||||
*
|
||||
@@ -107,52 +186,4 @@ public abstract class TransactionalResourceHelper
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support method to set a boolean (true) value in the current transaction.
|
||||
* @param resourceKey the key under which the resource will be stored
|
||||
* @return true - the value of resourceKey, was set to true, false - the value was already true
|
||||
*/
|
||||
public static final boolean setBoolean(Object resourceKey)
|
||||
{
|
||||
Boolean value = AlfrescoTransactionSupport.getResource(resourceKey);
|
||||
if(value == null)
|
||||
{
|
||||
AlfrescoTransactionSupport.bindResource(resourceKey, Boolean.TRUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support method to reset (make false) a boolean value in the current transaction.
|
||||
* @param resourceKey the key under which the resource is stored.
|
||||
*/
|
||||
public static final void resetBoolean(Object resourceKey)
|
||||
{
|
||||
Boolean value = AlfrescoTransactionSupport.getResource(resourceKey);
|
||||
if(value == null)
|
||||
{
|
||||
AlfrescoTransactionSupport.unbindResource(resourceKey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is there a boolean value in the current transaction
|
||||
* @param resourceKey the key under which the resource will be stored
|
||||
* @return true - thre is, false no.
|
||||
*/
|
||||
public static final boolean testBoolean(Object resourceKey)
|
||||
{
|
||||
Boolean value = AlfrescoTransactionSupport.getResource(resourceKey);
|
||||
if(value == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user