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.io.IOException; 019import java.util.Map; 020 021import org.ametys.plugins.repository.data.UnknownDataException; 022import org.ametys.plugins.repository.data.holder.group.impl.ModifiableModelLessComposite; 023import org.ametys.runtime.model.exception.BadDataPathCardinalityException; 024import org.ametys.runtime.model.exception.BadItemTypeException; 025import org.ametys.runtime.model.exception.NotUniqueTypeException; 026import org.ametys.runtime.model.exception.UnknownTypeException; 027 028/** 029 * Interface for modifiable data containers without models 030 */ 031public interface ModifiableModelLessDataHolder extends ModifiableDataHolder, ModelLessDataHolder 032{ 033 @Override 034 public ModifiableModelLessComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, BadDataPathCardinalityException; 035 036 /** 037 * {@inheritDoc} 038 * @throws BadDataPathCardinalityException if the value of a part of the data path is multiple. Only the last part can be multiple 039 */ 040 @Override 041 public ModifiableModelLessComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, BadItemTypeException, BadDataPathCardinalityException; 042 043 /** 044 * Synchronizes the given values with the current ones 045 * @param values the values to synchronize 046 * @return <code>true</code> if some values have changed, <code>false</code> otherwise 047 * @throws IOException if an error occurs while synchronizing I/O data 048 * @throws UnknownTypeException if there is no available type compatible with a given value for this data holder's type extension point 049 * @throws NotUniqueTypeException if there is more than one available types compatibles with the a value for this data holder's type extension point 050 */ 051 public boolean synchronizeValues(Map<String, Object> values) throws UnknownTypeException, NotUniqueTypeException, IOException; 052 053 /** 054 * Sets the value of the data at the given path 055 * @param dataPath path of the data 056 * @param value the value to set. To empty a value, use {@link #setValue(String, Object, String)} with a <code>null</code> value 057 * @throws IllegalArgumentException if the given data path is null or empty 058 * @throws UnknownTypeException if there is no available type compatible with the given value for this data holder's type extension point 059 * @throws NotUniqueTypeException if there is more than one available types compatibles with the given value for this data holder's type extension point 060 * @throws UnknownDataException if given the data path is composed of an inexisting group 061 * @throws BadDataPathCardinalityException if the value of a part of the data path is multiple. Only the last part can be multiple 062 */ 063 public void setValue(String dataPath, Object value) throws IllegalArgumentException, UnknownTypeException, NotUniqueTypeException, UnknownDataException, BadDataPathCardinalityException; 064 065 /** 066 * Sets the value of the data at the given path 067 * @param dataPath path of the data 068 * @param value the value to set. Give <code>null</code> to empty the value. 069 * @param dataTypeId type identifier of the data 070 * @throws IllegalArgumentException if the given data path is null or empty 071 * @throws UnknownTypeException if the given type is not available for this data holder's type extension point 072 * @throws BadItemTypeException if the given type doesn't match the given value to set 073 * @throws UnknownDataException if the given data path is composed of an inexisting group 074 * @throws BadDataPathCardinalityException if the value of a part of the data path is multiple. Only the last part can be multiple 075 */ 076 public void setValue(String dataPath, Object value, String dataTypeId) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, UnknownDataException, BadDataPathCardinalityException; 077 078 /** 079 * {@inheritDoc} 080 * @throws BadDataPathCardinalityException if the value of a part of the data path is multiple. Only the last part can be multiple 081 */ 082 @Override 083 public void removeValue(String dataPath) throws IllegalArgumentException, UnknownDataException, BadItemTypeException, BadDataPathCardinalityException; 084}