001package org.nuxeo.box.api.marshalling.dao;
002
003import com.fasterxml.jackson.annotation.JsonProperty;
004import com.fasterxml.jackson.annotation.JsonTypeInfo;
005
006import java.util.Map;
007
008/**
009 * Box folder.
010 */
011@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", defaultImpl = BoxFolder.class)
012public class BoxFolder extends BoxItem {
013
014    public static final String FIELD_FOLDER_UPLOAD_EMAIL = "folder_upload_email";
015
016    public static final String FIELD_ITEM_COLLECTION = "item_collection";
017
018    public static final String FIELD_HAS_COLLABORATIONS = "has_collaborations";
019
020    /**
021     * Constructor.
022     */
023    public BoxFolder() {
024        setType(BoxResourceType.FOLDER.toString());
025    }
026
027    /**
028     * Copy constructor, this does deep copy for all the fields.
029     *
030     * @param obj
031     */
032    public BoxFolder(BoxFolder 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 BoxFolder(Map<String, Object> map) {
042        super(map);
043    }
044
045    /**
046     * This is folder specific field, get the email that can be used to upload file into the folder.
047     *
048     * @return email
049     */
050    @JsonProperty(FIELD_FOLDER_UPLOAD_EMAIL)
051    public BoxEmail getFolderUploadEmail() {
052        return (BoxEmail) getValue(FIELD_FOLDER_UPLOAD_EMAIL);
053    }
054
055    /**
056     * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>}
057     *
058     * @param folderUploadEmail
059     */
060    @JsonProperty(FIELD_FOLDER_UPLOAD_EMAIL)
061    protected void setFolderUploadEmail(BoxEmail folderUploadEmail) {
062        put(FIELD_FOLDER_UPLOAD_EMAIL, folderUploadEmail);
063    }
064
065    /**
066     * Getter.Get the items(files, subfolders, web links...) under this box folder.
067     *
068     * @return collection of children items.
069     */
070    @JsonProperty(FIELD_ITEM_COLLECTION)
071    public BoxCollection getItemCollection() {
072        return (BoxCollection) getValue(FIELD_ITEM_COLLECTION);
073    }
074
075    /**
076     * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>}
077     *
078     * @param itemCollection children item.
079     */
080    @JsonProperty(FIELD_ITEM_COLLECTION)
081    protected void setItemCollection(BoxCollection itemCollection) {
082        put(FIELD_ITEM_COLLECTION, itemCollection);
083    }
084
085    /**
086     * Getter.Get whether this box folder has collaborations.
087     *
088     * @return whether this box folder has collaborations
089     */
090    @JsonProperty(FIELD_HAS_COLLABORATIONS)
091    public Boolean hasCollaborations() {
092        return (Boolean) getValue(FIELD_HAS_COLLABORATIONS);
093    }
094
095    public boolean hasCollaborations(boolean defaultValue) {
096        Boolean hasCollabs = hasCollaborations();
097        return hasCollabs != null ? hasCollabs : defaultValue;
098    }
099
100    /**
101     * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>}
102     *
103     * @param hasCollaborations whether folder has collaborations.
104     */
105    @JsonProperty(FIELD_HAS_COLLABORATIONS)
106    protected void setHasCollaborations(Boolean hasCollaborations) {
107        put(FIELD_HAS_COLLABORATIONS, hasCollaborations);
108    }
109}