001/** 002 * Copyright 2014 Tampere University of Technology, Pori Department 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package core.tut.pori.http; 017 018 019/** 020 * Definitions for the http package. 021 * 022 * In addition to the internally used element definitions, 023 * this utility class also contains the common HTTP method names and encodings. 024 * 025 */ 026public final class Definitions { 027 028 /* elements */ 029 /** HTTP response element */ 030 protected static final String ELEMENT_MESSAGE = "message"; 031 /** HTTP response element */ 032 protected static final String ELEMENT_RESPONSE = "response"; 033 /** HTTP response element */ 034 protected static final String ELEMENT_STATUS = "status"; 035 036 /* attributes */ 037 /** HTTP response element response attribute */ 038 protected static final String ATTRIBUTE_METHOD = "method"; 039 /** HTTP response element response attribute */ 040 protected static final String ATTRIBUTE_SERVICE = "service"; 041 042 /* json objects */ 043 /** HTTP response object */ 044 protected static final String JSON_METHOD = "method"; 045 /** HTTP response object */ 046 protected static final String JSON_MESSAGE = "message"; 047 /** HTTP response object */ 048 protected static final String JSON_SERVICE = "service"; 049 /** HTTP response object */ 050 protected static final String JSON_STATUS = "status"; 051 052 /* HTTP Methods */ 053 /** HTTP method GET */ 054 public static final String METHOD_GET = "GET"; 055 /** HTTP method DELETE */ 056 public static final String METHOD_DELETE = "DELETE"; 057 /** HTTP method PATCH */ 058 public static final String METHOD_PATCH = "PATCH"; 059 /** HTTP method POST */ 060 public static final String METHOD_POST = "POST"; 061 /** HTTP method PUT */ 062 public static final String METHOD_PUT = "PUT"; 063 064 /* headers */ 065 /** HTTP WWW-authenticate header (<a href="http://tools.ietf.org/html/rfc2617#section-3.2.1">WWW-Authenticate header</a>)*/ 066 public static final String HEADER_AUTHENTICATE = "WWW-Authenticate"; 067 /** 068 * Default HTTP authenticate realm for basic auth 069 * 070 * @see core.tut.pori.http.Definitions#HEADER_AUTHENTICATE 071 * */ 072 public static final String HEADER_AUTHENTICATE_VALUE = "Basic realm=\"CAFrontend\""; 073 074 /* uri separators */ 075 /** separator used in the service uri path to separate methods from parameters i.e. www.domain.fi/somethingSEPARATOR_URI_METHOD_PARAMSparam=value */ 076 public static final String SEPARATOR_URI_METHOD_PARAMS = "?"; 077 /** separator used in the service uri path i.e. www.domain.fiSEPARATOR_URI_PATHsomething */ 078 public static final String SEPARATOR_URI_PATH = "/"; 079 /** separator used in query string to separate parameter values ({@value core.tut.pori.http.Definitions#SEPARATOR_URI_QUERY_PARAM_VALUES}) */ 080 public static final String SEPARATOR_URI_QUERY_PARAM_VALUES = ","; 081 /** separator used in query string to separate query parameters ({@value core.tut.pori.http.Definitions#SEPARATOR_URI_QUERY_PARAMS}) */ 082 public static final String SEPARATOR_URI_QUERY_PARAMS = "&"; 083 /** separator used in query string to separate parameters from values ({@value core.tut.pori.http.Definitions#SEPARATOR_URI_QUERY_PARAM_VALUE_SEPARATOR}) */ 084 public static final String SEPARATOR_URI_QUERY_PARAM_VALUE_SEPARATOR = "="; 085 /** separates types from values. e.g. ?param=type[SEPARATOR_URI_QUERY_TYPE_VALUE]value */ 086 public static final String SEPARATOR_URI_QUERY_TYPE_VALUE = ";"; 087 088 /* common */ 089 /** the default encoding for HTTP traffic */ 090 public static final String ENCODING_UTF8 = "UTF-8"; 091 /** HTTP content type for JSON */ 092 public static final String CONTENT_TYPE_JSON = "application/json"; 093 /** HTTP content type for XML */ 094 public static final String CONTENT_TYPE_XML = "text/xml"; 095 /** HTTP content type for plain text */ 096 public static final String CONTENT_TYPE_TEXT = "text/plain"; 097 098 /** 099 * 100 */ 101 private Definitions(){ 102 // nothing needed 103 } 104}