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