View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.common.rest.api;
20  
21  import javax.ws.rs.core.MediaType;
22  
23  /**
24   * Custom HTTP headers in use with REST services.
25   */
26  public final class RESTHeaders {
27  
28      public static final String DOMAIN = "X-Syncope-Domain";
29  
30      public static final String TOKEN = "X-Syncope-Token";
31  
32      public static final String TOKEN_EXPIRE = "X-Syncope-Token-Expire";
33  
34      public static final String OWNED_ENTITLEMENTS = "X-Syncope-Entitlements";
35  
36      public static final String DELEGATED_BY = "X-Syncope-Delegated-By";
37  
38      public static final String DELEGATIONS = "X-Syncope-Delegations";
39  
40      public static final String RESOURCE_KEY = "X-Syncope-Key";
41  
42      public static final String CONNOBJECT_KEY = "X-Syncope-ConnObject-Key";
43  
44      /**
45       * Asks for asynchronous propagation towards external resources with null priority.
46       */
47      public static final String NULL_PRIORITY_ASYNC = "X-Syncope-Null-Priority-Async";
48  
49      /**
50       * Declares the type of exception being raised.
51       *
52       * @see org.apache.syncope.common.lib.types.ClientExceptionType
53       */
54      public static final String ERROR_CODE = "X-Application-Error-Code";
55  
56      /**
57       * Declares additional information for the exception being raised.
58       */
59      public static final String ERROR_INFO = "X-Application-Error-Info";
60  
61      /**
62       * Mediatype for PNG images, not defined in {@link javax.ws.rs.core.MediaType}.
63       */
64      public static final String MEDIATYPE_IMAGE_PNG = "image/png";
65  
66      /**
67       * Mediatype for YAML, not defined in {@link javax.ws.rs.core.MediaType}.
68       */
69      public static final String APPLICATION_YAML = "application/yaml";
70  
71      /**
72       * Mediatype for YAML, not defined in {@link javax.ws.rs.core.MediaType}.
73       */
74      public static final MediaType APPLICATION_YAML_TYPE = new MediaType("application", "yaml");
75  
76      /**
77       * Mediatype for text/csv, not defined in {@link javax.ws.rs.core.MediaType}.
78       */
79      public static final String TEXT_CSV = "text/csv";
80  
81      /**
82       * Mediatype for text/csv, not defined in {@link javax.ws.rs.core.MediaType}.
83       */
84      public static final MediaType TEXT_CSV_TYPE = new MediaType("text", "csv");
85  
86      /**
87       * Mediatype for multipart/mixed, not defined in {@link javax.ws.rs.core.MediaType}.
88       */
89      public static final String MULTIPART_MIXED = "multipart/mixed";
90  
91      /**
92       * The boundary parameter name for multipart, not defined in {@link javax.ws.rs.core.MediaType}.
93       */
94      public static final String BOUNDARY_PARAMETER = "boundary";
95  
96      /**
97       * Builds Content-Type string for multipart/mixed and the given boundary.
98       *
99       * @param boundary multipart boundary value
100      * @return multipart/mixed Content-Type string, with given boundary
101      */
102     public static String multipartMixedWith(final String boundary) {
103         return MULTIPART_MIXED + ';' + BOUNDARY_PARAMETER + '=' + boundary;
104     }
105 
106     /**
107      * Allows the client to specify a preference for the result to be returned from the server.
108      * <a href="http://msdn.microsoft.com/en-us/library/hh537533.aspx">More information</a>.
109      *
110      * @see Preference
111      */
112     public static final String PREFER = "Prefer";
113 
114     /**
115      * Allows the server to inform the client about the fact that a specified preference was applied.
116      * <a href="http://msdn.microsoft.com/en-us/library/hh554623.aspx">More information</a>.
117      *
118      * @see Preference
119      */
120     public static final String PREFERENCE_APPLIED = "Preference-Applied";
121 
122     private RESTHeaders() {
123         // Empty constructor for static utility class.
124     }
125 }