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
;
39 cacheControl
= new CacheControl();
40 cacheControl
.setNoCache(true);
41 cacheControl
.setNoTransform(false);
44 TableResource tableResource
;
48 * @param tableResource
51 public ExistsResource(TableResource tableResource
) throws IOException
{
53 this.tableResource
= tableResource
;
57 @Produces({MIMETYPE_TEXT
, MIMETYPE_XML
, MIMETYPE_JSON
, MIMETYPE_PROTOBUF
,
58 MIMETYPE_PROTOBUF_IETF
, MIMETYPE_BINARY
})
59 public Response
get(final @Context UriInfo uriInfo
) {
61 if (!tableResource
.exists()) {
62 return Response
.status(Response
.Status
.NOT_FOUND
)
63 .type(MIMETYPE_TEXT
).entity("Not found" + CRLF
)
66 } catch (IOException e
) {
67 return Response
.status(Response
.Status
.SERVICE_UNAVAILABLE
)
68 .type(MIMETYPE_TEXT
).entity("Unavailable" + CRLF
)
71 ResponseBuilder response
= Response
.ok();
72 response
.cacheControl(cacheControl
);
73 return response
.build();