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