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// CHECKSTYLE:OFF 023 024/** 025 * Shared link. 026 */ 027public class BoxSharedLink extends BoxObject { 028 029 public static final String FIELD_URL = "url"; 030 031 public static final String FIELD_DOWNLOAD_URL = "download_url"; 032 033 public static final String FIELD_PASSWORD_ENABLED = "password_enabled"; 034 035 public static final String FIELD_UNSHARED_AT = "unshared_at"; 036 037 public static final String FIELD_DOWNLOAD_COUNT = "download_count"; 038 039 public static final String FIELD_PREVIEW_COUNT = "preview_count"; 040 041 public static final String FIELD_ACCESS = "access"; 042 043 public static final String FIELD_PERMISSIONS = "permissions"; 044 045 public BoxSharedLink() { 046 } 047 048 /** 049 * Copy constructor, this does deep copy for all the fields. 050 * 051 * @param obj 052 */ 053 public BoxSharedLink(BoxSharedLink obj) { 054 super(obj); 055 } 056 057 /** 058 * Instantiate the object from a map. Each entry in the map reflects to a field. 059 * 060 * @param map 061 */ 062 public BoxSharedLink(Map<String, Object> map) { 063 super(map); 064 } 065 066 /** 067 * Get the url of the shared link. 068 * 069 * @return the url 070 */ 071 @JsonProperty(FIELD_URL) 072 public String getUrl() { 073 return (String) getValue(FIELD_URL); 074 } 075 076 /** 077 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 078 * 079 * @param theUrl the url to set 080 */ 081 @JsonProperty(FIELD_URL) 082 private void setUrl(final String theUrl) { 083 put(FIELD_URL, theUrl); 084 } 085 086 /** 087 * Get the url to download the shared item. 088 * 089 * @return the download_url 090 */ 091 @JsonProperty(FIELD_DOWNLOAD_URL) 092 public String getDownloadUrl() { 093 return (String) getValue(FIELD_DOWNLOAD_URL); 094 } 095 096 /** 097 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 098 * 099 * @param downloadUrl the download_url to set 100 */ 101 @JsonProperty(FIELD_DOWNLOAD_URL) 102 private void setDownloadUrl(final String downloadUrl) { 103 put(FIELD_DOWNLOAD_URL, downloadUrl); 104 } 105 106 /** 107 * Whether this shared link is password enabled. 108 * 109 * @return the password_enabled 110 */ 111 @JsonProperty(FIELD_PASSWORD_ENABLED) 112 public Boolean isPasswordEnabled() { 113 return (Boolean) getValue(FIELD_PASSWORD_ENABLED); 114 } 115 116 /** 117 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 118 * 119 * @param passwordEnabled the password_enabled to set 120 */ 121 @JsonProperty(FIELD_PASSWORD_ENABLED) 122 private void setPasswordEnabled(final Boolean passwordEnabled) { 123 put(FIELD_PASSWORD_ENABLED, passwordEnabled); 124 } 125 126 /** 127 * Get download count. 128 * 129 * @return the download_count 130 */ 131 @JsonProperty(FIELD_DOWNLOAD_COUNT) 132 public Integer getDownloadCount() { 133 return (Integer) getValue(FIELD_DOWNLOAD_COUNT); 134 } 135 136 /** 137 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 138 * 139 * @param downloadCount the download_count to set 140 */ 141 @JsonProperty(FIELD_DOWNLOAD_COUNT) 142 private void setDownloadCount(final Integer downloadCount) { 143 put(FIELD_DOWNLOAD_COUNT, downloadCount); 144 } 145 146 /** 147 * Get the time to unshare this link. This returns a String and can be parsed into {@link java.util.Date} by 148 * 149 * @return the unshared_at 150 */ 151 @JsonProperty(FIELD_UNSHARED_AT) 152 public String getUnsharedAt() { 153 return (String) getValue(FIELD_UNSHARED_AT); 154 } 155 156 /** 157 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 158 * 159 * @param unsharedAt the unshared_at to set 160 */ 161 @JsonProperty(FIELD_UNSHARED_AT) 162 private void setUnsharedAt(final String unsharedAt) { 163 put(FIELD_UNSHARED_AT, unsharedAt); 164 } 165 166 /** 167 * Get the preview count. 168 * 169 * @return the preview_count 170 */ 171 @JsonProperty(FIELD_PREVIEW_COUNT) 172 public Integer getPreviewCount() { 173 return (Integer) getValue(FIELD_PREVIEW_COUNT); 174 } 175 176 /** 177 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 178 * 179 * @param previewCount the preview_count to set 180 */ 181 @JsonProperty(FIELD_PREVIEW_COUNT) 182 private void setPreviewCount(final Integer previewCount) { 183 put(FIELD_PREVIEW_COUNT, previewCount); 184 } 185 186 /** 187 * Get access. This can only be the strings defined in {@link com.box .boxjavalibv2.dao.BoxSharedLinkAccess} 188 * 189 * @return the access 190 */ 191 @JsonProperty(FIELD_ACCESS) 192 public String getAccess() { 193 return (String) getValue(FIELD_ACCESS); 194 } 195 196 /** 197 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 198 * 199 * @param accessLevel the access to set 200 */ 201 @JsonProperty(FIELD_ACCESS) 202 private void setAccess(final String accessLevel) { 203 put(FIELD_ACCESS, accessLevel); 204 } 205 206 /** 207 * Get permissions. 208 * 209 * @return the permissions 210 */ 211 @JsonProperty(FIELD_PERMISSIONS) 212 public BoxSharedLinkPermissions getPermissions() { 213 return (BoxSharedLinkPermissions) getValue(FIELD_PERMISSIONS); 214 } 215 216 /** 217 * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>} 218 * 219 * @param permissionsEntity the permissions to set 220 */ 221 @JsonProperty(FIELD_PERMISSIONS) 222 private void setPermissions(final BoxSharedLinkPermissions permissionsEntity) { 223 put(FIELD_PERMISSIONS, permissionsEntity); 224 } 225}