mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merge V1.4 to HEAD
- Ignored Enterprise-specific changes svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3701 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3703 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3704 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3705 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3707 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3876 . svn revert root\projects\web-client\source\web\jsp\admin\admin-console.jsp git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3879 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -88,6 +88,8 @@ public class IntegrityChecker
|
||||
|
||||
/** key against which the set of events is stored in the current transaction */
|
||||
private static final String KEY_EVENT_SET = "IntegrityChecker.EventSet";
|
||||
/** key to store the local flag to disable integrity errors, i.e. downgrade to warnings */
|
||||
private static final String KEY_WARN_IN_TRANSACTION = "IntegrityChecker.WarnInTransaction";
|
||||
|
||||
private PolicyComponent policyComponent;
|
||||
private DictionaryService dictionaryService;
|
||||
@@ -97,6 +99,36 @@ public class IntegrityChecker
|
||||
private int maxErrorsPerTransaction;
|
||||
private boolean traceOn;
|
||||
|
||||
/**
|
||||
* Downgrade violations to warnings within the current transaction. This is temporary and
|
||||
* is <u>dependent on there being a current transaction</u> active against the
|
||||
* current thread. When set, this will override the global
|
||||
* {@link #setFailOnViolation(boolean) failure behaviour}.
|
||||
*/
|
||||
public static void setWarnInTransaction()
|
||||
{
|
||||
AlfrescoTransactionSupport.bindResource(KEY_WARN_IN_TRANSACTION, Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns true if the current transaction should only warn on violations.
|
||||
* If <code>false</code>, the global setting will take effect.
|
||||
*
|
||||
* @see #setWarnInTransaction()
|
||||
*/
|
||||
public static boolean isWarnInTransaction()
|
||||
{
|
||||
Boolean warnInTransaction = (Boolean) AlfrescoTransactionSupport.getResource(KEY_WARN_IN_TRANSACTION);
|
||||
if (warnInTransaction == null || warnInTransaction == Boolean.FALSE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public IntegrityChecker()
|
||||
@@ -572,7 +604,8 @@ public class IntegrityChecker
|
||||
}
|
||||
sb.append("\n").append(failure);
|
||||
}
|
||||
if (failOnViolation)
|
||||
boolean warnOnly = IntegrityChecker.isWarnInTransaction();
|
||||
if (failOnViolation && !warnOnly)
|
||||
{
|
||||
logger.error(sb.toString());
|
||||
throw new IntegrityException(failures);
|
||||
|
@@ -198,6 +198,18 @@ public class IntegrityTest extends TestCase
|
||||
assertNotNull("Static IntegrityChecker not created", integrityChecker);
|
||||
}
|
||||
|
||||
public void testTemporaryDowngrading() throws Exception
|
||||
{
|
||||
assertEquals("Per-transaction override not correct", false, IntegrityChecker.isWarnInTransaction());
|
||||
// create bad node
|
||||
NodeRef nodeRef = createNode("abc", TEST_TYPE_WITH_PROPERTIES, null);
|
||||
// switch it off
|
||||
IntegrityChecker.setWarnInTransaction();
|
||||
assertEquals("Per-transaction override not correct", true, IntegrityChecker.isWarnInTransaction());
|
||||
// now, only warnings should occur
|
||||
checkIntegrityNoFailure();
|
||||
}
|
||||
|
||||
public void testCreateWithoutProperties() throws Exception
|
||||
{
|
||||
NodeRef nodeRef = createNode("abc", TEST_TYPE_WITH_PROPERTIES, null);
|
||||
|
Reference in New Issue
Block a user