1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.persistence;
24  
25  /**
26   * <a href="ResourceUtil.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   *
30   */
31  public class ResourceUtil {
32      public static com.liferay.portal.model.Resource create(long resourceId) {
33          return getPersistence().create(resourceId);
34      }
35  
36      public static com.liferay.portal.model.Resource remove(long resourceId)
37          throws com.liferay.portal.SystemException,
38              com.liferay.portal.NoSuchResourceException {
39          return getPersistence().remove(resourceId);
40      }
41  
42      public static com.liferay.portal.model.Resource remove(
43          com.liferay.portal.model.Resource resource)
44          throws com.liferay.portal.SystemException {
45          return getPersistence().remove(resource);
46      }
47  
48      /**
49       * @deprecated Use <code>update(Resource resource, boolean merge)</code>.
50       */
51      public static com.liferay.portal.model.Resource update(
52          com.liferay.portal.model.Resource resource)
53          throws com.liferay.portal.SystemException {
54          return getPersistence().update(resource);
55      }
56  
57      /**
58       * Add, update, or merge, the entity. This method also calls the model
59       * listeners to trigger the proper events associated with adding, deleting,
60       * or updating an entity.
61       *
62       * @param        resource the entity to add, update, or merge
63       * @param        merge boolean value for whether to merge the entity. The
64       *                default value is false. Setting merge to true is more
65       *                expensive and should only be true when resource is
66       *                transient. See LEP-5473 for a detailed discussion of this
67       *                method.
68       * @return        true if the portlet can be displayed via Ajax
69       */
70      public static com.liferay.portal.model.Resource update(
71          com.liferay.portal.model.Resource resource, boolean merge)
72          throws com.liferay.portal.SystemException {
73          return getPersistence().update(resource, merge);
74      }
75  
76      public static com.liferay.portal.model.Resource updateImpl(
77          com.liferay.portal.model.Resource resource, boolean merge)
78          throws com.liferay.portal.SystemException {
79          return getPersistence().updateImpl(resource, merge);
80      }
81  
82      public static com.liferay.portal.model.Resource findByPrimaryKey(
83          long resourceId)
84          throws com.liferay.portal.SystemException,
85              com.liferay.portal.NoSuchResourceException {
86          return getPersistence().findByPrimaryKey(resourceId);
87      }
88  
89      public static com.liferay.portal.model.Resource fetchByPrimaryKey(
90          long resourceId) throws com.liferay.portal.SystemException {
91          return getPersistence().fetchByPrimaryKey(resourceId);
92      }
93  
94      public static java.util.List<com.liferay.portal.model.Resource> findByCodeId(
95          long codeId) throws com.liferay.portal.SystemException {
96          return getPersistence().findByCodeId(codeId);
97      }
98  
99      public static java.util.List<com.liferay.portal.model.Resource> findByCodeId(
100         long codeId, int begin, int end)
101         throws com.liferay.portal.SystemException {
102         return getPersistence().findByCodeId(codeId, begin, end);
103     }
104 
105     public static java.util.List<com.liferay.portal.model.Resource> findByCodeId(
106         long codeId, int begin, int end,
107         com.liferay.portal.kernel.util.OrderByComparator obc)
108         throws com.liferay.portal.SystemException {
109         return getPersistence().findByCodeId(codeId, begin, end, obc);
110     }
111 
112     public static com.liferay.portal.model.Resource findByCodeId_First(
113         long codeId, com.liferay.portal.kernel.util.OrderByComparator obc)
114         throws com.liferay.portal.SystemException,
115             com.liferay.portal.NoSuchResourceException {
116         return getPersistence().findByCodeId_First(codeId, obc);
117     }
118 
119     public static com.liferay.portal.model.Resource findByCodeId_Last(
120         long codeId, com.liferay.portal.kernel.util.OrderByComparator obc)
121         throws com.liferay.portal.SystemException,
122             com.liferay.portal.NoSuchResourceException {
123         return getPersistence().findByCodeId_Last(codeId, obc);
124     }
125 
126     public static com.liferay.portal.model.Resource[] findByCodeId_PrevAndNext(
127         long resourceId, long codeId,
128         com.liferay.portal.kernel.util.OrderByComparator obc)
129         throws com.liferay.portal.SystemException,
130             com.liferay.portal.NoSuchResourceException {
131         return getPersistence().findByCodeId_PrevAndNext(resourceId, codeId, obc);
132     }
133 
134     public static com.liferay.portal.model.Resource findByC_P(long codeId,
135         java.lang.String primKey)
136         throws com.liferay.portal.SystemException,
137             com.liferay.portal.NoSuchResourceException {
138         return getPersistence().findByC_P(codeId, primKey);
139     }
140 
141     public static com.liferay.portal.model.Resource fetchByC_P(long codeId,
142         java.lang.String primKey) throws com.liferay.portal.SystemException {
143         return getPersistence().fetchByC_P(codeId, primKey);
144     }
145 
146     public static java.util.List<com.liferay.portal.model.Resource> findWithDynamicQuery(
147         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
148         throws com.liferay.portal.SystemException {
149         return getPersistence().findWithDynamicQuery(queryInitializer);
150     }
151 
152     public static java.util.List<com.liferay.portal.model.Resource> findWithDynamicQuery(
153         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
154         int begin, int end) throws com.liferay.portal.SystemException {
155         return getPersistence()
156                    .findWithDynamicQuery(queryInitializer, begin, end);
157     }
158 
159     public static java.util.List<com.liferay.portal.model.Resource> findAll()
160         throws com.liferay.portal.SystemException {
161         return getPersistence().findAll();
162     }
163 
164     public static java.util.List<com.liferay.portal.model.Resource> findAll(
165         int begin, int end) throws com.liferay.portal.SystemException {
166         return getPersistence().findAll(begin, end);
167     }
168 
169     public static java.util.List<com.liferay.portal.model.Resource> findAll(
170         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException {
172         return getPersistence().findAll(begin, end, obc);
173     }
174 
175     public static void removeByCodeId(long codeId)
176         throws com.liferay.portal.SystemException {
177         getPersistence().removeByCodeId(codeId);
178     }
179 
180     public static void removeByC_P(long codeId, java.lang.String primKey)
181         throws com.liferay.portal.SystemException,
182             com.liferay.portal.NoSuchResourceException {
183         getPersistence().removeByC_P(codeId, primKey);
184     }
185 
186     public static void removeAll() throws com.liferay.portal.SystemException {
187         getPersistence().removeAll();
188     }
189 
190     public static int countByCodeId(long codeId)
191         throws com.liferay.portal.SystemException {
192         return getPersistence().countByCodeId(codeId);
193     }
194 
195     public static int countByC_P(long codeId, java.lang.String primKey)
196         throws com.liferay.portal.SystemException {
197         return getPersistence().countByC_P(codeId, primKey);
198     }
199 
200     public static int countAll() throws com.liferay.portal.SystemException {
201         return getPersistence().countAll();
202     }
203 
204     public static ResourcePersistence getPersistence() {
205         return _getUtil()._persistence;
206     }
207 
208     public void setPersistence(ResourcePersistence persistence) {
209         _persistence = persistence;
210     }
211 
212     private static ResourceUtil _getUtil() {
213         if (_util == null) {
214             _util = (ResourceUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
215         }
216 
217         return _util;
218     }
219 
220     private static final String _UTIL = ResourceUtil.class.getName();
221     private static ResourceUtil _util;
222     private ResourcePersistence _persistence;
223 }