You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2011/06/27 11:29:21 UTC
svn commit: r1140073 - in /incubator/stanbol/trunk:
enhancer/engines/opencalais/
enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/
enhancer/engines/opencalais/src/main/resources/OSGI-INF/
enhancer/engines/op...
Author: rwesten
Date: Mon Jun 27 09:29:21 2011
New Revision: 1140073
URL: http://svn.apache.org/viewvc?rev=1140073&view=rev
Log:
STANBOL-240: adds the changes as requested by this issue
Added:
incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/resources/OSGI-INF/
incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/resources/OSGI-INF/metatype/
incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/resources/OSGI-INF/metatype/metatype.properties (with props)
Modified:
incubator/stanbol/trunk/enhancer/engines/opencalais/pom.xml
incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/OpenCalaisEngine.java
incubator/stanbol/trunk/enhancer/engines/opencalais/src/test/java/org/apache/stanbol/enhancer/engines/opencalais/impl/TestOpenCalaisEngine.java
incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/EnhancerTestBase.java
Modified: incubator/stanbol/trunk/enhancer/engines/opencalais/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/opencalais/pom.xml?rev=1140073&r1=1140072&r2=1140073&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/opencalais/pom.xml (original)
+++ incubator/stanbol/trunk/enhancer/engines/opencalais/pom.xml Mon Jun 27 09:29:21 2011
@@ -90,6 +90,11 @@
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.enhancer.servicesapi</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.stanboltools.offline</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.felix</groupId>
Modified: incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/OpenCalaisEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/OpenCalaisEngine.java?rev=1140073&r1=1140072&r2=1140073&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/OpenCalaisEngine.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/OpenCalaisEngine.java Mon Jun 27 09:29:21 2011
@@ -71,6 +71,7 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.commons.stanboltools.offline.OnlineMode;
import org.apache.stanbol.enhancer.servicesapi.ContentItem;
import org.apache.stanbol.enhancer.servicesapi.EngineException;
import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
@@ -78,6 +79,7 @@ import org.apache.stanbol.enhancer.servi
import org.apache.stanbol.enhancer.servicesapi.ServiceProperties;
import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -148,6 +150,12 @@ public class OpenCalaisEngine implements
@Reference
TcManager tcManager;
+ /**
+ * Only activate this engine in online mode
+ */
+ @SuppressWarnings("unused")
+ @Reference
+ private OnlineMode onlineMode;
BundleContext bundleContext;
@@ -165,7 +173,13 @@ public class OpenCalaisEngine implements
return licenseKey;
}
- public void setLicenseKey(String licenseKey) {
+ public void setLicenseKey(String licenseKey) throws ConfigurationException {
+ if(licenseKey == null || licenseKey.isEmpty()){
+ throw new ConfigurationException(LICENSE_KEY, String.format(
+ "%s : please configure a OpenCalais License key to use this engine (e.g. by" +
+ "using the 'Configuration' tab of the Apache Felix Web Console).",
+ getClass().getSimpleName()));
+ }
this.licenseKey = licenseKey;
}
@@ -173,7 +187,13 @@ public class OpenCalaisEngine implements
return calaisUrl;
}
- public void setCalaisUrl(String calaisUrl) {
+ public void setCalaisUrl(String calaisUrl) throws ConfigurationException {
+ if(calaisUrl == null || calaisUrl.isEmpty()){
+ throw new ConfigurationException(CALAIS_URL_KEY, String.format(
+ "%s : please configure the URL of the OpenCalais Webservice (e.g. by" +
+ "using the 'Configuration' tab of the Apache Felix Web Console).",
+ getClass().getSimpleName()));
+ }
this.calaisUrl = calaisUrl;
}
@@ -221,11 +241,12 @@ public class OpenCalaisEngine implements
}
public int canEnhance(ContentItem ci) throws EngineException {
- if (getLicenseKey() == null || getLicenseKey().trim().length() == 0) {
- //do nothing if no license key is defined
- log.warn("No license key defined. The engine will not work!");
- return CANNOT_ENHANCE;
- }
+ //Engine will no longer activate if no license key is set
+// if (getLicenseKey() == null || getLicenseKey().trim().length() == 0) {
+// //do nothing if no license key is defined
+// log.warn("No license key defined. The engine will not work!");
+// return CANNOT_ENHANCE;
+// }
UriRef subj = new UriRef(ci.getId());
String mimeType = ci.getMimeType().split(";", 2)[0];
if (SUPPORTED_MIMETYPES.contains(mimeType.toLowerCase())) {
@@ -594,7 +615,7 @@ public class OpenCalaisEngine implements
*
* @param ce the {@link ComponentContext}
*/
- protected void activate(@SuppressWarnings("unused") ComponentContext ce) {
+ protected void activate(ComponentContext ce) throws ConfigurationException {
if (ce != null) {
this.bundleContext = ce.getBundleContext();
//TODO initialize Extractor
Added: incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1140073&view=auto
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/resources/OSGI-INF/metatype/metatype.properties (added)
+++ incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/resources/OSGI-INF/metatype/metatype.properties Mon Jun 27 09:29:21 2011
@@ -0,0 +1,18 @@
+#===============================================================================
+#Properties and Options used to configure OpenCalaisEnhancementEngine
+#===============================================================================
+
+org.apache.stanbol.enhancer.engines.opencalais.impl.OpenCalaisEngine.name=Stanbol Enhancement Engine for OpenCalais
+org.apache.stanbol.enhancer.engines.opencalais.impl.OpenCalaisEngine.description=An Enhancement Engine that sends ContentItems to OpenCalais and converts the results to the Stanbol Enhancement Structure
+
+org.apache.stanbol.enhancer.engines.opencalais.license.name=License Key
+org.apache.stanbol.enhancer.engines.opencalais.license.description=The key needed to access the OpenCalais Webservices
+
+org.apache.stanbol.enhancer.engines.opencalais.url.name=Service URL
+org.apache.stanbol.enhancer.engines.opencalais.url.description=The URL of the OpenCalais Webservice
+
+org.apache.stanbol.enhancer.engines.opencalais.typeMap.name=Type Map
+#org.apache.stanbol.enhancer.engines.opencalais.typeMap.description=
+
+org.apache.stanbol.enhancer.engines.opencalais.NERonly.name=NER only Mode
+org.apache.stanbol.enhancer.engines.opencalais.NERonly.description=Allows to run this engine in an mode that only uses performs Named Entity Recognition
Propchange: incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/resources/OSGI-INF/metatype/metatype.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/stanbol/trunk/enhancer/engines/opencalais/src/test/java/org/apache/stanbol/enhancer/engines/opencalais/impl/TestOpenCalaisEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/opencalais/src/test/java/org/apache/stanbol/enhancer/engines/opencalais/impl/TestOpenCalaisEngine.java?rev=1140073&r1=1140072&r2=1140073&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/opencalais/src/test/java/org/apache/stanbol/enhancer/engines/opencalais/impl/TestOpenCalaisEngine.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/opencalais/src/test/java/org/apache/stanbol/enhancer/engines/opencalais/impl/TestOpenCalaisEngine.java Mon Jun 27 09:29:21 2011
@@ -35,6 +35,7 @@ import org.junit.Assert;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.osgi.service.cm.ConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,7 +58,7 @@ public class TestOpenCalaisEngine {
private static String TEST_TEXT = "Israeli PM Netanyahu pulls out of US nuclear summit\nIsraeli PM Benjamin Netanyahu has cancelled a visit to the US where he was to attend a summit on nuclear security, Israeli officials say. Mr Netanyahu made the decision after learning that Egypt and Turkey intended to raise the issue of Israel's presumed nuclear arsenal, the officials said. Mr Obama is due to host dozens of world leaders at the two-day conference, which begins in Washington on Monday. Israel has never confirmed or denied that it possesses atomic weapons. Israel's Intelligence and Atomic Energy Minister Dan Meridor will take Netanyahu's place in the nuclear summit, Israeli radio said. More than 40 countries are expected at the meeting, which will focus on preventing the spread of nuclear weapons to militant groups.";
@BeforeClass
- public static void oneTimeSetup() {
+ public static void oneTimeSetup() throws ConfigurationException {
calaisExtractor = new OpenCalaisEngine();
calaisExtractor.setCalaisTypeMap(new HashMap<UriRef,UriRef>());
calaisExtractor.tcManager = TcManager.getInstance();
Modified: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/EnhancerTestBase.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/EnhancerTestBase.java?rev=1140073&r1=1140072&r2=1140073&view=diff
==============================================================================
--- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/EnhancerTestBase.java (original)
+++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/EnhancerTestBase.java Mon Jun 27 09:29:21 2011
@@ -71,7 +71,7 @@ public class EnhancerTestBase extends St
"org.apache.stanbol.*MetaxaEngine",
"org.apache.stanbol.*LangIdEnhancementEngine",
"org.apache.stanbol.*NamedEntityExtractionEnhancementEngine",
- "org.apache.stanbol.*OpenCalaisEngine",
+ //"org.apache.stanbol.*OpenCalaisEngine", not available in offline mode
"org.apache.stanbol.*EntityMentionEnhancementEngine",
"org.apache.stanbol.*CachingDereferencerEngine"
//removed because not available in offline mode