mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV to HEAD
- ALF-8806 RINF 41: Lucene Removal: Fix CopyService - ALF-9028: RINF 41: Fix Aspect cm:copiedFrom - ALF-9029 RINF 49: Lucene Removal: CheckOutCheckInService API - ALF-9032: RINF 49: fixes to cm:workingcopy aspect 28996: Dev branch for De-Lucene work pending patches 29004: Evaluator runs in read-only txn 29006: Additional PermissionCheckedCollection.create method - Use an existing collection's permission check data (cut-off, etc) to wrap a new collection 29007: CopyService and CheckOutCheckInService refactors to remove Lucene CopyService: Removed cm:source property from cm:copiedfrom aspect and replaced with a cm:original association. Added CQ-based APIs to query for copies Added APIs to support bi-directional walking of copy association Fixed sundry uses of cm:copiedfrom esp. all uses related to cm:workingcopy CheckOutCheckInService: Check-out now creates a source aspect cm:checkedOut with 1:1 relationship to cm:workingcopy via cm:workingcopylink Removed explicit use of cm:workingcopy aspect and replaced it with calls to COCI API 29083: Audit tests fail when indexing is turned off. Also removed a getReader() call during rule evaluation, leading to a 'sub-action' read being recorded. 29113: NodeDAO.getNodesWithAspects supports paging 29135: Removed unused patch queries 29139: Basic patch (still terminates with error) to upgrade cm:copiedfrom and cm:workingcopy 29157: Tested patch for cm:copiedfrom and cm:workingcopy aspects git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29159 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,9 +19,13 @@
|
||||
package org.alfresco.repo.copy.query;
|
||||
|
||||
import org.alfresco.query.AbstractCannedQueryFactory;
|
||||
import org.alfresco.query.CannedQueryParameters;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||
import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Support for Canned Queries for copy
|
||||
@@ -34,6 +38,7 @@ public abstract class AbstractCopyCannedQueryFactory<R> extends AbstractCannedQu
|
||||
protected NodeDAO nodeDAO;
|
||||
protected QNameDAO qnameDAO;
|
||||
protected CannedQueryDAO cannedQueryDAO;
|
||||
protected MethodSecurityBean<CopyInfo> methodSecurity;
|
||||
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
@@ -47,4 +52,56 @@ public abstract class AbstractCopyCannedQueryFactory<R> extends AbstractCannedQu
|
||||
{
|
||||
this.cannedQueryDAO = cannedQueryDAO;
|
||||
}
|
||||
|
||||
public void setMethodSecurity(MethodSecurityBean<CopyInfo> methodSecurity)
|
||||
{
|
||||
this.methodSecurity = methodSecurity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter bean to use for copy queries
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 4.0
|
||||
*/
|
||||
public static class CopyCannedQueryDetail
|
||||
{
|
||||
/*package*/ final NodeRef originalNodeRef;
|
||||
/*package*/ final NodeRef copyParentNodeRef;
|
||||
/**
|
||||
* @param originalNodeRef the original node
|
||||
*/
|
||||
public CopyCannedQueryDetail(NodeRef originalNodeRef)
|
||||
{
|
||||
this(originalNodeRef, null);
|
||||
}
|
||||
/**
|
||||
* @param originalNodeRef the original node
|
||||
* @param copyParentNodeRef the copied node's primary parent (optional)
|
||||
* @param copyNodeAspectsToIgnore aspects on the copied node that effectively hide it
|
||||
* (<tt>null</tt> or empty allowed)
|
||||
*/
|
||||
public CopyCannedQueryDetail(NodeRef originalNodeRef, NodeRef copyParentNodeRef)
|
||||
{
|
||||
super();
|
||||
if (originalNodeRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Must supply an originalNodeRef");
|
||||
}
|
||||
this.originalNodeRef = originalNodeRef;
|
||||
this.copyParentNodeRef = copyParentNodeRef;
|
||||
}
|
||||
}
|
||||
|
||||
protected CopyCannedQueryDetail getDetail(CannedQueryParameters parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (CopyCannedQueryDetail) parameters.getParameterBean();
|
||||
}
|
||||
catch (ClassCastException e)
|
||||
{
|
||||
throw new IllegalArgumentException("Expected " + CopyCannedQueryDetail.class);
|
||||
}
|
||||
}
|
||||
}
|
50
source/java/org/alfresco/repo/copy/query/CopyEntity.java
Normal file
50
source/java/org/alfresco/repo/copy/query/CopyEntity.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 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.repo.copy.query;
|
||||
|
||||
import org.alfresco.repo.domain.node.NodeEntity;
|
||||
|
||||
/**
|
||||
* Bean class to data about copied nodes
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 4.0
|
||||
*/
|
||||
public class CopyEntity
|
||||
{
|
||||
private NodeEntity copy;
|
||||
private String copyName;
|
||||
|
||||
public NodeEntity getCopy()
|
||||
{
|
||||
return copy;
|
||||
}
|
||||
public void setCopy(NodeEntity copy)
|
||||
{
|
||||
this.copy = copy;
|
||||
}
|
||||
public String getCopyName()
|
||||
{
|
||||
return copyName;
|
||||
}
|
||||
public void setCopyName(String copyName)
|
||||
{
|
||||
this.copyName = copyName;
|
||||
}
|
||||
}
|
@@ -29,7 +29,8 @@ import java.util.List;
|
||||
public class CopyParametersEntity
|
||||
{
|
||||
private Long originalNodeId;
|
||||
private Long copiedFromAssocTypeId;
|
||||
private Long originalAssocTypeId;
|
||||
private Long namePropId;
|
||||
private Long copyParentNodeId;
|
||||
private List<Long> copyAspectIdsToIgnore;
|
||||
|
||||
@@ -41,13 +42,21 @@ public class CopyParametersEntity
|
||||
{
|
||||
this.originalNodeId = originalNodeId;
|
||||
}
|
||||
public Long getCopiedFromAssocTypeId()
|
||||
public Long getOriginalAssocTypeId()
|
||||
{
|
||||
return copiedFromAssocTypeId;
|
||||
return originalAssocTypeId;
|
||||
}
|
||||
public void setCopiedFromAssocTypeId(Long copiedFromAssocTypeId)
|
||||
public void setOriginalAssocTypeId(Long originalAssocTypeId)
|
||||
{
|
||||
this.copiedFromAssocTypeId = copiedFromAssocTypeId;
|
||||
this.originalAssocTypeId = originalAssocTypeId;
|
||||
}
|
||||
public Long getNamePropId()
|
||||
{
|
||||
return namePropId;
|
||||
}
|
||||
public void setNamePropId(Long namePropId)
|
||||
{
|
||||
this.namePropId = namePropId;
|
||||
}
|
||||
public Long getCopyParentNodeId()
|
||||
{
|
||||
@@ -65,4 +74,8 @@ public class CopyParametersEntity
|
||||
{
|
||||
this.copyAspectIdsToIgnore = copyAspectIdsToIgnore;
|
||||
}
|
||||
public boolean getTrue()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -18,10 +18,20 @@
|
||||
*/
|
||||
package org.alfresco.repo.copy.query;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.CannedQuery;
|
||||
import org.alfresco.query.CannedQueryParameters;
|
||||
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||
import org.alfresco.service.cmr.repository.CopyService;
|
||||
import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* Factory producing queries for the {@link CopyService}
|
||||
@@ -34,6 +44,75 @@ public class GetCopiesCannedQueryFactory extends AbstractCopyCannedQueryFactory<
|
||||
@Override
|
||||
public CannedQuery<CopyInfo> getCannedQuery(CannedQueryParameters parameters)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
return new GetCopiesCannedQuery(parameters, methodSecurity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query to find nodes copied <i>from</i> a given node, optionally filtering out
|
||||
* based on specific values.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 4.0
|
||||
*/
|
||||
private class GetCopiesCannedQuery extends AbstractCannedQueryPermissions<CopyInfo>
|
||||
{
|
||||
private GetCopiesCannedQuery(CannedQueryParameters parameters, MethodSecurityBean<CopyInfo> methodSecurity)
|
||||
{
|
||||
super(parameters, methodSecurity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<CopyInfo> queryAndFilter(CannedQueryParameters parameters)
|
||||
{
|
||||
CopyCannedQueryDetail detail = GetCopiesCannedQueryFactory.this.getDetail(parameters);
|
||||
// Build parameters
|
||||
CopyParametersEntity queryParameters = new CopyParametersEntity();
|
||||
// Original node
|
||||
Pair<Long, NodeRef> originalNodePair = nodeDAO.getNodePair(detail.originalNodeRef);
|
||||
if (originalNodePair == null)
|
||||
{
|
||||
return Collections.emptyList(); // Shortcut
|
||||
}
|
||||
queryParameters.setOriginalNodeId(originalNodePair.getFirst());
|
||||
// cm:original association type ID
|
||||
Pair<Long, QName> assocTypeQNamePair = qnameDAO.getQName(ContentModel.ASSOC_ORIGINAL);
|
||||
if (assocTypeQNamePair == null)
|
||||
{
|
||||
return Collections.emptyList(); // Shortcut
|
||||
}
|
||||
queryParameters.setOriginalAssocTypeId(assocTypeQNamePair.getFirst());
|
||||
// cm:name property ID
|
||||
Pair<Long, QName> propQNamePair = qnameDAO.getQName(ContentModel.PROP_NAME);
|
||||
if (propQNamePair == null)
|
||||
{
|
||||
return Collections.emptyList(); // Shortcut
|
||||
}
|
||||
queryParameters.setNamePropId(propQNamePair.getFirst());
|
||||
// Copied parent node
|
||||
if (detail.copyParentNodeRef != null)
|
||||
{
|
||||
Pair<Long, NodeRef> copyParentNodePair = nodeDAO.getNodePair(detail.copyParentNodeRef);
|
||||
if (copyParentNodePair == null)
|
||||
{
|
||||
return Collections.emptyList(); // Shortcut
|
||||
}
|
||||
queryParameters.setCopyParentNodeId(copyParentNodePair.getFirst());
|
||||
}
|
||||
// Now query
|
||||
int resultsRequired = parameters.getResultsRequired();
|
||||
List<CopyEntity> copies = cannedQueryDAO.executeQuery(
|
||||
"alfresco.query.copy", "select_GetCopies",
|
||||
queryParameters,
|
||||
0, resultsRequired);
|
||||
// Convert them
|
||||
List<CopyInfo> results = new ArrayList<CopyService.CopyInfo>(copies.size());
|
||||
for (CopyEntity copy : copies)
|
||||
{
|
||||
CopyInfo result = new CopyInfo(copy.getCopy().getNodeRef(), copy.getCopyName());
|
||||
results.add(result);
|
||||
}
|
||||
// Done
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user