public class JsonEntityPropertyManagerImpl extends Object implements JsonEntityPropertyManager
Modifier and Type | Field and Description |
---|---|
static int |
MAXIMUM_ENTITY_NAME_LENGTH
If you any of these change these values, please update the JavaDocs for
JsonEntityPropertyManager.put(String, Long, String, String) and
JsonEntityPropertyManager.getMaximumValueLength() accordingly. |
static int |
MAXIMUM_KEY_LENGTH |
static int |
MAXIMUM_VALUE_LENGTH |
Constructor and Description |
---|
JsonEntityPropertyManagerImpl(EntityEngine entityEngine,
com.atlassian.event.api.EventPublisher eventPublisher) |
Modifier and Type | Method and Description |
---|---|
long |
countByEntity(String entityName,
Long entityId)
Counts the number of properties that match the given entity.
|
long |
countByEntityNameAndPropertyKey(String entityName,
String key)
Counts the number of properties that match the given entity name and property key.
|
void |
delete(String entityName,
Long entityId,
String key)
Deletes the stored value for an entity property, if it exists.
|
void |
deleteByEntity(String entityName,
Long entityId)
Deletes all properties that are associated with the provided entity.
|
void |
deleteByEntityNameAndPropertyKey(String entityName,
String key)
Deletes all properties that are associated with the provided entity name and
property key.
|
boolean |
exists(String entityName,
Long entityId,
String key)
Returns whether or not a given property exists.
|
List<String> |
findKeys(String entityName,
Long entityId)
Produces a list of entity property keys that match the provided entity name and entity id.
|
List<String> |
findKeys(String entityName,
String keyPrefix)
Produces a list of entity property keys that match the provided entity name and key prefix.
|
EntityProperty |
get(String entityName,
Long entityId,
String key)
Look up an entity property by the entity name, entity id, and property key.
|
int |
getMaximumValueLength()
The maximum allowed length (in characters) permitted for the
String json value
when calling JsonEntityPropertyManager.put(String, Long, String, String) (or JsonEntityPropertyManager.putDryRun(String, String, String) ). |
void |
put(ApplicationUser user,
String entityName,
Long entityId,
String key,
String json,
com.atlassian.fugue.Function2<ApplicationUser,EntityProperty,? extends EntityPropertySetEvent> eventFunction,
boolean dispatchEvent)
Set the value for an entity property, creating, updating, or deleting it as necessary.
|
void |
put(String entityName,
Long entityId,
String key,
String json)
Set the value for an entity property, creating, updating, or deleting it as necessary.
|
void |
putDryRun(String entityName,
String key,
String json)
Performs all of the validation that would be performed during a
JsonEntityPropertyManager.put(String, Long, String, String)
request, but does not actually store the value. |
EntityPropertyQuery<?> |
query()
Returns a query object for finding, counting, or deleting properties with various restrictions.
|
public static final int MAXIMUM_ENTITY_NAME_LENGTH
JsonEntityPropertyManager.put(String, Long, String, String)
and
JsonEntityPropertyManager.getMaximumValueLength()
accordingly.public static final int MAXIMUM_KEY_LENGTH
public static final int MAXIMUM_VALUE_LENGTH
public JsonEntityPropertyManagerImpl(EntityEngine entityEngine, com.atlassian.event.api.EventPublisher eventPublisher)
public void putDryRun(@Nonnull String entityName, @Nonnull String key, String json)
JsonEntityPropertyManager
JsonEntityPropertyManager.put(String, Long, String, String)
request, but does not actually store the value.putDryRun
in interface JsonEntityPropertyManager
entityName
- as for JsonEntityPropertyManager.put(String, Long, String, String)
key
- as for JsonEntityPropertyManager.put(String, Long, String, String)
json
- as for JsonEntityPropertyManager.put(String, Long, String, String)
JsonEntityPropertyManager.put(String, Long, String, String)
public void put(@Nonnull String entityName, @Nonnull Long entityId, @Nonnull String key, String json)
JsonEntityPropertyManager
put
in interface JsonEntityPropertyManager
entityName
- the entity name for the property (maximum length 255
). As explained in the
class documentation
, this value should be unique to the service
creating the properties and will generally not be the same as the entity to
which the properties are attached.entityId
- the entity ID for the property. In general, this will be the same as the ID of the
owning entity; for example, the
RemoteVersionLinkService
uses the version ID
for this value.key
- the key for the property (maximum length 255
). This value should generally be suitable
for a reverse lookup when the same data might be associated with multiple entities. For example, the
RemoteVersionLinkService
uses the global ID
of the remote object, which is the same identifier used by applinks to identify
a Confluence page, Bamboo project, etc.json
- the new value for the property, or null
to delete it (maximum length
is available by calling JsonEntityPropertyManager.getMaximumValueLength()
)JsonEntityPropertyManager.putDryRun(String, String, String)
public void put(ApplicationUser user, @Nonnull String entityName, @Nonnull Long entityId, @Nonnull String key, @Nullable String json, com.atlassian.fugue.Function2<ApplicationUser,EntityProperty,? extends EntityPropertySetEvent> eventFunction, boolean dispatchEvent)
JsonEntityPropertyManager
put
in interface JsonEntityPropertyManager
user
- The user performing the action. The event will be actioned as this userentityName
- the entity name for the property (maximum length 255
). As explained in the
class documentation
, this value should be unique to the service
creating the properties and will generally not be the same as the entity to
which the properties are attached.entityId
- the entity ID for the property. In general, this will be the same as the ID of the
owning entity; for example, the
RemoteVersionLinkService
uses the version ID
for this value.key
- the key for the property (maximum length 255
). This value should generally be suitable
for a reverse lookup when the same data might be associated with multiple entities. For example, the
RemoteVersionLinkService
uses the global ID
of the remote object, which is the same identifier used by applinks to identify
a Confluence page, Bamboo project, etc.json
- the new value for the property, or null
to delete it (maximum length
is available by calling JsonEntityPropertyManager.getMaximumValueLength()
)eventFunction
- the function that generates the event to be thrown.
See EntityPropertyHelper
for some functions that
may be used to generate eventsdispatchEvent
- true if the method should dispatch an event after it is run.JsonEntityPropertyManager.putDryRun(String, String, String)
public EntityProperty get(String entityName, Long entityId, String key)
JsonEntityPropertyManager
get
in interface JsonEntityPropertyManager
entityName
- the entity name of the propertyentityId
- the entity ID of the propertykey
- the key of the propertynull
if the property does not exist.public void delete(@Nonnull String entityName, @Nonnull Long entityId, @Nonnull String key)
JsonEntityPropertyManager
delete
in interface JsonEntityPropertyManager
entityName
- the entity name of the property to be deletedentityId
- the entity ID of the property to be deletedkey
- the key of the property to be deletedpublic int getMaximumValueLength()
JsonEntityPropertyManager
String json
value
when calling JsonEntityPropertyManager.put(String, Long, String, String)
(or JsonEntityPropertyManager.putDryRun(String, String, String)
).
This value is currently 32,768
, but this may change in the future.getMaximumValueLength
in interface JsonEntityPropertyManager
public EntityPropertyQuery<?> query()
JsonEntityPropertyManager
EntityPropertyQuery
for usage and minimum requirements.query
in interface JsonEntityPropertyManager
@Nonnull public List<String> findKeys(@Nonnull String entityName, @Nonnull String keyPrefix)
JsonEntityPropertyManager
JsonEntityPropertyManager.query()
.entityName(entityName)
.keyPrefix(keyPrefix)
.findDistinctKeys()
findKeys
in interface JsonEntityPropertyManager
entityName
- the entity name for the entities that are associated with the properties.keyPrefix
- the prefix to apply for limiting which keys are returned; must not be
null
or a blank string@Nonnull public List<String> findKeys(@Nonnull String entityName, @Nonnull Long entityId)
JsonEntityPropertyManager
JsonEntityPropertyManager.query()
.entityName(entityName)
.entityId(entityId)
.EntityPropertyQuery.ExecutableQuery.findKeys()
findKeys
in interface JsonEntityPropertyManager
entityName
- the entity name for the entities that are associated with the properties.entityId
- the id of the entity.public boolean exists(@Nonnull String entityName, @Nonnull Long entityId, @Nonnull String key)
JsonEntityPropertyManager
JsonEntityPropertyManager.get(String, Long, String)
!= null
, but does not actually retrieve
the JSON data from the database, so it may have better performance characteristics when
the JSON content is not needed.exists
in interface JsonEntityPropertyManager
entityName
- the entity name for the propertyentityId
- the entity ID for the propertykey
- the key for the propertypublic long countByEntity(@Nonnull String entityName, @Nonnull Long entityId)
JsonEntityPropertyManager
JsonEntityPropertyManager.query()
.entityName(entityName)
.entityId(entityId)
.count()
countByEntity
in interface JsonEntityPropertyManager
entityName
- the entity name of the owning entityentityId
- the entity ID of the owning entitypublic long countByEntityNameAndPropertyKey(@Nonnull String entityName, @Nonnull String key)
JsonEntityPropertyManager
JsonEntityPropertyManager.query()
.entityName(entityName)
.key(key)
.count()
countByEntityNameAndPropertyKey
in interface JsonEntityPropertyManager
entityName
- the entity name of the owning entitieskey
- the property key to look forpublic void deleteByEntity(@Nonnull String entityName, @Nonnull Long entityId)
JsonEntityPropertyManager
JsonEntityPropertyManager.query()
.entityName(entityName)
.entityId(entityId)
.delete()
deleteByEntity
in interface JsonEntityPropertyManager
entityName
- the entity name for the propertiesentityId
- the entity ID for the propertiespublic void deleteByEntityNameAndPropertyKey(@Nonnull String entityName, @Nonnull String key)
JsonEntityPropertyManager
JsonEntityPropertyManager.query()
.entityName(entityName)
.key(key)
.delete()
deleteByEntityNameAndPropertyKey
in interface JsonEntityPropertyManager
entityName
- the entity name for the propertieskey
- the property key for the propertiesCopyright © 2002-2015 Atlassian. All Rights Reserved.