001/* 002 * Copyright 2017 Anyware Services 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.ametys.plugins.linkdirectory; 017 018import java.io.InputStream; 019 020import org.ametys.core.group.GroupIdentity; 021import org.ametys.core.user.UserIdentity; 022import org.ametys.plugins.repository.AmetysRepositoryException; 023import org.ametys.plugins.repository.metadata.BinaryMetadata; 024 025/** 026 * A link in the directory. 027 */ 028public interface Link 029{ 030 /** Type of a link. */ 031 public enum LinkType 032 { 033 /** External URL */ 034 URL, 035 /** Internal page */ 036 PAGE 037 } 038 039 /** 040 * Get the URL. 041 * 042 * @return the link URL. 043 * @throws AmetysRepositoryException if an error occurs. 044 */ 045 public String getUrl() throws AmetysRepositoryException; 046 047 /** 048 * Set the URL. 049 * 050 * @param type The URL type 051 * @param url the link URL to set. 052 * @throws AmetysRepositoryException if an error occurs. 053 */ 054 public void setUrl(LinkType type, String url) throws AmetysRepositoryException; 055 056 /** 057 * Get the internal URL. 058 * 059 * @return the link internal URL. 060 * @throws AmetysRepositoryException if an error occurs. 061 */ 062 public String getInternalUrl() throws AmetysRepositoryException; 063 064 /** 065 * Set the internal URL. 066 * 067 * @param url the link internal URL to set. 068 * @throws AmetysRepositoryException if an error occurs. 069 */ 070 public void setInternalUrl(String url) throws AmetysRepositoryException; 071 072 /** 073 * Retrieves the linked URL type. 074 * 075 * @return the linked URL type. 076 * @throws AmetysRepositoryException if an error occurs. 077 */ 078 public LinkType getUrlType() throws AmetysRepositoryException; 079 080 /** 081 * Get the link title. 082 * 083 * @return the link title. 084 * @throws AmetysRepositoryException if an error occurs. 085 */ 086 public String getTitle() throws AmetysRepositoryException; 087 088 /** 089 * Set the title. 090 * 091 * @param title the link title to set. 092 * @throws AmetysRepositoryException if an error occurs. 093 */ 094 public void setTitle(String title) throws AmetysRepositoryException; 095 096 /** 097 * Get the link content. 098 * 099 * @return the link content. 100 * @throws AmetysRepositoryException if an error occurs. 101 */ 102 public String getContent() throws AmetysRepositoryException; 103 104 /** 105 * Set the content. 106 * 107 * @param content the link content to set. 108 * @throws AmetysRepositoryException if an error occurs. 109 */ 110 public void setContent(String content) throws AmetysRepositoryException; 111 112 /** 113 * Get the link alternative. 114 * 115 * @return the link alternative. 116 * @throws AmetysRepositoryException if an error occurs. 117 */ 118 public String getAlternative() throws AmetysRepositoryException; 119 120 /** 121 * Set the link alternative. 122 * 123 * @param alternative the link alternative to set. 124 * @throws AmetysRepositoryException if an error occurs. 125 */ 126 public void setAlternative(String alternative) throws AmetysRepositoryException; 127 128 /** 129 * Get the picture as a binary metadata. 130 * 131 * @return the picture as a binary metadata. 132 * @throws AmetysRepositoryException if an error occurs. 133 */ 134 public BinaryMetadata getExternalPicture() throws AmetysRepositoryException; 135 136 /** 137 * Set the picture from an external file. 138 * 139 * @param mimeType the file MIME type. 140 * @param filename the file name. 141 * @param stream an input stream on the file bytes. 142 * @throws AmetysRepositoryException if an error occurs. 143 */ 144 public void setExternalPicture(String mimeType, String filename, InputStream stream) throws AmetysRepositoryException; 145 146 /** 147 * Get the picture resource ID. 148 * 149 * @return the resource ID. 150 * @throws AmetysRepositoryException if an error occurs. 151 */ 152 public String getResourcePictureId() throws AmetysRepositoryException; 153 154 /** 155 * Set the picture from an explorer resource. 156 * 157 * @param resourceId the resource ID. 158 * @throws AmetysRepositoryException if an error occurs. 159 */ 160 public void setResourcePicture(String resourceId) throws AmetysRepositoryException; 161 162 /** 163 * Removes any picture currently assigned. 164 * 165 * @throws AmetysRepositoryException if an error occurs. 166 */ 167 public void setNoPicture() throws AmetysRepositoryException; 168 169 /** 170 * Get the picture type. 171 * 172 * @return the picture type. 173 * @throws AmetysRepositoryException if an error occurs. 174 */ 175 public String getPictureType() throws AmetysRepositoryException; 176 177 /** 178 * Set the picture type. 179 * 180 * @param type the picture type to set. 181 * @throws AmetysRepositoryException if an error occurs. 182 */ 183 public void setPictureType(String type) throws AmetysRepositoryException; 184 185 /** 186 * Get the picture alternative. 187 * 188 * @return the picture alternative. 189 * @throws AmetysRepositoryException if an error occurs. 190 */ 191 public String getPictureAlternative() throws AmetysRepositoryException; 192 193 /** 194 * Set the picture alternative. 195 * 196 * @param alternative the picture alternative to set. 197 * @throws AmetysRepositoryException if an error occurs. 198 */ 199 public void setPictureAlternative(String alternative) throws AmetysRepositoryException; 200 201 /** 202 * Get the themes. 203 * 204 * @return the themes in an Array 205 * @throws AmetysRepositoryException if an error occurs. 206 */ 207 public String[] getThemes() throws AmetysRepositoryException; 208 209 /** 210 * Set the themes. 211 * 212 * @param themes the themes to set. 213 * @throws AmetysRepositoryException if an error occurs. 214 */ 215 public void setThemes(String[] themes) throws AmetysRepositoryException; 216 217 /** 218 * Remove theme if exist 219 * 220 * @param themeId The id of theme to remove 221 * @throws AmetysRepositoryException if an error occurs 222 */ 223 public void removeTheme(String themeId) throws AmetysRepositoryException; 224 225 /** 226 * Get the list of granted users 227 * 228 * @return the users who have access to this link 229 * @throws AmetysRepositoryException if an error occurs 230 */ 231 public UserIdentity[] getGrantedUsers() throws AmetysRepositoryException; 232 233 /** 234 * Set the list of granted users 235 * 236 * @param grantedUsers the users who will have access to this link 237 * @throws AmetysRepositoryException if an error occurs 238 */ 239 public void setGrantedUsers(UserIdentity[] grantedUsers) throws AmetysRepositoryException; 240 241 /** 242 * Get the list of granted groups 243 * 244 * @return excludedGroups the groups who don't have access to this link 245 * @throws AmetysRepositoryException if an error occurs 246 */ 247 public GroupIdentity[] getGrantedGroups() throws AmetysRepositoryException; 248 249 /** 250 * Set the list of granted groups 251 * 252 * @param grantedGroups the groups who will have access to this link 253 * @throws AmetysRepositoryException if an exception occurs 254 */ 255 public void setGrantedGroups(GroupIdentity[] grantedGroups) throws AmetysRepositoryException; 256 257 /** 258 * Is any connected user allowed ? 259 * 260 * @return true if every connected user is allowed, false otherwise 261 * @throws AmetysRepositoryException if an exceptions occurs 262 */ 263 public boolean isAllowedAnyUser() throws AmetysRepositoryException; 264 265 /** 266 * Determines if any connected user will be granted access to this link, 267 * depending on the parameter's value 268 * 269 * @param allowAnyUser "true" to allow any connected user, "false" otherwise 270 * @throws AmetysRepositoryException if a an exception occurs while 271 * exploring the repository 272 */ 273 public void setGrantAnyUser(boolean allowAnyUser) throws AmetysRepositoryException; 274 275 /** 276 * Get the id of the provider of dynamic information. 277 * @return the id of provider. Can be null. 278 * @throws AmetysRepositoryException if an error occurs. 279 */ 280 public String getDynamicInformationProvider() throws AmetysRepositoryException; 281 282 /** 283 * Set the id of the provider of dynamic information. 284 * @param providerId the id of provider 285 * @throws AmetysRepositoryException if an error occurs. 286 */ 287 public void setDynamicInformationProvider(String providerId) throws AmetysRepositoryException; 288 289}