Author: suat
Date: Wed Jul 25 10:43:03 2012
New Revision: 1365516
URL: http://svn.apache.org/viewvc?rev=1365516&view=rev
Log:
STANBOL-499, STANBOL-498:
-Used UriRef instead of String for URI when creating a ContentItem in FileStore
-Added check for removing LDPathSemanticIndex from Felix Web Console in
deactivate not to delete resource for the second time
-Improved some tests according latest changes
Modified:
incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/pom.xml
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndex.java
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndexManager.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/test/src/main/java/org/apache/stanbol/contenthub/test/index/ldpath/LDPathSemanticIndexTest.java
Modified:
incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/pom.xml?rev=1365516&r1=1365515&r2=1365516&view=diff
==============================================================================
---
incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/pom.xml
(original)
+++
incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/pom.xml
Wed Jul 25 10:43:03 2012
@@ -34,6 +34,10 @@
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
</plugins>
</build>
Modified:
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndex.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndex.java?rev=1365516&r1=1365515&r2=1365516&view=diff
==============================================================================
---
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndex.java
(original)
+++
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndex.java
Wed Jul 25 10:43:03 2012
@@ -109,8 +109,8 @@ import at.newmedialab.ldpath.model.progr
* <li><b>Solr Server Check Time:</b> Maximum time in seconds to wait for the
availability of the Solr core
* associated with this index</li>
* <li><b>Service Ranking:</b> To be able adjust priorities of {@link
SemanticIndex}es with same name or same
- * {@link EndpointTypeEnum}, this property is used. The higher value of this
property, the higher priority of the
- * {@link SemanticIndex} instance.</li>
+ * {@link EndpointTypeEnum}, this property is used. The higher value of this
property, the higher priority of
+ * the {@link SemanticIndex} instance.</li>
* </ul>
*
* @author suat
@@ -143,9 +143,9 @@ public class LDPathSemanticIndex impleme
@Reference(target = "(org.apache.solr.core.CoreContainer.name=contenthub)")
private ManagedSolrServer managedSolrServer;
- //TODO: this assumes that only a single Store instance is active!
- // Semantic Indexes should be connected to stores based on the
- // name of the Store!
+ // TODO: this assumes that only a single Store instance is active!
+ // Semantic Indexes should be connected to stores based on the
+ // name of the Store!
@Reference
private Store<ContentItem> store;
@@ -303,10 +303,10 @@ public class LDPathSemanticIndex impleme
public String getName() {
return this.name;
}
-
+
@Override
public Class<ContentItem> getIntdexType() {
- return ContentItem.class;
+ return ContentItem.class;
}
@Override
@@ -611,8 +611,10 @@ public class LDPathSemanticIndex impleme
@Override
public Map<String,String> getRESTSearchEndpoints() {
Map<String,String> searchEndpoints = new HashMap<String,String>();
- searchEndpoints.put(EndpointTypeEnum.CONTENTHUB.getUri(),
"contenthub/" + this.name + "/search/featured");
- searchEndpoints.put(EndpointTypeEnum.SOLR.getUri(), "solr/" +
managedSolrServer.getServerName() + "/" + this.name);
+ searchEndpoints.put(EndpointTypeEnum.CONTENTHUB.getUri(),
"contenthub/" + this.name
+ +
"/search/featured");
+ searchEndpoints.put(EndpointTypeEnum.SOLR.getUri(), "solr/" +
managedSolrServer.getServerName() + "/"
+ + this.name);
return searchEndpoints;
}
@@ -765,7 +767,7 @@ public class LDPathSemanticIndex impleme
}
@Deactivate
- protected void deactivate(ComponentContext context) {
+ protected void deactivate(ComponentContext context) throws
IndexManagementException {
// close store check thread and solr core tracker
deactivate = true;
if (pollingThread != null) {
@@ -782,13 +784,16 @@ public class LDPathSemanticIndex impleme
.getService(reference);
Configuration config;
try {
- config = configAdmin.getConfiguration(pid);
+ config = configAdmin.getConfiguration(this.pid);
// if the configuration for the index has been removed, clear all
files for this index
if (config.getProperties() == null) {
logger.info(
"Configuration for the Semantic Index: {} has been
deleted. All resources will be removed.",
this.name);
- managedSolrServer.removeIndex(this.name, true);
+ if (ldpathSemanticIndexManager.isConfigured(pid)) {
+ // this case is a check for the remove operation from the
felix web console
+ ldpathSemanticIndexManager.removeIndex(this.pid);
+ }
} // the index is deactivated. do not nothing.
} catch (IOException e) {
logger.error("Failed to obtain configuration for the Semantic
Index: {}.", this.name, e);
@@ -930,8 +935,7 @@ public class LDPathSemanticIndex impleme
ci = store.get(changedItem);
if (ci != null) {
index(ci);
- logger.info("ContentItem with Uri {} is
indexed to {}",
- changedItem, name);
+ logger.info("ContentItem with Uri {} is
indexed to {}", changedItem, name);
} else {
remove(changedItem);
}
Modified:
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndexManager.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndexManager.java?rev=1365516&r1=1365515&r2=1365516&view=diff
==============================================================================
---
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndexManager.java
(original)
+++
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/index/src/main/java/org/apache/stanbol/contenthub/index/ldpath/LDPathSemanticIndexManager.java
Wed Jul 25 10:43:03 2012
@@ -370,6 +370,7 @@ public class LDPathSemanticIndexManager
String indexMetadataFilePath =
indexMetadataDirectory.getAbsolutePath() + File.separator + pid
+ ".props";
File file = new File(indexMetadataFilePath);
+ logger.info("Index metadata file to be deleted: {}",
file.getAbsolutePath());
if (file.exists()) {
file.delete();
} else {
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=1365516&r1=1365515&r2=1365516&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
Wed Jul 25 10:43:03 2012
@@ -607,7 +607,7 @@ public class FileStore implements Store<
// create content item using the metadata and main blob
ContentItem ci;
try {
- ci = contentItemFactory.createContentItem(id, blobSource,
metadata);
+ ci = contentItemFactory.createContentItem(new UriRef(id),
blobSource, metadata);
} catch (IOException e) {
throw new StoreException("Failed to created the content item", e);
}
Modified:
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/index/ldpath/LDPathSemanticIndexTest.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/index/ldpath/LDPathSemanticIndexTest.java?rev=1365516&r1=1365515&r2=1365516&view=diff
==============================================================================
---
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/index/ldpath/LDPathSemanticIndexTest.java
(original)
+++
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/index/ldpath/LDPathSemanticIndexTest.java
Wed Jul 25 10:43:03 2012
@@ -37,12 +37,14 @@ import org.apache.solr.common.SolrDocume
import org.apache.solr.common.SolrInputDocument;
import org.apache.stanbol.commons.semanticindex.index.IndexException;
import org.apache.stanbol.commons.semanticindex.index.IndexManagementException;
+import org.apache.stanbol.commons.semanticindex.index.IndexState;
import org.apache.stanbol.commons.semanticindex.index.SemanticIndex;
import org.apache.stanbol.commons.semanticindex.index.SemanticIndexManager;
import org.apache.stanbol.commons.semanticindex.store.StoreException;
import org.apache.stanbol.contenthub.index.ldpath.LDPathSemanticIndex;
import org.apache.stanbol.contenthub.index.ldpath.LDPathSemanticIndexManager;
import org.apache.stanbol.contenthub.servicesapi.index.search.SearchException;
+import
org.apache.stanbol.contenthub.servicesapi.index.search.featured.FeaturedSearch;
import org.apache.stanbol.contenthub.servicesapi.index.search.solr.SolrSearch;
import
org.apache.stanbol.contenthub.servicesapi.store.vocabulary.SolrVocabulary.SolrFieldName;
import org.apache.stanbol.enhancer.servicesapi.ContentItem;
@@ -97,18 +99,19 @@ public class LDPathSemanticIndexTest {
if (counter == 0) {
String program = "@prefix dbp-ont :
<http://dbpedia.org/ontology/>; city = dbp-ont:city / rdfs:label :: xsd:string;
country = dbp-ont:country / rdfs:label :: xsd:string; ";
pid = ldPathSemanticIndexManager.createIndex(name,
"test_index_description", program);
- SemanticIndex<ContentItem> tempSemanticIndex =
(SemanticIndex<ContentItem>)semanticIndexManager.getIndex(name);
+ SemanticIndex<ContentItem> tempSemanticIndex =
(SemanticIndex<ContentItem>) semanticIndexManager
+ .getIndex(name);
int timeoutCount = 0;
while (tempSemanticIndex == null) {
if (timeoutCount == 8) break;
Thread.sleep(500);
- tempSemanticIndex =
(SemanticIndex<ContentItem>)semanticIndexManager.getIndex(name);
+ tempSemanticIndex = (SemanticIndex<ContentItem>)
semanticIndexManager.getIndex(name);
timeoutCount++;
}
- assertNotNull("SemanticIndex '"+name+"' not available after
waiting 4sec!",tempSemanticIndex);
- assertTrue("This tests assume that the Semantic Index with the
name '"
- + name +"' is of type
"+LDPathSemanticIndex.class.getSimpleName(),
- tempSemanticIndex instanceof LDPathSemanticIndex);
+ assertNotNull("SemanticIndex '" + name + "' not available after
waiting 4sec!", tempSemanticIndex);
+ assertTrue("This tests assume that the Semantic Index with the
name '" + name + "' is of type "
+ + LDPathSemanticIndex.class.getSimpleName(),
+ tempSemanticIndex instanceof LDPathSemanticIndex);
semanticIndex = (LDPathSemanticIndex) tempSemanticIndex;
solrServer = semanticIndex.getServer();
}
@@ -296,15 +299,26 @@ public class LDPathSemanticIndexTest {
@Test
public void testGetSearchEndPoints() throws ClassNotFoundException {
Map<String,ServiceReference> searchEndpoints =
semanticIndex.getSearchEndPoints();
+ int serviceCount = 0;
for (Entry<String,ServiceReference> entry :
searchEndpoints.entrySet()) {
- Class<?> clazz = Class.forName(entry.getKey());
+ String className = entry.getKey();
ServiceReference serviceReference = entry.getValue();
- Object service =
clazz.cast(bundleContext.getService(serviceReference));
- assertNotNull(String.format(
- "Service cannot be retrieved by given %s Class and its Service
Reference", clazz.getName()),
- service);
+ Object service;
+ if (SolrSearch.class.getName().equals(className)) {
+ service = (SolrSearch)
bundleContext.getService(serviceReference);
+ assertNotNull(String.format(
+ "Service cannot be retrieved by given %s Class and its
Service Reference", className),
+ service);
+ serviceCount++;
+ } else if (FeaturedSearch.class.getName().equals(className)) {
+ service = (FeaturedSearch)
bundleContext.getService(serviceReference);
+ assertNotNull(String.format(
+ "Service cannot be retrieved by given %s Class and its
Service Reference", className),
+ service);
+ serviceCount++;
+ }
}
-
+ assertTrue("One or more expected search service were not available",
serviceCount == 2);
}
@Test
@@ -349,13 +363,16 @@ public class LDPathSemanticIndexTest {
semanticIndex = (LDPathSemanticIndex)
semanticIndexManager.getIndex(name);
timeoutCount = 0;
- while (!semanticIndex.getDescription().equals("reindexing")) {
+ while (semanticIndex == null ||
!semanticIndex.getDescription().equals("reindexing")) {
if (timeoutCount == 8) break;
Thread.sleep(500);
semanticIndex = (LDPathSemanticIndex)
semanticIndexManager.getIndex(name);
timeoutCount++;
}
// index ci to new semantic index
+ while(semanticIndex.getState() != IndexState.ACTIVE) {
+ Thread.sleep(500);
+ }
semanticIndex.index(ci);
Properties indexMetadata =
ldPathSemanticIndexManager.getIndexMetadata(pid);