@ExperimentalApi public abstract class

AbstractRemoteEntityLinkService

extends Object
java.lang.Object
   ↳ com.atlassian.jira.entity.remotelink.AbstractRemoteEntityLinkService
Known Direct Subclasses

@ExperimentalApi

This class is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

Class Overview

Base tools for implementing a remote entity link service that uses the JsonEntityPropertyManager to store the link data.

Summary

Constants
String MSG_APPLICATION_NAME
String MSG_APPLICATION_TYPE
String MSG_DOES_NOT_EXIST
String MSG_ERROR_CREATING
String MSG_ERROR_REMOVING
String MSG_ERROR_UPDATING
String MSG_FIELD_TOO_LONG
String MSG_GLOBAL_ID
String MSG_INVALID_JSON
String MSG_INVALID_URI
String MSG_IS_REQUIRED
String MSG_TITLE
String MSG_URL
Fields
protected final String entityName
protected final JsonEntityPropertyManager jsonEntityPropertyManager
Protected Constructors
AbstractRemoteEntityLinkService(String entityName, JsonEntityPropertyManager jsonEntityPropertyManager)
Super-constructor for all remote entity link services that use JSON entity properties for storage.
Protected Methods
@Nullable String getEntityPropertyValue(Long entityId, String globalId)
Retrieve the stored JSON for an entity link.
String putEntityPropertyDryRun(Long entityId, String globalId, String json)
Verifies the same conditions that putEntityPropertyValue(Long, String, String) would without actually creating or updating the property value.
@Nonnull String putEntityPropertyValue(Long entityId, String globalId, String json)
Store JSON data representing an entity link.
static void verifyNotBlank(ErrorCollection errors, I18nHelper i18n, String field, String value)
static void verifyNotNull(ErrorCollection errors, I18nHelper i18n, String field, Object value)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

protected static final String MSG_APPLICATION_NAME

Constant Value: "remotelink.service.applicationname"

protected static final String MSG_APPLICATION_TYPE

Constant Value: "remotelink.service.applicationtype"

protected static final String MSG_DOES_NOT_EXIST

Constant Value: "remotelink.service.does.not.exist"

protected static final String MSG_ERROR_CREATING

Constant Value: "remotelink.service.error.creating"

protected static final String MSG_ERROR_REMOVING

Constant Value: "remotelink.service.error.removing"

protected static final String MSG_ERROR_UPDATING

Constant Value: "remotelink.service.error.updating"

protected static final String MSG_FIELD_TOO_LONG

Constant Value: "remotelink.service.field.too.long"

protected static final String MSG_GLOBAL_ID

Constant Value: "remotelink.service.globalid"

protected static final String MSG_INVALID_JSON

Constant Value: "remotelink.service.invalid.json"

protected static final String MSG_INVALID_URI

Constant Value: "remotelink.service.invalid.uri"

protected static final String MSG_IS_REQUIRED

Constant Value: "admin.common.words.is.required"

protected static final String MSG_TITLE

Constant Value: "remotelink.service.title"

protected static final String MSG_URL

Constant Value: "remotelink.service.url"

Fields

protected final String entityName

protected final JsonEntityPropertyManager jsonEntityPropertyManager

Protected Constructors

protected AbstractRemoteEntityLinkService (String entityName, JsonEntityPropertyManager jsonEntityPropertyManager)

Super-constructor for all remote entity link services that use JSON entity properties for storage.

Parameters
entityName the entity name that should be used when storing the JSON properties for this link service. this MUST be unique to the service. To reduce the risk of collision, it SHOULD NOT be the same as the name of the entity itself. For example, RemoteVersionLinkService uses "RemoteVersionLink", not "Version".
jsonEntityPropertyManager the injected JsonEntityPropertyManager component

Protected Methods

@Nullable protected String getEntityPropertyValue (Long entityId, String globalId)

Retrieve the stored JSON for an entity link.

Parameters
entityId the ID of the specific entity that this remote entity link was stored against
globalId the global ID against which the entity link was stored. See the return value of putEntityPropertyValue(Long, String, String) for more information.
Returns
  • the stored JSON, or null if the remote entity link does not exist

protected String putEntityPropertyDryRun (Long entityId, String globalId, String json)

Verifies the same conditions that putEntityPropertyValue(Long, String, String) would without actually creating or updating the property value. This is intended for use when validating a service request.

Returns
  • the global ID that would have been used to store the link. If this method is used to perform validation, then this value may be passed in as the globalId parameter in the following call to putEntityPropertyValue(Long, String, String) to guarantee that the same value will be used even if it is a generated UUID.
Throws
FieldTooLongJsonPropertyException if globalId or json exceeds the maximum allowed length
InvalidJsonPropertyException if json is malformed
IllegalArgumentException if entityId or json is null

@Nonnull protected String putEntityPropertyValue (Long entityId, String globalId, String json)

Store JSON data representing an entity link.

Parameters
entityId the ID of the specific entity that this remote entity link will be stored against
globalId the global ID against which to store the remote entity link, or null. If it is null, then the supplied json value is examined to see if it is a valid JSON object with a value specified for GLOBAL_ID generate a new unique identifier to serve as the global ID
json the content to be stored
Returns
  • the global ID used to store the link. If the supplied JSON is an an object that contains a string field called {@value RemoteEntityLink#GLOBAL_ID} at its top level, then that value will be extracted and used as the global ID for storage. Otherwise, a global ID will be generated by this method and returned in its place.
Throws
FieldTooLongJsonPropertyException if globalId or json exceeds the maximum allowed length
InvalidJsonPropertyException if json is malformed
IllegalArgumentException if entityId or json is null

protected static void verifyNotBlank (ErrorCollection errors, I18nHelper i18n, String field, String value)

protected static void verifyNotNull (ErrorCollection errors, I18nHelper i18n, String field, Object value)