Unique Identification Number Module

Last modified by Denis Gervalle on 2022/02/28 00:08

brickGenerates unique identification number for XWiki data types
Developed by


Active Installs1
0 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager


Preliminary informations

UniqueIdentificationNumber can be used in the xwiki environment in order to generate a next available number for a group of documents that follow two rules:

  1. Their names is built as follows: anyString.UniqueIdentificationNumber 
  2. They are instantiations of a class specified in xwiki.properties

These numbers will be called UIN from now on. The purpose of this component is to ensure we do not have 2 documents with the same UIN.

A number is considered AVAILABLE when it hasn't been used before. For example, we create documents PIN.12, PIN.13, PIN.14 and after that we delete PIN.13, PIN.14 from the wiki. When generating the next AVAILABLE number we want to avoid numbers 13 and 14 and so we need to keep track of already generated numbers in a table in database.

Don't confuse this extension with the UIN Script Service which provides more basic features, with an improved performance.

Methods for velocity

These are the methods that UniqueIdentificationNumber makes available for velocity calls:

  1. To retrieve the next available UIN based on the rules. This method makes sure that the UIN returned hasn't been used before.
  2. To check whether a uinValue was used before
    $uin.isUINUsedBefore(long uinValue)
  3. To store this value in the database (This should be used when doing mass import of documents
    $uin.storeUIN(long uinValue)
  4. to retrieve the maximum value cureently used as UIN
  5. To reset the values to starting point. This method deletes all documents that meet the rules above and empties the table with used values. Careful when using this !

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.

  • Add the properties to xwiki.properties according to your needs
    uin.manager.increment = 1
    uin.manager.initialUinValue=800000 See explanations below. 

    increment - the value used to increment the last used value in order to retrieve the next usable value
    className - the class which is used to instantiate the documents the component searches for
    initialUinValue - the initial value that is returned when there are no documents created with the rules

  • Add this mapping to your hibernate.cfg.xml file
    <mapping resource="hibernate/PINClass.hbm.xml"/>
  • Restart wiki.
Tags: development

Get Connected