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