Changes for page XAR Extensions

Last modified by Thomas Mortagne on 2021/03/02 18:22

<
From version < 7.1 >
edited by Thomas Mortagne
on 2021/03/02 17:06
To version < 8.1
edited by Thomas Mortagne
on 2021/03/02 18:22
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -143,6 +143,56 @@
143 143  * ##denySimple## = EDIT/DELETE right is denied for simple users except for simple admins who just get a warning
144 144  * ##forcedDenySimple## = EDIT/DELETE right is denied for all simple users, simple admins can't force edit/delete
145 145  
146 += Standard types
147 +
148 +* ##default##: used to force the default. Edit and delete are not allowed and a 3-way merge is applied to the document during upgrades.
149 +* ##configuration##: a document containing configuration. Edit is allowed and the document is never upgraded.
150 +* ##demo##: a document which purpose is to provide demo data. Edit and delete are allowed and the document is upgraded only if it's not been customized.
151 +* ##customizable##: a document meant to be modified but not deleted. Edit is allowed and the document is upgraded only if it's not been customized.
152 +
153 +Also the following document references have a different default type:
154 +* ##XWiki.XWikiPreference##: ##configuration##
155 +* ##Main.WebHome##: ##demo##
156 +
157 += Provide custom entry types =
158 +
159 +XWiki comes with standard XAR entry types but it's possible to extend this list with your own by implementing the component role ##org.xwiki.xar.XarEntryType##.
160 +
161 +Each XarEntryType component can indicate:
162 +* if edit is allowed for this type of document
163 +* if delete is allwoed for this type of document
164 +* the generic list of possible behavior to apply during an upgrade
165 +
166 +Appart from an arbitrary entry type name (like "configuration" or "demo") a XarEntryType can be associated to a document reference in which case documents with this reference will be assigned this type unless a type was explicitly associated to it in the XAR extension:
167 +
168 +{{code language="java"}}
169 +@Component(hints = { MyXarEntryType.HINT, XarEntryTypeResolver.DOCUMENT_PREFIX + "MySpace.MyPage" })
170 +@Singleton
171 +public class MyXarEntryType extends AbstractXarEntryType
172 +{
173 + /**
174 + * The name of the type.
175 + */
176 + public static final String HINT = "mytype";
177 +
178 + /**
179 + * Default constructor.
180 + */
181 + public MyXarEntryType()
182 + {
183 + super(HINT);
184 +
185 + // This kind of document should not be modified
186 + setEditAllowed(false);
187 + // Deleting this kind of document is fine
188 + setDeleteAllowed(true);
189 +
190 + // Don't upgrade the configuration even if the default configuration changed
191 + setUpgradeType(UpgradeType.SKIP_ALLWAYS);
192 + }
193 +}
194 +{{/code}}
195 +
146 146  = Customize upgrade behavior =
147 147  
148 148  10.3 introduced XAR entry types to customize install/upgrade behavior but XAR Extension also provide an extension point for more complex use cases: ##org.xwiki.extension.xar.XWikiDocumentMerger##.

Get Connected