001package org.nuxeo.box.api.marshalling.dao; 002 003import com.fasterxml.jackson.annotation.JsonInclude; 004import com.fasterxml.jackson.annotation.JsonProperty; 005import com.fasterxml.jackson.annotation.JsonTypeInfo; 006 007import java.util.Map; 008 009/** 010 * Box item, this is a base class for the box items({@link org.nuxeo.box.api .dao.BoxFile}/{@link BoxFolder}/...) 011 */ 012@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", defaultImpl = BoxItem.class) 013public class BoxItem extends BoxTypedObject { 014 015 public static final String FIELD_ETAG = "etag"; 016 017 public static final String FIELD_SEQUENCE_ID = "sequence_id"; 018 019 public static final String FIELD_NAME = "name"; 020 021 public static final String FIELD_DESCRIPTION = "description"; 022 023 public static final String FIELD_SIZE = "size"; 024 025 public static final String FIELD_ITEM_STATUS = "item_status"; 026 027 public static final String FIELD_SHARED_LINK = "shared_link"; 028 029 public static final String FIELD_CREATED_BY = "created_by"; 030 031 public static final String FIELD_MODIFIED_BY = "modified_by"; 032 033 public static final String FIELD_OWNED_BY = "owned_by"; 034 035 public static final String FIELD_PARENT = "parent"; 036 037 public static final String FIELD_PATH_COLLECTION = "path_collection"; 038 039 public static final String FIELD_TAGS = "tags"; 040 041 public BoxItem() { 042 } 043 044 /** 045 * Copy constructor, this does deep copy for all the fields. 046 * 047 * @param obj 048 */ 049 public BoxItem(BoxItem obj) { 050 super(obj); 051 } 052 053 /** 054 * Instantiate the object from a map. Each entry in the map reflects to a field. 055 * 056 * @param map 057 */ 058 public BoxItem(Map<String, Object> map) { 059 super(map); 060 } 061 062 /** 063 * Get the path of folders to this item, starting at the root. 064 * 065 * @return the path_collection 066 */ 067 @JsonProperty(FIELD_PATH_COLLECTION) 068 public BoxCollection getPathCollection() { 069 return (BoxCollection) getValue(FIELD_PATH_COLLECTION); 070 } 071 072 /** 073 * This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 074 * 075 * @param pathCollection the path_collection to set 076 */ 077 @JsonProperty(FIELD_PATH_COLLECTION) 078 private void setPathCollection(BoxCollection pathCollection) { 079 put(FIELD_PATH_COLLECTION, pathCollection); 080 } 081 082 /** 083 * Get the tags that are set on this item. 084 * 085 * @return the tags 086 */ 087 @JsonProperty(FIELD_TAGS) 088 public String[] getTags() { 089 return (String[]) getValue(FIELD_TAGS); 090 } 091 092 /** 093 * This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 094 * 095 * @param tags the tags to set 096 */ 097 @JsonProperty(FIELD_TAGS) 098 private void setTags(String[] tags) { 099 put(FIELD_TAGS, tags); 100 } 101 102 /** 103 * Getter. 104 * 105 * @return sequence id 106 */ 107 // NXIO-45: don't skip null value to fit to Box json payload response 108 @JsonInclude(JsonInclude.Include.ALWAYS) 109 @JsonProperty(FIELD_SEQUENCE_ID) 110 public String getSequenceId() { 111 return (String) getValue(FIELD_SEQUENCE_ID); 112 } 113 114 /** 115 * Setter.This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 116 * 117 * @param sequenceId sequence id 118 */ 119 @JsonProperty(FIELD_SEQUENCE_ID) 120 private void setSequenceId(String sequenceId) { 121 put(FIELD_SEQUENCE_ID, sequenceId); 122 } 123 124 /** 125 * Get name of the item. 126 * 127 * @return name of the item 128 */ 129 @JsonProperty(FIELD_NAME) 130 public String getName() { 131 return (String) getValue(FIELD_NAME); 132 } 133 134 /** 135 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 136 * 137 * @param name name of the item 138 */ 139 @JsonProperty(FIELD_NAME) 140 private void setName(String name) { 141 put(FIELD_NAME, name); 142 } 143 144 /** 145 * Get description of the item. 146 * 147 * @return description of the item 148 */ 149 @JsonProperty(FIELD_DESCRIPTION) 150 public String getDescription() { 151 return (String) getValue(FIELD_DESCRIPTION); 152 } 153 154 /** 155 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 156 * 157 * @param description description 158 */ 159 @JsonProperty(FIELD_DESCRIPTION) 160 private void setDescription(String description) { 161 put(FIELD_DESCRIPTION, description); 162 } 163 164 /** 165 * Get size of the box item. In bytes. 166 * 167 * @return size of the box item in bytes. 168 */ 169 @JsonProperty(FIELD_SIZE) 170 public Double getSize() { 171 return (Double) getValue(FIELD_SIZE); 172 } 173 174 /** 175 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 176 * 177 * @param size 178 */ 179 @JsonProperty(FIELD_SIZE) 180 private void setSize(Double size) { 181 put(FIELD_SIZE, size); 182 } 183 184 /** 185 * Get shared link of box item. Note if there is not shared link created, this is null. 186 * 187 * @return shared link of box item 188 */ 189 @JsonProperty(FIELD_SHARED_LINK) 190 public BoxSharedLink getSharedLink() { 191 return (BoxSharedLink) getValue(FIELD_SHARED_LINK); 192 } 193 194 /** 195 * Set the shared link. 196 * 197 * @param sharedLink shared link 198 */ 199 @JsonProperty(FIELD_SHARED_LINK) 200 private void setSharedLink(BoxSharedLink sharedLink) { 201 put(FIELD_SHARED_LINK, sharedLink); 202 } 203 204 /** 205 * Get the user creating this item. 206 * 207 * @return user creating this item 208 */ 209 @JsonProperty(FIELD_CREATED_BY) 210 public BoxUser getCreatedBy() { 211 return (BoxUser) getValue(FIELD_CREATED_BY); 212 } 213 214 /** 215 * Set the user creating this item. 216 * 217 * @param createdBy created by 218 */ 219 @JsonProperty(FIELD_CREATED_BY) 220 private void setCreatedBy(BoxUser createdBy) { 221 put(FIELD_CREATED_BY, createdBy); 222 } 223 224 /** 225 * Get the user last modified the item. 226 * 227 * @return user last modified the item 228 */ 229 @JsonProperty(FIELD_MODIFIED_BY) 230 public BoxUser getModifiedBy() { 231 return (BoxUser) getValue(FIELD_MODIFIED_BY); 232 } 233 234 /** 235 * Set the user last modified the item. 236 * 237 * @param modifiedBy 238 */ 239 @JsonProperty(FIELD_MODIFIED_BY) 240 private void setModifiedBy(BoxUser modifiedBy) { 241 put(FIELD_MODIFIED_BY, modifiedBy); 242 } 243 244 /** 245 * Get owner of the item. 246 * 247 * @return owner of the item 248 */ 249 @JsonProperty(FIELD_OWNED_BY) 250 public BoxUser getOwnedBy() { 251 return (BoxUser) getValue(FIELD_OWNED_BY); 252 } 253 254 /** 255 * Set the owner. 256 * 257 * @param ownedBy owner 258 */ 259 @JsonProperty(FIELD_OWNED_BY) 260 private void setOwnedBy(BoxUser ownedBy) { 261 put(FIELD_OWNED_BY, ownedBy); 262 } 263 264 /** 265 * Get parent folder. 266 * 267 * @return parent folder 268 */ 269 @JsonProperty(FIELD_PARENT) 270 public BoxFolder getParent() { 271 return (BoxFolder) getValue(FIELD_PARENT); 272 } 273 274 /** 275 * Set the parent. 276 * 277 * @param parent parent folder 278 */ 279 @JsonProperty(FIELD_PARENT) 280 private void setParent(BoxFolder parent) { 281 put(FIELD_PARENT, parent); 282 } 283 284 /** 285 * Get etag. 286 * 287 * @return etag 288 */ 289 // NXIO-45: don't skip null value to fit to Box json payload response 290 @JsonInclude(JsonInclude.Include.ALWAYS) 291 @JsonProperty(FIELD_ETAG) 292 public String getEtag() { 293 return (String) getValue(FIELD_ETAG); 294 } 295 296 /** 297 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 298 * 299 * @param etag etag 300 */ 301 @JsonProperty(FIELD_ETAG) 302 private void setEtag(String etag) { 303 put(FIELD_ETAG, etag); 304 } 305 306 /** 307 * Get the status of this item, which indicates whether this item is deleted or not. 308 * 309 * @return the item_status 310 */ 311 @JsonProperty(FIELD_ITEM_STATUS) 312 public String getItemStatus() { 313 return (String) getValue(FIELD_ITEM_STATUS); 314 } 315 316 /** 317 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 318 * 319 * @param itemStatus the item_status to set 320 */ 321 @JsonProperty(FIELD_ITEM_STATUS) 322 private void setItemStatus(String itemStatus) { 323 put(FIELD_ITEM_STATUS, itemStatus); 324 } 325}