Revert "HBASE-26523 Upgrade hbase-thirdparty dependency to 4.0.0 (#3910)"
[hbase.git] / hbase-rest / src / main / java / org / apache / hadoop / hbase / rest / ExistsResource.java
blobaacfc9fcfddd86396b60a82cc241f390136d2ec4
1 /*
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 package org.apache.hadoop.hbase.rest;
22 import java.io.IOException;
24 import javax.ws.rs.GET;
25 import javax.ws.rs.Produces;
26 import javax.ws.rs.core.CacheControl;
27 import javax.ws.rs.core.Context;
28 import javax.ws.rs.core.Response;
29 import javax.ws.rs.core.UriInfo;
30 import javax.ws.rs.core.Response.ResponseBuilder;
32 import org.apache.yetus.audience.InterfaceAudience;
34 @InterfaceAudience.Private
35 public class ExistsResource extends ResourceBase {
37 static CacheControl cacheControl;
38 static {
39 cacheControl = new CacheControl();
40 cacheControl.setNoCache(true);
41 cacheControl.setNoTransform(false);
44 TableResource tableResource;
46 /**
47 * Constructor
48 * @param tableResource
49 * @throws IOException
51 public ExistsResource(TableResource tableResource) throws IOException {
52 super();
53 this.tableResource = tableResource;
56 @GET
57 @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
58 MIMETYPE_PROTOBUF_IETF, MIMETYPE_BINARY})
59 public Response get(final @Context UriInfo uriInfo) {
60 try {
61 if (!tableResource.exists()) {
62 return Response.status(Response.Status.NOT_FOUND)
63 .type(MIMETYPE_TEXT).entity("Not found" + CRLF)
64 .build();
66 } catch (IOException e) {
67 return Response.status(Response.Status.SERVICE_UNAVAILABLE)
68 .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
69 .build();
71 ResponseBuilder response = Response.ok();
72 response.cacheControl(cacheControl);
73 return response.build();