Package org.apache.roller.model

Examples of org.apache.roller.model.BookmarkManager


    public String render(WeblogEntryData entry, String str)
    {
        String text = str;       
        try
        {
            BookmarkManager bMgr = RollerFactory.getRoller().getBookmarkManager();
            FolderData rootFolder = bMgr.getRootFolder(entry.getWebsite());
            text = matchBookmarks(text, rootFolder);
            text = lookInFolders(text, rootFolder.getFolders());
        }
        catch (RollerException e)
        {
View Full Code Here


    private void removeWebsiteContents(WebsiteData website)
            throws HibernateException, RollerException {
       
        Session session = this.strategy.getSession();
       
        BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();
        WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
       
        // Remove the website's ping queue entries
        Criteria criteria = session.createCriteria(PingQueueEntryData.class);
        criteria.add(Expression.eq("website", website));
        List queueEntries = criteria.list();
       
        // Remove the website's auto ping configurations
        AutoPingManager autoPingMgr = RollerFactory.getRoller().getAutopingManager();
        List autopings = autoPingMgr.getAutoPingsByWebsite(website);
        Iterator it = autopings.iterator();
        while(it.hasNext()) {
            this.strategy.remove((AutoPingData) it.next());
        }
       
        // Remove the website's custom ping targets
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        List pingtargets = pingTargetMgr.getCustomPingTargets(website);
        it = pingtargets.iterator();
        while(it.hasNext()) {
            this.strategy.remove((PingTargetData) it.next());
        }
       
        // remove entries
        Criteria entryQuery = session.createCriteria(WeblogEntryData.class);
        entryQuery.add(Expression.eq("website", website));
        List entries = entryQuery.list();
        for (Iterator iter = entries.iterator(); iter.hasNext();) {
            WeblogEntryData entry = (WeblogEntryData) iter.next();
           
            this.strategy.remove(entry);
        }
       
        // remove associated referers
        Criteria refererQuery = session.createCriteria(RefererData.class);
        refererQuery.add(Expression.eq("website", website));
        List referers = refererQuery.list();
        for (Iterator iter = referers.iterator(); iter.hasNext();) {
            RefererData referer = (RefererData) iter.next();
            this.strategy.remove(referer);
        }
       
               
        // remove associated pages
        Criteria pageQuery = session.createCriteria(WeblogTemplate.class);
        pageQuery.add(Expression.eq("website", website));
        List pages = pageQuery.list();
        for (Iterator iter = pages.iterator(); iter.hasNext();) {
            WeblogTemplate page = (WeblogTemplate) iter.next();
            this.strategy.remove(page);
        }
       
        // remove folders (including bookmarks)
        FolderData rootFolder = bmgr.getRootFolder(website);
        if (null != rootFolder) {
            this.strategy.remove(rootFolder);
           
            // Still cannot get all Bookmarks cleared!
            Iterator allFolders = bmgr.getAllFolders(website).iterator();
            while (allFolders.hasNext()) {
                FolderData aFolder = (FolderData)allFolders.next();
                bmgr.removeFolderContents(aFolder);
                this.strategy.remove(aFolder);
            }
        }
       
        // remove categories
View Full Code Here

        {
            mLogger.debug("Init called without website.  Skipping bookmark initialization.");
        }
        else
        {
            BookmarkManager bMgr = RollerFactory.getRoller().getBookmarkManager();
            List bookmarks = bMgr.getBookmarks(bMgr.getRootFolder(website), true);

            for (Iterator i = bookmarks.iterator(); i.hasNext();)
            {
                BookmarkData b = (BookmarkData) i.next();
                bookmarkMap.put(b.getName(), b);
View Full Code Here

        HttpServletResponse response)
        throws Exception
    {
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        RollerSession rses = RollerSession.getRollerSession(request);
        BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();
        BookmarkFormEx form = (BookmarkFormEx)actionForm;
       
        FolderData parentFolder = null;
        if (null!=rreq.getBookmark() && null==request.getParameter("correct"))
        {
            // If request specifies bookmark and we are not correcting an
            // already submitted form then load that bookmark into the form.
            BookmarkData bd = rreq.getBookmark();
            form.copyFrom(bd, request.getLocale());
            request.setAttribute("state","edit");
               
            // Pass bookmark's Folder on as attribute.                
            parentFolder = bd.getFolder();

            request.setAttribute("model", new BasePageModel(
                "bookmarkForm.edit.title", request, response, mapping));
        }
        else if (null != request.getParameter("correct"))
        {
            // We are correcting a previously submtted form.
            request.setAttribute("state","correcting");
               
            // Folder is specified by request param, pass it on as attribute.                
            parentFolder = bmgr.getFolder(rreq.getFolder().getId());       
           
            request.setAttribute("model", new BasePageModel(
                "bookmarkForm.correct.title", request, response, mapping));
        }
        else
        {
            // We are adding a new bookmark
            request.setAttribute("state","add");
           
            // Folder is specified by request param, pass it on as attribute.                
            parentFolder = bmgr.getFolder(rreq.getFolder().getId());
           
            request.setAttribute("model", new BasePageModel(
                "bookmarkForm.add.title", request, response, mapping));
        }
       
View Full Code Here

        throws Exception
    {
        ActionForward forward = mapping.findForward("Bookmarks");
        BookmarkFormEx form = (BookmarkFormEx)actionForm;
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();

        BookmarkData bd = null;
        if (null != form.getId() && !form.getId().trim().equals(""))
        {
            bd = bmgr.getBookmark(form.getId());
        }
        else
        {
            bd = new BookmarkData();
            FolderData fd = bmgr.getFolder(
                request.getParameter(RollerRequest.FOLDERID_KEY));
            bd.setFolder(fd);
        }
        RollerSession rses = RollerSession.getRollerSession(request);
        if (bd.getFolder().getWebsite().hasUserPermissions(
                rses.getAuthenticatedUser(), PermissionsData.AUTHOR))
        {
            form.copyTo(bd, request.getLocale());
            bmgr.saveBookmark(bd);
            RollerFactory.getRoller().flush();
           
            CacheManager.invalidate(bd);
           
            request.setAttribute(
View Full Code Here

    {
        ActionForward forward = mapping.findForward("Bookmarks");
        FolderFormEx form = (FolderFormEx)actionForm;
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        RollerSession rses = RollerSession.getRollerSession(request);
        BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();
        WebsiteData website = null;
               
        FolderData fd = null;
        if (null != form.getId() && !form.getId().trim().equals(""))
        {
            fd = bmgr.getFolder(form.getId());
            website = fd.getWebsite();
        }
        else
        {
            fd = new FolderData();
            String parentId = request.getParameter(RollerRequest.PARENTID_KEY);
            FolderData parent = bmgr.getFolder(parentId);
            website = parent.getWebsite();
            fd.setParent(parent);
            fd.setWebsite(website);
        }
       
        if (fd.getWebsite().hasUserPermissions(
                rses.getAuthenticatedUser(), PermissionsData.AUTHOR))
        {
            // Copy form values to object
            form.copyTo(fd, request.getLocale());
            bmgr.saveFolder(fd);
            RollerFactory.getRoller().flush();
           
            CacheManager.invalidate(fd);
        }
        else
View Full Code Here

        HttpServletRequest  request,
        HttpServletResponse response)
        throws Exception
    {
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();
        FolderFormEx form = (FolderFormEx)actionForm;
       
        FolderData parentFolder = null;
        if (null!=rreq.getFolder() && null==request.getParameter("correct"))
        {
            // If request specifies folder and we are not correcting an
            // already submitted form then load that folder into the form.
            request.setAttribute("state","edit");

            FolderData fd = rreq.getFolder();
            form.copyFrom(fd, request.getLocale());
            parentFolder = fd.getParent();
           
            BasePageModel pageModel = new BasePageModel(
                "folderForm.add.title", request, response, mapping);
            pageModel.setWebsite(parentFolder.getWebsite());
            request.setAttribute("model", pageModel);
        }
        else if (null != request.getParameter("correct"))
        {
            // We are correcting a previously submtted form.
            request.setAttribute("state","correcting");
           
            String parentId = request.getParameter(RollerRequest.PARENTID_KEY);
            parentFolder = bmgr.getFolder(parentId);
           
            BasePageModel pageModel = new BasePageModel(
                "folderForm.correct.title", request, response, mapping);
            pageModel.setWebsite(parentFolder.getWebsite());
            request.setAttribute("model", pageModel);
        }
        else
        {
            // We are adding a new bookmark
            request.setAttribute("state","add");
           
            String parentId = request.getParameter(RollerRequest.PARENTID_KEY);
            parentFolder = bmgr.getFolder(parentId);
           
            BasePageModel pageModel = new BasePageModel(
                "folderForm.add.title", request, response, mapping);
            pageModel.setWebsite(parentFolder.getWebsite());
            request.setAttribute("model", pageModel);
View Full Code Here

        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,
View Full Code Here

    public static WebsiteData getWebsite(HttpServletRequest request) throws RollerException {
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        WebsiteData website = rreq.getWebsite();
        String folderid = request.getParameter(RollerRequest.FOLDERID_KEY);
        if (website == null && folderid != null) {
            BookmarkManager bm = RollerFactory.getRoller().getBookmarkManager();
            FolderData folder = bm.getFolder(folderid);    
            website = folder.getWebsite();
        }          
        if (website != null) {
            request.getSession().setAttribute(HANDLE, website.getHandle());
        }
View Full Code Here

        BookmarksPageModel pageModel = new BookmarksPageModel(
            request, response, mapping, (BookmarksForm)actionForm);
        WebsiteData website = pageModel.getFolder().getWebsite();
        if (RollerSession.getRollerSession(request).isUserAuthorizedToAuthor(website))
        {
            BookmarkManager bmgr = roller.getBookmarkManager();
            BookmarksForm form = (BookmarksForm)actionForm;

            mLogger.debug("Deleting folders and bookmarks.");

            String folders[] = form.getSelectedFolders();
            if (null != folders)
            {
                for (int i = 0; i < folders.length; i++)
                {
                    FolderData fd = bmgr.getFolder(folders[i]);
                    bmgr.removeFolder(fd); // removes child folders and bookmarks too
                }
            }
           
            BookmarkData bookmark = null;
            String bookmarks[] = form.getSelectedBookmarks();
            if (null != bookmarks)
            {
                for (int j = 0; j < bookmarks.length; j++)
                {
                    bookmark = bmgr.getBookmark(bookmarks[j]);
                    bmgr.removeBookmark(bookmark);
                }
            }
            RollerFactory.getRoller().flush();
               
            CacheManager.invalidate(website);
View Full Code Here

TOP

Related Classes of org.apache.roller.model.BookmarkManager

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.