Examples of BookmarkData


Examples of org.apache.roller.pojos.BookmarkData

        try {
            // Add to destination folder
            LinkedList deleteList = new LinkedList();
            Iterator srcBookmarks = src.getBookmarks().iterator();
            while (srcBookmarks.hasNext()) {
                BookmarkData bd = (BookmarkData)srcBookmarks.next();
                deleteList.add(bd);
               
                BookmarkData movedBd = new BookmarkData();
                movedBd.setData(bd);
                movedBd.setId(null);
               
                dest.addBookmark(movedBd);
                this.strategy.store(movedBd);
            }
           
            // Remove from source folder
            Iterator deleteIter = deleteList.iterator();
            while (deleteIter.hasNext()) {
                BookmarkData bd = (BookmarkData)deleteIter.next();
                src.removeBookmark(bd);
                // TODO: this won't conflict with the bookmark we store above right?
                this.strategy.remove(bd);
            }
           
View Full Code Here

Examples of org.apache.roller.pojos.BookmarkData

    public void removeFolderContents(FolderData src) throws RollerException {
       
        // just go through the folder and remove each bookmark
        Iterator srcBookmarks = src.getBookmarks().iterator();
        while (srcBookmarks.hasNext()) {
            BookmarkData bd = (BookmarkData)srcBookmarks.next();
            this.strategy.remove(bd);
        }
    }
View Full Code Here

Examples of org.apache.roller.pojos.BookmarkData

                            .createCriteria(BookmarkData.class);
                    bookmarksQuery.add(Expression.eq("folder", assoc
                            .getFolder()));
                    Iterator bookmarkIter = bookmarksQuery.list().iterator();
                    while (bookmarkIter.hasNext()) {
                        BookmarkData entry = (BookmarkData) bookmarkIter.next();
                        bookmarks.add(entry);
                    }
                }
            }
           
            // get bookmarks in folder
            Criteria bookmarksQuery = session
                    .createCriteria(BookmarkData.class);
            bookmarksQuery.add(Expression.eq("folder", folder));
            Iterator bookmarkIter = bookmarksQuery.list().iterator();
            while (bookmarkIter.hasNext()) {
                BookmarkData bookmark = (BookmarkData) bookmarkIter.next();
                bookmarks.add(bookmark);
            }
            return bookmarks;
        } catch (HibernateException e) {
            throw new RollerException(e);
View Full Code Here

Examples of org.apache.roller.pojos.BookmarkData

        if (blogroll != null) {
            String[] splitroll = blogroll.split(",");
            for (int i=0; i<splitroll.length; i++) {
                String[] rollitems = splitroll[i].split("\\|");
                if (rollitems != null && rollitems.length > 1) {
                    BookmarkData b = new BookmarkData(
                            root,                // parent
                            rollitems[0],        // name
                            "",                  // description
                            rollitems[1].trim(), // url
                            null,                // feedurl
View Full Code Here

Examples of org.apache.roller.pojos.BookmarkData

   
    public void testAddBookmarkToFolder() throws Exception {
       
        BookmarkManager bmgr = getRoller().getBookmarkManager();
        FolderData folder = null;
        BookmarkData bookmark1 = null, bookmark2 = null;
       
        FolderData root = bmgr.getRootFolder(testWeblog);
       
        folder = new FolderData();
        folder.setName("TestFolder1");
        folder.setDescription("created by testAddBookmarkToFolder()");
        folder.setWebsite(testWeblog);
        folder.setParent(root);
        bmgr.saveFolder(folder);
       
        // Add bookmark by adding to folder
        bookmark1 = new BookmarkData(
                folder,
                "TestBookmark1",
                "created by testAddBookmarkToFolder()",
                "http://www.example.com",
                "http://www.example.com/rss.xml",
                new Integer(1),
                new Integer(12),
                "test.jpg");
        folder.addBookmark(bookmark1);
       
        // Add another bookmark
        bookmark2 = new BookmarkData(
                folder,
                "TestBookmark2",
                "created by testAddBookmarkToFolder()",
                "http://www.example.com",
                "http://www.example.com/rss.xml",
                new Integer(1),
                new Integer(12),
                "test.jpf");
        folder.addBookmark(bookmark2);
       
        TestUtils.endSession(true);
       
        FolderData testFolder = null;
        BookmarkData bookmarkb = null, bookmarka = null;
       
        // See that two bookmarks were stored
        testFolder = bmgr.getFolder(folder.getId());
        assertEquals(2, testFolder.getBookmarks().size());
        bookmarka = (BookmarkData)testFolder.getBookmarks().iterator().next();
        bookmarkb = (BookmarkData)testFolder.getBookmarks().iterator().next();
        // Remove one bookmark
        testFolder.removeBookmark(bookmarka);
        bmgr.removeBookmark(bookmarka);
        TestUtils.endSession(true);
       
        // Folder should now contain one bookmark
        testFolder = bmgr.getFolder(folder.getId());
        assertEquals(1, testFolder.getBookmarks().size());
        TestUtils.endSession(true);
       
        // Remove folder
        testFolder = bmgr.getFolder(folder.getId());
        bmgr.removeFolder(testFolder);
        TestUtils.endSession(true);
       
        // Folder and one remaining bookmark should be gone
        assertNull( bmgr.getBookmark(bookmarkb.getId()) );
        assertNull( bmgr.getFolder(folder.getId()) );
    }
View Full Code Here

Examples of org.apache.roller.pojos.BookmarkData

        f1.setParent(root);
        f1.setWebsite(testWeblog);
        bmgr.saveFolder(f1);
       
        // create bookmark b1 inside source folder f1
        BookmarkData b1 = new BookmarkData(
                f1, "b1", "testbookmark",
                "http://example.com", "http://example.com/rss",
                new Integer(1), new Integer(1), "image.gif");
        f1.addBookmark(b1);
       
        // create folder f2 inside f1
        FolderData f2 = new FolderData();
        f2.setName("f2");
        f2.setParent(f1);
        f2.setWebsite(testWeblog);
        bmgr.saveFolder(f2);
       
        // create bookmark b2 inside folder f2
        BookmarkData b2 = new BookmarkData(
                f2, "b2", "testbookmark",
                "http://example.com", "http://example.com/rss",
                new Integer(1), new Integer(1), "image.gif");
        f2.addBookmark(b2);
       
        // create folder f3 inside folder f2
        FolderData f3 = new FolderData();
        f3.setName("f3");
        f3.setParent(f2);
        f3.setWebsite(testWeblog);
        bmgr.saveFolder(f3);
       
        // crete bookmark b3 inside folder f3
        BookmarkData b3 = new BookmarkData(
                f3, "b3", "testbookmark",
                "http://example.com", "http://example.com/rss",
                new Integer(1), new Integer(1), "image.gif");
        f3.addBookmark(b3);
       
View Full Code Here

Examples of org.apache.roller.pojos.BookmarkData

   
    private String matchBookmarks(String text, FolderData folder) {
        Iterator bookmarks = folder.getBookmarks().iterator();
        String workingText = text;
        while (bookmarks.hasNext()) {
            BookmarkData bookmark = (BookmarkData)bookmarks.next();
            String bkDescription = bookmark.getDescription();
            if (bkDescription == null) bkDescription = "";
            String bookmarkLink = "<a href=\"" +
                    bookmark.getUrl() + "\" title=\"" +
                    bkDescription + "\">" +
                    bookmark.getName() + "</a>";
            try {
                // Replace all occurrences of bookmark name that don't occur within the bounds of an anchor tag
                // Notes:
                // - use reluctant quantifiers on the tags to avoid gobbling more than desired
                // - use non-capturing groups for boundaries to avoid replacing the boundary as well as the bookmark name.
                // - we depend on the numbering of the specific groups in this expression in the replacement code below.
                // TODO: should escape the bookmark name
                String regEx = "(<a(?:\\s.*?)??/>)|(<a(?:\\s.*?)??>)|(</a(?:\\s.*?)??>)|(?:\\b)(" + bookmark.getName() + ")(?:\\b)";
                Matcher m = Pattern.compile(regEx).matcher(workingText);
                StringBuffer textBuf = new StringBuffer(workingText.length());
                int inLink = 0;
                while (m.find()) {
                    if (m.group(1) != null) {
                        // self-closed anchor tag <a  ... /> -- ignore
                    } else if (m.group(2) != null) {
                        // matched opening anchor tag <a ...>
                        inLink++;
                    } else if (m.group(3) != null) {
                        // closing anchor tag </a>, but ignore nonmatching ones
                        if (inLink > 0) inLink--;
                    } else if (m.group(4) != null) {
                        // matched the bookmark -- replace, but only if not within a link tag.
                        if (inLink == 0) m.appendReplacement(textBuf, bookmarkLink);
                    }
                    // Any remaining case indicates a bug.  One could add an else with assertion here.  Conservatively don't substitute.
                }
                m.appendTail(textBuf);
                workingText = textBuf.toString();
            } catch (PatternSyntaxException e) {
                // Can happen since we don't escape pattern the bookmark name to protect pattern characters.
                mLogger.warn("Failed to substitute for bookmark [" + bookmark.getName() + "] due to regular expression characters.");
            }
        }
        return workingText.toString();
    }
View Full Code Here

Examples of org.apache.roller.pojos.BookmarkData

        // Build map of the user's bookmarks
        userBookmarks = buildBookmarkMap(website);

        // Determine default topic site from bookmark if present
        BookmarkData defaultTopicBookmark = (BookmarkData) userBookmarks.get(defaultTopicBookmarkName);
        if (defaultTopicBookmark != null) defaultTopicSite = defaultTopicBookmark.getUrl();

        // Append / to defaultTopicSite if it doesn't have it
        if (!defaultTopicSite.endsWith("/"))
        {
            defaultTopicSite += "/";
View Full Code Here

Examples of org.apache.roller.pojos.BookmarkData

     * @return String form of the URL from the bookmark by that name from any of the user's folders, or null if not
     *         found.
     */
    protected String getBookmarkSite(String bookmarkName)
    {
        BookmarkData bookmark = (BookmarkData) getUserBookmarks().get(bookmarkName);
        return bookmark == null ? null : bookmark.getUrl();
    }
View Full Code Here

Examples of org.apache.roller.pojos.BookmarkData

            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);
            }
        }
        return bookmarkMap;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.