001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.hadoop.hdfs.web.resources; 019 020 import java.net.HttpURLConnection; 021 022 /** Http GET operation parameter. */ 023 public class GetOpParam extends HttpOpParam<GetOpParam.Op> { 024 /** Get operations. */ 025 public static enum Op implements HttpOpParam.Op { 026 OPEN(HttpURLConnection.HTTP_OK), 027 028 GETFILESTATUS(HttpURLConnection.HTTP_OK), 029 LISTSTATUS(HttpURLConnection.HTTP_OK), 030 GETCONTENTSUMMARY(HttpURLConnection.HTTP_OK), 031 GETFILECHECKSUM(HttpURLConnection.HTTP_OK), 032 033 GETHOMEDIRECTORY(HttpURLConnection.HTTP_OK), 034 GETDELEGATIONTOKEN(HttpURLConnection.HTTP_OK), 035 036 /** GET_BLOCK_LOCATIONS is a private unstable op. */ 037 GET_BLOCK_LOCATIONS(HttpURLConnection.HTTP_OK), 038 039 NULL(HttpURLConnection.HTTP_NOT_IMPLEMENTED); 040 041 final int expectedHttpResponseCode; 042 043 Op(final int expectedHttpResponseCode) { 044 this.expectedHttpResponseCode = expectedHttpResponseCode; 045 } 046 047 @Override 048 public HttpOpParam.Type getType() { 049 return HttpOpParam.Type.GET; 050 } 051 052 @Override 053 public boolean getDoOutput() { 054 return false; 055 } 056 057 @Override 058 public int getExpectedHttpResponseCode() { 059 return expectedHttpResponseCode; 060 } 061 062 @Override 063 public String toQueryString() { 064 return NAME + "=" + this; 065 } 066 } 067 068 private static final Domain<Op> DOMAIN = new Domain<Op>(NAME, Op.class); 069 070 /** 071 * Constructor. 072 * @param str a string representation of the parameter value. 073 */ 074 public GetOpParam(final String str) { 075 super(DOMAIN, DOMAIN.parse(str)); 076 } 077 078 @Override 079 public String getName() { 080 return NAME; 081 } 082 }