001    /**
002     * Copyright (c) 2000-present 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.service.base;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.db.DB;
021    import com.liferay.portal.kernel.dao.db.DBManagerUtil;
022    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
024    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
025    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
028    import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
029    import com.liferay.portal.kernel.dao.orm.Projection;
030    import com.liferay.portal.kernel.exception.PortalException;
031    import com.liferay.portal.kernel.exception.SystemException;
032    import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
033    import com.liferay.portal.kernel.search.Indexable;
034    import com.liferay.portal.kernel.search.IndexableType;
035    import com.liferay.portal.kernel.util.OrderByComparator;
036    import com.liferay.portal.model.PersistedModel;
037    import com.liferay.portal.model.ResourcePermission;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.ResourcePermissionLocalService;
041    import com.liferay.portal.service.persistence.ResourceActionPersistence;
042    import com.liferay.portal.service.persistence.ResourcePermissionFinder;
043    import com.liferay.portal.service.persistence.ResourcePermissionPersistence;
044    import com.liferay.portal.service.persistence.RoleFinder;
045    import com.liferay.portal.service.persistence.RolePersistence;
046    import com.liferay.portal.util.PortalUtil;
047    
048    import java.io.Serializable;
049    
050    import java.util.List;
051    
052    import javax.sql.DataSource;
053    
054    /**
055     * Provides the base implementation for the resource permission local service.
056     *
057     * <p>
058     * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl}.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl
063     * @see com.liferay.portal.service.ResourcePermissionLocalServiceUtil
064     * @generated
065     */
066    @ProviderType
067    public abstract class ResourcePermissionLocalServiceBaseImpl
068            extends BaseLocalServiceImpl implements ResourcePermissionLocalService,
069                    IdentifiableOSGiService {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.ResourcePermissionLocalServiceUtil} to access the resource permission local service.
074             */
075    
076            /**
077             * Adds the resource permission to the database. Also notifies the appropriate model listeners.
078             *
079             * @param resourcePermission the resource permission
080             * @return the resource permission that was added
081             */
082            @Indexable(type = IndexableType.REINDEX)
083            @Override
084            public ResourcePermission addResourcePermission(
085                    ResourcePermission resourcePermission) {
086                    resourcePermission.setNew(true);
087    
088                    return resourcePermissionPersistence.update(resourcePermission);
089            }
090    
091            /**
092             * Creates a new resource permission with the primary key. Does not add the resource permission to the database.
093             *
094             * @param resourcePermissionId the primary key for the new resource permission
095             * @return the new resource permission
096             */
097            @Override
098            public ResourcePermission createResourcePermission(
099                    long resourcePermissionId) {
100                    return resourcePermissionPersistence.create(resourcePermissionId);
101            }
102    
103            /**
104             * Deletes the resource permission with the primary key from the database. Also notifies the appropriate model listeners.
105             *
106             * @param resourcePermissionId the primary key of the resource permission
107             * @return the resource permission that was removed
108             * @throws PortalException if a resource permission with the primary key could not be found
109             */
110            @Indexable(type = IndexableType.DELETE)
111            @Override
112            public ResourcePermission deleteResourcePermission(
113                    long resourcePermissionId) throws PortalException {
114                    return resourcePermissionPersistence.remove(resourcePermissionId);
115            }
116    
117            /**
118             * Deletes the resource permission from the database. Also notifies the appropriate model listeners.
119             *
120             * @param resourcePermission the resource permission
121             * @return the resource permission that was removed
122             */
123            @Indexable(type = IndexableType.DELETE)
124            @Override
125            public ResourcePermission deleteResourcePermission(
126                    ResourcePermission resourcePermission) {
127                    return resourcePermissionPersistence.remove(resourcePermission);
128            }
129    
130            @Override
131            public DynamicQuery dynamicQuery() {
132                    Class<?> clazz = getClass();
133    
134                    return DynamicQueryFactoryUtil.forClass(ResourcePermission.class,
135                            clazz.getClassLoader());
136            }
137    
138            /**
139             * Performs a dynamic query on the database and returns the matching rows.
140             *
141             * @param dynamicQuery the dynamic query
142             * @return the matching rows
143             */
144            @Override
145            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
146                    return resourcePermissionPersistence.findWithDynamicQuery(dynamicQuery);
147            }
148    
149            /**
150             * Performs a dynamic query on the database and returns a range of the matching rows.
151             *
152             * <p>
153             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ResourcePermissionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
154             * </p>
155             *
156             * @param dynamicQuery the dynamic query
157             * @param start the lower bound of the range of model instances
158             * @param end the upper bound of the range of model instances (not inclusive)
159             * @return the range of matching rows
160             */
161            @Override
162            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
163                    int end) {
164                    return resourcePermissionPersistence.findWithDynamicQuery(dynamicQuery,
165                            start, end);
166            }
167    
168            /**
169             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
170             *
171             * <p>
172             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ResourcePermissionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
173             * </p>
174             *
175             * @param dynamicQuery the dynamic query
176             * @param start the lower bound of the range of model instances
177             * @param end the upper bound of the range of model instances (not inclusive)
178             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
179             * @return the ordered range of matching rows
180             */
181            @Override
182            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
183                    int end, OrderByComparator<T> orderByComparator) {
184                    return resourcePermissionPersistence.findWithDynamicQuery(dynamicQuery,
185                            start, end, orderByComparator);
186            }
187    
188            /**
189             * Returns the number of rows matching the dynamic query.
190             *
191             * @param dynamicQuery the dynamic query
192             * @return the number of rows matching the dynamic query
193             */
194            @Override
195            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
196                    return resourcePermissionPersistence.countWithDynamicQuery(dynamicQuery);
197            }
198    
199            /**
200             * Returns the number of rows matching the dynamic query.
201             *
202             * @param dynamicQuery the dynamic query
203             * @param projection the projection to apply to the query
204             * @return the number of rows matching the dynamic query
205             */
206            @Override
207            public long dynamicQueryCount(DynamicQuery dynamicQuery,
208                    Projection projection) {
209                    return resourcePermissionPersistence.countWithDynamicQuery(dynamicQuery,
210                            projection);
211            }
212    
213            @Override
214            public ResourcePermission fetchResourcePermission(long resourcePermissionId) {
215                    return resourcePermissionPersistence.fetchByPrimaryKey(resourcePermissionId);
216            }
217    
218            /**
219             * Returns the resource permission with the primary key.
220             *
221             * @param resourcePermissionId the primary key of the resource permission
222             * @return the resource permission
223             * @throws PortalException if a resource permission with the primary key could not be found
224             */
225            @Override
226            public ResourcePermission getResourcePermission(long resourcePermissionId)
227                    throws PortalException {
228                    return resourcePermissionPersistence.findByPrimaryKey(resourcePermissionId);
229            }
230    
231            @Override
232            public ActionableDynamicQuery getActionableDynamicQuery() {
233                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
234    
235                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ResourcePermissionLocalServiceUtil.getService());
236                    actionableDynamicQuery.setClassLoader(getClassLoader());
237                    actionableDynamicQuery.setModelClass(ResourcePermission.class);
238    
239                    actionableDynamicQuery.setPrimaryKeyPropertyName("resourcePermissionId");
240    
241                    return actionableDynamicQuery;
242            }
243    
244            @Override
245            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
246                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
247    
248                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ResourcePermissionLocalServiceUtil.getService());
249                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
250                    indexableActionableDynamicQuery.setModelClass(ResourcePermission.class);
251    
252                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
253                            "resourcePermissionId");
254    
255                    return indexableActionableDynamicQuery;
256            }
257    
258            protected void initActionableDynamicQuery(
259                    ActionableDynamicQuery actionableDynamicQuery) {
260                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ResourcePermissionLocalServiceUtil.getService());
261                    actionableDynamicQuery.setClassLoader(getClassLoader());
262                    actionableDynamicQuery.setModelClass(ResourcePermission.class);
263    
264                    actionableDynamicQuery.setPrimaryKeyPropertyName("resourcePermissionId");
265            }
266    
267            /**
268             * @throws PortalException
269             */
270            @Override
271            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
272                    throws PortalException {
273                    return resourcePermissionLocalService.deleteResourcePermission((ResourcePermission)persistedModel);
274            }
275    
276            @Override
277            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
278                    throws PortalException {
279                    return resourcePermissionPersistence.findByPrimaryKey(primaryKeyObj);
280            }
281    
282            /**
283             * Returns a range of all the resource permissions.
284             *
285             * <p>
286             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ResourcePermissionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
287             * </p>
288             *
289             * @param start the lower bound of the range of resource permissions
290             * @param end the upper bound of the range of resource permissions (not inclusive)
291             * @return the range of resource permissions
292             */
293            @Override
294            public List<ResourcePermission> getResourcePermissions(int start, int end) {
295                    return resourcePermissionPersistence.findAll(start, end);
296            }
297    
298            /**
299             * Returns the number of resource permissions.
300             *
301             * @return the number of resource permissions
302             */
303            @Override
304            public int getResourcePermissionsCount() {
305                    return resourcePermissionPersistence.countAll();
306            }
307    
308            /**
309             * Updates the resource permission in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
310             *
311             * @param resourcePermission the resource permission
312             * @return the resource permission that was updated
313             */
314            @Indexable(type = IndexableType.REINDEX)
315            @Override
316            public ResourcePermission updateResourcePermission(
317                    ResourcePermission resourcePermission) {
318                    return resourcePermissionPersistence.update(resourcePermission);
319            }
320    
321            /**
322             * Returns the resource permission local service.
323             *
324             * @return the resource permission local service
325             */
326            public ResourcePermissionLocalService getResourcePermissionLocalService() {
327                    return resourcePermissionLocalService;
328            }
329    
330            /**
331             * Sets the resource permission local service.
332             *
333             * @param resourcePermissionLocalService the resource permission local service
334             */
335            public void setResourcePermissionLocalService(
336                    ResourcePermissionLocalService resourcePermissionLocalService) {
337                    this.resourcePermissionLocalService = resourcePermissionLocalService;
338            }
339    
340            /**
341             * Returns the resource permission persistence.
342             *
343             * @return the resource permission persistence
344             */
345            public ResourcePermissionPersistence getResourcePermissionPersistence() {
346                    return resourcePermissionPersistence;
347            }
348    
349            /**
350             * Sets the resource permission persistence.
351             *
352             * @param resourcePermissionPersistence the resource permission persistence
353             */
354            public void setResourcePermissionPersistence(
355                    ResourcePermissionPersistence resourcePermissionPersistence) {
356                    this.resourcePermissionPersistence = resourcePermissionPersistence;
357            }
358    
359            /**
360             * Returns the resource permission finder.
361             *
362             * @return the resource permission finder
363             */
364            public ResourcePermissionFinder getResourcePermissionFinder() {
365                    return resourcePermissionFinder;
366            }
367    
368            /**
369             * Sets the resource permission finder.
370             *
371             * @param resourcePermissionFinder the resource permission finder
372             */
373            public void setResourcePermissionFinder(
374                    ResourcePermissionFinder resourcePermissionFinder) {
375                    this.resourcePermissionFinder = resourcePermissionFinder;
376            }
377    
378            /**
379             * Returns the counter local service.
380             *
381             * @return the counter local service
382             */
383            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
384                    return counterLocalService;
385            }
386    
387            /**
388             * Sets the counter local service.
389             *
390             * @param counterLocalService the counter local service
391             */
392            public void setCounterLocalService(
393                    com.liferay.counter.service.CounterLocalService counterLocalService) {
394                    this.counterLocalService = counterLocalService;
395            }
396    
397            /**
398             * Returns the resource action local service.
399             *
400             * @return the resource action local service
401             */
402            public com.liferay.portal.service.ResourceActionLocalService getResourceActionLocalService() {
403                    return resourceActionLocalService;
404            }
405    
406            /**
407             * Sets the resource action local service.
408             *
409             * @param resourceActionLocalService the resource action local service
410             */
411            public void setResourceActionLocalService(
412                    com.liferay.portal.service.ResourceActionLocalService resourceActionLocalService) {
413                    this.resourceActionLocalService = resourceActionLocalService;
414            }
415    
416            /**
417             * Returns the resource action persistence.
418             *
419             * @return the resource action persistence
420             */
421            public ResourceActionPersistence getResourceActionPersistence() {
422                    return resourceActionPersistence;
423            }
424    
425            /**
426             * Sets the resource action persistence.
427             *
428             * @param resourceActionPersistence the resource action persistence
429             */
430            public void setResourceActionPersistence(
431                    ResourceActionPersistence resourceActionPersistence) {
432                    this.resourceActionPersistence = resourceActionPersistence;
433            }
434    
435            /**
436             * Returns the role local service.
437             *
438             * @return the role local service
439             */
440            public com.liferay.portal.service.RoleLocalService getRoleLocalService() {
441                    return roleLocalService;
442            }
443    
444            /**
445             * Sets the role local service.
446             *
447             * @param roleLocalService the role local service
448             */
449            public void setRoleLocalService(
450                    com.liferay.portal.service.RoleLocalService roleLocalService) {
451                    this.roleLocalService = roleLocalService;
452            }
453    
454            /**
455             * Returns the role persistence.
456             *
457             * @return the role persistence
458             */
459            public RolePersistence getRolePersistence() {
460                    return rolePersistence;
461            }
462    
463            /**
464             * Sets the role persistence.
465             *
466             * @param rolePersistence the role persistence
467             */
468            public void setRolePersistence(RolePersistence rolePersistence) {
469                    this.rolePersistence = rolePersistence;
470            }
471    
472            /**
473             * Returns the role finder.
474             *
475             * @return the role finder
476             */
477            public RoleFinder getRoleFinder() {
478                    return roleFinder;
479            }
480    
481            /**
482             * Sets the role finder.
483             *
484             * @param roleFinder the role finder
485             */
486            public void setRoleFinder(RoleFinder roleFinder) {
487                    this.roleFinder = roleFinder;
488            }
489    
490            public void afterPropertiesSet() {
491                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.ResourcePermission",
492                            resourcePermissionLocalService);
493            }
494    
495            public void destroy() {
496                    persistedModelLocalServiceRegistry.unregister(
497                            "com.liferay.portal.model.ResourcePermission");
498            }
499    
500            /**
501             * Returns the OSGi service identifier.
502             *
503             * @return the OSGi service identifier
504             */
505            @Override
506            public String getOSGiServiceIdentifier() {
507                    return ResourcePermissionLocalService.class.getName();
508            }
509    
510            protected Class<?> getModelClass() {
511                    return ResourcePermission.class;
512            }
513    
514            protected String getModelClassName() {
515                    return ResourcePermission.class.getName();
516            }
517    
518            /**
519             * Performs a SQL query.
520             *
521             * @param sql the sql query
522             */
523            protected void runSQL(String sql) {
524                    try {
525                            DataSource dataSource = resourcePermissionPersistence.getDataSource();
526    
527                            DB db = DBManagerUtil.getDB();
528    
529                            sql = db.buildSQL(sql);
530                            sql = PortalUtil.transformSQL(sql);
531    
532                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
533                                            sql, new int[0]);
534    
535                            sqlUpdate.update();
536                    }
537                    catch (Exception e) {
538                            throw new SystemException(e);
539                    }
540            }
541    
542            @BeanReference(type = com.liferay.portal.service.ResourcePermissionLocalService.class)
543            protected ResourcePermissionLocalService resourcePermissionLocalService;
544            @BeanReference(type = ResourcePermissionPersistence.class)
545            protected ResourcePermissionPersistence resourcePermissionPersistence;
546            @BeanReference(type = ResourcePermissionFinder.class)
547            protected ResourcePermissionFinder resourcePermissionFinder;
548            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
549            protected com.liferay.counter.service.CounterLocalService counterLocalService;
550            @BeanReference(type = com.liferay.portal.service.ResourceActionLocalService.class)
551            protected com.liferay.portal.service.ResourceActionLocalService resourceActionLocalService;
552            @BeanReference(type = ResourceActionPersistence.class)
553            protected ResourceActionPersistence resourceActionPersistence;
554            @BeanReference(type = com.liferay.portal.service.RoleLocalService.class)
555            protected com.liferay.portal.service.RoleLocalService roleLocalService;
556            @BeanReference(type = RolePersistence.class)
557            protected RolePersistence rolePersistence;
558            @BeanReference(type = RoleFinder.class)
559            protected RoleFinder roleFinder;
560            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
561            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
562    }