Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-2642 Throw exceptions when trying to use blacklists in TypeTo…
…kenFilterFactory-based analyzer defs with Elasticsearch Elasticsearch only supports whitelists.
- Loading branch information
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...asticsearch/settings/impl/translation/ThrowingMandatoryStrippedParametersTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.settings.impl.translation; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import org.hibernate.search.elasticsearch.logging.impl.Log; | ||
import org.hibernate.search.util.logging.impl.LoggerFactory; | ||
|
||
import com.google.gson.JsonElement; | ||
|
||
class ThrowingMandatoryStrippedParametersTransformer implements ParametersTransformer { | ||
|
||
private static final Log log = LoggerFactory.make( Log.class ); | ||
|
||
private final Class<?> factoryClass; | ||
private final String parameterName; | ||
private final String expectedValue; | ||
|
||
ThrowingMandatoryStrippedParametersTransformer(Class<?> factoryClass, String parameterName, String expectedValue) { | ||
this.factoryClass = factoryClass; | ||
this.parameterName = parameterName; | ||
this.expectedValue = expectedValue; | ||
} | ||
|
||
@Override | ||
public Map<String, JsonElement> transform(Map<String, String> luceneParameters) { | ||
String actualValue = luceneParameters.remove( parameterName ); | ||
|
||
if ( !expectedValue.equals( actualValue ) ) { | ||
throw log.invalidAnalysisFactoryParameter( factoryClass, parameterName, expectedValue, actualValue ); | ||
} | ||
|
||
return Collections.emptyMap(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringBuilder( getClass().getSimpleName() ) | ||
.append( "[" ) | ||
.append( factoryClass ) | ||
.append( "," ) | ||
.append( parameterName ) | ||
.append( "," ) | ||
.append( expectedValue ) | ||
.append( "]" ) | ||
.toString(); | ||
} | ||
} |