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