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 GETDELEGATIONTOKENS(HttpURLConnection.HTTP_OK), 036 037 /** GET_BLOCK_LOCATIONS is a private unstable op. */ 038 GET_BLOCK_LOCATIONS(HttpURLConnection.HTTP_OK), 039 040 NULL(HttpURLConnection.HTTP_NOT_IMPLEMENTED); 041 042 final int expectedHttpResponseCode; 043 044 Op(final int expectedHttpResponseCode) { 045 this.expectedHttpResponseCode = expectedHttpResponseCode; 046 } 047 048 @Override 049 public HttpOpParam.Type getType() { 050 return HttpOpParam.Type.GET; 051 } 052 053 @Override 054 public boolean getDoOutput() { 055 return false; 056 } 057 058 @Override 059 public int getExpectedHttpResponseCode() { 060 return expectedHttpResponseCode; 061 } 062 063 @Override 064 public String toQueryString() { 065 return NAME + "=" + this; 066 } 067 } 068 069 private static final Domain<Op> DOMAIN = new Domain<Op>(NAME, Op.class); 070 071 /** 072 * Constructor. 073 * @param str a string representation of the parameter value. 074 */ 075 public GetOpParam(final String str) { 076 super(DOMAIN, DOMAIN.parse(str)); 077 } 078 079 @Override 080 public String getName() { 081 return NAME; 082 } 083 }