Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
outlinetrue
stylenone

Quick Start Guide

Jira Plugin

Download the following files

  • tba

  • Documentation: tba

Add the files to your Maven repository

There are two possibilities to install the library files. Either install them in a local Maven repository or deploy them to a hosted Maven repository.

Install in the local Maven repository

Code Block
mvn install:install-file -Dfile=user-profiles-external-api-1.1.0.jar -DgroupId=de.communardo.atlassian.plugins.userprofile.external.api -DartifactId=user-profiles-external-api -Dversion=1.1.0 -Dpackaging=jar -Djavadoc=user-profiles-external-api-1.1.0-javadoc.jar

Deploy to a hosted Maven repository

Code Block
mvn deploy:deploy-file -Dfile=user-profiles-external-api-1.1.0.jar -DgroupId=de.communardo.atlassian.plugins.userprofile.external.api -DartifactId=user-profiles-external-api -Dversion=1.1.0 -Dpackaging=jar -Djavadoc=user-profiles-external-api-1.1.0-javadoc.jar -DrepositoryId=<id-to-map-on-server-section-of-settings.xml> -Durl=<url-of-the-repository-to-deploy>

Include the UPJ Java API in your Add-On pom.xml

Code Block
<dependency>
    <groupId>de.communardo.atlassian.plugins.userprofile.external.api</groupId>
    <artifactId>user-profiles-external-api</artifactId>
    <version>1.1.0</version>
    <scope>provided</scope>
</dependency>

Import UPJ components to your atlassian-plugin.xml

Code Block
<component-import key="uppProfileElementManager" interface="de.communardo.atlassian.plugins.userprofile.external.api.service.UppProfileElementManager" />
<component-import key="uppProfileElementDataManager" interface="de.communardo.atlassian.plugins.userprofile.external.api.service.UppProfileElementDataManager" />

Make sure the User Profiles for Jira Add-on is already installed on your Jira system.

Check Installation and Licensing (v 2.4) for further information.

Scriptrunner

General

Our Java API may also be accessed via Scriptrunner. To be able to do that you have to follow the steps which are described in the official Scriptrunner documentation, which can be found here: https://scriptrunner.adaptavist.com/latest/jira/scripting-other-plugins.html

Make sure the User Profiles for Jira Add-on is already installed on your Jira system.

Check Installation and Licensing (v 2.4) for further information.

Example

To provide you a more easy way to start developing scripts with Scriptrunner, we prepared a minimal example, which provides you our API managers with whom you can access profile elements and their data:

...

The example prints the currently available profile elements and the available element data for the current user in the log (info log level, which may prevent you from seeing anything per default, so maybe use error instead if you want to directly see something).

Internal structure and basic usage

The UPJ Java API consists out of two basic elements: the profile element and the profile element data. Profile elements can be added and removed in the UPJ administration (check Create and Edit User Profile Elements (v 2.4) for further information). Values may afterwards be added for every user via an LDAP sync or by manually editing user profiles (in the administration or the user does it on his own) or even by using our new Java API.

To interact with profile elements, just inject and use the provided UppProfileElementManager. With this manager you will be able to load the available profile elements. Afterwards you may want to access some data which is related to a user. To achieve that, just inject and use the provided UppProfileElementDataManager.

Profile element and data types

There are several profile element and data types which are used to work with the API. To provide you a better start, we are going to list all currently available profile elements and their matching data models in the following table:

...

You have to use matching profile element and data types to be able to interact with the API. Furthermore the specialized data objects make an interaction with a specific data type more easy.

Event publication

ProfileElementDataChangedEvent

The User Profiles for Jira App publish every minute events for all changes that are taken since the last publication. One event contains maximum 1000 changes as a collection of updates. Each update contains a key of an user, a profile element and new data. The following table shows the models of the change sets:

Profile Element Change Set Models

Profile Element Models

Data Models

AutocompleteProfileElementDataUpdate

AutocompleteProfileElement

Set<String>

MultiSelectProfileElementDataUpdate

MultiSelectProfileElement

Set<OptionedProfileElement.Option>

SingleSelectProfileElementDataUpdate

SingleSelectProfileElement

OptionedProfileElement.Option

TextBasedProfileElementDataUpdate

TextBasedProfileElement

String

UserProfileElementDataUpdate

UserProfileElement

UserKey

ProfileElementNameChangedEvent

This event will publish if an default name of a profile element was changed. It contains the updated profile element.

ProfileElementRemovedEvent

This event will publish if a profile element was removed. It contains the removed profile element.

ProfileElementOptionNameChangedEvent

This event will publish if the default name of an option of a profile element was changed. It contains the updated profile element and the updated option.

ProfileElementOptionRemovedEvent

This event will publish if an option of a profile element was removed. It contains the updated profile element and the removed option.

Examples

To kickstart you a little bit more, we want to provide you with a few examples on what you can currently do with our Java API:

UppProfileElementManager

Loading all profile elements

Code Block
Collection<ProfileElement> profileElements =  uppProfileElementManager.getProfileElements();

Loading a specific profile element with a specific id (for example 1)

Code Block
languagejava
ProfileElement profileElement = uppProfileElementManager.getProfileElement(1);
//or if you know the type of the profileElement (in this example it is a TextBasedProfileElement)
TextBasedProfileElement textbasedProfileElement = uppProfileElementManager.getProfileElement(1);

UppProfileElementDataManager

Loading profile element data for a profile element and an user

Code Block
languagejava
ProfileElementData data = uppProfileElementDataManager.getProfileElementData(userKey, profileElement);
//or if you know the type of the profileElement or the data (in this example it is a TextBasedProfileElementData)
TextBasedProfileElementData data = uppProfileElementDataManager.getProfileElementData(userKey, profileElement);

Loading all profile elements for an user

Code Block
languagejava
Map<ProfileElement, ProfileElementData> data = uppProfileElementDataManager.getProfileElementData(userKey);

Storing profile element data for a profile element and an user

Code Block
languagejava
uppProfileElementDataManager.storeProfileElementData(userKey, profileElement, data);

To be able to store data, the type of the profile Element must match the type of the data.

ProfileElementDataChangedEvent

Event Listener example

Code Block
languagexml
<!-- add the listener as component to atlassian-plugin.xml -->
<component key="unique-key-for-your-event-listener" class="path.to.your.event.listener.class.in.this.example.ProfileElementDataChangeEventListener"/>
<!-- or use @Component at your listener class if you use the annotation notation in your app --> 

...