001package org.nuxeo.box.api.marshalling.dao; 002 003import com.fasterxml.jackson.annotation.JsonProperty; 004 005import java.util.Map; 006 007/** 008 * Box user. 009 */ 010public class BoxUser extends BoxTypedObject { 011 012 /** 013 * Used when the user's enterprise role is admin. 014 */ 015 public static final String ROLE_ADMIN = "admin"; 016 017 /** 018 * Used when the user's enterprise role is co-admin. 019 */ 020 public static final String ROLE_COADMIN = "coadmin"; 021 022 /** 023 * Used when the user's enterprise role is normal user. 024 */ 025 public static final String ROLE_USER = "user"; 026 027 /** 028 * Used when user status is active 029 */ 030 public static final String STATUS_ACTIVE = "active"; 031 032 /** 033 * Used when user status is inactive 034 */ 035 public static final String STATUS_INACTIVE = "inactive"; 036 037 /** Optional field parameters. */ 038 039 /** 040 * The user's enterprise role. Can be admin, coadmin, or user 041 */ 042 public static final String FIELD_ROLE = "role"; 043 044 /** 045 * An array of key/value pairs set by the user's admin 046 */ 047 public static final String FIELD_TRACKING_CODES = "tracking_codes"; 048 049 /** 050 * Whether this user can see other enterprise users in its contact list 051 */ 052 public static final String FIELD_CAN_SEE_MANAGED_USERS = "can_see_managed_users"; 053 054 /** 055 * Whether to exempt this user from Enterprise device limits 056 */ 057 public static final String FIELD_IS_SYNC_ENABLED = "is_sync_enabled"; 058 059 /** 060 * Whether or not this user must use two-factor authentication 061 */ 062 public static final String FIELD_IS_EXEMPT_FROM_DEVICE_LIMITS = "is_exempt_from_device_limits"; 063 064 /** 065 * Whether or not this user must use two-factor authentication 066 */ 067 public static final String FIELD_IS_EXEMPT_FROM_LOGIN_VERIFICATION = "is_exempt_from_login_verficiation"; 068 069 /** 070 * Mini representation of this user's enterprise, including the ID of its enterprise 071 */ 072 public static final String FIELD_ENTERPRISE = "enterprise"; 073 074 public static final String FIELD_NAME = "name"; 075 076 public static final String FIELD_LOGIN = "login"; 077 078 public static final String FIELD_LANGUAGE = "language"; 079 080 public static final String FIELD_SPACE_AMOUNT = "space_amount"; 081 082 public static final String FIELD_SPACE_USED = "space_used"; 083 084 public static final String FIELD_MAX_UPLOAD_SIZE = "max_upload_size"; 085 086 public static final String FIELD_STATUS = "status"; 087 088 public static final String FIELD_JOB_TITLE = "job_title"; 089 090 public static final String FIELD_PHONE = "phone"; 091 092 public static final String FIELD_ADDRESS = "address"; 093 094 public static final String FIELD_AVATAR_URL = "avatar_url"; 095 096 public static final String FIELD_EXEMPT_FROM_DEVICE_LIMITS = "is_exempt_from_device_limits"; 097 098 public static final String FIELD_EXEMPT_FROM_LOGIN_VERIFICATION = "is_exempt_from_login_verification"; 099 100 public static final String FIELD_MY_TAGS = "my_tags"; 101 102 /** 103 * Constructor. 104 */ 105 public BoxUser() { 106 setType(BoxResourceType.USER.toString()); 107 } 108 109 /** 110 * Copy constructor, this does deep copy for all the fields. 111 * 112 * @param obj 113 */ 114 public BoxUser(BoxUser obj) { 115 super(obj); 116 } 117 118 /** 119 * Instantiate the object from a map. Each entry in the map reflects to a field. 120 * 121 * @param map 122 */ 123 public BoxUser(Map<String, Object> map) { 124 super(map); 125 } 126 127 /** 128 * Get name of this user. 129 * 130 * @return name 131 */ 132 @JsonProperty(FIELD_NAME) 133 public String getName() { 134 return (String) getValue(FIELD_NAME); 135 } 136 137 /** 138 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 139 * 140 * @param name name 141 */ 142 @JsonProperty(FIELD_NAME) 143 private void setName(String name) { 144 put(FIELD_NAME, name); 145 } 146 147 /** 148 * Get the email address this user uses to login 149 * 150 * @return login 151 */ 152 @JsonProperty(FIELD_LOGIN) 153 public String getLogin() { 154 return (String) getValue(FIELD_LOGIN); 155 } 156 157 /** 158 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 159 * 160 * @param login login 161 */ 162 @JsonProperty(FIELD_LOGIN) 163 private void setLogin(String login) { 164 put(FIELD_LOGIN, login); 165 } 166 167 /** 168 * Get the user's enterprise role. The role can be {@link #ROLE_ADMIN}, {@link #ROLE_COADMIN} or {@link #ROLE_USER} 169 * 170 * @return the role 171 */ 172 @JsonProperty(FIELD_ROLE) 173 public String getRole() { 174 return (String) getValue(FIELD_ROLE); 175 } 176 177 /** 178 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 179 * 180 * @param role the role to set 181 */ 182 @JsonProperty(FIELD_ROLE) 183 private void setRole(String role) { 184 put(FIELD_ROLE, role); 185 } 186 187 /** 188 * Get the language of this user. This uses <a href="http://en.wikipedia .org/wiki/ISO_639-1">ISO 639-1 Language 189 * Code</a> 190 * 191 * @return the language 192 */ 193 @JsonProperty(FIELD_LANGUAGE) 194 public String getLanguage() { 195 return (String) getValue(FIELD_LANGUAGE); 196 } 197 198 /** 199 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 200 * 201 * @param language the language to set 202 */ 203 @JsonProperty(FIELD_LANGUAGE) 204 private void setLanguage(String language) { 205 put(FIELD_LANGUAGE, language); 206 } 207 208 /** 209 * Get the user's total available space amount in bytes. 210 * 211 * @return the space_amount 212 */ 213 @JsonProperty(FIELD_SPACE_AMOUNT) 214 public Double getSpaceAmount() { 215 return (Double) getValue(FIELD_SPACE_AMOUNT); 216 } 217 218 /** 219 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 220 * 221 * @param spaceAmount the space_amount to set 222 */ 223 @JsonProperty(FIELD_SPACE_AMOUNT) 224 private void setSpaceAmount(Double spaceAmount) { 225 put(FIELD_SPACE_AMOUNT, spaceAmount); 226 } 227 228 /** 229 * Get the amount of space in use by the user. 230 * 231 * @return the space_used 232 */ 233 @JsonProperty(FIELD_SPACE_USED) 234 public Double getSpaceUsed() { 235 return (Double) getValue(FIELD_SPACE_USED); 236 } 237 238 /** 239 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 240 * 241 * @param spaceUsed the space_used to set 242 */ 243 @JsonProperty(FIELD_SPACE_USED) 244 private void setSpaceUsed(Double spaceUsed) { 245 put(FIELD_SPACE_USED, spaceUsed); 246 } 247 248 /** 249 * Get the maximum individual file size in bytes this user can have 250 * 251 * @return the max_upload_size 252 */ 253 @JsonProperty(FIELD_MAX_UPLOAD_SIZE) 254 public Double getMaxUploadSize() { 255 return (Double) getValue(FIELD_MAX_UPLOAD_SIZE); 256 } 257 258 /** 259 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 260 * 261 * @param max_upload_size the max_upload_size to set 262 */ 263 @JsonProperty(FIELD_MAX_UPLOAD_SIZE) 264 private void setMaxUploadSize(Double max_upload_size) { 265 put(FIELD_MAX_UPLOAD_SIZE, max_upload_size); 266 } 267 268 /** 269 * Get the tracking codes. This is an array of key/value pairs set by the user's admin. 270 * 271 * @return the tracking_codes 272 */ 273 @SuppressWarnings("unchecked") 274 @JsonProperty(FIELD_TRACKING_CODES) 275 public Map<String, String> getTrackingCodes() { 276 return (Map<String, String>) getValue(FIELD_TRACKING_CODES); 277 } 278 279 /** 280 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 281 * 282 * @param trackingCodes the tracking_codes to set 283 */ 284 @JsonProperty(FIELD_TRACKING_CODES) 285 private void setTrackingCodes(Map<String, String> trackingCodes) { 286 put(FIELD_TRACKING_CODES, trackingCodes); 287 } 288 289 /** 290 * Whether or not the user can see other enterprise users in the contact list. 291 * 292 * @return the can_see_managed_users 293 */ 294 @JsonProperty(FIELD_CAN_SEE_MANAGED_USERS) 295 public Boolean canSeeManagedUsers() { 296 return (Boolean) getValue(FIELD_CAN_SEE_MANAGED_USERS); 297 } 298 299 /** 300 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 301 * 302 * @param canSeeManagedUsers the can_see_managed_users to set 303 */ 304 @JsonProperty(FIELD_CAN_SEE_MANAGED_USERS) 305 private void setCanSeeManagedUsers(Boolean canSeeManagedUsers) { 306 put(FIELD_CAN_SEE_MANAGED_USERS, canSeeManagedUsers); 307 } 308 309 /** 310 * Whether or not this user can use Box Sync. 311 * 312 * @return the is_sync_enabled 313 */ 314 @JsonProperty(FIELD_IS_SYNC_ENABLED) 315 public Boolean isSyncEnabled() { 316 return (Boolean) getValue(FIELD_IS_SYNC_ENABLED); 317 } 318 319 /** 320 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 321 * 322 * @param isSyncEnabled the is_sync_enabled to set 323 */ 324 @JsonProperty(FIELD_IS_SYNC_ENABLED) 325 private void setSyncEnabled(Boolean isSyncEnabled) { 326 put(FIELD_IS_SYNC_ENABLED, isSyncEnabled); 327 } 328 329 /** 330 * Get status of the user. This String can be {@link #STATUS_ACTIVE} or {@link #STATUS_INACTIVE} 331 * 332 * @return the status 333 */ 334 @JsonProperty(FIELD_STATUS) 335 public String getStatus() { 336 return (String) getValue(FIELD_STATUS); 337 } 338 339 /** 340 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 341 * 342 * @param status the status to set 343 */ 344 @JsonProperty(FIELD_STATUS) 345 private void setStatus(String status) { 346 put(FIELD_STATUS, status); 347 } 348 349 /** 350 * Get the user's job title. 351 * 352 * @return the job_title 353 */ 354 @JsonProperty(FIELD_JOB_TITLE) 355 public String getJobTitle() { 356 return (String) getValue(FIELD_JOB_TITLE); 357 } 358 359 /** 360 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 361 * 362 * @param jobTitle the job_title to set 363 */ 364 @JsonProperty(FIELD_JOB_TITLE) 365 private void setJob_title(String jobTitle) { 366 put(FIELD_JOB_TITLE, jobTitle); 367 } 368 369 /** 370 * Get the user's phone number. 371 * 372 * @return the phone 373 */ 374 @JsonProperty(FIELD_PHONE) 375 public String getPhone() { 376 return (String) getValue(FIELD_PHONE); 377 } 378 379 /** 380 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 381 * 382 * @param phone the phone to set 383 */ 384 @JsonProperty(FIELD_PHONE) 385 private void setPhone(String phone) { 386 put(FIELD_PHONE, phone); 387 } 388 389 /** 390 * Get the user's address. 391 * 392 * @return the address 393 */ 394 @JsonProperty(FIELD_ADDRESS) 395 public String getAddress() { 396 return (String) getValue(FIELD_ADDRESS); 397 } 398 399 /** 400 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 401 * 402 * @param address the address to set 403 */ 404 @JsonProperty(FIELD_ADDRESS) 405 private void setAddress(String address) { 406 put(FIELD_ADDRESS, address); 407 } 408 409 /** 410 * get the URL for this user's avatar image. 411 * 412 * @return the avatar_url 413 */ 414 @JsonProperty(FIELD_AVATAR_URL) 415 public String getAvatarUrl() { 416 return (String) getValue(FIELD_AVATAR_URL); 417 } 418 419 /** 420 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 421 * 422 * @param avatarUrl the avatar_url to set 423 */ 424 @JsonProperty(FIELD_AVATAR_URL) 425 private void setAvatarUrl(String avatarUrl) { 426 put(FIELD_AVATAR_URL, avatarUrl); 427 } 428 429 /** 430 * Whether to exempt this user from Enterprise device limits. 431 * 432 * @return the is_exempt_from_device_limits 433 */ 434 @JsonProperty(FIELD_EXEMPT_FROM_DEVICE_LIMITS) 435 public Boolean isExemptFromDeviceLimits() { 436 return (Boolean) getValue(FIELD_EXEMPT_FROM_DEVICE_LIMITS); 437 } 438 439 /** 440 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 441 * 442 * @param isExemptFromDeviceLimits the is_exempt_from_device_limits to set 443 */ 444 @JsonProperty(FIELD_EXEMPT_FROM_DEVICE_LIMITS) 445 private void setExemptFromDeviceLimits(Boolean isExemptFromDeviceLimits) { 446 put(FIELD_EXEMPT_FROM_DEVICE_LIMITS, isExemptFromDeviceLimits); 447 } 448 449 /** 450 * Whether or not this user must use two-factor authentication. 451 * 452 * @return the is_exempt_from_login_verification 453 */ 454 @JsonProperty(FIELD_EXEMPT_FROM_LOGIN_VERIFICATION) 455 public Boolean isExemptFromLoginVerification() { 456 return (Boolean) getValue(FIELD_EXEMPT_FROM_LOGIN_VERIFICATION); 457 } 458 459 /** 460 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 461 * 462 * @param isExemptFromLoginVerification the is_exempt_from_login_verification to set 463 */ 464 @JsonProperty(FIELD_EXEMPT_FROM_LOGIN_VERIFICATION) 465 private void setExemptFromLoginVerification(boolean isExemptFromLoginVerification) { 466 put(FIELD_EXEMPT_FROM_LOGIN_VERIFICATION, isExemptFromLoginVerification); 467 } 468 469 /** 470 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 471 * 472 * @param enterprise enterprise 473 */ 474 @JsonProperty(FIELD_ENTERPRISE) 475 private void setEnterprise(BoxEnterprise enterprise) { 476 put(FIELD_ENTERPRISE, enterprise); 477 } 478 479 /** 480 * Get the enterprise this user belongs to if available, null otherwise. 481 * 482 * @return enterprise 483 */ 484 @JsonProperty(FIELD_ENTERPRISE) 485 public BoxEnterprise getEnterprise() { 486 return (BoxEnterprise) getValue(FIELD_ENTERPRISE); 487 } 488 489 /** 490 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 491 * 492 * @param myTags my_tags 493 */ 494 @JsonProperty(FIELD_MY_TAGS) 495 private void setMyTags(String[] myTags) { 496 put(FIELD_MY_TAGS, myTags); 497 } 498 499 /** 500 * Get set of all tags on items that are visible by this user. Note this is not tags of the "BoxUser" object. 501 * 502 * @return tags 503 */ 504 @JsonProperty(FIELD_MY_TAGS) 505 public String[] getMyTags() { 506 return (String[]) getValue(FIELD_MY_TAGS); 507 } 508}