001    /**
002     * Copyright (c) 2000-2013 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.portlet.journal.service.impl;
016    
017    import com.liferay.portal.kernel.dao.orm.QueryDefinition;
018    import com.liferay.portal.kernel.exception.PortalException;
019    import com.liferay.portal.kernel.exception.SystemException;
020    import com.liferay.portal.kernel.util.ArrayUtil;
021    import com.liferay.portal.kernel.util.OrderByComparator;
022    import com.liferay.portal.kernel.workflow.WorkflowConstants;
023    import com.liferay.portal.security.permission.ActionKeys;
024    import com.liferay.portal.service.ServiceContext;
025    import com.liferay.portal.theme.ThemeDisplay;
026    import com.liferay.portlet.journal.model.JournalArticle;
027    import com.liferay.portlet.journal.model.JournalArticleConstants;
028    import com.liferay.portlet.journal.service.base.JournalArticleServiceBaseImpl;
029    import com.liferay.portlet.journal.service.permission.JournalArticlePermission;
030    import com.liferay.portlet.journal.service.permission.JournalPermission;
031    
032    import java.io.File;
033    import java.io.Serializable;
034    
035    import java.util.ArrayList;
036    import java.util.Collections;
037    import java.util.Date;
038    import java.util.HashMap;
039    import java.util.List;
040    import java.util.Locale;
041    import java.util.Map;
042    
043    /**
044     * Provides the remote service for accessing, adding, deleting, and updating web
045     * content articles. Its methods include permission checks.
046     *
047     * @author Brian Wing Shun Chan
048     * @author Raymond Augé
049     * @author Levente Hudák
050     * @see    com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl
051     */
052    public class JournalArticleServiceImpl extends JournalArticleServiceBaseImpl {
053    
054            /**
055             * Adds a web content article with additional parameters.
056             *
057             * @param  groupId the primary key of the web content article's group
058             * @param  folderId the primary key of the web content article folder
059             * @param  classNameId the primary key of the DDMStructure class if the web
060             *         content article is related to a DDM structure, the primary key of
061             *         the class name associated with the article, or {@link
062             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
063             * @param  classPK the primary key of the DDM structure, if the primary key
064             *         of the DDMStructure class is given as the
065             *         <code>classNameId</code> parameter, the primary key of the class
066             *         associated with the web content article, or <code>0</code>
067             *         otherwise
068             * @param  articleId the primary key of the web content article
069             * @param  autoArticleId whether to auto generate the web content article ID
070             * @param  titleMap the web content article's locales and localized titles
071             * @param  descriptionMap the web content article's locales and localized
072             *         descriptions
073             * @param  content the HTML content wrapped in XML. For more information,
074             *         see the content example in the class description for {@link
075             *         JournalArticleLocalServiceImpl}.
076             * @param  type the structure's type, if the web content article is related
077             *         to a DDM structure. For more information, see {@link
078             *         com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}.
079             * @param  ddmStructureKey the primary key of the web content article's DDM
080             *         structure, if the article is related to a DDM structure, or
081             *         <code>null</code> otherwise
082             * @param  ddmTemplateKey the primary key of the web content article's DDM
083             *         template (optionally <code>null</code>). If the article is
084             *         related to a DDM structure, the template's structure must match
085             *         it.
086             * @param  layoutUuid the unique string identifying the web content
087             *         article's display page
088             * @param  displayDateMonth the month the web content article is set to
089             *         display
090             * @param  displayDateDay the calendar day the web content article is set to
091             *         display
092             * @param  displayDateYear the year the web content article is set to
093             *         display
094             * @param  displayDateHour the hour the web content article is set to
095             *         display
096             * @param  displayDateMinute the minute the web content article is set to
097             *         display
098             * @param  expirationDateMonth the month the web content article is set to
099             *         expire
100             * @param  expirationDateDay the calendar day the web content article is set
101             *         to expire
102             * @param  expirationDateYear the year the web content article is set to
103             *         expire
104             * @param  expirationDateHour the hour the web content article is set to
105             *         expire
106             * @param  expirationDateMinute the minute the web content article is set to
107             *         expire
108             * @param  neverExpire whether the web content article is not set to auto
109             *         expire
110             * @param  reviewDateMonth the month the web content article is set for
111             *         review
112             * @param  reviewDateDay the calendar day the web content article is set for
113             *         review
114             * @param  reviewDateYear the year the web content article is set for review
115             * @param  reviewDateHour the hour the web content article is set for review
116             * @param  reviewDateMinute the minute the web content article is set for
117             *         review
118             * @param  neverReview whether the web content article is not set for review
119             * @param  indexable whether the web content article is searchable
120             * @param  smallImage whether the web content article has a small image
121             * @param  smallImageURL the web content article's small image URL
122             * @param  smallFile the web content article's small image file
123             * @param  images the web content's images
124             * @param  articleURL the web content article's accessible URL
125             * @param  serviceContext the service context to be applied. Can set the
126             *         UUID, creation date, modification date, expando bridge
127             *         attributes, guest permissions, group permissions, asset category
128             *         IDs, asset tag names, asset link entry IDs, the "urlTitle"
129             *         attribute, and workflow actions for the web content article. Can
130             *         also set whether to add the default guest and group permissions.
131             * @return the web content article
132             * @throws PortalException if the user did not have permission to add the
133             *         web content article or if a portal exception occurred
134             * @throws SystemException if a system exception occurred
135             */
136            public JournalArticle addArticle(
137                            long groupId, long folderId, long classNameId, long classPK,
138                            String articleId, boolean autoArticleId,
139                            Map<Locale, String> titleMap, Map<Locale, String> descriptionMap,
140                            String content, String type, String ddmStructureKey,
141                            String ddmTemplateKey, String layoutUuid, int displayDateMonth,
142                            int displayDateDay, int displayDateYear, int displayDateHour,
143                            int displayDateMinute, int expirationDateMonth,
144                            int expirationDateDay, int expirationDateYear,
145                            int expirationDateHour, int expirationDateMinute,
146                            boolean neverExpire, int reviewDateMonth, int reviewDateDay,
147                            int reviewDateYear, int reviewDateHour, int reviewDateMinute,
148                            boolean neverReview, boolean indexable, boolean smallImage,
149                            String smallImageURL, File smallFile, Map<String, byte[]> images,
150                            String articleURL, ServiceContext serviceContext)
151                    throws PortalException, SystemException {
152    
153                    JournalPermission.check(
154                            getPermissionChecker(), groupId, ActionKeys.ADD_ARTICLE);
155    
156                    return journalArticleLocalService.addArticle(
157                            getUserId(), groupId, folderId, classNameId, classPK, articleId,
158                            autoArticleId, JournalArticleConstants.VERSION_DEFAULT, titleMap,
159                            descriptionMap, content, type, ddmStructureKey, ddmTemplateKey,
160                            layoutUuid, displayDateMonth, displayDateDay, displayDateYear,
161                            displayDateHour, displayDateMinute, expirationDateMonth,
162                            expirationDateDay, expirationDateYear, expirationDateHour,
163                            expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay,
164                            reviewDateYear, reviewDateHour, reviewDateMinute, neverReview,
165                            indexable, smallImage, smallImageURL, smallFile, images, articleURL,
166                            serviceContext);
167            }
168    
169            /**
170             * Adds a web content article without any images.
171             *
172             * @param  groupId the primary key of the web content article's group
173             * @param  folderId the primary key of the web content article folder
174             * @param  classNameId the primary key of the DDMStructure class if the web
175             *         content article is related to a DDM structure, the primary key of
176             *         the class name associated with the article, or {@link
177             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
178             * @param  classPK the primary key of the DDM structure, if the primary key
179             *         of the DDMStructure class is given as the
180             *         <code>classNameId</code> parameter, the primary key of the class
181             *         associated with the web content article, or <code>0</code>
182             *         otherwise
183             * @param  articleId the primary key of the web content article
184             * @param  autoArticleId whether to auto generate the web content article ID
185             * @param  titleMap the web content article's locales and localized titles
186             * @param  descriptionMap the web content article's locales and localized
187             *         descriptions
188             * @param  content the HTML content wrapped in XML. For more information,
189             *         see the content example in the class description for {@link
190             *         JournalArticleLocalServiceImpl}.
191             * @param  type the structure's type, if the web content article is related
192             *         to a DDM structure. For more information, see {@link
193             *         com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}.
194             * @param  ddmStructureKey the primary key of the web content article's DDM
195             *         structure, if the article is related to a DDM structure, or
196             *         <code>null</code> otherwise
197             * @param  ddmTemplateKey the primary key of the web content article's DDM
198             *         template (optionally <code>null</code>). If the article is
199             *         related to a DDM structure, the template's structure must match
200             *         it.
201             * @param  layoutUuid the unique string identifying the web content
202             *         article's display page
203             * @param  displayDateMonth the month the web content article is set to
204             *         display
205             * @param  displayDateDay the calendar day the web content article is set to
206             *         display
207             * @param  displayDateYear the year the web content article is set to
208             *         display
209             * @param  displayDateHour the hour the web content article is set to
210             *         display
211             * @param  displayDateMinute the minute the web content article is set to
212             *         display
213             * @param  expirationDateMonth the month the web content article is set to
214             *         expire
215             * @param  expirationDateDay the calendar day the web content article is set
216             *         to expire
217             * @param  expirationDateYear the year the web content article is set to
218             *         expire
219             * @param  expirationDateHour the hour the web content article is set to
220             *         expire
221             * @param  expirationDateMinute the minute the web content article is set to
222             *         expire
223             * @param  neverExpire whether the web content article is not set to auto
224             *         expire
225             * @param  reviewDateMonth the month the web content article is set for
226             *         review
227             * @param  reviewDateDay the calendar day the web content article is set for
228             *         review
229             * @param  reviewDateYear the year the web content article is set for review
230             * @param  reviewDateHour the hour the web content article is set for review
231             * @param  reviewDateMinute the minute the web content article is set for
232             *         review
233             * @param  neverReview whether the web content article is not set for review
234             * @param  indexable whether the web content article is searchable
235             * @param  articleURL the web content article's accessible URL
236             * @param  serviceContext the service context to be applied. Can set the
237             *         UUID, creation date, modification date, expando bridge
238             *         attributes, guest permissions, group permissions, asset category
239             *         IDs, asset tag names, asset link entry IDs, the "urlTitle"
240             *         attribute, and workflow actions for the web content article. Can
241             *         also set whether to add the default guest and group permissions.
242             * @return the web content article
243             * @throws PortalException if the user did not have permission to add the
244             *         web content article or if a portal exception occurred
245             * @throws SystemException if a system exception occurred
246             */
247            public JournalArticle addArticle(
248                            long groupId, long folderId, long classNameId, long classPK,
249                            String articleId, boolean autoArticleId,
250                            Map<Locale, String> titleMap, Map<Locale, String> descriptionMap,
251                            String content, String type, String ddmStructureKey,
252                            String ddmTemplateKey, String layoutUuid, int displayDateMonth,
253                            int displayDateDay, int displayDateYear, int displayDateHour,
254                            int displayDateMinute, int expirationDateMonth,
255                            int expirationDateDay, int expirationDateYear,
256                            int expirationDateHour, int expirationDateMinute,
257                            boolean neverExpire, int reviewDateMonth, int reviewDateDay,
258                            int reviewDateYear, int reviewDateHour, int reviewDateMinute,
259                            boolean neverReview, boolean indexable, String articleURL,
260                            ServiceContext serviceContext)
261                    throws PortalException, SystemException {
262    
263                    JournalPermission.check(
264                            getPermissionChecker(), groupId, ActionKeys.ADD_ARTICLE);
265    
266                    return journalArticleLocalService.addArticle(
267                            getUserId(), groupId, folderId, classNameId, classPK, articleId,
268                            autoArticleId, JournalArticleConstants.VERSION_DEFAULT, titleMap,
269                            descriptionMap, content, type, ddmStructureKey, ddmTemplateKey,
270                            layoutUuid, displayDateMonth, displayDateDay, displayDateYear,
271                            displayDateHour, displayDateMinute, expirationDateMonth,
272                            expirationDateDay, expirationDateYear, expirationDateHour,
273                            expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay,
274                            reviewDateYear, reviewDateHour, reviewDateMinute, neverReview,
275                            indexable, false, null, null, null, articleURL, serviceContext);
276            }
277    
278            /**
279             * Copies the web content article matching the group, article ID, and
280             * version. This method creates a new article, extracting all the values
281             * from the old one and updating its article ID.
282             *
283             * @param  groupId the primary key of the web content article's group
284             * @param  oldArticleId the primary key of the old web content article
285             * @param  newArticleId the primary key of the new web content article
286             * @param  autoArticleId whether to auto-generate the web content article ID
287             * @param  version the web content article's version
288             * @return the new web content article
289             * @throws PortalException if the user did not have permission to add the
290             *         copy the web content article, if a matching web content article
291             *         could not be found, or if a portal exception occurred
292             * @throws SystemException if a system exception occurred
293             */
294            public JournalArticle copyArticle(
295                            long groupId, String oldArticleId, String newArticleId,
296                            boolean autoArticleId, double version)
297                    throws PortalException, SystemException {
298    
299                    JournalPermission.check(
300                            getPermissionChecker(), groupId, ActionKeys.ADD_ARTICLE);
301    
302                    return journalArticleLocalService.copyArticle(
303                            getUserId(), groupId, oldArticleId, newArticleId, autoArticleId,
304                            version);
305            }
306    
307            /**
308             * Deletes the web content article and its resources matching the group,
309             * article ID, and version, optionally sending email notifying denial of the
310             * web content article if it had not yet been approved.
311             *
312             * @param  groupId the primary key of the web content article's group
313             * @param  articleId the primary key of the web content article
314             * @param  version the web content article's version
315             * @param  articleURL the web content article's accessible URL
316             * @param  serviceContext the service context to be applied. Can set the
317             *         portlet preferences that include email information to notify
318             *         recipients of the unapproved web content article's denial.
319             * @throws PortalException if the user did not have permission to delete the
320             *         web content article, if a matching web content article could not
321             *         be found, or if a portal exception occurred
322             * @throws SystemException if a system exception occurred
323             */
324            public void deleteArticle(
325                            long groupId, String articleId, double version, String articleURL,
326                            ServiceContext serviceContext)
327                    throws PortalException, SystemException {
328    
329                    JournalArticlePermission.check(
330                            getPermissionChecker(), groupId, articleId, version,
331                            ActionKeys.DELETE);
332    
333                    journalArticleLocalService.deleteArticle(
334                            groupId, articleId, version, articleURL, serviceContext);
335            }
336    
337            /**
338             * Deletes all web content articles and their resources matching the group
339             * and article ID, optionally sending email notifying denial of article if
340             * it had not yet been approved.
341             *
342             * @param  groupId the primary key of the web content article's group
343             * @param  articleId the primary key of the web content article
344             * @param  articleURL the web content article's accessible URL
345             * @param  serviceContext the service context to be applied. Can set the
346             *         portlet preferences that include email information to notify
347             *         recipients of the unapproved web content article's denial.
348             * @throws PortalException if the user did not have permission to delete the
349             *         web content article or if a portal exception occurred
350             * @throws SystemException if a system exception occurred
351             */
352            public void deleteArticle(
353                            long groupId, String articleId, String articleURL,
354                            ServiceContext serviceContext)
355                    throws PortalException, SystemException {
356    
357                    JournalArticlePermission.check(
358                            getPermissionChecker(), groupId, articleId, ActionKeys.DELETE);
359    
360                    journalArticleLocalService.deleteArticle(
361                            groupId, articleId, serviceContext);
362            }
363    
364            /**
365             * Expires the web content article matching the group, article ID, and
366             * version.
367             *
368             * @param  groupId the primary key of the web content article's group
369             * @param  articleId the primary key of the web content article
370             * @param  version the web content article's version
371             * @param  articleURL the web content article's accessible URL
372             * @param  serviceContext the service context to be applied. Can set the
373             *         modification date, status date, portlet preferences, and can set
374             *         whether to add the default command update for the web content
375             *         article. With respect to social activities, by setting the
376             *         service context's command to {@link
377             *         com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
378             *         is considered a web content update activity; otherwise it is
379             *         considered a web content add activity.
380             * @return the web content article
381             * @throws PortalException if the user did not have permission to expire the
382             *         web content article, if a matching web content article could not
383             *         be found, or if a portal exception occurred
384             * @throws SystemException if a system exception occurred
385             */
386            public JournalArticle expireArticle(
387                            long groupId, String articleId, double version, String articleURL,
388                            ServiceContext serviceContext)
389                    throws PortalException, SystemException {
390    
391                    JournalArticlePermission.check(
392                            getPermissionChecker(), groupId, articleId, version,
393                            ActionKeys.EXPIRE);
394    
395                    return journalArticleLocalService.expireArticle(
396                            getUserId(), groupId, articleId, version, articleURL,
397                            serviceContext);
398            }
399    
400            /**
401             * Expires the web content article matching the group and article ID,
402             * expiring all of its versions if the
403             * <code>journal.article.expire.all.versions</code> portal property is
404             * <code>true</code>, otherwise expiring only its latest approved version.
405             *
406             * @param  groupId the primary key of the web content article's group
407             * @param  articleId the primary key of the web content article
408             * @param  articleURL the web content article's accessible URL
409             * @param  serviceContext the service context to be applied. Can set the
410             *         modification date, status date, portlet preferences, and can set
411             *         whether to add the default command update for the web content
412             *         article. With respect to social activities, by setting the
413             *         service context's command to {@link
414             *         com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
415             *         is considered a web content update activity; otherwise it is
416             *         considered a web content add activity.
417             * @throws PortalException if the user did not have permission to expire the
418             *         web content article, if a matching web content article could not
419             *         be found, or if a portal exception occurred
420             * @throws SystemException if a system exception occurred
421             */
422            public void expireArticle(
423                            long groupId, String articleId, String articleURL,
424                            ServiceContext serviceContext)
425                    throws PortalException, SystemException {
426    
427                    JournalArticlePermission.check(
428                            getPermissionChecker(), groupId, articleId, ActionKeys.EXPIRE);
429    
430                    journalArticleLocalService.expireArticle(
431                            getUserId(), groupId, articleId, articleURL, serviceContext);
432            }
433    
434            /**
435             * Returns the web content article with the ID.
436             *
437             * @param  id the primary key of the web content article
438             * @return the web content article with the ID
439             * @throws PortalException if a matching web content article could not be
440             *         found or if the user did not have permission to view the web
441             *         content article
442             * @throws SystemException if a system exception occurred
443             */
444            public JournalArticle getArticle(long id)
445                    throws PortalException, SystemException {
446    
447                    JournalArticle article = journalArticleLocalService.getArticle(id);
448    
449                    JournalArticlePermission.check(
450                            getPermissionChecker(), article, ActionKeys.VIEW);
451    
452                    return article;
453            }
454    
455            /**
456             * Returns the latest approved web content article, or the latest unapproved
457             * article if none are approved. Both approved and unapproved articles must
458             * match the group and article ID.
459             *
460             * @param  groupId the primary key of the web content article's group
461             * @param  articleId the primary key of the web content article
462             * @return the matching web content article
463             * @throws PortalException if the user did not have permission to view the
464             *         web content article or if a matching web content article could
465             *         not be found
466             * @throws SystemException if a system exception occurred
467             */
468            public JournalArticle getArticle(long groupId, String articleId)
469                    throws PortalException, SystemException {
470    
471                    JournalArticlePermission.check(
472                            getPermissionChecker(), groupId, articleId, ActionKeys.VIEW);
473    
474                    return journalArticleLocalService.getArticle(groupId, articleId);
475            }
476    
477            /**
478             * Returns the web content article matching the group, article ID, and
479             * version.
480             *
481             * @param  groupId the primary key of the web content article's group
482             * @param  articleId the primary key of the web content article
483             * @param  version the web content article's version
484             * @return the matching web content article
485             * @throws PortalException if the user did not have permission to view the
486             *         web content article or if a matching web content article could
487             *         not be found
488             * @throws SystemException if a system exception occurred
489             */
490            public JournalArticle getArticle(
491                            long groupId, String articleId, double version)
492                    throws PortalException, SystemException {
493    
494                    JournalArticlePermission.check(
495                            getPermissionChecker(), groupId, articleId, version,
496                            ActionKeys.VIEW);
497    
498                    return journalArticleLocalService.getArticle(
499                            groupId, articleId, version);
500            }
501    
502            /**
503             * Returns the web content article matching the group, class name, and class
504             * PK.
505             *
506             * @param  groupId the primary key of the web content article's group
507             * @param  className the DDMStructure class name if the web content article
508             *         is related to a DDM structure, the primary key of the class name
509             *         associated with the article, or {@link
510             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
511             * @param  classPK the primary key of the DDM structure, if the the
512             *         DDMStructure class name is given as the <code>className</code>
513             *         parameter, the primary key of the class associated with the web
514             *         content article, or <code>0</code> otherwise
515             * @return the matching web content article
516             * @throws PortalException if a matching web content article could not be
517             *         found or if the user did not have permission to view the web
518             *         content article
519             * @throws SystemException if a system exception occurred
520             */
521            public JournalArticle getArticle(
522                            long groupId, String className, long classPK)
523                    throws PortalException, SystemException {
524    
525                    JournalArticle article = journalArticleLocalService.getArticle(
526                            groupId, className, classPK);
527    
528                    JournalArticlePermission.check(
529                            getPermissionChecker(), groupId, article.getArticleId(),
530                            article.getVersion(), ActionKeys.VIEW);
531    
532                    return article;
533            }
534    
535            /**
536             * Returns the latest web content article that is approved, or the latest
537             * unapproved article if none are approved. Both approved and unapproved
538             * articles must match the group and URL title.
539             *
540             * @param  groupId the primary key of the web content article's group
541             * @param  urlTitle the web content article's accessible URL title
542             * @return the matching web content article
543             * @throws PortalException if the user did not have permission to view the
544             *         web content article or if a portal exception occurred
545             * @throws SystemException if a system exception occurred
546             */
547            public JournalArticle getArticleByUrlTitle(long groupId, String urlTitle)
548                    throws PortalException, SystemException {
549    
550                    JournalArticle article =
551                            journalArticleLocalService.getArticleByUrlTitle(groupId, urlTitle);
552    
553                    JournalArticlePermission.check(
554                            getPermissionChecker(), article, ActionKeys.VIEW);
555    
556                    return article;
557            }
558    
559            /**
560             * Returns the web content matching the group, article ID, and version.
561             *
562             * @param  groupId the primary key of the web content article's group
563             * @param  articleId the primary key of the web content article
564             * @param  version the web content article's version
565             * @param  languageId the primary key of the language translation to get
566             * @param  themeDisplay the theme display
567             * @return the matching web content
568             * @throws PortalException if the user did not have permission to view the
569             *         web content article, if a matching web content article or DDM
570             *         template could not be found, or if a portal exception occurred
571             * @throws SystemException if a system exception occurred
572             */
573            public String getArticleContent(
574                            long groupId, String articleId, double version, String languageId,
575                            ThemeDisplay themeDisplay)
576                    throws PortalException, SystemException {
577    
578                    JournalArticlePermission.check(
579                            getPermissionChecker(), groupId, articleId, version,
580                            ActionKeys.VIEW);
581    
582                    return journalArticleLocalService.getArticleContent(
583                            groupId, articleId, version, null, languageId, themeDisplay);
584            }
585    
586            /**
587             * Returns the latest web content matching the group and article ID.
588             *
589             * @param  groupId the primary key of the web content article's group
590             * @param  articleId the primary key of the web content article
591             * @param  languageId the primary key of the language translation to get
592             * @param  themeDisplay the theme display
593             * @return the matching web content
594             * @throws PortalException if the user did not have permission to view the
595             *         web content article, if a matching web content article or DDM
596             *         template could not be found, or if a portal exception occurred
597             * @throws SystemException if a system exception occurred
598             */
599            public String getArticleContent(
600                            long groupId, String articleId, String languageId,
601                            ThemeDisplay themeDisplay)
602                    throws PortalException, SystemException {
603    
604                    JournalArticlePermission.check(
605                            getPermissionChecker(), groupId, articleId, ActionKeys.VIEW);
606    
607                    return journalArticleLocalService.getArticleContent(
608                            groupId, articleId, null, languageId, themeDisplay);
609            }
610    
611            /**
612             * Returns all the web content articles matching the group and folder.
613             *
614             * @param  groupId the primary key of the web content article's group
615             * @param  folderId the primary key of the web content article folder
616             * @return the matching web content articles
617             * @throws SystemException if a system exception occurred
618             */
619            public List<JournalArticle> getArticles(long groupId, long folderId)
620                    throws SystemException {
621    
622                    QueryDefinition queryDefinition = new QueryDefinition(
623                            WorkflowConstants.STATUS_ANY);
624    
625                    List<Long> folderIds = new ArrayList<Long>();
626    
627                    folderIds.add(folderId);
628    
629                    return journalArticleFinder.filterFindByG_F(
630                            groupId, folderIds, queryDefinition);
631            }
632    
633            /**
634             * Returns an ordered range of all the web content articles matching the
635             * group and folder.
636             *
637             * <p>
638             * Useful when paginating results. Returns a maximum of <code>end -
639             * start</code> instances. <code>start</code> and <code>end</code> are not
640             * primary keys, they are indexes in the result set. Thus, <code>0</code>
641             * refers to the first result in the set. Setting both <code>start</code>
642             * and <code>end</code> to {@link
643             * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
644             * result set.
645             * </p>
646             *
647             * @param  groupId the primary key of the web content article's group
648             * @param  folderId the primary key of the web content article folder
649             * @param  start the lower bound of the range of web content articles to
650             *         return
651             * @param  end the upper bound of the range of web content articles to
652             *         return (not inclusive)
653             * @param  obc the comparator to order the web content articles
654             * @return the matching web content articles
655             * @throws SystemException if a system exception occurred
656             */
657            public List<JournalArticle> getArticles(
658                            long groupId, long folderId, int start, int end,
659                            OrderByComparator obc)
660                    throws SystemException {
661    
662                    QueryDefinition queryDefinition = new QueryDefinition(
663                            WorkflowConstants.STATUS_ANY, start, end, obc);
664    
665                    List<Long> folderIds = new ArrayList<Long>();
666    
667                    folderIds.add(folderId);
668    
669                    return journalArticleFinder.filterFindByG_F(
670                            groupId, folderIds, queryDefinition);
671            }
672    
673            /**
674             * Returns an ordered range of all the web content articles matching the
675             * group and article ID.
676             *
677             * <p>
678             * Useful when paginating results. Returns a maximum of <code>end -
679             * start</code> instances. <code>start</code> and <code>end</code> are not
680             * primary keys, they are indexes in the result set. Thus, <code>0</code>
681             * refers to the first result in the set. Setting both <code>start</code>
682             * and <code>end</code> to {@link
683             * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
684             * result set.
685             * </p>
686             *
687             * @param  groupId the primary key of the web content article's group
688             * @param  articleId the primary key of the web content article
689             * @param  start the lower bound of the range of web content articles to
690             *         return
691             * @param  end the upper bound of the range of web content articles to
692             *         return (not inclusive)
693             * @param  obc the comparator to order the web content articles
694             * @return the range of matching web content articles ordered by the
695             *         comparator
696             * @throws SystemException if a system exception occurred
697             */
698            public List<JournalArticle> getArticlesByArticleId(
699                            long groupId, String articleId, int start, int end,
700                            OrderByComparator obc)
701                    throws SystemException {
702    
703                    return journalArticlePersistence.filterFindByG_A(
704                            groupId, articleId, start, end, obc);
705            }
706    
707            /**
708             * Returns all the web content articles matching the group and layout UUID.
709             *
710             * @param  groupId the primary key of the web content article's group
711             * @param  layoutUuid the unique string identifying the web content
712             *         article's display page
713             * @return the matching web content articles
714             * @throws SystemException if a system exception occurred
715             */
716            public List<JournalArticle> getArticlesByLayoutUuid(
717                            long groupId, String layoutUuid)
718                    throws SystemException {
719    
720                    return journalArticlePersistence.filterFindByG_L(groupId, layoutUuid);
721            }
722    
723            /**
724             * Returns an ordered range of all the web content articles matching the
725             * group, class name ID, DDM structure key, and workflow status.
726             *
727             * <p>
728             * Useful when paginating results. Returns a maximum of <code>end -
729             * start</code> instances. <code>start</code> and <code>end</code> are not
730             * primary keys, they are indexes in the result set. Thus, <code>0</code>
731             * refers to the first result in the set. Setting both <code>start</code>
732             * and <code>end</code> to {@link
733             * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
734             * result set.
735             * </p>
736             *
737             * @param  groupId the primary key of the web content article's group
738             * @param  classNameId the primary key of the DDMStructure class if the web
739             *         content article is related to a DDM structure, the primary key of
740             *         the class name associated with the article, or {@link
741             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
742             * @param  ddmStructureKey the primary key of the web content article's DDM
743             *         structure
744             * @param  status the web content article's workflow status. For more
745             *         information see {@link WorkflowConstants} for constants starting
746             *         with the "STATUS_" prefix.
747             * @param  start the lower bound of the range of web content articles to
748             *         return
749             * @param  end the upper bound of the range of web content articles to
750             *         return (not inclusive)
751             * @param  obc the comparator to order the web content articles
752             * @return the range of matching web content articles ordered by the
753             *         comparator
754             * @throws SystemException if a system exception occurred
755             */
756            public List<JournalArticle> getArticlesByStructureId(
757                            long groupId, long classNameId, String ddmStructureKey, int status,
758                            int start, int end, OrderByComparator obc)
759                    throws SystemException {
760    
761                    QueryDefinition queryDefinition = new QueryDefinition(
762                            status, start, end, obc);
763    
764                    return journalArticleFinder.filterFindByG_C_S(
765                            groupId, classNameId, ddmStructureKey, queryDefinition);
766            }
767    
768            /**
769             * Returns an ordered range of all the web content articles matching the
770             * group, default class name ID, and DDM structure key.
771             *
772             * <p>
773             * Useful when paginating results. Returns a maximum of <code>end -
774             * start</code> instances. <code>start</code> and <code>end</code> are not
775             * primary keys, they are indexes in the result set. Thus, <code>0</code>
776             * refers to the first result in the set. Setting both <code>start</code>
777             * and <code>end</code> to {@link
778             * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
779             * result set.
780             * </p>
781             *
782             * @param  groupId the primary key of the web content article's group
783             * @param  ddmStructureKey the primary key of the web content article's DDM
784             *         structure
785             * @param  start the lower bound of the range of web content articles to
786             *         return
787             * @param  end the upper bound of the range of web content articles to
788             *         return (not inclusive)
789             * @param  obc the comparator to order the web content articles
790             * @return the range of matching web content articles ordered by the
791             *         comparator
792             * @throws SystemException if a system exception occurred
793             */
794            public List<JournalArticle> getArticlesByStructureId(
795                            long groupId, String ddmStructureKey, int start, int end,
796                            OrderByComparator obc)
797                    throws SystemException {
798    
799                    QueryDefinition queryDefinition = new QueryDefinition(
800                            WorkflowConstants.STATUS_ANY, start, end, obc);
801    
802                    return journalArticleFinder.filterFindByG_C_S(
803                            groupId, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
804                            ddmStructureKey, queryDefinition);
805            }
806    
807            /**
808             * Returns the number of web content articles matching the group and folder.
809             *
810             * @param  groupId the primary key of the web content article's group
811             * @param  folderId the primary key of the web content article folder
812             * @return the number of matching web content articles
813             * @throws SystemException if a system exception occurred
814             */
815            public int getArticlesCount(long groupId, long folderId)
816                    throws SystemException {
817    
818                    QueryDefinition queryDefinition = new QueryDefinition(
819                            WorkflowConstants.STATUS_ANY);
820    
821                    List<Long> folderIds = new ArrayList<Long>();
822    
823                    folderIds.add(folderId);
824    
825                    return journalArticleFinder.filterCountByG_F(
826                            groupId, folderIds, queryDefinition);
827            }
828    
829            /**
830             * Returns the number of web content articles matching the group and article
831             * ID.
832             *
833             * @param  groupId the primary key of the web content article's group
834             * @param  articleId the primary key of the web content article
835             * @return the number of matching web content articles
836             * @throws SystemException if a system exception occurred
837             */
838            public int getArticlesCountByArticleId(long groupId, String articleId)
839                    throws SystemException {
840    
841                    return journalArticlePersistence.filterCountByG_A(groupId, articleId);
842            }
843    
844            /**
845             * Returns the number of web content articles matching the group, class name
846             * ID, DDM structure key, and workflow status.
847             *
848             * @param  groupId the primary key of the web content article's group
849             * @param  classNameId the primary key of the DDMStructure class if the web
850             *         content article is related to a DDM structure, the primary key of
851             *         the class name associated with the article, or {@link
852             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
853             * @param  ddmStructureKey the primary key of the web content article's DDM
854             *         structure
855             * @param  status the web content article's workflow status. For more
856             *         information see {@link WorkflowConstants} for constants starting
857             *         with the "STATUS_" prefix.
858             * @return the number of matching web content articles
859             * @throws SystemException if a system exception occurred
860             */
861            public int getArticlesCountByStructureId(
862                            long groupId, long classNameId, String ddmStructureKey, int status)
863                    throws SystemException {
864    
865                    return journalArticleFinder.filterCountByG_C_S(
866                            groupId, classNameId, ddmStructureKey, new QueryDefinition(status));
867            }
868    
869            /**
870             * Returns the number of web content articles matching the group, default
871             * class name ID, and DDM structure key.
872             *
873             * @param  groupId the primary key of the web content article's group
874             * @param  ddmStructureKey the primary key of the web content article's DDM
875             *         structure
876             * @return the number of matching web content articles
877             * @throws SystemException if a system exception occurred
878             */
879            public int getArticlesCountByStructureId(
880                            long groupId, String ddmStructureKey)
881                    throws SystemException {
882    
883                    return getArticlesCountByStructureId(
884                            groupId, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
885                            ddmStructureKey, WorkflowConstants.STATUS_ANY);
886            }
887    
888            /**
889             * Returns the web content article matching the URL title that is currently
890             * displayed or next to be displayed if no article is currently displayed.
891             *
892             * @param  groupId the primary key of the web content article's group
893             * @param  urlTitle the web content article's accessible URL title
894             * @return the web content article matching the URL title that is currently
895             *         displayed, or next one to be displayed if no version of the
896             *         article is currently displayed
897             * @throws PortalException if the user did not have permission to view the
898             *         web content article or if no approved matching web content
899             *         articles could be found
900             * @throws SystemException if a system exception occurred
901             */
902            public JournalArticle getDisplayArticleByUrlTitle(
903                            long groupId, String urlTitle)
904                    throws PortalException, SystemException {
905    
906                    JournalArticle article =
907                            journalArticleLocalService.getDisplayArticleByUrlTitle(
908                                    groupId, urlTitle);
909    
910                    JournalArticlePermission.check(
911                            getPermissionChecker(), article, ActionKeys.VIEW);
912    
913                    return article;
914            }
915    
916            /**
917             * Returns the number of folders containing web content articles belonging
918             * to the group.
919             *
920             * @param  groupId the primary key of the web content article's group
921             * @param  folderIds the primary keys of the web content article folders
922             *         (optionally {@link java.util.Collections#EMPTY_LIST})
923             * @return the number of matching folders containing web content articles
924             * @throws SystemException if a system exception occurred
925             */
926            public int getFoldersAndArticlesCount(long groupId, List<Long> folderIds)
927                    throws SystemException {
928    
929                    return journalArticlePersistence.filterCountByG_F(
930                            groupId,
931                            ArrayUtil.toArray(folderIds.toArray(new Long[folderIds.size()])));
932            }
933    
934            /**
935             * Returns an ordered range of all the web content articles matching the
936             * group, user, the root folder or any of its subfolders.
937             *
938             * @param  groupId the primary key of the web content article's group
939             * @param  userId the primary key of the user (optionally <code>0</code>)
940             * @param  rootFolderId the primary key of the root folder to begin the
941             *         search
942             * @param  start the lower bound of the range of web content articles to
943             *         return
944             * @param  end the upper bound of the range of web content articles to
945             *         return (not inclusive)
946             * @param  orderByComparator the comparator to order the web content
947             *         articles
948             * @return the range of matching web content articles ordered by the
949             *         comparator
950             * @throws PortalException if the root folder could not be found, if the
951             *         current user did not have permission to view the root folder, or
952             *         if a portal exception occurred
953             * @throws SystemException if a system exception occurred
954             */
955            public List<JournalArticle> getGroupArticles(
956                            long groupId, long userId, long rootFolderId, int start, int end,
957                            OrderByComparator orderByComparator)
958                    throws PortalException, SystemException {
959    
960                    List<Long> folderIds = journalFolderService.getFolderIds(
961                            groupId, rootFolderId);
962    
963                    QueryDefinition queryDefinition = new QueryDefinition(
964                            WorkflowConstants.STATUS_ANY, start, end, orderByComparator);
965    
966                    if (folderIds.isEmpty()) {
967                            return Collections.emptyList();
968                    }
969                    else if (userId <= 0) {
970                            return journalArticleFinder.filterFindByG_F(
971                                    groupId, folderIds, queryDefinition);
972                    }
973                    else {
974                            return journalArticleFinder.filterFindByG_U_F_C(
975                                    groupId, userId, folderIds,
976                                    JournalArticleConstants.CLASSNAME_ID_DEFAULT, queryDefinition);
977                    }
978            }
979    
980            /**
981             * Returns the number of web content articles matching the group, user, and
982             * the root folder or any of its subfolders.
983             *
984             * @param  groupId the primary key of the web content article's group
985             * @param  userId the primary key of the user (optionally <code>0</code>)
986             * @param  rootFolderId the primary key of the root folder to begin the
987             *         search
988             * @return the number of matching web content articles
989             * @throws PortalException if the root folder could not be found, if the
990             *         current user did not have permission to view the root folder, or
991             *         if a portal exception occurred
992             * @throws SystemException if a system exception occurred
993             */
994            public int getGroupArticlesCount(
995                            long groupId, long userId, long rootFolderId)
996                    throws PortalException, SystemException {
997    
998                    List<Long> folderIds = journalFolderService.getFolderIds(
999                            groupId, rootFolderId);
1000    
1001                    QueryDefinition queryDefinition = new QueryDefinition(
1002                            WorkflowConstants.STATUS_ANY);
1003    
1004                    if (folderIds.isEmpty()) {
1005                            return 0;
1006                    }
1007                    else if (userId <= 0) {
1008                            return journalArticleFinder.filterCountByG_F(
1009                                    groupId, folderIds, queryDefinition);
1010                    }
1011                    else {
1012                            return journalArticleFinder.filterCountByG_U_F_C(
1013                                    groupId, userId, folderIds,
1014                                    JournalArticleConstants.CLASSNAME_ID_DEFAULT, queryDefinition);
1015                    }
1016            }
1017    
1018            /**
1019             * Returns the latest web content article matching the resource primary key,
1020             * preferring articles with approved workflow status.
1021             *
1022             * @param  resourcePrimKey the primary key of the resource instance
1023             * @return the latest web content article matching the resource primary key,
1024             *         preferring articles with approved workflow status
1025             * @throws PortalException if the user did not have permission to view the
1026             *         web content article or if a matching web content article could
1027             *         not be found
1028             * @throws SystemException if a system exception occurred
1029             */
1030            public JournalArticle getLatestArticle(long resourcePrimKey)
1031                    throws PortalException, SystemException {
1032    
1033                    JournalArticlePermission.check(
1034                            getPermissionChecker(), resourcePrimKey, ActionKeys.VIEW);
1035    
1036                    return journalArticleLocalService.getLatestArticle(resourcePrimKey);
1037            }
1038    
1039            /**
1040             * Returns the latest web content article matching the group, article ID,
1041             * and workflow status.
1042             *
1043             * @param  groupId the primary key of the web content article's group
1044             * @param  articleId the primary key of the web content article
1045             * @param  status the web content article's workflow status. For more
1046             *         information see {@link WorkflowConstants} for constants starting
1047             *         with the "STATUS_" prefix.
1048             * @return the latest matching web content article
1049             * @throws PortalException if the user did not have permission to view the
1050             *         web content article or if a matching web content article could
1051             *         not be found
1052             * @throws SystemException if a system exception occurred
1053             */
1054            public JournalArticle getLatestArticle(
1055                            long groupId, String articleId, int status)
1056                    throws PortalException, SystemException {
1057    
1058                    JournalArticlePermission.check(
1059                            getPermissionChecker(), groupId, articleId, status,
1060                            ActionKeys.VIEW);
1061    
1062                    return journalArticleLocalService.getLatestArticle(
1063                            groupId, articleId, status);
1064            }
1065    
1066            /**
1067             * Returns the latest web content article matching the group, class name ID,
1068             * and class PK.
1069             *
1070             * @param  groupId the primary key of the web content article's group
1071             * @param  className the DDMStructure class name if the web content article
1072             *         is related to a DDM structure, the class name associated with the
1073             *         article, or {@link JournalArticleConstants#CLASSNAME_ID_DEFAULT}
1074             *         otherwise
1075             * @param  classPK the primary key of the DDM structure, if the DDMStructure
1076             *         class name is given as the <code>className</code> parameter, the
1077             *         primary key of the class associated with the web content article,
1078             *         or <code>0</code> otherwise
1079             * @return the latest matching web content article
1080             * @throws PortalException if a matching web content article could not be
1081             *         found or if the user did not have permission to view the web
1082             *         content article
1083             * @throws SystemException if a system exception occurred
1084             */
1085            public JournalArticle getLatestArticle(
1086                            long groupId, String className, long classPK)
1087                    throws PortalException, SystemException {
1088    
1089                    JournalArticle article = journalArticleLocalService.getLatestArticle(
1090                            groupId, className, classPK);
1091    
1092                    JournalArticlePermission.check(
1093                            getPermissionChecker(), groupId, article.getArticleId(),
1094                            article.getVersion(), ActionKeys.VIEW);
1095    
1096                    return article;
1097            }
1098    
1099            /**
1100             * Moves all versions of the the web content article matching the group and
1101             * article ID to the folder.
1102             *
1103             * @param  groupId the primary key of the web content article's group
1104             * @param  articleId the primary key of the web content article
1105             * @param  newFolderId the primary key of the web content article's new
1106             *         folder
1107             * @throws PortalException if the user did not have permission to update any
1108             *         one of the versions of the web content article or if any one of
1109             *         the versions of the web content article could not be moved to the
1110             *         folder
1111             * @throws SystemException if a system exception occurred
1112             */
1113            public void moveArticle(long groupId, String articleId, long newFolderId)
1114                    throws PortalException, SystemException {
1115    
1116                    List<JournalArticle> articles = journalArticlePersistence.findByG_A(
1117                            groupId, articleId);
1118    
1119                    for (JournalArticle article : articles) {
1120                            JournalArticlePermission.check(
1121                                    getPermissionChecker(), article, ActionKeys.UPDATE);
1122    
1123                            journalArticleLocalService.moveArticle(
1124                                    groupId, articleId, newFolderId);
1125                    }
1126            }
1127    
1128            /**
1129             * Moves the web content article from the Recycle Bin to the folder.
1130             *
1131             * @param  groupId the primary key of the web content article's group
1132             * @param  resourcePrimKey the primary key of the resource instance
1133             * @param  newFolderId the primary key of the web content article's new
1134             *         folder
1135             * @param  serviceContext the service context to be applied. Can set the
1136             *         modification date, portlet preferences, and can set whether to
1137             *         add the default command update for the web content article. With
1138             *         respect to social activities, by setting the service context's
1139             *         command to {@link
1140             *         com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
1141             *         is considered a web content update activity; otherwise it is
1142             *         considered a web content add activity.
1143             * @return the updated web content article, which was moved from the Recycle
1144             *         Bin to the folder
1145             * @throws PortalException if the user did not have permission to view or
1146             *         update the web content article, if a matching trashed web content
1147             *         article could not be found, or if a portal exception occurred
1148             * @throws SystemException if a system exception occurred
1149             */
1150            public JournalArticle moveArticleFromTrash(
1151                            long groupId, long resourcePrimKey, long newFolderId,
1152                            ServiceContext serviceContext)
1153                    throws PortalException, SystemException {
1154    
1155                    JournalArticle article = getLatestArticle(resourcePrimKey);
1156    
1157                    JournalArticlePermission.check(
1158                            getPermissionChecker(), article, ActionKeys.UPDATE);
1159    
1160                    return journalArticleLocalService.moveArticleFromTrash(
1161                            getUserId(), groupId, article, newFolderId, serviceContext);
1162            }
1163    
1164            /**
1165             * Moves the web content article from the Recycle Bin to the folder.
1166             *
1167             * @param  groupId the primary key of the web content article's group
1168             * @param  articleId the primary key of the web content article
1169             * @param  newFolderId the primary key of the web content article's new
1170             *         folder
1171             * @param  serviceContext the service context to be applied. Can set the
1172             *         modification date, portlet preferences, and can set whether to
1173             *         add the default command update for the web content article. With
1174             *         respect to social activities, by setting the service context's
1175             *         command to {@link
1176             *         com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
1177             *         is considered a web content update activity; otherwise it is
1178             *         considered a web content add activity.
1179             * @return the updated web content article, which was moved from the Recycle
1180             *         Bin to the folder
1181             * @throws PortalException if the user did not have permission to view or
1182             *         update the web content article, if a trashed web content article
1183             *         with the primary key could not be found, or if a portal exception
1184             *         occurred
1185             * @throws SystemException if a system exception occurred
1186             */
1187            public JournalArticle moveArticleFromTrash(
1188                            long groupId, String articleId, long newFolderId,
1189                            ServiceContext serviceContext)
1190                    throws PortalException, SystemException {
1191    
1192                    JournalArticle article = getLatestArticle(
1193                            groupId, articleId, WorkflowConstants.STATUS_IN_TRASH);
1194    
1195                    JournalArticlePermission.check(
1196                            getPermissionChecker(), groupId, articleId, ActionKeys.UPDATE);
1197    
1198                    return journalArticleLocalService.moveArticleFromTrash(
1199                            getUserId(), groupId, article, newFolderId, serviceContext);
1200            }
1201    
1202            /**
1203             * Moves the latest version of the web content article matching the group
1204             * and article ID to the recycle bin.
1205             *
1206             * @param  groupId the primary key of the web content article's group
1207             * @param  articleId the primary key of the web content article
1208             * @return the moved web content article or <code>null</code> if no matching
1209             *         article was found
1210             * @throws PortalException if the user did not have permission to move the
1211             *         article to the Recycle Bin or if a portal exception occurred
1212             * @throws SystemException if a system exception occurred
1213             */
1214            public JournalArticle moveArticleToTrash(long groupId, String articleId)
1215                    throws PortalException, SystemException {
1216    
1217                    JournalArticlePermission.check(
1218                            getPermissionChecker(), groupId, articleId, ActionKeys.DELETE);
1219    
1220                    return journalArticleLocalService.moveArticleToTrash(
1221                            getUserId(), groupId, articleId);
1222            }
1223    
1224            /**
1225             * Removes the web content of all the company's web content articles
1226             * matching the language.
1227             *
1228             * @param  companyId the primary key of the web content article's company
1229             * @param  languageId the primary key of the language locale to remove
1230             * @throws PortalException if the user did not have permission to update any
1231             *         one of the the web content articles or if web content matching
1232             *         the language could not be found for any one of the articles
1233             * @throws SystemException if a system exception occurred
1234             */
1235            public void removeArticleLocale(long companyId, String languageId)
1236                    throws PortalException, SystemException {
1237    
1238                    for (JournalArticle article :
1239                                    journalArticlePersistence.findByCompanyId(companyId)) {
1240    
1241                            removeArticleLocale(
1242                                    article.getGroupId(), article.getArticleId(),
1243                                    article.getVersion(), languageId);
1244                    }
1245            }
1246    
1247            /**
1248             * Removes the web content of the web content article matching the group,
1249             * article ID, and version, and language.
1250             *
1251             * @param  groupId the primary key of the web content article's group
1252             * @param  articleId the primary key of the web content article
1253             * @param  version the web content article's version
1254             * @param  languageId the primary key of the language locale to remove
1255             * @return the updated web content article with the locale removed
1256             * @throws PortalException if the user did not have permission to update the
1257             *         web content article or if a matching web content article could
1258             *         not be found
1259             * @throws SystemException if a system exception occurred
1260             */
1261            public JournalArticle removeArticleLocale(
1262                            long groupId, String articleId, double version, String languageId)
1263                    throws PortalException, SystemException {
1264    
1265                    JournalArticlePermission.check(
1266                            getPermissionChecker(), groupId, articleId, version,
1267                            ActionKeys.UPDATE);
1268    
1269                    return journalArticleLocalService.removeArticleLocale(
1270                            groupId, articleId, version, languageId);
1271            }
1272    
1273            /**
1274             * Restores the web content article associated with the resource primary key
1275             * from the Recycle Bin.
1276             *
1277             * @param  resourcePrimKey the primary key of the resource instance
1278             * @throws PortalException if a matching web content article could not be
1279             *         found in the Recycle Bin, if the user did not have permission to
1280             *         view or restore the article, or if a portal exception occurred
1281             * @throws SystemException if a system exception occurred
1282             */
1283            public void restoreArticleFromTrash(long resourcePrimKey)
1284                    throws PortalException, SystemException {
1285    
1286                    JournalArticle article = getLatestArticle(resourcePrimKey);
1287    
1288                    JournalArticlePermission.check(
1289                            getPermissionChecker(), article, ActionKeys.DELETE);
1290    
1291                    journalArticleLocalService.restoreArticleFromTrash(
1292                            getUserId(), article);
1293            }
1294    
1295            /**
1296             * Restores the web content article from the Recycle Bin.
1297             *
1298             * @param  groupId the primary key of the web content article's group
1299             * @param  articleId the primary key of the web content article
1300             * @throws PortalException if the web content article with the primary key
1301             *         could not be found in the Recycle Bin, if the user did not have
1302             *         permission to restore the article, or if a portal exception
1303             *         occurred
1304             * @throws SystemException if a system exception occurred
1305             */
1306            public void restoreArticleFromTrash(long groupId, String articleId)
1307                    throws PortalException, SystemException {
1308    
1309                    JournalArticle article = getLatestArticle(
1310                            groupId, articleId, WorkflowConstants.STATUS_IN_TRASH);
1311    
1312                    restoreArticleFromTrash(article.getResourcePrimKey());
1313            }
1314    
1315            /**
1316             * Returns an ordered range of all the web content articles matching the
1317             * parameters, including a keywords parameter for matching with the
1318             * article's ID, title, description, and content, a DDM structure key
1319             * parameter, and a DDM template key parameter.
1320             *
1321             * <p>
1322             * Useful when paginating results. Returns a maximum of <code>end -
1323             * start</code> instances. <code>start</code> and <code>end</code> are not
1324             * primary keys, they are indexes in the result set. Thus, <code>0</code>
1325             * refers to the first result in the set. Setting both <code>start</code>
1326             * and <code>end</code> to {@link
1327             * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
1328             * result set.
1329             * </p>
1330             *
1331             * @param  companyId the primary key of the web content article's company
1332             * @param  groupId the primary key of the group (optionally <code>0</code>)
1333             * @param  folderIds the primary keys of the web content article folders
1334             *         (optionally {@link java.util.Collections#EMPTY_LIST})
1335             * @param  classNameId the primary key of the DDMStructure class if the web
1336             *         content article is related to a DDM structure, the primary key of
1337             *         the class name associated with the article, or {@link
1338             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
1339             * @param  keywords the keywords (space separated), which may occur in the
1340             *         web content article ID, title, description, or content
1341             *         (optionally <code>null</code>). If the keywords value is not
1342             *         <code>null</code>, the search uses the OR operator in connecting
1343             *         query criteria; otherwise it uses the AND operator.
1344             * @param  version the web content article's version (optionally
1345             *         <code>null</code>)
1346             * @param  type the web content article's type (optionally
1347             *         <code>null</code>)
1348             * @param  ddmStructureKey the primary key of the web content article's DDM
1349             *         structure, if the article is related to a DDM structure, or
1350             *         <code>null</code> otherwise
1351             * @param  ddmTemplateKey the primary key of the web content article's DDM
1352             *         template (optionally <code>null</code>). If the article is
1353             *         related to a DDM structure, the template's structure must match
1354             *         it.
1355             * @param  displayDateGT the date after which a matching web content
1356             *         article's display date must be after (optionally
1357             *         <code>null</code>)
1358             * @param  displayDateLT the date before which a matching web content
1359             *         article's display date must be before (optionally
1360             *         <code>null</code>)
1361             * @param  status the web content article's workflow status. For more
1362             *         information see {@link WorkflowConstants} for constants starting
1363             *         with the "STATUS_" prefix.
1364             * @param  reviewDate the web content article's scheduled review date
1365             *         (optionally <code>null</code>)
1366             * @param  start the lower bound of the range of web content articles to
1367             *         return
1368             * @param  end the upper bound of the range of web content articles to
1369             *         return (not inclusive)
1370             * @param  obc the comparator to order the web content articles
1371             * @return the range of matching web content articles ordered by the
1372             *         comparator
1373             * @throws SystemException if a system exception occurred
1374             */
1375            public List<JournalArticle> search(
1376                            long companyId, long groupId, List<Long> folderIds,
1377                            long classNameId, String keywords, Double version, String type,
1378                            String ddmStructureKey, String ddmTemplateKey, Date displayDateGT,
1379                            Date displayDateLT, int status, Date reviewDate, int start, int end,
1380                            OrderByComparator obc)
1381                    throws SystemException {
1382    
1383                    return journalArticleFinder.filterFindByKeywords(
1384                            companyId, groupId, folderIds, classNameId, keywords, version, type,
1385                            ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT,
1386                            status, reviewDate, start, end, obc);
1387            }
1388    
1389            /**
1390             * Returns an ordered range of all the web content articles matching the
1391             * parameters, including keyword parameters for article ID, title,
1392             * description, and content, a DDM structure key parameter, a DDM template
1393             * key parameter, and an AND operator switch.
1394             *
1395             * <p>
1396             * Useful when paginating results. Returns a maximum of <code>end -
1397             * start</code> instances. <code>start</code> and <code>end</code> are not
1398             * primary keys, they are indexes in the result set. Thus, <code>0</code>
1399             * refers to the first result in the set. Setting both <code>start</code>
1400             * and <code>end</code> to {@link
1401             * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
1402             * result set.
1403             * </p>
1404             *
1405             * @param  companyId the primary key of the web content article's company
1406             * @param  groupId the primary key of the group (optionally <code>0</code>)
1407             * @param  folderIds the primary keys of the web content article folders
1408             *         (optionally {@link java.util.Collections#EMPTY_LIST})
1409             * @param  classNameId the primary key of the DDMStructure class if the web
1410             *         content article is related to a DDM structure, the primary key of
1411             *         the class name associated with the article, or {@link
1412             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
1413             * @param  articleId the article ID keywords (space separated, optionally
1414             *         <code>null</code>)
1415             * @param  version the web content article's version (optionally
1416             *         <code>null</code>)
1417             * @param  title the title keywords (space separated, optionally
1418             *         <code>null</code>)
1419             * @param  description the description keywords (space separated, optionally
1420             *         <code>null</code>)
1421             * @param  content the content keywords (space separated, optionally
1422             *         <code>null</code>)
1423             * @param  type the web content article's type (optionally
1424             *         <code>null</code>)
1425             * @param  ddmStructureKey the primary key of the web content article's DDM
1426             *         structure, if the article is related to a DDM structure, or
1427             *         <code>null</code> otherwise
1428             * @param  ddmTemplateKey the primary key of the web content article's DDM
1429             *         template (optionally <code>null</code>). If the article is
1430             *         related to a DDM structure, the template's structure must match
1431             *         it.
1432             * @param  displayDateGT the date after which a matching web content
1433             *         article's display date must be after (optionally
1434             *         <code>null</code>)
1435             * @param  displayDateLT the date before which a matching web content
1436             *         article's display date must be before (optionally
1437             *         <code>null</code>)
1438             * @param  status the web content article's workflow status. For more
1439             *         information see {@link WorkflowConstants} for constants starting
1440             *         with the "STATUS_" prefix.
1441             * @param  reviewDate the web content article's scheduled review date
1442             *         (optionally <code>null</code>)
1443             * @param  andOperator whether every field must match its value or keywords,
1444             *         or just one field must match. Company, group, folder IDs, class
1445             *         name ID, and status must all match their values.
1446             * @param  start the lower bound of the range of web content articles to
1447             *         return
1448             * @param  end the upper bound of the range of web content articles to
1449             *         return (not inclusive)
1450             * @param  obc the comparator to order the web content articles
1451             * @return the range of matching web content articles ordered by the
1452             *         comparator
1453             * @throws SystemException if a system exception occurred
1454             */
1455            public List<JournalArticle> search(
1456                            long companyId, long groupId, List<Long> folderIds,
1457                            long classNameId, String articleId, Double version, String title,
1458                            String description, String content, String type,
1459                            String ddmStructureKey, String ddmTemplateKey, Date displayDateGT,
1460                            Date displayDateLT, int status, Date reviewDate,
1461                            boolean andOperator, int start, int end, OrderByComparator obc)
1462                    throws SystemException {
1463    
1464                    QueryDefinition queryDefinition = new QueryDefinition(
1465                            status, start, end, obc);
1466    
1467                    return journalArticleFinder.filterFindByC_G_F_C_A_V_T_D_C_T_S_T_D_R(
1468                            companyId, groupId, folderIds, classNameId, articleId, version,
1469                            title, description, content, type, ddmStructureKey, ddmTemplateKey,
1470                            displayDateGT, displayDateLT, reviewDate, andOperator,
1471                            queryDefinition);
1472            }
1473    
1474            /**
1475             * Returns an ordered range of all the web content articles matching the
1476             * parameters, including keyword parameters for article ID, title,
1477             * description, and content, a DDM structure keys (plural) parameter, a DDM
1478             * template keys (plural) parameter, and an AND operator switch.
1479             *
1480             * <p>
1481             * Useful when paginating results. Returns a maximum of <code>end -
1482             * start</code> instances. <code>start</code> and <code>end</code> are not
1483             * primary keys, they are indexes in the result set. Thus, <code>0</code>
1484             * refers to the first result in the set. Setting both <code>start</code>
1485             * and <code>end</code> to {@link
1486             * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
1487             * result set.
1488             * </p>
1489             *
1490             * @param  companyId the primary key of the web content article's company
1491             * @param  groupId the primary key of the group (optionally <code>0</code>)
1492             * @param  folderIds the primary keys of the web content article folders
1493             *         (optionally {@link java.util.Collections#EMPTY_LIST})
1494             * @param  classNameId the primary key of the DDMStructure class if the web
1495             *         content article is related to a DDM structure, the primary key of
1496             *         the class name associated with the article, or {@link
1497             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
1498             * @param  articleId the article ID keywords (space separated, optionally
1499             *         <code>null</code>)
1500             * @param  version the web content article's version (optionally
1501             *         <code>null</code>)
1502             * @param  title the title keywords (space separated, optionally
1503             *         <code>null</code>)
1504             * @param  description the description keywords (space separated, optionally
1505             *         <code>null</code>)
1506             * @param  content the content keywords (space separated, optionally
1507             *         <code>null</code>)
1508             * @param  type the web content article's type (optionally
1509             *         <code>null</code>)
1510             * @param  ddmStructureKeys the primary keys of the web content article's
1511             *         DDM structures, if the article is related to a DDM structure, or
1512             *         <code>null</code> otherwise
1513             * @param  ddmTemplateKeys the primary keys of the web content article's DDM
1514             *         templates (originally <code>null</code>). If the articles are
1515             *         related to a DDM structure, the template's structure must match
1516             *         it.
1517             * @param  displayDateGT the date after which a matching web content
1518             *         article's display date must be after (optionally
1519             *         <code>null</code>)
1520             * @param  displayDateLT the date before which a matching web content
1521             *         article's display date must be before (optionally
1522             *         <code>null</code>)
1523             * @param  status the web content article's workflow status. For more
1524             *         information see {@link WorkflowConstants} for constants starting
1525             *         with the "STATUS_" prefix.
1526             * @param  reviewDate the web content article's scheduled review date
1527             *         (optionally <code>null</code>)
1528             * @param  andOperator whether every field must match its value or keywords,
1529             *         or just one field must match.  Company, group, folder IDs, class
1530             *         name ID, and status must all match their values.
1531             * @param  start the lower bound of the range of web content articles to
1532             *         return
1533             * @param  end the upper bound of the range of web content articles to
1534             *         return (not inclusive)
1535             * @param  obc the comparator to order the web content articles
1536             * @return the range of matching web content articles ordered by the
1537             *         comparator
1538             * @throws SystemException if a system exception occurred
1539             */
1540            public List<JournalArticle> search(
1541                            long companyId, long groupId, List<Long> folderIds,
1542                            long classNameId, String articleId, Double version, String title,
1543                            String description, String content, String type,
1544                            String[] ddmStructureKeys, String[] ddmTemplateKeys,
1545                            Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
1546                            boolean andOperator, int start, int end, OrderByComparator obc)
1547                    throws SystemException {
1548    
1549                    QueryDefinition queryDefinition = new QueryDefinition(
1550                            status, start, end, obc);
1551    
1552                    return journalArticleFinder.filterFindByC_G_F_C_A_V_T_D_C_T_S_T_D_R(
1553                            companyId, groupId, folderIds, classNameId, articleId, version,
1554                            title, description, content, type, ddmStructureKeys,
1555                            ddmTemplateKeys, displayDateGT, displayDateLT, reviewDate,
1556                            andOperator, queryDefinition);
1557            }
1558    
1559            /**
1560             * Returns the number of web content articles matching the parameters,
1561             * including a keywords parameter for matching with the article's ID, title,
1562             * description, and content, a DDM structure key parameter, and a DDM
1563             * template key parameter.
1564             *
1565             * @param  companyId the primary key of the web content article's company
1566             * @param  groupId the primary key of the group (optionally <code>0</code>)
1567             * @param  folderIds the primary keys of the web content article folders
1568             *         (optionally {@link java.util.Collections#EMPTY_LIST})
1569             * @param  classNameId the primary key of the DDMStructure class if the web
1570             *         content article is related to a DDM structure, the primary key of
1571             *         the class name associated with the article, or {@link
1572             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
1573             * @param  keywords the keywords (space separated), which may occur in the
1574             *         web content article ID, title, description, or content
1575             *         (optionally <code>null</code>). If the keywords value is not
1576             *         <code>null</code>, the search uses the OR operator in connecting
1577             *         query criteria; otherwise it uses the AND operator.
1578             * @param  version the web content article's version (optionally
1579             *         <code>null</code>)
1580             * @param  type the web content article's type (optionally
1581             *         <code>null</code>)
1582             * @param  ddmStructureKey the primary key of the web content article's DDM
1583             *         structure, if the article is related to a DDM structure, or
1584             *         <code>null</code> otherwise
1585             * @param  ddmTemplateKey the primary key of the web content article's DDM
1586             *         template (optionally <code>null</code>). If the article is
1587             *         related to a DDM structure, the template's structure must match
1588             *         it.
1589             * @param  displayDateGT the date after which a matching web content
1590             *         article's display date must be after (optionally
1591             *         <code>null</code>)
1592             * @param  displayDateLT the date before which a matching web content
1593             *         article's display date must be before (optionally
1594             *         <code>null</code>)
1595             * @param  status the web content article's workflow status. For more
1596             *         information see {@link WorkflowConstants} for constants starting
1597             *         with the "STATUS_" prefix.
1598             * @param  reviewDate the web content article's scheduled review date
1599             *         (optionally <code>null</code>)
1600             * @return the number of matching web content articles
1601             * @throws SystemException if a system exception occurred
1602             */
1603            public int searchCount(
1604                            long companyId, long groupId, List<Long> folderIds,
1605                            long classNameId, String keywords, Double version, String type,
1606                            String ddmStructureKey, String ddmTemplateKey, Date displayDateGT,
1607                            Date displayDateLT, int status, Date reviewDate)
1608                    throws SystemException {
1609    
1610                    return journalArticleFinder.filterCountByKeywords(
1611                            companyId, groupId, folderIds, classNameId, keywords, version, type,
1612                            ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT,
1613                            status, reviewDate);
1614            }
1615    
1616            /**
1617             * Returns the number of web content articles matching the parameters,
1618             * including keyword parameters for article ID, title, description, and
1619             * content, a DDM structure key parameter, a DDM template key parameter, and
1620             * an AND operator switch.
1621             *
1622             * @param  companyId the primary key of the web content article's company
1623             * @param  groupId the primary key of the group (optionally <code>0</code>)
1624             * @param  folderIds the primary keys of the web content article folders
1625             *         (optionally {@link java.util.Collections#EMPTY_LIST})
1626             * @param  classNameId the primary key of the DDMStructure class if the web
1627             *         content article is related to a DDM structure, the primary key of
1628             *         the class name associated with the article, or {@link
1629             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
1630             * @param  articleId the article ID keywords (space separated, optionally
1631             *         <code>null</code>)
1632             * @param  version the web content article's version (optionally
1633             *         <code>null</code>)
1634             * @param  title the title keywords (space separated, optionally
1635             *         <code>null</code>)
1636             * @param  description the description keywords (space separated, optionally
1637             *         <code>null</code>)
1638             * @param  content the content keywords (space separated, optionally
1639             *         <code>null</code>)
1640             * @param  type the web content article's type (optionally
1641             *         <code>null</code>)
1642             * @param  ddmStructureKey the primary key of the web content article's DDM
1643             *         structure, if the article is related to a DDM structure, or
1644             *         <code>null</code> otherwise
1645             * @param  ddmTemplateKey the primary key of the web content article's DDM
1646             *         template (optionally <code>null</code>). If the article is
1647             *         related to a DDM structure, the template's structure must match
1648             *         it.
1649             * @param  displayDateGT the date after which a matching web content
1650             *         article's display date must be after (optionally
1651             *         <code>null</code>)
1652             * @param  displayDateLT the date before which a matching web content
1653             *         article's display date must be before (optionally
1654             *         <code>null</code>)
1655             * @param  status the web content article's workflow status. For more
1656             *         information see {@link WorkflowConstants} for constants starting
1657             *         with the "STATUS_" prefix.
1658             * @param  reviewDate the web content article's scheduled review date
1659             *         (optionally <code>null</code>)
1660             * @param  andOperator whether every field must match its value or keywords,
1661             *         or just one field must match. Group, folder IDs, class name ID,
1662             *         and status must all match their values.
1663             * @return the number of matching web content articles
1664             * @throws SystemException if a system exception occurred
1665             */
1666            public int searchCount(
1667                            long companyId, long groupId, List<Long> folderIds,
1668                            long classNameId, String articleId, Double version, String title,
1669                            String description, String content, String type,
1670                            String ddmStructureKey, String ddmTemplateKey, Date displayDateGT,
1671                            Date displayDateLT, int status, Date reviewDate,
1672                            boolean andOperator)
1673                    throws SystemException {
1674    
1675                    return journalArticleFinder.filterCountByC_G_F_C_A_V_T_D_C_T_S_T_D_R(
1676                            companyId, groupId, folderIds, classNameId, articleId, version,
1677                            title, description, content, type, ddmStructureKey, ddmTemplateKey,
1678                            displayDateGT, displayDateLT, reviewDate, andOperator,
1679                            new QueryDefinition(status));
1680            }
1681    
1682            /**
1683             * Returns the number of web content articles matching the parameters,
1684             * including keyword parameters for article ID, title, description, and
1685             * content, a DDM structure keys (plural) parameter, a DDM template keys
1686             * (plural) parameter, and an AND operator switch.
1687             *
1688             * @param  companyId the primary key of the web content article's company
1689             * @param  groupId the primary key of the group (optionally <code>0</code>)
1690             * @param  folderIds the primary keys of the web content article folders
1691             *         (optionally {@link java.util.Collections#EMPTY_LIST})
1692             * @param  classNameId the primary key of the DDMStructure class if the web
1693             *         content article is related to a DDM structure, the primary key of
1694             *         the class name associated with the article, or {@link
1695             *         JournalArticleConstants#CLASSNAME_ID_DEFAULT} otherwise
1696             * @param  articleId the article ID keywords (space separated, optionally
1697             *         <code>null</code>)
1698             * @param  version the web content article's version (optionally
1699             *         <code>null</code>)
1700             * @param  title the title keywords (space separated, optionally
1701             *         <code>null</code>)
1702             * @param  description the description keywords (space separated, optionally
1703             *         <code>null</code>)
1704             * @param  content the content keywords (space separated, optionally
1705             *         <code>null</code>)
1706             * @param  type the web content article's type (optionally
1707             *         <code>null</code>)
1708             * @param  ddmStructureKeys the primary keys of the web content article's
1709             *         DDM structures, if the article is related to a DDM structure, or
1710             *         <code>null</code> otherwise
1711             * @param  ddmTemplateKeys the primary keys of the web content article's DDM
1712             *         templates (originally <code>null</code>). If the articles are
1713             *         related to a DDM structure, the template's structure must match
1714             *         it.
1715             * @param  displayDateGT the date after which a matching web content
1716             *         article's display date must be after (optionally
1717             *         <code>null</code>)
1718             * @param  displayDateLT the date before which a matching web content
1719             *         article's display date must be before (optionally
1720             *         <code>null</code>)
1721             * @param  status the web content article's workflow status. For more
1722             *         information see {@link WorkflowConstants} for constants starting
1723             *         with the "STATUS_" prefix.
1724             * @param  reviewDate the web content article's scheduled review date
1725             *         (optionally <code>null</code>)
1726             * @param  andOperator whether every field must match its value or keywords,
1727             *         or just one field must match.  Group, folder IDs, class name ID,
1728             *         and status must all match their values.
1729             * @return the number of matching web content articles
1730             * @throws SystemException if a system exception occurred
1731             */
1732            public int searchCount(
1733                            long companyId, long groupId, List<Long> folderIds,
1734                            long classNameId, String articleId, Double version, String title,
1735                            String description, String content, String type,
1736                            String[] ddmStructureKeys, String[] ddmTemplateKeys,
1737                            Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
1738                            boolean andOperator)
1739                    throws SystemException {
1740    
1741                    return journalArticleFinder.filterCountByC_G_F_C_A_V_T_D_C_T_S_T_D_R(
1742                            companyId, groupId, folderIds, classNameId, articleId, version,
1743                            title, description, content, type, ddmStructureKeys,
1744                            ddmTemplateKeys, displayDateGT, displayDateLT, reviewDate,
1745                            andOperator, new QueryDefinition(status));
1746            }
1747    
1748            /**
1749             * Subscribes the user to notifications for the web content article matching
1750             * the group, notifying him the instant versions of the article are created,
1751             * deleted, or modified.
1752             *
1753             * @param  groupId the primary key of the group
1754             * @throws PortalException if the user did not have permission to subscribe
1755             *         to the web content article or if a matching user or group could
1756             *         not be found
1757             * @throws SystemException if a system exception occurred
1758             */
1759            public void subscribe(long groupId)
1760                    throws PortalException, SystemException {
1761    
1762                    JournalPermission.check(
1763                            getPermissionChecker(), groupId, ActionKeys.SUBSCRIBE);
1764    
1765                    journalArticleLocalService.subscribe(getUserId(), groupId);
1766            }
1767    
1768            /**
1769             * Unsubscribes the user from notifications for the web content article
1770             * matching the group.
1771             *
1772             * @param  groupId the primary key of the group
1773             * @throws PortalException if the user did not have permission to subscribe
1774             *         to the web content article or if a matching user or subscription
1775             *         could not be found
1776             * @throws SystemException if a system exception occurred
1777             */
1778            public void unsubscribe(long groupId)
1779                    throws PortalException, SystemException {
1780    
1781                    JournalPermission.check(
1782                            getPermissionChecker(), groupId, ActionKeys.SUBSCRIBE);
1783    
1784                    journalArticleLocalService.unsubscribe(getUserId(), groupId);
1785            }
1786    
1787            /**
1788             * Updates the web content article matching the version, replacing its
1789             * folder, title, description, content, and layout UUID.
1790             *
1791             * @param  userId the primary key of the user updating the web content
1792             *         article
1793             * @param  groupId the primary key of the web content article's group
1794             * @param  folderId the primary key of the web content article folder
1795             * @param  articleId the primary key of the web content article
1796             * @param  version the web content article's version
1797             * @param  titleMap the web content article's locales and localized titles
1798             * @param  descriptionMap the web content article's locales and localized
1799             *         descriptions
1800             * @param  content the HTML content wrapped in XML. For more information,
1801             *         see the content example in the class description for {@link
1802             *         JournalArticleLocalServiceImpl}.
1803             * @param  layoutUuid the unique string identifying the web content
1804             *         article's display page
1805             * @param  serviceContext the service context to be applied. Can set the
1806             *         modification date, expando bridge attributes, asset category IDs,
1807             *         asset tag names, asset link entry IDs, workflow actions, the
1808             *         "defaultLanguageId" and "urlTitle" attributes, and can set
1809             *         whether to add the default command update for the web content
1810             *         article. With respect to social activities, by setting the
1811             *         service context's command to {@link
1812             *         com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
1813             *         is considered a web content update activity; otherwise it is
1814             *         considered a web content add activity.
1815             * @return the updated web content article
1816             * @throws PortalException if a user with the primary key or a matching web
1817             *         content article could not be found, or if a portal exception
1818             *         occurred
1819             * @throws SystemException if a system exception occurred
1820             */
1821            public JournalArticle updateArticle(
1822                            long userId, long groupId, long folderId, String articleId,
1823                            double version, Map<Locale, String> titleMap,
1824                            Map<Locale, String> descriptionMap, String content,
1825                            String layoutUuid, ServiceContext serviceContext)
1826                    throws PortalException, SystemException {
1827    
1828                    return journalArticleLocalService.updateArticle(
1829                            userId, groupId, folderId, articleId, version, titleMap,
1830                            descriptionMap, content, layoutUuid, serviceContext);
1831            }
1832    
1833            /**
1834             * Updates the web content article with additional parameters.
1835             *
1836             * @param  groupId the primary key of the web content article's group
1837             * @param  folderId the primary key of the web content article folder
1838             * @param  articleId the primary key of the web content article
1839             * @param  version the web content article's version
1840             * @param  titleMap the web content article's locales and localized titles
1841             * @param  descriptionMap the web content article's locales and localized
1842             *         descriptions
1843             * @param  content the HTML content wrapped in XML. For more information,
1844             *         see the content example in the class description for {@link
1845             *         JournalArticleLocalServiceImpl}.
1846             * @param  type the structure's type, if the web content article is related
1847             *         to a DDM structure. For more information, see {@link
1848             *         com.liferay.portlet.dynamicdatamapping.model.DDMStructureConstants}.
1849             * @param  ddmStructureKey the primary key of the web content article's DDM
1850             *         structure, if the article is related to a DDM structure, or
1851             *         <code>null</code> otherwise
1852             * @param  ddmTemplateKey the primary key of the web content article's DDM
1853             *         template (optionally <code>null</code>). If the article is
1854             *         related to a DDM structure, the template's structure must match
1855             *         it.
1856             * @param  layoutUuid the unique string identifying the web content
1857             *         article's display page
1858             * @param  displayDateMonth the month the web content article is set to
1859             *         display
1860             * @param  displayDateDay the calendar day the web content article is set to
1861             *         display
1862             * @param  displayDateYear the year the web content article is set to
1863             *         display
1864             * @param  displayDateHour the hour the web content article is set to
1865             *         display
1866             * @param  displayDateMinute the minute the web content article is set to
1867             *         display
1868             * @param  expirationDateMonth the month the web content article is set to
1869             *         expire
1870             * @param  expirationDateDay the calendar day the web content article is set
1871             *         to expire
1872             * @param  expirationDateYear the year the web content article is set to
1873             *         expire
1874             * @param  expirationDateHour the hour the web content article is set to
1875             *         expire
1876             * @param  expirationDateMinute the minute the web content article is set to
1877             *         expire
1878             * @param  neverExpire whether the web content article is not set to auto
1879             *         expire
1880             * @param  reviewDateMonth the month the web content article is set for
1881             *         review
1882             * @param  reviewDateDay the calendar day the web content article is set for
1883             *         review
1884             * @param  reviewDateYear the year the web content article is set for review
1885             * @param  reviewDateHour the hour the web content article is set for review
1886             * @param  reviewDateMinute the minute the web content article is set for
1887             *         review
1888             * @param  neverReview whether the web content article is not set for review
1889             * @param  indexable whether the web content is searchable
1890             * @param  smallImage whether to update web content article's a small image.
1891             *         A file must be passed in as <code>smallImageFile</code> value,
1892             *         otherwise the current small image is deleted.
1893             * @param  smallImageURL the web content article's small image URL
1894             *         (optionally <code>null</code>)
1895             * @param  smallFile the web content article's new small image file
1896             *         (optionally <code>null</code>). Must pass in
1897             *         <code>smallImage</code> value of <code>true</code> to replace the
1898             *         article's small image file.
1899             * @param  images the web content's images (optionally <code>null</code>)
1900             * @param  articleURL the web content article's accessible URL (optionally
1901             *         <code>null</code>)
1902             * @param  serviceContext the service context to be applied. Can set the
1903             *         modification date, expando bridge attributes, asset category IDs,
1904             *         asset tag names, asset link entry IDs, workflow actions, the
1905             *         "defaultLanguageId" and "urlTitle" attributes, and can set
1906             *         whether to add the default command update for the web content
1907             *         article. With respect to social activities, by setting the
1908             *         service context's command to {@link
1909             *         com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
1910             *         is considered a web content update activity; otherwise it is
1911             *         considered a web content add activity.
1912             * @return the updated web content article
1913             * @throws PortalException if the user did not have permission to update the
1914             *         web content article, if a user with the primary key or a matching
1915             *         web content article could not be found, or if a portal exception
1916             *         occurred
1917             * @throws SystemException if a system exception occurred
1918             */
1919            public JournalArticle updateArticle(
1920                            long groupId, long folderId, String articleId, double version,
1921                            Map<Locale, String> titleMap, Map<Locale, String> descriptionMap,
1922                            String content, String type, String ddmStructureKey,
1923                            String ddmTemplateKey, String layoutUuid, int displayDateMonth,
1924                            int displayDateDay, int displayDateYear, int displayDateHour,
1925                            int displayDateMinute, int expirationDateMonth,
1926                            int expirationDateDay, int expirationDateYear,
1927                            int expirationDateHour, int expirationDateMinute,
1928                            boolean neverExpire, int reviewDateMonth, int reviewDateDay,
1929                            int reviewDateYear, int reviewDateHour, int reviewDateMinute,
1930                            boolean neverReview, boolean indexable, boolean smallImage,
1931                            String smallImageURL, File smallFile, Map<String, byte[]> images,
1932                            String articleURL, ServiceContext serviceContext)
1933                    throws PortalException, SystemException {
1934    
1935                    JournalArticlePermission.check(
1936                            getPermissionChecker(), groupId, articleId, version,
1937                            ActionKeys.UPDATE);
1938    
1939                    return journalArticleLocalService.updateArticle(
1940                            getUserId(), groupId, folderId, articleId, version, titleMap,
1941                            descriptionMap, content, type, ddmStructureKey, ddmTemplateKey,
1942                            layoutUuid, displayDateMonth, displayDateDay, displayDateYear,
1943                            displayDateHour, displayDateMinute, expirationDateMonth,
1944                            expirationDateDay, expirationDateYear, expirationDateHour,
1945                            expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay,
1946                            reviewDateYear, reviewDateHour, reviewDateMinute, neverReview,
1947                            indexable, smallImage, smallImageURL, smallFile, images, articleURL,
1948                            serviceContext);
1949            }
1950    
1951            /**
1952             * Updates the web content article matching the version, replacing its
1953             * folder and content.
1954             *
1955             * @param  groupId the primary key of the web content article's group
1956             * @param  folderId the primary key of the web content article folder
1957             * @param  articleId the primary key of the web content article
1958             * @param  version the web content article's version
1959             * @param  content the HTML content wrapped in XML. For more information,
1960             *         see the content example in the class description for {@link
1961             *         JournalArticleLocalServiceImpl}.
1962             * @param  serviceContext the service context to be applied. Can set the
1963             *         modification date, expando bridge attributes, asset category IDs,
1964             *         asset tag names, asset link entry IDs, workflow actions, the
1965             *         "defaultLanguageId" and "urlTitle" attributes, and can set
1966             *         whether to add the default command update for the web content
1967             *         article. With respect to social activities, by setting the
1968             *         service context's command to {@link
1969             *         com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
1970             *         is considered a web content update activity; otherwise it is
1971             *         considered a web content add activity.
1972             * @return the updated web content article
1973             * @throws PortalException if the user did not have permission to update the
1974             *         web content article, if a user with the primary key or a matching
1975             *         web content article could not be found, or if a portal exception
1976             *         occurred
1977             * @throws SystemException if a system exception occurred
1978             */
1979            public JournalArticle updateArticle(
1980                            long groupId, long folderId, String articleId, double version,
1981                            String content, ServiceContext serviceContext)
1982                    throws PortalException, SystemException {
1983    
1984                    JournalArticlePermission.check(
1985                            getPermissionChecker(), groupId, articleId, version,
1986                            ActionKeys.UPDATE);
1987    
1988                    return journalArticleLocalService.updateArticle(
1989                            getUserId(), groupId, folderId, articleId, version, content,
1990                            serviceContext);
1991            }
1992    
1993            /**
1994             * @deprecated As of 6.2.0, replaced by {@link
1995             *             #updateArticleTranslation(long, String, double, Locale,
1996             *             String, String, String, Map, ServiceContext)}
1997             */
1998            public JournalArticle updateArticleTranslation(
1999                            long groupId, String articleId, double version, Locale locale,
2000                            String title, String description, String content,
2001                            Map<String, byte[]> images)
2002                    throws PortalException, SystemException {
2003    
2004                    return updateArticleTranslation(
2005                            groupId, articleId, version, locale, title, description, content,
2006                            images, null);
2007            }
2008    
2009            /**
2010             * Updates the translation of the web content article.
2011             *
2012             * @param  groupId the primary key of the web content article's group
2013             * @param  articleId the primary key of the web content article
2014             * @param  version the web content article's version
2015             * @param  locale the locale of the web content article's display template
2016             * @param  title the translated web content article title
2017             * @param  description the translated web content article description
2018             * @param  content the HTML content wrapped in XML. For more information,
2019             *         see the content example in the class description for {@link
2020             *         JournalArticleLocalServiceImpl}.
2021             * @param  images the web content's images
2022             * @param  serviceContext the service context to be applied. Can set the
2023             *         modification date and "urlTitle" attribute for the web content
2024             *         article.
2025             * @return the updated web content article
2026             * @throws PortalException if the user did not have permission to update the
2027             *         web content article, if a user with the primary key or a matching
2028             *         web content article could not be found, or if a portal exception
2029             *         occurred
2030             * @throws SystemException if a system exception occurred
2031             */
2032            public JournalArticle updateArticleTranslation(
2033                            long groupId, String articleId, double version, Locale locale,
2034                            String title, String description, String content,
2035                            Map<String, byte[]> images, ServiceContext serviceContext)
2036                    throws PortalException, SystemException {
2037    
2038                    JournalArticlePermission.check(
2039                            getPermissionChecker(), groupId, articleId, version,
2040                            ActionKeys.UPDATE);
2041    
2042                    return journalArticleLocalService.updateArticleTranslation(
2043                            groupId, articleId, version, locale, title, description, content,
2044                            images, serviceContext);
2045            }
2046    
2047            /**
2048             * Updates the web content article matching the group, article ID, and
2049             * version, replacing its content.
2050             *
2051             * @param  groupId the primary key of the web content article's group
2052             * @param  articleId the primary key of the web content article
2053             * @param  version the web content article's version
2054             * @param  content the HTML content wrapped in XML. For more information,
2055             *         see the content example in the class description for {@link
2056             *         JournalArticleLocalServiceImpl}.
2057             * @return the updated web content article
2058             * @throws PortalException if the user did not have permission to update the
2059             *         web content article or if a matching web content article could
2060             *         not be found
2061             * @throws SystemException if a system exception occurred
2062             */
2063            public JournalArticle updateContent(
2064                            long groupId, String articleId, double version, String content)
2065                    throws PortalException, SystemException {
2066    
2067                    JournalArticlePermission.check(
2068                            getPermissionChecker(), groupId, articleId, version,
2069                            ActionKeys.UPDATE);
2070    
2071                    return journalArticleLocalService.updateContent(
2072                            groupId, articleId, version, content);
2073            }
2074    
2075            /**
2076             * Updates the workflow status of the web content article matching the
2077             * group, article ID, and version.
2078             *
2079             * @param  groupId the primary key of the web content article's group
2080             * @param  articleId the primary key of the web content article
2081             * @param  version the web content article's version
2082             * @param  status the web content article's workflow status. For more
2083             *         information see {@link WorkflowConstants} for constants starting
2084             *         with the "STATUS_" prefix.
2085             * @param  articleURL the web content article's accessible URL
2086             * @param  serviceContext the service context to be applied. Can set the
2087             *         modification date, portlet preferences, and can set whether to
2088             *         add the default command update for the web content article.
2089             * @return the updated web content article
2090             * @throws PortalException if the user did not have permission to update the
2091             *         web content article, if a matching web content article could not
2092             *         be found, or if a portal exception occurred
2093             * @throws SystemException if a system exception occurred
2094             */
2095            public JournalArticle updateStatus(
2096                            long groupId, String articleId, double version, int status,
2097                            String articleURL, ServiceContext serviceContext)
2098                    throws PortalException, SystemException {
2099    
2100                    JournalArticlePermission.check(
2101                            getPermissionChecker(), groupId, articleId, version,
2102                            ActionKeys.UPDATE);
2103    
2104                    return journalArticleLocalService.updateStatus(
2105                            getUserId(), groupId, articleId, version, status, articleURL,
2106                            new HashMap<String, Serializable>(), serviceContext);
2107            }
2108    
2109    }