Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.WebsiteData


                UserData user = umgr.getUserByUsername(userid);
                // get list of user's enabled websites
                List websites = umgr.getWebsites(user, Boolean.TRUE, null);
                Iterator iter = websites.iterator();
                while (iter.hasNext()) {
                    WebsiteData website = (WebsiteData)iter.next();
                    Hashtable blog = new Hashtable(3);
                    blog.put("url", contextUrl+"/page/"+website.getHandle());
                    blog.put("blogid", website.getHandle());
                    blog.put("blogName", website.getName());
                    result.add(blog);
                }
            } catch (Exception e) {
                String msg = "ERROR in BlooggerAPIHander.getUsersBlogs";
                mLogger.error(msg,e);
View Full Code Here


        mLogger.debug("     BlogId: " + blogid);
        mLogger.debug("     UserId: " + userid);
        mLogger.debug("    Publish: " + publish);
        mLogger.debug("    Content:\n " + content);
       
        WebsiteData website = validate(blogid, userid, password);
       
        // extract the title from the content
        String title = "";
       
        if (content.indexOf("<title>") != -1) {
            title =
                    content.substring(content.indexOf("<title>") + 7,
                    content.indexOf("</title>"));
            content = StringUtils.replace(content, "<title>"+title+"</title>", "");
        }
        if (Utilities.isEmpty(title)) {
            title = Utilities.truncateNicely(content, 15, 15, "...");
        }
       
        try {
            RollerRequest rreq = RollerRequest.getRollerRequest();
            Roller roller = RollerFactory.getRoller();
            WeblogManager weblogMgr = roller.getWeblogManager();
           
            Timestamp current = new Timestamp(System.currentTimeMillis());
           
            WeblogEntryData entry = new WeblogEntryData();
            entry.setTitle(title);
            entry.setText(content);
            entry.setPubTime(current);
            entry.setUpdateTime(current);
            UserData user = roller.getUserManager().getUserByUsername(userid);
            entry.setCreator(user);
            entry.setWebsite(website);
            entry.setCategory(website.getBloggerCategory());
            if (Boolean.valueOf(publish).booleanValue()) {
                entry.setStatus(WeblogEntryData.PUBLISHED);
            } else {
                entry.setStatus(WeblogEntryData.DRAFT);
            }
View Full Code Here

        mLogger.debug("     Appkey: " + appkey);
        mLogger.debug("     BlogId: " + blogid);
        mLogger.debug("     UserId: " + userid);
        mLogger.debug("     Number: " + numposts);
       
        WebsiteData website = validate(blogid, userid,password);
       
        try {
            Vector results = new Vector();
           
            Roller roller = RollerFactory.getRoller();
View Full Code Here

        CreateWebsiteForm form = (CreateWebsiteForm)actionForm;
        ActionMessages msgs = new ActionMessages();
        ActionMessages errors = validate(form, new ActionErrors());
        ActionForward forward = mapping.findForward("yourWebsites");
        Roller roller = RollerFactory.getRoller();
        WebsiteData website = null;
        if (!errors.isEmpty())
        {
            saveErrors(request, errors);
            forward = mapping.findForward("createWebsite.page");
        }
        else try
        {
            RollerContext rollerContext = RollerContext.getRollerContext();
            UserData user =
                RollerSession.getRollerSession(request).getAuthenticatedUser();
            UserManager mgr = roller.getUserManager();
           
            if (!RollerConfig.getBooleanProperty("groupblogging.enabled")) {         
                List permissions = roller.getUserManager().getAllPermissions(user);
                if (permissions.size() > 0) {
                    // sneaky user trying to get around 1 blog limit that applies
                    // only when group blogging is disabled
                    return mapping.findForward("access-denied");
                }
            }
           
            WebsiteData wd = new WebsiteData(
                    form.getHandle(),
                    user,
                    form.getName(),
                    form.getDescription(),
                    form.getEmailAddress(),
                    form.getEmailAddress(),
                    form.getTheme(),
                    form.getLocale(),
                    form.getTimeZone());
           
            try {
                String def = RollerRuntimeConfig.getProperty("users.editor.pages");
                String[] defs = Utilities.stringToStringArray(def,",");
                wd.setEditorPage(defs[0]);
            } catch (Exception ex) {
                log.error("ERROR setting default editor page for weblog", ex);
            }
           
            mgr.addWebsite(wd);
View Full Code Here

                return;
            }
        }
       
       
        WebsiteData weblog = null;
        boolean isSiteWide = false;
       
        WeblogPageRequest pageRequest = null;
        try {
            pageRequest = new WeblogPageRequest(request);
           
            weblog = pageRequest.getWeblog();
            if(weblog == null) {
                throw new RollerException("unable to lookup weblog: "+
                        pageRequest.getWeblogHandle());
            }
           
            // is this the site-wide weblog?
            isSiteWide = RollerRuntimeConfig.isSiteWideWeblog(pageRequest.getWeblogHandle());
           
        } catch (Exception e) {
            // some kind of error parsing the request or looking up weblog
            log.debug("error creating page request", e);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
       
        // determine the lastModified date for this content
        long lastModified = System.currentTimeMillis();
        if(isSiteWide) {
            lastModified = siteWideCache.getLastModified().getTime();
        } else if (weblog.getLastModified() != null) {
            lastModified = weblog.getLastModified().getTime();
        }

        // 304 Not Modified handling.
        // We skip this for logged in users to avoid the scenerio where a user
        // views their weblog, logs in, then gets a 304 without the 'edit' links
        if(!pageRequest.isLoggedIn()) {
            if (ModDateHeaderUtil.respondIfNotModified(request,response,lastModified)) {
                return;
            } else {
                // set last-modified date
                ModDateHeaderUtil.setLastModifiedHeader(response,lastModified);
            }
        }

               
        // generate cache key
        String cacheKey = null;
        if(isSiteWide) {
            cacheKey = siteWideCache.generateKey(pageRequest);
        } else {
            cacheKey = weblogPageCache.generateKey(pageRequest);
        }
       
        // cached content checking
        if((!this.excludeOwnerPages || !pageRequest.isLoggedIn()) &&
                request.getAttribute("skipCache") == null) {
           
            CachedContent cachedContent = null;
            if(isSiteWide) {
                cachedContent = (CachedContent) siteWideCache.get(cacheKey);
            } else {
                cachedContent = (CachedContent) weblogPageCache.get(cacheKey, lastModified);
            }
           
            if(cachedContent != null) {
                log.debug("HIT "+cacheKey);
               
                // allow for hit counting
                if(!isSiteWide) {
                    this.processHit(weblog, request.getRequestURL().toString(), request.getHeader("referer"));
                }
       
                response.setContentLength(cachedContent.getContent().length);
                response.setContentType(cachedContent.getContentType());
                response.getOutputStream().write(cachedContent.getContent());
                return;
               
            } else {
                log.debug("MISS "+cacheKey);
            }
        }

       
        // figure out what we are going to render
        Template page = null;
       
        // If this is a popup request, then deal with it specially
        // TODO: do we really need to keep supporting this?
        if (request.getParameter("popup") != null) {
            try {
                // Does user have a popupcomments page?
                page = weblog.getPageByName("_popupcomments");
            } catch(Exception e ) {
                // ignored ... considered page not found
            }
           
            // User doesn't have one so return the default
            if(page == null) {
                page = new WeblogTemplate("templates/weblog/popupcomments.vm", weblog,
                        "Comments", "Comments", "dummy_link",
                        "dummy_template", new Date(), "velocity", true, false, null);
            }
           
        // If request specified the page, then go with that
        } else if (pageRequest.getWeblogPageName() != null) {
            page = pageRequest.getWeblogPage();
           
        // If page not available from request, then use weblog's default
        } else {
            try {
                page = weblog.getDefaultPage();
            } catch(Exception e) {
                log.error("Error getting weblogs default page", e);
            }
        }
       
        // Still no page?  Then that is a 404
        if (page == null) {
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
        log.debug("page found, dealing with it");
       
       
        // validation.  make sure that request input makes sense.
        boolean invalid = false;
        if(pageRequest.getWeblogPageName() != null && page.isHidden()) {
            invalid = true;
        }
        if(pageRequest.getLocale() != null) {
           
            // locale view only allowed if weblog has enabled it
            if(!pageRequest.getWeblog().isEnableMultiLang()) {
                invalid = true;
            }
           
        }
        if(pageRequest.getWeblogAnchor() != null) {
           
            // permalink specified.
            // entry must exist, be published before current time, and locale must match
            WeblogEntryData entry = pageRequest.getWeblogEntry();
            if(entry == null) {
                invalid = true;
            } else if (pageRequest.getLocale() != null &&
                    !entry.getLocale().startsWith(pageRequest.getLocale())) {
                invalid = true;
            } else if (!entry.isPublished()) {
                invalid = true;
            } else if (new Date().before(entry.getPubTime())) {
                invalid = true;
            }
           
        } else if(pageRequest.getWeblogCategoryName() != null) {
           
            // category specified.  category must exist.
            if(pageRequest.getWeblogCategory() == null) {
                invalid = true;
            }
           
        } else if(pageRequest.getTags() != null && pageRequest.getTags().size() > 0) {
           
            try {
                // tags specified.  make sure they exist.
                WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
                invalid = !wmgr.getTagComboExists(pageRequest.getTags(), (isSiteWide) ? null : weblog);
            } catch (RollerException ex) {
                invalid = true;
            }
        }

       
        if(invalid) {
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
       
        // allow for hit counting
        if(!isSiteWide) {
            this.processHit(weblog, request.getRequestURL().toString(), request.getHeader("referer"));
        }
       

        // looks like we need to render content
       
        // set the content type
        String mimeType = RollerContext.getServletContext().getMimeType(page.getLink());
        String contentType = "text/html; charset=utf-8";
        if(mimeType != null) {
            // we found a match ... set the content type
            contentType = mimeType+"; charset=utf-8";
        }

        HashMap model = new HashMap();
        try {
            PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
                    this, request, response,"", false, 8192, true);
           
            // special hack for menu tag
            request.setAttribute("pageRequest", pageRequest);
           
            // populate the rendering model
            Map initData = new HashMap();
            initData.put("request", request);
            initData.put("requestParameters", request.getParameterMap());
            initData.put("weblogRequest", pageRequest);
            initData.put("pageContext", pageContext);
           
            // if this was a comment posting, check for comment form
            WeblogEntryCommentForm commentForm =
                    (WeblogEntryCommentForm) request.getAttribute("commentForm");
            if(commentForm != null) {
                initData.put("commentForm", commentForm);
            }
           
            // Load models for pages
            String pageModels = RollerConfig.getProperty("rendering.pageModels");
            ModelLoader.loadModels(pageModels, model, initData, true);
           
            // Load special models for site-wide blog
            if(RollerRuntimeConfig.isSiteWideWeblog(weblog.getHandle())) {
                String siteModels = RollerConfig.getProperty("rendering.siteModels");
                ModelLoader.loadModels(siteModels, model, initData, true);
            }

            // Load weblog custom models
View Full Code Here

            HttpServletResponse response)
            throws IOException, ServletException {
       
        try {
            RollerRequest rreq  = RollerRequest.getRollerRequest(request);
            WebsiteData website = rreq.getWebsite();
            RollerSession rses = RollerSession.getRollerSession(request);
           
            if (rses.isUserAuthorizedToAdmin(website) ) {
                IndexManager manager =
                        RollerFactory.getRoller().getIndexManager();
View Full Code Here

            HttpServletResponse response)
            throws IOException, ServletException {
       
        try {
            RollerRequest rreq  = RollerRequest.getRollerRequest(request);
            WebsiteData website = rreq.getWebsite();
            RollerSession rses = RollerSession.getRollerSession(request);
           
            if ( rses.isUserAuthorizedToAdmin(website) ) {
               
                // some caches are based on weblog last-modified, so update it
                website.setLastModified(new Date());
               
                try {
                    UserManager umgr = RollerFactory.getRoller().getUserManager();
                    umgr.saveWebsite(website);
                    RollerFactory.getRoller().flush();
View Full Code Here

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
       
        log.debug("Entering");
       
        WebsiteData weblog = null;
        WeblogSearchRequest searchRequest = null;
       
        // first off lets parse the incoming request and validate it
        try {
            searchRequest = new WeblogSearchRequest(request);
           
            // now make sure the specified weblog really exists
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
            weblog = userMgr.getWebsiteByHandle(searchRequest.getWeblogHandle(), Boolean.TRUE);
           
        } catch(Exception e) {
            // invalid search request format or weblog doesn't exist
            log.debug("error creating weblog search request", e);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
        // get their default page template to use for rendering
        Template page = null;
        try {
            page = weblog.getDefaultPage();
            if(page == null) {
                throw new RollerException("Could not lookup default page "+
                        "for weblog "+weblog.getHandle());
            }
        } catch(Exception e) {
            log.error("Error getting weblogs default page", e);
        }
       
        // set the content type
        response.setContentType("text/html; charset=utf-8");
       
        // looks like we need to render content
        Map model = new HashMap();
        try {
            PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
                    this, request, response,"", false, 8192, true);
           
            // populate the rendering model
            Map initData = new HashMap();
            initData.put("request", request);
            initData.put("pageContext", pageContext);
           
            // this is a little hacky, but nothing we can do about it
            // we need the 'weblogRequest' to be a pageRequest so other models
            // are properly loaded, which means that searchRequest needs its
            // own custom initData property aside from the standard weblogRequest.
            // possible better approach is make searchRequest extend pageRequest.
            WeblogPageRequest pageRequest = new WeblogPageRequest();
            pageRequest.setWeblogHandle(searchRequest.getWeblogHandle());
            pageRequest.setWeblogCategoryName(searchRequest.getWeblogCategoryName());
            initData.put("weblogRequest", pageRequest);
            initData.put("searchRequest", searchRequest);
           
            // Load models for pages
            String searchModels = RollerConfig.getProperty("rendering.searchModels");
            ModelLoader.loadModels(searchModels, model, initData, true);
           
            // Load special models for site-wide blog
            if(RollerRuntimeConfig.isSiteWideWeblog(weblog.getHandle())) {
                String siteModels = RollerConfig.getProperty("rendering.siteModels");
                ModelLoader.loadModels(siteModels, model, initData, true);
            }

            // Load weblog custom models
View Full Code Here

        try {
            request.setAttribute("model", new BasePageModel(
                    "pagesForm.title", request, response, mapping));
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            RollerSession rses = RollerSession.getRollerSession(request);
            WebsiteData website = rreq.getWebsite();
            if ( rses.isUserAuthorizedToAdmin(website) ) {
               
                UserManager mgr = RollerFactory.getRoller().getUserManager();
               
                // first off, check if template already exists
                WeblogTemplate existingPage = mgr.getPageByName(website, form.getName());
                if(existingPage != null) {
                    ActionErrors errors = new ActionErrors();
                    errors.add(null, new ActionError("pagesForm.error.alreadyExists", form.getName()));
                    saveErrors(request, errors);
                    addModelObjects(request, response, mapping, website, null);
                    return forward;
                }
               
                WeblogTemplate data = new WeblogTemplate();
                form.copyTo(data, request.getLocale());
                data.setWebsite(website);
                data.setLastModified( new Date() );
                data.setDescription(data.getName());
                data.setContents(bundle.getString("pageForm.newTemplateContent"));
                validateLink( data );
               
                // all templates start out as velocity templates
                data.setTemplateLanguage("velocity");
               
                // for now, all templates just use _decorator
                if(!"_decorator".equals(data.getName())) {
                    data.setDecoratorName("_decorator");
                }
               
                // save the page
                mgr.savePage( data );
               
                // if this person happened to create a Weblog template from
                // scratch then make sure and set the defaultPageId
                if(WeblogTemplate.DEFAULT_PAGE.equals(data.getName())) {
                    website.setDefaultPageId(data.getId());
                    mgr.saveWebsite(website);
                }
               
                // flush results to db
                RollerFactory.getRoller().flush();
View Full Code Here

            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            RollerSession rses = RollerSession.getRollerSession(request);
            request.setAttribute("model", new BasePageModel(
                    "pagesForm.title", request, response, mapping));
           
            WebsiteData website = rreq.getWebsite();
            if (website == null && form.getId()!=null) {
                UserManager mgr = RollerFactory.getRoller().getUserManager();
                WeblogTemplate template = mgr.getPage(form.getId());
                website = template.getWebsite();
            }
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.WebsiteData

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.