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.repositorydata.ModifiableRepositoryData;
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    /**
032     * Retrieves the composite at the given path
033     * @param compositePath path of the composite to retrieve
034     * @param createNew <code>true</code> to create the composite if it does not exist, <code>false</code> otherwise
035     * @return the composite or <code>null</code> if createNew is <code>false</code> and value not exists or is empty
036     * @throws IllegalArgumentException if the given composite path is null or empty
037     * @throws BadItemTypeException if the stored value at the given path is not a composite
038     */
039    public ModifiableComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, BadItemTypeException;
040    
041    /**
042     * Removes the stored value of the data at the given path
043     * @param dataPath path of the data
044     * @throws IllegalArgumentException if the given data path is null or empty
045     * @throws UnknownDataException if the value at the given data path does not exist
046     * @throws BadItemTypeException if the value of the parent of the given path is not an item container
047     */
048    public void removeValue(String dataPath) throws IllegalArgumentException, UnknownDataException, BadItemTypeException;
049    
050    @Override
051    public ModifiableRepositoryData getRepositoryData();
052}