Merge remote-tracking branch 'origin/master' into feature/RM-3039_AikauUpgrade

This commit is contained in:
David Webster
2016-02-24 22:35:23 +00:00
4 changed files with 111 additions and 20 deletions

View File

@@ -108,7 +108,7 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
*
* @return job query string
*/
private String getQuery()
protected String getQuery()
{
if (query == null)
{
@@ -133,8 +133,8 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
}
sb.append("))");
sb.append(" AND ISNULL:\"rma:dispositionActionCompletedAt\" ");
sb.append(" + ( ");
sb.append(" AND ISUNSET:\"rma:dispositionActionCompletedAt\" ");
sb.append(" AND ( ");
sb.append("@rma\\:dispositionEventsEligible:true ");
sb.append("OR @rma\\:dispositionAsOf:[MIN TO NOW] ");
sb.append(") ");

View File

@@ -228,24 +228,33 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
* @param typeQName
* @return
*/
private boolean shouldRuleBeAppliedToNode(Rule rule, NodeRef nodeRef, QName typeQName)
private boolean shouldRuleBeAppliedToNode(final Rule rule, final NodeRef nodeRef, final QName typeQName)
{
boolean result = true;
NodeRef ruleNodeRef = getOwningNodeRef(rule);
if(filePlanService.isFilePlan(ruleNodeRef))
return AuthenticationUtil.runAsSystem(new RunAsWork<Boolean>()
{
// if this rule is defined at the root of the file plan then we do not want to apply
// it to holds/transfers/unfiled content...
result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName) ||
RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName) ||
RecordsManagementModel.TYPE_TRANSFER.equals(typeQName) ||
RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(typeQName) ||
RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER.equals(typeQName) ||
RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) ||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRING) ||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) ||
!recordService.isFiled(nodeRef));
}
return result;
public Boolean doWork() throws Exception
{
boolean result = true;
NodeRef ruleNodeRef = getOwningNodeRef(rule);
if (filePlanService.isFilePlan(ruleNodeRef))
{
// if this rule is defined at the root of the file plan then
// we do not want to apply
// it to holds/transfers/unfiled content...
result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName)
|| RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName)
|| RecordsManagementModel.TYPE_TRANSFER.equals(typeQName)
|| RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(typeQName)
|| RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER
.equals(typeQName)
|| RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName)
|| nodeService.hasAspect(nodeRef,
RecordsManagementModel.ASPECT_TRANSFERRING)
|| nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN)
|| !recordService.isFiled(nodeRef));
}
return result;
}
});
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2005-2016 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.util;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Enumeration for sort direction.
*
* @author Tuna Aksoy
* @since 2.5
*/
public enum SortDirection
{
ASC ("asc"),
DESC ("desc");
/** A string representation of the sort direction. */
private final String sortDirection;
private SortDirection(String sortDirection)
{
this.sortDirection = sortDirection;
}
/**
* Get the appropriate {@code SortDirection} from a string representation.
*
* @param sortDirectionString A string representation (case will be ignored).
* @return The {@code SortDirection} value.
*/
public static SortDirection getSortDirection(String sortDirectionString)
{
SortDirection sortDirection = null;
for (SortDirection value : values())
{
if (value.sortDirection.equalsIgnoreCase(sortDirectionString))
{
sortDirection = value;
break;
}
}
if (sortDirection == null)
{
throw new AlfrescoRuntimeException("Sort direction '" + sortDirection +"' unknown.");
}
return sortDirection;
}
}

View File

@@ -19,6 +19,7 @@
package org.alfresco.module.org_alfresco_module_rm.job;
import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateQName;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMap;
import static org.mockito.Matchers.anyString;
@@ -229,4 +230,17 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
// ensure no more interactions
verifyNoMoreInteractions(mockedNodeService, mockedRecordsManagementActionService);
}
/**
* Brittle unit test that simply checks the generated query is an exact string when the supplied disposition actions
* are "CUTOFF" and "RETAIN" (see {@link #before}).
*/
@Test
public void testGetQuery()
{
String actual = executer.getQuery();
String expected = "TYPE:\"rma:dispositionAction\" + (@rma\\:dispositionAction:(\"cutoff\" OR \"retain\")) AND ISUNSET:\"rma:dispositionActionCompletedAt\" AND ( @rma\\:dispositionEventsEligible:true OR @rma\\:dispositionAsOf:[MIN TO NOW] ) ";
assertEquals(expected, actual);
}
}