Package org.apache.roller.presentation.weblog.formbeans

Examples of org.apache.roller.presentation.weblog.formbeans.WeblogEntryManagementForm


        ActionForward forward = mapping.findForward("exportEntries.page");
        try
        {
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            RollerSession rses = RollerSession.getRollerSession(rreq.getRequest());
            WeblogEntryManagementForm form = (WeblogEntryManagementForm)actionForm;
            if ( rreq.getWebsite() != null
                    && rses.isUserAuthorizedToAdmin(rreq.getWebsite()) )
            {              
                request.setAttribute("model",
                        new BasePageModel("", request, response, mapping));
               
                Locale locale = Locale.getDefault();//rreq.getWebsite().getLocaleInstance();
                final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
                Date startDate;
                Date endDate;
                try
                {
                    startDate = DateUtil.getStartOfDay(df.parse(form.getStartDateString()));
                    endDate = DateUtil.getEndOfDay(df.parse(form.getEndDateString()));
                }
                catch (ParseException e)
                {
                    throw new RollerException("ERROR parsing date:" + e.getMessage());
                }
               
                if (startDate != null && endDate != null)
                {
                    // this work should go into a Thread!
                    WeblogManager weblogMgr =
                        RollerFactory.getRoller().getWeblogManager();
                   
                    //List entries = weblogMgr.getWeblogEntriesInDateRange(
                        //rreq.getUser().getUserName(), null, startDate, endDate, false);
                    //System.out.println("Export: got " + entries.size() + " entries.");
                   
                    List entries = weblogMgr.getWeblogEntries(
                                    rreq.getWebsite(), // userName
                                    startDate,         // startDate
                                    endDate,           // endDate
                                    null,              // catName
                                    null,              // status
                                    null,              // sortby (null for pubtime)
                                    null);             // maxEntries

                    ActionMessages messages = writeSuccessMessage(request, response, rreq, form);

                    // seperate the entries as specified: day, month, year
                    Map entryMap = seperateByPeriod(entries, form.getFileBy());

                    // now export each List in the entryMap
                    ExportRss exporter = new ExportRss(rreq.getWebsite());
                    String exportTo = form.getExportFormat().toLowerCase();
                    if ("atom".equals(exportTo))
                    {
                        exporter.setExportAtom(true);
                    }
                    ArrayList fileNames = new ArrayList();
                    Iterator it = entryMap.keySet().iterator();
                    while(it.hasNext())
                    {
                        String key = (String)it.next();
                        ArrayList list = (ArrayList)entryMap.get(key);
                        exporter.exportEntries(list, key+"_"+exportTo+".xml");
                        fileNames.add("Exported " + list.size() + " entry(s) to " + key+"_"+exportTo+".xml<br />");
                        //System.out.println("Exported: " + list.size() + " entries for " + key);
                    }
                   
                    StringBuffer fileMessage = new StringBuffer();
                    it = fileNames.iterator();
                    while (it.hasNext())
                    {
                        fileMessage.append((String)it.next());
                    }
                    if (fileMessage.length() > 0)
                    {
                        messages.add(ActionMessages.GLOBAL_MESSAGE,
                                     new ActionMessage("weblogEntryExport.exportFiles",
                                                       fileMessage.toString()));
                    }
                    saveMessages(request, messages);
                }
                else
                {
                    form.reset(mapping, (ServletRequest)request);
                    return edit(mapping, actionForm, request, response);
                }

                //forward = mapping.findForward("exportEntries.done");
            }
View Full Code Here


        ActionForm          actionForm,
        HttpServletRequest  request,
        HttpServletResponse response)
        throws IOException, ServletException, RollerException
    {
        WeblogEntryManagementForm form = (WeblogEntryManagementForm)actionForm;
        RollerRequest   rreq = RollerRequest.getRollerRequest(request);
        WeblogManager   wmgr = RollerFactory.getRoller().getWeblogManager();          
        RollerSession   rses = RollerSession.getRollerSession(request);
       
        // ensure that weblog is specfied and user has permission to work there
        if (rreq.getWebsite() != null && rses.isUserAuthorized(rreq.getWebsite())) {
            String status= form.getStatus().equals("ALL") ? null : form.getStatus();       
            request.setAttribute("model", new PageModel(
               request,
               response,
               mapping,
               rreq.getWebsite(),
View Full Code Here

TOP

Related Classes of org.apache.roller.presentation.weblog.formbeans.WeblogEntryManagementForm

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.