1 37 38 package org.jahia.blogs.actions; 39 40 import org.jahia.data.containers.JahiaContainer; 41 42 import org.jahia.services.usermanager.JahiaUser; 43 44 import org.jahia.services.categories.Category; 45 46 import org.jahia.exceptions.JahiaException; 47 48 import org.apache.log4j.Logger; 49 50 import java.util.Hashtable ; 51 import java.util.Set ; 52 53 59 public class GetPostAction extends AbstractAction { 60 61 static Logger log = Logger.getLogger(GetPostAction.class); 63 64 private String postID; 65 private boolean meta; 66 67 70 public GetPostAction(String appKey, String postID, 71 String userName, String password) { 72 super.appKey = appKey; 73 super.userName = userName; 74 super.password = password; 75 this.postID = postID; 76 meta = false; 77 } 78 79 82 public GetPostAction(String postID, 83 String userName, String password) { 84 super.userName = userName; 85 super.password = password; 86 this.postID = postID; 87 meta = true; 88 } 89 90 95 public Object execute() throws JahiaException { 96 97 super.init(); 99 100 final JahiaUser user = super.checkLogin(); 102 103 final JahiaContainer postContainer = super.getContainer( 105 Integer.parseInt(postID)); 106 107 if (postContainer == null) { 108 throw new JahiaException("Post: "+postID+ 109 " does not exist", "Container: "+postID+ " does not exist", 110 JahiaException.ENTRY_NOT_FOUND, 111 JahiaException.WARNING_SEVERITY); 112 } 113 114 log.debug("Working on container: "+postContainer.getID()); 115 116 Hashtable postInfo; 118 if (meta) { 119 Set set = Category.getObjectCategories(postContainer. 120 getContentContainer().getObjectKey()); 121 postInfo = super.createMetaPostInfo(postContainer, set); 122 } else { 123 postInfo = super.createPostInfo(postContainer); 124 } 125 126 log.debug("Post info is: "+ postInfo); 127 return postInfo; 128 } 129 } 130 | Popular Tags |