Package org.apache.xmlrpc

Examples of org.apache.xmlrpc.XmlRpcException


       
        Hashtable postcontent = struct;
        String description = (String)postcontent.get("description");
        String title = (String)postcontent.get("title");
        if (Utilities.isEmpty(title) && Utilities.isEmpty(description)) {
            throw new XmlRpcException(
              BLOGGERAPI_INCOMPLETE_POST, "Must specify title or description");
        }
        if (Utilities.isEmpty(title)) {
            title = Utilities.truncateNicely(description, 15, 15, "...");
        }
       
        Date dateCreated = (Date)postcontent.get("dateCreated");
        if (dateCreated == null) dateCreated = (Date)postcontent.get("pubDate");
        if (dateCreated == null) dateCreated = new Date();
        mLogger.debug("      Title: " + title);
       
        try {
            Roller roller = RollerFactory.getRoller();
            WeblogManager weblogMgr = roller.getWeblogManager();
            UserData user = roller.getUserManager().getUserByUsername(userid);
            Timestamp current =
                    new Timestamp(System.currentTimeMillis());
           
            WeblogEntryData entry = new WeblogEntryData();
            entry.setTitle(title);
            entry.setText(description);
            entry.setPubTime(new Timestamp(dateCreated.getTime()));
            entry.setUpdateTime(current);
            entry.setWebsite(website);
            entry.setCreator(user);
            if (Boolean.valueOf(publish).booleanValue()) {
                entry.setStatus(WeblogEntryData.PUBLISHED);
            } else {
                entry.setStatus(WeblogEntryData.DRAFT);
            }
                       
            // MetaWeblog supports multiple cats, Roller supports one/entry
            // so here we take accept the first category that exists
            WeblogCategoryData rollerCat = null;
            if ( postcontent.get("categories") != null ) {
                Vector cats = (Vector)postcontent.get("categories");
                if (cats != null && cats.size() > 0) {
                    for (int i=0; i<cats.size(); i++) {
                        String cat = (String)cats.get(i);
                        rollerCat = weblogMgr.getWeblogCategoryByPath(website, cat);
                        if (rollerCat != null) {
                            entry.setCategory(rollerCat);
                            break;
                        }
                    }
                }
            }
            if (rollerCat == null) {
                // or we fall back to the default Blogger API category
                entry.setCategory(website.getBloggerCategory());
            }
           
            // save the entry
            weblogMgr.saveWeblogEntry(entry);
            roller.flush();
           
            // notify cache
            flushPageCache(entry.getWebsite());
           
            // TODO: Roller timestamps need better than 1 second accuracy
            // Until then, we can't allow more than one post per second
            Thread.sleep(1000);
           
            return entry.getId();
        } catch (Exception e) {
            String msg = "ERROR in MetaWeblogAPIHandler.newPost";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
        }
    }
View Full Code Here


        try {
            return createPostStruct(entry, userid);
        } catch (Exception e) {
            String msg = "ERROR in MetaWeblogAPIHandler.getPost";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
        }
    }
View Full Code Here

               
                Hashtable returnStruct = new Hashtable(1);
                returnStruct.put("url", fileLink);
                return returnStruct;
            }
            throw new XmlRpcException(UPLOAD_DENIED_EXCEPTION,
                    "File upload denied because:" + msgs.toString());
        } catch (RollerException e) {
            String msg = "ERROR in MetaWeblogAPIHandler.newMediaObject";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
        }
    }
View Full Code Here

            return results;
           
        } catch (Exception e) {
            String msg = "ERROR in MetaWeblogAPIHandler.getRecentPosts";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
        }
    }
View Full Code Here

            mLogger.error("ERROR internal error validating user", e);
        }
       
        if ( !authenticated )
        {
            throw new XmlRpcException(
                AUTHORIZATION_EXCEPTION, AUTHORIZATION_EXCEPTION_MSG);
        }
        if ( !userEnabled )
        {
            throw new XmlRpcException(
                USER_DISABLED, USER_DISABLED_MSG);
        }       
        if ( !weblogEnabled )
        {
            throw new XmlRpcException(
                WEBLOG_DISABLED, WEBLOG_DISABLED_MSG);
        }       
        if ( !weblogFound )
        {
            throw new XmlRpcException(
                WEBLOG_NOT_FOUND, WEBLOG_NOT_FOUND_MSG);
        }       
        if ( !apiEnabled )
        {
            throw new XmlRpcException(
                BLOGGERAPI_DISABLED, BLOGGERAPI_DISABLED_MSG);
        }       
        return website;
    }
View Full Code Here

            mLogger.error("ERROR internal error validating user", e);
        }
       
        if ( !enabled )
        {
            throw new XmlRpcException(
                BLOGGERAPI_DISABLED, BLOGGERAPI_DISABLED_MSG);
        }
       
        if ( !authenticated )
        {
            throw new XmlRpcException(
                AUTHORIZATION_EXCEPTION, AUTHORIZATION_EXCEPTION_MSG);
        }
        return authenticated;
    }
View Full Code Here

            // notify cache
            flushPageCache(entry.getWebsite());
        } catch (Exception e) {
            String msg = "ERROR in blogger.deletePost: "+e.getClass().getName();
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
        }
       
        return true;
    }
View Full Code Here

        mLogger.debug("       Type: " + templateType);
       
        validate(blogid, userid, password);
       
        if (! templateType.equals("main")) {
            throw new XmlRpcException(
                    UNKNOWN_EXCEPTION, "Roller only supports main template");
        }
       
        try {
            Roller roller = RollerFactory.getRoller();
            UserManager userMgr = roller.getUserManager();
           
            WeblogTemplate page = userMgr.getPage(templateType);
            page.setContents(templateData);
            userMgr.savePage(page);
            flushPageCache(page.getWebsite());
           
            return true;
        } catch (RollerException e) {
            String msg = "ERROR in BlooggerAPIHander.setTemplate";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION,msg);
        }
    }
View Full Code Here

            Roller roller = RollerFactory.getRoller();
            UserManager userMgr = roller.getUserManager();
            WeblogTemplate page = userMgr.getPage(templateType);
           
            if ( null == page ) {
                throw new XmlRpcException(UNKNOWN_EXCEPTION,"Template not found");
            } else {
                return page.getContents();
            }
        } catch (Exception e) {
            String msg = "ERROR in BlooggerAPIHander.getTemplate";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION,msg);
        }
    }
View Full Code Here

           
            return result;
        } catch (RollerException e) {
            String msg = "ERROR in BlooggerAPIHander.getInfo";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION,msg);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.xmlrpc.XmlRpcException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.