| JournalCreationStrategy.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.liferay.portlet.journal.lar;
24
25 import com.liferay.portal.lar.PortletDataContext;
26 import com.liferay.portlet.journal.model.JournalArticle;
27
28 /**
29 * <a href="JournalCreationStrategy.java.html"><b><i>View Source</i></b></a>
30 *
31 * <p>
32 * An interface defining how newly created content should be added to the
33 * Journal when imported from a LAR file. A class implementing this interface
34 * should be specified in <i>portal.properties</i> under the
35 * <b>journal.lar.creation.strategy</b> property.
36 * </p>
37 *
38 * @author Joel Kozikowski
39 *
40 */
41 public interface JournalCreationStrategy {
42
43 /**
44 * Constant returned by getAuthorUserId() and/or getApprovalUserId()
45 * that indicates the default portlet data import user id strategy that
46 * should be used to determine the user id.
47 */
48 public static final long USE_DEFAULT_USER_ID_STRATEGY = 0;
49
50 /**
51 * Constant returned by getTransformedContent() to indicate that the
52 * article text should remained unchanged.
53 */
54 public static final String ARTICLE_CONTENT_UNCHANGED = null;
55
56 /**
57 * Returns the author's user id to assign to newly created content. If zero
58 * is returned, the default user id import strategy will determine the
59 * author id.
60 *
61 * @param context the context of the data import
62 * @param journalObj the new object must be an instance of
63 * JournalArticle, JournalStructure, or JournalTemplate
64 * @return the author's user id or USE_DEFAULT_USER_ID_STRATEGY to use
65 * the default user id strategy
66 */
67 public long getAuthorUserId(PortletDataContext context, Object journalObj)
68 throws Exception;
69
70 /**
71 * Returns the approver's user id to assign to newly created content. If
72 * zero is returned, the default user id import strategy will determine the
73 * author id.
74 *
75 * @param context the context of the data import
76 * @param journalObj the new object must be an instance of
77 * JournalArticle, JournalStructure, or JournalTemplate
78 * @return the approver's user id or USE_DEFAULT_USER_ID_STRATEGY to
79 * use the default user id strategy
80 */
81 public long getApprovalUserId(PortletDataContext context, Object journalObj)
82 throws Exception;
83
84 /**
85 * Gives the content creation strategy an opportunity to transform the
86 * content before the new article is saved to the database. Possible use
87 * cases include using Velocity to merge in community specific values into
88 * the text. Returns the new content to assign to the article. If null is
89 * returned, the article content will be added unchanged.
90 *
91 * @param context the context of the data import
92 * @param newArticle the new article being created
93 * @return the transformed content to save in the database or
94 * ARTICLE_CONTENT_UNCHANGED if the content should be added
95 * unchanged
96 */
97 public String getTransformedContent(
98 PortletDataContext context, JournalArticle newArticle)
99 throws Exception;
100
101 /**
102 * Returns true if the default community permissions should be added when
103 * the specified journalObj is created.
104 *
105 * @param context the context of the data import
106 * @param journalObj the new object must be an instance of
107 * JournalArticle, JournalStructure, or JournalTemplate
108 * @return true if default community permissions should be added to the
109 * specified journalObj
110 */
111 public boolean addCommunityPermissions(
112 PortletDataContext context, Object journalObj)
113 throws Exception;
114
115 /**
116 * Returns true if the default guest permissions should be added when the
117 * specified journalObj is created.
118 *
119 * @param context the context of the data import
120 * @param journalObj the new object must be an instance of
121 * JournalArticle, JournalStructure, or JournalTemplate
122 * @return true if default guest permissions should be added to the
123 * specified journalObj
124 */
125 public boolean addGuestPermissions(
126 PortletDataContext context, Object journalObj)
127 throws Exception;
128
129 }