Package de.anomic.data.BookmarksDB

Examples of de.anomic.data.BookmarksDB.Bookmark


        if(post != null && isAdmin) {
          if (post.containsKey("selectTag") && post.containsKey("addTag")) {
                switchboard.bookmarksDB.addTag(post.get("selectTag"), post.get("addTag"));
                prop.put("result", "1");//success        
          } else if (post.containsKey("urlhash") && post.containsKey("addTag")) {
                final Bookmark bm = switchboard.bookmarksDB.getBookmark(post.get("urlhash"));
            bm.addTag(post.get("addTag"));
                prop.put("result", "1");//success
          }
        }      
        // return rewrite properties
        return prop;
View Full Code Here


    }
   
    // rebuilds the datesDB from the bookmarksDB
    public void init(final Iterator<Bookmark> it) {
        Log.logInfo("BOOKMARKS", "start init dates.db from bookmarks.db...");
        Bookmark bookmark;       
        String date;
        Entry bmDate;
        int count = 0;
        while (it.hasNext()) {
            bookmark = it.next();
            date = String.valueOf(bookmark.getTimeStamp());
            bmDate=getDate(date);
            if (bmDate == null) {
                bmDate = new Entry(date);
            }
            bmDate.add(bookmark.getUrlHash());
            bmDate.setDatesTable();
            count++;
        }
        Log.logInfo("BOOKMARKS", "finished init "+datesTable.size()+" dates using " + count + " bookmarks.");
    }
View Full Code Here

        int importCount = 0;
       
        Map<MultiProtocolURI, Properties> links = new HashMap<MultiProtocolURI, Properties>();
        String title;
        MultiProtocolURI url;
        Bookmark bm;
        final Set<String> tags=ListManager.string2set(tag); //this allow multiple default tags
        try {
            //load the links
            final ContentScraper scraper = new ContentScraper(baseURL);        
            //OutputStream os = new htmlFilterOutputStream(null, scraper, null, false);
            final Writer writer= new TransformerWriter(null,null,scraper, null, false);
            FileUtils.copy(input,writer);
            writer.close();
            links = scraper.getAnchors();          
        } catch (final IOException e) { Log.logWarning("BOOKMARKS", "error during load of links: "+ e.getClass() +" "+ e.getMessage());}
        for (final Entry<MultiProtocolURI, Properties> link: links.entrySet()) {
            url = link.getKey();
            title = link.getValue().getProperty("name", "");
            Log.logInfo("BOOKMARKS", "links.get(url)");
            if ("".equals(title)) {//cannot be displayed
                title = url.toString();
            }
            bm = db.new Bookmark(url.toString());
            bm.setProperty(Bookmark.BOOKMARK_TITLE, title);
            bm.setTags(tags);
            bm.setPublic(importPublic);
            db.saveBookmark(bm);
           
            importCount++;
        }
       
View Full Code Here

            final NamedNodeMap attributes = doc.getAttributes();
            final String url = attributes.getNamedItem("href").getNodeValue();
            if("".equals(url)){
                return 0;
            }
            final Bookmark bm = db.new Bookmark(url);
            String tagsString = "";
            String title = "";
            String description = "";
            String time = "";
            if(attributes.getNamedItem("tag") != null){
                tagsString = attributes.getNamedItem("tag").getNodeValue();
            }
            if(attributes.getNamedItem("description") != null){
                title = attributes.getNamedItem("description").getNodeValue();
            }
            if(attributes.getNamedItem("extended") != null){
                description = attributes.getNamedItem("extended").getNodeValue();
            }
            if(attributes.getNamedItem("time") != null){
                time = attributes.getNamedItem("time").getNodeValue();
            }
            Set<String> tags = new HashSet<String>();
           
            if (title != null) {
                bm.setProperty(Bookmark.BOOKMARK_TITLE, title);
            }
            if (tagsString != null) {
                tags = ListManager.string2set(tagsString.replace(' ', ','));
            }
            bm.setTags(tags, true);
            if(time != null){
               
                Date parsedDate = null;
                try {
                    parsedDate = ISO8601Formatter.FORMATTER.parse(time);
                } catch (final ParseException e) {
                    parsedDate = new Date();
                }              
                bm.setTimeStamp(parsedDate.getTime());
            }
            if(description!=null){
                bm.setProperty(Bookmark.BOOKMARK_DESCRIPTION, description);
            }
            bm.setPublic(importPublic);
            db.saveBookmark(bm);
           
            importCount++;
        }
        final NodeList children=doc.getChildNodes();
View Full Code Here

                    count++;
           }

           count = 0;
           while(count < max_count && it.hasNext()) {
                    final Bookmark bookmark = sb.bookmarksDB.getBookmark(it.next());

                    if (bookmark != null){
                        if (bookmark.getFeed() && isAdmin) {
                            prop.put("display_bookmarks_"+count+"_link", "/FeedReader_p.html?url="+bookmark.getUrl());
                        } else {
                            prop.put("display_bookmarks_"+count+"_link",bookmark.getUrl());
                        }
                        prop.putHTML("display_bookmarks_"+count+"_title", bookmark.getTitle());
                        prop.putHTML("display_bookmarks_"+count+"_description", bookmark.getDescription());
                        prop.put("display_bookmarks_"+count+"_date", ISO8601Formatter.FORMATTER.format(new Date(bookmark.getTimeStamp())));
                        prop.put("display_bookmarks_"+count+"_rfc822date", HeaderFramework.formatRFC1123(new Date(bookmark.getTimeStamp())));
                        prop.put("display_bookmarks_"+count+"_public", (bookmark.getPublic() ? "1" : "0"));

                        //List Tags.
                        final Set<String> tags = bookmark.getTags();
                        int tagCount=0;
                        for (final String tag : tags) {
                            if (tag.length() > 0 && tag.charAt(0) != '/') {
                                prop.putHTML("display_bookmarks_" + count + "_tags_" + tagCount + "_tag", tag);
                                tagCount++;
                            }
                        }
                        prop.put("display_bookmarks_"+count+"_tags", tagCount);
                        prop.put("display_bookmarks_"+count+"_hash", bookmark.getUrlHash());
                        count++;
                    }
           }

           prop.putHTML("display_tag", tagName);
