diff --git a/DOTSFeedMonster/_builds/org.openntf.news.monster_0.0.1.201212091335.jar b/DOTSFeedMonster/_builds/org.openntf.news.monster_0.0.1.201212091335.jar new file mode 100644 index 0000000..70110de Binary files /dev/null and b/DOTSFeedMonster/_builds/org.openntf.news.monster_0.0.1.201212091335.jar differ diff --git a/DOTSFeedMonster/org.openntf.news.monster/.classpath b/DOTSFeedMonster/org.openntf.news.monster/.classpath new file mode 100644 index 0000000..f9d1fb6 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/DOTSFeedMonster/org.openntf.news.monster/.project b/DOTSFeedMonster/org.openntf.news.monster/.project new file mode 100644 index 0000000..8072568 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/.project @@ -0,0 +1,28 @@ + + + org.openntf.news.monster + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/DOTSFeedMonster/org.openntf.news.monster/.settings/org.eclipse.jdt.core.prefs b/DOTSFeedMonster/org.openntf.news.monster/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f9f1d24 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Sun Dec 09 11:05:27 VET 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/DOTSFeedMonster/org.openntf.news.monster/.settings/org.eclipse.pde.core.prefs b/DOTSFeedMonster/org.openntf.news.monster/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000..a8b7608 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +#Mon Feb 08 11:29:33 EST 2010 +eclipse.preferences.version=1 +pluginProject.extensions=true +resolve.requirebundle=false diff --git a/DOTSFeedMonster/org.openntf.news.monster/META-INF/MANIFEST.MF b/DOTSFeedMonster/org.openntf.news.monster/META-INF/MANIFEST.MF new file mode 100644 index 0000000..c8ccbed --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.openntf.news.monster;singleton:=true +Bundle-Version: 0.0.1.qualifier +Bundle-Activator: org.openntf.news.dots.activator.Activator +Bundle-Vendor: OpenNTF +Bundle-RequiredExecutionEnvironment: JavaSE-1.6, + J2SE-1.5 +Bundle-ActivationPolicy: lazy +Require-Bundle: com.ibm.dots +Bundle-ClassPath: lib/rome-1.0.jar, + ., + lib/jdom.jar, + lib/commons-logging-api-1.1.1.jar, + lib/jericho-html-3.1.jar + diff --git a/DOTSFeedMonster/org.openntf.news.monster/build.properties b/DOTSFeedMonster/org.openntf.news.monster/build.properties new file mode 100644 index 0000000..f9de2f9 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/build.properties @@ -0,0 +1,26 @@ +# *********************************************************************** +# © Copyright IBM Corp. 2009,2010 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# ************************************************************************* + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + lib/rome-1.0.jar,\ + lib/jdom.jar,\ + lib/jericho-html-3.1.jar,\ + lib/commons-logging-api-1.1.1.jar +jre.compilation.profile = J2SE-1.5 diff --git a/DOTSFeedMonster/org.openntf.news.monster/lib/commons-logging-api-1.1.1.jar b/DOTSFeedMonster/org.openntf.news.monster/lib/commons-logging-api-1.1.1.jar new file mode 100644 index 0000000..bd45116 Binary files /dev/null and b/DOTSFeedMonster/org.openntf.news.monster/lib/commons-logging-api-1.1.1.jar differ diff --git a/DOTSFeedMonster/org.openntf.news.monster/lib/jdom.jar b/DOTSFeedMonster/org.openntf.news.monster/lib/jdom.jar new file mode 100644 index 0000000..65a1b3f Binary files /dev/null and b/DOTSFeedMonster/org.openntf.news.monster/lib/jdom.jar differ diff --git a/DOTSFeedMonster/org.openntf.news.monster/lib/jericho-html-3.1.jar b/DOTSFeedMonster/org.openntf.news.monster/lib/jericho-html-3.1.jar new file mode 100644 index 0000000..97c06ee Binary files /dev/null and b/DOTSFeedMonster/org.openntf.news.monster/lib/jericho-html-3.1.jar differ diff --git a/DOTSFeedMonster/org.openntf.news.monster/lib/rome-1.0.jar b/DOTSFeedMonster/org.openntf.news.monster/lib/rome-1.0.jar new file mode 100644 index 0000000..7138baa Binary files /dev/null and b/DOTSFeedMonster/org.openntf.news.monster/lib/rome-1.0.jar differ diff --git a/DOTSFeedMonster/org.openntf.news.monster/plugin.xml b/DOTSFeedMonster/org.openntf.news.monster/plugin.xml new file mode 100644 index 0000000..0c0e3d7 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/plugin.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/Story.java b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/Story.java new file mode 100644 index 0000000..f392166 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/Story.java @@ -0,0 +1,171 @@ +package org.openntf.news; + +import java.io.IOException; +import java.text.DateFormat; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; +import java.util.TimeZone; + +import lotus.domino.Database; +import lotus.domino.Document; +import lotus.domino.NotesException; +import lotus.domino.Session; + +import org.openntf.news.shared.Constants; +import org.openntf.news.shared.StoryReaderException; +import org.openntf.news.shared.Utilities; + +// Story element for news items +public class Story { + + //From Entry + private String id; + private String link; + private Calendar date; + private String title; + private String abstractContent; + private String fullContent; + + //Set on Save + private Calendar creationDate; + + private HashMap additionalFields; + private boolean redirectEnabled=false; + + public Story() { + additionalFields=new HashMap(); + + // setting all things GMT to prevent time zone inconsistencies... + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + } + + public void addField(String name, Object value) { + additionalFields.put(name, value); + } + + public Object getField(String name) { + return additionalFields.get(name); + } + + public void addFields(Map values) { + additionalFields.putAll(values); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLink() { + return link; + } + + + public void setLink(String link) { + this.link = link; + } + + + public Calendar getDate() { + return date; + } + + public void setDate(Calendar date) { + this.date = date; + } + + + public String getTitle() { + return title; + } + + + public void setTitle(String title) { + this.title = title; + } + + + public String getAbstractContent() { + return abstractContent; + } + + public void setAbstractContent(String abstractContent) { + this.abstractContent = abstractContent; + } + + public String getFullContent() { + return fullContent; + } + + public void setFullContent(String fullContent) { + this.fullContent = fullContent; + } + + public Calendar getCreationDate() { + return creationDate; + } + + public void setCreationDate(Calendar creationDate) { + this.creationDate = creationDate; + } + + public String toString() { + DateFormat sdf = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); + return getTitle() + " (" + getLink() + " - " + sdf.format(getDate().getTime()) + ")"; + } + + public boolean saveToDatabase(Database db) throws StoryReaderException { + try { + setCreationDate(Calendar.getInstance()); + + Session session=db.getParent(); + + Document storyDoc = db.createDocument(); + storyDoc.replaceItemValue("Form", "News"); + storyDoc.replaceItemValue("NID", Utilities.generateUniqueId()); + + if(isRedirectEnabled()) { + try { + setLink(Utilities.followRedirect(getLink())); + } catch (IOException e) { + throw new StoryReaderException(Constants.EXCEPTION_COMM_ERROR + ": "+getLink()); + } + } + + storyDoc.replaceItemValue("NLink", getLink()); + + storyDoc.replaceItemValue("NCreationDate", session.createDateTime(getCreationDate())); + storyDoc.replaceItemValue("NPublicationDate", session.createDateTime(getDate())); + storyDoc.replaceItemValue("NTitle", getTitle()); + storyDoc.replaceItemValue("NAbstract", getAbstractContent()); + storyDoc.replaceItemValue("NContent", getFullContent()); + + for (Map.Entry entry : additionalFields.entrySet()) { + storyDoc.replaceItemValue(entry.getKey(), entry.getValue()); + } + + storyDoc.save(); + storyDoc.recycle(); + + + return true; + } catch (NotesException e) { + throw new StoryReaderException(Constants.EXCEPTION_SAVE_STORY + ": "+ e.getMessage()); + } + + } + + public boolean isRedirectEnabled() { + return redirectEnabled; + } + + public void setRedirectEnabled(boolean redirectEnabled) { + this.redirectEnabled = redirectEnabled; + } + + +} diff --git a/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/dots/activator/Activator.java b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/dots/activator/Activator.java new file mode 100644 index 0000000..6f62f7b --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/dots/activator/Activator.java @@ -0,0 +1,38 @@ +/* + * © Copyright IBM Corp. 2009,2010 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package org.openntf.news.dots.activator; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + } + +} diff --git a/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/DOTSFeedMonster.java b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/DOTSFeedMonster.java new file mode 100644 index 0000000..665a611 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/DOTSFeedMonster.java @@ -0,0 +1,64 @@ +package org.openntf.news.monster; + +import lotus.domino.Database; +import lotus.domino.NotesException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.openntf.news.shared.Constants; +import org.openntf.news.shared.MonsterException; +import org.openntf.news.shared.Utilities; + +import com.ibm.dots.task.AbstractServerTask; +import com.ibm.dots.task.RunWhen; + + +public class DOTSFeedMonster extends AbstractServerTask { + + Database db; + + public DOTSFeedMonster() { + } + + /* (non-Javadoc) + * @see com.ibm.dots.task.IServerTaskRunnable#dispose() + */ + public void dispose() throws NotesException { + if(db!=null) db.recycle(); + } + + /* (non-Javadoc) + * This is version 1 + */ + public void run(RunWhen runWhen, String[] args, IProgressMonitor monitor) throws NotesException { + + monitor.beginTask(Constants.APPLICATION_NAME + ": " + Constants.TASK_ID, 0 ); + logMessage(Constants.APPLICATION_NAME + ": " + Constants.TASK_ID + " started"); + if(Constants.memory_dump) logMessage("Launching: " + Utilities.getMemoryStatus()); + + String dbname=getSession().getEnvironmentString("Monster_TargetDB", true); + + if(null == dbname || dbname.equals("")) { + dbname=Constants.DATABASE_PATH_AND_NAME; + } + + logMessage(Constants.APPLICATION_NAME + ": Using database '" + dbname + "'"); + + db = getSession().getDatabase("", dbname ); + + try { + if(!db.isOpen()) { + throw new MonsterException(Constants.EXCEPTION_NEWSDB_ERROR + ": "+dbname); + } + + new FeedMonster(db).ReadFeeds(); + } catch(MonsterException e) { + if(Constants.debug) e.printStackTrace(); + logMessage(e.getMessage()); + } + + logMessage(Constants.APPLICATION_NAME + ": " + Constants.TASK_ID + " finished"); + if(Constants.memory_dump) logMessage("Run Success: " + Utilities.getMemoryStatus()); + monitor.worked( 1 ); + + } +} diff --git a/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/FeedMonster.java b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/FeedMonster.java new file mode 100644 index 0000000..11d2fcc --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/FeedMonster.java @@ -0,0 +1,149 @@ +package org.openntf.news.monster; + +import java.util.Calendar; +import java.util.Date; + +import lotus.domino.Database; +import lotus.domino.DateTime; +import lotus.domino.Document; +import lotus.domino.NotesException; +import lotus.domino.Session; +import lotus.domino.View; +import lotus.domino.ViewEntry; +import lotus.domino.ViewNavigator; +import lotus.domino.Item; + +import org.openntf.news.Story; +import org.openntf.news.shared.Constants; +import org.openntf.news.shared.MonsterException; +import org.openntf.news.shared.StoryReaderException; + +public final class FeedMonster { + + private Session session; + private Database newsDB; + private View viewCheck; + private View viewBlogsAll; + private ViewNavigator viewNavigator; + private DateTime now; + + public FeedMonster(Database _newsDB) throws NotesException { + newsDB = _newsDB; + } + + public final void ReadFeeds() throws MonsterException, NotesException { + + try { + try { + if (!newsDB.isOpen()) { + newsDB.open(); + } + session=newsDB.getParent(); + } catch(NotesException e) { + if(Constants.debug) e.printStackTrace(); + throw new MonsterException(Constants.EXCEPTION_NEWSDB_ERROR + ": "+ e.getMessage()); + } + now=session.createDateTime(Calendar.getInstance()); + + viewCheck = newsDB.getView(Constants.VIEW_NEWS_CHECK); + viewBlogsAll = newsDB.getView(Constants.VIEW_BLOGS_ALL); + viewNavigator = viewBlogsAll.createViewNav(); + ViewEntry tmpEntry; + ViewEntry entry = viewNavigator.getFirst(); + while (entry != null) { + Date startTime=new Date(); + int storyCount=0; + + Document blogDocument = entry.getDocument(); + String blogId=blogDocument.getItemValueString("BID"); + + try { + blogDocument.replaceItemValue("BLastTry", now); + + DateTime lastStoryDate=null; + + Item lastSuccess=blogDocument.getFirstItem("BLastSuccess"); + + if(null != lastSuccess && lastSuccess.getType()==Item.DATETIMES) { + lastStoryDate=lastSuccess.getDateTimeValue(); + } + + RSSReader rss=new RSSReader(blogDocument.getItemValueString("BFeed")); + + // Setting default values + rss.addStoryField("BID", blogId); //blogId + rss.addStoryField("PID", blogDocument.getItemValueString("PID")); //authorId + rss.addStoryField("NState", "queued"); //State + + if(blogDocument.getItemValueString("BFeedHasRedirection").equals("1")) { + rss.setRedirectEnabled(true); + } + + rss.loadFeed(); + + blogDocument.replaceItemValue("BLastError", ""); + blogDocument.replaceItemValue("BLastErrorMessage", ""); + + for(int i=0; i 0; + storyDate.recycle(); + + if(saveToDB) { + storyCount++; + s.saveToDatabase(newsDB); + } + } + + if(storyCount>0) { + blogDocument.replaceItemValue("BLastSuccess", now); + } + blogDocument.save(); + + } catch (NotesException e) { + if(Constants.debug) e.printStackTrace(); + System.out.println(Constants.EXCEPTION_BLOG_SAVE + " : " + e.getMessage()); + } catch(StoryReaderException sre) { + System.out.println("Error reading RSSEntry: ["+blogDocument.getItemValueString("BID")+"]: "+sre.getMessage()); + try { + blogDocument.replaceItemValue("BLastError", now); + blogDocument.replaceItemValue("BLastErrorMessage", sre.getMessage()); + blogDocument.save(); + } catch (NotesException e) { + if(Constants.debug) e.printStackTrace(); + System.out.println(Constants.EXCEPTION_BLOG_SAVE + " : " + e.getMessage()); + } + } + + tmpEntry = viewNavigator.getNext(); + entry.recycle(); + blogDocument.recycle(); + entry = tmpEntry; + + long duration=((new Date().getTime()) - startTime.getTime())/1000; + System.out.println("Fetched " + String.valueOf(storyCount) + " stories from '" + blogId + "' in " + String.valueOf(duration) + " secs..."); + } + } + catch (Exception e) { + if(Constants.debug) e.printStackTrace(); + throw new MonsterException(Constants.EXCEPTION_NEWSDB_FEEDS + ": "+ e.getMessage()); + } + finally { + if (viewNavigator != null) { + viewNavigator.recycle(); + } + if (viewBlogsAll != null) { + viewBlogsAll.recycle(); + } + if (viewCheck != null) { + viewCheck.recycle(); + } + if(now!=null) { + now.recycle(); + } + } + + } + +} diff --git a/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/RSSReader.java b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/RSSReader.java new file mode 100644 index 0000000..fc5b8d9 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/RSSReader.java @@ -0,0 +1,182 @@ +package org.openntf.news.monster; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import net.htmlparser.jericho.Renderer; +import net.htmlparser.jericho.Source; + +import org.openntf.news.Story; +import org.openntf.news.shared.Constants; +import org.openntf.news.shared.StoryReaderException; + +import com.sun.syndication.feed.synd.SyndContent; +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.io.FeedException; +import com.sun.syndication.io.SyndFeedInput; +import com.sun.syndication.io.XmlReader; + +public class RSSReader { + + private String feedUrl; + + private HashMap storyFields; + + private int size=0; + private boolean loaded=false; + private SyndFeed feed; + private boolean redirectEnabled=false; + + public RSSReader(String _feedUrl) throws StoryReaderException { + + this.feedUrl=_feedUrl; + this.storyFields=new HashMap(); + + // Initialize Jericho +// Config.LoggerProvider=LoggerProvider.DISABLED; + } + + public void addStoryField(String name, Object value) { + storyFields.put(name, value); + } + + public Object getStoryField(String name) { + return storyFields.get(name); + } + + public void addStoryFields(Map values) { + storyFields.putAll(values); + } + + // TODO: should add error trapping if there is no call loadFeed before getting stories. + public void loadFeed() throws StoryReaderException { + try { + URL url = new URL(feedUrl); + + HttpURLConnection httpSource = (HttpURLConnection)url.openConnection(); + SyndFeedInput input = new SyndFeedInput(); + XmlReader reader = new XmlReader(httpSource); + + this.feed = input.build(reader); + this.size = feed.getEntries().size(); + setLoaded(true); + + } catch (MalformedURLException e) { + if(Constants.debug) e.printStackTrace(); + throw new StoryReaderException(Constants.EXCEPTION_INVALID_URL + ": "+ e.getMessage()); + } catch (IOException e) { + if(Constants.debug) e.printStackTrace(); + throw new StoryReaderException(Constants.EXCEPTION_COMM_ERROR + ": "+ e.getMessage()); + } catch (IllegalArgumentException e) { + if(Constants.debug) e.printStackTrace(); + throw new StoryReaderException(Constants.EXCEPTION_FEED_ERROR + ": "+ e.getMessage()); + } catch (FeedException e) { + if(Constants.debug) e.printStackTrace(); + throw new StoryReaderException(Constants.EXCEPTION_FEED_ERROR + ": "+ e.getMessage()); + } + } + + public Story getNthStory(int index) { + + if(! isLoaded()) { + throw new IllegalStateException("RSSReader has not been loaded yet"); + } + + if(index < 0 || index >=size) { + throw new IndexOutOfBoundsException(); + } + + SyndEntry entry=(SyndEntry)feed.getEntries().get(index); + return entryToStory(entry); + + } + + private Story entryToStory(SyndEntry entry) { + Story story=new Story(); + + story.addFields(storyFields); + + story.setLink(entry.getLink()); + story.setRedirectEnabled(isRedirectEnabled()); + + Calendar date = Calendar.getInstance(); + + if (entry.getPublishedDate()!=null) { + date.setTime(entry.getPublishedDate()); + } + else if (entry.getUpdatedDate()!=null) { + date.setTime(entry.getUpdatedDate()); + } + + story.setDate(date); + story.setTitle(entry.getTitle()); + + String content=getFeedContent(entry); + String abstractContent=cleanHTML(content); + + if(abstractContent.length() >= Constants.STORY_ABSTRACT_MAXLENGTH) { + abstractContent = abstractContent.substring(0, Constants.STORY_ABSTRACT_MAXLENGTH - 1) + "[...]"; + } + + story.setAbstractContent(abstractContent); +// story.setFullContent(content); // Currently we won't have full content due to possible legal implications. + + return story; + } + + @SuppressWarnings("unchecked") + private String getFeedContent(SyndEntry entry) { + StringBuffer output = new StringBuffer(); + if(entry.getDescription() == null) { + Iterator contentIterator = entry.getContents().iterator(); + + while (contentIterator.hasNext()) { + SyndContent content = contentIterator.next(); + output.append(content.getValue()); + } + } + else { + SyndContent content = entry.getDescription(); + output.append(content.getValue()); + } + return output.toString(); + } + + private String cleanHTML(String input) { + Renderer renderer=new Source(input).getRenderer(); + + // We don't want it to be wrapped + renderer.setMaxLineLength(Integer.MAX_VALUE); + renderer.setIncludeHyperlinkURLs(false); + + return renderer.toString(); + } + + public int getSize() { + return size; + } + + public boolean isLoaded() { + return loaded; + } + + private void setLoaded(boolean loaded) { + this.loaded = loaded; + } + + private boolean isRedirectEnabled() { + return redirectEnabled; + } + + public void setRedirectEnabled(boolean redirectEnabled) { + this.redirectEnabled = redirectEnabled; + } + +} diff --git a/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/Constants.java b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/Constants.java new file mode 100644 index 0000000..44cb20a --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/Constants.java @@ -0,0 +1,31 @@ +package org.openntf.news.shared; + +public final class Constants { + public static final String DATABASE_PATH_AND_NAME = "openntf/news1.nsf"; + public static final String APPLICATION_NAME = "News"; + public static final String TASK_ID = "org.openntf.news.readFeeds"; + + public static final int STORY_ABSTRACT_MAXLENGTH=400; + + public static final int SO_CLIENT_ID = 636; + public static final String SO_CLIENT_SECRET = "UJJvYYZ)Fdf1o7IMwOLa4Q(("; + public static final String SO_APP_KEY = "WyYv8IMhY28eyZdIDcbZfw(("; + + + public static String EXCEPTION_NO_BLOG_DOCUMENT = "No blog document"; + public static String EXCEPTION_NO_SESSION = "Unable to obtain Notes Session"; + public static String EXCEPTION_BLOG_SAVE = "Blog document cannot be updated"; + public static String EXCEPTION_INVALID_URL = "Invalid URL specified"; + public static String EXCEPTION_INVALID_CONFIG = "Feed document cannot be read"; + public static String EXCEPTION_COMM_ERROR = "Communication Error"; + public static String EXCEPTION_FEED_ERROR = "Feed cannot be read"; + public static String EXCEPTION_SAVE_STORY = "Story cannot be saved"; + public static String EXCEPTION_NEWSDB_ERROR = "News Database cannot be opened"; + public static String EXCEPTION_NEWSDB_FEEDS = "Error in Feeds"; + + public static String VIEW_BLOGS_ALL = "BlogsAll"; + public static String VIEW_NEWS_CHECK = "NewsByIdDate"; + + public static boolean debug=false; + public static boolean memory_dump=true; +} diff --git a/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/MonsterException.java b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/MonsterException.java new file mode 100644 index 0000000..e2f8de5 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/MonsterException.java @@ -0,0 +1,14 @@ +package org.openntf.news.shared; + +public class MonsterException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public MonsterException(String message) { + super(message); + } + +} diff --git a/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/StoryReaderException.java b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/StoryReaderException.java new file mode 100644 index 0000000..c3c4244 --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/StoryReaderException.java @@ -0,0 +1,14 @@ +package org.openntf.news.shared; + +public class StoryReaderException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public StoryReaderException(String message) { + super(message); + } + +} diff --git a/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/Utilities.java b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/Utilities.java new file mode 100644 index 0000000..b8e2f6a --- /dev/null +++ b/DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/shared/Utilities.java @@ -0,0 +1,49 @@ +package org.openntf.news.shared; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.text.NumberFormat; +import java.util.Locale; +import java.util.Random; + +public final class Utilities { + + private static String UNIQUEID_LETTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + private static int UNIQUEID_DEFAULTSIZE = 6; + + public static String generateUniqueId() { + StringBuilder sb = new StringBuilder(UNIQUEID_DEFAULTSIZE); + Random random = new Random(); + for (int i=0; i < UNIQUEID_DEFAULTSIZE; i++) { + sb.append(UNIQUEID_LETTERS.charAt(random.nextInt(UNIQUEID_LETTERS.length()))); + } + return sb.toString().toLowerCase(Locale.US); + } + + public static String followRedirect(String urlString) throws IOException { + URL url=new URL(urlString); + HttpURLConnection conn=(HttpURLConnection) url.openConnection(); + conn.setInstanceFollowRedirects(false); + + if(conn.getResponseCode()==301 && conn.getHeaderField("Location")!=null) { + return conn.getHeaderField("Location"); + } + + return urlString; + } + + public static String getMemoryStatus() { + Runtime rt = Runtime.getRuntime(); + NumberFormat nf = NumberFormat.getInstance(); + nf.setGroupingUsed(true); + nf.setMinimumFractionDigits(0); + long total_mem = rt.totalMemory(); + long free_mem = rt.freeMemory(); + long used_mem = total_mem - free_mem; + return "Amount of used memory/free memory: " + nf.format(used_mem/1000) + "KB / " + nf.format(free_mem/1000)+" KB"; + + + } + +} diff --git a/DOTSFeedMonster/readme.txt b/DOTSFeedMonster/readme.txt new file mode 100644 index 0000000..c3a4089 --- /dev/null +++ b/DOTSFeedMonster/readme.txt @@ -0,0 +1,7 @@ +Collaboration Today DOTS-FeedMonster Project + +DOTS Task for the CollaborationToday project gets configured feed entries into CT database. + +Initial version uses Rome library to read feed entries. Because of OSGi incompatibilities in Rome library, it currently does not support scheduled DOTS operations. So to schedule working, you might use Program configuration in names.nsf. + +To set up the CT database, you might either use Constants.java or notes.ini variable "Monster_TargetDB" which points to the nsf file (relative path to the data folder). \ No newline at end of file diff --git a/disk-collaborationtoday/.settings/org.eclipse.core.resources.prefs b/disk-collaborationtoday/.settings/org.eclipse.core.resources.prefs index 4a24f4d..c05e854 100644 --- a/disk-collaborationtoday/.settings/org.eclipse.core.resources.prefs +++ b/disk-collaborationtoday/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,4 @@ -#Mon Nov 26 07:09:02 EST 2012 +#Wed Dec 19 09:45:05 CET 2012 encoding//Resources/StyleSheets/jquery.Jcrop.css=UTF-8 encoding//Resources/Files/TestWidget.html=UTF-8 encoding//Resources/Files/TestJSONP.html=UTF-8 diff --git a/disk-collaborationtoday/Code/Java/org/openntf/news/http/core/NewsEntriesJson.java b/disk-collaborationtoday/Code/Java/org/openntf/news/http/core/NewsEntriesJson.java index 2495934..2a4b140 100644 --- a/disk-collaborationtoday/Code/Java/org/openntf/news/http/core/NewsEntriesJson.java +++ b/disk-collaborationtoday/Code/Java/org/openntf/news/http/core/NewsEntriesJson.java @@ -30,8 +30,8 @@ public class NewsEntriesJson { public NewsEntriesJson() { } private String _count = DEFAULT_COUNT; - private String _filter = FORMAT_JSONP; - private String _format = FILTER_ALL; + private String _filter = FILTER_ALL; + private String _format = FORMAT_JSONP; public static final String FORMAT_JSON = "json"; public static final String FORMAT_JSONP = "jsonp"; diff --git a/disk-collaborationtoday/CustomControls/leftColumnLineItems.xsp.metadata b/disk-collaborationtoday/CustomControls/leftColumnLineItems.xsp.metadata index 1760993..b3f1c35 100644 --- a/disk-collaborationtoday/CustomControls/leftColumnLineItems.xsp.metadata +++ b/disk-collaborationtoday/CustomControls/leftColumnLineItems.xsp.metadata @@ -1,12 +1,12 @@ - - -20121029T102736,09-04 -20121029T102736,54-04 -20121029T102736,53-04 -20121029T102736,53-04 -20121029T102736,17-04 -CN=Jesse Gallagher/O=MTC -CN=Jesse Gallagher/O=MTC + + +20120824T102840,49+02 +20121219T094502,00+01 +20121219T094501,99+01 +20121219T094502,00+01 +20120914T085927,21+02 +CN=Niklas Heidloff/OU=Germany/O=IBM +CN=Niklas Heidloff/OU=Germany/O=IBM gC~4; leftColumnLineItems.xsp 8.5.3 diff --git a/disk-collaborationtoday/XPages/author.xsp.metadata b/disk-collaborationtoday/XPages/author.xsp.metadata index 5f93804..81622cd 100644 --- a/disk-collaborationtoday/XPages/author.xsp.metadata +++ b/disk-collaborationtoday/XPages/author.xsp.metadata @@ -1,19 +1,19 @@ - - -20121029T102650,93-04 -20121119T124350,61-05 -20121119T124350,59-05 -20121119T124350,59-05 -20121029T102651,03-04 -CN=Jesse Gallagher/O=Frost -CN=Jesse Gallagher/O=Frost + + +20120727T081521,45+02 +20121219T094516,76+01 +20121219T094516,75+01 +20121219T094516,76+01 +20120914T085934,96+02 +CN=Niklas Heidloff/OU=Germany/O=IBM +CN=Niklas Heidloff/OU=Germany/O=IBM gC~4K author.xsp Moderators Only - author.xsp + 8.5.3