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.referencetable; 017 018import java.util.Map; 019 020import org.ametys.core.ui.Callable; 021import org.ametys.plugins.repository.AmetysRepositoryException; 022import org.ametys.runtime.authentication.AccessDeniedException; 023 024import com.opensymphony.workflow.WorkflowException; 025 026/** 027 * Client side element to validate a candidate content 028 */ 029public class ValidateCandidateClientSideElement extends HierarchicalReferenceTableClientSideElement 030{ 031 /** Validate the candidate by removing the mixin from the content 032 * @param contentId The id of the content 033 * @param actionId the id of the workflow action 034 * @return The result in a Map 035 * @throws WorkflowException The Workflow Exception 036 * @throws AmetysRepositoryException The Ametys Repository Exception 037 */ 038 @Callable(rights = Callable.CHECKED_BY_IMPLEMENTATION) 039 public Map<String, Object> validateCandidate(String contentId, int actionId) throws AmetysRepositoryException, WorkflowException 040 { 041 if (hasRight(getRights(Map.of()))) 042 { 043 return _contentHelper.removeMixinType(contentId, HierarchicalReferenceTablesHelper.CANDIDATE_CONTENT_TYPE, actionId); 044 } 045 else 046 { 047 throw new AccessDeniedException(_currentUserProvider.getUser() + " tried to validate a candidate without sufficient rights"); 048 } 049 } 050}