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