001/* 002 * Copyright 2025 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.cms.model.restrictions; 017 018import org.ametys.cms.repository.Content; 019 020/** 021 * Interface for restriction on content attributes 022 */ 023public interface Restriction 024{ 025 /** 026 * Enumeration for restrictions results 027 */ 028 public enum RestrictionResult 029 { 030 /** Restrictions are OK */ 031 TRUE, 032 033 /** Restrictions are not OK */ 034 FALSE, 035 036 /** There are more checks to do */ 037 UNKNOWN, 038 } 039 040 /** 041 * Determine whether a model item can be read at this time. 042 * @param content The content where item is to be written on. Can be null, on content creation. 043 * @param modelItem the model item on which check the restrictions 044 * @return The restriction result 045 */ 046 public RestrictionResult canRead(Content content, RestrictedModelItem modelItem); 047 048 /** 049 * Determine whether a model item can be written at this time. 050 * @param content The content where item is to be written on. Can be null, on content creation. 051 * @param modelItem the model item on which check the restrictions 052 * @return The restriction result 053 */ 054 public RestrictionResult canWrite(Content content, RestrictedModelItem modelItem); 055 056}