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