1   /**
2    * Copyright (c) 2000-2007 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.portlet.journal.model.JournalArticle;
26  
27  /**
28   * <a href="JournalCreationStrategy.java.html"><b><i>View Source</i></b></a>
29   *
30   * <p>
31   * An interface defining how newly created content should be added to the
32   * Journal when imported from a LAR file. A class implementing this interface
33   * should be specified in <i>portal.properties</i> under the
34   * <b>journal.lar.creation.strategy</b> property.
35   * </p>
36   *
37   * @author Joel Kozikowski
38   *
39   */
40  public interface JournalCreationStrategy {
41  
42      /**
43       * Returns the author's user id to assign to newly created content. If null
44       * is returned, the original author of the exported content will be used.
45       *
46       * @param       companyId the company id of the layout
47       * @param       groupId the group id of the layout
48       * @param       journalObj the new object must be an instance of
49       *              JournalArticle, JournalStructure or JournalTemplate
50       * @return      the author's user id, or 0 to use the original author
51       */
52      public long getAuthorUserId(long companyId, long groupId, Object journalObj)
53          throws Exception;
54  
55      /**
56       * Returns the author's user name. This method should be ignored if
57       * <code>getAuthorUserId()</code> returns null.
58       *
59       * @param       companyId the company id of the layout
60       * @param       groupId the group id of the layout
61       * @param       journalObj the new object must be an instance of
62       *              JournalArticle, JournalStructure or JournalTemplate
63       * @return      the author's user name must not be null if
64       *              <code>getAuthorUserId()</code> does not return null
65       */
66      public String getAuthorUserName(
67              long companyId, long groupId, Object journalObj)
68          throws Exception;
69  
70      /**
71       * Returns the approver's user id to assign to newly created content. If
72       * null is returned, the article will not be marked as approved.
73       *
74       * @param       companyId the company id of the layout
75       * @param       groupId the group id of the layout
76       * @param       journalObj the new object must be an instance of
77       *              JournalArticle, JournalStructure or JournalTemplate
78       * @return      the approver's user id, or 0 if the article should not be
79       *              approved
80       */
81      public long getApprovalUserId(
82              long companyId, long groupId, Object journalObj)
83          throws Exception;
84  
85      /**
86       * Returns the approver's user name. This method should be ignored if
87       * <code>getApprovalUserId()</code> returns null.
88       *
89       * @param       companyId the company id of the layout
90       * @param       groupId the group id of the layout
91       * @param       journalObj the new object must be an instance of
92       *              JournalArticle, JournalStructure or JournalTemplate
93       * @return      the approver's user name must not be null if
94       *              <code>getApprovalUserId()</code> does not return null
95       */
96      public String getApprovalUserName(
97              long companyId, long groupId, Object journalObj)
98          throws Exception;
99  
100     /**
101      * Gives the content creation strategy an opportunity to transform the
102      * content before the new article is saved to the database. Possible use
103      * cases include using Velocity to merge in community specific values into
104      * the text. Returns the new content to assign to the article. If null is
105      * returned, the article content will be added unchanged.
106      *
107      * @param       companyId the company id of the layout
108      * @param       groupId the group id of the layout
109      * @param       newArticle the new article being created
110      * @return      the transformed content to save in the database or null if
111      *              the content should be added unchanged
112      */
113     public String getTransformedContent(
114             long companyId, long groupId, JournalArticle newArticle)
115         throws Exception;
116 
117     /**
118      * Returns true if the default community permissions should be added when
119      * the specified journalObj is created.
120      *
121      * @param       companyId the company id of the layout
122      * @param       groupId the group id of the layout
123      * @param       journalObj the new object must be an instance of
124      *              JournalArticle, JournalStructure or JournalTemplate
125      * @return      true if default community permissions should be added to the
126      *              specified journalObj
127      */
128     public boolean addCommunityPermissions(
129             long companyId, long groupId, Object journalObj)
130         throws Exception;
131 
132     /**
133      * Returns true if the default guest permissions should be added when the
134      * specified journalObj is created.
135      *
136      * @param       companyId the company id of the layout
137      * @param       groupId the group id of the layout
138      * @param       journalObj the new object must be an instance of
139      *              JournalArticle, JournalStructure or JournalTemplate
140      * @return      true if default guest permissions should be added to the
141      *              specified journalObj
142      */
143     public boolean addGuestPermissions(
144             long companyId, long groupId, Object journalObj)
145         throws Exception;
146 
147 }