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