001 /** 002 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.security.permission; 016 017 /** 018 * Provides utility methods for filtering SQL queries by the user's permissions. 019 * 020 * @author Raymond Aug?? 021 */ 022 public interface InlineSQLHelper { 023 024 /** 025 * Returns <code>true</code> if the inline SQL helper is enabled. 026 * 027 * @return <code>true</code> if the inline SQL helper is enabled; 028 * <code>false</code> otherwise 029 */ 030 public boolean isEnabled(); 031 032 /** 033 * Returns <code>true</code> if the inline SQL helper is enabled for the 034 * group. 035 * 036 * @param groupId the primary key of the group 037 * @return <code>true</code> if the inline SQL helper is enabled for the 038 * group; <code>false</code> otherwise 039 */ 040 public boolean isEnabled(long groupId); 041 042 /** 043 * Returns <code>true</code> if the inline SQL helper is enabled for the 044 * groups. 045 * 046 * @param groupIds the primary keys of the groups 047 * @return <code>true</code> if the inline SQL helper is enabled for the 048 * groups; <code>false</code> otherwise 049 */ 050 public boolean isEnabled(long[] groupIds); 051 052 /** 053 * Modifies the SQL query to only match resources that the user has 054 * permission to view. 055 * 056 * @param sql the SQL query 057 * @param className the fully qualified class name of the resources matched 058 * by the query 059 * @param classPKField the name of the column containing the resource's 060 * primary key 061 */ 062 public String replacePermissionCheck( 063 String sql, String className, String classPKField); 064 065 /** 066 * Modifies the SQL query to only match resources that the user has 067 * permission to view. 068 * 069 * @param sql the SQL query 070 * @param className the fully qualified class name of the resources matched 071 * by the query 072 * @param classPKField the name of the column containing the resource's 073 * primary key 074 * @param groupId the primary key of the group containing the resources 075 * (optionally <code>null</code>) 076 */ 077 public String replacePermissionCheck( 078 String sql, String className, String classPKField, long groupId); 079 080 /** 081 * Modifies the SQL query to only match resources that the user has 082 * permission to view. 083 * 084 * @param sql the SQL query 085 * @param className the fully qualified class name of the resources matched 086 * by the query 087 * @param classPKField the name of the column containing the resource's 088 * primary key 089 * @param groupId the primary key of the group containing the resources 090 * (optionally <code>null</code>) 091 * @param bridgeJoin an additional join clause to insert before the 092 * permission join (optionally <code>null</code>) 093 */ 094 public String replacePermissionCheck( 095 String sql, String className, String classPKField, long groupId, 096 String bridgeJoin); 097 098 /** 099 * Modifies the SQL query to only match resources that the user has 100 * permission to view. 101 * 102 * @param sql the SQL query 103 * @param className the fully qualified class name of the resources matched 104 * by the query 105 * @param classPKField the name of the column containing the resource's 106 * primary key 107 * @param groupIds the primary keys of the groups containing the resources 108 * (optionally <code>null</code>) 109 */ 110 public String replacePermissionCheck( 111 String sql, String className, String classPKField, long[] groupIds); 112 113 /** 114 * Modifies the SQL query to only match resources that the user has 115 * permission to view. 116 * 117 * @param sql the SQL query 118 * @param className the fully qualified class name of the resources matched 119 * by the query 120 * @param classPKField the name of the column containing the resource's 121 * primary key 122 * @param groupIds the primary keys of the groups containing the resources 123 * (optionally <code>null</code>) 124 * @param bridgeJoin an additional join clause to insert before the 125 * permission join (optionally <code>null</code>) 126 */ 127 public String replacePermissionCheck( 128 String sql, String className, String classPKField, long[] groupIds, 129 String bridgeJoin); 130 131 /** 132 * Modifies the SQL query to only match resources that the user has 133 * permission to view. 134 * 135 * @param sql the SQL query 136 * @param className the fully qualified class name of the resources matched 137 * by the query 138 * @param classPKField the name of the column containing the resource's 139 * primary key 140 * @param userIdField the name of the column containing the resource 141 * owner's primary key (optionally <code>null</code>) 142 */ 143 public String replacePermissionCheck( 144 String sql, String className, String classPKField, String userIdField); 145 146 /** 147 * Modifies the SQL query to only match resources that the user has 148 * permission to view. 149 * 150 * @param sql the SQL query 151 * @param className the fully qualified class name of the resources matched 152 * by the query 153 * @param classPKField the name of the column containing the resource's 154 * primary key 155 * @param userIdField the name of the column containing the resource 156 * owner's primary key (optionally <code>null</code>) 157 * @param groupId the primary key of the group containing the resources 158 * (optionally <code>null</code>) 159 */ 160 public String replacePermissionCheck( 161 String sql, String className, String classPKField, String userIdField, 162 long groupId); 163 164 /** 165 * Modifies the SQL query to only match resources that the user has 166 * permission to view. 167 * 168 * @param sql the SQL query 169 * @param className the fully qualified class name of the resources matched 170 * by the query 171 * @param classPKField the name of the column containing the resource's 172 * primary key 173 * @param userIdField the name of the column containing the resource 174 * owner's primary key (optionally <code>null</code>) 175 * @param groupId the primary key of the group containing the resources 176 * (optionally <code>null</code>) 177 * @param bridgeJoin an additional join clause to insert before the 178 * permission join (optionally <code>null</code>) 179 */ 180 public String replacePermissionCheck( 181 String sql, String className, String classPKField, String userIdField, 182 long groupId, String bridgeJoin); 183 184 /** 185 * Modifies the SQL query to only match resources that the user has 186 * permission to view. 187 * 188 * @param sql the SQL query 189 * @param className the fully qualified class name of the resources matched 190 * by the query 191 * @param classPKField the name of the column containing the resource's 192 * primary key 193 * @param userIdField the name of the column containing the resource 194 * owner's primary key (optionally <code>null</code>) 195 * @param groupIds the primary keys of the groups containing the resources 196 * (optionally <code>null</code>) 197 */ 198 public String replacePermissionCheck( 199 String sql, String className, String classPKField, String userIdField, 200 long[] groupIds); 201 202 /** 203 * Modifies the SQL query to only match resources that the user has 204 * permission to view. 205 * 206 * @param sql the SQL query 207 * @param className the fully qualified class name of the resources matched 208 * by the query 209 * @param classPKField the name of the column containing the resource's 210 * primary key 211 * @param userIdField the name of the column containing the resource 212 * owner's primary key (optionally <code>null</code>) 213 * @param groupIds the primary keys of the groups containing the resources 214 * (optionally <code>null</code>) 215 * @param bridgeJoin an additional join clause to insert before the 216 * permission join (optionally <code>null</code>) 217 */ 218 public String replacePermissionCheck( 219 String sql, String className, String classPKField, String userIdField, 220 long[] groupIds, String bridgeJoin); 221 222 /** 223 * Modifies the SQL query to only match resources that the user has 224 * permission to view. 225 * 226 * @param sql the SQL query 227 * @param className the fully qualified class name of the resources matched 228 * by the query 229 * @param classPKField the name of the column containing the resource's 230 * primary key 231 * @param userIdField the name of the column containing the resource 232 * owner's primary key (optionally <code>null</code>) 233 * @param bridgeJoin an additional join clause to insert before the 234 * permission join (optionally <code>null</code>) 235 */ 236 public String replacePermissionCheck( 237 String sql, String className, String classPKField, String userIdField, 238 String bridgeJoin); 239 240 /** 241 * Modifies the SQL query to only match resources that the user has 242 * permission to view. 243 * 244 * @param sql the SQL query 245 * @param className the fully qualified class name of the resources matched 246 * by the query 247 * @param classPKField the name of the column containing the resource's 248 * primary key 249 * @param userIdField the name of the column containing the resource 250 * owner's primary key (optionally <code>null</code>) 251 * @param groupIdField the name of the column containing the resource's 252 * group ID (optionally <code>null</code>) 253 * @param groupIds the primary keys of the groups containing the resources 254 * (optionally <code>null</code>) 255 * @param bridgeJoin an additional join clause to insert before the 256 * permission join (optionally <code>null</code>) 257 * @return the modified SQL query 258 */ 259 public String replacePermissionCheck( 260 String sql, String className, String classPKField, String userIdField, 261 String groupIdField, long[] groupIds, String bridgeJoin); 262 263 }