ALF-10429 / ALF-10413 - Start to refactor the blog service to match the other new services, as a precursor to fixing the paging bug

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31166 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-10-12 13:01:23 +00:00
parent df96dd8e68
commit 33289cbe68
10 changed files with 295 additions and 46 deletions

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.blog;
import java.io.Serializable;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.permissions.PermissionCheckValue;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* This class represents a blog post in a blog.
*
* @author Neil Mc Erlean
* @since 4.0
*/
public interface BlogPostInfo extends Serializable, PermissionCheckValue
{
/**
* Gets the NodeRef representing this blog-post.
*/
NodeRef getNodeRef();
/**
* @return the NodeRef of the container this belongs to (Site or Otherwise)
*/
NodeRef getContainerNodeRef();
/**
* Gets the {@link ContentModel#PROP_NAME cm:name} of the blog post.
*/
String getSystemName();
/**
* @return the Title of the blog post.
*/
String getTitle();
// TODO Remaining fields
}

View File

@@ -24,7 +24,6 @@ import org.alfresco.model.ContentModel;
import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults;
import org.alfresco.repo.blog.BlogIntegrationService;
import org.alfresco.repo.security.permissions.PermissionCheckValue;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteService;
@@ -42,6 +41,20 @@ import org.alfresco.service.namespace.QName;
*/
public interface BlogService
{
/**
* Creates a new blog post in the specified site
*
* @param siteShortName the name of the site to add the post to.
* @param blogTitle the title of the blog post.
* @param blogContent text/html content of the blog post.
* @param isDraft <tt>true</tt> if the blog post is a draft post, else <tt>false</tt>.
*
* @return The {@link BlogPostInfo} of the newly created blog post.
*
* @see SiteService#getContainer(String, String) to retrieve the blogContainerNode
*/
BlogPostInfo createBlogPost(String siteShortName, String blogTitle, String blogContent, boolean isDraft);
/**
* Creates a new blog post within the specified container node.
*
@@ -56,6 +69,31 @@ public interface BlogService
*/
BlogPostInfo createBlogPost(NodeRef blogContainerNode, String blogTitle, String blogContent, boolean isDraft);
/**
* Updates an existing {@link BlogPostInfo} in the repository.
*
* @return The updated {@link BlogPostInfo}
*/
BlogPostInfo updateBlogPost(BlogPostInfo post);
/**
* Deletes an existing {@link BlogPostInfo} from the repository.
*/
void deleteBlogPost(BlogPostInfo post);
/**
* Gets the draft blog posts created by the specified user.
*
* @param siteShortName the name of the site to add the post to.
* @param username to limit results to blogs with this cm:creator. <tt>null</tt> means all users.
* @param pagingReq an object defining the paging parameters for the result set.
*
* @return a {@link PagingResults} object containing some or all of the results (subject to paging).
*
* @see SiteService#getContainer(String, String) to retrieve the blogContainerNode
*/
PagingResults<BlogPostInfo> getDrafts(String siteShortName, String username, PagingRequest pagingReq);
/**
* Gets the draft blog posts created by the specified user.
*
@@ -69,6 +107,22 @@ public interface BlogService
*/
PagingResults<BlogPostInfo> getDrafts(NodeRef blogContainerNode, String username, PagingRequest pagingReq);
/**
* Gets the (internally, Alfresco-) published blog posts.
*
* @param siteShortName the name of the site to add the post to.
* @param fromDate an inclusive date limit for the results (more recent than).
* @param toDate an inclusive date limit for the results (before).
* @param byUser if not <tt>null</tt> limits results to posts by the specified user.
* if <tt>null</tt> results will be by all users.
* @param pagingReq an object defining the paging parameters for the result set.
*
* @return a {@link PagingResults} object containing some or all of the results (subject to paging).
*
* @see SiteService#getContainer(String, String) to retrieve the blogContainerNode
*/
PagingResults<BlogPostInfo> getPublished(String siteShortName, Date fromDate, Date toDate, String byUser, PagingRequest pagingReq);
/**
* Gets the (internally, Alfresco-) published blog posts.
*
@@ -85,6 +139,18 @@ public interface BlogService
*/
PagingResults<BlogPostInfo> getPublished(NodeRef blogContainerNode, Date fromDate, Date toDate, String byUser, PagingRequest pagingReq);
/**
* Gets blog posts published externally (i.e. to an external blog hosting site).
*
* @param siteShortName the name of the site to add the post to.
* @param pagingReq an object defining the paging parameters for the result set.
*
* @return a {@link PagingResults} object containing some or all of the results (subject to paging).
*
* @see SiteService#getContainer(String, String) to retrieve the blogContainerNode
*/
PagingResults<BlogPostInfo> getPublishedExternally(String siteShortName, PagingRequest pagingReq);
/**
* Gets blog posts published externally (i.e. to an external blog hosting site).
*
@@ -113,6 +179,22 @@ public interface BlogService
*/
PagingResults<BlogPostInfo> getMyDraftsAndAllPublished(NodeRef blogContainerNode, Date fromDate, Date toDate, PagingRequest pagingReq);
/**
* Finds blog posts by the specified user tagged with the given tag string. This method allows date ranges to be applied to any valid
* {@link DataTypeDefinition#DATE} or {@link DataTypeDefinition#DATETIME} property. Examples include {@link ContentModel#PROP_CREATED} or
* {@link ContentModel#PROP_PUBLISHED}.
*
* @param siteShortName the name of the site to add the post to.
* @param dateRange a {@link RangedDateProperty} parameter object. Can be null.
* @param tag tag string.
* @param pagingReq an object defining the paging parameters for the result set.
*
* @return a {@link PagingResults} object containing some or all of the results (subject to paging).
*
* @see SiteService#getContainer(String, String) to retrieve the blogContainerNode
*/
PagingResults<BlogPostInfo> findBlogPosts(String siteShortName, RangedDateProperty dateRange, String tag, PagingRequest pagingReq);
/**
* Finds blog posts by the specified user tagged with the given tag string. This method allows date ranges to be applied to any valid
* {@link DataTypeDefinition#DATE} or {@link DataTypeDefinition#DATETIME} property. Examples include {@link ContentModel#PROP_CREATED} or
@@ -134,44 +216,11 @@ public interface BlogService
*
* @param blogPostNode a NodeRef representing a blog-post.
* @return <tt>true</tt> if it is a draft post, else <tt>false</tt>.
*
* @deprecated Add this to the BlogPostInfo shortly
*/
boolean isDraftBlogPost(NodeRef blogPostNode);
/**
* A simple data object for storage of blog-related data.
*
* @author Neil Mc Erlean
* @since 4.0
*/
public class BlogPostInfo implements PermissionCheckValue
{
private final NodeRef nodeRef;
private final String name;
public BlogPostInfo(NodeRef nodeRef, String name)
{
this.nodeRef = nodeRef;
this.name = name;
}
/**
* Gets the NodeRef representing this blog-post.
*/
@Override
public NodeRef getNodeRef()
{
return nodeRef;
}
/**
* Gets the {@link ContentModel#PROP_NAME cm:name} of the blog post.
* @return
*/
public String getName()
{
return name;
}
}
/**
* A simple data object for expressing a date range search parameter.
*/