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