001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.file.collectors; 029 030import org.opencms.file.CmsObject; 031import org.opencms.file.CmsResource; 032import org.opencms.util.CmsPair; 033 034/** 035 * Interface which can be used to add custom code to execute after a user has created a new content 036 * via a collector list.<p> 037 * Post create handlers can also be specified when using the tags 038 * {@link org.opencms.jsp.CmsJspTagDisplay} or {@link org.opencms.jsp.CmsJspTagEdit}.<p> 039 */ 040public interface I_CmsCollectorPostCreateHandler { 041 042 /** 043 * Splits the string that configures the handler into the handler class and the configuration part. 044 * @param handlerConfig string that configures the handler 045 * @return pair with the handler class and the configuration 046 */ 047 static CmsPair<String, String> splitClassAndConfig(String handlerConfig) { 048 049 if (null != handlerConfig) { 050 int separatorIdx = handlerConfig.indexOf('|'); 051 if (separatorIdx > -1) { 052 String className = handlerConfig.substring(0, separatorIdx); 053 String config = handlerConfig.substring(separatorIdx + 1); 054 return CmsPair.create(className, config); 055 } else { 056 return CmsPair.create(handlerConfig, null); 057 } 058 } 059 return CmsPair.create(null, null); 060 } 061 062 /** 063 * This is called after the new content has been created (and possibly already been filled with content).<p> 064 * 065 * @param cms the current user's CMS context 066 * @param createdResource the resource which has been created 067 * @param copyMode true if the user chose one of the elements in the collector list as a model 068 */ 069 void onCreate(CmsObject cms, CmsResource createdResource, boolean copyMode); 070 071 /** 072 * This is called after the new content has been created (and possibly already been filled with content).<p> 073 * 074 * @param cms the current user's CMS context 075 * @param createdResource the resource which has been created 076 * @param copyMode true if the user chose one of the elements in the collector list as a model 077 * @param config an optional configuration string that can be handled specific by each implementation 078 */ 079 default void onCreate(CmsObject cms, CmsResource createdResource, boolean copyMode, String config) { 080 081 onCreate(cms, createdResource, copyMode); 082 } 083}