Skip to content

Commit ffa80ff

Browse files
committed
nouveau welcome message for version negotiation
1 parent 6c3dbdc commit ffa80ff

4 files changed

Lines changed: 69 additions & 1 deletion

File tree

nouveau/src/main/java/org/apache/couchdb/nouveau/NouveauApplication.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.couchdb.nouveau.lucene.ParallelSearcherFactory;
2929
import org.apache.couchdb.nouveau.resources.AnalyzeResource;
3030
import org.apache.couchdb.nouveau.resources.IndexResource;
31+
import org.apache.couchdb.nouveau.resources.WelcomeResource;
3132
import org.apache.couchdb.nouveau.tasks.CloseAllIndexesTask;
3233

3334
public class NouveauApplication extends Application<NouveauApplicationConfiguration> {
@@ -67,6 +68,10 @@ public void run(NouveauApplicationConfiguration configuration, Environment envir
6768
// Serialization classes
6869
environment.getObjectMapper().registerModule(new LuceneModule());
6970

71+
// WelcomeResource
72+
final WelcomeResource welcomeResource = new WelcomeResource();
73+
environment.jersey().register(welcomeResource);
74+
7075
// AnalyzeResource
7176
final AnalyzeResource analyzeResource = new AnalyzeResource();
7277
environment.jersey().register(analyzeResource);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
package org.apache.couchdb.nouveau.api;
15+
16+
import com.fasterxml.jackson.annotation.JsonProperty;
17+
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
18+
import com.fasterxml.jackson.databind.annotation.JsonNaming;
19+
20+
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
21+
public final class WelcomeResponse {
22+
23+
public static final WelcomeResponse INSTANCE = new WelcomeResponse();
24+
25+
private final int[] supportedLuceneVersions =
26+
new int[] {IndexDefinition.LEGACY_LUCENE_VERSION, IndexDefinition.LATEST_LUCENE_VERSION};
27+
28+
private WelcomeResponse() {}
29+
30+
@JsonProperty
31+
public int[] getSupportedLuceneVersions() {
32+
return supportedLuceneVersions;
33+
}
34+
}

nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ public void create(final String name, IndexDefinition indexDefinition) throws IO
219219
assertSame(indexDefinition, loadIndexDefinition(name));
220220
return;
221221
}
222-
223222
final Lock lock = this.createLock.writeLock(name);
224223
lock.lock();
225224
try {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
package org.apache.couchdb.nouveau.resources;
15+
16+
import jakarta.ws.rs.GET;
17+
import jakarta.ws.rs.Path;
18+
import jakarta.ws.rs.Produces;
19+
import jakarta.ws.rs.core.MediaType;
20+
import org.apache.couchdb.nouveau.api.WelcomeResponse;
21+
22+
@Path("/")
23+
@Produces(MediaType.APPLICATION_JSON)
24+
public final class WelcomeResource {
25+
26+
@GET
27+
public WelcomeResponse welcome() {
28+
return WelcomeResponse.INSTANCE;
29+
}
30+
}

0 commit comments

Comments
 (0)