本文整理汇总了Java中org.alfresco.service.cmr.discussion.PostInfo类的典型用法代码示例。如果您正苦于以下问题:Java PostInfo类的具体用法?Java PostInfo怎么用?Java PostInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PostInfo类属于org.alfresco.service.cmr.discussion包,在下文中一共展示了PostInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPost
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
@Override
public PostInfo getPost(TopicInfo topic, String postName)
{
// Sanity check what we were given
if (topic.getNodeRef() == null)
{
throw new IllegalArgumentException("Can't get posts for a topic that was never persisted!");
}
// Fetch
NodeRef post = nodeService.getChildByName(topic.getNodeRef(), ContentModel.ASSOC_CONTAINS, postName);
if (post != null)
{
return buildPost(post, topic, postName, null);
}
return null;
}
示例2: createReply
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
@Override
public PostInfo createReply(PostInfo parentPost, String contents)
{
// Sanity check what we were given
if (parentPost.getNodeRef() == null)
{
throw new IllegalArgumentException("Can't reply to a post that was never persisted");
}
if (parentPost.getTopic() == null)
{
throw new IllegalArgumentException("Can't reply to a post with no attached topic");
}
// Have the post created
PostInfo reply = createPost(parentPost.getTopic(), contents);
// Now make it a reply
nodeService.createAssociation(
reply.getNodeRef(), parentPost.getNodeRef(), ContentModel.ASSOC_REFERENCES);
// All done
return reply;
}
示例3: getPrimaryPost
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
@Override
public PostInfo getPrimaryPost(TopicInfo topic)
{
// First up, see if there is a post with the same name as the topic
// (That's the normal Share case)
PostInfo post = getPost(topic, topic.getSystemName());
if (post != null)
{
return post;
}
// Cater for the explorer case, we want the first child
List<ChildAssociationRef> children = nodeService.getChildAssocs(topic.getNodeRef());
if (children.size() == 0)
{
// No child posts yet
return null;
}
// We want the first one in the list
NodeRef postNodeRef = children.get(0).getChildRef();
String postName = children.get(0).getQName().getLocalName();
return buildPost(postNodeRef, topic, postName, null);
}
示例4: getMostRecentPost
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
@Override
public PostInfo getMostRecentPost(TopicInfo topic)
{
// Do a listing at the Node level, ordered by created date
// to get the most recent nodes
PagingRequest paging = new PagingRequest(0, 1);
CannedQueryResults<NodeBackedEntity> results =
listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, null, null, false, paging);
// Bail if the topic lacks posts
if (results.getPage().size() == 0)
{
// No posts in the topic
return null;
}
// Grab the newest node
NodeBackedEntity node = results.getPage().get(0);
// Wrap and return
return buildPost(tenantService.getBaseName(node.getNodeRef()), topic, node.getName(), null);
}
示例5: wrap
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
private PostWithReplies wrap(PostInfo post, Map<NodeRef,List<NodeWithTargetsEntity>> idToReplies, int levels)
{
List<PostWithReplies> replies = new ArrayList<PostWithReplies>();
if (levels > 0)
{
List<NodeWithTargetsEntity> replyEntities = idToReplies.get(post.getNodeRef());
if (replyEntities != null && replyEntities.size() > 0)
{
for (NodeWithTargetsEntity entity : replyEntities)
{
PostInfo replyPost = buildPost(tenantService.getBaseName(entity.getNodeRef()), post.getTopic(), entity.getName(), null);
replies.add(wrap(replyPost, idToReplies, levels-1));
}
}
}
return new PostWithReplies(post, replies);
}
示例6: executeImpl
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
@Override
protected Map<String, Object> executeImpl(SiteInfo site, NodeRef nodeRef,
TopicInfo topic, PostInfo post, WebScriptRequest req, JSONObject json,
Status status, Cache cache)
{
// Build the common model parts
Map<String, Object> model = buildCommonModel(site, topic, post, req);
// Did they want just one post, or the whole of the topic?
if (post != null)
{
model.put(KEY_POSTDATA, renderPost(post, site));
}
else if (topic != null)
{
model.put(KEY_POSTDATA, renderTopic(topic, site));
}
else
{
String error = "Node was of the wrong type, only Topic and Post are supported";
throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
}
// All done
return model;
}
示例7: buildTopic
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
private TopicInfo buildTopic(NodeRef nodeRef, NodeRef container, String name)
{
TopicInfoImpl topic = new TopicInfoImpl(nodeRef, container, name);
// Grab all the properties, we need the bulk of them anyway
Map<QName,Serializable> props = nodeService.getProperties(nodeRef);
// Start with the auditable properties
topic.setCreator((String)props.get(ContentModel.PROP_CREATOR));
topic.setModifier((String)props.get(ContentModel.PROP_MODIFIER));
topic.setCreatedAt((Date)props.get(ContentModel.PROP_CREATED));
topic.setModifiedAt((Date)props.get(ContentModel.PROP_MODIFIED));
// Now do the discussion ones
// Title is special - in older cases from share it was set on the
// First Post but not on the Topic
String title = (String)props.get(ContentModel.PROP_TITLE);
if (title == null)
{
// Try the first child
PostInfo primaryPost = getPrimaryPost(topic);
if (primaryPost != null)
{
title = primaryPost.getTitle();
}
}
topic.setTitle(title);
// Finally tags
topic.setTags(taggingService.getTags(nodeRef));
// All done
return topic;
}
示例8: buildPost
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
private PostInfo buildPost(NodeRef nodeRef, TopicInfo topic, String name, String preLoadedContents)
{
PostInfoImpl post = new PostInfoImpl(nodeRef, name, topic);
// Grab all the properties, we need the bulk of them anyway
Map<QName,Serializable> props = nodeService.getProperties(nodeRef);
// Start with the auditable properties
post.setCreator((String)props.get(ContentModel.PROP_CREATOR));
post.setModifier((String)props.get(ContentModel.PROP_MODIFIER));
post.setCreatedAt((Date)props.get(ContentModel.PROP_CREATED));
post.setModifiedAt((Date)props.get(ContentModel.PROP_MODIFIED));
post.setUpdatedAt((Date)props.get(ContentModel.PROP_UPDATED));
// Now do the discussion ones
post.setTitle((String)props.get(ContentModel.PROP_TITLE));
// Finally, do the content
String contents = preLoadedContents;
if (contents == null)
{
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
if (reader != null)
{
contents = reader.getContentString();
}
}
post.setContents(contents);
// All done
return post;
}
示例9: updatePost
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
@Override
public PostInfo updatePost(PostInfo post)
{
// Sanity check what we were given
if (post.getNodeRef() == null)
{
throw new IllegalArgumentException("Can't update a post that was never persisted, call create instead");
}
// Update the properties
NodeRef nodeRef = post.getNodeRef();
nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, post.getTitle());
// Change the content
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
writer.setEncoding("UTF-8");
writer.putContent(post.getContents());
// Mark it as having been updated
Date updatedAt = new Date();
nodeService.setProperty(nodeRef, ContentModel.PROP_UPDATED, updatedAt);
if (post instanceof PostInfoImpl)
{
((PostInfoImpl)post).setUpdatedAt(updatedAt);
((PostInfoImpl)post).setModifiedAt(updatedAt);
}
else
{
// Re-create to get the updated date
post = buildPost(nodeRef, post.getTopic(), post.getSystemName(), post.getContents());
}
// All done
return post;
}
示例10: deletePost
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
@Override
public void deletePost(PostInfo post)
{
if (post.getNodeRef() == null)
{
throw new IllegalArgumentException("Can't delete a post that was never persisted");
}
nodeService.deleteNode(post.getNodeRef());
}
示例11: listPosts
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
@Override
public PagingResults<PostInfo> listPosts(TopicInfo topic, PagingRequest paging)
{
// Do the listing, oldest first
CannedQueryResults<NodeBackedEntity> nodes =
listEntries(topic.getNodeRef(), ForumModel.TYPE_POST, null, null, null, true, paging);
// Wrap and return
return wrap(nodes, topic);
}
示例12: listPostReplies
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
@Override
public PostWithReplies listPostReplies(TopicInfo topic, int levels)
{
PostInfo primaryPost = getPrimaryPost(topic);
if (primaryPost == null)
{
return null;
}
return listPostReplies(primaryPost, levels);
}
示例13: canUserEditPost
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
/**
* Is the current user allowed to edit this post?
* In order to be deemed allowed, you first need write
* permissions on the underlying node of the post.
* You then also need to either be the cm:creator of
* the post node, or a site manager
*/
protected boolean canUserEditPost(PostInfo post, SiteInfo site)
{
// Are they OK on the node?
AccessStatus canEdit = permissionService.hasPermission(post.getNodeRef(), PermissionService.WRITE);
if (canEdit == AccessStatus.ALLOWED)
{
// Only the creator and site managers may edit
String user = AuthenticationUtil.getFullyAuthenticatedUser();
if (post.getCreator().equals(user))
{
// It's their post
return true;
}
if (site != null)
{
String role = siteService.getMembersRole(site.getShortName(), user);
if (SiteServiceImpl.SITE_MANAGER.equals(role))
{
// Managers may edit
return true;
}
}
}
// If in doubt, you may not edit
return false;
}
示例14: renderPost
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
protected Map<String, Object> renderPost(PostInfo post, SiteInfo site)
{
Map<String, Object> item = new HashMap<String, Object>();
item.put(KEY_IS_TOPIC_POST, false);
item.put(KEY_POST, post.getNodeRef());
item.put(KEY_CAN_EDIT, canUserEditPost(post, site));
item.put(KEY_AUTHOR, buildPerson(post.getCreator()));
return item;
}
示例15: buildCommonModel
import org.alfresco.service.cmr.discussion.PostInfo; //导入依赖的package包/类
protected Map<String, Object> buildCommonModel(SiteInfo site, TopicInfo topic,
PostInfo post, WebScriptRequest req)
{
// Build the common model parts
Map<String, Object> model = new HashMap<String, Object>();
model.put(KEY_TOPIC, topic);
model.put(KEY_POST, post);
// Capture the site details only if site based
if (site != null)
{
model.put("siteId", site.getShortName());
model.put("site", site);
}
// The limit on the length of the content to be returned
int contentLength = -1;
String contentLengthS = req.getParameter("contentLength");
if (contentLengthS != null)
{
try
{
contentLength = Integer.parseInt(contentLengthS);
}
catch (NumberFormatException e)
{
logger.info("Skipping invalid length " + contentLengthS);
}
}
model.put("contentLength", contentLength);
// All done
return model;
}