public class OmeroInterceptor extends Object implements org.hibernate.Interceptor
Interceptor
for controlling various aspects
of the Hibernate runtime. Where no special requirements exist, methods
delegate to EmptyInterceptor
Current responsibilities include the proper (re-)setting of Details
EmptyInterceptor
,
Interceptor
Constructor and Description |
---|
OmeroInterceptor(Roles roles,
SystemTypes sysTypes,
ExtendedMetadata em,
CurrentDetails cd,
TokenHolder tokenHolder,
SessionStats stats) |
Modifier and Type | Method and Description |
---|---|
void |
afterTransactionBegin(org.hibernate.Transaction tx) |
void |
afterTransactionCompletion(org.hibernate.Transaction tx) |
void |
beforeTransactionCompletion(org.hibernate.Transaction tx) |
Details |
checkManagedDetails(IObject iobj,
Details previousDetails) |
protected Details |
checkManagedDetails(IObject iobj,
Details previousDetails,
Details newDetails)
Like
checkManagedDetails(IObject, Details, Details) but allows
passing in a specific Details instance. |
Details |
evaluateLinkages(IObject changedObject)
Checks the details of the objects which the given object links to in
order to guarantee that linkages are valid.
|
int[] |
findDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
org.hibernate.type.Type[] types)
default logic
|
Object |
getEntity(String entityName,
Serializable id) |
String |
getEntityName(Object object) |
Object |
instantiate(String entityName,
org.hibernate.EntityMode entityMode,
Serializable id)
default logic, but we may want to use them eventually for
dependency-injection.
|
Boolean |
isTransient(Object entity) |
protected void |
log(String msg) |
protected boolean |
managedEvent(boolean privileged,
IObject obj,
Details previousDetails,
Details currentDetails,
Details newDetails) |
protected boolean |
managedExternalInfo(boolean privileged,
IObject obj,
Details previousDetails,
Details currentDetails,
Details newDetails)
responsible for guaranteeing that external info is not modified by any
users, including root.
|
protected boolean |
managedGroup(boolean privileged,
IObject obj,
Details previousDetails,
Details currentDetails,
Details newDetails,
BasicEventContext bec) |
protected boolean |
managedOwner(boolean privileged,
IObject obj,
Details previousDetails,
Details currentDetails,
Details newDetails,
BasicEventContext bec) |
protected Permissions.Right |
neededRight(Class<?> changedClass,
Class<?> linkedClass)
The default right need for a linkage is
Permissions.Right.WRITE . |
Details |
newTransientDetails(IObject obj) |
protected Details |
newTransientDetails(IObject obj,
Details newDetails)
Like
newTransientDetails(IObject) but allows passing in a
newDetails object with possibly preset values. |
void |
onCollectionRecreate(Object collection,
Serializable key) |
void |
onCollectionRemove(Object collection,
Serializable key) |
void |
onCollectionUpdate(Object collection,
Serializable key) |
void |
onDelete(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
org.hibernate.type.Type[] types)
default logic
|
boolean |
onFlushDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
org.hibernate.type.Type[] types)
calls back to
BasicSecuritySystem.checkManagedDetails(IObject, Details) for
properly setting Details . |
boolean |
onLoad(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
org.hibernate.type.Type[] types)
default logic.
|
String |
onPrepareStatement(String sql) |
boolean |
onSave(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
org.hibernate.type.Type[] types)
callsback to
BasicSecuritySystem.newTransientDetails(IObject) for
properly setting Details |
void |
postFlush(Iterator entities) |
void |
preFlush(Iterator entities) |
protected boolean |
resetDetails(IObject entity,
Object[] currentState,
Object[] previousState,
int idx,
Details newDetails)
asks
BasicSecuritySystem to create a new managed Details
based on the previous state of this entity. |
public OmeroInterceptor(Roles roles, SystemTypes sysTypes, ExtendedMetadata em, CurrentDetails cd, TokenHolder tokenHolder, SessionStats stats)
public Object instantiate(String entityName, org.hibernate.EntityMode entityMode, Serializable id) throws org.hibernate.CallbackException
instantiate
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types) throws org.hibernate.CallbackException
onLoad
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)
findDirty
in interface org.hibernate.Interceptor
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)
BasicSecuritySystem.newTransientDetails(IObject)
for
properly setting Details
onSave
in interface org.hibernate.Interceptor
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)
BasicSecuritySystem.checkManagedDetails(IObject, Details)
for
properly setting Details
.onFlushDirty
in interface org.hibernate.Interceptor
public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types) throws org.hibernate.CallbackException
onDelete
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public void onCollectionRecreate(Object collection, Serializable key) throws org.hibernate.CallbackException
onCollectionRecreate
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public void onCollectionRemove(Object collection, Serializable key) throws org.hibernate.CallbackException
onCollectionRemove
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public void onCollectionUpdate(Object collection, Serializable key) throws org.hibernate.CallbackException
onCollectionUpdate
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public void preFlush(Iterator entities) throws org.hibernate.CallbackException
preFlush
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public void postFlush(Iterator entities) throws org.hibernate.CallbackException
postFlush
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public void afterTransactionBegin(org.hibernate.Transaction tx)
afterTransactionBegin
in interface org.hibernate.Interceptor
public void afterTransactionCompletion(org.hibernate.Transaction tx)
afterTransactionCompletion
in interface org.hibernate.Interceptor
public void beforeTransactionCompletion(org.hibernate.Transaction tx)
beforeTransactionCompletion
in interface org.hibernate.Interceptor
public Object getEntity(String entityName, Serializable id) throws org.hibernate.CallbackException
getEntity
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public String getEntityName(Object object) throws org.hibernate.CallbackException
getEntityName
in interface org.hibernate.Interceptor
org.hibernate.CallbackException
public Boolean isTransient(Object entity)
isTransient
in interface org.hibernate.Interceptor
public String onPrepareStatement(String sql)
onPrepareStatement
in interface org.hibernate.Interceptor
protected boolean resetDetails(IObject entity, Object[] currentState, Object[] previousState, int idx, Details newDetails)
BasicSecuritySystem
to create a new managed Details
based on the previous state of this entity. If the previous state is null
(see ticket:3929) then throw an exception.entity
- IObject to be updatedcurrentState
- the possibly changed field data for this entitypreviousState
- the field data as seen in the dbidx
- the index of Details in the state arrays.protected void log(String msg)
public Details evaluateLinkages(IObject changedObject)
save
and
update
since this is the only time that new entity references can be
created.changedObject
- new or updated entity which may reference other entities which
then require locking. Nulls are tolerated but do nothing.protected Permissions.Right neededRight(Class<?> changedClass, Class<?> linkedClass)
Permissions.Right.WRITE
.
If however, this is only an annotation or only a viewing,
then less permission is needed.changedClass
- the changed classlinkedClass
- the linked classprotected Details newTransientDetails(IObject obj, Details newDetails)
newTransientDetails(IObject)
but allows passing in a
newDetails object with possibly preset values.evaluateLinkages(IObject)
protected Details checkManagedDetails(IObject iobj, Details previousDetails, Details newDetails)
checkManagedDetails(IObject, Details, Details)
but allows
passing in a specific Details
instance.protected boolean managedExternalInfo(boolean privileged, IObject obj, Details previousDetails, Details currentDetails, Details newDetails)
privileged
- if the user is privilegedobj
- the model objectpreviousDetails
- details representing the known DB statecurrentDetails
- details representing the user request (UNTRUSTED)newDetails
- details from the current context. Holder for the merged
Permissions
Permissions
of newDetails are changed.protected boolean managedOwner(boolean privileged, IObject obj, Details previousDetails, Details currentDetails, Details newDetails, BasicEventContext bec)
protected boolean managedGroup(boolean privileged, IObject obj, Details previousDetails, Details currentDetails, Details newDetails, BasicEventContext bec)
Version: 5.2.4-ice35-b23
Copyright © 2016 The University of Dundee & Open Microscopy Environment. All Rights Reserved.