001/* 002 * Copyright 2013 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.core.ui; 017 018import java.lang.annotation.ElementType; 019import java.lang.annotation.Retention; 020import java.lang.annotation.RetentionPolicy; 021import java.lang.annotation.Target; 022 023import org.apache.commons.lang.StringUtils; 024 025import org.ametys.core.right.RightAssignmentContext; 026 027/** 028 * Mark the annotated method as callable by a client-side component. 029 */ 030@Retention(RetentionPolicy.RUNTIME) 031@Target(ElementType.METHOD) 032public @interface Callable 033{ 034 /** Constant to use to explicitly do not check right */ 035 public static final String SKIP_BUILTIN_CHECK = StringUtils.EMPTY; 036 037 /** Constant to check read access */ 038 public static final String READ_ACCESS = "__READ_ACCESS"; 039 040 /** 041 * Indicate how to check multiple rights 042 */ 043 public enum RightMode 044 { 045 /** All the right must be allowed */ 046 AND, 047 /** At least one right must be allowed */ 048 OR 049 } 050 051 /** 052 * The ids of rights to be checked 053 * @return The ids or empty if there is no right protection 054 */ 055 public String[] rights() default SKIP_BUILTIN_CHECK; 056 057 /** 058 * The mode to use to check multiple rights 059 * @return The mode to use 060 */ 061 public RightMode rightMode() default RightMode.OR; 062 063 /** 064 * Determines if the method can be accessed by a anonymous user 065 * @return true if anonymous user is allowed 066 */ 067 public boolean allowAnonymous() default false; 068 069 /** 070 * The context to check the right. Defaults to '/${WorkspaceName}' 071 * @return The context 072 */ 073 public String context() default "/${WorkspaceName}"; 074 075 /** 076 * The id of a type of the {@link RightAssignmentContext} to use to convert JS object into into a Java object 077 * @return The id of the {@link RightAssignmentContext} 078 */ 079 public String rightContext() default ""; 080 081 /** 082 * The index of method's argument holding the context value to be converted by {@link RightAssignmentContext} 083 * @return The parameter's index 084 */ 085 public int paramIndex() default -1; 086}