001/* 002 * Copyright 2017 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.rights.solrchecking; 017 018import org.apache.cocoon.environment.Request; 019 020import org.ametys.core.right.RightManager; 021import org.ametys.plugins.repository.AmetysObject; 022import org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint; 023 024/** 025 * Extension point used by {@link AllowedUsersByObjectAction} before ({@link #beforeGettingAllowedUsers(AmetysObject, Request)}) 026 * and after ({@link #afterGettingAllowedUsers(AmetysObject, Request)}) calling {@link RightManager#getReadAccessAllowedUsers(Object)} 027 * for doing additional operations (for instance, setting some request attributes needed by the {@link RightManager}). 028 */ 029public class AllowedUsersActionAdditionalOperationsExtensionPoint extends AbstractThreadSafeComponentExtensionPoint<AllowedUsersActionAdditionalOperations> 030{ 031 /** Avalon Role */ 032 public static final String ROLE = AllowedUsersActionAdditionalOperationsExtensionPoint.class.getName(); 033 034 /** 035 * Do additional operations before {@link AllowedUsersByObjectAction} calls {@link RightManager#getReadAccessAllowedUsers(Object)} 036 * @param ametysObject The AmetysObject which will be passed to {@link RightManager#getReadAccessAllowedUsers(Object)} 037 * @param request The current request 038 */ 039 void beforeGettingAllowedUsers(AmetysObject ametysObject, Request request) 040 { 041 getExtensionsIds().stream().map(this::getExtension).forEach(ext -> 042 { 043 try 044 { 045 ext.beforeGettingAllowedUsers(ametysObject, request); 046 } 047 catch (Exception e) 048 { 049 getLogger().error("An exception occured in 'beforeGettingAllowedUsers' with " + ext, e); 050 } 051 }); 052 } 053 054 /** 055 * Do additional operations after {@link AllowedUsersByObjectAction} calls {@link RightManager#getReadAccessAllowedUsers(Object)} 056 * @param ametysObject The AmetysObject which will be passed to {@link RightManager#getReadAccessAllowedUsers(Object)} 057 * @param request The current request 058 */ 059 void afterGettingAllowedUsers(AmetysObject ametysObject, Request request) 060 { 061 getExtensionsIds().stream().map(this::getExtension).forEach(ext -> 062 { 063 try 064 { 065 ext.afterGettingAllowedUsers(ametysObject, request); 066 } 067 catch (Exception e) 068 { 069 getLogger().error("An exception occured in 'afterGettingAllowedUsers' with " + ext, e); 070 } 071 }); 072 } 073}