001/* 002 * Copyright 2010 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.repository.metadata; 017 018import java.util.Date; 019import java.util.Locale; 020 021import org.ametys.core.user.UserIdentity; 022import org.ametys.plugins.repository.AmetysRepositoryException; 023import org.ametys.plugins.repository.ModifiableTraversableAmetysObject; 024import org.ametys.plugins.repository.TraversableAmetysObject; 025 026/** 027 * Modifiable {@link CompositeMetadata}. 028 */ 029public interface ModifiableCompositeMetadata extends CompositeMetadata 030{ 031 /** 032 * Rename the current metadata 033 * @param newName the new name 034 * @throws AmetysRepositoryException if an error occurs. 035 */ 036 public void rename(String newName) throws AmetysRepositoryException; 037 038 /** 039 * Removes the given metadata. 040 * @param metadataName metadata name. 041 * @throws UnknownMetadataException if the metadata does not exist. 042 * @throws AmetysRepositoryException if an error occurs. 043 */ 044 public void removeMetadata(String metadataName) throws UnknownMetadataException, AmetysRepositoryException; 045 046 /** 047 * Returns the named metadata's value as {@link BinaryMetadata}.<br> 048 * If the metadata does not exist and createNew is <code>false</code>, an {@link UnknownMetadataException} is thrown. 049 * Otherwise, the metadata is automatically created. 050 * @param metadataName the metadata name. 051 * @param createNew <code>true</code> to create automatically the {@link BinaryMetadata} when missing. 052 * @return the metadata value as BinaryMetadata. 053 * @throws UnknownMetadataException if the named metadata does not exist. 054 * @throws AmetysRepositoryException if an error occurs. 055 */ 056 public ModifiableBinaryMetadata getBinaryMetadata(String metadataName, boolean createNew) throws UnknownMetadataException, AmetysRepositoryException; 057 058 public ModifiableBinaryMetadata getBinaryMetadata(String metadataName) throws UnknownMetadataException, AmetysRepositoryException; 059 060 /** 061 * Returns the named metadata's value as {@link RichText}.<br> 062 * If the metadata does not exist and createNew is <code>false</code>, an {@link UnknownMetadataException} is thrown. 063 * Otherwise, the metadata is automatically created. 064 * @param metadataName the metadata name. 065 * @param createNew <code>true</code> to create automatically the {@link BinaryMetadata} when missing. 066 * @return the metadata value as RichText. 067 * @throws UnknownMetadataException if the named metadata does not exist. 068 * @throws AmetysRepositoryException if an error occurs. 069 */ 070 public ModifiableRichText getRichText(String metadataName, boolean createNew) throws UnknownMetadataException, AmetysRepositoryException; 071 072 public ModifiableRichText getRichText(String metadataName) throws UnknownMetadataException, AmetysRepositoryException; 073 074 @Override 075 public ModifiableCompositeMetadata getCompositeMetadata(String metadataName) throws UnknownMetadataException, AmetysRepositoryException; 076 077 /** 078 * Returns the named metadata's value as {@link CompositeMetadata}.<br> 079 * If the metadata is multi-valued, one of the value is returned.<br> 080 * If the metadata does not exist and createNew is <code>false</code>, an {@link UnknownMetadataException} is thrown. Otherwise, the metadata is automatically created. 081 * @param metadataName the metadata name. 082 * @param createNew <code>true</code> to create automatically the {@link CompositeMetadata} when missing. 083 * @return the metadata value as {@link CompositeMetadata}. 084 * @throws UnknownMetadataException if the named metadata does not exist. 085 * @throws AmetysRepositoryException if an error occurs. 086 */ 087 public ModifiableCompositeMetadata getCompositeMetadata(String metadataName, boolean createNew) throws UnknownMetadataException, AmetysRepositoryException; 088 089 @Override 090 ModifiableTraversableAmetysObject getObjectCollection(String metadataName) throws AmetysRepositoryException; 091 092 /** 093 * Returns an object collection metadata as a {@link TraversableAmetysObject}<br>. 094 * If the metadata does not exist and createNew is <code>false</code>, an {@link UnknownMetadataException} is thrown. Otherwise, the metadata is automatically created. 095 * @param metadataName the metadata name. 096 * @param createNew <code>true</code> to create automatically the {@link CompositeMetadata} when missing. 097 * @return the metadata as a {@link TraversableAmetysObject}. 098 * @throws UnknownMetadataException if the named metadata does not exist. 099 * @throws AmetysRepositoryException if an error occurs. 100 */ 101 ModifiableTraversableAmetysObject getObjectCollection(String metadataName, boolean createNew) throws AmetysRepositoryException; 102 103 /** 104 * Set a string metadata. 105 * @param metadataName the metadata name. 106 * @param value the String value of this metadata. 107 * @throws AmetysRepositoryException if the metadata cannot be set. 108 */ 109 public void setMetadata(String metadataName, String value) throws AmetysRepositoryException; 110 111 /** 112 * Set a multilingual string metadata. 113 * @param metadataName the metadata name. 114 * @param value the String value of this metadata in the given locale. 115 * @param locale The value of locale 116 * @throws AmetysRepositoryException if the metadata cannot be set. 117 */ 118 public void setMetadata(String metadataName, String value, Locale locale) throws AmetysRepositoryException; 119 120 /** 121 * Set a date metadata. 122 * @param metadataName the metadata name. 123 * @param value the Date value of this metadata. 124 * @throws AmetysRepositoryException if the metadata cannot be set. 125 */ 126 public void setMetadata(String metadataName, Date value) throws AmetysRepositoryException; 127 128 /** 129 * Set a long metadata. 130 * @param metadataName the metadata name. 131 * @param value the integer value of this metadata. 132 * @throws AmetysRepositoryException if the metadata cannot be set. 133 */ 134 public void setMetadata(String metadataName, long value) throws AmetysRepositoryException; 135 136 /** 137 * Set a double metadata. 138 * @param metadataName the metadata name. 139 * @param value the integer value of this metadata. 140 * @throws AmetysRepositoryException if the metadata cannot be set. 141 */ 142 public void setMetadata(String metadataName, double value) throws AmetysRepositoryException; 143 144 /** 145 * Set a boolean metadata. 146 * @param metadataName the metadata name. 147 * @param value the boolean value of this metadata. 148 * @throws AmetysRepositoryException if the metadata cannot be set. 149 */ 150 public void setMetadata(String metadataName, boolean value) throws AmetysRepositoryException; 151 152 /** 153 * Set a {@link UserIdentity} metadata. 154 * @param metadataName the metadata name. 155 * @param value the {@link UserIdentity} value of this metadata. 156 * @throws AmetysRepositoryException if the metadata cannot be set. 157 */ 158 public void setMetadata(String metadataName, UserIdentity value) throws AmetysRepositoryException; 159 160 /** 161 * Set a multi-valued string metadata. 162 * @param metadataName the metadata name. 163 * @param values the String array containing values of this metadata. 164 * @throws AmetysRepositoryException if the metadata cannot be set. 165 */ 166 public void setMetadata(String metadataName, String[] values) throws AmetysRepositoryException; 167 168 /** 169 * Set a multi-valued date metadata. 170 * @param metadataName the metadata name. 171 * @param values the Date array containing values of this metadata. 172 * @throws AmetysRepositoryException if the metadata cannot be set. 173 */ 174 public void setMetadata(String metadataName, Date[] values) throws AmetysRepositoryException; 175 176 /** 177 * Set a multi-valued long metadata. 178 * @param metadataName the metadata name. 179 * @param values the integer array containing values of this metadata. 180 * @throws AmetysRepositoryException if the metadata cannot be set. 181 */ 182 public void setMetadata(String metadataName, long[] values) throws AmetysRepositoryException; 183 184 /** 185 * Set a multi-valued double metadata. 186 * @param metadataName the metadata name. 187 * @param values the integer array containing values of this metadata. 188 * @throws AmetysRepositoryException if the metadata cannot be set. 189 */ 190 public void setMetadata(String metadataName, double[] values) throws AmetysRepositoryException; 191 192 /** 193 * Set a multi-valued boolean metadata. 194 * @param metadataName the metadata name. 195 * @param values the boolean array containing values of this metadata. 196 * @throws AmetysRepositoryException if the metadata cannot be set. 197 */ 198 public void setMetadata(String metadataName, boolean[] values) throws AmetysRepositoryException; 199 200 /** 201 * Set a multi-valued {@link UserIdentity} metadata. 202 * @param metadataName the metadata name. 203 * @param values the {@link UserIdentity} array containing values of this metadata. 204 * @throws AmetysRepositoryException if the metadata cannot be set. 205 */ 206 public void setMetadata(String metadataName, UserIdentity[] values) throws AmetysRepositoryException; 207 208 /** 209 * Set a {@link MultilingualString} metadata. 210 * @param metadataName the metadata name. 211 * @param value the {@link MultilingualString} value 212 * @throws AmetysRepositoryException if the metadata cannot be set. 213 */ 214 public void setMetadata(String metadataName, MultilingualString value) throws AmetysRepositoryException; 215}