You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by su...@apache.org on 2012/03/28 09:52:18 UTC

svn commit: r1306205 - in /incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi: index/ search/solr/ store/

Author: suat
Date: Wed Mar 28 07:52:17 2012
New Revision: 1306205

URL: http://svn.apache.org/viewvc?rev=1306205&view=rev
Log:
STANBOL-471:
-Created initial interfaces for the two layered structure

Added:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndexManager.java
      - copied, changed from r1305799, incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java
Modified:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java?rev=1306205&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java Wed Mar 28 07:52:17 2012
@@ -0,0 +1,5 @@
+package org.apache.stanbol.contenthub.servicesapi.index;
+
+public enum EndpointType {
+    SOLR
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java?rev=1306205&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java Wed Mar 28 07:52:17 2012
@@ -0,0 +1,8 @@
+package org.apache.stanbol.contenthub.servicesapi.index;
+
+public enum IndexState {
+    UNINIT,
+    INDEXING,
+    ACTIVE,
+    REINDEXING
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java?rev=1306205&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java Wed Mar 28 07:52:17 2012
@@ -0,0 +1,31 @@
+package org.apache.stanbol.contenthub.servicesapi.index;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.osgi.framework.ServiceReference;
+
+public interface SemanticIndex {
+    String getName();
+    
+    String getDescription();
+    
+    boolean index(ContentItem ci);
+    
+    void remove(UriRef ciURI);
+    
+    void persist(long revision);
+    
+    long getRevision();
+    
+    List<String> getFieldsNames();
+    
+    Map<String,Object> getFieldProperties(String name);
+    
+    Map<String, String> getRESTSearchEndpoints();
+
+    @SuppressWarnings("rawtypes")
+    Map<Class, ServiceReference> getSearchEndPoints();
+}

Copied: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndexManager.java (from r1305799, incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndexManager.java?p2=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndexManager.java&p1=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java&r1=1305799&r2=1306205&rev=1306205&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/SemanticIndexManager.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndexManager.java Wed Mar 28 07:52:17 2012
@@ -14,122 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.stanbol.contenthub.servicesapi.ldpath;
+package org.apache.stanbol.contenthub.servicesapi.index;
+
+import java.util.List;
 
-import java.io.Reader;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import at.newmedialab.ldpath.model.programs.Program;
-
-/**
- * This interface provides create, retrieve, delete operations for LDPath
- * programs to be managed in the scope of Contenthub.
- * 
- * @author anil.sinaci
- * 
- */
 public interface SemanticIndexManager {
+    SemanticIndex getIndex(String name);
+
+    List<SemanticIndex> getIndexes(String name);
+
+    SemanticIndex getIndex(EndpointType endpointType);
+
+    List<SemanticIndex> getIndexes(EndpointType endpointType);
 
-	/**
-	 * Saves LDPath program to persistent storage with given name and
-	 * initializes a new Solr core with the same name
-	 * 
-	 * @param programName
-	 *            name of the submitted program, also will be name of
-	 *            corresponding Solr Core
-	 * @param ldPathProgram
-	 *            LDPath Program in the form of {@link String}
-	 * @throws LDPathException
-	 *             is thrown while parsing program and creating Solr Core
-	 */
-	public void submitProgram(String programName, String ldPathProgram)
-			throws LDPathException;
-
-	/**
-	 * Saves LDPath program to persistent storage with given name and
-	 * initializes a new Solr core with the same name
-	 * 
-	 * @param programName
-	 *            name of the submitted program, also will be name of
-	 *            corresponding Solr Core
-	 * @param ldPathProgram
-	 *            LDPath Program in the form of {@link java.io.Reader}
-	 * @throws LDPathException
-	 *             is thrown while parsing program and creating Solr Core
-	 */
-	public void submitProgram(String programName, Reader ldPathProgram)
-			throws LDPathException;
-
-	/**
-	 * Checks whether a program-core pair exists with given name or not
-	 * 
-	 * @param programName
-	 *            name of the program/core
-	 * @return {@link true} if a program with given name exists; {@link false}
-	 *         otherwise
-	 */
-	public boolean isManagedProgram(String programName);
-
-	/**
-	 * Retrieves the program managed by {@link ProgramManager} with given name
-	 * 
-	 * @param programName
-	 *            name of the program that will be retrieved
-	 * @return requested program as String, if such program does not exist,
-	 *         returns {@link false}
-	 */
-	public String getProgramByName(String programName);
-
-	 /**
-	 * Retrieves the program managed by {@link ProgramManager} with given
-	 name,
-	 * parses it, and returns the {@link Progra}
-	 *
-	 * @param programName
-	 * @return
-	 * @throws LDPathException
-	 */
-	 public Program<Object> getParsedProgramByName(String programName);
-
-	/**
-	 * Deletes both the program and the corresponding Solr Core
-	 * 
-	 * @param programName
-	 *            name of the program-core pair to be deleted
-	 */
-	public void deleteProgram(String programName);
-
-	/**
-	 * Used to retrieve names and programs of all currently managed program-core
-	 * pairs
-	 * 
-	 * @return All managed programs as {@link LDProgramCollection}
-	 */
-	public LDProgramCollection retrieveAllPrograms();
-
-	/**
-	 * This method first tries to obtain the program itself through the given
-	 * <code>programName</code> and if the program is obtained it is executed on
-	 * the given <code>graph</code>.
-	 * 
-	 * @param programName
-	 *            name of the program to be executed
-	 * @param contexts
-	 *            a {@link Set} of URIs (string representations) that are used
-	 *            as starting nodes to execute LDPath program specified by
-	 *            {@code programName} on the given {@code program}
-	 * @param graph
-	 *            a Clerezza graph on which the specified program will be
-	 *            executed
-	 * @return the {@link Map} containing the results obtained by executing the
-	 *         given program on the given graph. Keys of the map corresponds to
-	 *         fields in the program and values of the map corresponds to
-	 *         results obtained for the field specified in the key.
-	 * @throws LDPathException
-	 */
-	public Map<String, Collection<?>> executeProgram(String programName,
-			Set<String> contexts) throws LDPathException;
+    SemanticIndex getIndex(String name, EndpointType endpointType);
 
+    List<SemanticIndex> getIndexes(String name, EndpointType endpointType);
 }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java?rev=1306205&r1=1306204&r2=1306205&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java Wed Mar 28 07:52:17 2012
@@ -18,7 +18,7 @@ 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.SemanticIndexManager;
+import org.apache.stanbol.contenthub.servicesapi.index.SemanticIndexManager;
 import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
 
 /**

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java?rev=1306205&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java Wed Mar 28 07:52:17 2012
@@ -0,0 +1,14 @@
+package org.apache.stanbol.contenthub.servicesapi.store;
+
+import java.util.Set;
+
+import org.apache.clerezza.rdf.core.UriRef;
+
+public interface Changes {
+    long from();
+    
+    long to();
+    
+    Set<UriRef>changed();
+    
+}

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java?rev=1306205&r1=1306204&r2=1306205&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java Wed Mar 28 07:52:17 2012
@@ -1,67 +1,67 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.contenthub.servicesapi.store;
 
-import org.apache.clerezza.rdf.core.MGraph;
+import java.io.InputStream;
+
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
 
-
 /**
  * Store and retrieve ContentItem instances.
- *
- * Incomplete CRUD for now, we don't need it for our
- * initial use cases.
+ * 
+ * Incomplete CRUD for now, we don't need it for our initial use cases.
  */
 public interface Store {
 
     /**
-     * Creates a {@link ContentItem} item based on supplied data,
-     * using an implementation that suits this store.
+     * Creates a {@link ContentItem} item based on supplied data, using an implementation that suits this
+     * store.
      * <p>
-     * Calling this method creates an empty data transfer object in
-     * memory suitable for later saving using the {@link Store#put(ContentItem)} method.
-     * The Store state is unchanged by the call to the
+     * Calling this method creates an empty data transfer object in memory suitable for later saving using the
+     * {@link Store#put(ContentItem)} method. The Store state is unchanged by the call to the
      * {@link #create(String, byte[], String)} method.
-     *
-     * @param id The value to use {@link ContentItem#getId}. If <code>null</code>
-     * is parsed as id, an id need to be computed based on the parsed content (
-     * e.g. calculating the stream digest (see also
-     * {@link ContentItemHelper#streamDigest(java.io.InputStream, java.io.OutputStream, String)})
-     * @param content the binary content
-     * @param contentType The Mime-Type of the binary data
+     * 
+     * @param id
+     *            The value to use {@link ContentItem#getId}. If <code>null</code> is parsed as id, an id need
+     *            to be computed based on the parsed content ( e.g. calculating the stream digest (see also
+     *            {@link ContentItemHelper#streamDigest(java.io.InputStream, java.io.OutputStream, String)})
+     * @param content
+     *            the binary content
+     * @param contentType
+     *            The Mime-Type of the binary data
      * @return the {@link ContentItem} that was created
      */
-    ContentItem create(String id, byte[] content, String contentType);
+    ContentItem create(String id, byte[] content, String contentType) throws StoreException;
 
-    /** Store supplied {@link ContentItem} and return its id, which
-     *  is assigned by the store if not defined yet.
-     *
-     *  If the {@link ContentItem} already exists, it is overwritten.
+    ContentItem create(String id, InputStream is, String contentType) throws StoreException;
+
+    ContentItem remove(String id) throws StoreException;
+
+    /**
+     * Store supplied {@link ContentItem} and return its id, which is assigned by the store if not defined
+     * yet.
+     * 
+     * If the {@link ContentItem} already exists, it is overwritten.
      */
     String put(ContentItem ci) throws StoreException;
 
     /** Get a {@link ContentItem} by id, null if non-existing */
     ContentItem get(String id) throws StoreException;
 
-    /**
-     * Get the graph of triples of enhancements related to the content item from
-     * this store
-     */
-    MGraph getEnhancementGraph();
-
+    Changes changes(long revision) throws StoreException;
 }