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.content; 017 018import java.util.Map; 019 020import org.ametys.core.ui.Callable; 021import org.ametys.plugins.core.ui.util.ParameterEnumeratorHelper; 022import org.ametys.runtime.model.Enumerator; 023 024/** 025 * Helper for getting entries from a {@link ContentQueryEnumerator} 026 * Used by edition.content-enumerator-combobox widget 027 */ 028public class ContentQueryEnumeratorHelper extends ParameterEnumeratorHelper 029{ 030 @Override 031 @Callable (rights = Callable.CHECKED_BY_IMPLEMENTATION) 032 public Map<String, Object> getEntries(String enumeratorRole) throws Exception 033 { 034 Enumerator enumerator = (Enumerator) _manager.lookup(enumeratorRole); 035 036 if (enumerator instanceof ContentQueryEnumerator) 037 { 038 // check of read access on contents is in charge of ContentQueryEnumerator 039 return getEntries(enumerator); 040 } 041 042 // only a ContentQueryEnumerator is allowed 043 throw new IllegalArgumentException("Callable method ContentQueryEnumeratorHelper#getEntries can not be called with enumerator '" + enumeratorRole + "' that is not a org.ametys.cms.content.ContentQueryEnumerator"); 044 } 045 046}