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