com.atlassian.jira.entity.property
Class BaseEntityPropertyService<E extends WithId>

java.lang.Object
  extended by com.atlassian.jira.entity.property.BaseEntityPropertyService<E>
Type Parameters:
E - the entity type which is identifiable by id.
All Implemented Interfaces:
EntityPropertyService<E>
Direct Known Subclasses:
BaseEntityWithKeyPropertyService, DefaultChangeHistoryPropertyService, DefaultCommentPropertyService

@ExperimentalApi
public class BaseEntityPropertyService<E extends WithId>
extends Object
implements EntityPropertyService<E>

The base implementation of EntityPropertyService.

Since:
v6.2
See Also:
BaseEntityWithKeyPropertyService

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.jira.entity.property.EntityPropertyService
EntityPropertyService.DeletePropertyValidationResult, EntityPropertyService.EntityPropertyInput, EntityPropertyService.PropertyInput, EntityPropertyService.PropertyKeys<E>, EntityPropertyService.PropertyResult, EntityPropertyService.PropertyServiceResult, EntityPropertyService.SetPropertyValidationResult
 
Constructor Summary
BaseEntityPropertyService(JsonEntityPropertyManager jsonEntityPropertyManager, I18nHelper i18n, com.atlassian.event.api.EventPublisher eventPublisher, EntityPropertyHelper<E> entityPropertyHelper)
           
 
Method Summary
 void deleteProperty(ApplicationUser user, EntityPropertyService.DeletePropertyValidationResult validationResult)
          Removes the entity property with specified entity's id and entity's property key.
 EntityPropertyService.PropertyKeys<E> getPropertiesKeys(ApplicationUser user, Long entityId)
          Returns the properties keys associated with the specified entity.
 EntityPropertyService.PropertyKeys<E> getPropertiesKeys(ApplicationUser user, Long entityId, EntityPropertyOptions options)
          Returns the properties keys associated with the specified entity.
protected  EntityPropertyService.PropertyKeys<E> getPropertiesKeys(ApplicationUser user, com.atlassian.fugue.Option<E> entity, EntityPropertyOptions options)
           
 EntityPropertyService.PropertyResult getProperty(ApplicationUser user, Long entityId, String propertyKey)
          Returns the JSON property with the specified key from specified entity.
 EntityPropertyService.PropertyResult getProperty(ApplicationUser user, Long entityId, String propertyKey, EntityPropertyOptions options)
          Returns the JSON property with the specified key from specified entity.
protected  EntityPropertyService.PropertyResult getProperty(ApplicationUser user, com.atlassian.fugue.Option<E> entity, String propertyKey, EntityPropertyOptions options)
           
 EntityPropertyService.PropertyResult setProperty(ApplicationUser user, EntityPropertyService.SetPropertyValidationResult propertyValidationResult)
          Associates validated property with the entity.
 EntityPropertyService.DeletePropertyValidationResult validateDeleteProperty(ApplicationUser user, Long entityId, String propertyKey)
          Check if it is possible to remove the entity property with specified entity's id and entity's property key.
 EntityPropertyService.DeletePropertyValidationResult validateDeleteProperty(ApplicationUser user, Long entityId, String propertyKey, EntityPropertyOptions options)
          Check if it is possible to remove the entity property with specified entity's id and entity's property key.
protected  EntityPropertyService.DeletePropertyValidationResult validateDeleteProperty(ApplicationUser user, com.atlassian.fugue.Option<E> entity, String propertyKey, EntityPropertyOptions options)
           
 ErrorCollection validatePropertyInput(EntityPropertyService.PropertyInput propertyInput)
          Validates the property's key and property's value without permission checking.
 EntityPropertyService.SetPropertyValidationResult validateSetProperty(ApplicationUser user, Long entityId, EntityPropertyService.PropertyInput propertyInput)
          Checks if the provided entity's property is valid.
 EntityPropertyService.SetPropertyValidationResult validateSetProperty(ApplicationUser user, Long entityId, EntityPropertyService.PropertyInput propertyInput, EntityPropertyOptions options)
          Checks if the provided entity's property is valid.
