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 */ 018package org.apache.hadoop.hdfs.web.resources; 019 020import java.net.HttpURLConnection; 021 022/** Http GET operation parameter. */ 023public class GetOpParam extends HttpOpParam<GetOpParam.Op> { 024 /** Get operations. */ 025 public enum Op implements HttpOpParam.Op { 026 OPEN(true, HttpURLConnection.HTTP_OK), 027 028 GETFILESTATUS(false, HttpURLConnection.HTTP_OK), 029 LISTSTATUS(false, HttpURLConnection.HTTP_OK), 030 GETCONTENTSUMMARY(false, HttpURLConnection.HTTP_OK), 031 GETFILECHECKSUM(true, HttpURLConnection.HTTP_OK), 032 033 GETHOMEDIRECTORY(false, HttpURLConnection.HTTP_OK), 034 GETDELEGATIONTOKEN(false, HttpURLConnection.HTTP_OK, true), 035 036 /** GET_BLOCK_LOCATIONS is a private unstable op. */ 037 GET_BLOCK_LOCATIONS(false, HttpURLConnection.HTTP_OK), 038 GETACLSTATUS(false, HttpURLConnection.HTTP_OK), 039 GETXATTRS(false, HttpURLConnection.HTTP_OK), 040 LISTXATTRS(false, HttpURLConnection.HTTP_OK), 041 042 GETALLSTORAGEPOLICY(false, HttpURLConnection.HTTP_OK), 043 GETSTORAGEPOLICY(false, HttpURLConnection.HTTP_OK), 044 045 NULL(false, HttpURLConnection.HTTP_NOT_IMPLEMENTED), 046 047 CHECKACCESS(false, HttpURLConnection.HTTP_OK); 048 049 final boolean redirect; 050 final int expectedHttpResponseCode; 051 final boolean requireAuth; 052 053 Op(final boolean redirect, final int expectedHttpResponseCode) { 054 this(redirect, expectedHttpResponseCode, false); 055 } 056 057 Op(final boolean redirect, final int expectedHttpResponseCode, 058 final boolean requireAuth) { 059 this.redirect = redirect; 060 this.expectedHttpResponseCode = expectedHttpResponseCode; 061 this.requireAuth = requireAuth; 062 } 063 064 @Override 065 public HttpOpParam.Type getType() { 066 return HttpOpParam.Type.GET; 067 } 068 069 @Override 070 public boolean getRequireAuth() { 071 return requireAuth; 072 } 073 074 @Override 075 public boolean getDoOutput() { 076 return false; 077 } 078 079 @Override 080 public boolean getRedirect() { 081 return redirect; 082 } 083 084 @Override 085 public int getExpectedHttpResponseCode() { 086 return expectedHttpResponseCode; 087 } 088 089 @Override 090 public String toQueryString() { 091 return NAME + "=" + this; 092 } 093 } 094 095 private static final Domain<Op> DOMAIN = new Domain<>(NAME, Op.class); 096 097 /** 098 * Constructor. 099 * @param str a string representation of the parameter value. 100 */ 101 public GetOpParam(final String str) { 102 super(DOMAIN, DOMAIN.parse(str)); 103 } 104 105 @Override 106 public String getName() { 107 return NAME; 108 } 109}