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 * @return the modified SQL query 062 */ 063 public String replacePermissionCheck( 064 String sql, String className, String classPKField); 065 066 /** 067 * Modifies the SQL query to only match resources that the user has 068 * permission to view. 069 * 070 * @param sql the SQL query 071 * @param className the fully qualified class name of the resources matched 072 * by the query 073 * @param classPKField the name of the column containing the resource's 074 * primary key 075 * @param groupId the primary key of the group containing the resources 076 * (optionally <code>null</code>) 077 * @return the modified SQL query 078 */ 079 public String replacePermissionCheck( 080 String sql, String className, String classPKField, long groupId); 081 082 /** 083 * Modifies the SQL query to only match resources that the user has 084 * permission to view. 085 * 086 * @param sql the SQL query 087 * @param className the fully qualified class name of the resources matched 088 * by the query 089 * @param classPKField the name of the column containing the resource's 090 * primary key 091 * @param groupId the primary key of the group containing the resources 092 * (optionally <code>null</code>) 093 * @param bridgeJoin an additional join clause to insert before the 094 * permission join (optionally <code>null</code>) 095 * @return the modified SQL query 096 */ 097 public String replacePermissionCheck( 098 String sql, String className, String classPKField, long groupId, 099 String bridgeJoin); 100 101 /** 102 * Modifies the SQL query to only match resources that the user has 103 * permission to view. 104 * 105 * @param sql the SQL query 106 * @param className the fully qualified class name of the resources matched 107 * by the query 108 * @param classPKField the name of the column containing the resource's 109 * primary key 110 * @param groupIds the primary keys of the groups containing the resources 111 * (optionally <code>null</code>) 112 * @return the modified SQL query 113 */ 114 public String replacePermissionCheck( 115 String sql, String className, String classPKField, long[] groupIds); 116 117 /** 118 * Modifies the SQL query to only match resources that the user has 119 * permission to view. 120 * 121 * @param sql the SQL query 122 * @param className the fully qualified class name of the resources matched 123 * by the query 124 * @param classPKField the name of the column containing the resource's 125 * primary key 126 * @param groupIds the primary keys of the groups containing the resources 127 * (optionally <code>null</code>) 128 * @param bridgeJoin an additional join clause to insert before the 129 * permission join (optionally <code>null</code>) 130 * @return the modified SQL query 131 */ 132 public String replacePermissionCheck( 133 String sql, String className, String classPKField, long[] groupIds, 134 String bridgeJoin); 135 136 /** 137 * Modifies the SQL query to only match resources that the user has 138 * permission to view. 139 * 140 * @param sql the SQL query 141 * @param className the fully qualified class name of the resources matched 142 * by the query 143 * @param classPKField the name of the column containing the resource's 144 * primary key 145 * @param userIdField the name of the column containing the resource 146 * owner's primary key (optionally <code>null</code>) 147 * @return the modified SQL query 148 */ 149 public String replacePermissionCheck( 150 String sql, String className, String classPKField, String userIdField); 151 152 /** 153 * Modifies the SQL query to only match resources that the user has 154 * permission to view. 155 * 156 * @param sql the SQL query 157 * @param className the fully qualified class name of the resources matched 158 * by the query 159 * @param classPKField the name of the column containing the resource's 160 * primary key 161 * @param userIdField the name of the column containing the resource 162 * owner's primary key (optionally <code>null</code>) 163 * @param groupId the primary key of the group containing the resources 164 * (optionally <code>null</code>) 165 * @return the modified SQL query 166 */ 167 public String replacePermissionCheck( 168 String sql, String className, String classPKField, String userIdField, 169 long groupId); 170 171 /** 172 * Modifies the SQL query to only match resources that the user has 173 * permission to view. 174 * 175 * @param sql the SQL query 176 * @param className the fully qualified class name of the resources matched 177 * by the query 178 * @param classPKField the name of the column containing the resource's 179 * primary key 180 * @param userIdField the name of the column containing the resource 181 * owner's primary key (optionally <code>null</code>) 182 * @param groupId the primary key of the group containing the resources 183 * (optionally <code>null</code>) 184 * @param bridgeJoin an additional join clause to insert before the 185 * permission join (optionally <code>null</code>) 186 * @return the modified SQL query 187 */ 188 public String replacePermissionCheck( 189 String sql, String className, String classPKField, String userIdField, 190 long groupId, String bridgeJoin); 191 192 /** 193 * Modifies the SQL query to only match resources that the user has 194 * permission to view. 195 * 196 * @param sql the SQL query 197 * @param className the fully qualified class name of the resources matched 198 * by the query 199 * @param classPKField the name of the column containing the resource's 200 * primary key 201 * @param userIdField the name of the column containing the resource 202 * owner's primary key (optionally <code>null</code>) 203 * @param groupIds the primary keys of the groups containing the resources 204 * (optionally <code>null</code>) 205 * @return the modified SQL query 206 */ 207 public String replacePermissionCheck( 208 String sql, String className, String classPKField, String userIdField, 209 long[] groupIds); 210 211 /** 212 * Modifies the SQL query to only match resources that the user has 213 * permission to view. 214 * 215 * @param sql the SQL query 216 * @param className the fully qualified class name of the resources matched 217 * by the query 218 * @param classPKField the name of the column containing the resource's 219 * primary key 220 * @param userIdField the name of the column containing the resource 221 * owner's primary key (optionally <code>null</code>) 222 * @param groupIds the primary keys of the groups containing the resources 223 * (optionally <code>null</code>) 224 * @param bridgeJoin an additional join clause to insert before the 225 * permission join (optionally <code>null</code>) 226 * @return the modified SQL query 227 */ 228 public String replacePermissionCheck( 229 String sql, String className, String classPKField, String userIdField, 230 long[] groupIds, String bridgeJoin); 231 232 /** 233 * Modifies the SQL query to only match resources that the user has 234 * permission to view. 235 * 236 * @param sql the SQL query 237 * @param className the fully qualified class name of the resources matched 238 * by the query 239 * @param classPKField the name of the column containing the resource's 240 * primary key 241 * @param userIdField the name of the column containing the resource 242 * owner's primary key (optionally <code>null</code>) 243 * @param bridgeJoin an additional join clause to insert before the 244 * permission join (optionally <code>null</code>) 245 * @return the modified SQL query 246 */ 247 public String replacePermissionCheck( 248 String sql, String className, String classPKField, String userIdField, 249 String bridgeJoin); 250 251 /** 252 * Modifies the SQL query to only match resources that the user has 253 * permission to view. 254 * 255 * @param sql the SQL query 256 * @param className the fully qualified class name of the resources matched 257 * by the query 258 * @param classPKField the name of the column containing the resource's 259 * primary key 260 * @param userIdField the name of the column containing the resource 261 * owner's primary key (optionally <code>null</code>) 262 * @param groupIdField the name of the column containing the resource's 263 * group ID (optionally <code>null</code>) 264 * @param groupIds the primary keys of the groups containing the resources 265 * (optionally <code>null</code>) 266 * @param bridgeJoin an additional join clause to insert before the 267 * permission join (optionally <code>null</code>) 268 * @return the modified SQL query 269 */ 270 public String replacePermissionCheck( 271 String sql, String className, String classPKField, String userIdField, 272 String groupIdField, long[] groupIds, String bridgeJoin); 273 274 }