mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-10429 / ALF-10413 - Implement the site related methods on BlogService
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31173 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,8 +66,11 @@
|
||||
<property name="dictionaryService" ref="DictionaryService"/>
|
||||
<property name="namespaceService" ref="NamespaceService"/>
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="permissionService" ref="PermissionService"/>
|
||||
<property name="siteService" ref="SiteService"/>
|
||||
<property name="searchService" ref="SearchService"/>
|
||||
<property name="taggingService" ref="TaggingService"/>
|
||||
<property name="permissionService" ref="PermissionService"/>
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
|
||||
<property name="draftBlogPostsCannedQueryFactory" ref="getDraftBlogPostsCannedQueryFactory"/>
|
||||
<property name="publishedBlogPostsCannedQueryFactory" ref="getPublishedBlogPostsCannedQueryFactory"/>
|
||||
|
@@ -28,6 +28,7 @@ import java.util.Map;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.CannedQueryFactory;
|
||||
import org.alfresco.query.CannedQueryResults;
|
||||
import org.alfresco.query.EmptyPagingResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQuery;
|
||||
@@ -37,6 +38,7 @@ import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneUtils;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
import org.alfresco.service.cmr.blog.BlogPostInfo;
|
||||
import org.alfresco.service.cmr.blog.BlogService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
@@ -50,8 +52,11 @@ import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ISO9075;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
@@ -70,6 +75,8 @@ public class BlogServiceImpl implements BlogService
|
||||
*/
|
||||
private static final int MAX_QUERY_ENTRY_COUNT = 10000;
|
||||
|
||||
public static final String BLOG_COMPONENT = "blog";
|
||||
|
||||
// Injected services
|
||||
private NamedObjectRegistry<CannedQueryFactory<BlogPostInfo>> cannedQueryRegistry;
|
||||
private GetBlogPostsCannedQueryFactory draftPostsCannedQueryFactory;
|
||||
@@ -82,7 +89,10 @@ public class BlogServiceImpl implements BlogService
|
||||
private DictionaryService dictionaryService;
|
||||
private NamespaceService namespaceService;
|
||||
private NodeService nodeService;
|
||||
private SiteService siteService;
|
||||
private TransactionService transactionService;
|
||||
private PermissionService permissionService;
|
||||
private TaggingService taggingService;
|
||||
private SearchService searchService;
|
||||
|
||||
public void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory<BlogPostInfo>> cannedQueryRegistry)
|
||||
@@ -130,16 +140,41 @@ public class BlogServiceImpl implements BlogService
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setSiteService(SiteService siteService)
|
||||
{
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public void setTaggingService(TaggingService taggingService)
|
||||
{
|
||||
this.taggingService = taggingService;
|
||||
}
|
||||
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the Blogs Container on a site, creating as required if requested.
|
||||
*/
|
||||
protected NodeRef getSiteBlogContainer(final String siteShortName, boolean create)
|
||||
{
|
||||
return SiteServiceImpl.getSiteContainer(
|
||||
siteShortName, BLOG_COMPONENT, create,
|
||||
siteService, transactionService, taggingService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDraftBlogPost(NodeRef blogPostNode)
|
||||
{
|
||||
@@ -151,8 +186,11 @@ public class BlogServiceImpl implements BlogService
|
||||
public BlogPostInfo createBlogPost(String siteShortName, String blogTitle,
|
||||
String blogContent, boolean isDraft)
|
||||
{
|
||||
// TODO Implement
|
||||
return null;
|
||||
// Grab the location to stor ein
|
||||
NodeRef container = getSiteBlogContainer(siteShortName, true);
|
||||
|
||||
// Add by Parent NodeRef
|
||||
return createBlogPost(container, blogTitle, blogContent, isDraft);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -197,7 +235,7 @@ public class BlogServiceImpl implements BlogService
|
||||
throw new IllegalArgumentException("Can't update a post that was never persisted, call create instead");
|
||||
}
|
||||
|
||||
// TODO Implement
|
||||
// TODO Implement, once BlogPostInfo is finished
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -216,8 +254,15 @@ public class BlogServiceImpl implements BlogService
|
||||
public PagingResults<BlogPostInfo> getDrafts(String siteShortName,
|
||||
String username, PagingRequest pagingReq)
|
||||
{
|
||||
// TODO Implement
|
||||
return null;
|
||||
NodeRef container = getSiteBlogContainer(siteShortName, false);
|
||||
if (container == null)
|
||||
{
|
||||
// No blog posts yet
|
||||
return new EmptyPagingResults<BlogPostInfo>();
|
||||
}
|
||||
|
||||
// We can now fetch by parent nodeRef
|
||||
return getDrafts(container, username, pagingReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -239,8 +284,15 @@ public class BlogServiceImpl implements BlogService
|
||||
public PagingResults<BlogPostInfo> getPublishedExternally(
|
||||
String siteShortName, PagingRequest pagingReq)
|
||||
{
|
||||
// TODO Implement
|
||||
return null;
|
||||
NodeRef container = getSiteBlogContainer(siteShortName, false);
|
||||
if (container == null)
|
||||
{
|
||||
// No blog posts yet
|
||||
return new EmptyPagingResults<BlogPostInfo>();
|
||||
}
|
||||
|
||||
// We can now fetch by parent nodeRef
|
||||
return getPublishedExternally(container, pagingReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,8 +314,15 @@ public class BlogServiceImpl implements BlogService
|
||||
public PagingResults<BlogPostInfo> getPublished(String siteShortName,
|
||||
Date fromDate, Date toDate, String byUser, PagingRequest pagingReq)
|
||||
{
|
||||
// TODO Implement
|
||||
return null;
|
||||
NodeRef container = getSiteBlogContainer(siteShortName, false);
|
||||
if (container == null)
|
||||
{
|
||||
// No blog posts yet
|
||||
return new EmptyPagingResults<BlogPostInfo>();
|
||||
}
|
||||
|
||||
// We can now fetch by parent nodeRef
|
||||
return getPublished(container, fromDate, toDate, byUser, pagingReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -341,8 +400,15 @@ public class BlogServiceImpl implements BlogService
|
||||
public PagingResults<BlogPostInfo> findBlogPosts(String siteShortName,
|
||||
RangedDateProperty dateRange, String tag, PagingRequest pagingReq)
|
||||
{
|
||||
// TODO Implement
|
||||
return null;
|
||||
NodeRef container = getSiteBlogContainer(siteShortName, false);
|
||||
if (container == null)
|
||||
{
|
||||
// No blog posts yet
|
||||
return new EmptyPagingResults<BlogPostInfo>();
|
||||
}
|
||||
|
||||
// We can now fetch by parent nodeRef
|
||||
return findBlogPosts(container, dateRange, tag, pagingReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -54,7 +54,6 @@ import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.Pair;
|
||||
@@ -101,6 +100,7 @@ public class BlogServiceImplTest
|
||||
*/
|
||||
private static List<NodeRef> CLASS_TEST_NODES_TO_TIDY = new ArrayList<NodeRef>();
|
||||
|
||||
private static SiteInfo BLOG_SITE;
|
||||
private static NodeRef BLOG_CONTAINER_NODE;
|
||||
|
||||
@BeforeClass public static void initTestsContext() throws Exception
|
||||
@@ -125,21 +125,32 @@ public class BlogServiceImplTest
|
||||
|
||||
private static void createTestSiteWithBlogContainer() throws Exception
|
||||
{
|
||||
BLOG_CONTAINER_NODE = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
|
||||
BLOG_SITE = TRANSACTION_HELPER.doInTransaction(
|
||||
new RetryingTransactionHelper.RetryingTransactionCallback<SiteInfo>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef execute() throws Throwable
|
||||
public SiteInfo execute() throws Throwable
|
||||
{
|
||||
SiteInfo site = SITE_SERVICE.createSite("BlogSitePreset", BlogServiceImplTest.class.getSimpleName() + "_testSite" + System.currentTimeMillis(),
|
||||
"test site title", "test site description", SiteVisibility.PUBLIC);
|
||||
CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef());
|
||||
return site;
|
||||
}
|
||||
});
|
||||
|
||||
NodeRef result = SITE_SERVICE.getContainer(site.getShortName(), "blog");
|
||||
BLOG_CONTAINER_NODE = TRANSACTION_HELPER.doInTransaction(
|
||||
new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
SiteInfo site = BLOG_SITE;
|
||||
NodeRef result = SITE_SERVICE.getContainer(site.getShortName(), BlogServiceImpl.BLOG_COMPONENT);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
result = NODE_SERVICE.createNode(site.getNodeRef(), ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "blog"), ContentModel.TYPE_FOLDER, null).getChildRef();
|
||||
result = SITE_SERVICE.createContainer(site.getShortName(), BlogServiceImpl.BLOG_COMPONENT,
|
||||
ContentModel.TYPE_FOLDER, null);
|
||||
CLASS_TEST_NODES_TO_TIDY.add(result);
|
||||
}
|
||||
|
||||
@@ -215,7 +226,17 @@ public class BlogServiceImplTest
|
||||
|
||||
for (int i = 0; i < arbitraryNumberGreaterThanPageSize; i++)
|
||||
{
|
||||
BlogPostInfo newBlogPost = BLOG_SERVICE.createBlogPost(BLOG_CONTAINER_NODE, "title_" + i, "Hello world", true);
|
||||
BlogPostInfo newBlogPost;
|
||||
if(i % 2 == 0)
|
||||
{
|
||||
// By container ref
|
||||
newBlogPost = BLOG_SERVICE.createBlogPost(BLOG_CONTAINER_NODE, "title_" + i, "Hello world", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// By site name
|
||||
newBlogPost = BLOG_SERVICE.createBlogPost(BLOG_SITE.getShortName(), "title_" + i, "Hello world", true);
|
||||
}
|
||||
|
||||
results.add(newBlogPost.getNodeRef());
|
||||
testNodesToTidy.add(newBlogPost.getNodeRef());
|
||||
|
Reference in New Issue
Block a user