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