You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2011/03/16 19:44:00 UTC
svn commit: r1082257 [4/4] - in /incubator/stanbol/trunk/entityhub: ./
generic/core/src/main/java/org/apache/stanbol/entityhub/core/impl/
generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/
generic/core/src/main/java/org/apache/stanbo...
Modified: incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlDereferencer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlDereferencer.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlDereferencer.java (original)
+++ incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlDereferencer.java Wed Mar 16 18:43:57 2011
@@ -55,7 +55,7 @@ public class SparqlDereferencer extends
}
@Reference
- protected Parser parser;
+ private Parser parser;
/*
@@ -65,7 +65,7 @@ public class SparqlDereferencer extends
* However it is not clear if such a functionality is needed.
*/
@Override
- public InputStream dereference(String uri, String contentType) throws IOException {
+ public final InputStream dereference(String uri, String contentType) throws IOException {
if(uri==null){
return null;
}
@@ -81,7 +81,7 @@ public class SparqlDereferencer extends
return SparqlEndpointUtils.sendSparqlRequest(getAccessUri(),query.toString(),contentType);
}
- public Representation dereference(String uri) throws IOException {
+ public final Representation dereference(String uri) throws IOException {
long start = System.currentTimeMillis();
String format = SupportedFormat.RDF_XML;
InputStream in = dereference(uri, format);
Modified: incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlEndpointUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlEndpointUtils.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlEndpointUtils.java (original)
+++ incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlEndpointUtils.java Wed Mar 16 18:43:57 2011
@@ -24,10 +24,10 @@ import java.net.URLConnection;
import javax.ws.rs.core.UriBuilder;
-public class SparqlEndpointUtils {
+public final class SparqlEndpointUtils {
+ private SparqlEndpointUtils() {/* Do not create instances of utility classes*/}
public static final String SPARQL_RESULT_JSON = "application/sparql-results+json";
- public SparqlEndpointUtils() {/* Do not create instances of utility classes*/}
/**
* Sends an SPARQL Request to the accessUri. Please note that based on the
@@ -43,7 +43,7 @@ public class SparqlEndpointUtils {
final URI dereferenceUri = UriBuilder.fromUri(accessUri)
.queryParam("query", "{query}")
.queryParam("format", "{format}")
- .build(query.toString(), contentType);
+ .build(query, contentType);
final URLConnection con = dereferenceUri.toURL().openConnection();
con.addRequestProperty("Accept", contentType);
return con.getInputStream();
Modified: incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlSearcher.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlSearcher.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlSearcher.java (original)
+++ incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/SparqlSearcher.java Wed Mar 16 18:43:57 2011
@@ -40,9 +40,9 @@ import org.apache.stanbol.entityhub.serv
import org.apache.stanbol.entityhub.servicesapi.query.FieldQuery;
import org.apache.stanbol.entityhub.servicesapi.query.QueryResultList;
import org.apache.stanbol.entityhub.servicesapi.site.EntitySearcher;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
import org.slf4j.LoggerFactory;
@@ -59,12 +59,12 @@ public class SparqlSearcher extends Abst
}
@Reference
- protected Parser parser;
+ private Parser parser;
protected static final String DEFAULT_RDF_CONTENT_TYPE = SupportedFormat.N3;
protected static final String DEFAULT_SPARQL_RESULT_CONTENT_TYPE = SparqlEndpointUtils.SPARQL_RESULT_JSON;
@Override
- public QueryResultList<String> findEntities(FieldQuery parsedQuery) throws IOException {
+ public final QueryResultList<String> findEntities(FieldQuery parsedQuery) throws IOException {
final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
String sparqlQuery = query.toSparqlSelect(false);
InputStream in = SparqlEndpointUtils.sendSparqlRequest(getQueryUri(), sparqlQuery, DEFAULT_SPARQL_RESULT_CONTENT_TYPE);
@@ -116,7 +116,7 @@ public class SparqlSearcher extends Abst
}
@Override
- public QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException{
+ public final QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException{
long start = System.currentTimeMillis();
final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
String sparqlQuery = query.toSparqlConstruct();
Modified: incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/VirtuosoSearcher.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/VirtuosoSearcher.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/VirtuosoSearcher.java (original)
+++ incubator/stanbol/trunk/entityhub/site/linkedData/src/main/java/org/apache/stanbol/entityhub/site/linkedData/impl/VirtuosoSearcher.java Wed Mar 16 18:43:57 2011
@@ -48,14 +48,14 @@ import org.slf4j.LoggerFactory;
)
public class VirtuosoSearcher extends AbstractEntitySearcher implements EntitySearcher{
@Reference
- protected Parser parser;
+ private Parser parser;
public VirtuosoSearcher() {
super(LoggerFactory.getLogger(VirtuosoSearcher.class));
}
@Override
- public QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException {
+ public final QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException {
long start = System.currentTimeMillis();
final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
query.setEndpointType(EndpointTypeEnum.Virtuoso);
@@ -83,7 +83,7 @@ public class VirtuosoSearcher extends Ab
}
@Override
- public QueryResultList<String> findEntities(FieldQuery parsedQuery) throws IOException {
+ public final QueryResultList<String> findEntities(FieldQuery parsedQuery) throws IOException {
final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
query.setEndpointType(EndpointTypeEnum.Virtuoso);
String sparqlQuery = query.toSparqlSelect(false);
Modified: incubator/stanbol/trunk/entityhub/yard/clerezza/src/main/java/org/apache/stanbol/entityhub/yard/clerezza/impl/ClerezzaYard.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/clerezza/src/main/java/org/apache/stanbol/entityhub/yard/clerezza/impl/ClerezzaYard.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/clerezza/src/main/java/org/apache/stanbol/entityhub/yard/clerezza/impl/ClerezzaYard.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/clerezza/src/main/java/org/apache/stanbol/entityhub/yard/clerezza/impl/ClerezzaYard.java Wed Mar 16 18:43:57 2011
@@ -56,7 +56,7 @@ import org.apache.stanbol.entityhub.core
import org.apache.stanbol.entityhub.core.yard.SimpleYardConfig;
import org.apache.stanbol.entityhub.model.clerezza.RdfRepresentation;
import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory;
-import org.apache.stanbol.entityhub.model.clerezza.utils.Resource2StringAdapter;
+import org.apache.stanbol.entityhub.model.clerezza.impl.Resource2StringAdapter;
import org.apache.stanbol.entityhub.query.clerezza.RdfQueryResultList;
import org.apache.stanbol.entityhub.query.clerezza.SparqlFieldQuery;
import org.apache.stanbol.entityhub.query.clerezza.SparqlFieldQueryFactory;
@@ -99,7 +99,7 @@ import org.slf4j.LoggerFactory;
// @Property(name=Yard.DESCRIPTION,value="Default values for configuring the Entityhub Yard without editing")
//})
public class ClerezzaYard extends AbstractYard implements Yard {
- Logger log = LoggerFactory.getLogger(ClerezzaYard.class);
+ private static Logger log = LoggerFactory.getLogger(ClerezzaYard.class);
/**
* Property used to mark empty Representations managed by this Graph. This is
* needed to workaround the fact, that the Entityhub supports the storage of
@@ -113,11 +113,11 @@ public class ClerezzaYard extends Abstra
* <code> ?representationId <{@value #MANAGED_REPRESENTATION}> true^^xsd:boolean </code>
* <br> for any empty Representation avoids this unwanted behaviour.
*/
- public static UriRef MANAGED_REPRESENTATION = new UriRef("urn:org.apache.stanbol:entityhub.yard:rdf.clerezza:managesRepresentation");
+ public static final UriRef MANAGED_REPRESENTATION = new UriRef("urn:org.apache.stanbol:entityhub.yard:rdf.clerezza:managesRepresentation");
/**
* The TRUE value used as object for the property {@link #MANAGED_REPRESENTATION}.
*/
- private static Literal TRUE_LITERAL = LiteralFactory.getInstance().createTypedLiteral(Boolean.FALSE);
+ private static final Literal TRUE_LITERAL = LiteralFactory.getInstance().createTypedLiteral(Boolean.FALSE);
//public static final String YARD_URI_PREFIX = "urn:org.apache.stanbol:entityhub.yard:rdf.clerezza:";
// public static final UriRef REPRESENTATION = new UriRef(RdfResourceEnum.Representation.getUri());
// protected ComponentContext context;
@@ -136,7 +136,7 @@ public class ClerezzaYard extends Abstra
}
@SuppressWarnings("unchecked")
@Activate
- protected void activate(ComponentContext context) throws ConfigurationException {
+ protected final void activate(ComponentContext context) throws ConfigurationException {
log.info("in "+ClerezzaYard.class+" activate with context "+context);
if(context == null || context.getProperties() == null){
throw new IllegalStateException("No valid"+ComponentContext.class+" parsed in activate!");
@@ -149,10 +149,10 @@ public class ClerezzaYard extends Abstra
* Method. In case the Yard runs outside of an OSGI Container it is called
* by the Constructor taking the {@link YardConfig} as parameter
* @param config The configuration for the new Yard instance
- * @throws NullPointerException In case <code>null</code> is parsed as configuration
- * @throws IllegalArgumentException In case the configuration is invalid
+ * @throws IllegalArgumentException In case <code>null</code> is parsed as
+ * configuration or the configuration is invalid
*/
- private final void activate(YardConfig config) throws IllegalArgumentException, NullPointerException {
+ private final void activate(YardConfig config) throws IllegalArgumentException {
super.activate(RdfValueFactory.getInstance(), SparqlFieldQueryFactory.getInstance(), config);
if(tcManager == null){ //this will be the case if we are not in an OSGI environment
//use the getInstance() method!
@@ -171,7 +171,7 @@ public class ClerezzaYard extends Abstra
}
@Deactivate
- protected void deactivate(ComponentContext context) {
+ protected final void deactivate(ComponentContext context) {
log.info("in "+ClerezzaYard.class.getSimpleName()+" deactivate with context "+context);
this.yardGraphUri = null;
this.graph = null;
@@ -183,14 +183,14 @@ public class ClerezzaYard extends Abstra
* @return the URI used for the RDF graph that stores all the data of this
* yard.
*/
- public String getYardGraphUri(){
+ public final String getYardGraphUri(){
return yardGraphUri.getUnicodeString();
}
@Override
public Representation getRepresentation(String id) {
if(id == null){
- throw new NullPointerException("The parsed representation id MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed representation id MUST NOT be NULL!");
}
if(id.isEmpty()){
throw new IllegalArgumentException("The parsed representation id MUST NOT be EMTPY!");
@@ -204,7 +204,7 @@ public class ClerezzaYard extends Abstra
* refers to a Resource in the graph that is of type {@link #REPRESENTATION}
* @return the Representation
*/
- protected Representation getRepresentation(UriRef uri, boolean check) {
+ protected final Representation getRepresentation(UriRef uri, boolean check) {
Lock readLock = graph.getLock().readLock();
readLock.lock();
try {
@@ -214,7 +214,7 @@ public class ClerezzaYard extends Abstra
// ... this will only remove the triple if the Representation is empty
// but a check would take longer than the this call
nodeGraph.remove(new TripleImpl(uri,MANAGED_REPRESENTATION,TRUE_LITERAL));
- return ((RdfValueFactory)valueFactory).createRdfRepresentation(uri, nodeGraph);
+ return ((RdfValueFactory)getValueFactory()).createRdfRepresentation(uri, nodeGraph);
} else {
return null; //not found
}
@@ -265,7 +265,7 @@ public class ClerezzaYard extends Abstra
@Override
public boolean isRepresentation(String id) {
if(id == null) {
- throw new NullPointerException("The parsed id MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed id MUST NOT be NULL!");
}
if(id.isEmpty()){
throw new IllegalArgumentException("The parsed id MUST NOT be EMPTY!");
@@ -278,14 +278,14 @@ public class ClerezzaYard extends Abstra
* @param resource the resource to check
* @return the state
*/
- protected boolean isRepresentation(UriRef resource){
+ protected final boolean isRepresentation(UriRef resource){
return graph.filter(resource, null, null).hasNext();
}
@Override
public void remove(String id) throws IllegalArgumentException {
if(id == null) {
- throw new NullPointerException("The parsed Representation id MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Representation id MUST NOT be NULL!");
}
UriRef resource = new UriRef(id);
Lock writeLock = graph.getLock().writeLock();
@@ -299,9 +299,9 @@ public class ClerezzaYard extends Abstra
}
}
@Override
- public void remove(Iterable<String> ids) throws IllegalArgumentException, YardException {
+ public final void remove(Iterable<String> ids) throws IllegalArgumentException, YardException {
if(ids == null){
- throw new NullPointerException("The parsed Iterable over the IDs to remove MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Iterable over the IDs to remove MUST NOT be NULL!");
}
for(String id : ids){
if(id != null){
@@ -310,24 +310,30 @@ public class ClerezzaYard extends Abstra
}
}
@Override
- public Representation store(Representation representation) throws IllegalArgumentException, YardException {
+ public final Representation store(Representation representation) throws IllegalArgumentException, YardException {
+ if(representation == null){
+ throw new IllegalArgumentException("The parsed Representation MUST NOT be NULL!");
+ }
return store(representation,true,true);
}
@Override
- public Iterable<Representation> store(Iterable<Representation> representations) throws IllegalArgumentException, YardException {
+ public final Iterable<Representation> store(Iterable<Representation> representations) throws IllegalArgumentException, YardException {
if(representations == null){
- throw new NullPointerException("The parsed Iterable over the Representations to store MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Iterable over the Representations to store MUST NOT be NULL!");
}
return store(representations, true);
}
@Override
- public Representation update(Representation representation) throws IllegalArgumentException, YardException {
+ public final Representation update(Representation representation) throws IllegalArgumentException, YardException {
+ if(representation == null){
+ throw new IllegalArgumentException("The parsed Representation MUST NOT be NULL!");
+ }
return store(representation,false,true);
}
@Override
- public Iterable<Representation> update(Iterable<Representation> representations) throws YardException, IllegalArgumentException {
+ public final Iterable<Representation> update(Iterable<Representation> representations) throws YardException, IllegalArgumentException {
if(representations == null){
- throw new NullPointerException("The parsed Iterable over the Representations to update MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Iterable over the Representations to update MUST NOT be NULL!");
}
return store(representations,false);
}
@@ -350,7 +356,9 @@ public class ClerezzaYard extends Abstra
protected final Representation store(Representation representation,boolean allowCreate,boolean canNotCreateIsError) throws IllegalArgumentException, YardException{
log.info("store Representation "+representation.getId());
// log.info(" > entityhub size: "+graph.size());
- if(representation == null) return null;
+ if(representation == null) {
+ return null;
+ }
if(isRepresentation(representation.getId())){
// log.info(" > remove previous version");
remove(representation.getId());
@@ -363,7 +371,7 @@ public class ClerezzaYard extends Abstra
}
}
//get the graph for the Representation and add it to the store
- RdfRepresentation toAdd = ((RdfValueFactory)valueFactory).toRdfRepresentation(representation);
+ RdfRepresentation toAdd = ((RdfValueFactory)getValueFactory()).toRdfRepresentation(representation);
// log.info(" > add "+toAdd.size()+" triples to Yard "+getId());
Lock writeLock = graph.getLock().writeLock();
writeLock.lock();
@@ -388,23 +396,7 @@ public class ClerezzaYard extends Abstra
throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
}
final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
- int limit = QueryUtils.getLimit(query, config.getDefaultQueryResultNumber(), config.getMaxQueryResultNumber());
- SelectQuery sparqlQuery;
- String sparqlQueryString = SparqlQueryUtils.createSparqlSelectQuery(query, false,limit,EndpointTypeEnum.Standard);
- try {
- sparqlQuery = (SelectQuery)QueryParser.getInstance().parse(sparqlQueryString);
- } catch (ParseException e) {
- log.error("ParseException for SPARQL Query in findRepresentation");
- log.error("FieldQuery: "+query);
- log.error("SPARQL Query: "+sparqlQueryString);
- throw new YardException("Unable to parse SPARQL query generated for the parse FieldQuery",e);
- } catch (ClassCastException e){
- log.error("ClassCastExeption because parsed SPARQL Query is not of Type "+SelectQuery.class);
- log.error("FieldQuery: "+query);
- log.error("SPARQL Query: "+sparqlQueryString);
- throw new YardException("Unable to parse SPARQL SELECT query generated for the parse FieldQuery",e);
- }
- final ResultSet result = tcManager.executeSparqlQuery((SelectQuery)sparqlQuery, graph);
+ final ResultSet result = executeSparqlFieldQuery(query);
//A little bit complex construct ...
// first we use the adaptingIterator to convert reseource to string
// to get the resources we have to retrieve the root-variable of the
@@ -419,13 +411,16 @@ public class ClerezzaYard extends Abstra
new Resource2StringAdapter<Resource>(), String.class);
return new QueryResultListImpl<String>(query,representationIdIterator,String.class);
}
- @Override
- public QueryResultList<Representation> findRepresentation(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
- if(parsedQuery == null){
- throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
- }
- final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
- int limit = QueryUtils.getLimit(query, config.getDefaultQueryResultNumber(), config.getMaxQueryResultNumber());
+ /**
+ * Returns the SPARQL result set for a given {@link SparqlFieldQuery} that
+ * was executed on this yard
+ * @param query the SparqlFieldQuery instance
+ * @return the results of the SPARQL query in the yard
+ * @throws YardException in case the generated SPARQL query could not be parsed
+ * or the generated Query is not an SPARQL SELECT query.
+ */
+ private ResultSet executeSparqlFieldQuery(final SparqlFieldQuery query) throws YardException {
+ int limit = QueryUtils.getLimit(query, getConfig().getDefaultQueryResultNumber(), getConfig().getMaxQueryResultNumber());
SelectQuery sparqlQuery;
String sparqlQueryString = SparqlQueryUtils.createSparqlSelectQuery(query, false,limit,EndpointTypeEnum.Standard);
try {
@@ -441,7 +436,15 @@ public class ClerezzaYard extends Abstra
log.error("SPARQL Query: "+sparqlQueryString);
throw new YardException("Unable to parse SPARQL SELECT query generated for the parse FieldQuery",e);
}
- final ResultSet result = tcManager.executeSparqlQuery((SelectQuery)sparqlQuery, graph);
+ return tcManager.executeSparqlQuery((SelectQuery)sparqlQuery, graph);
+ }
+ @Override
+ public QueryResultList<Representation> findRepresentation(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
+ if(parsedQuery == null){
+ throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
+ }
+ final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
+ final ResultSet result = executeSparqlFieldQuery(query);
//Note: An other possibility would be to first iterate over all results and add it to
// a list and create this Iterator than based on the List. This would
// be the preferenced way if changes in the graph could affect the
@@ -459,7 +462,7 @@ public class ClerezzaYard extends Abstra
@Override
public Representation adapt(SolutionMapping solution, Class<Representation> type) {
Resource resource = solution.get(query.getRootVariableName());
- if(resource != null && resource instanceof UriRef){
+ if(resource instanceof UriRef){
try {
return getRepresentation((UriRef)resource,false);
} catch (IllegalArgumentException e) {
@@ -477,12 +480,12 @@ public class ClerezzaYard extends Abstra
return new QueryResultListImpl<Representation>(query,representationIterator,Representation.class);
}
@Override
- public QueryResultList<Representation> find(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
+ public final QueryResultList<Representation> find(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
if(parsedQuery == null){
throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
}
final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
- int limit = QueryUtils.getLimit(query, config.getDefaultQueryResultNumber(), config.getMaxQueryResultNumber());
+ int limit = QueryUtils.getLimit(query, getConfig().getDefaultQueryResultNumber(), getConfig().getMaxQueryResultNumber());
Query sparqlQuery;
//NOTE(s):
// - parse RdfResourceEnum.representationType as additional field, because
Modified: incubator/stanbol/trunk/entityhub/yard/clerezza/src/test/java/org/apache/stanbol/entityhub/yard/clerezza/impl/ClerezzaYardTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/clerezza/src/test/java/org/apache/stanbol/entityhub/yard/clerezza/impl/ClerezzaYardTest.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/clerezza/src/test/java/org/apache/stanbol/entityhub/yard/clerezza/impl/ClerezzaYardTest.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/clerezza/src/test/java/org/apache/stanbol/entityhub/yard/clerezza/impl/ClerezzaYardTest.java Wed Mar 16 18:43:57 2011
@@ -29,7 +29,6 @@ import org.apache.stanbol.entityhub.serv
import org.apache.stanbol.entityhub.servicesapi.yard.YardException;
import org.apache.stanbol.entityhub.test.yard.YardTest;
import org.junit.AfterClass;
-import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/defaults/SolrConst.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/defaults/SolrConst.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/defaults/SolrConst.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/defaults/SolrConst.java Wed Mar 16 18:43:57 2011
@@ -24,7 +24,8 @@ package org.apache.stanbol.entityhub.yar
* @author Rupert Westenthaler
*
*/
-public class SolrConst {
+public final class SolrConst {
+ private SolrConst(){}
/**
* Char used to mark special fields. Special fields are internally used
* fields that do not represent a value that was present in the original
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/embedded/EmbeddedSolrPorovider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/embedded/EmbeddedSolrPorovider.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/embedded/EmbeddedSolrPorovider.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/embedded/EmbeddedSolrPorovider.java Wed Mar 16 18:43:57 2011
@@ -81,7 +81,7 @@ public class EmbeddedSolrPorovider imple
* requested paths.
*/
@SuppressWarnings("unchecked")
- protected Map<String, CoreContainer> coreContainers = new ReferenceMap();
+ private Map<String, CoreContainer> coreContainers = new ReferenceMap();
@Property
public static final String SOLR_HOME = "solr.solr.home";
@@ -101,7 +101,7 @@ public class EmbeddedSolrPorovider imple
public SolrServer getSolrServer(Type type, String uriOrPath, String... additional) throws NullPointerException, IllegalArgumentException {
log.debug(String.format("getSolrServer Request for %s and path %s",type,uriOrPath));
if(uriOrPath == null){
- throw new NullPointerException("The Path to the Index MUST NOT be NULL!");
+ throw new IllegalArgumentException("The Path to the Index MUST NOT be NULL!");
}
File index = new File(uriOrPath);
if(!index.exists()){
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/DefaultSolrServerProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/DefaultSolrServerProvider.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/DefaultSolrServerProvider.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/DefaultSolrServerProvider.java Wed Mar 16 18:43:57 2011
@@ -50,7 +50,7 @@ public class DefaultSolrServerProvider i
@Override
public SolrServer getSolrServer(Type type, String uriOrPath, String... additional) throws NullPointerException, IllegalArgumentException {
if(uriOrPath == null){
- throw new NullPointerException("The parsed SolrServer URI MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed SolrServer URI MUST NOT be NULL!");
}
if(type == null){
type = Type.HTTP;
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrFieldMapper.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrFieldMapper.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrFieldMapper.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrFieldMapper.java Wed Mar 16 18:43:57 2011
@@ -19,7 +19,6 @@ package org.apache.stanbol.entityhub.yar
import static org.apache.stanbol.entityhub.yard.solr.defaults.SolrConst.DEPENDENT_DOCUMENT_FIELD;
import static org.apache.stanbol.entityhub.yard.solr.defaults.SolrConst.DOCUMENT_ID_FIELD;
import static org.apache.stanbol.entityhub.yard.solr.defaults.SolrConst.DOMAIN_FIELD;
-import static org.apache.stanbol.entityhub.yard.solr.defaults.SolrConst.LANG_MERGER_FIELD;
import static org.apache.stanbol.entityhub.yard.solr.defaults.SolrConst.PATH_SEPERATOR;
import static org.apache.stanbol.entityhub.yard.solr.defaults.SolrConst.REFERRED_DOCUMENT_FIELD;
import static org.apache.stanbol.entityhub.yard.solr.defaults.SolrConst.SPECIAL_CONFIG_FIELD;
@@ -65,7 +64,7 @@ import org.slf4j.LoggerFactory;
*/
public class SolrFieldMapper implements FieldMapper {
- Logger log = LoggerFactory.getLogger(SolrFieldMapper.class);
+ private static Logger log = LoggerFactory.getLogger(SolrFieldMapper.class);
/**
* Char used to separate the prefix from the local name of uri's
*/
@@ -86,6 +85,10 @@ public class SolrFieldMapper implements
Collections.singletonList(RdfResourceEnum.resultScore.getUri()),
IndexDataTypeEnum.FLOAT.getIndexType());
/**
+ * The Solr Server of this FieldMapper
+ */
+ protected final SolrServer server;
+ /**
* Internally used as LRU Cache with {@link SolrFieldMapper#LRU_MAPPINGS_CACHE_SIZE}
* elements. This subclass of {@link LinkedHashMap} overrides the
* {@link LinkedHashMap#removeEldestEntry(Entry)} as suggested by the java
@@ -115,17 +118,16 @@ public class SolrFieldMapper implements
* them again and again.
* @see LinkedHashMap#
*/
- private final LinkedHashMap<IndexField, Collection<String>> indexFieldMappings =
+ private final LRU<IndexField, Collection<String>> indexFieldMappings =
new LRU<IndexField, Collection<String>>();
/**
* The assumption is, that only a handful of fields appear in index documents.
* So it makes sense to keep some mappings within a cache rather than calculating
* them again and again.
*/
- private final LinkedHashMap<String, IndexField> fieldMappings =
+ private final LRU<String, IndexField> fieldMappings =
new LRU<String, IndexField>();
- protected final SolrServer server;
public SolrFieldMapper(SolrServer server){
if(server == null){
throw new IllegalArgumentException("The parsed SolrServer MUST NOT be NULL");
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrQueryFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrQueryFactory.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrQueryFactory.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrQueryFactory.java Wed Mar 16 18:43:57 2011
@@ -96,15 +96,15 @@ public class SolrQueryFactory {
* The default limit of results for queries
*/
public static final Integer DEFAULT_QUERY_RESULTS = 10;
- protected final Logger log = LoggerFactory.getLogger(SolrQueryFactory.class);
+ private final Logger log = LoggerFactory.getLogger(SolrQueryFactory.class);
private final FieldMapper fieldMapper;
private final IndexValueFactory indexValueFactory;
private final ValueFactory valueFactory;
- protected final Map<IndexConstraintTypeEnum, IndexConstraintTypeEncoder<?>> constraintEncoders;
+ private final Map<IndexConstraintTypeEnum, IndexConstraintTypeEncoder<?>> constraintEncoders;
- protected String domain;
- protected Integer maxQueryResults = MAX_QUERY_RESULTS;
- protected Integer defaultQueryResults = DEFAULT_QUERY_RESULTS;
+ private String domain;
+ private Integer maxQueryResults = MAX_QUERY_RESULTS;
+ private Integer defaultQueryResults = DEFAULT_QUERY_RESULTS;
public SolrQueryFactory(ValueFactory valueFactory, IndexValueFactory indexValueFactory, FieldMapper fieldMapper){
if(fieldMapper == null){
@@ -230,7 +230,7 @@ public class SolrQueryFactory {
if(dataType == null){
dataType = upperDataType;
} else {
- if(dataType != upperDataType){
+ if(!dataType.equals(upperDataType)){
indexConstraint.setInvalied(String.format("A Range Query MUST use the same data type for the upper and lover Bound! (lower:[value=%s|datatype=%s] | upper:[value=%s|datatype=%s])",
rangeConstraint.getLowerBound(),dataType,rangeConstraint.getUpperBound(),upperDataType));
}
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java Wed Mar 16 18:43:57 2011
@@ -190,7 +190,7 @@ public class SolrYard extends AbstractYa
* {@link Representation} to fields in the {@link SolrInputDocument} and
* vice versa
*/
- protected FieldMapper fieldMapper;
+ private FieldMapper fieldMapper;
/**
* The {@link IndexValueFactory} is responsible for converting values of
* fields in the {@link Representation} to the according {@link IndexValue}.
@@ -200,7 +200,7 @@ public class SolrYard extends AbstractYa
* the {@link SolrInputDocument} and {@link SolrDocument}. This is done by
* the configured {@link FieldMapper}.
*/
- protected IndexValueFactory indexValueFactory;
+ private IndexValueFactory indexValueFactory;
/**
* The {@link SolrQueryFactory} is responsible for converting the
* {@link Constraint}s of a query to constraints in the index. This requires
@@ -264,7 +264,7 @@ public class SolrYard extends AbstractYa
}
@SuppressWarnings("unchecked")
@Activate
- protected void activate(ComponentContext context) throws ConfigurationException,IOException,SolrServerException {
+ protected final void activate(ComponentContext context) throws ConfigurationException,IOException,SolrServerException {
log.info("in "+SolrYard.class+" activate with context "+context);
if(context == null){
throw new IllegalStateException("No valid"+ComponentContext.class+" parsed in activate!");
@@ -282,36 +282,39 @@ public class SolrYard extends AbstractYa
private void activate(SolrYardConfig config) throws ConfigurationException,IOException,SolrServerException {
//init with the default implementations of the ValueFactory and the QueryFactory
super.activate(InMemoryValueFactory.getInstance(), DefaultQueryFactory.getInstance(), config);
+ //mayby the super activate has updated the configuration
+ config = (SolrYardConfig) this.getConfig();
if(solrServerProviderManager == null){ //not within an OSGI environment
solrServerProviderManager = SolrServerProviderManager.getInstance();
}
server = solrServerProviderManager.getSolrServer(
- ((SolrYardConfig)this.config).getSolrServerType(),
- ((SolrYardConfig)this.config).getSolrServerLocation().toString());
+ config.getSolrServerType(),
+ config.getSolrServerLocation().toString());
//test the server
SolrPingResponse pingResponse = server.ping();
log.info(String.format("Successful ping for SolrServer %s ( %d ms) Details: %s",config.getSolrServerLocation(),pingResponse.getElapsedTime(),pingResponse));
//the fieldMapper need the Server to store it's namespace prefix configuration
this.fieldMapper = new SolrFieldMapper(server);
this.indexValueFactory = IndexValueFactory.getInstance();
- this.solrQueryFactoy = new SolrQueryFactory(valueFactory, indexValueFactory, fieldMapper);
- if(((SolrYardConfig)this.config).isMultiYardIndexLayout()){ // set the yardID as domain if multiYardLayout is activated
+ this.solrQueryFactoy = new SolrQueryFactory(getValueFactory(), indexValueFactory, fieldMapper);
+ if(config.isMultiYardIndexLayout()){ // set the yardID as domain if multiYardLayout is activated
solrQueryFactoy.setDomain(config.getId());
}
- solrQueryFactoy.setDefaultQueryResults(this.config.getDefaultQueryResultNumber());
- solrQueryFactoy.setMaxQueryResults(this.config.getMaxQueryResultNumber());
+ solrQueryFactoy.setDefaultQueryResults(config.getDefaultQueryResultNumber());
+ solrQueryFactoy.setMaxQueryResults(config.getMaxQueryResultNumber());
this.documentBoostFieldName = config.getDocumentBoostFieldName();
this.fieldBoostMap = config.getFieldBoosts();
}
@Deactivate
- protected void deactivate(ComponentContext context) {
+ protected final void deactivate(ComponentContext context) {
log.info("in "+SolrYard.class+" deactivate with context "+context);
+ SolrYardConfig config = (SolrYardConfig)getConfig();
try {
this.server.commit();
} catch (SolrServerException e) {
- log.error(String.format("Unable to commit unsaved changes to SolrServer %s during deactivate!",((SolrYardConfig)this.config).getSolrServerLocation()),e);
+ log.error(String.format("Unable to commit unsaved changes to SolrServer %s during deactivate!",config.getSolrServerLocation()),e);
} catch (IOException e) {
- log.error(String.format("Unable to commit unsaved changes to SolrServer %s during deactivate!",((SolrYardConfig)this.config).getSolrServerLocation()),e);
+ log.error(String.format("Unable to commit unsaved changes to SolrServer %s during deactivate!",config.getSolrServerLocation()),e);
}
this.server = null;
this.fieldMapper = null;
@@ -324,7 +327,7 @@ public class SolrYard extends AbstractYa
@Override
- public QueryResultList<Representation> find(final FieldQuery parsedQuery) throws YardException{
+ public final QueryResultList<Representation> find(final FieldQuery parsedQuery) throws YardException{
return find(parsedQuery,SELECT.QUERY);
}
private QueryResultList<Representation> find(final FieldQuery parsedQuery,SELECT select) throws YardException {
@@ -368,7 +371,7 @@ public class SolrYard extends AbstractYa
}
@Override
- public QueryResultList<String> findReferences(FieldQuery parsedQuery) throws YardException {
+ public final QueryResultList<String> findReferences(FieldQuery parsedQuery) throws YardException {
SolrQuery query = solrQueryFactoy.parseFieldQuery(parsedQuery,SELECT.ID);
QueryResponse respone;
try {
@@ -391,14 +394,14 @@ public class SolrYard extends AbstractYa
}
@Override
- public QueryResultList<Representation> findRepresentation(FieldQuery parsedQuery) throws YardException {
+ public final QueryResultList<Representation> findRepresentation(FieldQuery parsedQuery) throws YardException {
return find(parsedQuery,SELECT.ALL);
}
@Override
- public Representation getRepresentation(String id) throws YardException {
+ public final Representation getRepresentation(String id) throws YardException {
if(id == null){
- throw new NullPointerException("The parsed Representation id MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Representation id MUST NOT be NULL!");
}
if(id.isEmpty()){
throw new IllegalArgumentException("The parsed Representation id MUST NOT be empty!");
@@ -432,14 +435,14 @@ public class SolrYard extends AbstractYa
* @param fields if NOT NULL only this fields are added to the Representation
* @return the Representation
*/
- protected Representation createRepresentation(SolrDocument doc, Set<String> fields) {
+ protected final Representation createRepresentation(SolrDocument doc, Set<String> fields) {
Object id = doc.getFirstValue(fieldMapper.getDocumentIdField());
if(id == null){
throw new IllegalStateException(
String.format("The parsed Solr Document does not contain a value for the %s Field!",
fieldMapper.getDocumentIdField()));
}
- Representation rep = valueFactory.createRepresentation(id.toString());
+ Representation rep = getValueFactory().createRepresentation(id.toString());
for(String fieldName : doc.getFieldNames()){
// log.debug(String.format(" > process SolrDocument.field: %s",fieldName));
IndexField indexField = fieldMapper.getField(fieldName);
@@ -480,9 +483,9 @@ public class SolrYard extends AbstractYa
@Override
- public boolean isRepresentation(String id) throws YardException {
+ public final boolean isRepresentation(String id) throws YardException {
if(id == null){
- throw new NullPointerException("The parsed Representation id MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Representation id MUST NOT be NULL!");
}
if(id.isEmpty()){
throw new IllegalArgumentException("The parsed Representation id MUST NOT be empty!");
@@ -503,7 +506,7 @@ public class SolrYard extends AbstractYa
* @throws SolrServerException on any exception of the SolrServer
* @throws IOException an any IO exception while accessing the SolrServer
*/
- protected Set<String> checkRepresentations(Set<String> ids) throws SolrServerException, IOException{
+ protected final Set<String> checkRepresentations(Set<String> ids) throws SolrServerException, IOException{
Set<String> found = new HashSet<String>();
String field = fieldMapper.getDocumentIdField();
for(SolrDocument foundDoc : getSolrDocuments(ids,Arrays.asList(field))){
@@ -516,9 +519,9 @@ public class SolrYard extends AbstractYa
}
@Override
- public void remove(String id) throws YardException, IllegalArgumentException {
+ public final void remove(String id) throws YardException, IllegalArgumentException {
if(id == null){
- throw new NullPointerException("The parsed Representation id MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Representation id MUST NOT be NULL!");
}
if(id.isEmpty()){
throw new IllegalArgumentException("The parsed Representation id MUST NOT be empty!");
@@ -537,9 +540,9 @@ public class SolrYard extends AbstractYa
// the entity still exists and might be referenced by others!
}
@Override
- public void remove(Iterable<String> ids) throws IllegalArgumentException, YardException {
+ public final void remove(Iterable<String> ids) throws IllegalArgumentException, YardException {
if(ids == null){
- throw new NullPointerException("The parsed IDs MUST NOT be NULL");
+ throw new IllegalArgumentException("The parsed IDs MUST NOT be NULL");
}
List<String> toRemove = new ArrayList<String>();
for(String id :ids){
@@ -561,10 +564,10 @@ public class SolrYard extends AbstractYa
// the entity still exists and might be referenced by others!
}
@Override
- public Representation store(Representation representation) throws YardException,IllegalArgumentException {
+ public final Representation store(Representation representation) throws YardException,IllegalArgumentException {
log.debug(String.format("Store %s",representation!= null?representation.getId():null));
if(representation == null){
- throw new NullPointerException("The parsed Representation MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Representation MUST NOT be NULL!");
}
long start = System.currentTimeMillis();
SolrInputDocument inputDocument = createSolrInputDocument(representation);
@@ -583,9 +586,9 @@ public class SolrYard extends AbstractYa
return representation;
}
@Override
- public Iterable<Representation> store(Iterable<Representation> representations) throws IllegalArgumentException, YardException {
+ public final Iterable<Representation> store(Iterable<Representation> representations) throws IllegalArgumentException, YardException {
if(representations == null){
- throw new NullPointerException("The parsed Representations MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Representations MUST NOT be NULL!");
}
Collection<Representation> added = new HashSet<Representation>();
long start = System.currentTimeMillis();
@@ -615,11 +618,12 @@ public class SolrYard extends AbstractYa
* @param representation
* @return
*/
- protected SolrInputDocument createSolrInputDocument(Representation representation) {
+ protected final SolrInputDocument createSolrInputDocument(Representation representation) {
+ SolrYardConfig config = (SolrYardConfig)getConfig();
SolrInputDocument inputDocument = new SolrInputDocument();
// If multiYardLayout is active, than we need to add the YardId as
// domain for all added documents!
- if(((SolrYardConfig)this.config).isMultiYardIndexLayout()){
+ if(config.isMultiYardIndexLayout()){
inputDocument.addField(fieldMapper.getDocumentDomainField(), config.getId());
} // else we need to do nothing
inputDocument.addField(fieldMapper.getDocumentIdField(), representation.getId());
@@ -675,9 +679,9 @@ public class SolrYard extends AbstractYa
}
@Override
- public Representation update(Representation representation) throws IllegalArgumentException, NullPointerException, YardException {
+ public final Representation update(Representation representation) throws IllegalArgumentException, NullPointerException, YardException {
if(representation == null){
- throw new NullPointerException("The parsed Representation MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Representation MUST NOT be NULL!");
}
boolean found = isRepresentation(representation.getId());
if(found) {
@@ -687,9 +691,9 @@ public class SolrYard extends AbstractYa
}
}
@Override
- public Iterable<Representation> update(Iterable<Representation> representations) throws YardException, IllegalArgumentException, NullPointerException {
+ public final Iterable<Representation> update(Iterable<Representation> representations) throws YardException, IllegalArgumentException, NullPointerException {
if(representations == null){
- throw new NullPointerException("The parsed Iterable over Representations MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Iterable over Representations MUST NOT be NULL!");
}
long start = System.currentTimeMillis();
Set<String> ids = new HashSet<String>();
@@ -738,7 +742,7 @@ public class SolrYard extends AbstractYa
* the index
* @param inputDoc the document to store
*/
- protected void storeSolrDocument(SolrInputDocument inputDoc) throws SolrServerException, IOException{
+ protected final void storeSolrDocument(SolrInputDocument inputDoc) throws SolrServerException, IOException{
server.add(inputDoc);
}
/**
@@ -747,10 +751,11 @@ public class SolrYard extends AbstractYa
* the index
* @param inputDoc the document to store
*/
- public SolrDocument getSolrDocument(String uri) throws SolrServerException, IOException {
+ public final SolrDocument getSolrDocument(String uri) throws SolrServerException, IOException {
return getSolrDocument(uri, null);
}
- protected Collection<SolrDocument> getSolrDocuments(Collection<String> uris,Collection<String> fields) throws SolrServerException, IOException {
+ protected final Collection<SolrDocument> getSolrDocuments(Collection<String> uris,Collection<String> fields) throws SolrServerException, IOException {
+ SolrYardConfig config = (SolrYardConfig)getConfig();
SolrQuery solrQuery = new SolrQuery();
if(fields == null || fields.isEmpty()){
solrQuery.addField("*"); //select all fields
@@ -765,7 +770,7 @@ public class SolrYard extends AbstractYa
// clauses in one query, than we need to send several requests!
Iterator<String> uriIterator = uris.iterator();
int maxClauses;
- Integer configuredMaxClauses = ((SolrYardConfig)config).getMaxBooleanClauses();
+ Integer configuredMaxClauses = config.getMaxBooleanClauses();
if(configuredMaxClauses != null && configuredMaxClauses > 0){
maxClauses = configuredMaxClauses;
} else {
@@ -802,7 +807,7 @@ public class SolrYard extends AbstractYa
if(resultDocs == null){
resultDocs = queryResponse.getResults();
} else {
- if(myList == false){
+ if(!myList){
//most of the time there will be only one request, so only
//create my own list when the second response is processed
resultDocs = new ArrayList<SolrDocument>(resultDocs);
@@ -813,7 +818,7 @@ public class SolrYard extends AbstractYa
} //end while more uris
return resultDocs;
}
- protected SolrDocument getSolrDocument(String uri,Collection<String> fields) throws SolrServerException, IOException {
+ protected final SolrDocument getSolrDocument(String uri,Collection<String> fields) throws SolrServerException, IOException {
SolrQuery solrQuery = new SolrQuery();
if(fields == null || fields.isEmpty()){
solrQuery.addField("*"); //select all fields
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/queryencoders/DataTypeEncoder.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/queryencoders/DataTypeEncoder.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/queryencoders/DataTypeEncoder.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/queryencoders/DataTypeEncoder.java Wed Mar 16 18:43:57 2011
@@ -40,8 +40,8 @@ public class DataTypeEncoder implements
private static final ConstraintTypePosition PREFIX = new ConstraintTypePosition(PositionType.prefix);
private static final ConstraintTypePosition SUFFIX = new ConstraintTypePosition(PositionType.suffux);
- protected final FieldMapper fieldMapper;
- protected final IndexValueFactory indexValueFactory;
+ private final FieldMapper fieldMapper;
+ private final IndexValueFactory indexValueFactory;
public DataTypeEncoder(IndexValueFactory indexValueFactory, FieldMapper fieldMapper) {
if(fieldMapper == null){
throw new IllegalArgumentException("The FieldMapper MUST NOT be NULL!");
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/queryencoders/LangEncoder.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/queryencoders/LangEncoder.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/queryencoders/LangEncoder.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/queryencoders/LangEncoder.java Wed Mar 16 18:43:57 2011
@@ -19,9 +19,7 @@ package org.apache.stanbol.entityhub.yar
import java.util.Arrays;
import java.util.Collection;
-import org.apache.stanbol.entityhub.servicesapi.defaults.NamespaceEnum;
import org.apache.stanbol.entityhub.yard.solr.model.FieldMapper;
-import org.apache.stanbol.entityhub.yard.solr.model.IndexDataType;
import org.apache.stanbol.entityhub.yard.solr.query.ConstraintTypePosition;
import org.apache.stanbol.entityhub.yard.solr.query.EncodedConstraintParts;
import org.apache.stanbol.entityhub.yard.solr.query.IndexConstraintTypeEncoder;
@@ -33,7 +31,7 @@ import org.apache.stanbol.entityhub.yard
public class LangEncoder implements IndexConstraintTypeEncoder<Collection<String>> {
private static final ConstraintTypePosition PREFIX = new ConstraintTypePosition(PositionType.prefix);
- private static final ConstraintTypePosition SUFFIX = new ConstraintTypePosition(PositionType.suffux);
+// private static final ConstraintTypePosition SUFFIX = new ConstraintTypePosition(PositionType.suffux);
//deactivated, because xsd:string values are now also included in the language
//merger field (the name returned by fieldMapper.getLanguageMergerField(null)).
//private static final IndexDataType STRING_DATATYPE = new IndexDataType(NamespaceEnum.xsd+"string");
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/FieldMapper.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/FieldMapper.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/FieldMapper.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/FieldMapper.java Wed Mar 16 18:43:57 2011
@@ -35,7 +35,7 @@ import java.util.List;
* while indexing data.<p>
* The three encode** methods are used to encode query constraints.<p>
* Implementations are encouraged to cache mappings, because typically there will
- * be manny request with similar parameters.
+ * be many request with similar parameters.
* @author Rupert Westenthaler.
*/
public interface FieldMapper {
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexDataType.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexDataType.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexDataType.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexDataType.java Wed Mar 16 18:43:57 2011
@@ -64,19 +64,21 @@ public final class IndexDataType {
public IndexDataType(String id,String name) {
this.id = id;
if(name == null){
- if(id.lastIndexOf("#")>=0){
- name = id.substring(id.lastIndexOf("#")+1);
- } else if(id.lastIndexOf("/")>=0){
- name = id.substring(id.lastIndexOf("/")+1);
- } else if(id.lastIndexOf(":")>=0){
- name = id.substring(id.lastIndexOf(":")+1);
+ String defaultName;
+ if(id.lastIndexOf('#')>=0){
+ defaultName = id.substring(id.lastIndexOf('#')+1);
+ } else if(id.lastIndexOf('/')>=0){
+ defaultName = id.substring(id.lastIndexOf('/')+1);
+ } else if(id.lastIndexOf(':')>=0){
+ defaultName = id.substring(id.lastIndexOf(':')+1);
} else {
- name = id;
+ defaultName = id;
}
//convert first char to lower case
- name = name.substring(0,1).toLowerCase()+name.substring(1);
+ this.name = defaultName.substring(0,1).toLowerCase()+defaultName.substring(1);
+ } else {
+ this.name = name;
}
- this.name = name;
}
/**
* Getter for the prefix
@@ -99,7 +101,7 @@ public final class IndexDataType {
}
@Override
public boolean equals(Object obj) {
- return obj != null && obj instanceof IndexDataType && ((IndexDataType)obj).id.equals(id);
+ return obj instanceof IndexDataType && ((IndexDataType)obj).id.equals(id);
}
/**
* Returns the id of the dataType. Use {@link #getName()} if you need a
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexField.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexField.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexField.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexField.java Wed Mar 16 18:43:57 2011
@@ -44,7 +44,7 @@ public class IndexField {
private final List<String> path;
private final IndexDataType indexType;
private final Set<String> languages;
- private final int _hash;
+ private final int hash;
/**
* Constructs a new IndexField
* @param path
@@ -76,7 +76,7 @@ public class IndexField {
this.languages = Collections.unmodifiableSet(languageSet);
}
//calculate the hash of is immutable class only once
- _hash = this.path.hashCode()+this.indexType.hashCode()+this.languages.hashCode();
+ hash = this.path.hashCode()+this.indexType.hashCode()+this.languages.hashCode();
}
/**
* Checks if the path is not <code>null</code>, empty and does not contain
@@ -127,14 +127,14 @@ public class IndexField {
}
@Override
public boolean equals(Object obj) {
- return obj != null && obj instanceof IndexField &&
+ return obj instanceof IndexField &&
((IndexField)obj).path.equals(path) &&
((IndexField)obj).indexType.equals(indexType) &&
((IndexField)obj).languages.equals(languages);
}
@Override
public int hashCode() {
- return _hash;
+ return hash;
}
@Override
public String toString() {
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexValue.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexValue.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexValue.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexValue.java Wed Mar 16 18:43:57 2011
@@ -25,7 +25,7 @@ public final class IndexValue {
/**
* Calculate the hash only once
*/
- private final int _hash;
+ private final int hash;
public IndexValue(String value,IndexDataType type){
this(value,type,null,false);
@@ -49,7 +49,7 @@ public final class IndexValue {
} else {
this.language = null;
}
- this._hash= type.hashCode()+value.hashCode()+(language!=null?language.hashCode():0);
+ this.hash = type.hashCode()+value.hashCode()+(language!=null?language.hashCode():0);
}
public final String getValue(){
return value;
@@ -65,12 +65,11 @@ public final class IndexValue {
}
@Override
public int hashCode() {
- return _hash;
+ return hash;
}
@Override
public boolean equals(Object obj) {
- return obj != null &&
- obj instanceof IndexValue &&
+ return obj instanceof IndexValue &&
((IndexValue)obj).value.equals(value) &&
((IndexValue)obj).type.equals(type) &&
((IndexValue)obj).hasLanguage == hasLanguage && (
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexValueFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexValueFactory.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexValueFactory.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/model/IndexValueFactory.java Wed Mar 16 18:43:57 2011
@@ -115,11 +115,11 @@ public class IndexValueFactory {
//NOTE: To ensure thread save iterations over Entries of this Map
//create new map instance, add to the new instance and replace reference
// ... i know this is slow, but such calls are very uncommon
- Map<Class<?>,TypeConverter<?>> javaInterfaceConverters =
+ Map<Class<?>,TypeConverter<?>> javaInterfaceConverterMap =
new HashMap<Class<?>,TypeConverter<?>>(this.javaInterfaceConverters);
- javaInterfaceConverters.put(javaType,converter);
+ javaInterfaceConverterMap.put(javaType,converter);
//TODO: add support for IndexTypeConverter
- this.javaInterfaceConverters = javaInterfaceConverters;
+ this.javaInterfaceConverters = javaInterfaceConverterMap;
} else {
//there are no Iterations over this Map!
javaClassConverters.put(javaType,converter);
@@ -139,10 +139,10 @@ public class IndexValueFactory {
if(javaInterfaceConverters.containsKey(type)){
//create new map instance, remove to the converter and replace reference
// ... i know this is slow, but such calls are very uncommon
- Map<Class<?>,TypeConverter<?>> javaInterfaceConverters =
+ Map<Class<?>,TypeConverter<?>> javaInterfaceConverterMap =
new HashMap<Class<?>,TypeConverter<?>>(this.javaInterfaceConverters);
- converter = (TypeConverter<T>)javaInterfaceConverters.remove(type);
- this.javaInterfaceConverters = javaInterfaceConverters;
+ converter = (TypeConverter<T>)javaInterfaceConverterMap.remove(type);
+ this.javaInterfaceConverters = javaInterfaceConverterMap;
} else {
converter = null;
}
@@ -271,7 +271,7 @@ public class IndexValueFactory {
@Override
public Date createObject(IndexDataType type, Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException {
if(type == null){
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(!type.equals(INDEX_TYPE)) {
throw new UnsupportedIndexTypeException(this,type);
@@ -333,7 +333,7 @@ public class IndexValueFactory {
@Override
public Boolean createObject(IndexDataType type, Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException {
if(type == null){
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(!type.equals(INDEX_TYPE)){
throw new UnsupportedIndexTypeException(this,type);
@@ -394,7 +394,7 @@ public class IndexValueFactory {
@Override
public String createObject(IndexDataType type, Object value, String lang) throws NullPointerException {
if(type == null){
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
return value!=null?value.toString():null;
}
@@ -442,7 +442,7 @@ public class IndexValueFactory {
@Override
public Integer createObject(IndexDataType type, Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException, NullPointerException {
if(type == null){
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(type.equals(INDEX_TYPE)){
if(value == null){ //move in here to ensure returning UnsupportedIndexTypeException on wrong types
@@ -452,7 +452,7 @@ public class IndexValueFactory {
return (Integer)value;
} else {
try {
- return new Integer(value.toString());
+ return Integer.valueOf(value.toString());
} catch (NumberFormatException e) {
throw new UnsupportedValueException(this, type, value, e);
}
@@ -516,7 +516,7 @@ public class IndexValueFactory {
@Override
public Long createObject(IndexDataType type, Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException,NullPointerException {
if(type == null){
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(type.equals(LONG_TYPE) || type.equals(INT_TYPE)){
if(value == null){
@@ -542,7 +542,7 @@ public class IndexValueFactory {
public static class DoubleConverter implements TypeConverter<Double> {
public static final IndexDataType INDEX_TYPE = IndexDataTypeEnum.DOUBLE.getIndexType();
- private static Set<IndexDataType> SUPPORTED = new HashSet<IndexDataType>(
+ private static final Set<IndexDataType> SUPPORTED = new HashSet<IndexDataType>(
Arrays.asList(
IndexDataTypeEnum.FLOAT.getIndexType(),
IndexDataTypeEnum.INT.getIndexType(),
@@ -576,7 +576,7 @@ public class IndexValueFactory {
@Override
public Double createObject(IndexDataType type, Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException, NullPointerException {
if(type == null){
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(SUPPORTED.contains(type)){
if(value == null){
@@ -616,7 +616,7 @@ public class IndexValueFactory {
public boolean isAcceptDoubleAndLongIndexTypes(){
return supported.containsAll(DOUBLE_LONG_TYPES);
}
- public void setAcceptDoubleAndLongIndexTypes(boolean state){
+ public final void setAcceptDoubleAndLongIndexTypes(boolean state){
if(state){
supported.addAll(DOUBLE_LONG_TYPES);
} else {
@@ -649,7 +649,7 @@ public class IndexValueFactory {
@Override
public Float createObject(IndexDataType type, Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException, NullPointerException {
if(type == null) {
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(supported.contains(type)){
if(value == null){
@@ -703,7 +703,7 @@ public class IndexValueFactory {
@Override
public BigInteger createObject(IndexDataType type, Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException, NullPointerException {
if(type == null){
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(type.equals(INDEX_TYPE) || type.equals(INT_TYPE)){
if(value == null){
@@ -722,7 +722,7 @@ public class IndexValueFactory {
public static class BigDecimalConverter implements TypeConverter<BigDecimal> {
public static final IndexDataType INDEX_TYPE = IndexDataTypeEnum.DOUBLE.getIndexType();
- private static Set<IndexDataType> SUPPORTED = new HashSet<IndexDataType>(
+ private static final Set<IndexDataType> SUPPORTED = new HashSet<IndexDataType>(
Arrays.asList(
IndexDataTypeEnum.FLOAT.getIndexType(),
IndexDataTypeEnum.INT.getIndexType(),
@@ -744,7 +744,7 @@ public class IndexValueFactory {
@Override
public BigDecimal createObject(IndexDataType type,Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException, NullPointerException {
if(type == null){
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(SUPPORTED.contains(type)){
if(value == null){
@@ -773,7 +773,7 @@ public class IndexValueFactory {
public static final IndexDataType INDEX_TYPE = IndexDataTypeEnum.TXT.getIndexType();
private static final IndexDataType STRING_TYPE = IndexDataTypeEnum.STR.getIndexType();
- protected final ValueFactory valueFactory;
+ private final ValueFactory valueFactory;
public TextConverter(ValueFactory valueFactory) {
if(valueFactory == null){
throw new IllegalArgumentException("Parameter ValueFactory MUST NOT be NULL!");
@@ -805,7 +805,7 @@ public class IndexValueFactory {
@Override
public Text createObject(IndexDataType type, Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException, NullPointerException {
if(type == null){
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(type.equals(INDEX_TYPE) || type.equals(STRING_TYPE)){
if(value == null){
@@ -819,7 +819,7 @@ public class IndexValueFactory {
}
public static class ReferenceConverter implements TypeConverter<Reference> {
public static final IndexDataType INDEX_TYPE = IndexDataTypeEnum.REF.getIndexType();
- protected final ValueFactory valueFactory;
+ private final ValueFactory valueFactory;
public ReferenceConverter(ValueFactory valueFactory) {
if(valueFactory == null){
throw new IllegalArgumentException("Parameter ValueFactory MUST NOT be NULL!");
@@ -851,7 +851,7 @@ public class IndexValueFactory {
@Override
public Reference createObject(IndexDataType type, Object value, String lang) throws UnsupportedIndexTypeException, UnsupportedValueException, NullPointerException {
if(type == null) {
- throw new NullPointerException("The parsed IndexDataType MUST NOT be null");
+ throw new IllegalArgumentException("The parsed IndexDataType MUST NOT be null");
}
if(type.equals(INDEX_TYPE)){
if(value == null){
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/provider/SolrServerProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/provider/SolrServerProvider.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/provider/SolrServerProvider.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/provider/SolrServerProvider.java Wed Mar 16 18:43:57 2011
@@ -77,10 +77,10 @@ public interface SolrServerProvider {
* ignored if the requested type does not support the usage of multiple
* servers.
* @return the configured SolrServer client for the parsed parameter
- * @throws NullPointerException if <code>null</code> is parsed as uriOrPath.
- * @throws IllegalArgumentException if the parsed URI or path is not valid
- * for the requested {@link Type} or the parsed type is not supported by
- * this provider
+ * @throws NullPointerException
+ * @throws IllegalArgumentException if <code>null</code> is parsed as uriOrPath
+ * or if the parsed URI or path is not valid for the requested {@link Type}
+ * or the parsed type is not supported by this provider
*/
- SolrServer getSolrServer(Type type,String uriOrPath,String...additional) throws NullPointerException,IllegalArgumentException;
+ SolrServer getSolrServer(Type type,String uriOrPath,String...additional) throws IllegalArgumentException;
}
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/provider/SolrServerProviderManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/provider/SolrServerProviderManager.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/provider/SolrServerProviderManager.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/provider/SolrServerProviderManager.java Wed Mar 16 18:43:57 2011
@@ -64,7 +64,7 @@ public final class SolrServerProviderMan
policy=ReferencePolicy.DYNAMIC,
cardinality=ReferenceCardinality.MANDATORY_MULTIPLE,
bind="addSolrProvider",unbind="removeSolrProvider")
- protected Map<Type,List<SolrServerProvider>> solrServerProviders = Collections.synchronizedMap(new EnumMap<Type,List<SolrServerProvider>>(Type.class));
+ private Map<Type,List<SolrServerProvider>> solrServerProviders = Collections.synchronizedMap(new EnumMap<Type,List<SolrServerProvider>>(Type.class));
public static SolrServerProviderManager getInstance(){
if(solrServerProviderManager == null){
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/query/ConstraintTypePosition.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/query/ConstraintTypePosition.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/query/ConstraintTypePosition.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/query/ConstraintTypePosition.java Wed Mar 16 18:43:57 2011
@@ -71,7 +71,7 @@ public class ConstraintTypePosition impl
}
@Override
public boolean equals(Object obj) {
- return obj != null && obj instanceof ConstraintTypePosition
+ return obj instanceof ConstraintTypePosition
&& ((ConstraintTypePosition)obj).type == type && ((ConstraintTypePosition)obj).pos == pos;
}
@Override
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/query/EncodedConstraintParts.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/query/EncodedConstraintParts.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/query/EncodedConstraintParts.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/query/EncodedConstraintParts.java Wed Mar 16 18:43:57 2011
@@ -87,6 +87,6 @@ public class EncodedConstraintParts impl
}
@Override
public boolean equals(Object obj) {
- return obj != null && obj instanceof EncodedConstraintParts && ((EncodedConstraintParts)obj).constraintMap.equals(constraintMap);
+ return obj instanceof EncodedConstraintParts && ((EncodedConstraintParts)obj).constraintMap.equals(constraintMap);
}
}
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/utils/ConfigUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/utils/ConfigUtils.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/utils/ConfigUtils.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/utils/ConfigUtils.java Wed Mar 16 18:43:57 2011
@@ -19,14 +19,10 @@ package org.apache.stanbol.entityhub.yar
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import java.util.Arrays;
import java.util.Enumeration;
import org.apache.commons.io.FileUtils;
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
-import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.stanbol.entityhub.yard.solr.embedded.EmbeddedSolrPorovider;
import org.osgi.framework.Bundle;
import org.slf4j.Logger;
@@ -42,7 +38,8 @@ import org.slf4j.LoggerFactory;
* @author Rupert Westenthaler
*
*/
-public class ConfigUtils {
+public final class ConfigUtils {
+ private ConfigUtils(){}
/**
* The logger
*/
@@ -75,10 +72,10 @@ public class ConfigUtils {
@SuppressWarnings("unchecked") //Enumeration<URL> required by OSGI specification
public static File copyDefaultConfig(Bundle bundle, File rootDir,boolean override) throws IOException, NullPointerException, IllegalStateException, IllegalArgumentException {
if(bundle == null){
- throw new NullPointerException("The parsed Bundle MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Bundle MUST NOT be NULL!");
}
if(rootDir == null){
- throw new NullPointerException("The parsed root directory MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed root directory MUST NOT be NULL!");
}
if(rootDir.exists() && !rootDir.isDirectory()){
throw new IllegalStateException("The parsed root directory "+rootDir.getAbsolutePath()+" extists but is not a directory!");
@@ -156,10 +153,10 @@ public class ConfigUtils {
@SuppressWarnings("unchecked") //Enumeration<URL> required by OSGI specification
public static void copyCore(Bundle bundle, File coreDir, String coreName, boolean override) throws IOException,NullPointerException,IllegalStateException,IllegalArgumentException{
if(bundle == null){
- throw new NullPointerException("The parsed Bundle MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed Bundle MUST NOT be NULL!");
}
if(coreDir == null){
- throw new NullPointerException("The parsed core directory MUST NOT be NULL!");
+ throw new IllegalArgumentException("The parsed core directory MUST NOT be NULL!");
}
if(coreDir.exists() && !coreDir.isDirectory()){
throw new IllegalStateException("The parsed core directory "+coreDir.getAbsolutePath()+" extists but is not a directory!");
Modified: incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/utils/SolrUtil.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/utils/SolrUtil.java?rev=1082257&r1=1082256&r2=1082257&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/utils/SolrUtil.java (original)
+++ incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/utils/SolrUtil.java Wed Mar 16 18:43:57 2011
@@ -19,8 +19,8 @@ package org.apache.stanbol.entityhub.yar
import java.util.regex.Pattern;
-public class SolrUtil {
-
+public final class SolrUtil {
+ private SolrUtil(){}
private static final String LUCENE_ESCAPE_CHARS = "[\\\\+\\-\\!\\(\\)\\:\\^\\[\\]\\{\\}\\~\\*\\?]";
private static final Pattern LUCENE_PATTERN = Pattern.compile(LUCENE_ESCAPE_CHARS);