1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.kernel.util.GetterUtil;
26 import com.liferay.portal.kernel.util.Validator;
27 import com.liferay.portal.model.ModelListener;
28 import com.liferay.portal.util.PropsUtil;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32
33
39 public class ResourceCodeUtil {
40 public static com.liferay.portal.model.ResourceCode create(long codeId) {
41 return getPersistence().create(codeId);
42 }
43
44 public static com.liferay.portal.model.ResourceCode remove(long codeId)
45 throws com.liferay.portal.SystemException,
46 com.liferay.portal.NoSuchResourceCodeException {
47 ModelListener listener = _getListener();
48
49 if (listener != null) {
50 listener.onBeforeRemove(findByPrimaryKey(codeId));
51 }
52
53 com.liferay.portal.model.ResourceCode resourceCode = getPersistence()
54 .remove(codeId);
55
56 if (listener != null) {
57 listener.onAfterRemove(resourceCode);
58 }
59
60 return resourceCode;
61 }
62
63 public static com.liferay.portal.model.ResourceCode remove(
64 com.liferay.portal.model.ResourceCode resourceCode)
65 throws com.liferay.portal.SystemException {
66 ModelListener listener = _getListener();
67
68 if (listener != null) {
69 listener.onBeforeRemove(resourceCode);
70 }
71
72 resourceCode = getPersistence().remove(resourceCode);
73
74 if (listener != null) {
75 listener.onAfterRemove(resourceCode);
76 }
77
78 return resourceCode;
79 }
80
81 public static com.liferay.portal.model.ResourceCode update(
82 com.liferay.portal.model.ResourceCode resourceCode)
83 throws com.liferay.portal.SystemException {
84 ModelListener listener = _getListener();
85 boolean isNew = resourceCode.isNew();
86
87 if (listener != null) {
88 if (isNew) {
89 listener.onBeforeCreate(resourceCode);
90 }
91 else {
92 listener.onBeforeUpdate(resourceCode);
93 }
94 }
95
96 resourceCode = getPersistence().update(resourceCode);
97
98 if (listener != null) {
99 if (isNew) {
100 listener.onAfterCreate(resourceCode);
101 }
102 else {
103 listener.onAfterUpdate(resourceCode);
104 }
105 }
106
107 return resourceCode;
108 }
109
110 public static com.liferay.portal.model.ResourceCode update(
111 com.liferay.portal.model.ResourceCode resourceCode, boolean merge)
112 throws com.liferay.portal.SystemException {
113 ModelListener listener = _getListener();
114 boolean isNew = resourceCode.isNew();
115
116 if (listener != null) {
117 if (isNew) {
118 listener.onBeforeCreate(resourceCode);
119 }
120 else {
121 listener.onBeforeUpdate(resourceCode);
122 }
123 }
124
125 resourceCode = getPersistence().update(resourceCode, merge);
126
127 if (listener != null) {
128 if (isNew) {
129 listener.onAfterCreate(resourceCode);
130 }
131 else {
132 listener.onAfterUpdate(resourceCode);
133 }
134 }
135
136 return resourceCode;
137 }
138
139 public static com.liferay.portal.model.ResourceCode findByPrimaryKey(
140 long codeId)
141 throws com.liferay.portal.SystemException,
142 com.liferay.portal.NoSuchResourceCodeException {
143 return getPersistence().findByPrimaryKey(codeId);
144 }
145
146 public static com.liferay.portal.model.ResourceCode fetchByPrimaryKey(
147 long codeId) throws com.liferay.portal.SystemException {
148 return getPersistence().fetchByPrimaryKey(codeId);
149 }
150
151 public static java.util.List findByCompanyId(long companyId)
152 throws com.liferay.portal.SystemException {
153 return getPersistence().findByCompanyId(companyId);
154 }
155
156 public static java.util.List findByCompanyId(long companyId, int begin,
157 int end) throws com.liferay.portal.SystemException {
158 return getPersistence().findByCompanyId(companyId, begin, end);
159 }
160
161 public static java.util.List findByCompanyId(long companyId, int begin,
162 int end, com.liferay.portal.kernel.util.OrderByComparator obc)
163 throws com.liferay.portal.SystemException {
164 return getPersistence().findByCompanyId(companyId, begin, end, obc);
165 }
166
167 public static com.liferay.portal.model.ResourceCode findByCompanyId_First(
168 long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
169 throws com.liferay.portal.SystemException,
170 com.liferay.portal.NoSuchResourceCodeException {
171 return getPersistence().findByCompanyId_First(companyId, obc);
172 }
173
174 public static com.liferay.portal.model.ResourceCode findByCompanyId_Last(
175 long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
176 throws com.liferay.portal.SystemException,
177 com.liferay.portal.NoSuchResourceCodeException {
178 return getPersistence().findByCompanyId_Last(companyId, obc);
179 }
180
181 public static com.liferay.portal.model.ResourceCode[] findByCompanyId_PrevAndNext(
182 long codeId, long companyId,
183 com.liferay.portal.kernel.util.OrderByComparator obc)
184 throws com.liferay.portal.SystemException,
185 com.liferay.portal.NoSuchResourceCodeException {
186 return getPersistence().findByCompanyId_PrevAndNext(codeId, companyId,
187 obc);
188 }
189
190 public static java.util.List findByName(java.lang.String name)
191 throws com.liferay.portal.SystemException {
192 return getPersistence().findByName(name);
193 }
194
195 public static java.util.List findByName(java.lang.String name, int begin,
196 int end) throws com.liferay.portal.SystemException {
197 return getPersistence().findByName(name, begin, end);
198 }
199
200 public static java.util.List findByName(java.lang.String name, int begin,
201 int end, com.liferay.portal.kernel.util.OrderByComparator obc)
202 throws com.liferay.portal.SystemException {
203 return getPersistence().findByName(name, begin, end, obc);
204 }
205
206 public static com.liferay.portal.model.ResourceCode findByName_First(
207 java.lang.String name,
208 com.liferay.portal.kernel.util.OrderByComparator obc)
209 throws com.liferay.portal.SystemException,
210 com.liferay.portal.NoSuchResourceCodeException {
211 return getPersistence().findByName_First(name, obc);
212 }
213
214 public static com.liferay.portal.model.ResourceCode findByName_Last(
215 java.lang.String name,
216 com.liferay.portal.kernel.util.OrderByComparator obc)
217 throws com.liferay.portal.SystemException,
218 com.liferay.portal.NoSuchResourceCodeException {
219 return getPersistence().findByName_Last(name, obc);
220 }
221
222 public static com.liferay.portal.model.ResourceCode[] findByName_PrevAndNext(
223 long codeId, java.lang.String name,
224 com.liferay.portal.kernel.util.OrderByComparator obc)
225 throws com.liferay.portal.SystemException,
226 com.liferay.portal.NoSuchResourceCodeException {
227 return getPersistence().findByName_PrevAndNext(codeId, name, obc);
228 }
229
230 public static com.liferay.portal.model.ResourceCode findByC_N_S(
231 long companyId, java.lang.String name, int scope)
232 throws com.liferay.portal.SystemException,
233 com.liferay.portal.NoSuchResourceCodeException {
234 return getPersistence().findByC_N_S(companyId, name, scope);
235 }
236
237 public static com.liferay.portal.model.ResourceCode fetchByC_N_S(
238 long companyId, java.lang.String name, int scope)
239 throws com.liferay.portal.SystemException {
240 return getPersistence().fetchByC_N_S(companyId, name, scope);
241 }
242
243 public static java.util.List findWithDynamicQuery(
244 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
245 throws com.liferay.portal.SystemException {
246 return getPersistence().findWithDynamicQuery(queryInitializer);
247 }
248
249 public static java.util.List findWithDynamicQuery(
250 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
251 int begin, int end) throws com.liferay.portal.SystemException {
252 return getPersistence().findWithDynamicQuery(queryInitializer, begin,
253 end);
254 }
255
256 public static java.util.List findAll()
257 throws com.liferay.portal.SystemException {
258 return getPersistence().findAll();
259 }
260
261 public static java.util.List findAll(int begin, int end)
262 throws com.liferay.portal.SystemException {
263 return getPersistence().findAll(begin, end);
264 }
265
266 public static java.util.List findAll(int begin, int end,
267 com.liferay.portal.kernel.util.OrderByComparator obc)
268 throws com.liferay.portal.SystemException {
269 return getPersistence().findAll(begin, end, obc);
270 }
271
272 public static void removeByCompanyId(long companyId)
273 throws com.liferay.portal.SystemException {
274 getPersistence().removeByCompanyId(companyId);
275 }
276
277 public static void removeByName(java.lang.String name)
278 throws com.liferay.portal.SystemException {
279 getPersistence().removeByName(name);
280 }
281
282 public static void removeByC_N_S(long companyId, java.lang.String name,
283 int scope)
284 throws com.liferay.portal.SystemException,
285 com.liferay.portal.NoSuchResourceCodeException {
286 getPersistence().removeByC_N_S(companyId, name, scope);
287 }
288
289 public static void removeAll() throws com.liferay.portal.SystemException {
290 getPersistence().removeAll();
291 }
292
293 public static int countByCompanyId(long companyId)
294 throws com.liferay.portal.SystemException {
295 return getPersistence().countByCompanyId(companyId);
296 }
297
298 public static int countByName(java.lang.String name)
299 throws com.liferay.portal.SystemException {
300 return getPersistence().countByName(name);
301 }
302
303 public static int countByC_N_S(long companyId, java.lang.String name,
304 int scope) throws com.liferay.portal.SystemException {
305 return getPersistence().countByC_N_S(companyId, name, scope);
306 }
307
308 public static int countAll() throws com.liferay.portal.SystemException {
309 return getPersistence().countAll();
310 }
311
312 public static ResourceCodePersistence getPersistence() {
313 return _getUtil()._persistence;
314 }
315
316 public void setPersistence(ResourceCodePersistence persistence) {
317 _persistence = persistence;
318 }
319
320 private static ResourceCodeUtil _getUtil() {
321 if (_util == null) {
322 _util = (ResourceCodeUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
323 }
324
325 return _util;
326 }
327
328 private static ModelListener _getListener() {
329 if (Validator.isNotNull(_LISTENER)) {
330 try {
331 return (ModelListener)Class.forName(_LISTENER).newInstance();
332 }
333 catch (Exception e) {
334 _log.error(e);
335 }
336 }
337
338 return null;
339 }
340
341 private static final String _UTIL = ResourceCodeUtil.class.getName();
342 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
343 "value.object.listener.com.liferay.portal.model.ResourceCode"));
344 private static Log _log = LogFactory.getLog(ResourceCodeUtil.class);
345 private static ResourceCodeUtil _util;
346 private ResourceCodePersistence _persistence;
347 }