001package org.nuxeo.box.api.marshalling.dao; 002 003import com.fasterxml.jackson.annotation.JsonIgnore; 004import com.fasterxml.jackson.annotation.JsonProperty; 005 006import java.util.Map; 007 008/** 009 * Class for errors sent from server. 010 */ 011public class BoxServerError extends BoxTypedObject { 012 013 public static final String FIELD_STATUS = "status"; 014 015 public static final String FIELD_CODE = "code"; 016 017 public static final String FIELD_HELP_URL = "help_url"; 018 019 public static final String FIELD_MESSAGE = "message"; 020 021 public static final String FIELD_REQUEST_ID = "request_id"; 022 023 public BoxServerError() { 024 setType(BoxResourceType.ERROR.toString()); 025 } 026 027 /** 028 * Copy constructor, this does deep copy for all the fields. 029 * 030 * @param obj 031 */ 032 public BoxServerError(BoxServerError obj) { 033 super(obj); 034 } 035 036 /** 037 * Instantiate the object from a map. Each entry in the map reflects to a field. 038 * 039 * @param map 040 */ 041 public BoxServerError(Map<String, Object> map) { 042 super(map); 043 } 044 045 /** 046 * @return the status 047 */ 048 @JsonProperty(FIELD_STATUS) 049 public Integer getStatus() { 050 return (Integer) getValue(FIELD_STATUS); 051 } 052 053 /** 054 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 055 * 056 * @param status the status to set 057 */ 058 @JsonProperty(FIELD_STATUS) 059 public void setStatus(Integer status) { 060 put(FIELD_STATUS, status); 061 } 062 063 /** 064 * @return the code 065 */ 066 @JsonProperty(FIELD_CODE) 067 public String getCode() { 068 return (String) getValue(FIELD_CODE); 069 } 070 071 /** 072 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 073 * 074 * @param code the code to set 075 */ 076 @JsonProperty(FIELD_CODE) 077 protected void setCode(String code) { 078 put(FIELD_CODE, code); 079 } 080 081 /** 082 * @return the help_url 083 */ 084 @JsonProperty(FIELD_HELP_URL) 085 public String getHelpUrl() { 086 return (String) getValue(FIELD_HELP_URL); 087 } 088 089 /** 090 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 091 * 092 * @param helpUrl the help_url to set 093 */ 094 @JsonProperty(FIELD_HELP_URL) 095 protected void setHelpUrl(String helpUrl) { 096 put(FIELD_HELP_URL, helpUrl); 097 } 098 099 /** 100 * @return the message 101 */ 102 @JsonProperty(FIELD_MESSAGE) 103 public String getMessage() { 104 return (String) getValue(FIELD_MESSAGE); 105 } 106 107 /** 108 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 109 * 110 * @param message the message to set 111 */ 112 @JsonProperty(FIELD_MESSAGE) 113 protected void setMessage(String message) { 114 put(FIELD_MESSAGE, message); 115 } 116 117 /** 118 * @return the request_id 119 */ 120 @JsonProperty(FIELD_REQUEST_ID) 121 public String getRequestId() { 122 return (String) getValue(FIELD_REQUEST_ID); 123 } 124 125 /** 126 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 127 * 128 * @param requestId the request_id to set 129 */ 130 @JsonProperty(FIELD_REQUEST_ID) 131 protected void setRequestId(String requestId) { 132 put(FIELD_REQUEST_ID, requestId); 133 } 134 135 /** 136 * Deprecated, use getStatus() instead 137 * 138 * @return status code 139 */ 140 @JsonIgnore 141 @Deprecated 142 public Integer getHttpStatusCode() { 143 return getStatus(); 144 } 145}