001 /** 002 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portlet.journal.lar; 016 017 import com.liferay.portal.kernel.lar.PortletDataContext; 018 import com.liferay.portlet.journal.model.JournalArticle; 019 020 /** 021 * <p> 022 * An interface defining how newly created content should be added to the 023 * Journal when imported from a LAR file. A class implementing this interface 024 * should be specified in <i>portal.properties</i> under the 025 * <b>journal.lar.creation.strategy</b> property. 026 * </p> 027 * 028 * @author Joel Kozikowski 029 */ 030 public interface JournalCreationStrategy { 031 032 /** 033 * Constant returned by getTransformedContent() to indicate that the article 034 * text should remained unchanged. 035 */ 036 public static final String ARTICLE_CONTENT_UNCHANGED = null; 037 038 /** 039 * Constant returned by getAuthorUserId() that indicates the default portlet 040 * data import user ID strategy that should be used to determine the user 041 * ID. 042 */ 043 public static final long USE_DEFAULT_USER_ID_STRATEGY = 0; 044 045 /** 046 * Returns <code>true</code> if the default group permissions should be 047 * added when the specified journalObj is created. 048 * 049 * @return <code>true</code> if default group permissions should be added to 050 * the specified journalObj 051 */ 052 public boolean addGroupPermissions( 053 PortletDataContext context, Object journalObj) 054 throws Exception; 055 056 /** 057 * Returns <code>true</code> if the default guest permissions should be 058 * added when the specified journalObj is created. 059 * 060 * @return <code>true</code> if default guest permissions should be added to 061 * the specified journalObj 062 */ 063 public boolean addGuestPermissions( 064 PortletDataContext context, Object journalObj) 065 throws Exception; 066 067 /** 068 * Returns the author's user ID to assign to newly created content. If zero 069 * is returned, the default user ID import strategy will determine the 070 * author ID. 071 * 072 * @return the author's user ID or USE_DEFAULT_USER_ID_STRATEGY to use the 073 * default user ID strategy 074 */ 075 public long getAuthorUserId(PortletDataContext context, Object journalObj) 076 throws Exception; 077 078 /** 079 * Gives the content creation strategy an opportunity to transform the 080 * content before the new article is saved to the database. Possible use 081 * cases include using Velocity to merge in group specific values into the 082 * text. Returns the new content to assign to the article. If 083 * <code>null</code> is returned, the article content will be added 084 * unchanged. 085 * 086 * @return the transformed content to save in the database or 087 * ARTICLE_CONTENT_UNCHANGED if the content should be added 088 * unchanged 089 */ 090 public String getTransformedContent( 091 PortletDataContext context, JournalArticle newArticle) 092 throws Exception; 093 094 }