Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
26 changed files
with
847 additions
and
22 deletions.
There are no files selected for viewing
Binary file added
BIN
+560 KB
DOTSFeedMonster/_builds/org.openntf.news.monster_0.0.1.201212091335.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry exported="true" kind="lib" path="lib/rome-1.0.jar"/> | ||
<classpathentry exported="true" kind="lib" path="lib/jdom.jar"/> | ||
<classpathentry exported="true" kind="lib" path="lib/commons-logging-api-1.1.1.jar"/> | ||
<classpathentry exported="true" kind="lib" path="lib/jericho-html-3.1.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.openntf.news.monster</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
8 changes: 8 additions & 0 deletions
8
DOTSFeedMonster/org.openntf.news.monster/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
4 changes: 4 additions & 0 deletions
4
DOTSFeedMonster/org.openntf.news.monster/.settings/org.eclipse.pde.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#Mon Feb 08 11:29:33 EST 2010 | ||
eclipse.preferences.version=1 | ||
pluginProject.extensions=true | ||
resolve.requirebundle=false |
16 changes: 16 additions & 0 deletions
16
DOTSFeedMonster/org.openntf.news.monster/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Binary file added
BIN
+51.1 KB
DOTSFeedMonster/org.openntf.news.monster/lib/commons-logging-api-1.1.1.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension | ||
point="com.ibm.dots.task"> | ||
<task id="org.openntf.news.readFeeds" | ||
description="" | ||
class="org.openntf.news.monster.DOTSFeedMonster" | ||
runOnStart="false"> | ||
<!--<run every="30" unit="second" />--> | ||
</task> | ||
</extension> | ||
</plugin> |
171 changes: 171 additions & 0 deletions
171
DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/Story.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String,Object> additionalFields; | ||
private boolean redirectEnabled=false; | ||
|
||
public Story() { | ||
additionalFields=new HashMap<String,Object>(); | ||
|
||
// 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<String,Object> 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<String, Object> 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; | ||
} | ||
|
||
|
||
} |
38 changes: 38 additions & 0 deletions
38
DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/dots/activator/Activator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
DOTSFeedMonster/org.openntf.news.monster/src/org/openntf/news/monster/DOTSFeedMonster.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ); | ||
|
||
} | ||
} |
Oops, something went wrong.