| JournalCreationStrategy.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 */
14
15 package com.liferay.portlet.journal.lar;
16
17 import com.liferay.portal.kernel.lar.PortletDataContext;
18 import com.liferay.portlet.journal.model.JournalArticle;
19
20 /**
21 * <a href="JournalCreationStrategy.java.html"><b><i>View Source</i></b></a>
22 *
23 * <p>
24 * An interface defining how newly created content should be added to the
25 * Journal when imported from a LAR file. A class implementing this interface
26 * should be specified in <i>portal.properties</i> under the
27 * <b>journal.lar.creation.strategy</b> property.
28 * </p>
29 *
30 * @author Joel Kozikowski
31 */
32 public interface JournalCreationStrategy {
33
34 /**
35 * Constant returned by getAuthorUserId() that indicates the default portlet
36 * data import user id strategy that should be used to determine the user
37 * id.
38 */
39 public static final long USE_DEFAULT_USER_ID_STRATEGY = 0;
40
41 /**
42 * Constant returned by getTransformedContent() to indicate that the article
43 * text should remained unchanged.
44 */
45 public static final String ARTICLE_CONTENT_UNCHANGED = null;
46
47 /**
48 * Returns the author's user id to assign to newly created content. If zero
49 * is returned, the default user id import strategy will determine the
50 * author id.
51 *
52 * @return the author's user id or USE_DEFAULT_USER_ID_STRATEGY to use the
53 * default user id strategy
54 */
55 public long getAuthorUserId(PortletDataContext context, Object journalObj)
56 throws Exception;
57
58 /**
59 * Gives the content creation strategy an opportunity to transform the
60 * content before the new article is saved to the database. Possible use
61 * cases include using Velocity to merge in community specific values into
62 * the text. Returns the new content to assign to the article. If null is
63 * returned, the article content will be added unchanged.
64 *
65 * @return the transformed content to save in the database or
66 * ARTICLE_CONTENT_UNCHANGED if the content should be added
67 * unchanged
68 */
69 public String getTransformedContent(
70 PortletDataContext context, JournalArticle newArticle)
71 throws Exception;
72
73 /**
74 * Returns true if the default community permissions should be added when
75 * the specified journalObj is created.
76 *
77 * @return true if default community permissions should be added to the
78 * specified journalObj
79 */
80 public boolean addCommunityPermissions(
81 PortletDataContext context, Object journalObj)
82 throws Exception;
83
84 /**
85 * Returns true if the default guest permissions should be added when the
86 * specified journalObj is created.
87 *
88 * @return true if default guest permissions should be added to the
89 * specified journalObj
90 */
91 public boolean addGuestPermissions(
92 PortletDataContext context, Object journalObj)
93 throws Exception;
94
95 }