@@ -65,7 +65,6 @@ public class MetastoreMessageHandler implements IMessageHandler {
6565
6666 public static final String RESOURCE_URL = "resolvingUrl" ;
6767 public static final String MAPPING_ID = "documentType" ;
68- private static final String MAPPING_URL_APPENDIX = "/api/v1/schemas/" ;
6968
7069 MetastoreMessageHandler (ApplicationProperties configuration , MappingService mappingService , IndexingService indexingService ) {
7170 properties = configuration ;
@@ -89,13 +88,8 @@ public RESULT handle(BasicMessage message) {
8988 return RESULT .REJECTED ;
9089 }
9190
92- int beginIndex = mappingId .indexOf ( MAPPING_URL_APPENDIX ) ;
91+ int beginIndex = mappingId .lastIndexOf ( "/" ) + 1 ;
9392 int endIndex = mappingId .indexOf ("?" , beginIndex );
94- if (beginIndex > 0 ) {
95- beginIndex += MAPPING_URL_APPENDIX .length ();
96- } else {
97- beginIndex = 0 ;
98- }
9993 if (endIndex < 0 ) {
10094 endIndex = mappingId .length ();
10195 }
@@ -126,7 +120,8 @@ public RESULT handle(BasicMessage message) {
126120 }
127121
128122 String jsonDocument = FileUtils .readFileToString (resultPath .toFile (), StandardCharsets .UTF_8 );
129- elasticsearchService .uploadToElastic (jsonDocument , index , properties .getElasticsearchType (), resourceUrlAsString );
123+ String resourceUrlAsStringWithoutVersion = removeFilterFromUri (resourceUrlAsString );
124+ elasticsearchService .uploadToElastic (jsonDocument , index , properties .getElasticsearchType (), resourceUrlAsStringWithoutVersion );
130125
131126 } catch (URISyntaxException ex ) {
132127 String errorMessage = String .format ("Error downloading content from '%s': %s" , resourceUrlAsString , ex .getMessage ());
@@ -148,4 +143,18 @@ public RESULT handle(BasicMessage message) {
148143 public boolean configure () {
149144 return true ;
150145 }
146+
147+ /**
148+ * Remove version and other stuff added to the URI.
149+ * @param uri URI of the object.
150+ * @return URI without additional parameter.
151+ */
152+ public String removeFilterFromUri (String uri ) {
153+ String strippedUri = null ;
154+ if (uri != null ) {
155+ strippedUri = uri .split ("\\ ?" , -1 )[0 ];
156+ }
157+ return strippedUri ;
158+ }
159+
151160}
0 commit comments