1 37 38 package org.jahia.blogs; 39 40 import org.jahia.blogs.api.MovableTypeAPI; 41 import org.jahia.blogs.api.XMLRPCConstants; 42 43 import org.jahia.blogs.actions.AbstractAction; 44 import org.jahia.blogs.actions.GetRecentPostTitlesAction; 45 import org.jahia.blogs.actions.GetCategoriesAction; 46 import org.jahia.blogs.actions.GetPostCategoriesAction; 47 import org.jahia.blogs.actions.SetPostCategoriesAction; 48 import org.jahia.blogs.actions.GetTrackBackPingsAction; 49 50 import java.util.Vector ; 51 52 import org.apache.xmlrpc.XmlRpcException; 53 54 import org.apache.log4j.Logger; 55 56 61 public class MovableTypeAPIImpl extends MetaWeblogAPIImpl 62 implements MovableTypeAPI, XMLRPCConstants { 63 64 static Logger log = Logger.getLogger(MovableTypeAPIImpl.class); 66 67 70 public Vector getRecentPostTitles( 71 final String blogID, 72 final String userName, 73 final String passWord, 74 final int numberOfPosts) 75 throws XmlRpcException { 76 77 log.debug("mt.getRecentPostTitles: " +blogID+ ", " +userName+ 78 ", " +passWord+ ", " +numberOfPosts); 79 80 AbstractAction action = new GetRecentPostTitlesAction(blogID, userName, 81 passWord, numberOfPosts); 82 83 try { 84 return (Vector )action.execute(); 85 } catch (Exception e) { 86 e.printStackTrace(); 87 if (e.getMessage().indexOf("Login") != -1) { 88 throw new XmlRpcException(AUTHORIZATION_EXCEPTION, 89 AUTHORIZATION_EXCEPTION_MSG); 90 } else { 91 throw new XmlRpcException(UNKNOWN_EXCEPTION, e.getMessage()); 92 } 93 } finally { 94 action = null; 95 } 96 } 97 98 101 public Vector getCategoryList( 102 final String blogID, 103 final String userName, 104 final String passWord) 105 throws XmlRpcException { 106 107 log.debug("mt.getCategoryList: " +blogID+ ", " +userName+ 108 ", " +passWord); 109 110 AbstractAction action = new GetCategoriesAction(blogID, userName, 111 passWord, false); 112 113 try { 114 return (Vector )action.execute(); 115 } catch (Exception e) { 116 e.printStackTrace(); 117 if (e.getMessage().indexOf("Login") != -1) { 118 throw new XmlRpcException(AUTHORIZATION_EXCEPTION, 119 AUTHORIZATION_EXCEPTION_MSG); 120 } else { 121 throw new XmlRpcException(UNKNOWN_EXCEPTION, e.getMessage()); 122 } 123 } finally { 124 action = null; 125 } 126 } 127 128 131 public Vector getPostCategories( 132 final String postID, 133 final String userName, 134 final String passWord) 135 throws XmlRpcException { 136 137 log.debug("mt.getPostCategories: " +postID+ ", " +userName+ 138 ", " +passWord); 139 140 AbstractAction action = new GetPostCategoriesAction(postID, userName, 141 passWord); 142 143 try { 144 return (Vector )action.execute(); 145 } catch (Exception e) { 146 e.printStackTrace(); 147 if (e.getMessage().indexOf("Login") != -1) { 148 throw new XmlRpcException(AUTHORIZATION_EXCEPTION, 149 AUTHORIZATION_EXCEPTION_MSG); 150 } else { 151 throw new XmlRpcException(UNKNOWN_EXCEPTION, e.getMessage()); 152 } 153 } finally { 154 action = null; 155 } 156 } 157 158 161 public boolean setPostCategories( 162 final String postID, 163 final String userName, 164 final String passWord, 165 final Vector categories) 166 throws XmlRpcException { 167 168 log.debug("mt.setPostCategories: " +postID+ ", " +userName+ 169 ", " +passWord+ ", " +categories); 170 171 AbstractAction action = new SetPostCategoriesAction(postID, userName, 172 passWord, categories); 173 174 try { 175 return ((Boolean )action.execute()).booleanValue(); 176 } catch (Exception e) { 177 e.printStackTrace(); 178 if (e.getMessage().indexOf("Login") != -1) { 179 throw new XmlRpcException(AUTHORIZATION_EXCEPTION, 180 AUTHORIZATION_EXCEPTION_MSG); 181 } else { 182 throw new XmlRpcException(UNKNOWN_EXCEPTION, e.getMessage()); 183 } 184 } finally { 185 action = null; 186 } 187 } 188 189 192 public Vector supportedMethods() throws XmlRpcException { 193 log.debug("mt.supportedMethods()"); 194 Vector result = new Vector (21); 195 196 result.add("blogger.newPost"); 197 result.add("blogger.editPost"); 198 result.add("blogger.getPost"); 199 result.add("blogger.deletePost"); 200 result.add("blogger.getRecentPosts"); 201 result.add("blogger.getUsersBlogs"); 202 result.add("blogger.getUserInfo"); 203 204 result.add("metaWeblog.newPost"); 205 result.add("metaWeblog.editPost"); 206 result.add("metaWeblog.getPost"); 207 result.add("metaWeblog.deletePost"); 208 result.add("metaWeblog.getRecentPosts"); 209 result.add("metaWeblog.getUsersBlogs"); 210 result.add("metaWeblog.getUserInfo"); 211 result.add("metaWeblog.getCategories"); 212 result.add("metaWeblog.newMediaObject"); 213 214 result.add("mt.getRecentPostTitles"); 215 result.add("mt.getCategoryList"); 216 result.add("mt.getPostCategories"); 217 result.add("mt.getTrackbackPings"); 218 result.add("mt.setPostCategories"); 219 result.add("mt.supportedMethods"); 220 result.add("mt.supportedTextFilters"); 221 222 return result; 223 } 224 225 229 public Vector supportedTextFilters() throws XmlRpcException { 230 log.debug("mt.supportedTextFilters()"); 231 return new Vector (0); 232 } 233 234 241 public Vector getTrackbackPings( 242 final String postID) 243 throws XmlRpcException { 244 log.debug("mt.getTrackbackPings: "+postID); 245 246 AbstractAction action = new GetTrackBackPingsAction(postID); 247 248 try { 249 return (Vector )action.execute(); 250 } catch (Exception e) { 251 e.printStackTrace(); 252 if (e.getMessage().indexOf("Login") != -1) { 253 throw new XmlRpcException(AUTHORIZATION_EXCEPTION, 254 AUTHORIZATION_EXCEPTION_MSG); 255 } else { 256 throw new XmlRpcException(UNKNOWN_EXCEPTION, e.getMessage()); 257 } 258 } finally { 259 action = null; 260 } 261 } 262 263 267 public boolean publishPost( 268 final String blogID, 269 final String userName, 270 final String passWord) 271 throws XmlRpcException { 272 273 log.debug("mt.publishPost: " +blogID+ ", " +userName+ 274 ", " +passWord); 275 throw new XmlRpcException(UNSUPPORTED_EXCEPTION, 276 UNSUPPORTED_EXCEPTION_MSG); 277 278 } 279 } 280 | Popular Tags |