com.atlassian.jira.entity.remotelink
Class AbstractRemoteEntityLinkService

java.lang.Object
  extended by com.atlassian.jira.entity.remotelink.AbstractRemoteEntityLinkService
Direct Known Subclasses:
RemoteVersionLinkServiceImpl

@ExperimentalApi
public abstract class AbstractRemoteEntityLinkService
extends Object

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

Since:
v6.1.1

Field Summary
protected  String entityName
           
protected  JsonEntityPropertyManager jsonEntityPropertyManager
           
protected static String MSG_APPLICATION_NAME
           
protected static String MSG_APPLICATION_TYPE
           
protected static String MSG_DOES_NOT_EXIST
           
protected static String MSG_ERROR_CREATING
           
protected static String MSG_ERROR_REMOVING
           
protected static String MSG_ERROR_UPDATING
           
protected static String MSG_FIELD_TOO_LONG
           
protected static String MSG_GLOBAL_ID
           
protected static String MSG_INVALID_JSON
           
protected static String MSG_INVALID_URI
           
protected static String MSG_IS_REQUIRED
           
protected static String MSG_TITLE
           
protected static String MSG_URL
           
 
Constructor Summary
protected AbstractRemoteEntityLinkService(String entityName, JsonEntityPropertyManager jsonEntityPropertyManager)
          Super-constructor for all remote entity link services that use JSON entity properties for storage.
 
Method Summary
protected  String getEntityPropertyValue(Long entityId, String globalId)
          Retrieve the stored JSON for an entity link.
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.
protected  String putEntityPropertyValue(Long entityId, String globalId, String json)
          Store JSON data representing an entity link.
protected static void verifyNotBlank(ErrorCollection errors, I18nHelper i18n, String field, String value)
           
protected static void verifyNotNull(ErrorCollection errors, I18nHelper i18n, String field, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSG_IS_REQUIRED

protected static final String MSG_IS_REQUIRED
See Also:
Constant Field Values

MSG_DOES_NOT_EXIST

protected static final String MSG_DOES_NOT_EXIST
See Also:
Constant Field Values

MSG_ERROR_CREATING

protected static final String MSG_ERROR_CREATING
See Also:
Constant Field Values

MSG_ERROR_UPDATING

protected static final String MSG_ERROR_UPDATING
See Also:
Constant Field Values

MSG_ERROR_REMOVING

protected static final String MSG_ERROR_REMOVING
See Also:
Constant Field Values

MSG_FIELD_TOO_LONG

protected static final String MSG_FIELD_TOO_LONG
See Also:
Constant Field Values

MSG_GLOBAL_ID

protected static final String MSG_GLOBAL_ID
See Also:
Constant Field Values

MSG_TITLE

protected static final String MSG_TITLE
See Also:
Constant Field Values

MSG_URL

protected static final String MSG_URL
See Also:
Constant Field Values

MSG_APPLICATION_TYPE

protected static final String MSG_APPLICATION_TYPE
See Also:
Constant Field Values

MSG_APPLICATION_NAME

protected static final String MSG_APPLICATION_NAME
See Also:
Constant Field Values

MSG_INVALID_JSON

protected static final String MSG_INVALID_JSON
See Also:
Constant Field Values

MSG_INVALID_URI

protected static final String MSG_INVALID_URI
See Also:
Constant Field Values

entityName

protected final String entityName

jsonEntityPropertyManager

protected final JsonEntityPropertyManager jsonEntityPropertyManager
Constructor Detail

AbstractRemoteEntityLinkService

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
Method Detail

getEntityPropertyValue

@Nullable
protected String getEntityPropertyValue(@Nonnull
                                                 Long entityId,
                                                 @Nonnull
                                                 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

putEntityPropertyValue

@Nonnull
protected String putEntityPropertyValue(@Nonnull
                                                Long entityId,
                                                @Nullable
                                                String globalId,
                                                @Nonnull
                                                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 RemoteEntityLink.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 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

putEntityPropertyDryRun

protected String putEntityPropertyDryRun(@Nonnull
                                         Long entityId,
                                         @Nullable
                                         String globalId,
                                         @Nonnull
                                         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.

Parameters:
entityId - as for putEntityPropertyValue(Long, String, String)
globalId - as for putEntityPropertyValue(Long, String, String)
json - as for putEntityPropertyValue(Long, String, String)
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

verifyNotNull

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

verifyNotBlank

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


Copyright © 2002-2014 Atlassian. All Rights Reserved.