View Full Code Here

            prop.put("display_folderlist_"+count+"_folder", "<li>"+fn.replaceFirst(root+"/*","")+"<ul class=\"folder\">");
            count++;
            final Iterator<String> bit = sb.bookmarksDB.getBookmarksIterator(fn, isAdmin);

            while (bit.hasNext()) {
                final Bookmark bookmark=sb.bookmarksDB.getBookmark(bit.next());
        if(bookmark == null) {
                    break;
                }
                prop.put("display_folderlist_" + count + "_folder", "<li><a href=\"" + bookmark.getUrl() + "\" title=\"" + bookmark.getDescription() + "\">" + bookmark.getTitle() + "</a></li>");
                count++;
            }

            if (it.hasNext()) {
                count = recurseFolders(it, fn, count, true, fn);
View Full Code Here

        if(post != null && isAdmin) {
          if (post.containsKey("selectTag") && post.containsKey("addTag")) {
                switchboard.bookmarksDB.addTag(post.get("selectTag"), post.get("addTag"));
                prop.put("result", "1");//success
          } else if (post.containsKey("urlhash") && post.containsKey("addTag")) {
                final Bookmark bm = switchboard.bookmarksDB.getBookmark(post.get("urlhash"));
            bm.addTag(post.get("addTag"));
                prop.put("result", "1");//success
          }
        }
        // return rewrite properties
        return prop;
View Full Code Here

                    count++;
           }

           count = 0;
           while(count < max_count && it.hasNext()) {
                    final Bookmark bookmark = sb.bookmarksDB.getBookmark(it.next());

                    if (bookmark != null){
                        if (bookmark.getFeed() && isAdmin) {
                            prop.put("display_bookmarks_"+count+"_link", "/FeedReader_p.html?url="+bookmark.getUrl());
                        } else {
                            prop.put("display_bookmarks_"+count+"_link",bookmark.getUrl());
                        }
                        prop.putHTML("display_bookmarks_"+count+"_title", bookmark.getTitle());
                        prop.putHTML("display_bookmarks_"+count+"_description", bookmark.getDescription());
                        prop.put("display_bookmarks_"+count+"_date", ISO8601Formatter.FORMATTER.format(new Date(bookmark.getTimeStamp())));
                        prop.put("display_bookmarks_"+count+"_rfc822date", HeaderFramework.formatRFC1123(new Date(bookmark.getTimeStamp())));
                        prop.put("display_bookmarks_"+count+"_public", (bookmark.getPublic() ? "1" : "0"));

                        //List Tags.
                        final Set<String> tags = bookmark.getTags();
                        int tagCount=0;
                        for (final String tag : tags) {
                            if (tag.length() > 0 && tag.charAt(0) != '/') {
                                prop.putHTML("display_bookmarks_" + count + "_tags_" + tagCount + "_tag", tag);
                                tagCount++;
                            }
                        }
                        prop.put("display_bookmarks_"+count+"_tags", tagCount);
                        prop.put("display_bookmarks_"+count+"_hash", bookmark.getUrlHash());
                        count++;
                    }
           }

           prop.putHTML("display_tag", tagName);
View Full Code Here

            prop.put("display_folderlist_"+count+"_folder", "<li>"+fn.replaceFirst(root+"/*","")+"<ul class=\"folder\">");
            count++;
            final Iterator<String> bit = sb.bookmarksDB.getBookmarksIterator(fn, isAdmin);

            while (bit.hasNext()) {
                final Bookmark bookmark=sb.bookmarksDB.getBookmark(bit.next());
        if(bookmark == null) {
                    break;
                }
                prop.put("display_folderlist_" + count + "_folder", "<li><a href=\"" + bookmark.getUrl() + "\" title=\"" + bookmark.getDescription() + "\">" + bookmark.getTitle() + "</a></li>");
                count++;
            }

            if (it.hasNext()) {
                count = recurseFolders(it, fn, count, true, fn);
View Full Code Here

    }
   
    // rebuilds the datesDB from the bookmarksDB
    public void init(final Iterator<Bookmark> it) {
        Log.logInfo("BOOKMARKS", "start init dates.db from bookmarks.db...");
        Bookmark bookmark;       
        String date;
        Entry bmDate;
        int count = 0;
        while (it.hasNext()) {
            bookmark = it.next();
            date = String.valueOf(bookmark.getTimeStamp());
            bmDate=getDate(date);
            if (bmDate == null) {
                bmDate = new Entry(date);
            }
            bmDate.add(bookmark.getUrlHash());
            bmDate.setDatesTable();
            count++;
        }
        Log.logInfo("BOOKMARKS", "finished init "+datesTable.size()+" dates using " + count + " bookmarks.");
    }
View Full Code Here

TOP

Related Classes of de.anomic.data.BookmarksDB.Bookmark

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.