Package org.apache.roller.business

Examples of org.apache.roller.business.BookmarkManager


     *
     * @param subfolders
     */
    public List retrieveBookmarks(boolean subfolders) throws RollerException
    {
        BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();
        return bmgr.getBookmarks(this, subfolders);
    }
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"))
        {
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(RequestConstants.FOLDER_ID));
            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(RequestConstants.PARENT_ID);
            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

        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

        if (RollerSession.getRollerSession(request).isUserAuthorizedToAuthor(website))
        {
            try
            {
                BookmarkManager bmgr = roller.getBookmarkManager();
                BookmarksForm form = (BookmarksForm)actionForm;
   
                mLogger.debug("Moving folders and bookmarks to folder, id="
                    + form.getMoveToFolderId());
   
                // Move subfolders to new folder.
                String folders[] = form.getSelectedFolders();
                FolderData parent = bmgr.getFolder(form.getMoveToFolderId());
                if (null != folders)
                {
                    for (int i = 0; i < folders.length; i++)
                    {
                        FolderData fd = bmgr.getFolder(folders[i]);
   
                        // Don't move folder into itself.
                        if (    !fd.getId().equals(parent.getId())
                             && !parent.descendentOf(fd))
                        {
                            fd.setParent(parent);
                            bmgr.saveFolder(fd);
                        }
                        else
                        {
                            messages.add(null, new ActionMessage(
                                "bookmarksForm.warn.notMoving",fd.getName()));
                        }
                    }
                }
   
                // Move bookmarks.
                String bookmarks[] = form.getSelectedBookmarks();
                if (null != bookmarks)
                {
                    for (int j = 0; j < bookmarks.length; j++)
                    {
                        // maybe we should be using folder.addBookmark()?
                        BookmarkData bd = bmgr.getBookmark(bookmarks[j]);
                        bd.setFolder(parent);
                        bmgr.saveBookmark(bd);
                    }
                }
                RollerFactory.getRoller().flush();

                CacheManager.invalidate(website);
View Full Code Here

        {
            super("",  request, response, mapping);
           
            RollerRequest rreq = RollerRequest.getRollerRequest(request);
            RollerSession rollerSession = RollerSession.getRollerSession(request);
            BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();

            allFolders = new TreeSet(new FolderPathComparator());

            // Find folderid wherever it may be
            String folderId = (String)
                request.getAttribute(RequestConstants.FOLDER_ID);
            if (null == folderId)
            {
                folderId = request.getParameter(RequestConstants.FOLDER_ID);
            }
            if (null == folderId)
            {
                folderId = form.getFolderId();
            }

            if (null == folderId || folderId.equals("null"))
            {
                website = rreq.getWebsite();
                folder = bmgr.getRootFolder(website);
                folderId = folder.getId();
            }
            else
            {
                folder = bmgr.getFolder(folderId);
                website = folder.getWebsite();
            }
            form.setFolderId(folder.getId());

            if (null != folder.getParent())
            {
                folderPath = new LinkedList();
                folderPath.add(0, folder);
                FolderData parent = folder.getParent();
                while (parent != null)
                {
                    folderPath.add(0, parent);
                    parent = parent.getParent();
                }
                request.setAttribute(
                    RequestConstants.PARENT_ID, folder.getParent().getId());
            }

            // Build list of all folders, except for current one, sorted by path.
            Iterator iter = bmgr.getAllFolders(website).iterator();
            while (iter.hasNext())
            {
                FolderData fd = (FolderData) iter.next();
                if (!fd.getId().equals(folderId))
                {
View Full Code Here

     */
    public FolderData getBookmarkFolder(String folderName) {
        FolderData ret = null;
        try {
            Roller roller = RollerFactory.getRoller();
            BookmarkManager bmgr = roller.getBookmarkManager();
            if (folderName == null || folderName.equals("nil") || folderName.trim().equals("/")) {
                return bmgr.getRootFolder(this);
            } else {
                return bmgr.getFolder(this, folderName);
            }
        } catch (RollerException re) {
            log.error("ERROR: fetching folder for weblog", re);
        }
        return ret;
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(RequestConstants.FOLDER_ID);
        if (website == null && folderid != null) {
            BookmarkManager bm = RollerFactory.getRoller().getBookmarkManager();
            FolderData folder = bm.getFolder(folderid);    
            website = folder.getWebsite();
        }          
        if (website != null) {
            request.getSession().setAttribute(RequestConstants.WEBLOG_SESSION_STASH, website.getHandle());
        }
View Full Code Here

TOP

Related Classes of org.apache.roller.business.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.