001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.journal.service.impl;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.security.permission.ActionKeys;
026: import com.liferay.portal.model.User;
027: import com.liferay.portal.service.permission.PortletPermissionUtil;
028: import com.liferay.portal.theme.ThemeDisplay;
029: import com.liferay.portal.util.PortletKeys;
030: import com.liferay.portlet.journal.model.JournalArticle;
031: import com.liferay.portlet.journal.service.base.JournalArticleServiceBaseImpl;
032: import com.liferay.portlet.journal.service.permission.JournalArticlePermission;
033:
034: import java.io.File;
035:
036: import java.util.Iterator;
037: import java.util.Map;
038:
039: import javax.portlet.PortletPreferences;
040:
041: /**
042: * <a href="JournalArticleServiceImpl.java.html"><b><i>View Source</i></b></a>
043: *
044: * @author Brian Wing Shun Chan
045: *
046: */
047: public class JournalArticleServiceImpl extends
048: JournalArticleServiceBaseImpl {
049:
050: public JournalArticle addArticle(String articleId,
051: boolean autoArticleId, long plid, String title,
052: String description, String content, String type,
053: String structureId, String templateId,
054: int displayDateMonth, int displayDateDay,
055: int displayDateYear, int displayDateHour,
056: int displayDateMinute, int expirationDateMonth,
057: int expirationDateDay, int expirationDateYear,
058: int expirationDateHour, int expirationDateMinute,
059: boolean neverExpire, int reviewDateMonth,
060: int reviewDateDay, int reviewDateYear, int reviewDateHour,
061: int reviewDateMinute, boolean neverReview,
062: boolean indexable, boolean smallImage,
063: String smallImageURL, File smallFile, Map images,
064: String articleURL, PortletPreferences prefs,
065: String[] tagsEntries, boolean addCommunityPermissions,
066: boolean addGuestPermissions) throws PortalException,
067: SystemException {
068:
069: PortletPermissionUtil.check(getPermissionChecker(), plid,
070: PortletKeys.JOURNAL, ActionKeys.ADD_ARTICLE);
071:
072: return journalArticleLocalService.addArticle(getUserId(),
073: articleId, autoArticleId, plid, title, description,
074: content, type, structureId, templateId,
075: displayDateMonth, displayDateDay, displayDateYear,
076: displayDateHour, displayDateMinute,
077: expirationDateMonth, expirationDateDay,
078: expirationDateYear, expirationDateHour,
079: expirationDateMinute, neverExpire, reviewDateMonth,
080: reviewDateDay, reviewDateYear, reviewDateHour,
081: reviewDateMinute, neverReview, indexable, smallImage,
082: smallImageURL, smallFile, images, articleURL, prefs,
083: tagsEntries, addCommunityPermissions,
084: addGuestPermissions);
085: }
086:
087: public JournalArticle addArticle(String articleId,
088: boolean autoArticleId, long plid, String title,
089: String description, String content, String type,
090: String structureId, String templateId,
091: int displayDateMonth, int displayDateDay,
092: int displayDateYear, int displayDateHour,
093: int displayDateMinute, int expirationDateMonth,
094: int expirationDateDay, int expirationDateYear,
095: int expirationDateHour, int expirationDateMinute,
096: boolean neverExpire, int reviewDateMonth,
097: int reviewDateDay, int reviewDateYear, int reviewDateHour,
098: int reviewDateMinute, boolean neverReview,
099: boolean indexable, boolean smallImage,
100: String smallImageURL, File smallFile, Map images,
101: String articleURL, PortletPreferences prefs,
102: String[] tagsEntries, String[] communityPermissions,
103: String[] guestPermissions) throws PortalException,
104: SystemException {
105:
106: PortletPermissionUtil.check(getPermissionChecker(), plid,
107: PortletKeys.JOURNAL, ActionKeys.ADD_ARTICLE);
108:
109: return journalArticleLocalService.addArticle(getUserId(),
110: articleId, autoArticleId, plid, title, description,
111: content, type, structureId, templateId,
112: displayDateMonth, displayDateDay, displayDateYear,
113: displayDateHour, displayDateMinute,
114: expirationDateMonth, expirationDateDay,
115: expirationDateYear, expirationDateHour,
116: expirationDateMinute, neverExpire, reviewDateMonth,
117: reviewDateDay, reviewDateYear, reviewDateHour,
118: reviewDateMinute, neverReview, indexable, smallImage,
119: smallImageURL, smallFile, images, articleURL, prefs,
120: tagsEntries, communityPermissions, guestPermissions);
121: }
122:
123: public JournalArticle approveArticle(long groupId,
124: String articleId, double version, long plid,
125: String articleURL, PortletPreferences prefs)
126: throws PortalException, SystemException {
127:
128: User user = getUser();
129:
130: PortletPermissionUtil.check(getPermissionChecker(), plid,
131: PortletKeys.JOURNAL, ActionKeys.APPROVE_ARTICLE);
132:
133: return journalArticleLocalService.approveArticle(user
134: .getUserId(), groupId, articleId, version, articleURL,
135: prefs);
136: }
137:
138: public JournalArticle getArticle(long groupId, String articleId,
139: double version) throws PortalException, SystemException {
140:
141: JournalArticlePermission.check(getPermissionChecker(), groupId,
142: articleId, ActionKeys.VIEW);
143:
144: return journalArticleLocalService.getArticle(groupId,
145: articleId, version);
146: }
147:
148: public String getArticleContent(long groupId, String articleId,
149: String languageId, ThemeDisplay themeDisplay)
150: throws PortalException, SystemException {
151:
152: JournalArticlePermission.check(getPermissionChecker(), groupId,
153: articleId, ActionKeys.VIEW);
154:
155: return journalArticleLocalService.getArticleContent(groupId,
156: articleId, languageId, themeDisplay);
157: }
158:
159: public String getArticleContent(long groupId, String articleId,
160: double version, String languageId, ThemeDisplay themeDisplay)
161: throws PortalException, SystemException {
162:
163: JournalArticlePermission.check(getPermissionChecker(), groupId,
164: articleId, ActionKeys.VIEW);
165:
166: return journalArticleLocalService.getArticleContent(groupId,
167: articleId, version, languageId, themeDisplay);
168: }
169:
170: public void deleteArticle(long groupId, String articleId,
171: double version, String articleURL, PortletPreferences prefs)
172: throws PortalException, SystemException {
173:
174: JournalArticlePermission.check(getPermissionChecker(), groupId,
175: articleId, ActionKeys.DELETE);
176:
177: journalArticleLocalService.deleteArticle(groupId, articleId,
178: version, articleURL, prefs);
179: }
180:
181: public void expireArticle(long groupId, String articleId,
182: double version, String articleURL, PortletPreferences prefs)
183: throws PortalException, SystemException {
184:
185: JournalArticlePermission.check(getPermissionChecker(), groupId,
186: articleId, ActionKeys.EXPIRE);
187:
188: journalArticleLocalService.expireArticle(groupId, articleId,
189: version, articleURL, prefs);
190: }
191:
192: public void removeArticleLocale(long companyId, String languageId)
193: throws PortalException, SystemException {
194:
195: Iterator itr = journalArticlePersistence.findByCompanyId(
196: companyId).iterator();
197:
198: while (itr.hasNext()) {
199: JournalArticle article = (JournalArticle) itr.next();
200:
201: removeArticleLocale(article.getGroupId(), article
202: .getArticleId(), article.getVersion(), languageId);
203: }
204: }
205:
206: public JournalArticle removeArticleLocale(long groupId,
207: String articleId, double version, String languageId)
208: throws PortalException, SystemException {
209:
210: JournalArticlePermission.check(getPermissionChecker(), groupId,
211: articleId, ActionKeys.UPDATE);
212:
213: return journalArticleLocalService.removeArticleLocale(groupId,
214: articleId, version, languageId);
215: }
216:
217: public JournalArticle updateArticle(long groupId, String articleId,
218: double version, boolean incrementVersion, String title,
219: String description, String content, String type,
220: String structureId, String templateId,
221: int displayDateMonth, int displayDateDay,
222: int displayDateYear, int displayDateHour,
223: int displayDateMinute, int expirationDateMonth,
224: int expirationDateDay, int expirationDateYear,
225: int expirationDateHour, int expirationDateMinute,
226: boolean neverExpire, int reviewDateMonth,
227: int reviewDateDay, int reviewDateYear, int reviewDateHour,
228: int reviewDateMinute, boolean neverReview,
229: boolean indexable, boolean smallImage,
230: String smallImageURL, File smallFile, Map images,
231: String articleURL, PortletPreferences prefs,
232: String[] tagsEntries) throws PortalException,
233: SystemException {
234:
235: JournalArticlePermission.check(getPermissionChecker(), groupId,
236: articleId, ActionKeys.UPDATE);
237:
238: return journalArticleLocalService.updateArticle(getUserId(),
239: groupId, articleId, version, incrementVersion, title,
240: description, content, type, structureId, templateId,
241: displayDateMonth, displayDateDay, displayDateYear,
242: displayDateHour, displayDateMinute,
243: expirationDateMonth, expirationDateDay,
244: expirationDateYear, expirationDateHour,
245: expirationDateMinute, neverExpire, reviewDateMonth,
246: reviewDateDay, reviewDateYear, reviewDateHour,
247: reviewDateMinute, neverReview, indexable, smallImage,
248: smallImageURL, smallFile, images, articleURL, prefs,
249: tagsEntries);
250: }
251:
252: public JournalArticle updateContent(long groupId, String articleId,
253: double version, String content) throws PortalException,
254: SystemException {
255:
256: JournalArticlePermission.check(getPermissionChecker(), groupId,
257: articleId, ActionKeys.UPDATE);
258:
259: return journalArticleLocalService.updateContent(groupId,
260: articleId, version, content);
261: }
262:
263: }
|