001/*
002 * (C) Copyright 2019 Nuxeo (http://nuxeo.com/) and others.
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 *
016 * Contributors:
017 *     Kevin Leturc <kleturc@nuxeo.com>
018 */
019package org.nuxeo.ecm.core.schema;
020
021import java.util.Optional;
022import java.util.Set;
023
024/**
025 * Handler used to provide property's characteristics.
026 *
027 * @since 11.1
028 */
029public interface PropertyCharacteristicHandler {
030
031    /**
032     * Checks if the property represented by the given {@code schema} and {@code path} is secured.
033     *
034     * @param schema the schema name
035     * @param path the property path to test
036     * @return whether or not the given property is secured (ie: only administrators can edit it)
037     */
038    boolean isSecured(String schema, String path);
039
040    /**
041     * Checks if the property represented by the given {@code schema} and {@code path} is deprecated.
042     *
043     * @param schema the schema name (not the prefix)
044     * @param path the property path to test
045     * @return whether or not this property is marked as deprecated
046     */
047    boolean isDeprecated(String schema, String path);
048
049    /**
050     * Checks if the property represented by the given {@code schema} and {@code path} is removed.
051     *
052     * @param schema the schema name (not the prefix)
053     * @param path the property path to test
054     * @return whether or not this property is marked as removed
055     */
056    boolean isRemoved(String schema, String path);
057
058    /**
059     * The returned path are not Nuxeo xpath as they don't have the schema prefix.
060     *
061     * @param schema the schema name (not the prefix)
062     * @return a {@link Set} holding the deprecated property path
063     */
064    Set<String> getDeprecatedProperties(String schema);
065
066    /**
067     * The returned path are not Nuxeo xpath as they don't have the schema prefix.
068     *
069     * @param schema the schema name (not the prefix)
070     * @return a {@link Set} holding the removed property path
071     */
072    Set<String> getRemovedProperties(String schema);
073
074    /**
075     * Returns the fallback associated to this property if exist. Fallbacks exist when property is deprecated or
076     * removed.
077     *
078     * @param schema the schema name (not the prefix)
079     * @param path the property path to test
080     * @return fallback associated to this property if exist
081     */
082    Optional<String> getFallback(String schema, String path);
083}