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  public interface JournalCreationStrategy {
41  
42      /**
43       * Constant returned by getAuthorUserId() and/or getApprovalUserId() that
44       * indicates the default portlet data import user id strategy that should be
45       * 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 article
51       * 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       * @return the author's user id or USE_DEFAULT_USER_ID_STRATEGY to use the
61       *         default user id strategy
62       */
63      public long getAuthorUserId(PortletDataContext context, Object journalObj)
64          throws Exception;
65  
66      /**
67       * Returns the approver's user id to assign to newly created content. If
68       * zero is returned, the default user id import strategy will determine the
69       * author id.
70       *
71       * @return the approver's user id or USE_DEFAULT_USER_ID_STRATEGY to use the
72       *         default user id strategy
73       */
74      public long getApprovalUserId(PortletDataContext context, Object journalObj)
75          throws Exception;
76  
77      /**
78       * Gives the content creation strategy an opportunity to transform the
79       * content before the new article is saved to the database. Possible use
80       * cases include using Velocity to merge in community specific values into
81       * the text. Returns the new content to assign to the article. If null is
82       * returned, the article content will be added unchanged.
83       *
84       * @return the transformed content to save in the database or
85       *         ARTICLE_CONTENT_UNCHANGED if the content should be added
86       *         unchanged
87       */
88      public String getTransformedContent(
89              PortletDataContext context, JournalArticle newArticle)
90          throws Exception;
91  
92      /**
93       * Returns true if the default community permissions should be added when
94       * the specified journalObj is created.
95       *
96       * @return true if default community permissions should be added to the
97       *         specified journalObj
98       */
99      public boolean addCommunityPermissions(
100             PortletDataContext context, Object journalObj)
101         throws Exception;
102 
103     /**
104      * Returns true if the default guest permissions should be added when the
105      * specified journalObj is created.
106      *
107      * @return true if default guest permissions should be added to the
108      *         specified journalObj
109      */
110     public boolean addGuestPermissions(
111             PortletDataContext context, Object journalObj)
112         throws Exception;
113 
114 }