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.kernel.service;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
020    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
021    import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
022    import com.liferay.portal.kernel.dao.orm.Projection;
023    import com.liferay.portal.kernel.exception.PortalException;
024    import com.liferay.portal.kernel.exception.SystemException;
025    import com.liferay.portal.kernel.model.PersistedModel;
026    import com.liferay.portal.kernel.model.Subscription;
027    import com.liferay.portal.kernel.search.Indexable;
028    import com.liferay.portal.kernel.search.IndexableType;
029    import com.liferay.portal.kernel.transaction.Isolation;
030    import com.liferay.portal.kernel.transaction.Propagation;
031    import com.liferay.portal.kernel.transaction.Transactional;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    
034    import java.io.Serializable;
035    
036    import java.util.List;
037    
038    /**
039     * Provides the local service interface for Subscription. Methods of this
040     * service will not have security checks based on the propagated JAAS
041     * credentials because this service can only be accessed from within the same
042     * VM.
043     *
044     * @author Brian Wing Shun Chan
045     * @see SubscriptionLocalServiceUtil
046     * @see com.liferay.portal.service.base.SubscriptionLocalServiceBaseImpl
047     * @see com.liferay.portal.service.impl.SubscriptionLocalServiceImpl
048     * @generated
049     */
050    @ProviderType
051    @Transactional(isolation = Isolation.PORTAL, rollbackFor =  {
052            PortalException.class, SystemException.class})
053    public interface SubscriptionLocalService extends BaseLocalService,
054            PersistedModelLocalService {
055            /*
056             * NOTE FOR DEVELOPERS:
057             *
058             * Never modify or reference this interface directly. Always use {@link SubscriptionLocalServiceUtil} to access the subscription local service. Add custom service methods to {@link com.liferay.portal.service.impl.SubscriptionLocalServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.
059             */
060    
061            /**
062            * Returns <code>true</code> if the user is subscribed to the entity.
063            *
064            * @param companyId the primary key of the company
065            * @param userId the primary key of the user
066            * @param className the entity's class name
067            * @param classPK the primary key of the entity's instance
068            * @return <code>true</code> if the user is subscribed to the entity;
069            <code>false</code> otherwise
070            */
071            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
072            public boolean isSubscribed(long companyId, long userId,
073                    java.lang.String className, long classPK);
074    
075            /**
076            * Returns <code>true</code> if the user is subscribed to any of the
077            * entities.
078            *
079            * @param companyId the primary key of the company
080            * @param userId the primary key of the user
081            * @param className the entity's class name
082            * @param classPKs the primary key of the entities
083            * @return <code>true</code> if the user is subscribed to any of the
084            entities; <code>false</code> otherwise
085            */
086            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
087            public boolean isSubscribed(long companyId, long userId,
088                    java.lang.String className, long[] classPKs);
089    
090            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
091            public ActionableDynamicQuery getActionableDynamicQuery();
092    
093            public DynamicQuery dynamicQuery();
094    
095            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
096            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery();
097    
098            /**
099            * @throws PortalException
100            */
101            @Override
102            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
103                    throws PortalException;
104    
105            @Override
106            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
107            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
108                    throws PortalException;
109    
110            /**
111            * Adds the subscription to the database. Also notifies the appropriate model listeners.
112            *
113            * @param subscription the subscription
114            * @return the subscription that was added
115            */
116            @Indexable(type = IndexableType.REINDEX)
117            public Subscription addSubscription(Subscription subscription);
118    
119            /**
120            * Subscribes the user to the entity, notifying him the instant the entity
121            * is created, deleted, or modified.
122            *
123            * <p>
124            * If there is no asset entry with the class name and class PK a new asset
125            * entry is created.
126            * </p>
127            *
128            * <p>
129            * A social activity for the subscription is created using the asset entry
130            * associated with the class name and class PK, or the newly created asset
131            * entry.
132            * </p>
133            *
134            * @param userId the primary key of the user
135            * @param groupId the primary key of the entity's group
136            * @param className the entity's class name
137            * @param classPK the primary key of the entity's instance
138            * @return the subscription
139            */
140            public Subscription addSubscription(long userId, long groupId,
141                    java.lang.String className, long classPK) throws PortalException;
142    
143            /**
144            * Subscribes the user to the entity, notifying him at the given frequency.
145            *
146            * <p>
147            * If there is no asset entry with the class name and class PK a new asset
148            * entry is created.
149            * </p>
150            *
151            * <p>
152            * A social activity for the subscription is created using the asset entry
153            * associated with the class name and class PK, or the newly created asset
154            * entry.
155            * </p>
156            *
157            * @param userId the primary key of the user
158            * @param groupId the primary key of the entity's group
159            * @param className the entity's class name
160            * @param classPK the primary key of the entity's instance
161            * @param frequency the frequency for notifications
162            * @return the subscription
163            */
164            public Subscription addSubscription(long userId, long groupId,
165                    java.lang.String className, long classPK, java.lang.String frequency)
166                    throws PortalException;
167    
168            /**
169            * Creates a new subscription with the primary key. Does not add the subscription to the database.
170            *
171            * @param subscriptionId the primary key for the new subscription
172            * @return the new subscription
173            */
174            public Subscription createSubscription(long subscriptionId);
175    
176            /**
177            * Deletes the subscription from the database. Also notifies the appropriate model listeners.
178            *
179            * @param subscription the subscription
180            * @return the subscription that was removed
181            * @throws PortalException
182            */
183            @Indexable(type = IndexableType.DELETE)
184            public Subscription deleteSubscription(Subscription subscription)
185                    throws PortalException;
186    
187            /**
188            * Deletes the subscription with the primary key from the database. Also notifies the appropriate model listeners.
189            *
190            * @param subscriptionId the primary key of the subscription
191            * @return the subscription that was removed
192            * @throws PortalException if a subscription with the primary key could not be found
193            */
194            @Indexable(type = IndexableType.DELETE)
195            public Subscription deleteSubscription(long subscriptionId)
196                    throws PortalException;
197    
198            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
199            public Subscription fetchSubscription(long companyId, long userId,
200                    java.lang.String className, long classPK);
201    
202            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
203            public Subscription fetchSubscription(long subscriptionId);
204    
205            /**
206            * Returns the subscription of the user to the entity.
207            *
208            * @param companyId the primary key of the company
209            * @param userId the primary key of the user
210            * @param className the entity's class name
211            * @param classPK the primary key of the entity's instance
212            * @return the subscription of the user to the entity
213            */
214            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
215            public Subscription getSubscription(long companyId, long userId,
216                    java.lang.String className, long classPK) throws PortalException;
217    
218            /**
219            * Returns the subscription with the primary key.
220            *
221            * @param subscriptionId the primary key of the subscription
222            * @return the subscription
223            * @throws PortalException if a subscription with the primary key could not be found
224            */
225            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
226            public Subscription getSubscription(long subscriptionId)
227                    throws PortalException;
228    
229            /**
230            * Updates the subscription in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
231            *
232            * @param subscription the subscription
233            * @return the subscription that was updated
234            */
235            @Indexable(type = IndexableType.REINDEX)
236            public Subscription updateSubscription(Subscription subscription);
237    
238            /**
239            * Returns the number of subscriptions.
240            *
241            * @return the number of subscriptions
242            */
243            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
244            public int getSubscriptionsCount();
245    
246            /**
247            * Returns the number of subscriptions of the user.
248            *
249            * @param userId the primary key of the user
250            * @return the number of subscriptions of the user
251            */
252            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
253            public int getUserSubscriptionsCount(long userId);
254    
255            /**
256            * Returns the OSGi service identifier.
257            *
258            * @return the OSGi service identifier
259            */
260            public java.lang.String getOSGiServiceIdentifier();
261    
262            /**
263            * Performs a dynamic query on the database and returns the matching rows.
264            *
265            * @param dynamicQuery the dynamic query
266            * @return the matching rows
267            */
268            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery);
269    
270            /**
271            * Performs a dynamic query on the database and returns a range of the matching rows.
272            *
273            * <p>
274            * 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.SubscriptionModelImpl}. 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.
275            * </p>
276            *
277            * @param dynamicQuery the dynamic query
278            * @param start the lower bound of the range of model instances
279            * @param end the upper bound of the range of model instances (not inclusive)
280            * @return the range of matching rows
281            */
282            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
283                    int end);
284    
285            /**
286            * Performs a dynamic query on the database and returns an ordered range of the matching rows.
287            *
288            * <p>
289            * 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.SubscriptionModelImpl}. 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.
290            * </p>
291            *
292            * @param dynamicQuery the dynamic query
293            * @param start the lower bound of the range of model instances
294            * @param end the upper bound of the range of model instances (not inclusive)
295            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
296            * @return the ordered range of matching rows
297            */
298            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
299                    int end, OrderByComparator<T> orderByComparator);
300    
301            /**
302            * Returns a range of all the subscriptions.
303            *
304            * <p>
305            * 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.SubscriptionModelImpl}. 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.
306            * </p>
307            *
308            * @param start the lower bound of the range of subscriptions
309            * @param end the upper bound of the range of subscriptions (not inclusive)
310            * @return the range of subscriptions
311            */
312            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
313            public List<Subscription> getSubscriptions(int start, int end);
314    
315            /**
316            * Returns all the subscriptions to the entity.
317            *
318            * @param companyId the primary key of the company
319            * @param className the entity's class name
320            * @param classPK the primary key of the entity's instance
321            * @return the subscriptions to the entity
322            */
323            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
324            public List<Subscription> getSubscriptions(long companyId,
325                    java.lang.String className, long classPK);
326    
327            /**
328            * Returns all the subscriptions of the user to the entities.
329            *
330            * @param companyId the primary key of the company
331            * @param userId the primary key of the user
332            * @param className the entity's class name
333            * @param classPKs the primary key of the entities
334            * @return the subscriptions of the user to the entities
335            */
336            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
337            public List<Subscription> getSubscriptions(long companyId, long userId,
338                    java.lang.String className, long[] classPKs);
339    
340            /**
341            * Returns an ordered range of all the subscriptions of the user.
342            *
343            * @param userId the primary key of the user
344            * @param start the lower bound of the range of results
345            * @param end the upper bound of the range of results (not inclusive)
346            * @param orderByComparator the comparator to order the subscriptions
347            * @return the range of subscriptions of the user
348            */
349            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
350            public List<Subscription> getUserSubscriptions(long userId, int start,
351                    int end, OrderByComparator<Subscription> orderByComparator);
352    
353            /**
354            * Returns all the subscriptions of the user to the entities with the class
355            * name.
356            *
357            * @param userId the primary key of the user
358            * @param className the entity's class name
359            * @return the subscriptions of the user to the entities with the class name
360            */
361            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
362            public List<Subscription> getUserSubscriptions(long userId,
363                    java.lang.String className);
364    
365            /**
366            * Returns the number of rows matching the dynamic query.
367            *
368            * @param dynamicQuery the dynamic query
369            * @return the number of rows matching the dynamic query
370            */
371            public long dynamicQueryCount(DynamicQuery dynamicQuery);
372    
373            /**
374            * Returns the number of rows matching the dynamic query.
375            *
376            * @param dynamicQuery the dynamic query
377            * @param projection the projection to apply to the query
378            * @return the number of rows matching the dynamic query
379            */
380            public long dynamicQueryCount(DynamicQuery dynamicQuery,
381                    Projection projection);
382    
383            /**
384            * Deletes the user's subscription to the entity. A social activity with the
385            * unsubscribe action is created.
386            *
387            * @param userId the primary key of the user
388            * @param className the entity's class name
389            * @param classPK the primary key of the entity's instance
390            */
391            public void deleteSubscription(long userId, java.lang.String className,
392                    long classPK) throws PortalException;
393    
394            /**
395            * Deletes all the subscriptions to the entity.
396            *
397            * @param companyId the primary key of the company
398            * @param className the entity's class name
399            * @param classPK the primary key of the entity's instance
400            */
401            public void deleteSubscriptions(long companyId, java.lang.String className,
402                    long classPK) throws PortalException;
403    
404            /**
405            * Deletes all the subscriptions of the user.
406            *
407            * @param userId the primary key of the user
408            */
409            public void deleteSubscriptions(long userId) throws PortalException;
410    
411            public void deleteSubscriptions(long userId, long groupId)
412                    throws PortalException;
413    }