Author: rwesten
Date: Thu Jul 26 07:17:39 2012
New Revision: 1365898
URL: http://svn.apache.org/viewvc?rev=1365898&view=rev
Log:
STANBOL-498: added getName(), getDescription and getProperties() method to the
IndexingSource interface. Also provided simple implementation for the FileStore.
Added some TODOs and Notes to the FileStore
Modified:
incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/IndexingSource.java
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStoreDBManager.java
Modified:
incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/IndexingSource.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/IndexingSource.java?rev=1365898&r1=1365897&r2=1365898&view=diff
==============================================================================
---
incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/IndexingSource.java
(original)
+++
incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/IndexingSource.java
Thu Jul 26 07:17:39 2012
@@ -1,5 +1,7 @@
package org.apache.stanbol.commons.semanticindex.store;
+import java.util.Map;
+
/**
* Minimal interface required by the Semantic Index as an indexing source.
@@ -9,11 +11,36 @@ package org.apache.stanbol.commons.seman
public interface IndexingSource<Item> {
/**
+ * The property used for {@link #getName()}
+ */
+ String PROPERTY_NAME = "org.apache.stanbol.indexingsource.name";
+ String PROPERTY_DESCRIPTION =
"org.apache.stanbol.indexingsource.description";
+ String PROPERTY_ITEM_TYPE =
"org.apache.stanbol.indexingsource.itemtype";
+ /**
+ * The name of the IndexingSource
+ * @return the name. MUST NOT be <code>null</code> nor empty.
+ */
+ String getName();
+ /**
+ * An optional human readable description that provides some
+ * additional information about this IndexingSource
+ * @return the description
+ */
+ String getDescription();
+
+ /**
* Getter for the type of Items managed by this Store
* @return
*/
Class<Item> getItemType();
+ /**
+ * Read-only map with additional properties about this IndexingSource
+ * @return an read-only map with additional metadata available for
+ * this indexing source.
+ */
+ Map<String, Object> getProperties();
+
/**
* Gets a Item by uri, null if non-existing
* @param uri the uri of the item
Modified:
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java?rev=1365898&r1=1365897&r2=1365898&view=diff
==============================================================================
---
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java
(original)
+++
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java
Thu Jul 26 07:17:39 2012
@@ -29,10 +29,13 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.zip.ZipEntry;
@@ -103,6 +106,17 @@ import org.slf4j.LoggerFactory;
@Service
@Properties(value = {@Property(name = Constants.SERVICE_RANKING, intValue =
100)})
public class FileStore implements Store<ContentItem> {
+ //TODO: IMPORTANT
+ // We need to move the Contenthub related business logic out of this
class!
+ // Otherwise one can not implement/use different store implementations.
+ //
+ // e.g. the #put(..) method MUST NOT enhance the contentItem. It is
only
+ // expected to store the parsed content item (without modifications).
+ // The logic if the Contenthub needs to enhance ContentItems needs to
be
+ // outside of the actual Store implementation
+
+
+
// @Property(name = Constants.SERVICE_RANKING)
// private int ranking;
@@ -174,6 +188,8 @@ public class FileStore implements Store<
@Reference
private EnhancementJobManager jobManager;
+
+ Map<String,Object> storeProperties;
@Activate
protected void activate(ComponentContext componentContext) throws
StoreException {
@@ -183,8 +199,40 @@ public class FileStore implements Store<
if (!storeFolder.exists()) {
storeFolder.mkdirs();
}
+ // init the store properties
+ Map<String,Object> properties = new HashMap<String, Object>();
+ properties.put(PROPERTY_NAME, getName());
+ properties.put(PROPERTY_DESCRIPTION, getDescription());
+ properties.put(PROPERTY_ITEM_TYPE, getItemType());
+ storeProperties = Collections.unmodifiableMap(properties);
}
+ protected void deactivate(ComponentContext context) {
+ storeProperties = null;
+ }
+
+ /*
+ * NOTE: This implementation assume a single FileStore instance.
+ * If this is changed this implementations need to be adapted.
+ */
+ @Override
+ public String getName() {
+ return "contenthubFileStore";
+ }
+
+ /*
+ * NOTE: This implementation assume a single FileStore instance.
+ * If this is changed this implementations need to be adapted.
+ */
+ @Override
+ public String getDescription() {
+ return "File based Store implementation for ContentItems used by the
Stanbol Contenthub";
+ }
+
+ @Override
+ public Map<String, Object> getProperties() {
+ return storeProperties;
+ }
@Override
public Class<ContentItem> getItemType() {
return ContentItem.class;
Modified:
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStoreDBManager.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStoreDBManager.java?rev=1365898&r1=1365897&r2=1365898&view=diff
==============================================================================
---
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStoreDBManager.java
(original)
+++
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStoreDBManager.java
Thu Jul 26 07:17:39 2012
@@ -76,6 +76,8 @@ public class FileStoreDBManager {
@Activate
protected void activate(ComponentContext componentContext) throws
StoreException {
String stanbolHome =
componentContext.getBundleContext().getProperty("sling.home");
+ //TODO: do not use the datafiles folder for storing things.
+ // the contenthub should use its own folder ->
{sling.home}/contenthub/...
DB_URL = "jdbc:derby:" + stanbolHome +
"/datafiles/contenthub/filestore/filestorerevisions;create=true";
log.info("Initializing file store revision database");
Connection con = getConnection();