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