mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125781 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
98 lines
3.3 KiB
Java
98 lines
3.3 KiB
Java
|
|
package org.alfresco.repo.node.archive;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
import org.alfresco.query.CannedQueryParameters;
|
|
import org.alfresco.repo.domain.node.NodeDAO;
|
|
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
|
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
/**
|
|
* Canned query for archived nodes.
|
|
*
|
|
* @author Jamal Kaabi-Mofrad
|
|
* @since 4.2
|
|
*/
|
|
public class GetArchivedNodesCannedQuery extends AbstractCannedQueryPermissions<ArchivedNodeEntity>
|
|
{
|
|
private Log logger = LogFactory.getLog(GetArchivedNodesCannedQuery.class);
|
|
|
|
private static final String QUERY_NAMESPACE = "alfresco.query.archivednodes";
|
|
private static final String QUERY_SELECT_GET_ARCHIVED_NODES = "select_GetArchivedNodesCannedQuery";
|
|
|
|
private CannedQueryDAO cannedQueryDAO;
|
|
private NodeDAO nodeDAO;
|
|
|
|
public GetArchivedNodesCannedQuery(CannedQueryDAO cannedQueryDAO, NodeDAO nodeDAO,
|
|
MethodSecurityBean<ArchivedNodeEntity> methodSecurity, CannedQueryParameters params)
|
|
{
|
|
super(params, methodSecurity);
|
|
this.cannedQueryDAO = cannedQueryDAO;
|
|
this.nodeDAO = nodeDAO;
|
|
|
|
}
|
|
|
|
@Override
|
|
protected List<ArchivedNodeEntity> queryAndFilter(CannedQueryParameters parameters)
|
|
{
|
|
Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
|
|
|
|
Object paramBeanObj = parameters.getParameterBean();
|
|
if (paramBeanObj == null)
|
|
throw new NullPointerException("Null GetArchivedNodes query params");
|
|
|
|
// Get parameters
|
|
GetArchivedNodesCannedQueryParams paramBean = (GetArchivedNodesCannedQueryParams) paramBeanObj;
|
|
|
|
if (paramBean.getParentNodeId() == null || paramBean.getParentNodeId() < 0)
|
|
{
|
|
return Collections.emptyList();
|
|
}
|
|
|
|
int resultsRequired = parameters.getResultsRequired();
|
|
paramBean.setLimit(resultsRequired);
|
|
|
|
// note: refer to SQL for specific DB filtering and sorting
|
|
List<ArchivedNodeEntity> results = cannedQueryDAO.executeQuery(QUERY_NAMESPACE,
|
|
QUERY_SELECT_GET_ARCHIVED_NODES, paramBean, 0, Integer.MAX_VALUE);
|
|
|
|
List<NodeRef> nodeRefs = new ArrayList<NodeRef>(results.size());
|
|
for (ArchivedNodeEntity entity : results)
|
|
{
|
|
nodeRefs.add(entity.getNodeRef());
|
|
}
|
|
|
|
// preload the node for later when we want to get the properties of the node
|
|
preload(nodeRefs);
|
|
|
|
if (start != null)
|
|
{
|
|
logger.debug("Base query: " + nodeRefs.size() + " in "
|
|
+ (System.currentTimeMillis() - start) + " msecs");
|
|
}
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
private void preload(List<NodeRef> nodeRefs)
|
|
{
|
|
Long start = (logger.isTraceEnabled() ? System.currentTimeMillis() : null);
|
|
|
|
nodeDAO.cacheNodes(nodeRefs);
|
|
|
|
if (start != null)
|
|
{
|
|
logger.trace("Pre-load: " + nodeRefs.size() + " in "
|
|
+ (System.currentTimeMillis() - start) + " msecs");
|
|
}
|
|
}
|
|
}
|