You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by si...@apache.org on 2012/02/07 14:59:03 UTC
svn commit: r1241468 [1/2] - in /incubator/stanbol/trunk/contenthub:
crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/
crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/
ldpath/src/main/java/org/apache/stanbol/...
Author: sinaci
Date: Tue Feb 7 13:59:01 2012
New Revision: 1241468
URL: http://svn.apache.org/viewvc?rev=1241468&view=rev
Log:
STANBOL-485
* LDPath programs can be submitted and deleted through web user interface.
* Contenthub Store page is now presented according to the selected index name. LDPath programs are indetified through their names and each LDPath program corresponds to a Solr index/core.
* Contenthub Search page is now presented according to the selected index name.
* All RESTful services are re-arranged according to the index name parameter.
* LDProgramManager is renamed to SemanticIndexManager
Added:
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java
- copied, changed from r1239477, incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java
- copied, changed from r1239477, incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java
- copied, changed from r1239477, incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDProgramManagerResource.java
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource/
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource/index.ftl
Removed:
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDProgramManagerResource.java
Modified:
incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java
incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/CNNImporterImpl.java
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java
incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/util/SolrContentItemConverter.java
incubator/stanbol/trunk/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java
incubator/stanbol/trunk/contenthub/store/pom.xml
incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java
incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/manager/SolrCoreManager.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/CNNImporterResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/facetResultMacro.ftl
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/CNNImporterResource/index.ftl
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/result.ftl
incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/StoreResource/index.ftl
Modified: incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java (original)
+++ incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java Tue Feb 7 13:59:01 2012
@@ -20,6 +20,8 @@ package org.apache.stanbol.contenthub.cr
import java.net.URI;
import java.util.Map;
+import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
+
/**
* This is the interface to crawl CNN.
*
@@ -46,4 +48,26 @@ public interface CNNImporter {
*/
Map<URI,String> importCNNNews(String topic, int maxNumber, boolean fullNews);
+ /**
+ *
+ * @param topic
+ * The topic which will be crawled.
+ * @param maxNumber
+ * Max number of news to be retrieved from CNN about the {@link topic}
+ * @param fullNews
+ * If {@code true}, the topic will be crawled in detail to retrieve all information from CNN
+ * about the {@link topic}. If {@code false}, only summary of the news will be crawled and
+ * imported.
+ *
+ * @param indexName
+ * Name of the LDPath program (name of the Solr core/index) to be used while storing this
+ * content item. LDPath programs can be managed through {@link SemanticIndexManagerResource} or
+ * {@link SemanticIndexManager}
+ *
+ * @return A map which includes the URI of the related topic and the news content. If {@link fullNews} is
+ * {@code true}, the news content is the full news; if not, it is the summary of the news.
+ */
+ Map<URI, String> importCNNNews(String topic, int maxNumber,
+ boolean fullNews, String indexName);
+
}
Modified: incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/CNNImporterImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/CNNImporterImpl.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/CNNImporterImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/CNNImporterImpl.java Tue Feb 7 13:59:01 2012
@@ -69,9 +69,14 @@ public class CNNImporterImpl implements
logger.error("Cannot activate CNNImporter. There is no SolrStore to be binded.");
}
}
+
+ @Override
+ public Map<URI,String> importCNNNews(String topic, int maxNumber, boolean fullNews){
+ return importCNNNews(topic, maxNumber, fullNews, null);
+ }
@Override
- public Map<URI,String> importCNNNews(String topic, int maxNumber, boolean fullNews) {
+ public Map<URI,String> importCNNNews(String topic, int maxNumber, boolean fullNews, String indexName) {
List<NewsSummary> summaries = getRelatedNews(topic, maxNumber);
Map<URI,String> newsInfo = new HashMap<URI,String>();
if (fullNews) {
@@ -87,7 +92,7 @@ public class CNNImporterImpl implements
try {
SolrContentItem sci = solrStore.create(summary.getContent().getBytes(), null,
summary.getTitle(), "text/plain", null);
- URI uri = new URI(solrStore.enhanceAndPut(sci));
+ URI uri = new URI(solrStore.enhanceAndPut(sci, indexName));
String title = summary.getTitle();
if (uri != null) {
newsInfo.put(uri, title);
Modified: incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java Tue Feb 7 13:59:01 2012
@@ -111,6 +111,7 @@ public class LDPathUtils {
typeMap.put(NS_XSD + "decimal", "long");
typeMap.put(NS_XSD + "integer", "int");
+ typeMap.put(NS_XSD + "int", "int");
typeMap.put(NS_XSD + "long", "long");
typeMap.put(NS_XSD + "short", "int");
typeMap.put(NS_XSD + "double", "double");
Copied: incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java (from r1239477, incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java?p2=incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java&p1=incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java&r1=1239477&r2=1241468&rev=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/SemanticIndexManagerImpl.java Tue Feb 7 13:59:01 2012
@@ -35,11 +35,11 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.commons.ldpath.clerezza.ClerezzaBackend;
import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
-import org.apache.stanbol.contenthub.ldpath.backend.clerezza.ClerezzaBackend;
import org.apache.stanbol.contenthub.servicesapi.ldpath.LDPathException;
import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgramCollection;
-import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgramManager;
+import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
import org.apache.stanbol.contenthub.store.solr.manager.SolrCoreManager;
import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
@@ -62,9 +62,9 @@ import at.newmedialab.ldpath.exception.L
@Component(immediate = false)
@Service
-public class LDProgramManagerImpl implements LDProgramManager {
+public class SemanticIndexManagerImpl implements SemanticIndexManager {
- private final Logger logger = LoggerFactory.getLogger(LDProgramManagerImpl.class);
+ private final Logger logger = LoggerFactory.getLogger(SemanticIndexManagerImpl.class);
private final static String DEFAULT_ROOT_PATH = "datafiles/contenthub";
private final static String DEFAULT_FOLDER_NAME = "ldpath";
Modified: incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java Tue Feb 7 13:59:01 2012
@@ -155,7 +155,7 @@ public class FeaturedSearchImpl implemen
String ldProgramName) throws SearchException {
List<ResultantDocument> resultantDocuments = new ArrayList<ResultantDocument>();
for (SolrDocument solrDocument : queryResponse.getResults()) {
- resultantDocuments.add(SolrContentItemConverter.solrDocument2solrContentItem(solrDocument));
+ resultantDocuments.add(SolrContentItemConverter.solrDocument2solrContentItem(solrDocument, ldProgramName));
}
Map<String,Map<String,List<RelatedKeyword>>> relatedKeywords = new HashMap<String,Map<String,List<RelatedKeyword>>>();
List<String> queryTerms = tokenizeEntities(queryTerm);
Modified: incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/util/SolrContentItemConverter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/util/SolrContentItemConverter.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/util/SolrContentItemConverter.java (original)
+++ incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/util/SolrContentItemConverter.java Tue Feb 7 13:59:01 2012
@@ -27,16 +27,16 @@ public class SolrContentItemConverter {
* its metadata produced after enhancement process and stored. Its constraints indexed in Solr are also
* ignored as these items are only shown as a list in HTML interface.
*/
- public static ResultantDocument solrDocument2solrContentItem(SolrDocument solrDocument) {
- return solrDocument2solrContentItem(solrDocument, null);
+ public static ResultantDocument solrDocument2solrContentItem(SolrDocument solrDocument, String indexName) {
+ return solrDocument2solrContentItem(solrDocument, null, indexName);
}
- public static ResultantDocument solrDocument2solrContentItem(SolrDocument solrDocument, String baseURI) {
+ public static ResultantDocument solrDocument2solrContentItem(SolrDocument solrDocument, String baseURI, String indexName) {
String id = getStringValueFromSolrField(solrDocument, SolrFieldName.ID.toString());
String mimeType = getStringValueFromSolrField(solrDocument, SolrFieldName.MIMETYPE.toString());
String title = getStringValueFromSolrField(solrDocument, SolrFieldName.TITLE.toString());
long enhancementCount = (Long) solrDocument.getFieldValue(SolrFieldName.ENHANCEMENTCOUNT.toString());
- String dereferencableURI = baseURI != null ? (baseURI + "contenthub/store/content/" + id) : null;
+ String dereferencableURI = baseURI != null ? (baseURI + "contenthub/" + indexName + "/store/content/" + id) : null;
title = (title == null || title.trim().equals("") ? id : title);
ResultantDocumentImpl resultantDocument = new ResultantDocumentImpl(id, dereferencableURI, mimeType,
enhancementCount, title);
Modified: incubator/stanbol/trunk/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java (original)
+++ incubator/stanbol/trunk/contenthub/search/solr/src/main/java/org/apache/stanbol/contenthub/search/solr/util/SolrQueryUtil.java Tue Feb 7 13:59:01 2012
@@ -65,7 +65,12 @@ public class SolrQueryUtil {
for (Entry<String,List<Object>> entry : constraints.entrySet()) {
String fieldName = ClientUtils.escapeQueryChars(entry.getKey());
for (Object value : entry.getValue()) {
- query.addFilterQuery(fieldName + facetDelimiter + quotation + (String) value + quotation);
+ if(SolrVocabulary.isNameRangeField(fieldName)){
+ query.addFilterQuery(fieldName + facetDelimiter + (String) value);
+ } else {
+ query.addFilterQuery(fieldName + facetDelimiter + quotation + (String) value + quotation);
+ }
+
/*query.addFacetQuery(fieldName + facetDelimiter + (SolrVocabulary.isNameRangeField(fieldName) ? (String) value
: ClientUtils.escapeQueryChars(quotation + (String) value
+ quotation)));*/
Copied: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java (from r1239477, incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java?p2=incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java&p1=incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java&r1=1239477&r2=1241468&rev=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java Tue Feb 7 13:59:01 2012
@@ -29,7 +29,7 @@ import org.apache.clerezza.rdf.core.MGra
* @author anil.sinaci
*
*/
-public interface LDProgramManager {
+public interface SemanticIndexManager {
/**
* Saves LDPath program to persistent storage with given name and initializes a new Solr core with the
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java Tue Feb 7 13:59:01 2012
@@ -55,27 +55,27 @@ public interface FeaturedSearch {
/**
* This method returns a {@link SearchResult} as a unified search response. The response contains content
- * items retrieved from the index, which is accessed using the given <code>ldProgramName</code>, of
- * Contenthub for the given <code>queryTerm</code>. This name corresponds to a Solr Core name within
- * Contenthub. It also consists of related keywords that are obtained from the available
- * {@link RelatedKeywordSearch} instances. This method also takes an ontology URI. Using the URI, actual
- * ontology is retrieved and it is used as related keyword source. To obtain related keywords, the given
- * query term is tokenized with {@link #tokenizeEntities(String)}. And then, related keyword searchers are
- * queried for all the query tokens. Furthermore, the {@link SearchResult} includes Solr facets that are
- * obtained for the obtained content items.
+ * items retrieved from the index, which is accessed using the given <code>indexName</code>, of Contenthub
+ * for the given <code>queryTerm</code>. This name corresponds to a Solr Core name within Contenthub. It
+ * also consists of related keywords that are obtained from the available {@link RelatedKeywordSearch}
+ * instances. This method also takes an ontology URI. Using the URI, actual ontology is retrieved and it
+ * is used as related keyword source. To obtain related keywords, the given query term is tokenized with
+ * {@link #tokenizeEntities(String)}. And then, related keyword searchers are queried for all the query
+ * tokens. Furthermore, the {@link SearchResult} includes Solr facets that are obtained for the obtained
+ * content items.
*
* @param queryTerm
* Query term for which the unified response will be obtained
* @param ontologyURI
* URI of an ontology in which related keywords will be searched
- * @param ldProgramName
- * LDPath program name which is used to obtained the corresponding Solr core which will be
- * searched for the given query term
+ * @param indexName
+ * LDPath program name (name of the Solr core/index) which is used to obtained the
+ * corresponding Solr core which will be searched for the given query term
* @return {@link SearchResult} for the given query term. For details of the response see
* {@link SearchResult}.
* @throws SearchException
*/
- SearchResult search(String queryTerm, String ontologyURI, String ldProgramName) throws SearchException;
+ SearchResult search(String queryTerm, String ontologyURI, String indexName) throws SearchException;
/**
* This methods returns a {@link SearchResult} as a unified search response. The response contains content
@@ -96,7 +96,7 @@ public interface FeaturedSearch {
/**
* This methods returns a {@link SearchResult} as a unified search response. The response contains content
- * items retrieved from the index, which is accessed using the given <code>ldProgramName</code>, of
+ * items retrieved from the index, which is accessed using the given <code>indexName</code>, of
* Contenthub for the given <code>queryTerm</code>. This name corresponds to a Solr Core name within
* Contenthub. It also consists of related keywords that are obtained from the available
* {@link RelatedKeywordSearch} instances. This method also takes an ontology URI. Using the URI, actual
@@ -112,7 +112,7 @@ public interface FeaturedSearch {
* and facets for the obtained content items.
* @throws SearchException
*/
- SearchResult search(SolrParams solrQuery, String ontologyURI, String ldProgramName) throws SearchException;
+ SearchResult search(SolrParams solrQuery, String ontologyURI, String indexName) throws SearchException;
/**
* This method obtains the available field names of the default index of Contenthub.
@@ -124,14 +124,14 @@ public interface FeaturedSearch {
/**
* This method obtains the available field names of the index, corresponding to the given
- * <code>ldProgramName</code> of Contenthub. This name corresponds to a Solr Core name within Contenthub.
+ * <code>indexName</code> of Contenthub. This name corresponds to a Solr Core name within Contenthub.
*
- * @param ldProgramName
+ * @param indexName
* Name of the index for which the field names will be obtained.
* @return {@link List} of field names related index
* @throws SearchException
*/
- List<String> getFieldNames(String ldProgramName) throws SearchException;
+ List<String> getFieldNames(String indexName) throws SearchException;
/**
* This method tokenizes the given query term with the help of Stanbol Enhancer. The query term is fed to
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java Tue Feb 7 13:59:01 2012
@@ -18,14 +18,14 @@ package org.apache.stanbol.contenthub.se
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.SolrParams;
-import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgramManager;
+import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
/**
* Apache Solr based search interface of Stanbol Contenthub. It makes use of SolrJ API in the provided
* services such that it is possible to provide queries passed in {@link SolrParams} and response are returned
* in the form of {@link QueryResponse}s. This interface also allows querying different Solr cores which are
- * created based on the LDPath programs submitted through the {@link LDProgramManager}.
+ * created based on the LDPath programs submitted through the {@link SemanticIndexManager}.
*
* @author anil.sinaci
*
@@ -48,12 +48,13 @@ public interface SolrSearch {
*
* @param queryTerm
* Query term to be searched
- * @param ldProgramName
- * LDPath program name to obtain the corresponding Solr core to be searched
+ * @param indexName
+ * LDPath program name (Solr core/index name) to obtain the corresponding Solr core to be
+ * searched
* @return the {@link QueryResponse} as is obtained from Solr.
* @throws SearchException
*/
- QueryResponse search(String queryTerm, String ldProgramName) throws SearchException;
+ QueryResponse search(String queryTerm, String indexName) throws SearchException;
/**
* Executes the given <code>solrQuery</code> on the default Solr core of Contenthub.
@@ -71,11 +72,12 @@ public interface SolrSearch {
*
* @param solrQuery
* {@link SolrParams} to be executed
- * @param ldProgramName
- * LDPath program name to obtain the corresponding Solr core to be searched
+ * @param indexName
+ * LDPath program name (Solr core/index name) to obtain the corresponding Solr core to be
+ * searched
* @return the {@link QueryResponse} as is obtained from Solr.
* @throws SearchException
*/
- QueryResponse search(SolrParams solrQuery, String ldProgramName) throws SearchException;
+ QueryResponse search(SolrParams solrQuery, String indexName) throws SearchException;
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java Tue Feb 7 13:59:01 2012
@@ -70,48 +70,50 @@ public interface SolrStore extends Store
/**
* Sends the {@link SolrContentItem} to the {@link EnhancementJobManager} to enhance the content.
- * Afterwards saves the item in the Solr core corresponding to the given <code>ldProgramName</code>.
+ * Afterwards saves the item in the Solr core corresponding to the given <code>indexName</code>.
*
* @param sci
* The {@link SolrContentItem} to be enhanced and saved
- * @param ldProgramName
- * LDPath program name to obtain the corresponding Solr core to store the content item
+ * @param indexName
+ * LDPath program name (name of the Solr core/index) to obtain the corresponding Solr core to
+ * store the content item
* @return The unique ID of the {@link SolrContentItem}.
* @throws StoreException
*/
- String enhanceAndPut(SolrContentItem sci, String ldProgramName) throws StoreException;
+ String enhanceAndPut(SolrContentItem sci, String indexName) throws StoreException;
/**
* Stores the passed {@link SolrContentItem} in the Solr core corresponding to the specified
- * <code>ldProgramName</code>. If <code>null</code> is passed as the LDPath program name, the default Solr
- * core of Contenthub is used.
+ * <code>indexName</code>. If <code>null</code> is passed as the LDPath program name (index name), the
+ * default Solr core of Contenthub is used.
*
* @param ci
* {@link SolrContentItem} to be stored
- * @param ldProgramName
- * LDPath program name to obtain the corresponding Solr core to store the content item
+ * @param indexName
+ * LDPath program name (name of the Solr core/index) to obtain the corresponding Solr core to
+ * store the content item
* @return The unique ID of the {@link SolrContentItem}.
* @throws StoreException
*/
- String put(SolrContentItem ci, String ldProgramName) throws StoreException;
+ String put(SolrContentItem ci, String indexName) throws StoreException;
/**
* Retrieves the {@link SolrContentItem} from the Solr core corresponding to the specified
- * <code>ldProgramName</code>. If <code>null</code> is passed as the LDPath program name, the default Solr
- * core of Contenthub is used.
+ * <code>indexName</code>. If <code>null</code> is passed as the LDPath program name (index name), the
+ * default Solr core of Contenthub is used.
*
* @param id
* The ID of {@link SolrContentItem} to be retrieved.
- * @param ldProgramName
- * LDPath program name to obtain the corresponding Solr core from which the content item will
- * be retrieved
+ * @param indexName
+ * LDPath program name (name of the Solr core/index) to obtain the corresponding Solr core from
+ * which the content item will be retrieved
* @return {@link SolrContentItem} having the specified id
* @throws StoreException
*/
- SolrContentItem get(String id, String ldProgramName) throws StoreException;
+ SolrContentItem get(String id, String indexName) throws StoreException;
/**
- * Deletes the {@link ContentItem} from the default Solr core of Contenthub.
+ * Deletes the {@link ContentItem} from the default Solr core/index of Contenthub.
*
* @param id
* The ID of the item to be deleted.
@@ -120,16 +122,16 @@ public interface SolrStore extends Store
/**
* Deletes the {@link ContentItem} from the default Solr core corresponding to the given
- * <code>ldProgramName</code> of the Contenthub.
+ * <code>indexName</code> of the Contenthub.
*
* @param id
* The ID of the item to be deleted.
- * @param ldProgramName
- * LDPath program name to obtain the corresponding Solr core from which the content item will
- * be deleted
+ * @param indexName
+ * LDPath program name (name of the Solr core/index) to obtain the corresponding Solr core from
+ * which the content item will be deleted
* @throws StoreException
*/
- void deleteById(String id, String ldProgramName) throws StoreException;
+ void deleteById(String id, String indexName) throws StoreException;
/**
* Deletes the {@link ContentItem}s from the default Solr core of Contenthub.
@@ -140,14 +142,13 @@ public interface SolrStore extends Store
void deleteById(List<String> idList) throws StoreException;
/**
- * Deletes the {@link ContentItem}s from the Solr core corresponding to the given
- * <code>ldProgramName</code>.
+ * Deletes the {@link ContentItem}s from the Solr core corresponding to the given <code>indexName</code>.
*
* @param idList
* The list of IDs of the items to be deleted.
- * @param ldProgramName
- * LDPath program name to obtain the corresponding Solr core from which the content items will
- * be deleted
+ * @param indexName
+ * LDPath program name (name of the Solr core/index) to obtain the corresponding Solr core from
+ * which the content items will be deleted
*/
- void deleteById(List<String> idList, String ldProgramName) throws StoreException;
+ void deleteById(List<String> idList, String indexName) throws StoreException;
}
Modified: incubator/stanbol/trunk/contenthub/store/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/store/pom.xml?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/store/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/store/pom.xml Tue Feb 7 13:59:01 2012
@@ -39,10 +39,10 @@
<scm>
<connection>
- scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/store
+ scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/contenthub/store
</connection>
<developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/store
+ scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/contenthub/store
</developerConnection>
</scm>
Modified: incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java Tue Feb 7 13:59:01 2012
@@ -59,7 +59,7 @@ import org.apache.solr.common.SolrInputD
import org.apache.stanbol.commons.solr.managed.ManagedSolrServer;
import org.apache.stanbol.contenthub.servicesapi.Constants;
import org.apache.stanbol.contenthub.servicesapi.ldpath.LDPathException;
-import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgramManager;
+import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrContentItem;
import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrStore;
@@ -100,7 +100,7 @@ public class SolrStoreImpl implements So
private EnhancementJobManager jobManager;
@Reference
- private LDProgramManager ldProgramManager;
+ private SemanticIndexManager ldProgramManager;
private BundleContext bundleContext;
@@ -271,7 +271,7 @@ public class SolrStoreImpl implements So
@Override
public String put(SolrContentItem sci, String ldProgramName) throws StoreException {
if (ldProgramName == null || ldProgramName.isEmpty()
- || ldProgramName.equals(SolrCoreManager.CONTENTHUB_SOLR_SERVER_NAME)) {
+ || ldProgramName.equals(SolrCoreManager.CONTENTHUB_DEFAULT_INDEX_NAME)) {
return put(sci);
}
SolrInputDocument doc = new SolrInputDocument();
@@ -402,13 +402,13 @@ public class SolrStoreImpl implements So
values.add(value);
}
if (!values.isEmpty()) {
- doc.setField(fieldName.toString(), values.toArray());
+ doc.addField(fieldName.toString(), values.toArray());
}
}
@Override
public ContentItem get(String id) throws StoreException {
- return get(id, SolrCoreManager.CONTENTHUB_SOLR_SERVER_NAME);
+ return get(id, SolrCoreManager.CONTENTHUB_DEFAULT_INDEX_NAME);
}
// TODO: we can use cache for "Recently uploaded Content Items"..
@@ -507,7 +507,7 @@ public class SolrStoreImpl implements So
@Override
public void deleteById(String id) throws StoreException {
- deleteById(id, SolrCoreManager.CONTENTHUB_SOLR_SERVER_NAME);
+ deleteById(id, SolrCoreManager.CONTENTHUB_DEFAULT_INDEX_NAME);
}
@Override
@@ -533,7 +533,7 @@ public class SolrStoreImpl implements So
@Override
public void deleteById(List<String> idList) throws StoreException {
- deleteById(idList, SolrCoreManager.CONTENTHUB_SOLR_SERVER_NAME);
+ deleteById(idList, SolrCoreManager.CONTENTHUB_DEFAULT_INDEX_NAME);
}
}
Modified: incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/manager/SolrCoreManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/manager/SolrCoreManager.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/manager/SolrCoreManager.java (original)
+++ incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/manager/SolrCoreManager.java Tue Feb 7 13:59:01 2012
@@ -37,7 +37,7 @@ public class SolrCoreManager {
private static final Logger log = LoggerFactory.getLogger(SolrCoreManager.class);
private static SolrCoreManager instance;
- public static final String CONTENTHUB_SOLR_SERVER_NAME = "contenthub";
+ public static final String CONTENTHUB_DEFAULT_INDEX_NAME = "contenthub";
private static final int SECONDS_TO_WAITFOR_CORE_TO_BEREADY = 2;
@@ -78,11 +78,11 @@ public class SolrCoreManager {
}
public void createDefaultSolrServer() throws StoreException {
- if (!cache.containsKey(CONTENTHUB_SOLR_SERVER_NAME)) {
- if (!managedSolrServer.isManagedIndex(CONTENTHUB_SOLR_SERVER_NAME)) {
+ if (!cache.containsKey(CONTENTHUB_DEFAULT_INDEX_NAME)) {
+ if (!managedSolrServer.isManagedIndex(CONTENTHUB_DEFAULT_INDEX_NAME)) {
try {
- managedSolrServer.createSolrIndex(CONTENTHUB_SOLR_SERVER_NAME,
- CONTENTHUB_SOLR_SERVER_NAME, null);
+ managedSolrServer.createSolrIndex(CONTENTHUB_DEFAULT_INDEX_NAME,
+ CONTENTHUB_DEFAULT_INDEX_NAME, null);
} catch (IOException e) {
String msg = "Error while creating default solr index";
log.error(msg, e);
@@ -154,13 +154,13 @@ public class SolrCoreManager {
}
public SolrServer getServer() throws StoreException {
- return getServer(CONTENTHUB_SOLR_SERVER_NAME);
+ return getServer(CONTENTHUB_DEFAULT_INDEX_NAME);
}
public SolrServer getServer(String coreName) throws StoreException {
SolrServer solrServer = null;
if (coreName == null || coreName.trim().isEmpty()) {
- coreName = CONTENTHUB_SOLR_SERVER_NAME;
+ coreName = CONTENTHUB_DEFAULT_INDEX_NAME;
}
if (cache.containsKey(coreName)) {
// check cache for the server reference
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java Tue Feb 7 13:59:01 2012
@@ -23,25 +23,20 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.serializedform.Serializer;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.stanbol.commons.web.base.LinkResource;
import org.apache.stanbol.commons.web.base.NavigationLink;
import org.apache.stanbol.commons.web.base.ScriptResource;
import org.apache.stanbol.commons.web.base.WebFragment;
-import org.apache.stanbol.contenthub.servicesapi.store.Store;
import org.apache.stanbol.contenthub.web.resources.CNNImporterResource;
import org.apache.stanbol.contenthub.web.resources.FeaturedSearchResource;
-import org.apache.stanbol.contenthub.web.resources.LDProgramManagerResource;
+import org.apache.stanbol.contenthub.web.resources.SemanticIndexManagerResource;
import org.apache.stanbol.contenthub.web.resources.RootResource;
import org.apache.stanbol.contenthub.web.resources.StoreResource;
-import org.apache.stanbol.contenthub.web.writers.SearchResultWriter;
import org.apache.stanbol.contenthub.web.writers.LDProgramCollectionWriter;
-import org.apache.stanbol.enhancer.servicesapi.EnhancementJobManager;
+import org.apache.stanbol.contenthub.web.writers.SearchResultWriter;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
@@ -63,18 +58,6 @@ public class ContenthubWebFragment imple
private BundleContext bundleContext;
- @Reference
- TcManager tcManager;
-
- @Reference
- Store store;
-
- @Reference
- EnhancementJobManager jobManager;
-
- @Reference
- Serializer serializer;
-
@Override
public String getName() {
return NAME;
@@ -92,7 +75,7 @@ public class ContenthubWebFragment imple
classes.add(StoreResource.class);
classes.add(CNNImporterResource.class);
classes.add(FeaturedSearchResource.class);
- classes.add(LDProgramManagerResource.class);
+ classes.add(SemanticIndexManagerResource.class);
classes.add(LDProgramCollectionWriter.class);
classes.add(SearchResultWriter.class);
@@ -137,7 +120,7 @@ public class ContenthubWebFragment imple
@Override
public List<NavigationLink> getNavigationLinks() {
List<NavigationLink> links = new ArrayList<NavigationLink>();
- links.add(new NavigationLink("contenthub/store", "/contenthub", "/imports/contenthubDescription.ftl",
+ links.add(new NavigationLink("contenthub/contenthub/store", "/contenthub", "/imports/contenthubDescription.ftl",
20));
return links;
}
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/CNNImporterResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/CNNImporterResource.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/CNNImporterResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/CNNImporterResource.java Tue Feb 7 13:59:01 2012
@@ -28,6 +28,7 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
@@ -45,14 +46,17 @@ import com.sun.jersey.api.view.Viewable;
* @author cihan
*
*/
-@Path("/contenthub/import/cnn")
+@Path("/contenthub/{index}/import/cnn")
public class CNNImporterResource extends BaseStanbolResource {
private CNNImporter cnnImporter;
private Object templateData = null;
+ private String indexName;
- public CNNImporterResource(@Context ServletContext context) {
- cnnImporter = ContextHelper.getServiceFromContext(CNNImporter.class, context);
+ public CNNImporterResource(@Context ServletContext context,
+ @PathParam(value = "index") String indexName) {
+ this.indexName = indexName;
+ this.cnnImporter = ContextHelper.getServiceFromContext(CNNImporter.class, context);
}
private TopicNews importCNNNews(String topic, Integer max, Boolean full) {
@@ -66,7 +70,7 @@ public class CNNImporterResource extends
full = false;
}
- Map<URI,String> newsInfo = cnnImporter.importCNNNews(topic, max, full);
+ Map<URI,String> newsInfo = cnnImporter.importCNNNews(topic, max, full, indexName);
TopicNews tn = new TopicNews();
tn.setTopic(topic);
tn.setUris(new ArrayList<URI>(newsInfo.keySet()));
@@ -109,4 +113,8 @@ public class CNNImporterResource extends
public Object getTemplateData() {
return templateData;
}
+
+ public String getIndexName() {
+ return this.indexName;
+ }
}
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java Tue Feb 7 13:59:01 2012
@@ -33,6 +33,7 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
@@ -50,10 +51,12 @@ import org.apache.stanbol.commons.web.ba
import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
import org.apache.stanbol.contenthub.search.solr.util.SolrQueryUtil;
import org.apache.stanbol.contenthub.servicesapi.Constants;
+import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
import org.apache.stanbol.contenthub.servicesapi.search.featured.FeaturedSearch;
import org.apache.stanbol.contenthub.servicesapi.search.featured.SearchResult;
import org.apache.stanbol.contenthub.servicesapi.search.related.RelatedKeywordSearchManager;
+import org.apache.stanbol.contenthub.store.solr.manager.SolrCoreManager;
import org.apache.stanbol.contenthub.web.util.JSONUtils;
import org.apache.stanbol.contenthub.web.util.RestUtil;
import org.osgi.framework.InvalidSyntaxException;
@@ -70,7 +73,7 @@ import com.sun.jersey.api.view.Viewable;
* @author suat
*
*/
-@Path("/contenthub/search/featured")
+@Path("/contenthub/{index}/search/featured")
public class FeaturedSearchResource extends BaseStanbolResource {
private final static Logger log = LoggerFactory.getLogger(FeaturedSearchResource.class);
@@ -79,7 +82,22 @@ public class FeaturedSearchResource exte
private FeaturedSearch featuredSearch;
- public FeaturedSearchResource(@Context ServletContext context) throws IOException, InvalidSyntaxException {
+ private String indexName;
+
+ /**
+ *
+ * @param context
+ * @param indexName
+ * Name of the LDPath program (name of the Solr core/index) to be used while storing this
+ * content item. LDPath programs can be managed through {@link SemanticIndexManagerResource} or
+ * {@link SemanticIndexManager}
+ * @throws IOException
+ * @throws InvalidSyntaxException
+ */
+ public FeaturedSearchResource(@Context ServletContext context,
+ @PathParam(value = "index") String indexName) throws IOException,
+ InvalidSyntaxException {
+ this.indexName = indexName;
featuredSearch = ContextHelper.getServiceFromContext(FeaturedSearch.class, context);
tcManager = ContextHelper.getServiceFromContext(TcManager.class, context);
}
@@ -96,8 +114,6 @@ public class FeaturedSearchResource exte
* example, {@code q="john doe"&fl=score} is a valid value for this parameter. If this
* parameter exists, search is performed based on this solrQuery and any queryTerms are
* neglected.
- * @param ldProgram
- * The name of the LDPath program (actually name of the Solr core/index) to be searched over.
* @param jsonCons
* Constrainst in JSON format. These constraints are tranformed to corresponding Solr queries
* to enable faceted search. Each constraint is a facet field and values of the constraints
@@ -127,7 +143,6 @@ public class FeaturedSearchResource exte
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public final Response post(@FormParam("queryTerm") String queryTerm,
@FormParam("solrQuery") String solrQuery,
- @FormParam("ldProgram") String ldProgram,
@FormParam("constraints") String jsonCons,
@FormParam("graph") String graphURI,
@FormParam("offset") @DefaultValue("0") int offset,
@@ -138,7 +153,7 @@ public class FeaturedSearchResource exte
SolrServerException,
SearchException,
IOException {
- return get(queryTerm, solrQuery, ldProgram, jsonCons, graphURI, offset, limit, null, headers);
+ return get(queryTerm, solrQuery, jsonCons, graphURI, offset, limit, null, headers);
}
/**
@@ -151,8 +166,6 @@ public class FeaturedSearchResource exte
* example, {@code q="john doe"&fl=score} is a valid value for this parameter. If this
* parameter exists, search is performed based on this solrQuery and any queryTerms are
* neglected.
- * @param ldProgram
- * The name of the LDPath program (actually name of the Solr core/index) to be searched over.
* @param jsonCons
* Constrainst in JSON format. These constraints are tranformed to corresponding Solr queries
* to enable faceted search. Each constraint is a facet field and values of the constraints
@@ -183,7 +196,6 @@ public class FeaturedSearchResource exte
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
public final Response get(@QueryParam("queryTerm") String queryTerm,
@QueryParam("solrQuery") String solrQuery,
- @QueryParam("ldProgram") String ldProgram,
@QueryParam("constraints") String jsonCons,
@QueryParam("graphURI") String graphURI,
@QueryParam("offset") @DefaultValue("0") int offset,
@@ -199,7 +211,6 @@ public class FeaturedSearchResource exte
this.queryTerm = queryTerm = RestUtil.nullify(queryTerm);
solrQuery = RestUtil.nullify(solrQuery);
- ldProgram = RestUtil.nullify(ldProgram);
graphURI = RestUtil.nullify(graphURI);
jsonCons = RestUtil.nullify(jsonCons);
this.offset = offset;
@@ -222,8 +233,8 @@ public class FeaturedSearchResource exte
}
return Response.ok(new Viewable("index", this), MediaType.TEXT_HTML).build();
} else {
- ResponseBuilder rb = performSearch(queryTerm, solrQuery, ldProgram, jsonCons, graphURI,
- offset, limit, MediaType.TEXT_HTML_TYPE);
+ ResponseBuilder rb = performSearch(queryTerm, solrQuery, jsonCons, graphURI, offset, limit,
+ MediaType.TEXT_HTML_TYPE);
addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
@@ -232,8 +243,8 @@ public class FeaturedSearchResource exte
return Response.status(Status.BAD_REQUEST)
.entity("Either 'queryTerm' or 'solrQuery' should be specified").build();
} else {
- ResponseBuilder rb = performSearch(queryTerm, solrQuery, ldProgram, jsonCons, graphURI,
- offset, limit, MediaType.APPLICATION_JSON_TYPE);
+ ResponseBuilder rb = performSearch(queryTerm, solrQuery, jsonCons, graphURI, offset, limit,
+ MediaType.APPLICATION_JSON_TYPE);
addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
@@ -242,7 +253,6 @@ public class FeaturedSearchResource exte
private ResponseBuilder performSearch(String queryTerm,
String solrQuery,
- String ldProgramName,
String jsonCons,
String ontologyURI,
int offset,
@@ -250,22 +260,22 @@ public class FeaturedSearchResource exte
MediaType acceptedMediaType) throws SearchException {
if (solrQuery != null) {
- this.searchResults = featuredSearch.search(new SolrQuery(solrQuery), ontologyURI, ldProgramName);
+ this.searchResults = featuredSearch.search(new SolrQuery(solrQuery), ontologyURI, indexName);
} else if (queryTerm != null) {
Map<String,List<Object>> constraintsMap = JSONUtils.convertToMap(jsonCons);
this.chosenFacets = JSONUtils.convertToString(constraintsMap);
- List<String> allAvailableFacetNames = featuredSearch.getFieldNames(ldProgramName);
+ List<String> allAvailableFacetNames = featuredSearch.getFieldNames(indexName);
if (this.chosenFacets != null) {
SolrQuery sq = SolrQueryUtil.prepareFacetedSolrQuery(queryTerm, allAvailableFacetNames,
constraintsMap);
sq.setStart(offset);
sq.setRows(limit + 1);
- this.searchResults = featuredSearch.search(sq, ontologyURI, ldProgramName);
+ this.searchResults = featuredSearch.search(sq, ontologyURI, indexName);
} else {
SolrQuery sq = SolrQueryUtil.prepareDefaultSolrQuery(queryTerm, allAvailableFacetNames);
sq.setStart(offset);
sq.setRows(limit + 1);
- this.searchResults = featuredSearch.search(sq, ontologyURI, ldProgramName);
+ this.searchResults = featuredSearch.search(sq, ontologyURI, indexName);
}
} else {
log.error("Should never reach here!!!!");
@@ -356,4 +366,8 @@ public class FeaturedSearchResource exte
public String getChosenFacets() {
return this.chosenFacets;
}
+
+ public String getIndexName() {
+ return this.indexName;
+ }
}
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java Tue Feb 7 13:59:01 2012
@@ -86,7 +86,7 @@ public class RelatedKeywordResource exte
*
* @param keyword
* The keyword whose related keywords will be retrieved.
- * @param ontologyURI
+ * @param graphURI
* URI of the ontology to be used during the step in which related keywords are searched in
* ontology resources. If this parameter is {@code null}, then no related keywords are returned
* from ontology resources.
@@ -100,7 +100,7 @@ public class RelatedKeywordResource exte
@GET
@Produces(MediaType.APPLICATION_JSON)
public final Response findAllRelatedKeywords(@QueryParam("keyword") String keyword,
- @QueryParam("ontologyURI") String ontologyURI,
+ @QueryParam("graphURI") String graphURI,
@Context HttpHeaders headers) throws SearchException {
if (!RestUtil.isJSONaccepted(headers)) {
@@ -109,14 +109,14 @@ public class RelatedKeywordResource exte
keyword = RestUtil.nullify(keyword);
if (keyword == null) {
- String msg = "RelatedKeywordResource.findAllRelatedKeywords requires \"keyword\" parameter. \"ontologyURI\" is optional";
+ String msg = "RelatedKeywordResource.findAllRelatedKeywords requires \"keyword\" parameter. \"graphURI\" is optional";
log.error(msg);
throw new IllegalArgumentException(msg);
}
- ontologyURI = RestUtil.nullify(ontologyURI);
+ graphURI = RestUtil.nullify(graphURI);
SearchResult searchResult = relatedKeywordSearchManager.getRelatedKeywordsFromAllSources(keyword,
- ontologyURI);
+ graphURI);
return prepareResponse(searchResult, headers);
}
@@ -160,7 +160,7 @@ public class RelatedKeywordResource exte
*
* @param keyword
* The keyword whose related keywords will be retrieved from ontology resources.
- * @param ontologyURI
+ * @param graphURI
* URI of the ontology in which related keywords will be searched. The ontology should be
* available in the Contenthub system.
* @param headers
@@ -174,7 +174,7 @@ public class RelatedKeywordResource exte
@Produces(MediaType.APPLICATION_JSON)
@Path("/ontology")
public final Response findOntologyRelatedKeywords(@QueryParam("keyword") String keyword,
- @QueryParam("ontologyURI") String ontologyURI,
+ @QueryParam("graphURI") String graphURI,
@Context HttpHeaders headers) throws SearchException {
if (!RestUtil.isJSONaccepted(headers)) {
return Response.status(Status.BAD_REQUEST).build();
@@ -182,20 +182,20 @@ public class RelatedKeywordResource exte
keyword = RestUtil.nullify(keyword);
if (keyword == null) {
- String msg = "RelatedKeywordResource.findOntologyRelatedKeywords requires \"keyword\" and \"ontologyURI\" parameters.";
+ String msg = "RelatedKeywordResource.findOntologyRelatedKeywords requires \"keyword\" and \"graphURI\" parameters.";
log.error(msg);
throw new IllegalArgumentException(msg);
}
- ontologyURI = RestUtil.nullify(ontologyURI);
- if (ontologyURI == null) {
- String msg = "RelatedKeywordResource.findOntologyRelatedKeywords requires \"keyword\" and \"ontologyURI\" parameters.";
+ graphURI = RestUtil.nullify(graphURI);
+ if (graphURI == null) {
+ String msg = "RelatedKeywordResource.findOntologyRelatedKeywords requires \"keyword\" and \"graphURI\" parameters.";
log.error(msg);
throw new IllegalArgumentException(msg);
}
SearchResult searchResult = relatedKeywordSearchManager.getRelatedKeywordsFromOntology(keyword,
- ontologyURI);
+ graphURI);
return prepareResponse(searchResult, headers);
}
@@ -224,7 +224,7 @@ public class RelatedKeywordResource exte
keyword = RestUtil.nullify(keyword);
if (keyword == null) {
- String msg = "RelatedKeywordResource.findOntologyRelatedKeywords requires \"keyword\" and \"ontologyURI\" parameters.";
+ String msg = "RelatedKeywordResource.findOntologyRelatedKeywords requires a \"keyword\" parameter.";
log.error(msg);
throw new IllegalArgumentException(msg);
}
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java?rev=1241468&r1=1241467&r2=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java Tue Feb 7 13:59:01 2012
@@ -26,7 +26,7 @@ import javax.ws.rs.core.Response;
import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
/**
- * Base resource which automatically redirects to "contenthub/store"
+ * Base resource which automatically redirects to "contenthub/contenthub/store"
*
* @author anil.sinaci
*
@@ -36,6 +36,6 @@ public class RootResource extends BaseSt
@GET
public Response getView() throws URISyntaxException {
- return Response.seeOther(new URI(uriInfo.getBaseUri() + "contenthub/store/")).build();
+ return Response.seeOther(new URI(uriInfo.getBaseUri() + "contenthub/contenthub/store/")).build();
}
}
Copied: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java (from r1239477, incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDProgramManagerResource.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java?p2=incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java&p1=incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDProgramManagerResource.java&r1=1239477&r2=1241468&rev=1241468&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDProgramManagerResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java Tue Feb 7 13:59:01 2012
@@ -17,10 +17,11 @@
package org.apache.stanbol.contenthub.web.resources;
import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
+import java.util.List;
+
import javax.servlet.ServletContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -34,6 +35,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
@@ -41,11 +43,15 @@ import javax.ws.rs.core.Response.Status;
import org.apache.stanbol.commons.web.base.ContextHelper;
import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
import org.apache.stanbol.contenthub.servicesapi.ldpath.LDPathException;
+import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgram;
import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgramCollection;
-import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgramManager;
+import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
+import org.apache.stanbol.contenthub.web.util.RestUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.sun.jersey.api.view.Viewable;
+
/**
* This class the the web resource to handle the RESTful requests and HTML view of the LDProgram management
* facilities within Contenthub.
@@ -55,14 +61,14 @@ import org.slf4j.LoggerFactory;
*
*/
@Path("/contenthub/ldpath")
-public class LDProgramManagerResource extends BaseStanbolResource {
+public class SemanticIndexManagerResource extends BaseStanbolResource {
- private static final Logger logger = LoggerFactory.getLogger(LDProgramManagerResource.class);
+ private static final Logger logger = LoggerFactory.getLogger(SemanticIndexManagerResource.class);
- private LDProgramManager programManager;
+ private SemanticIndexManager programManager;
- public LDProgramManagerResource(@Context ServletContext context) {
- programManager = ContextHelper.getServiceFromContext(LDProgramManager.class, context);
+ public SemanticIndexManagerResource(@Context ServletContext context) {
+ programManager = ContextHelper.getServiceFromContext(SemanticIndexManager.class, context);
if (programManager == null) {
logger.error("Missing LDProgramManager = {}", programManager);
throw new WebApplicationException(404);
@@ -103,12 +109,17 @@ public class LDProgramManagerResource ex
* @return JSON string of {@code name:program} pairs.
*/
@GET
- @Produces(APPLICATION_JSON)
+ @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
public Response retrieveAllPrograms(@Context HttpHeaders headers) {
- LDProgramCollection ldProgramCollection = programManager.retrieveAllPrograms();
- ResponseBuilder rb = Response.ok(ldProgramCollection);
- addCORSOrigin(servletContext, rb, headers);
- return rb.build();
+ MediaType acceptedHeader = RestUtil.getAcceptedMediaType(headers);
+ if (acceptedHeader.isCompatible(MediaType.TEXT_HTML_TYPE)) {
+ return Response.ok(new Viewable("index", this), MediaType.TEXT_HTML).build();
+ } else{
+ LDProgramCollection ldProgramCollection = programManager.retrieveAllPrograms();
+ ResponseBuilder rb = Response.ok(ldProgramCollection, MediaType.APPLICATION_JSON);
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ }
}
/**
@@ -176,7 +187,7 @@ public class LDProgramManagerResource ex
@DELETE
@Path("/program")
@Consumes(APPLICATION_FORM_URLENCODED)
- public Response deleteProgram(@QueryParam("name") String programName, @Context HttpHeaders headers) {
+ public Response deleteProgram(@FormParam("name") String programName, @Context HttpHeaders headers) {
programManager.deleteProgram(programName);
ResponseBuilder rb = Response.ok();
addCORSOrigin(servletContext, rb, headers);
@@ -206,4 +217,9 @@ public class LDProgramManagerResource ex
}
}
+ // Helper methods for HTML view
+ public List<LDProgram> getLdPrograms() {
+ return programManager.retrieveAllPrograms().asList();
+ }
+
}