Package org.apache.roller.presentation

Examples of org.apache.roller.presentation.RollerSession


        ActionForward forward = mapping.findForward("CategoriesForm");

        CategoriesPageModel pageModel = new CategoriesPageModel(
                request, response, mapping, (CategoriesForm)actionForm);
       
        RollerSession rses = RollerSession.getRollerSession(request);
        if (rses.isUserAuthorizedToAuthor(pageModel.getCategory().getWebsite()))
        {
            request.setAttribute("model", pageModel);
            try
            {
                WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
View Full Code Here


    public void initNew(HttpServletRequest request, HttpServletResponse response)
    {
        mLogger.debug("init new called");
       
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        RollerSession rses = RollerSession.getRollerSession(request);
        if (rreq.getWebsite().getDefaultPlugins() != null)
        {
            setPluginsArray(StringUtils.split(
                    rreq.getWebsite().getDefaultPlugins(), ",") );
        }
View Full Code Here

        WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();

        String catid = request.getParameter(RollerRequest.WEBLOGCATEGORYID_KEY);
        WeblogCategoryData catToDelete =
                wmgr.getWeblogCategory(catid);
        RollerSession rses = RollerSession.getRollerSession(request);
        if (rses.isUserAuthorizedToAuthor(catToDelete.getWebsite()))
        {
            String returnId = null;
            if (catToDelete.getParent() != null)
            {
                returnId = catToDelete.getParent().getId();
View Full Code Here

     *  Check if the user has editing rights.
     */
    protected boolean hasRequiredRights(RollerRequest rreq, WebsiteData website)
        throws RollerException
    {
        RollerSession rses = RollerSession.getRollerSession(rreq.getRequest());
        return (rses.isUserAuthorizedToAdmin(website)
            && !PingConfig.getDisallowCustomTargets());
    }
View Full Code Here

    {
        ActionForward forward = mapping.findForward("importEntries.page");
        try
        {
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            RollerSession rollerSession = RollerSession.getRollerSession(rreq.getRequest());
            if ( rreq.getWebsite() == null
                  || !rollerSession.isUserAuthorizedToAdmin(rreq.getWebsite()))
            {
                forward = mapping.findForward("access-denied");
            }
            else
            {
View Full Code Here

    {
        ActionForward forward = mapping.findForward("importEntries.page");
        try
        {
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            RollerSession rses = RollerSession.getRollerSession(request);
            if ( rreq.getWebsite() == null
                 || !rses.isUserAuthorizedToAdmin(rreq.getWebsite()) )
            {
                forward = mapping.findForward("access-denied");
            }
            else
            {
View Full Code Here

            throws IOException, ServletException {
       
        ActionErrors errors = new ActionErrors();
        ActionForward forward = mapping.findForward("editTheme.page");
        try {
            RollerSession rses = RollerSession.getRollerSession(request);
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            WebsiteData website = rreq.getWebsite();
            if ( rses.isUserAuthorizedToAdmin(website) ) {
               
                BasePageModel pageModel = new BasePageModel(
                        "themeEditor.title", request, response, mapping);
                request.setAttribute("model",pageModel);         
                   
                // get users current theme and our themes list
                Roller roller = RollerFactory.getRoller();
                ThemeManager themeMgr = roller.getThemeManager();
               
                String username = rses.getAuthenticatedUser().getUserName();
                String currentTheme = website.getEditorTheme();
                List themes = themeMgr.getEnabledThemesList();
               
                // this checks if the website has a default page template
                // if not then we don't allow for a custom theme
View Full Code Here

        ActionErrors errors = new ActionErrors();
        FolderFormEx theForm = (FolderFormEx)actionForm;
        ActionForward fwd = mapping.findForward("importBookmarks.page");
       
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        RollerSession rses = RollerSession.getRollerSession(request);       
        BookmarkManager bm = RollerFactory.getRoller().getBookmarkManager();
       
        BasePageModel pageModel = new BasePageModel(
            "bookmarksImport.title", request, response, mapping);
        request.setAttribute("model", pageModel);

        WebsiteData website = getWebsite(request);
        pageModel.setWebsite(website);
       
        // if user authorized and a file is being uploaded
        if (rses.isUserAuthorizedToAuthor(website) && theForm.getBookmarksFile() != null) {
           
            // 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");
            }           
            boolean writeFile = false;
           
            //retrieve the file representation
            FormFile file = theForm.getBookmarksFile();
            String data = null;
            InputStream stream = null;
            try {
              
                //retrieve the file data
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                stream = file.getInputStream();
                if (!writeFile) {
                    //only write files out that are less than 1MB
                    if (file.getFileSize() < (4*1024000)) {
                       
                        byte[] buffer = new byte[8192];
                        int bytesRead = 0;
                        while ((bytesRead=stream.read(buffer,0,8192)) != -1) {
                            baos.write(buffer, 0, bytesRead);
                        }
                        data = new String(baos.toByteArray());
                       
                        SimpleDateFormat formatter =
                                new SimpleDateFormat("yyyyMMddHHmmss");
                        Date now = new Date();
                        String folderName = "imported-" + formatter.format(now);
                       
                        // Use Roller BookmarkManager to import bookmarks

                        bm.importBookmarks(website, folderName, data)
                        RollerFactory.getRoller().flush();
                        CacheManager.invalidate(website);
                       
                        ActionMessages messages = new ActionMessages();
                        messages.add(ActionMessages.GLOBAL_MESSAGE,
                           new ActionMessage("bookmarksImport.imported", folderName));
                        saveMessages(request, messages);
                    }
                    else {
                        data = "The file is greater than 4MB, "
                                +" and has not been written to stream."
                                +" File Size: "+file.getFileSize()+" bytes. "
                                +" This is a limitation of this particular "
                                +" web application, hard-coded in "
                                +" org.apache.struts.webapp.upload.UploadAction";
                        errors.add(ActionErrors.GLOBAL_ERROR,
                           new ActionError("bookmarksImport.error",data));
                    }
                }
               
            }
            catch (Exception e) {
                errors.add(ActionErrors.GLOBAL_ERROR,
                     new ActionError("bookmarksImport.error",e.toString()));
                saveErrors(request,errors);
                mLogger.error("ERROR: importing bookmarks",e);
            }
            finally {
                if ( stream!=null ) {
                    try { stream.close(); }
                    catch (Exception e) { mLogger.error("Closing stream",e); };
                }
            }           
            //destroy the temporary file created
            file.destroy();
        }
        else if (!rses.isUserAuthorizedToAuthor(website)) {
            fwd = mapping.findForward("access-denied");
        }       
        return fwd;
    }
View Full Code Here

            throws IOException, ServletException {
       
        ActionErrors errors = new ActionErrors();
        ActionForward forward = mapping.findForward("editTheme.page");
        try {
            RollerSession rses = RollerSession.getRollerSession(request);           
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            WebsiteData website = rreq.getWebsite();
            if ( rses.isUserAuthorizedToAdmin(website)) {

                // get users current theme
                Roller roller = RollerFactory.getRoller();
                ThemeManager themeMgr = roller.getThemeManager();
               
                   
                BasePageModel pageModel = new BasePageModel(
                        "themeEditor.title", request, response, mapping);
                request.setAttribute("model",pageModel);         
                   
                String username = rses.getAuthenticatedUser().getUserName();
                String currentTheme = website.getEditorTheme();
                List themes = themeMgr.getEnabledThemesList();
               
                // this checks if the website has a default page template
                // if not then we don't allow for a custom theme
View Full Code Here

            throws IOException, ServletException {
       
        ActionErrors errors = new ActionErrors();
        ActionForward forward = mapping.findForward("editTheme.page");
        try {
            RollerSession rses = RollerSession.getRollerSession(request);
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            WebsiteData website = rreq.getWebsite();
            if ( rses.isUserAuthorizedToAdmin(website) ) {
               
                BasePageModel pageModel = new BasePageModel(
                        "themeEditor.title", request, response, mapping);
                request.setAttribute("model",pageModel);         
                   
                String newTheme = null;
               
                // lookup what theme the user wants first
                String theme = request.getParameter("theme");
                try {
                    Roller roller = RollerFactory.getRoller();
                    ThemeManager themeMgr = roller.getThemeManager();
                    Theme previewTheme = themeMgr.getTheme(theme);
                   
                    if(previewTheme.isEnabled()) {
                        newTheme = previewTheme.getName();
                    } else {
                        errors.add(null, new ActionMessage("Theme not enabled"));
                        saveErrors(request, errors);
                    }
                   
                } catch(ThemeNotFoundException tnfe) {
                    // possibly selected "custom"
                    if(theme != null && theme.equals(Theme.CUSTOM)) {
                        newTheme = Theme.CUSTOM;
                    } else {
                        // hmm ... that's weird
                        mLogger.warn(tnfe);
                        errors.add(null, new ActionMessage("Theme not found"));
                        saveErrors(request, errors);
                    }
                }
               
                // update theme for website and save
                if(newTheme != null) {
                    try {
                        String username = rses.getAuthenticatedUser().getUserName();
                       
                        website.setEditorTheme(newTheme);
                       
                        UserManager userMgr = RollerFactory.getRoller().getUserManager();
                        userMgr.saveWebsite(website);
View Full Code Here

TOP

Related Classes of org.apache.roller.presentation.RollerSession

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.