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       * Constant returned by getAuthorUserId() and/or getApprovalUserId()
44       * that indicates the default portlet data import user id strategy that
45       * should be used to determine the user id.
46       */
47      public static final long USE_DEFAULT_USER_ID_STRATEGY = 0;
48  
49      /**
50       * Constant returned by getTransformedContent() to indicate that the
51       * article text should remained unchanged.
52       */
53      public static final String ARTICLE_CONTENT_UNCHANGED = null;
54  
55      /**
56       * Returns the author's user id to assign to newly created content. If zero
57       * is returned, the default user id import strategy will determine the
58       * author id.
59       *
60       * @param       companyId the company id of the layout
61       * @param       groupId the group id of the layout
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(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       * zero is returned, the default user id import strategy will determine the
73       * author id.
74       *
75       * @param       companyId the company id of the layout
76       * @param       groupId the group id of the layout
77       * @param       journalObj the new object must be an instance of
78       *              JournalArticle, JournalStructure, or JournalTemplate
79       * @return      the approver's user id or USE_DEFAULT_USER_ID_STRATEGY to
80       *              use the default user id strategy
81       */
82      public long getApprovalUserId(
83              long companyId, long groupId, Object journalObj)
84          throws Exception;
85  
86      /**
87       * Gives the content creation strategy an opportunity to transform the
88       * content before the new article is saved to the database. Possible use
89       * cases include using Velocity to merge in community specific values into
90       * the text. Returns the new content to assign to the article. If null is
91       * returned, the article content will be added unchanged.
92       *
93       * @param       companyId the company id of the layout
94       * @param       groupId the group id of the layout
95       * @param       newArticle the new article being created
96       * @return      the transformed content to save in the database or
97       *              ARTICLE_CONTENT_UNCHANGED if the content should be added
98       *              unchanged
99       */
100     public String getTransformedContent(
101             long companyId, long groupId, JournalArticle newArticle)
102         throws Exception;
103 
104     /**
105      * Returns true if the default community permissions should be added when
106      * the specified journalObj is created.
107      *
108      * @param       companyId the company id of the layout
109      * @param       groupId the group id of the layout
110      * @param       journalObj the new object must be an instance of
111      *              JournalArticle, JournalStructure, or JournalTemplate
112      * @return      true if default community permissions should be added to the
113      *              specified journalObj
114      */
115     public boolean addCommunityPermissions(
116             long companyId, long groupId, Object journalObj)
117         throws Exception;
118 
119     /**
120      * Returns true if the default guest permissions should be added when the
121      * specified journalObj is created.
122      *
123      * @param       companyId the company id of the layout
124      * @param       groupId the group id of the layout
125      * @param       journalObj the new object must be an instance of
126      *              JournalArticle, JournalStructure, or JournalTemplate
127      * @return      true if default guest permissions should be added to the
128      *              specified journalObj
129      */
130     public boolean addGuestPermissions(
131             long companyId, long groupId, Object journalObj)
132         throws Exception;
133 
134 }