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