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