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