O
- The type that got the propertiesP
- The type of propertyV
- The type of the value the property will handlepublic abstract class PropertyAccessor<O extends Propertyable,P extends Property,V> extends Object
Constructor and Description |
---|
PropertyAccessor(EventDispatcher eventDispatcher) |
Modifier and Type | Method and Description |
---|---|
void |
addToFilterDefinition(String keyGroup,
String key)
Add a combination of a property key group and property key to the accessible properties.
|
protected O |
assertLoadObject(Long id,
boolean writeAccess)
Load and check the existence of the object.
|
protected abstract void |
assertReadAccess(O object)
Asserts valid read access for the given object.
|
protected boolean |
assertValidForCreateAndUpdate(String keyGroup,
String key)
Check that the group and key are both set and that the filters allow setting the property
|
protected abstract void |
assertWriteAccess(O object)
Method to assert, that the current user has write access to the given object.
|
protected PropertyAccessorFilterDefinition |
getFilterDefintion() |
P |
getGlobalObjectProperty(Long objectId,
String key)
Get an global property, that is one with no key group (internal the key group will be global
however).
|
protected abstract Long |
getObjectId(O object) |
P |
getObjectProperty(Long objectId,
String keyGroup,
String key)
Get an object property for the given group and key
|
P |
getObjectPropertyUnfiltered(Long objectId,
String keyGroup,
String key)
Get an object property for the given group and key.
|
abstract PropertyType |
getPropertyType() |
protected abstract P |
handleCreateNewProperty(O object)
Create a new property and associate it with the object
|
protected abstract P |
handleGetObjectPropertyUnfiltered(O object,
String keyGroup,
String key)
Get an object property for the given group and key
|
protected void |
handleRemoveObjectProperty(O object,
String keyGroup,
String key)
Removes the property of an object
|
protected P |
handleSetObjectProperty(O object,
String keyGroup,
String key,
V value)
Adds a new, modifies or deletes an existing property.
|
protected P |
handleSetObjectPropertyUnfiltered(O object,
String keyGroup,
String key,
V value)
Adds a new, modifies or deletes an existing property.
|
protected abstract O |
load(Long id) |
void |
removeFromFilterDefinition(String keyGroup,
String key)
Remove a combination of a property key group and property key from the accessible properties.
|
void |
removeObjectProperty(Long objectId,
String keyGroup,
String key)
Removes the property of an object
|
P |
setGlobalObjectProperty(Long objectId,
String key,
V value)
Add a new, modify or delete an existing global property
|
P |
setObjectProperty(Long objectId,
String keyGroup,
String key,
V value)
Add a new, modify or delete an existing property.
|
P |
setObjectPropertyUnfiltered(Long objectId,
String keyGroup,
String key,
V value)
Adds a new, modifies or deletes an existing property.
|
protected abstract void |
setPropertyValue(P property,
V value) |
public PropertyAccessor(EventDispatcher eventDispatcher)
eventDispatcher
- the event dispatcher for dispatching event on property changespublic void addToFilterDefinition(String keyGroup, String key)
keyGroup
- the key group of the property that should be read and writablekey
- the key of the property that should be read and writableprotected O assertLoadObject(Long id, boolean writeAccess) throws NotFoundException, AuthorizationException
id
- the ID of the objectwriteAccess
- true
if the current user needs to have write access to the object and
its properties, false
if only read access is requiredNotFoundException
- in case the object has not been foundAuthorizationException
- in case the current user has not the requested access level to the objectprotected abstract void assertReadAccess(O object) throws AuthorizationException, NotFoundException
object
- The object.AuthorizationException
- Thrown, when the read access to the object was denied.NotFoundException
protected boolean assertValidForCreateAndUpdate(String keyGroup, String key)
keyGroup
- the key group of the propertykey
- the key of the propertyprotected abstract void assertWriteAccess(O object) throws AuthorizationException, NotFoundException
object
- The object to assert write access for.AuthorizationException
- Thrown, when the current user is not allowed to write to the given object.NotFoundException
protected PropertyAccessorFilterDefinition getFilterDefintion()
public final P getGlobalObjectProperty(Long objectId, String key) throws NotFoundException, AuthorizationException
objectId
- the id of the object to get the property ofkey
- the key of the propertyNotFoundException
- in case there is not object to the given id.AuthorizationException
- Thrown, when the user is not allowed to access.protected abstract Long getObjectId(O object)
object
- the object the property is / will be assigned topublic final P getObjectProperty(Long objectId, String keyGroup, String key) throws NotFoundException, AuthorizationException
objectId
- the id of the object to get the property ofkeyGroup
- the key group of the property to getkey
- the key of the propertyNotFoundException
- in case there is not object to the given id.AuthorizationException
- Thrown, when the user is not allowed to access.public final P getObjectPropertyUnfiltered(Long objectId, String keyGroup, String key) throws NotFoundException, AuthorizationException
objectId
- the id of the object to get the property ofkeyGroup
- the key group of the property to getkey
- the key of the propertyNotFoundException
- in case there is not object to the given id.AuthorizationException
- Thrown, when the user is not allowed to access.public abstract PropertyType getPropertyType()
protected abstract P handleCreateNewProperty(O object)
object
- the object to add a new property toprotected abstract P handleGetObjectPropertyUnfiltered(O object, String keyGroup, String key) throws AuthorizationException
object
- the object to get the property ofkeyGroup
- the key group of the property to getkey
- the key of the propert no such property existsAuthorizationException
- Thrown, when the user is not allowed to access the property.protected void handleRemoveObjectProperty(O object, String keyGroup, String key) throws AuthorizationException
object
- object to get the property ofkeyGroup
- the key group of the property to getkey
- the key of the propertyAuthorizationException
- Thrown, when the user is not allowed to access.protected final P handleSetObjectProperty(O object, String keyGroup, String key, V value) throws AuthorizationException
object
- the object for which the properties should be modifiedkeyGroup
- the key group of the property to setkey
- the key of the propertyvalue
- the value of the property, can be null to delete the propertyAuthorizationException
- Thrown, when the user is not allowed to access the object.protected P handleSetObjectPropertyUnfiltered(O object, String keyGroup, String key, V value) throws AuthorizationException
object
- the object for which the properties should be modifiedkeyGroup
- the key group of the property to setkey
- the key of the propertyvalue
- the value of the property, can be null to delete the propertyAuthorizationException
- Thrown, when the user is not allowed to access the object.protected abstract O load(Long id)
id
- the id of the objectpublic void removeFromFilterDefinition(String keyGroup, String key)
keyGroup
- the key group of the propertykey
- the key of the propertypublic final void removeObjectProperty(Long objectId, String keyGroup, String key) throws NotFoundException, AuthorizationException
objectId
- the id of the object to get the property ofkeyGroup
- the key group of the property to getkey
- the key of the propertyNotFoundException
- in case there is not object to the given id.AuthorizationException
- Thrown, when the user is not allowed to access.public final P setGlobalObjectProperty(Long objectId, String key, V value) throws NotFoundException, AuthorizationException
objectId
- the object to set the property onkey
- the key of the propertyvalue
- the value of the propertyNotFoundException
- in case there is not object to the given id.AuthorizationException
- Thrown, when the user is not allowed to access.public final P setObjectProperty(Long objectId, String keyGroup, String key, V value) throws NotFoundException, AuthorizationException
objectId
- the id of the object for which the properties should be modifiedkeyGroup
- the key group of the property to setkey
- the key of the propertyvalue
- the value of the property, can be null to delete the propertyNotFoundException
- in case there is no object for the given IDAuthorizationException
- Thrown, when the user is not allowed to modify the object.public final P setObjectPropertyUnfiltered(Long objectId, String keyGroup, String key, V value) throws NotFoundException, AuthorizationException
objectId
- the id of the object for which the properties should be modifiedkeyGroup
- the key group of the property to setkey
- the key of the propertyvalue
- the value of the property, can be null to delete the propertyNotFoundException
- in case there is no object for the given IDAuthorizationException
- Thrown, when the user is not allowed to modify the object.Copyright © 2019 Communote team. All rights reserved.