当前位置: 首页>>代码示例>>Java>>正文


Java Status.STATUS_PRECONDITION_FAILED属性代码示例

本文整理汇总了Java中org.springframework.extensions.webscripts.Status.STATUS_PRECONDITION_FAILED属性的典型用法代码示例。如果您正苦于以下问题:Java Status.STATUS_PRECONDITION_FAILED属性的具体用法?Java Status.STATUS_PRECONDITION_FAILED怎么用?Java Status.STATUS_PRECONDITION_FAILED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.springframework.extensions.webscripts.Status的用法示例。


在下文中一共展示了Status.STATUS_PRECONDITION_FAILED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeImpl

@Override
protected Map<String, Object> executeImpl(SiteInfo site, NodeRef nodeRef,
      TopicInfo topic, PostInfo post, WebScriptRequest req, JSONObject json,
      Status status, Cache cache) 
{
   // If they're trying to create a reply to a topic, they actually
   //  mean to create the reply on the primary post
   if (post == null)
   {
      post = discussionService.getPrimaryPost(topic);
      if (post == null)
      {
         throw new WebScriptException(Status.STATUS_PRECONDITION_FAILED,
               "First (primary) post was missing from the topic, can't fetch");
      }
   }
   else if (topic == null)
   {
      String error = "Node was of the wrong type, only Topic and Post are supported";
      throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
   }
   
   // Have the reply created
   PostInfo reply = doCreatePost(post, topic, req, json);
   
   // Add the activity entry for the reply change
   addActivityEntry("reply", "created", topic, reply, site, req, json);
   
   // Build the common model parts
   Map<String, Object> model = buildCommonModel(site, topic, reply, req);
   
   // Build the JSON for the new reply post
   model.put(KEY_POSTDATA, renderPost(reply, site));
   
   // All done
   return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:37,代码来源:ForumPostRepliesPost.java

示例2: renderTopic

protected Map<String, Object> renderTopic(TopicInfo topic, SiteInfo site)
{
   // Fetch the primary post
   PostInfo primaryPost = discussionService.getPrimaryPost(topic);
   if (primaryPost == null)
   {
      throw new WebScriptException(Status.STATUS_PRECONDITION_FAILED,
             "First (primary) post was missing from the topic, can't fetch");
   }
   
   // Fetch the most recent reply
   PostInfo mostRecentPost = discussionService.getMostRecentPost(topic);
   
   // Find out how many replies there are
   int numReplies;
   if (mostRecentPost.getNodeRef().equals( primaryPost.getNodeRef() ))
   {
      // Only the one post in the topic
      mostRecentPost = null;
      numReplies = 0;
   }
   else
   {
      // Use this trick to get the number of posts in the topic, 
      //  but without needing to get lots of data and objects
      PagingRequest paging = new PagingRequest(1);
      paging.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
      PagingResults<PostInfo> posts = discussionService.listPosts(topic, paging);
      
      // The primary post is in the list, so exclude from the reply count 
      numReplies = posts.getTotalResultCount().getFirst() - 1;
   }
   
   // Build the details
   Map<String, Object> item = new HashMap<String, Object>();
   item.put(KEY_IS_TOPIC_POST, true);
   item.put(KEY_TOPIC, topic.getNodeRef());
   item.put(KEY_POST, primaryPost.getNodeRef());
   item.put(KEY_CAN_EDIT, canUserEditPost(primaryPost, site));
   item.put(KEY_AUTHOR, buildPerson(topic.getCreator()));
   
   // The reply count is one less than all posts (first is the primary one)
   item.put("totalReplyCount", numReplies);
   
   // Add the topic site 
   item.put("site", topic.getShortSiteName());
   
   // We want details on the most recent post
   if (mostRecentPost != null)
   {
      item.put("lastReply", mostRecentPost.getNodeRef());
      item.put("lastReplyBy", buildPerson(mostRecentPost.getCreator()));
   }
   
   // Include the tags
   item.put("tags", topic.getTags());
   
   // All done
   return item;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:60,代码来源:AbstractDiscussionWebScript.java

示例3: executeImpl

@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 to change a reply or the whole topic?
   if (post != null)
   {
      // Update the specified post
      doUpdatePost(post, post.getTopic(), req, json);
      
      // Add the activity entry for the reply change
      addActivityEntry("reply", "updated", post.getTopic(), post, site, req, json);
      
      // Build the JSON for just this post
      model.put(KEY_POSTDATA, renderPost(post, site));
   }
   else if (topic != null)
   {
      // Update the primary post of the topic
      post = discussionService.getPrimaryPost(topic);
      if (post == null)
      {
         throw new WebScriptException(Status.STATUS_PRECONDITION_FAILED,
               "First (primary) post was missing from the topic, can't fetch");
      }
      doUpdatePost(post, topic, req, json);
      
      // Add the activity entry for the topic change
      addActivityEntry("post", "updated", topic, null, site, req, json);
      
      // Build the JSON for the whole topic
      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;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:46,代码来源:ForumPostPut.java


注:本文中的org.springframework.extensions.webscripts.Status.STATUS_PRECONDITION_FAILED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。