001/* 002 * Copyright 2026 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.trash.observer; 017 018import java.util.Map; 019 020import org.ametys.core.observation.Event; 021 022/** 023 * Helper providing methods to manipulate {@link Event} related to trash. 024 */ 025public final class TrashObserverHelper 026{ 027 /** Argument when an element is restored from the trash, used to indicate to observers that the object was created by restoration */ 028 public static final String ARGS_ORIGIN_RESTORED = "event.origin.trash.restored"; 029 030 private TrashObserverHelper() 031 { 032 // Empty constructor 033 } 034 035 /** 036 * Get the event and check if it is an event created by a trash restore event. 037 * @param event The event 038 * @return true if it is an event created by a trash restore event 039 */ 040 public static Boolean isFromRestoredEvent(Event event) 041 { 042 Map<String, Object> arguments = event.getArguments(); 043 return (Boolean) arguments.getOrDefault(ARGS_ORIGIN_RESTORED, false); 044 } 045}