RM-2130 (Check classification after method execution, filtering results where appropriate)

+review RM-94

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/ENFORCE@107009 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2015-06-24 19:39:48 +00:00
parent f1cb06d937
commit 662b0db31f
3 changed files with 87 additions and 6 deletions

View File

@@ -0,0 +1,81 @@
/*
* 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.module.org_alfresco_module_rm.classification.interceptor.processor;
import java.util.List;
import org.alfresco.query.PagingResults;
import org.alfresco.util.Pair;
/**
* PagingResults Post Method Invocation Processor
*
* @author Tuna Aksoy
* @since 3.0
*/
public class PagingResultsPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
{
/**
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
*/
@SuppressWarnings("rawtypes")
@Override
protected Class<PagingResults> getClassName()
{
return PagingResults.class;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public <T> T process(T object)
{
final PagingResults pagingResults = getClassName().cast(object);
List page = pagingResults.getPage();
final List processedPage = getPostMethodInvocationProcessor().process(page);
return (T) new PagingResults<T>()
{
@Override
public String getQueryExecutionId()
{
return pagingResults.getQueryExecutionId();
}
@Override
public List<T> getPage()
{
return processedPage;
}
@Override
public boolean hasMoreItems()
{
// FIXME: hasMoreItems might not be correct
return pagingResults.hasMoreItems();
}
@Override
public Pair<Integer, Integer> getTotalResultCount()
{
int size = processedPage.size();
return new Pair<Integer, Integer>(size, size);
}
};
}
}