protected  EntityPropertyService.SetPropertyValidationResult validateSetProperty(ApplicationUser user, com.atlassian.fugue.Option<E> entity, EntityPropertyService.PropertyInput propertyInput, EntityPropertyOptions options)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseEntityPropertyService

public BaseEntityPropertyService(JsonEntityPropertyManager jsonEntityPropertyManager,
                                 I18nHelper i18n,
                                 com.atlassian.event.api.EventPublisher eventPublisher,
                                 EntityPropertyHelper<E> entityPropertyHelper)
Method Detail

validateSetProperty

public EntityPropertyService.SetPropertyValidationResult validateSetProperty(ApplicationUser user,
                                                                             Long entityId,
                                                                             EntityPropertyService.PropertyInput propertyInput)
Description copied from interface: EntityPropertyService
Checks if the provided entity's property is valid.

This method checks if the entity with which the property will be associated exists and if the calling user has permissions to edit the entity. It validates if the property's key length is less then 255 characters. It also checks if the length of the property's value is less then 32,768.

Specified by:
validateSetProperty in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
entityId - the id of the entity with which the property will be associated.
propertyInput - the pair of key and value which will be associated with the entity.
Returns:
either entity ready to be persisted in DB or collection of errors.

validateSetProperty

public EntityPropertyService.SetPropertyValidationResult validateSetProperty(ApplicationUser user,
                                                                             @Nonnull
                                                                             Long entityId,
                                                                             @Nonnull
                                                                             EntityPropertyService.PropertyInput propertyInput,
                                                                             @Nonnull
                                                                             EntityPropertyOptions options)
Description copied from interface: EntityPropertyService
Checks if the provided entity's property is valid.

This method checks if the entity with which the property will be associated exists. It validates if the property's key length is less then 255 characters. It also checks if the length of the property's value is less then 32,768.

Specified by:
validateSetProperty in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
entityId - the id of the entity with which the property will be associated.
propertyInput - the pair of key and value which will be associated with the entity.
options - options to skip permission while performing the validation.
Returns:
either entity ready to be persisted in DB or collection of errors.

validateSetProperty

protected EntityPropertyService.SetPropertyValidationResult validateSetProperty(ApplicationUser user,
                                                                                com.atlassian.fugue.Option<E> entity,
                                                                                EntityPropertyService.PropertyInput propertyInput,
                                                                                EntityPropertyOptions options)

validatePropertyInput

public ErrorCollection validatePropertyInput(EntityPropertyService.PropertyInput propertyInput)
Description copied from interface: EntityPropertyService
Validates the property's key and property's value without permission checking.

Specified by:
validatePropertyInput in interface EntityPropertyService<E extends WithId>
Parameters:
propertyInput - the key and value of the property.
Returns:
all validation errors or empty error collection.

setProperty

public EntityPropertyService.PropertyResult setProperty(ApplicationUser user,
                                                        @Nonnull
                                                        EntityPropertyService.SetPropertyValidationResult propertyValidationResult)
Description copied from interface: EntityPropertyService
Associates validated property with the entity. Upon successful set an instance of EntityPropertySetEvent is published.

Specified by:
setProperty in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
propertyValidationResult - validated entity property.
Returns:
the persisted entity property or the error collection.

validateDeleteProperty

public EntityPropertyService.DeletePropertyValidationResult validateDeleteProperty(ApplicationUser user,
                                                                                   Long entityId,
                                                                                   String propertyKey)
Description copied from interface: EntityPropertyService
Check if it is possible to remove the entity property with specified entity's id and entity's property key.

This method checks if the calling user has permissions to edit the selected entity and if the property for given entity id and property key exists.

Specified by:
validateDeleteProperty in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
entityId - the id of the entity with which the property is associated.
propertyKey - the key of the entity's property.
Returns:
either entity ready to be removed or collection of errors.

validateDeleteProperty

public EntityPropertyService.DeletePropertyValidationResult validateDeleteProperty(ApplicationUser user,
                                                                                   @Nonnull
                                                                                   Long entityId,
                                                                                   @Nonnull
                                                                                   String propertyKey,
                                                                                   @Nonnull
                                                                                   EntityPropertyOptions options)
