001/*
002 *  Copyright 2018 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.data.holder;
017
018import org.ametys.plugins.repository.data.UnknownDataException;
019import org.ametys.plugins.repository.data.holder.group.ModifiableComposite;
020import org.ametys.plugins.repository.data.holder.group.ModifiableRepeater;
021import org.ametys.runtime.model.exception.BadItemTypeException;
022
023/**
024 * Interface for modifiable data containers
025 */
026public interface ModifiableDataHolder extends DataHolder
027{
028    @Override
029    public ModifiableComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException;
030    
031    @Override
032    public ModifiableRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, BadItemTypeException;
033    
034    /**
035     * Retrieves the composite at the given path
036     * @param compositePath path of the composite to retrieve
037     * @param createNew <code>true</code> to create the composite if it does not exist, <code>false</code> otherwise
038     * @return the composite
039     * @throws IllegalArgumentException if the given composite path is null or empty
040     * @throws BadItemTypeException if the value stored in the repository at the given path is not a composite
041     */
042    public ModifiableComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, BadItemTypeException;
043    
044    /**
045     * Retrieves the repeater at the given path
046     * @param repeaterPath path of the repeater to retrieve
047     * @param createNew <code>true</code> to create the repeater if it does not exist, <code>false</code> otherwise
048     * @return the repeater
049     * @throws IllegalArgumentException if the given repeater path is null or empty
050     * @throws BadItemTypeException if the value stored in the repository at the given path is not a repeater
051     */
052    public ModifiableRepeater getRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, BadItemTypeException;
053    
054    /**
055     * Removes the value of the data stored in the repository at the given path
056     * @param dataPath path of the data
057     * @throws IllegalArgumentException if the given data path is null or empty
058     * @throws UnknownDataException if the value at the given data path does not exist
059     */
060    public void removeValue(String dataPath) throws IllegalArgumentException, UnknownDataException;
061}