mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-10429 / ALF-10413 Refactor the blog webscripts to follow the pattern of the other new service webscripts, avoiding the old JS style code
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31184 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -930,9 +930,9 @@
|
|||||||
<property name="afterInvocationManager"><ref bean="afterInvocationManager"/></property>
|
<property name="afterInvocationManager"><ref bean="afterInvocationManager"/></property>
|
||||||
<property name="objectDefinitionSource">
|
<property name="objectDefinitionSource">
|
||||||
<value>
|
<value>
|
||||||
org.alfresco.service.cmr.blog.BlogService.getDrafts=ACL_NODE.0.sys:base.ReadChildren,AFTER_ACL_NODE.sys:base.ReadProperties
|
org.alfresco.service.cmr.blog.BlogService.getDrafts=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties
|
||||||
org.alfresco.service.cmr.blog.BlogService.getPublished=ACL_NODE.0.sys:base.ReadChildren,AFTER_ACL_NODE.sys:base.ReadProperties
|
org.alfresco.service.cmr.blog.BlogService.getPublished=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties
|
||||||
org.alfresco.service.cmr.blog.BlogService.getPublishedExternally=ACL_NODE.0.sys:base.ReadChildren,AFTER_ACL_NODE.sys:base.ReadProperties
|
org.alfresco.service.cmr.blog.BlogService.getPublishedExternally=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties
|
||||||
org.alfresco.service.cmr.blog.BlogService.getMyDraftsAndAllPublished=ACL_NODE.0.sys:base.ReadChildren,AFTER_ACL_NODE.sys:base.ReadProperties
|
org.alfresco.service.cmr.blog.BlogService.getMyDraftsAndAllPublished=ACL_NODE.0.sys:base.ReadChildren,AFTER_ACL_NODE.sys:base.ReadProperties
|
||||||
org.alfresco.service.cmr.blog.BlogService.*=ACL_ALLOW
|
org.alfresco.service.cmr.blog.BlogService.*=ACL_ALLOW
|
||||||
</value>
|
</value>
|
||||||
|
@@ -38,6 +38,7 @@ import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory;
|
|||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.search.impl.lucene.LuceneUtils;
|
import org.alfresco.repo.search.impl.lucene.LuceneUtils;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
import org.alfresco.repo.site.SiteServiceImpl;
|
import org.alfresco.repo.site.SiteServiceImpl;
|
||||||
import org.alfresco.service.cmr.blog.BlogPostInfo;
|
import org.alfresco.service.cmr.blog.BlogPostInfo;
|
||||||
import org.alfresco.service.cmr.blog.BlogService;
|
import org.alfresco.service.cmr.blog.BlogService;
|
||||||
@@ -61,6 +62,8 @@ import org.alfresco.util.ISO9075;
|
|||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.alfresco.util.registry.NamedObjectRegistry;
|
import org.alfresco.util.registry.NamedObjectRegistry;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Neil Mc Erlean (based on existing webscript controllers in the REST API)
|
* @author Neil Mc Erlean (based on existing webscript controllers in the REST API)
|
||||||
@@ -77,6 +80,11 @@ public class BlogServiceImpl implements BlogService
|
|||||||
|
|
||||||
public static final String BLOG_COMPONENT = "blog";
|
public static final String BLOG_COMPONENT = "blog";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The logger
|
||||||
|
*/
|
||||||
|
private static Log logger = LogFactory.getLog(BlogServiceImpl.class);
|
||||||
|
|
||||||
// Injected services
|
// Injected services
|
||||||
private NamedObjectRegistry<CannedQueryFactory<BlogPostInfo>> cannedQueryRegistry;
|
private NamedObjectRegistry<CannedQueryFactory<BlogPostInfo>> cannedQueryRegistry;
|
||||||
private GetBlogPostsCannedQueryFactory draftPostsCannedQueryFactory;
|
private GetBlogPostsCannedQueryFactory draftPostsCannedQueryFactory;
|
||||||
@@ -175,6 +183,25 @@ public class BlogServiceImpl implements BlogService
|
|||||||
siteService, transactionService, taggingService);
|
siteService, transactionService, taggingService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds up a {@link BlogPostInfo} object for the given node
|
||||||
|
*/
|
||||||
|
private BlogPostInfo buildBlogPost(NodeRef nodeRef, NodeRef parentNodeRef, String postName)
|
||||||
|
{
|
||||||
|
BlogPostInfoImpl post = new BlogPostInfoImpl(nodeRef, postName);
|
||||||
|
|
||||||
|
// Grab all the properties, we need the bulk of them anyway
|
||||||
|
Map<QName,Serializable> props = nodeService.getProperties(nodeRef);
|
||||||
|
|
||||||
|
// TODO Populate them
|
||||||
|
|
||||||
|
// Finally set tags
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
// All done
|
||||||
|
return post;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDraftBlogPost(NodeRef blogPostNode)
|
public boolean isDraftBlogPost(NodeRef blogPostNode)
|
||||||
{
|
{
|
||||||
@@ -250,6 +277,65 @@ public class BlogServiceImpl implements BlogService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlogPostInfo getForNodeRef(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
QName type = nodeService.getType(nodeRef);
|
||||||
|
|
||||||
|
// Note - there isn't a special blog type!
|
||||||
|
// The nodes are just created as cm:Content
|
||||||
|
if (type.equals(ContentModel.TYPE_CONTENT))
|
||||||
|
{
|
||||||
|
ChildAssociationRef ref = nodeService.getPrimaryParent(nodeRef);
|
||||||
|
String postName = ref.getQName().getLocalName();
|
||||||
|
NodeRef container = ref.getParentRef();
|
||||||
|
return buildBlogPost(nodeRef, container, postName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.debug("Invalid type " + type + " found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlogPostInfo getBlogPost(String siteShortName, String postName)
|
||||||
|
{
|
||||||
|
NodeRef container = getSiteBlogContainer(siteShortName, false);
|
||||||
|
if (container == null)
|
||||||
|
{
|
||||||
|
// No blog posts yet
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We can now fetch by parent nodeRef
|
||||||
|
return getBlogPost(container, postName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlogPostInfo getBlogPost(NodeRef parentNodeRef, String postName)
|
||||||
|
{
|
||||||
|
NodeRef postNode;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
postNode = nodeService.getChildByName(parentNodeRef, ContentModel.ASSOC_CONTAINS, postName);
|
||||||
|
}
|
||||||
|
catch(AccessDeniedException e)
|
||||||
|
{
|
||||||
|
// You can't see that blog post
|
||||||
|
// For compatibility with the old webscripts, rather than
|
||||||
|
// reporting permission denied, pretend it isn't there
|
||||||
|
postNode = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we found a node, wrap it as a BlogPostInfo
|
||||||
|
if (postNode != null)
|
||||||
|
{
|
||||||
|
return buildBlogPost(postNode, parentNodeRef, postName);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PagingResults<BlogPostInfo> getDrafts(String siteShortName,
|
public PagingResults<BlogPostInfo> getDrafts(String siteShortName,
|
||||||
String username, PagingRequest pagingReq)
|
String username, PagingRequest pagingReq)
|
||||||
|
@@ -24,6 +24,7 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.query.PagingRequest;
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.query.PagingResults;
|
import org.alfresco.query.PagingResults;
|
||||||
import org.alfresco.repo.blog.BlogIntegrationService;
|
import org.alfresco.repo.blog.BlogIntegrationService;
|
||||||
|
import org.alfresco.service.NotAuditable;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
@@ -81,6 +82,28 @@ public interface BlogService
|
|||||||
*/
|
*/
|
||||||
void deleteBlogPost(BlogPostInfo post);
|
void deleteBlogPost(BlogPostInfo post);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For a given NodeRef corresponding to a {@link BlogPostInfo},
|
||||||
|
* returns the object wrapping the Node.
|
||||||
|
*
|
||||||
|
* For anything else, the response is null.
|
||||||
|
*/
|
||||||
|
@NotAuditable
|
||||||
|
BlogPostInfo getForNodeRef(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves an existing {@link BlogPostInfo} from the repository,
|
||||||
|
* which is within a site
|
||||||
|
*/
|
||||||
|
BlogPostInfo getBlogPost(String siteShortName, String postName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves an existing {@link BlogPostInfo} from the repository,
|
||||||
|
* which is attached to the specified Node.
|
||||||
|
* The parent Node should normally be a Site Container
|
||||||
|
*/
|
||||||
|
BlogPostInfo getBlogPost(NodeRef parentNodeRef, String postName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the draft blog posts created by the specified user.
|
* Gets the draft blog posts created by the specified user.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user