Chapter 6. Storing Data with Your Plugin

Overview

One of the most common questions when adding new functionality to JIRA is where do I store my plugin’s data?. The brute-force way is to add new tables or new columns to the database by modifying the file entitydefs/entitymodel.xml, but then all your future upgrades will need to make the same changes.

Two better approaches to storing your data are covered in this chapter. The first one is to use the same PropertySet interface that JIRA uses for much of its own configuration data. The second approach is to use the newer Active Objects plugin, which can handle both more complex data and more of it. This Atlassian plugin is shipped as part of JIRA 5.0 and later, but can also be installed separately in JIRA 4.3 and 4.4.

Storing Data with PropertySet

The first approach is to store plugin data where JIRA stores this kind of configuration data, which is in the propertyentry table. This also has the advantage of allowing us to use the same classes, such as PropertyUtils, that JIRA uses for accessing the data. However it is strictly key/value pairs with no idea of relational concepts.

The way that JIRA uses the propertyentry database table is based on the PropertySet interface from OpenSymphony. This interface allows you to store unique key=value pairs with various get and set methods for different types of data.

The propertyentry table is defined in the entitymodel.xml file, as shown in Example 6-1. Note that the entity name OSPropertyEntry ...

Get Practical JIRA Plugins now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.