001package com.box.sdk;
002
003import java.util.ArrayList;
004import java.util.List;
005
006/**
007 * Optional parameters for creating an updating a Retention Policy.
008 *
009 * @see BoxRetentionPolicy
010 */
011public class RetentionPolicyParams {
012
013    /**
014     * @see #getCanOwnerExtendRetention()
015     */
016    private boolean canOwnerExtendRetention;
017
018    /**
019     * @see #getAreOwnersNotified()
020     */
021    private boolean areOwnersNotified;
022
023    /**
024     * @see #getDescription()
025     */
026    private String description;
027
028    /**
029     * @see #getCustomNotificationRecipients()
030     */
031    private List<BoxUser.Info> customNotificationRecipients;
032
033    /**
034     * @see #getCustomNotificationRecipients()
035     */
036    private RetentionType retentionType;
037
038    /**
039     * Creates optional retention policy params with default values.
040     */
041    public RetentionPolicyParams() {
042        this.canOwnerExtendRetention = false;
043        this.areOwnersNotified = false;
044        this.customNotificationRecipients = new ArrayList<>();
045        this.description = "";
046        this.retentionType = RetentionType.MODIFIABLE;
047    }
048
049    /**
050     * @return the flag denoting whether the owner can extend the retention.
051     */
052    public boolean getCanOwnerExtendRetention() {
053        return this.canOwnerExtendRetention;
054    }
055
056    /**
057     * Set the flag denoting whether the owner can extend the retentiion.
058     *
059     * @param canOwnerExtendRetention The flag value.
060     */
061    public void setCanOwnerExtendRetention(boolean canOwnerExtendRetention) {
062        this.canOwnerExtendRetention = canOwnerExtendRetention;
063    }
064
065    /**
066     * @return the flag denoting whether owners and co-onwers are notified when the retention period is ending.
067     */
068    public boolean getAreOwnersNotified() {
069        return this.areOwnersNotified;
070    }
071
072    /**
073     * Set the flag denoting whether owners and co-owners are notified when the retention period is ending.
074     *
075     * @param areOwnersNotified The flag value.
076     */
077    public void setAreOwnersNotified(boolean areOwnersNotified) {
078        this.areOwnersNotified = areOwnersNotified;
079    }
080
081    /**
082     * @return The additional text description of the retention policy
083     */
084    public String getDescription() {
085        return this.description;
086    }
087
088    /**
089     *
090     * @return retention type. It can be one of values: `modifiable` or `non-modifiable`.
091     *
092     * `modifiable` means that you can modify the retention policy. For example, you can add or remove folders,
093     *  shorten or lengthen the policy duration, or delete the assignment.
094     *
095     * `non-modifiable` means that can modify the retention policy only in a limited way: add a folder,
096     *  lengthen the duration, retire the policy, change the disposition action or notification settings.
097     *  You cannot perform other actions, such as deleting the assignment or shortening the policy duration.
098     */
099    public RetentionType getRetentionType() {
100        return retentionType;
101    }
102
103    /**
104     *
105     * @param retentionType The retention type: `modifiable` or `non-modifiable`.
106     */
107    public void setRetentionType(RetentionType retentionType) {
108        this.retentionType = retentionType;
109    }
110
111    /**
112     * Set additional text description of the retention policy.
113     *
114     * @param description The additional text description of the retention policy.
115     */
116    public void setDescription(String description) {
117        this.description = description;
118    }
119
120    /**
121     * @return the list of extra users to notify when the retention period is ending.
122     */
123    public List<BoxUser.Info> getCustomNotificationRecipients() {
124        return this.customNotificationRecipients;
125    }
126
127    /**
128     * Set the list of extra users to notify when the retention period is ending.
129     *
130     * @param customNotificationRecipients The list of users.
131     */
132    public void setCustomNotificationRecipients(List<BoxUser.Info> customNotificationRecipients) {
133        this.customNotificationRecipients = customNotificationRecipients;
134    }
135
136    /**
137     * Add a user by ID to the list of people to notify when the retention period is ending.
138     *
139     * @param userID The ID of the user to add to the list.
140     */
141    public void addCustomNotificationRecipient(String userID) {
142        BoxUser user = new BoxUser(null, userID);
143        this.customNotificationRecipients.add(user.new Info());
144
145    }
146
147    /**
148     * Add a user to the list of people to notify when the retention period is ending.
149     *
150     * @param user The info of the user to add to the list
151     */
152    public void addCustomNotificationRecipient(BoxUser user) {
153        this.customNotificationRecipients.add(user.new Info());
154    }
155
156    /**
157     * The type of retention.
158     */
159    public enum RetentionType {
160        /**
161         * You can modify the retention policy. For example, you can add or remove folders,
162         * shorten or lengthen the policy duration, or delete the assignment.
163         * Use this type if your retention policy is not related to any regulatory purposes.
164         */
165        MODIFIABLE("modifiable"),
166
167        /**
168         * You can modify the retention policy only in a limited way: add a folder, lengthen the duration,
169         * retire the policy, change the disposition action or notification settings.
170         * You cannot perform other actions, such as deleting the assignment or shortening the policy duration.
171         * Use this type to ensure compliance with regulatory retention policies.
172         */
173        NON_MODIFIABLE("non_modifiable");
174
175        private final String jsonValue;
176
177        RetentionType(String jsonValue) {
178            this.jsonValue = jsonValue;
179        }
180
181        static RetentionType fromJSONString(String jsonValue) {
182            return RetentionType.valueOf(jsonValue.toUpperCase());
183        }
184
185        String toJSONString() {
186            return this.jsonValue;
187        }
188    }
189}