Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.WebsiteData


        // get all entries in category and subcats
        List results = getWeblogEntries(srcCd, true);
       
        // Loop through entries in src cat, assign them to dest cat
        Iterator iter = results.iterator();
        WebsiteData website = destCd.getWebsite();
        while (iter.hasNext()) {
            WeblogEntryData entry = (WeblogEntryData) iter.next();
            entry.setCategory(destCd);
            entry.setWebsite(website);
            this.strategy.store(entry);
View Full Code Here


       
        if (weblogHandle == null)
            return;
       
        String selfSiteFragment = "/page/"+weblogHandle;
        WebsiteData weblog = null;
        WeblogEntryData entry = null;
       
        // lookup the weblog now
        try {
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
View Full Code Here

       
        // check cache first
        // NOTE: if we ever allow changing handles then this needs updating
        if(this.weblogHandleToIdMap.containsKey(handle)) {
           
            WebsiteData weblog = this.getWebsite((String) this.weblogHandleToIdMap.get(handle));
            if(weblog != null) {
                // only return weblog if enabled status matches
                if(enabled == null || enabled.equals(weblog.getEnabled())) {
                    log.debug("weblogHandleToId CACHE HIT - "+handle);
                    return weblog;
                }
            } else {
                // mapping hit with lookup miss?  mapping must be old, remove it
                this.weblogHandleToIdMap.remove(handle);
            }
        }
       
        // cache failed, do lookup
        try {
            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
            Criteria criteria = session.createCriteria(WebsiteData.class);
           
            if (enabled != null) {
                criteria.add(
                        Expression.conjunction()
                        .add(new IgnoreCaseEqExpression("handle", handle))
                        .add(Expression.eq("enabled", enabled)));
            } else {
                criteria.add(
                        Expression.conjunction()
                        .add(Expression.eq("handle", handle)));
            }
           
            WebsiteData website = (WebsiteData) criteria.uniqueResult();
           
            // add mapping to cache
            if(website != null) {
                log.debug("weblogHandleToId CACHE MISS - "+handle);
                this.weblogHandleToIdMap.put(website.getHandle(), website.getId());
            }
           
            return website;
        } catch (HibernateException e) {
            throw new RollerException(e);
View Full Code Here

       
        String id = pingTarget.getId();
       
        // Determine the set of "brother" targets (custom or common) among which this name should be unique.
        List brotherTargets = null;
        WebsiteData website = pingTarget.getWebsite();
        if (website == null) {
            brotherTargets = getCommonPingTargets();
        } else {
            brotherTargets = getCustomPingTargets(website);
        }
View Full Code Here

        YourWebsitesForm form = (YourWebsitesForm)actionForm;
       
        RollerSession rses = RollerSession.getRollerSession(request);
        UserData user = rses.getAuthenticatedUser();
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        WebsiteData website = rreq.getWebsite();
       
        UserManager userMgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perms = userMgr.getPermissions(website, user);
       
        if (perms != null)
View Full Code Here

            HttpServletResponse response)
            throws Exception {
       
        ActionForward fwd =  mapping.findForward("access-denied");
        RollerSession rses = RollerSession.getRollerSession(request);
        WebsiteData website = getWebsite(request);
       
        if (rses.isUserAuthorizedToAuthor(website)) {
            UploadFilePageModel pageModel = new UploadFilePageModel(
                request, response, mapping, website.getHandle());
            pageModel.setWebsite(website);
            request.setAttribute("model", pageModel);
            fwd = mapping.findForward("uploadFiles.page");
        }       
        return fwd;
View Full Code Here

            HttpServletRequest  request,
            HttpServletResponse response)
            throws Exception {
       
        ActionForward fwd = mapping.findForward("access-denied");
        WebsiteData website = getWebsite(request);
        RollerMessages rollerMessages = new RollerMessages();
        RollerSession rses = RollerSession.getRollerSession(request);
        List lastUploads = new ArrayList();
       
        if ( rses.isUserAuthorizedToAuthor(website)) {
           
            FileManager fmgr = RollerFactory.getRoller().getFileManager();
            fwd = mapping.findForward("uploadFiles.page");
            ActionMessages messages = new ActionMessages();
            ActionErrors errors = new ActionErrors();
            UploadFileForm theForm = (UploadFileForm)actionForm;
            if (theForm.getUploadedFiles().length > 0) {
                ServletContext app = servlet.getServletConfig().getServletContext();

                boolean uploadEnabled =
                        RollerRuntimeConfig.getBooleanProperty("uploads.enabled");

                if ( !uploadEnabled ) {
                    errors.add(ActionErrors.GLOBAL_ERROR,
                            new ActionError("error.upload.disabled", ""));
                    saveErrors(request, errors);
                    return fwd;
                }

                //this line is here for when the input page is upload-utf8.jsp,
                //it sets the correct character encoding for the response
                String encoding = request.getCharacterEncoding();
                if ((encoding != null) && (encoding.equalsIgnoreCase("utf-8"))) {
                    response.setContentType("text/html; charset=utf-8");
                }

                //retrieve the file representation
                FormFile[] files = theForm.getUploadedFiles();
                int fileSize = 0;
                try {
                    for (int i=0; i<files.length; i++) {
                        if (files[i] == null) continue;

                        // retrieve the file name
                        String fileName= files[i].getFileName();
                        int terminated = fileName.indexOf("\000");
                        if (terminated != -1) {
                            // disallow sneaky null terminated strings
                            fileName = fileName.substring(0, terminated).trim();
                        }

                        fileSize = files[i].getFileSize();

                        //retrieve the file data
                        if (fmgr.canSave(website.getHandle(), fileName, fileSize, rollerMessages)) {
                            InputStream stream = files[i].getInputStream();
                            fmgr.saveFile(website.getHandle(), fileName, fileSize, stream);
                            lastUploads.add(fileName);
                        }
                       
                        //destroy the temporary file created
                        files[i].destroy();
                    }
                } catch (Exception e) {
                    errors.add(ActionErrors.GLOBAL_ERROR,
                        new ActionError("error.upload.file",e.toString()));
                }
            }       
            UploadFilePageModel pageModel = new UploadFilePageModel(
                request, response, mapping, website.getHandle(), lastUploads);
            request.setAttribute("model", pageModel);
            pageModel.setWebsite(website);
           
            RollerContext rctx = RollerContext.getRollerContext();
        String baseURL = rctx.getAbsoluteContextUrl(request);
            String resourcesBaseURL = baseURL + fmgr.getUploadUrl() + "/" + website.getHandle();
            Iterator uploads = lastUploads.iterator();
            if (uploads.hasNext()) {
                messages.add(ActionMessages.GLOBAL_MESSAGE,
                    new ActionMessage("uploadFiles.uploadedFiles"));
            }
View Full Code Here

        ActionMessages messages = new ActionMessages();
        ActionErrors errors = new ActionErrors();
        UploadFileForm theForm = (UploadFileForm)actionForm;
        ActionForward fwd = mapping.findForward("access-denied");       
        WebsiteData website = getWebsite(request);

        int count = 0;
        RollerSession rses = RollerSession.getRollerSession(request);
        if (rses.isUserAuthorizedToAuthor(website)) {
            fwd = mapping.findForward("uploadFiles.page");
            try {
                FileManager fmgr = RollerFactory.getRoller().getFileManager();
                String[] deleteFiles = theForm.getDeleteFiles();
                for (int i=0; i<deleteFiles.length; i++) {
                    if (    deleteFiles[i].trim().startsWith("/")
                    || deleteFiles[i].trim().startsWith("\\")
                    || deleteFiles[i].indexOf("..") != -1) {
                        // ignore absolute paths, or paths that contiain '..'
                    } else {
                        fmgr.deleteFile(website.getHandle(), deleteFiles[i]);
                        count++;
                    }
                }
            } catch (Exception e) {
                errors.add(ActionErrors.GLOBAL_ERROR,
                        new ActionError("error.upload.file",e.toString()));
                saveErrors(request,errors);
            }
           
            messages.add(ActionMessages.GLOBAL_MESSAGE,
                new ActionMessage("uploadFiles.deletedFiles", new Integer(count)));
            saveMessages(request, messages);
           
            UploadFilePageModel pageModel = new UploadFilePageModel(
                request, response, mapping, website.getHandle());
            pageModel.setWebsite(website);
            request.setAttribute("model", pageModel);
        }
        return fwd;
    }
View Full Code Here

     * request params don't come accross in a file-upload post so we have to
     * stash the website handle in the session.
     */
    public static WebsiteData getWebsite(HttpServletRequest request) throws RollerException {
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        WebsiteData website = rreq.getWebsite();
        if (website != null) {
            request.getSession().setAttribute(HANDLE, website.getHandle());
        } else {
            String handle = (String)request.getSession().getAttribute(HANDLE);
            Roller roller = RollerFactory.getRoller();
            website = roller.getUserManager().getWebsiteByHandle(handle);
        }
View Full Code Here

               
                log.debug("Getting LOCAL feed "+sub.getFeedUrl());
               
                // get corresponding website object
                UserManager usermgr = RollerFactory.getRoller().getUserManager();
                WebsiteData website = usermgr.getWebsiteByHandle(sub.getAuthor());
                if (website == null) return newEntries;
               
                // figure website last update time
                WeblogManager blogmgr = RollerFactory.getRoller().getWeblogManager();
               
                Date siteUpdated = blogmgr.getWeblogLastPublishTime(website);
                if (siteUpdated == null) { // Site never updated, skip it
                    log.warn("Last-publish time null, skipping local feed ["
                            + website.getHandle() + "]");
                    return newEntries;
                }
               
                // if website last update time > subsciption last update time
                List entries = new ArrayList();
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.