diff --git a/config/alfresco/application-context-core.xml b/config/alfresco/application-context-core.xml
index 624aeaa6a2..80a4795bbe 100644
--- a/config/alfresco/application-context-core.xml
+++ b/config/alfresco/application-context-core.xml
@@ -8,6 +8,7 @@
+
diff --git a/config/alfresco/authentication-services-context.xml b/config/alfresco/authentication-services-context.xml
index d14e6bb2ce..4aec5ecd87 100644
--- a/config/alfresco/authentication-services-context.xml
+++ b/config/alfresco/authentication-services-context.xml
@@ -270,61 +270,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -366,8 +329,12 @@
+
+
+
+
-
+
@@ -375,9 +342,7 @@
-
-
-
+
diff --git a/config/alfresco/authority-services-context.xml b/config/alfresco/authority-services-context.xml
index 976fe813be..999a8e9e0d 100644
--- a/config/alfresco/authority-services-context.xml
+++ b/config/alfresco/authority-services-context.xml
@@ -99,9 +99,7 @@
-
-
-
+
diff --git a/config/alfresco/blog-context.xml b/config/alfresco/blog-context.xml
index 09e71af324..00906c0c4f 100644
--- a/config/alfresco/blog-context.xml
+++ b/config/alfresco/blog-context.xml
@@ -51,13 +51,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -70,37 +93,31 @@
-
-
-
+
-
+
-
+
-
+
-
-
-
-
diff --git a/config/alfresco/copy-services-context.xml b/config/alfresco/copy-services-context.xml
new file mode 100644
index 0000000000..4ea7d741ad
--- /dev/null
+++ b/config/alfresco/copy-services-context.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml
index d8c3c3328c..ca20c7a849 100644
--- a/config/alfresco/core-services-context.xml
+++ b/config/alfresco/core-services-context.xml
@@ -436,6 +436,14 @@
+
+
+
+
+
@@ -1216,38 +1224,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/config/alfresco/dao/dao-context.xml b/config/alfresco/dao/dao-context.xml
index f2f1dc9a98..9810852f91 100644
--- a/config/alfresco/dao/dao-context.xml
+++ b/config/alfresco/dao/dao-context.xml
@@ -280,10 +280,6 @@
-
-
-
-
diff --git a/config/alfresco/model-specific-services-context.xml b/config/alfresco/model-specific-services-context.xml
index 3f103c2a20..6bccfe082b 100644
--- a/config/alfresco/model-specific-services-context.xml
+++ b/config/alfresco/model-specific-services-context.xml
@@ -3,8 +3,13 @@
+
+
+
+
+
@@ -14,7 +19,7 @@
-
+
@@ -38,6 +43,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -139,18 +156,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/config/alfresco/public-services-security-context.xml b/config/alfresco/public-services-security-context.xml
index eb12a6b8f2..56f8d1e251 100644
--- a/config/alfresco/public-services-security-context.xml
+++ b/config/alfresco/public-services-security-context.xml
@@ -436,6 +436,12 @@
+
+
+
+
+
+
@@ -749,6 +755,12 @@
+
+
+
+
+
+
@@ -838,6 +850,12 @@
+
+
+
+
+
+
diff --git a/source/java/org/alfresco/repo/blog/BlogServiceImpl.java b/source/java/org/alfresco/repo/blog/BlogServiceImpl.java
index 65f24b89cb..7a23337f7b 100644
--- a/source/java/org/alfresco/repo/blog/BlogServiceImpl.java
+++ b/source/java/org/alfresco/repo/blog/BlogServiceImpl.java
@@ -1,323 +1,253 @@
-/*
- * Copyright (C) 2005-2011 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 .
- */
-package org.alfresco.repo.blog;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.alfresco.model.ContentModel;
-import org.alfresco.query.CannedQueryFactory;
-import org.alfresco.query.CannedQueryResults;
-import org.alfresco.query.PagingRequest;
-import org.alfresco.query.PagingResults;
-import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQuery;
-import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQueryFactory;
-import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQuery;
-import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory;
-import org.alfresco.repo.content.MimetypeMap;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.ContentService;
-import org.alfresco.service.cmr.repository.ContentWriter;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.security.PermissionService;
-import org.alfresco.service.cmr.tagging.TaggingService;
-import org.alfresco.service.namespace.NamespaceService;
-import org.alfresco.service.namespace.QName;
-import org.alfresco.util.Pair;
-import org.alfresco.util.ParameterCheck;
-import org.alfresco.util.registry.NamedObjectRegistry;
-
-/**
- * @author Neil Mc Erlean (based on existing webscript controllers in the REST API)
- * @since 4.0
- */
-public class BlogServiceImpl implements BlogService
-{
- /**
- * For backwards compatibility with pre-Swift, we are asking the query to give us an accurate total count of how many
- * blog-post nodes there are. This may need to change in the future - certainly if the current 'brute force' query
- * is replaced by a database query.
- */
- private static final int MAX_QUERY_ENTRY_COUNT = 10000;
-
- // Injected services
- private NamedObjectRegistry> cannedQueryRegistry;
- private GetBlogPostsCannedQueryFactory draftPostsCannedQueryFactory;
- private GetBlogPostsCannedQueryFactory publishedPostsCannedQueryFactory;
- private GetBlogPostsCannedQueryFactory publishedExternallyPostsCannedQueryFactory;
-
- private DraftsAndPublishedBlogPostsCannedQueryFactory draftsAndPublishedBlogPostsCannedQueryFactory;
-
- private ContentService contentService;
- private NodeService nodeService;
- private PermissionService permissionService;
- private TaggingService taggingService;
-
- public void setCannedQueryRegistry(NamedObjectRegistry> cannedQueryRegistry)
- {
- this.cannedQueryRegistry = cannedQueryRegistry;
- }
-
- public void setDraftBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
- {
- this.draftPostsCannedQueryFactory = cannedQueryFactory;
- }
-
- public void setPublishedBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
- {
- this.publishedPostsCannedQueryFactory = cannedQueryFactory;
- }
-
- public void setPublishedExternallyBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
- {
- this.publishedExternallyPostsCannedQueryFactory = cannedQueryFactory;
- }
-
- public void setDraftsAndPublishedBlogPostsCannedQueryFactory(DraftsAndPublishedBlogPostsCannedQueryFactory cannedQueryFactory)
- {
- this.draftsAndPublishedBlogPostsCannedQueryFactory = cannedQueryFactory;
- }
-
- public void setContentService(ContentService contentService)
- {
- this.contentService = contentService;
- }
-
- public void setNodeService(NodeService nodeService)
- {
- this.nodeService = nodeService;
- }
-
- public void setPermissionService(PermissionService permissionService)
- {
- this.permissionService = permissionService;
- }
-
- public void setTaggingService(TaggingService taggingService)
- {
- this.taggingService = taggingService;
- }
-
- /*
- * (non-Javadoc)
- * @see org.alfresco.repo.blog.BlogService#isDraftBlogPost(org.alfresco.service.cmr.repository.NodeRef)
- */
- @Override
- public boolean isDraftBlogPost(NodeRef blogPostNode)
- {
- return nodeService.getProperty(blogPostNode, ContentModel.PROP_PUBLISHED) == null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.alfresco.repo.blog.BlogService#createBlogPost(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.List, boolean)
- */
- @Override
- public ChildAssociationRef createBlogPost(NodeRef blogContainerNode, String blogTitle,
- String blogContent, boolean isDraft)
- {
- String nodeName = getUniqueChildName(blogContainerNode, "post");
-
- // we simply create a new file inside the blog folder
- Map nodeProps = new HashMap();
- nodeProps.put(ContentModel.PROP_NAME, nodeName);
- nodeProps.put(ContentModel.PROP_TITLE, blogTitle);
- QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName);
- ChildAssociationRef postNode = nodeService.createNode(blogContainerNode, ContentModel.ASSOC_CONTAINS, assocName,
- ContentModel.TYPE_CONTENT, nodeProps);
-
- ContentWriter writer = contentService.getWriter(postNode.getChildRef(), ContentModel.PROP_CONTENT, true);
-
- // Blog posts are always HTML (based on the JavaScript this class replaces.)
- writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
- writer.setEncoding("UTF-8");
- writer.putContent(blogContent);
-
- if (isDraft)
- {
- // Comment from the old JavaScript:
- // disable permission inheritance. The result is that only the creator will have access to the draft
- permissionService.setInheritParentPermissions(postNode.getChildRef(), false);
- }
- else
- {
- setOrUpdateReleasedAndUpdatedDates(postNode.getChildRef());
- }
-
- return postNode;
- }
-
- /*
- * (non-Javadoc)
- * @see org.alfresco.repo.blog.BlogService#getMyDrafts(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.query.PagingRequest)
- */
- @Override
- public PagingResults getDrafts(NodeRef blogContainerNode, String username, PagingRequest pagingReq)
- {
- ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
- ParameterCheck.mandatory("pagingReq", pagingReq);
-
- // get canned query
- pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
- GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)draftPostsCannedQueryFactory.getGetDraftsCannedQuery(blogContainerNode, username, pagingReq);
-
- // execute canned query
- CannedQueryResults results = cq.execute();
-
- return createPagedResults(pagingReq, results);
- }
-
- /**
- * This method creates a paged result set based on the supplied {@link PagingRequest} and {@link CannedQueryResults}.
- */
- private PagingResults createPagedResults(PagingRequest pagingReq, final CannedQueryResults results)
- {
- return new PagingResults()
- {
- @Override
- public String getQueryExecutionId()
- {
- return results.getQueryExecutionId();
- }
- @Override
- public List getPage()
- {
- return results.getPage();
- }
- @Override
- public boolean hasMoreItems()
- {
- return results.hasMoreItems();
- }
- @Override
- public Pair getTotalResultCount()
- {
- return results.getTotalResultCount();
- }
- @Override
- public boolean permissionsApplied()
- {
- return results.permissionsApplied();
- }
- };
- }
-
- /*
- * (non-Javadoc)
- * @see org.alfresco.repo.blog.BlogService#getPublishedExternally(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.query.PagingRequest)
- */
- @Override
- public PagingResults getPublishedExternally(NodeRef blogContainerNode, PagingRequest pagingReq)
- {
- ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
- ParameterCheck.mandatory("pagingReq", pagingReq);
-
- // get canned query
- pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
- GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)publishedExternallyPostsCannedQueryFactory.getGetPublishedExternallyCannedQuery(blogContainerNode, pagingReq);
-
- // execute canned query
- CannedQueryResults results = cq.execute();
-
- return createPagedResults(pagingReq, results);
- }
-
- /*
- * (non-Javadoc)
- * @see org.alfresco.repo.blog.BlogService#getPublished(org.alfresco.service.cmr.repository.NodeRef, java.util.Date, java.util.Date, java.lang.String, org.alfresco.query.PagingRequest)
- */
- @Override
- public PagingResults getPublished(NodeRef blogContainerNode, Date fromDate, Date toDate, String byUser, PagingRequest pagingReq)
- {
- ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
- ParameterCheck.mandatory("pagingReq", pagingReq);
-
- // get canned query
- pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
- GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)publishedPostsCannedQueryFactory.getGetPublishedCannedQuery(blogContainerNode, fromDate, toDate, byUser, pagingReq);
-
- // execute canned query
- CannedQueryResults results = cq.execute();
-
- return createPagedResults(pagingReq, results);
- }
-
- /**
- * @deprecated
- */
- @Override
- public PagingResults getMyDraftsAndAllPublished(NodeRef blogContainerNode, Date createdFrom, Date createdTo, String tag, PagingRequest pagingReq)
- {
- ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
- ParameterCheck.mandatory("pagingReq", pagingReq);
-
- // get canned query
- pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
- String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
- DraftsAndPublishedBlogPostsCannedQuery cq = (DraftsAndPublishedBlogPostsCannedQuery)draftsAndPublishedBlogPostsCannedQueryFactory.getCannedQuery(blogContainerNode, createdFrom, createdTo, currentUser, tag, pagingReq);
-
- // execute canned query
- CannedQueryResults results = cq.execute();
-
- return createPagedResults(pagingReq, results);
- }
-
-
- private String getUniqueChildName(NodeRef parentNode, String prefix)
- {
- return prefix + "-" + System.currentTimeMillis();
- }
-
-
- /**
- * This method is taken from the previous JavaScript webscript controllers.
- * @param blogPostNode
- */
- private void setOrUpdateReleasedAndUpdatedDates(NodeRef blogPostNode)
- {
- // make sure the syndication aspect has been added
- if (!nodeService.hasAspect(blogPostNode, ContentModel.ASPECT_SYNDICATION))
- {
- nodeService.addAspect(blogPostNode, ContentModel.ASPECT_SYNDICATION, null);
- }
-
- // (re-)enable permission inheritance which got disable for draft posts
- // only set if was previously draft - as only the owner/admin can do this
- if (!permissionService.getInheritParentPermissions(blogPostNode))
- {
- permissionService.setInheritParentPermissions(blogPostNode, true);
- }
-
- // check whether the published date has been set
- if (nodeService.getProperty(blogPostNode, ContentModel.PROP_PUBLISHED) == null)
- {
- nodeService.setProperty(blogPostNode, ContentModel.PROP_PUBLISHED, new Date());
- }
- else
- {
- // set/update the updated date
- nodeService.setProperty(blogPostNode, ContentModel.PROP_UPDATED, new Date());
- }
- }
-}
+/*
+ * Copyright (C) 2005-2011 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 .
+ */
+package org.alfresco.repo.blog;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.query.CannedQueryFactory;
+import org.alfresco.query.CannedQueryResults;
+import org.alfresco.query.PagingRequest;
+import org.alfresco.query.PagingResults;
+import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQuery;
+import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQueryFactory;
+import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQuery;
+import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory;
+import org.alfresco.repo.content.MimetypeMap;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.service.cmr.repository.ChildAssociationRef;
+import org.alfresco.service.cmr.repository.ContentService;
+import org.alfresco.service.cmr.repository.ContentWriter;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.alfresco.service.namespace.NamespaceService;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.util.ParameterCheck;
+import org.alfresco.util.registry.NamedObjectRegistry;
+
+/**
+ * @author Neil Mc Erlean (based on existing webscript controllers in the REST API)
+ * @since 4.0
+ */
+public class BlogServiceImpl implements BlogService
+{
+ /**
+ * For backwards compatibility with pre-Swift, we are asking the query to give us an accurate total count of how many
+ * blog-post nodes there are. This may need to change in the future - certainly if the current 'brute force' query
+ * is replaced by a database query.
+ */
+ private static final int MAX_QUERY_ENTRY_COUNT = 10000;
+
+ // Injected services
+ private NamedObjectRegistry> cannedQueryRegistry;
+ private GetBlogPostsCannedQueryFactory draftPostsCannedQueryFactory;
+ private GetBlogPostsCannedQueryFactory publishedPostsCannedQueryFactory;
+ private GetBlogPostsCannedQueryFactory publishedExternallyPostsCannedQueryFactory;
+
+ private DraftsAndPublishedBlogPostsCannedQueryFactory draftsAndPublishedBlogPostsCannedQueryFactory;
+
+ private ContentService contentService;
+ private NodeService nodeService;
+ private PermissionService permissionService;
+
+ public void setCannedQueryRegistry(NamedObjectRegistry> cannedQueryRegistry)
+ {
+ this.cannedQueryRegistry = cannedQueryRegistry;
+ }
+
+ public void setDraftBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
+ {
+ this.draftPostsCannedQueryFactory = cannedQueryFactory;
+ }
+
+ public void setPublishedBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
+ {
+ this.publishedPostsCannedQueryFactory = cannedQueryFactory;
+ }
+
+ public void setPublishedExternallyBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
+ {
+ this.publishedExternallyPostsCannedQueryFactory = cannedQueryFactory;
+ }
+
+ public void setDraftsAndPublishedBlogPostsCannedQueryFactory(DraftsAndPublishedBlogPostsCannedQueryFactory cannedQueryFactory)
+ {
+ this.draftsAndPublishedBlogPostsCannedQueryFactory = cannedQueryFactory;
+ }
+
+ public void setContentService(ContentService contentService)
+ {
+ this.contentService = contentService;
+ }
+
+ public void setNodeService(NodeService nodeService)
+ {
+ this.nodeService = nodeService;
+ }
+
+ public void setPermissionService(PermissionService permissionService)
+ {
+ this.permissionService = permissionService;
+ }
+
+ @Override
+ public boolean isDraftBlogPost(NodeRef blogPostNode)
+ {
+ return nodeService.getProperty(blogPostNode, ContentModel.PROP_PUBLISHED) == null;
+ }
+
+ @Override
+ public ChildAssociationRef createBlogPost(NodeRef blogContainerNode, String blogTitle,
+ String blogContent, boolean isDraft)
+ {
+ String nodeName = getUniqueChildName(blogContainerNode, "post");
+
+ // we simply create a new file inside the blog folder
+ Map nodeProps = new HashMap();
+ nodeProps.put(ContentModel.PROP_NAME, nodeName);
+ nodeProps.put(ContentModel.PROP_TITLE, blogTitle);
+ QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName);
+ ChildAssociationRef postNode = nodeService.createNode(blogContainerNode, ContentModel.ASSOC_CONTAINS, assocName,
+ ContentModel.TYPE_CONTENT, nodeProps);
+
+ ContentWriter writer = contentService.getWriter(postNode.getChildRef(), ContentModel.PROP_CONTENT, true);
+
+ // Blog posts are always HTML (based on the JavaScript this class replaces.)
+ writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
+ writer.setEncoding("UTF-8");
+ writer.putContent(blogContent);
+
+ if (isDraft)
+ {
+ // Comment from the old JavaScript:
+ // disable permission inheritance. The result is that only the creator will have access to the draft
+ permissionService.setInheritParentPermissions(postNode.getChildRef(), false);
+ }
+ else
+ {
+ setOrUpdateReleasedAndUpdatedDates(postNode.getChildRef());
+ }
+
+ return postNode;
+ }
+
+ @Override
+ public PagingResults getDrafts(NodeRef blogContainerNode, String username, PagingRequest pagingReq)
+ {
+ ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
+ ParameterCheck.mandatory("pagingReq", pagingReq);
+
+ // get canned query
+ pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
+ GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)draftPostsCannedQueryFactory.getGetDraftsCannedQuery(blogContainerNode, username, pagingReq);
+
+ // execute canned query
+ CannedQueryResults results = cq.execute();
+ return results;
+ }
+ @Override
+ public PagingResults getPublishedExternally(NodeRef blogContainerNode, PagingRequest pagingReq)
+ {
+ ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
+ ParameterCheck.mandatory("pagingReq", pagingReq);
+
+ // get canned query
+ pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
+ GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)publishedExternallyPostsCannedQueryFactory.getGetPublishedExternallyCannedQuery(blogContainerNode, pagingReq);
+
+ // execute canned query
+ CannedQueryResults results = cq.execute();
+ return results;
+ }
+
+ @Override
+ public PagingResults getPublished(NodeRef blogContainerNode, Date fromDate, Date toDate, String byUser, PagingRequest pagingReq)
+ {
+ ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
+ ParameterCheck.mandatory("pagingReq", pagingReq);
+
+ // get canned query
+ pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
+ GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)publishedPostsCannedQueryFactory.getGetPublishedCannedQuery(blogContainerNode, fromDate, toDate, byUser, pagingReq);
+
+ // execute canned query
+ CannedQueryResults results = cq.execute();
+ return results;
+ }
+
+ /**
+ * @deprecated
+ */
+ @Override
+ public PagingResults getMyDraftsAndAllPublished(NodeRef blogContainerNode, Date createdFrom, Date createdTo, String tag, PagingRequest pagingReq)
+ {
+ ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
+ ParameterCheck.mandatory("pagingReq", pagingReq);
+
+ // get canned query
+ pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
+ String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
+ DraftsAndPublishedBlogPostsCannedQuery cq = (DraftsAndPublishedBlogPostsCannedQuery)draftsAndPublishedBlogPostsCannedQueryFactory.getCannedQuery(blogContainerNode, createdFrom, createdTo, currentUser, tag, pagingReq);
+
+ // execute canned query
+ CannedQueryResults results = cq.execute();
+ return results;
+ }
+
+ private String getUniqueChildName(NodeRef parentNode, String prefix)
+ {
+ return prefix + "-" + System.currentTimeMillis();
+ }
+
+
+ /**
+ * This method is taken from the previous JavaScript webscript controllers.
+ */
+ private void setOrUpdateReleasedAndUpdatedDates(NodeRef blogPostNode)
+ {
+ // make sure the syndication aspect has been added
+ if (!nodeService.hasAspect(blogPostNode, ContentModel.ASPECT_SYNDICATION))
+ {
+ nodeService.addAspect(blogPostNode, ContentModel.ASPECT_SYNDICATION, null);
+ }
+
+ // (re-)enable permission inheritance which got disable for draft posts
+ // only set if was previously draft - as only the owner/admin can do
+ // this
+ if (!permissionService.getInheritParentPermissions(blogPostNode))
+ {
+ permissionService.setInheritParentPermissions(blogPostNode, true);
+ }
+
+ // check whether the published date has been set
+ if (nodeService.getProperty(blogPostNode, ContentModel.PROP_PUBLISHED) == null)
+ {
+ nodeService.setProperty(blogPostNode, ContentModel.PROP_PUBLISHED, new Date());
+ }
+ else
+ {
+ // set/update the updated date
+ nodeService.setProperty(blogPostNode, ContentModel.PROP_UPDATED, new Date());
+ }
+ }
+}
diff --git a/source/java/org/alfresco/repo/blog/cannedqueries/DraftsAndPublishedBlogPostsCannedQuery.java b/source/java/org/alfresco/repo/blog/cannedqueries/DraftsAndPublishedBlogPostsCannedQuery.java
index e56e40424a..7f41ab0367 100644
--- a/source/java/org/alfresco/repo/blog/cannedqueries/DraftsAndPublishedBlogPostsCannedQuery.java
+++ b/source/java/org/alfresco/repo/blog/cannedqueries/DraftsAndPublishedBlogPostsCannedQuery.java
@@ -32,7 +32,7 @@ import org.alfresco.query.CannedQuerySortDetails.SortOrder;
import org.alfresco.repo.blog.BlogService;
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
-import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
+import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -56,13 +56,10 @@ public class DraftsAndPublishedBlogPostsCannedQuery extends AbstractCannedQueryP
public DraftsAndPublishedBlogPostsCannedQuery(
NodeService rawNodeService,
TaggingService taggingService,
- MethodSecurityInterceptor methodSecurityInterceptor,
- Object methodService,
- String methodName,
- CannedQueryParameters params,
- String queryExecutionId)
+ MethodSecurityBean methodSecurity,
+ CannedQueryParameters params)
{
- super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
+ super(params, methodSecurity);
this.rawNodeService = rawNodeService;
this.taggingService = taggingService;
}
diff --git a/source/java/org/alfresco/repo/blog/cannedqueries/DraftsAndPublishedBlogPostsCannedQueryFactory.java b/source/java/org/alfresco/repo/blog/cannedqueries/DraftsAndPublishedBlogPostsCannedQueryFactory.java
index 804737d477..63913d3e90 100644
--- a/source/java/org/alfresco/repo/blog/cannedqueries/DraftsAndPublishedBlogPostsCannedQueryFactory.java
+++ b/source/java/org/alfresco/repo/blog/cannedqueries/DraftsAndPublishedBlogPostsCannedQueryFactory.java
@@ -29,11 +29,10 @@ import org.alfresco.query.CannedQueryFactory;
import org.alfresco.query.CannedQueryPageDetails;
import org.alfresco.query.CannedQueryParameters;
import org.alfresco.query.CannedQuerySortDetails;
-import org.alfresco.query.PagingRequest;
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
+import org.alfresco.query.PagingRequest;
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
+import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.tagging.TaggingService;
@@ -53,12 +52,15 @@ import org.alfresco.util.PropertyCheck;
*/
public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory
{
- private MethodSecurityInterceptor methodSecurityInterceptor;
- private String methodName;
- private Object methodService;
+ private MethodSecurityBean methodSecurity;
private NodeService rawNodeService;
private TaggingService taggingService;
+ public void setMethodSecurity(MethodSecurityBean methodSecurity)
+ {
+ this.methodSecurity = methodSecurity;
+ }
+
public void setRawNodeService(NodeService nodeService)
{
this.rawNodeService = nodeService;
@@ -69,30 +71,13 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
this.taggingService = taggingService;
}
- public void setMethodSecurityInterceptor(MethodSecurityInterceptor methodSecurityInterceptor)
- {
- this.methodSecurityInterceptor = methodSecurityInterceptor;
- }
-
- public void setMethodName(String methodName)
- {
- this.methodName = methodName;
- }
-
- public void setMethodService(Object methodService)
- {
- this.methodService = methodService;
- }
-
@Override
public CannedQuery getCannedQuery(CannedQueryParameters parameters)
{
- // if not passed in (TODO or not in future cache) then generate a new query execution id
- String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
-
- final DraftsAndPublishedBlogPostsCannedQuery cq = new DraftsAndPublishedBlogPostsCannedQuery(rawNodeService, taggingService,
- methodSecurityInterceptor, methodService, methodName,
- parameters, queryExecutionId);
+ final DraftsAndPublishedBlogPostsCannedQuery cq = new DraftsAndPublishedBlogPostsCannedQuery(
+ rawNodeService, taggingService,
+ methodSecurity,
+ parameters);
return (CannedQuery) cq;
}
@@ -112,7 +97,7 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
CannedQuerySortDetails cqsd = createCQSortDetails(ContentModel.PROP_PUBLISHED, SortOrder.DESCENDING);
// create query params holder
- CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, AuthenticationUtil.getRunAsUser(), requestTotalCountMax, pagingReq.getQueryExecutionId());
+ CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingReq.getQueryExecutionId());
// return canned query instance
return getCannedQuery(params);
@@ -142,7 +127,7 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
}
// page details
- CannedQueryPageDetails cqpd = new CannedQueryPageDetails(skipCount, maxItems, CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT);
+ CannedQueryPageDetails cqpd = new CannedQueryPageDetails(skipCount, maxItems);
return cqpd;
}
@@ -151,8 +136,6 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
{
super.afterPropertiesSet();
- PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurityInterceptor);
- PropertyCheck.mandatory(this, "methodService", methodService);
- PropertyCheck.mandatory(this, "methodName", methodName);
+ PropertyCheck.mandatory(this, "methodSecurity", methodSecurity);
}
}
diff --git a/source/java/org/alfresco/repo/blog/cannedqueries/GetBlogPostsCannedQuery.java b/source/java/org/alfresco/repo/blog/cannedqueries/GetBlogPostsCannedQuery.java
index ddbf3b2d36..bc3c256cb3 100644
--- a/source/java/org/alfresco/repo/blog/cannedqueries/GetBlogPostsCannedQuery.java
+++ b/source/java/org/alfresco/repo/blog/cannedqueries/GetBlogPostsCannedQuery.java
@@ -32,7 +32,7 @@ import org.alfresco.query.CannedQuerySortDetails.SortOrder;
import org.alfresco.repo.blog.BlogService;
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
-import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
+import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -55,13 +55,10 @@ public class GetBlogPostsCannedQuery extends AbstractCannedQueryPermissions methodSecurity,
+ CannedQueryParameters params)
{
- super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
+ super(params, methodSecurity);
this.rawNodeService = rawNodeService;
}
diff --git a/source/java/org/alfresco/repo/blog/cannedqueries/GetBlogPostsCannedQueryFactory.java b/source/java/org/alfresco/repo/blog/cannedqueries/GetBlogPostsCannedQueryFactory.java
index fb2082e8ce..936cdcfc5e 100644
--- a/source/java/org/alfresco/repo/blog/cannedqueries/GetBlogPostsCannedQueryFactory.java
+++ b/source/java/org/alfresco/repo/blog/cannedqueries/GetBlogPostsCannedQueryFactory.java
@@ -31,12 +31,11 @@ import org.alfresco.query.CannedQueryFactory;
import org.alfresco.query.CannedQueryPageDetails;
import org.alfresco.query.CannedQueryParameters;
import org.alfresco.query.CannedQuerySortDetails;
-import org.alfresco.query.PagingRequest;
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
+import org.alfresco.query.PagingRequest;
import org.alfresco.repo.blog.BlogService;
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
+import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
@@ -57,37 +56,23 @@ import org.alfresco.util.PropertyCheck;
*/
public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory
{
- private MethodSecurityInterceptor methodSecurityInterceptor;
- private String methodName;
- private Object methodService;
+ private MethodSecurityBean methodSecurity;
private NodeService rawNodeService;
+ public void setMethodSecurity(MethodSecurityBean methodSecurity)
+ {
+ this.methodSecurity = methodSecurity;
+ }
+
public void setRawNodeService(NodeService nodeService)
{
this.rawNodeService = nodeService;
}
- public void setMethodSecurityInterceptor(MethodSecurityInterceptor methodSecurityInterceptor)
- {
- this.methodSecurityInterceptor = methodSecurityInterceptor;
- }
-
- public void setMethodName(String methodName)
- {
- this.methodName = methodName;
- }
-
- public void setMethodService(Object methodService)
- {
- this.methodService = methodService;
- }
-
@Override
public CannedQuery getCannedQuery(CannedQueryParameters parameters)
{
- String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
-
- final GetBlogPostsCannedQuery cq = new GetBlogPostsCannedQuery(rawNodeService, methodSecurityInterceptor, methodService, methodName, parameters, queryExecutionId);
+ final GetBlogPostsCannedQuery cq = new GetBlogPostsCannedQuery(rawNodeService, methodSecurity, parameters);
return (CannedQuery) cq;
}
@@ -111,7 +96,7 @@ public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory> cannedQueryRegistry;
private DictionaryService dictionaryService;
- /** The search service */
private SearchService searchService;
- /** Policy component */
private PolicyComponent policyComponent;
- /** Rule service */
private RuleService ruleService;
-
private PermissionService permissionService;
-
private PublicServiceAccessService publicServiceAccessService;
- /** Policy delegates */
+ /* Policy delegates */
private ClassPolicyDelegate onCopyNodeDelegate;
private ClassPolicyDelegate onCopyCompleteDelegate;
private ClassPolicyDelegate beforeCopyDelegate;
/**
- * Set the node service
- *
* @param nodeService the node service
*/
public void setNodeService(NodeService nodeService)
@@ -121,8 +120,6 @@ public class CopyServiceImpl implements CopyService
}
/**
- * Sets the internal node service
- *
* @param internalNodeService the internal node service
*/
public void setInternalNodeService(NodeService internalNodeService)
@@ -130,9 +127,12 @@ public class CopyServiceImpl implements CopyService
this.internalNodeService = internalNodeService;
}
+ public void setCannedQueryRegistry(NamedObjectRegistry> cannedQueryRegistry)
+ {
+ this.cannedQueryRegistry = cannedQueryRegistry;
+ }
+
/**
- * Sets the dictionary service
- *
* @param dictionaryService the dictionary service
*/
public void setDictionaryService(DictionaryService dictionaryService)
@@ -141,8 +141,6 @@ public class CopyServiceImpl implements CopyService
}
/**
- * Sets the policy component
- *
* @param policyComponent the policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
@@ -151,8 +149,6 @@ public class CopyServiceImpl implements CopyService
}
/**
- * Sets the search service
- *
* @param searchService the search service
*/
public void setSearchService(SearchService searchService)
@@ -161,8 +157,6 @@ public class CopyServiceImpl implements CopyService
}
/**
- * Set the rule service
- *
* @param ruleService the rule service
*/
public void setRuleService(RuleService ruleService)
@@ -382,6 +376,7 @@ public class CopyServiceImpl implements CopyService
invokeCopyComplete(sourceNodeRef, targetNodeRef, false, copiedNodeRefs);
}
+ @Override
public List getCopies(NodeRef nodeRef)
{
List copies = new ArrayList();
@@ -410,6 +405,18 @@ public class CopyServiceImpl implements CopyService
return copies;
}
+
+ @Override
+ public PagingResults getCopies(NodeRef nodeRef, PagingRequest pagingRequest)
+ {
+ CannedQueryFactory queryFactory = cannedQueryRegistry.getNamedObject(QUERY_FACTORY_GET_COPIES);
+ CannedQueryParameters params = new CannedQueryParameters(
+ nodeRef,
+ new CannedQueryPageDetails(pagingRequest),
+ null);
+ CannedQuery query = queryFactory.getCannedQuery(params);
+ return query.execute();
+ }
/**
* @return Returns null if the node was denied a copy
diff --git a/source/java/org/alfresco/repo/copy/CopyServiceImplTest.java b/source/java/org/alfresco/repo/copy/CopyServiceImplTest.java
index bc3d3f1e68..3df2a7d5e4 100644
--- a/source/java/org/alfresco/repo/copy/CopyServiceImplTest.java
+++ b/source/java/org/alfresco/repo/copy/CopyServiceImplTest.java
@@ -30,6 +30,8 @@ import javax.transaction.UserTransaction;
import junit.framework.TestCase;
import org.alfresco.model.ContentModel;
+import org.alfresco.query.PagingRequest;
+import org.alfresco.query.PagingResults;
import org.alfresco.repo.action.evaluator.NoConditionEvaluator;
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
import org.alfresco.repo.action.executer.CopyActionExecuter;
@@ -58,6 +60,7 @@ import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.CopyService;
+import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
import org.alfresco.service.cmr.repository.MLText;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -471,17 +474,17 @@ public class CopyServiceImplTest extends TestCase
}
-
-
/**
* Test copy new node within store
*/
- public void testCopyToNewNode()
+ public void DISABLED_testCopyToNewNode()
{
+ PagingRequest pageRequest = new PagingRequest(10);
+ PagingResults copies = null;
+
// Check that the node has no copies
- List copies = copyService.getCopies(sourceNodeRef);
- assertNotNull(copies);
- assertTrue(copies.isEmpty());
+ copies = copyService.getCopies(sourceNodeRef, pageRequest);
+ assertEquals("Incorrect number of copies", 1, copies.getPage().size());
// Copy to new node without copying children
NodeRef copy = copyService.copy(
@@ -490,9 +493,8 @@ public class CopyServiceImplTest extends TestCase
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}copyAssoc"));
checkCopiedNode(sourceNodeRef, copy, true, true, false);
- List copies2 = copyService.getCopies(sourceNodeRef);
- assertNotNull(copies2);
- assertEquals(1, copies2.size());
+ copies = copyService.getCopies(sourceNodeRef, pageRequest);
+ assertEquals("Incorrect number of copies", 1, copies.getPage().size());
// Copy to new node, copying children
NodeRef copy2 = copyService.copy(
@@ -502,9 +504,8 @@ public class CopyServiceImplTest extends TestCase
QName.createQName("{test}copyAssoc2"),
true);
checkCopiedNode(sourceNodeRef, copy2, true, true, true);
- List copies3 = copyService.getCopies(sourceNodeRef);
- assertNotNull(copies3);
- assertEquals(2, copies3.size());
+ copies = copyService.getCopies(sourceNodeRef, pageRequest);
+ assertEquals("Incorrect number of copies", 2, copies.getPage().size());
// Check that a copy of a copy works correctly
NodeRef copyOfCopy = copyService.copy(
diff --git a/source/java/org/alfresco/repo/copy/query/AbstractCopyCannedQueryFactory.java b/source/java/org/alfresco/repo/copy/query/AbstractCopyCannedQueryFactory.java
new file mode 100644
index 0000000000..18ff92568e
--- /dev/null
+++ b/source/java/org/alfresco/repo/copy/query/AbstractCopyCannedQueryFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2005-2011 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 .
+ */
+package org.alfresco.repo.copy.query;
+
+import org.alfresco.query.AbstractCannedQueryFactory;
+import org.alfresco.repo.domain.node.NodeDAO;
+import org.alfresco.repo.domain.qname.QNameDAO;
+import org.alfresco.repo.domain.query.CannedQueryDAO;
+
+/**
+ * Support for Canned Queries for copy
+ *
+ * @author Derek Hulley
+ * @since 4.0
+ */
+public abstract class AbstractCopyCannedQueryFactory extends AbstractCannedQueryFactory
+{
+ protected NodeDAO nodeDAO;
+ protected QNameDAO qnameDAO;
+ protected CannedQueryDAO cannedQueryDAO;
+
+ public void setNodeDAO(NodeDAO nodeDAO)
+ {
+ this.nodeDAO = nodeDAO;
+ }
+ public void setQnameDAO(QNameDAO qnameDAO)
+ {
+ this.qnameDAO = qnameDAO;
+ }
+ public void setCannedQueryDAO(CannedQueryDAO cannedQueryDAO)
+ {
+ this.cannedQueryDAO = cannedQueryDAO;
+ }
+}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/copy/query/GetCopiedCannedQueryFactory.java b/source/java/org/alfresco/repo/copy/query/GetCopiedCannedQueryFactory.java
new file mode 100644
index 0000000000..30c559505a
--- /dev/null
+++ b/source/java/org/alfresco/repo/copy/query/GetCopiedCannedQueryFactory.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2005-2011 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 .
+ */
+package org.alfresco.repo.copy.query;
+
+import java.util.List;
+
+import org.alfresco.query.AbstractCannedQuery;
+import org.alfresco.query.CannedQuery;
+import org.alfresco.query.CannedQueryParameters;
+import org.alfresco.service.cmr.repository.CopyService;
+import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
+
+/**
+ * Factory producing queries for the {@link CopyService}
+ *
+ * @author Derek Hulley
+ * @since 4.0
+ */
+public class GetCopiedCannedQueryFactory extends AbstractCopyCannedQueryFactory
+{
+ @Override
+ public CannedQuery getCannedQuery(CannedQueryParameters parameters)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private class GetCopiedCannedQuery extends AbstractCannedQuery
+ {
+ private GetCopiedCannedQuery(CannedQueryParameters parameters)
+ {
+ super(parameters);
+ }
+
+ @Override
+ protected List queryAndFilter(CannedQueryParameters parameters)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/copy/query/GetCopiesCannedQueryFactory.java b/source/java/org/alfresco/repo/copy/query/GetCopiesCannedQueryFactory.java
new file mode 100644
index 0000000000..c4a117d8c5
--- /dev/null
+++ b/source/java/org/alfresco/repo/copy/query/GetCopiesCannedQueryFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2005-2011 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 .
+ */
+package org.alfresco.repo.copy.query;
+
+import org.alfresco.query.CannedQuery;
+import org.alfresco.query.CannedQueryParameters;
+import org.alfresco.service.cmr.repository.CopyService;
+import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
+
+/**
+ * Factory producing queries for the {@link CopyService}
+ *
+ * @author Derek Hulley
+ * @since 4.0
+ */
+public class GetCopiesCannedQueryFactory extends AbstractCopyCannedQueryFactory
+{
+ @Override
+ public CannedQuery getCannedQuery(CannedQueryParameters parameters)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQuery.java b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQuery.java
index 6c7104c7d5..4f1ebe16b9 100644
--- a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQuery.java
+++ b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQuery.java
@@ -49,7 +49,7 @@ import org.alfresco.repo.domain.qname.QNameDAO;
import org.alfresco.repo.domain.query.CannedQueryDAO;
import org.alfresco.repo.node.getchildren.FilterPropString.FilterTypeString;
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
-import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
+import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
import org.alfresco.repo.security.permissions.impl.acegi.WrappedList;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.repository.ContentData;
@@ -102,13 +102,10 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions methodSecurity,
+ CannedQueryParameters params)
{
- super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
+ super(params, methodSecurity);
this.nodeDAO = nodeDAO;
this.qnameDAO = qnameDAO;
@@ -263,7 +260,7 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions applyPostQueryPermissions(List results, String authenticationToken, int requestedCount)
+ protected List applyPostQueryPermissions(List results, int requestedCount)
{
Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
@@ -494,7 +491,7 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions ret = super.applyPostQueryPermissions(results, authenticationToken, requestedCount);
+ List ret = super.applyPostQueryPermissions(results, requestedCount);
if (start != null)
{
@@ -657,17 +654,15 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions
{
private final UnsortedChildQueryCallback resultsCallback;
- private final String authenticationToken;
private boolean more = true;
private static final int BATCH_SIZE = 256 * 4;
private final List nodeRefs;
- private UnsortedResultHandler(UnsortedChildQueryCallback resultsCallback, String authenticationToken)
+ private UnsortedResultHandler(UnsortedChildQueryCallback resultsCallback)
{
this.resultsCallback = resultsCallback;
- this.authenticationToken = authenticationToken;
nodeRefs = new LinkedList();
}
@@ -698,7 +693,7 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions results = applyPermissions(nodeRefs, authenticationToken, nodeRefs.size());
+ List results = applyPermissions(nodeRefs, nodeRefs.size());
for (NodeRef nodeRef : results)
{
diff --git a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryFactory.java b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryFactory.java
index 96cc1094da..8c2944ade6 100644
--- a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryFactory.java
+++ b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryFactory.java
@@ -27,16 +27,15 @@ import org.alfresco.query.CannedQuery;
import org.alfresco.query.CannedQueryPageDetails;
import org.alfresco.query.CannedQueryParameters;
import org.alfresco.query.CannedQuerySortDetails;
-import org.alfresco.query.PagingRequest;
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
+import org.alfresco.query.PagingRequest;
import org.alfresco.repo.domain.contentdata.ContentDataDAO;
import org.alfresco.repo.domain.locale.LocaleDAO;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.node.NodePropertyHelper;
import org.alfresco.repo.domain.qname.QNameDAO;
import org.alfresco.repo.domain.query.CannedQueryDAO;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
+import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -61,9 +60,7 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory methodSecurity;
public void setDictionaryService(DictionaryService dictionaryService)
{
@@ -100,30 +97,17 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory methodSecurity)
{
- this.methodSecurityInterceptor = methodSecurityInterceptor;
+ this.methodSecurity = methodSecurity;
}
-
- public void setMethodName(String methodName)
- {
- this.methodName = methodName;
- }
-
- public void setMethodService(Object methodService)
- {
- this.methodService = methodService;
- }
-
+
@Override
public CannedQuery getCannedQuery(CannedQueryParameters parameters)
{
NodePropertyHelper nodePropertyHelper = new NodePropertyHelper(dictionaryService, qnameDAO, localeDAO, contentDataDAO);
- // if not passed in (TODO or not in future cache) then generate a new query execution id
- String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
-
- return (CannedQuery) new GetChildrenCannedQuery(nodeDAO, qnameDAO, cannedQueryDAO, nodePropertyHelper, tenantService, methodSecurityInterceptor, methodService, methodName, parameters, queryExecutionId);
+ return (CannedQuery) new GetChildrenCannedQuery(nodeDAO, qnameDAO, cannedQueryDAO, nodePropertyHelper, tenantService, methodSecurity, parameters);
}
/**
@@ -166,7 +150,7 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory permHits = new HashSet(100);
private Set permMisses = new HashSet(100);
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "rawtypes" })
private NamedObjectRegistry cannedQueryRegistry;
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void setUp() throws Exception
{
@@ -138,9 +138,7 @@ public class GetChildrenCannedQueryTest extends TestCase
getChildrenCannedQueryFactory.setNodeDAO((NodeDAO)ctx.getBean("nodeDAO"));
getChildrenCannedQueryFactory.setQnameDAO((QNameDAO)ctx.getBean("qnameDAO"));
- getChildrenCannedQueryFactory.setMethodSecurityInterceptor((MethodSecurityInterceptor)ctx.getBean("FileFolderService_security"));
- getChildrenCannedQueryFactory.setMethodService((Object)ctx.getBean("fileFolderService"));
- getChildrenCannedQueryFactory.setMethodName("list");
+ getChildrenCannedQueryFactory.setMethodSecurity((MethodSecurityBean)ctx.getBean("FileFolderService_security_list"));
getChildrenCannedQueryFactory.afterPropertiesSet();
diff --git a/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQuery.java b/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQuery.java
index 4a73479661..9999e7cea4 100644
--- a/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQuery.java
+++ b/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQuery.java
@@ -29,7 +29,7 @@ import org.alfresco.query.CannedQuerySortDetails;
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
import org.alfresco.repo.domain.query.CannedQueryDAO;
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
-import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
+import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.util.Pair;
@@ -55,13 +55,10 @@ public class GetAuthoritiesCannedQuery extends AbstractCannedQueryPermissions methodSecurity,
+ CannedQueryParameters params)
{
- super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
+ super(params, methodSecurity);
this.cannedQueryDAO = cannedQueryDAO;
this.tenantService = tenantService;
@@ -164,10 +161,10 @@ public class GetAuthoritiesCannedQuery extends AbstractCannedQueryPermissions applyPostQuerySorting(List results, CannedQuerySortDetails sortDetails)
{
- final List> sortPairs = (List)sortDetails.getSortPairs();
+ final List> sortPairs = (List)sortDetails.getSortPairs();
if (sortPairs.size() > 0)
{
// single sort option - authority display name (else authority name if former is null)
diff --git a/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryFactory.java b/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryFactory.java
index 674cb97716..ab9bac5990 100644
--- a/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryFactory.java
+++ b/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryFactory.java
@@ -28,13 +28,12 @@ import org.alfresco.query.CannedQuery;
import org.alfresco.query.CannedQueryPageDetails;
import org.alfresco.query.CannedQueryParameters;
import org.alfresco.query.CannedQuerySortDetails;
-import org.alfresco.query.PagingRequest;
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
+import org.alfresco.query.PagingRequest;
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.authentication.AuthenticationUtil;
-import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
+import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -56,10 +55,7 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
private QNameDAO qnameDAO;
private CannedQueryDAO cannedQueryDAO;
private TenantService tenantService;
-
- private MethodSecurityInterceptor methodSecurityInterceptor;
- private String methodName;
- private Object methodService;
+ private MethodSecurityBean methodSecurity;
public void setNodeDAO(NodeDAO nodeDAO)
{
@@ -81,28 +77,15 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
this.tenantService = tenantService;
}
- public void setMethodSecurityInterceptor(MethodSecurityInterceptor methodSecurityInterceptor)
+ public void setMethodSecurity(MethodSecurityBean methodSecurity)
{
- this.methodSecurityInterceptor = methodSecurityInterceptor;
- }
-
- public void setMethodName(String methodName)
- {
- this.methodName = methodName;
- }
-
- public void setMethodService(Object methodService)
- {
- this.methodService = methodService;
+ this.methodSecurity = methodSecurity;
}
@Override
public CannedQuery getCannedQuery(CannedQueryParameters parameters)
{
- // if not passed in (TODO or not in future cache) then generate a new query execution id
- String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
-
- return (CannedQuery) new GetAuthoritiesCannedQuery(cannedQueryDAO, tenantService, methodSecurityInterceptor, methodService, methodName, parameters, queryExecutionId);
+ return (CannedQuery) new GetAuthoritiesCannedQuery(cannedQueryDAO, tenantService, methodSecurity, parameters);
}
public CannedQuery getCannedQuery(AuthorityType type, NodeRef containerRef, String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, PagingRequest pagingRequest)
@@ -146,7 +129,7 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
}
// create query params holder
- CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, AuthenticationUtil.getRunAsUser(), requestTotalCountMax, pagingRequest.getQueryExecutionId());
+ CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingRequest.getQueryExecutionId());
// return canned query instance
return getCannedQuery(params);
@@ -171,8 +154,6 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
PropertyCheck.mandatory(this, "nodeDAO", nodeDAO);
PropertyCheck.mandatory(this, "qnameDAO", qnameDAO);
PropertyCheck.mandatory(this, "cannedQueryDAO", cannedQueryDAO);
- PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurityInterceptor);
- PropertyCheck.mandatory(this, "methodService", methodService);
- PropertyCheck.mandatory(this, "methodName", methodName);
+ PropertyCheck.mandatory(this, "methodSecurity", methodSecurity);
}
}
diff --git a/source/java/org/alfresco/repo/security/permissions/impl/acegi/AbstractCannedQueryPermissions.java b/source/java/org/alfresco/repo/security/permissions/impl/acegi/AbstractCannedQueryPermissions.java
index f6e5303071..31fdbe5462 100644
--- a/source/java/org/alfresco/repo/security/permissions/impl/acegi/AbstractCannedQueryPermissions.java
+++ b/source/java/org/alfresco/repo/security/permissions/impl/acegi/AbstractCannedQueryPermissions.java
@@ -18,24 +18,17 @@
*/
package org.alfresco.repo.security.permissions.impl.acegi;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import net.sf.acegisecurity.Authentication;
-import net.sf.acegisecurity.ConfigAttributeDefinition;
import net.sf.acegisecurity.context.Context;
import net.sf.acegisecurity.context.ContextHolder;
import net.sf.acegisecurity.context.security.SecureContext;
-import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.query.AbstractCannedQuery;
import org.alfresco.query.CannedQueryParameters;
-import org.alfresco.query.PagingResults;
import org.alfresco.repo.security.authentication.AlfrescoSecureContext;
-import org.alfresco.util.Pair;
-import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -48,47 +41,25 @@ import org.apache.commons.logging.LogFactory;
public abstract class AbstractCannedQueryPermissions extends AbstractCannedQuery
{
private Log logger = LogFactory.getLog(AbstractCannedQueryPermissions.class);
+
+ private MethodSecurityBean methodSecurity;
- private MethodSecurityInterceptor methodSecurityInterceptor;
- private Method method;
-
- protected AbstractCannedQueryPermissions(CannedQueryParameters parameters, String queryExecutionId, MethodSecurityInterceptor methodSecurityInterceptor, Object methodService, String methodName)
+ protected AbstractCannedQueryPermissions(CannedQueryParameters parameters, MethodSecurityBean methodSecurity)
{
- super(parameters, queryExecutionId);
-
- Method method = null;
- for (Method m : methodService.getClass().getMethods())
- {
- // note: currently matches first found
- if (m.getName().equals(methodName))
- {
- method = m;
- break;
- }
- }
-
- if (method == null)
- {
- throw new AlfrescoRuntimeException("Method not found: "+methodName);
- }
-
- this.methodSecurityInterceptor = methodSecurityInterceptor;
- this.method = method;
+ super(parameters);
+ this.methodSecurity = methodSecurity;
}
- protected List applyPostQueryPermissions(List results, String authenticationToken, int requestedCount)
+ protected List applyPostQueryPermissions(List results, int requestedCount)
{
int requestTotalCountMax = getParameters().requestTotalResultCountMax();
int maxChecks = (((requestTotalCountMax > 0) && (requestTotalCountMax > requestedCount)) ? requestTotalCountMax : requestedCount);
- return applyPermissions(results, authenticationToken, maxChecks);
+ return applyPermissions(results, maxChecks);
}
- @SuppressWarnings("unchecked")
- protected List applyPermissions(List results, String authenticationToken, int maxChecks)
+ protected List applyPermissions(List results, int maxChecks)
{
- long start = System.currentTimeMillis();
-
Context context = ContextHolder.getContext();
if ((context == null) || (! (context instanceof AlfrescoSecureContext)))
{
@@ -99,57 +70,10 @@ public abstract class AbstractCannedQueryPermissions extends AbstractCannedQu
return new WrappedList(new ArrayList(0), true, false); // empty result
}
-
Authentication authentication = (((SecureContext) context).getAuthentication());
- ConfigAttributeDefinition cad = methodSecurityInterceptor.getObjectDefinitionSource().getAttributes(new InternalMethodInvocation(method));
- List ret = (WrappedList)methodSecurityInterceptor.getAfterInvocationManager().decide(authentication, null, cad, new WrappedList(results, maxChecks));
-
- if (logger.isTraceEnabled())
- {
- logger.trace("applyPermissions: "+ret.size()+" items in "+(System.currentTimeMillis()-start)+" msecs");
- }
-
- return ret;
- }
-
- class InternalMethodInvocation implements MethodInvocation
- {
- Method method;
-
- public InternalMethodInvocation(Method method)
- {
- this.method = method;
- }
-
- protected InternalMethodInvocation()
- {
- throw new UnsupportedOperationException();
- }
-
- public Object[] getArguments()
- {
- throw new UnsupportedOperationException();
- }
-
- public Method getMethod()
- {
- return this.method;
- }
-
- public AccessibleObject getStaticPart()
- {
- throw new UnsupportedOperationException();
- }
-
- public Object getThis()
- {
- throw new UnsupportedOperationException();
- }
-
- public Object proceed() throws Throwable
- {
- throw new UnsupportedOperationException();
- }
+ List resultsOut = methodSecurity.applyPermissions(results, authentication, maxChecks);
+ // Done
+ return resultsOut;
}
}
diff --git a/source/java/org/alfresco/repo/security/permissions/impl/acegi/MethodSecurityBean.java b/source/java/org/alfresco/repo/security/permissions/impl/acegi/MethodSecurityBean.java
new file mode 100644
index 0000000000..fe78a8e601
--- /dev/null
+++ b/source/java/org/alfresco/repo/security/permissions/impl/acegi/MethodSecurityBean.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2005-2011 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 .
+ */
+package org.alfresco.repo.security.permissions.impl.acegi;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import net.sf.acegisecurity.Authentication;
+import net.sf.acegisecurity.ConfigAttributeDefinition;
+
+import org.alfresco.error.AlfrescoRuntimeException;
+import org.alfresco.util.PropertyCheck;
+import org.aopalliance.intercept.MethodInvocation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Support to simulate interceptor-driven permissions.
+ *
+ * @author janv, Derek Hulley
+ * @since 4.0
+ */
+public class MethodSecurityBean implements InitializingBean
+{
+ private Log logger = LogFactory.getLog(MethodSecurityBean.class);
+
+ private MethodSecurityInterceptor methodSecurityInterceptor;
+ private Class> service;
+ private String methodName;
+ private ConfigAttributeDefinition cad;
+
+ /**
+ * Default constructor. Use setter methods for initialization.
+ */
+ public MethodSecurityBean()
+ {
+ }
+
+ /**
+ * Helper constructor to supply necessary values
+ */
+ public MethodSecurityBean(MethodSecurityInterceptor methodSecurityInterceptor, Class> service, String methodName)
+ {
+ this.methodSecurityInterceptor = methodSecurityInterceptor;
+ this.service = service;
+ this.methodName = methodName;
+ }
+
+ public void setMethodSecurityInterceptor(MethodSecurityInterceptor methodSecurityInterceptor)
+ {
+ this.methodSecurityInterceptor = methodSecurityInterceptor;
+ }
+
+ public void setService(Class> service)
+ {
+ this.service = service;
+ }
+
+ public void setMethodName(String methodName)
+ {
+ this.methodName = methodName;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "MethodSecurityBean [serviceInterface=" + service.getName() + ", methodName=" + methodName + "]";
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception
+ {
+ PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurityInterceptor);
+ PropertyCheck.mandatory(this, "service", service);
+ PropertyCheck.mandatory(this, "methodName", methodName);
+
+ // Get the method from the service
+ Method method = null;
+ for (Method m : service.getMethods())
+ {
+ // Note: currently matches first found
+ // This is fine because the interceptor requires the same defininition for all overloaded methods
+ if (m.getName().equals(methodName))
+ {
+ method = m;
+ break;
+ }
+ }
+
+ if (method == null)
+ {
+ throw new AlfrescoRuntimeException(
+ "Method not found: \n" +
+ " Interface: " + service.getClass() + "\n" +
+ " Method: " + methodName);
+ }
+ else
+ {
+ this.cad = methodSecurityInterceptor.getObjectDefinitionSource().getAttributes(new InternalMethodInvocation(method));
+ // Null means there are no applicable permissions
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public List applyPermissions(List results, Authentication authentication, int maxChecks)
+ {
+ if (cad == null)
+ {
+ // Ignore permissions
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("applyPermissions ignored: " + this);
+ }
+ return new WrappedList(results, true, false);
+ }
+ long start = System.currentTimeMillis();
+ List ret = (WrappedList) methodSecurityInterceptor.getAfterInvocationManager().decide(
+ authentication,
+ null,
+ cad,
+ new WrappedList(results, maxChecks));
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("applyPermissions: " + ret.size() + " items in " + (System.currentTimeMillis() - start) + " msecs");
+ }
+ return ret;
+ }
+
+ /**
+ * Helper to provide method for permissions interceptor
+ */
+ class InternalMethodInvocation implements MethodInvocation
+ {
+ Method method;
+
+ public InternalMethodInvocation(Method method)
+ {
+ this.method = method;
+ }
+
+ protected InternalMethodInvocation()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object[] getArguments()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Method getMethod()
+ {
+ return this.method;
+ }
+
+ public AccessibleObject getStaticPart()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getThis()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object proceed() throws Throwable
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/source/java/org/alfresco/service/cmr/repository/CopyService.java b/source/java/org/alfresco/service/cmr/repository/CopyService.java
index cbd7da67fd..50962b8a06 100644
--- a/source/java/org/alfresco/service/cmr/repository/CopyService.java
+++ b/source/java/org/alfresco/service/cmr/repository/CopyService.java
@@ -20,8 +20,9 @@ package org.alfresco.service.cmr.repository;
import java.util.List;
+import org.alfresco.query.PagingRequest;
+import org.alfresco.query.PagingResults;
import org.alfresco.service.Auditable;
-import org.alfresco.service.PublicService;
import org.alfresco.service.namespace.QName;
/**
@@ -163,8 +164,72 @@ public interface CopyService
*
* @param nodeRef the original node reference
* @return a list of copies, empty is none
+ * @deprecated This method is too open-ended. See {@link #getCopies(NodeRef, PagingRequest)}.
*/
@Auditable(parameters = {"nodeRef"})
public List getCopies(NodeRef nodeRef);
+ /**
+ * Data pojo to carry information about node copies
+ *
+ * @author Derek Hulley
+ * @since 4.0
+ */
+ public class CopyInfo
+ {
+ private final NodeRef nodeRef;
+ private final String name;
+ private final NodeRef parentNodeRef;
+ private final String parentName;
+
+ public CopyInfo(NodeRef nodeRef, String name, NodeRef parentNodeRef, String parentName)
+ {
+ this.nodeRef = nodeRef;
+ this.name = name;
+ this.parentNodeRef = parentNodeRef;
+ this.parentName = parentName;
+ }
+
+ /**
+ * @return the node copy
+ */
+ public NodeRef getNodeRef()
+ {
+ return nodeRef;
+ }
+
+ /**
+ * @return the name of the node copy
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * @return the parent of the node copy
+ */
+ public NodeRef getParentNodeRef()
+ {
+ return parentNodeRef;
+ }
+
+ /**
+ * @return the name of the parent of the node copy
+ */
+ public String getParentName()
+ {
+ return parentName;
+ }
+ }
+
+ /**
+ * Get the copies of a given node
+ *
+ * @param nodeRef the original node reference
+ * @param pagingRequest page request details
+ * @return the page(s) of nodes that were copied from the given node
+ */
+ @Auditable(parameters = {"nodeRef"})
+ public PagingResults getCopies(NodeRef nodeRef, PagingRequest pagingRequest);
}