Package com.xpn.xwiki.doc
Class AbstractMandatoryDocumentInitializer
- java.lang.Object
-
- com.xpn.xwiki.doc.AbstractMandatoryDocumentInitializer
-
- All Implemented Interfaces:
MandatoryDocumentInitializer,org.xwiki.component.phase.Initializable
- Direct Known Subclasses:
AbstractMandatoryClassInitializer
public abstract class AbstractMandatoryDocumentInitializer extends Object implements MandatoryDocumentInitializer, org.xwiki.component.phase.Initializable
Base class for standard mandatory document initializers.- Since:
- 9.0RC1
- Version:
- $Id: ecd913168d2013e2fb01f00ce66c152cb3114924 $
-
-
Field Summary
Fields Modifier and Type Field Description protected SheetBinderdocumentSheetBinderUsed to associate a document with a document sheet.protected DocumentReferenceResolver<EntityReference>resolverprotected WikiDescriptorManagerwikiDescriptorManagerUsed to get the main wiki.-
Fields inherited from interface com.xpn.xwiki.doc.MandatoryDocumentInitializer
DEFAULT_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description AbstractMandatoryDocumentInitializer(EntityReference reference)AbstractMandatoryDocumentInitializer(EntityReference reference, String title)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EntityReferencegetDocumentReference()protected StringgetTitle()voidinitialize()protected intintFromBoolean(Boolean value)protected booleanisMainWikiOnly()booleanupdateDocument(XWikiDocument document)Update the provided document according to the need.protected booleanupdateDocumentFields(XWikiDocument document, String title)Set the fields of the document passed as parameter.protected booleanupdateTitle(XWikiDocument document)
-
-
-
Field Detail
-
documentSheetBinder
@Inject @Named("document") protected SheetBinder documentSheetBinderUsed to associate a document with a document sheet.
-
wikiDescriptorManager
@Inject protected WikiDescriptorManager wikiDescriptorManager
Used to get the main wiki.
-
resolver
@Inject protected DocumentReferenceResolver<EntityReference> resolver
-
-
Constructor Detail
-
AbstractMandatoryDocumentInitializer
public AbstractMandatoryDocumentInitializer(EntityReference reference)
- Parameters:
reference- the reference of the document to update. Can be either local or absolute depending if the document is associated to a specific wiki or not
-
AbstractMandatoryDocumentInitializer
public AbstractMandatoryDocumentInitializer(EntityReference reference, String title)
- Parameters:
reference- the reference of the document to update. Can be either local or absolute depending if the document is associated to a specific wiki or nottitle- the title of the document
-
-
Method Detail
-
initialize
public void initialize() throws org.xwiki.component.phase.InitializationException- Specified by:
initializein interfaceorg.xwiki.component.phase.Initializable- Throws:
org.xwiki.component.phase.InitializationException
-
getDocumentReference
public EntityReference getDocumentReference()
- Specified by:
getDocumentReferencein interfaceMandatoryDocumentInitializer- Returns:
- the reference of the document to update. Can be either local or absolute depending if the document is associated to a specific wiki or not
-
updateDocument
public boolean updateDocument(XWikiDocument document)
Description copied from interface:MandatoryDocumentInitializerUpdate the provided document according to the need.- Specified by:
updateDocumentin interfaceMandatoryDocumentInitializer- Parameters:
document- the existing document to update- Returns:
- true if the document has been modified, false otherwise
-
updateTitle
protected boolean updateTitle(XWikiDocument document)
-
getTitle
protected String getTitle()
-
isMainWikiOnly
protected boolean isMainWikiOnly()
- Returns:
- true if the passed reference should be resolved to the main wiki instead of the local one. The default is
false. This is ignored if the passed reference already contains the wiki information.
-
updateDocumentFields
protected boolean updateDocumentFields(XWikiDocument document, String title)
Set the fields of the document passed as parameter. Can generate content for both XWiki Syntax 1.0 and XWiki Syntax 2.0. If new documents are set to be created in XWiki Syntax 1.0 then generate XWiki 1.0 Syntax otherwise generate XWiki Syntax 2.0.- Parameters:
document- the documenttitle- the page title to set (if null or blank the title won't be set)- Returns:
- true if the document has been modified, false otherwise
-
-