Description copied from interface: EntityPropertyService
Check if it is possible to remove the entity property with specified entity's id and entity's property key.

This method checks if the property for given entity id and property key exists.

Specified by:
validateDeleteProperty in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
entityId - the id of the entity with which the property is associated.
propertyKey - the key of the entity's property.
options - options to skip permission while performing the validation.
Returns:
either entity ready to be removed or collection of errors.

validateDeleteProperty

protected EntityPropertyService.DeletePropertyValidationResult validateDeleteProperty(ApplicationUser user,
                                                                                      com.atlassian.fugue.Option<E> entity,
                                                                                      @Nonnull
                                                                                      String propertyKey,
                                                                                      @Nonnull
                                                                                      EntityPropertyOptions options)

deleteProperty

public void deleteProperty(ApplicationUser user,
                           @Nonnull
                           EntityPropertyService.DeletePropertyValidationResult validationResult)
Description copied from interface: EntityPropertyService
Removes the entity property with specified entity's id and entity's property key. Upon successful removal, EntityPropertyDeletedEvent is published.

Specified by:
deleteProperty in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
validationResult - validation results of entity's property removal.

getProperty

public EntityPropertyService.PropertyResult getProperty(ApplicationUser user,
                                                        Long entityId,
                                                        String propertyKey)
Description copied from interface: EntityPropertyService
Returns the JSON property with the specified key from specified entity.

This method checks if the calling user has permissions to browse the entities and if the entity with given id exists.

Specified by:
getProperty in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
entityId - the id of the entity with which the property is associated.
propertyKey - the key of the entity's property.
Returns:
the chosen property of the entity if found or the error collection.

getProperty

public EntityPropertyService.PropertyResult getProperty(ApplicationUser user,
                                                        @Nonnull
                                                        Long entityId,
                                                        @Nonnull
                                                        String propertyKey,
                                                        @Nonnull
                                                        EntityPropertyOptions options)
Description copied from interface: EntityPropertyService
Returns the JSON property with the specified key from specified entity.

This method checks if the entity with given id exists.

Specified by:
getProperty in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
entityId - the id of the entity with which the property is associated.
propertyKey - the key of the entity's property.
options - options to skip permission while performing the validation.
Returns:
the chosen property of the entity if found or the error collection.

getProperty

protected EntityPropertyService.PropertyResult getProperty(ApplicationUser user,
                                                           com.atlassian.fugue.Option<E> entity,
                                                           @Nonnull
                                                           String propertyKey,
                                                           EntityPropertyOptions options)

getPropertiesKeys

public EntityPropertyService.PropertyKeys<E> getPropertiesKeys(ApplicationUser user,
                                                               Long entityId)
Description copied from interface: EntityPropertyService
Returns the properties keys associated with the specified entity.

This method checks if the calling user has permissions to browse the entities and if the entity with given id exists.

Specified by:
getPropertiesKeys in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
entityId - the id of the entity with which the property is associated.
Returns:
the list of properties keys and associated entity or a collection with errors.

getPropertiesKeys

public EntityPropertyService.PropertyKeys<E> getPropertiesKeys(ApplicationUser user,
                                                               @Nonnull
                                                               Long entityId,
                                                               @Nonnull
                                                               EntityPropertyOptions options)
Description copied from interface: EntityPropertyService
Returns the properties keys associated with the specified entity.

This method checks if the entity with given id exists.

Specified by:
getPropertiesKeys in interface EntityPropertyService<E extends WithId>
Parameters:
user - who the permission checks will be run against (can be null, indicating anonymous user).
entityId - the id of the entity with which the property is associated.
options - options to skip permission while performing the validation.
Returns:
the list of properties keys and associated entity or a collection with errors.

getPropertiesKeys

protected EntityPropertyService.PropertyKeys<E> getPropertiesKeys(ApplicationUser user,
                                                                  com.atlassian.fugue.Option<E> entity,
                                                                  EntityPropertyOptions options)


Copyright © 2002-2014 Atlassian. All Rights Reserved.