/* * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package com.xpn.xwiki.internal.mandatory; import javax.inject.Named; import javax.inject.Singleton; import org.xwiki.component.annotation.Component; import org.xwiki.model.reference.LocalDocumentReference; import org.xwiki.model.reference.RegexEntityReference; import com.xpn.xwiki.XWiki; import com.xpn.xwiki.doc.AbstractMandatoryClassInitializer; import com.xpn.xwiki.objects.BaseObjectReference; import com.xpn.xwiki.objects.classes.BaseClass; import com.xpn.xwiki.objects.classes.TextAreaClass.EditorType; /** * Update XWiki.XWikiComments document with all required informations. * * @version $Id: 54abb3921d73337671e87b629c72f46868d6bfcd $ * @since 4.3M1 */ @Component @Named(XWikiCommentsDocumentInitializer.LOCAL_REFERENCE_STRING) @Singleton public class XWikiCommentsDocumentInitializer extends AbstractMandatoryClassInitializer { /** * The name of the initialized document. * * @since 9.4RC1 */ public static final String NAME = "XWikiComments"; /** * The local reference of the initialized document as String. * * @since 9.4RC1 */ public static final String LOCAL_REFERENCE_STRING = XWiki.SYSTEM_SPACE + '.' + NAME; /** * The local reference of the initialized document as String. * * @since 9.4RC1 */ public static final LocalDocumentReference LOCAL_REFERENCE = new LocalDocumentReference(XWiki.SYSTEM_SPACE, NAME); /** * A regex to match any object reference with initialized class. * * @since 9.4RC1 */ public static final RegexEntityReference OBJECT_REFERENCE = BaseObjectReference.any(LOCAL_REFERENCE_STRING); /** * Default constructor. */ public XWikiCommentsDocumentInitializer() { super(LOCAL_REFERENCE); } @Override protected void createClass(BaseClass xclass) { xclass.addTextField("author", "Author", 30); xclass.addTextAreaField("highlight", "Highlighted Text", 40, 2); xclass.addNumberField("replyto", "Reply To", 5, "integer"); xclass.addDateField("date", "Date"); // Use the Text editor for backwards compatibility (e.g. the annotation module which uses the comment class // doesn't expect the WYSIWYG editor). xclass.addTextAreaField("comment", "Comment", 40, 5, EditorType.TEXT); } }