Class Item
- All Implemented Interfaces:
Serializable,Comparable
- Direct Known Subclasses:
ConfigProxyItem,ExtensibleItem,ViewResultItem
To retrieve any object by its
PK you just have to use where class is the Class of the Object you want to retrieve and JaloSession is an active(class)JaloSession.getItem(PK)
JaloSession .
each item is typed by a ComposedType which defines its class, datbase table,
jndi name and all attributes. besides composed types can be used to create new item instances a generic way (
opposite to creating them by their managers ) - see
ComposedType.newInstance(Map) .
each concrete subclass of item has to implement
createItem(SessionContext, ComposedType, de.hybris.platform.jalo.Item.ItemAttributeMap) which is responsible
for creating a new instance of this item. please note that the instance which this method is called on is
not assoziated with an exiting item, so any access to attributes will fail!
in addition it is intented that each jalo class implementing
createItem(SessionContext, ComposedType, de.hybris.platform.jalo.Item.ItemAttributeMap) should also override
getNonInitialAttributes(SessionContext, de.hybris.platform.jalo.Item.ItemAttributeMap) to avoid setting
initial attribute twice.
another method which subclasses may override is
setNonInitialAttributes(SessionContext, Item, de.hybris.platform.jalo.Item.ItemAttributeMap). it is called
after item creation and sets all additional (non-initial) attributes.
each declared attribute (see items.xml) which is not backed by a property or a relation requires a
AttributeAccess to allow generic value handling. to do so use
registerAccessFor(Class, String, AttributeAccess) .
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDescribes anAttributeFilter
Internal use only!static enumclassclassstatic classinternal use only!static interfaceInterface for implementing transaction aware consistency checks using the item methodcheckConstraint(ItemConstraint).static interfaceobject used by getSyncObject()static classThrown byItem.CachedGetter.get(SessionContext)andItem.CachedSetter.set(SessionContext)whenever the executed code throws an exception. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe_CREATION_TIME_INTERNALattribute constant.static final StringThe_MODIFIED_TIME_INTERNALattribute constant.static final org.apache.log4j.Loggerstatic final StringTheCREATION_TIMEattribute constant.static final Stringstatic final StringSessionContext Flag.static final intThe internal security check result constantEVEN.static final Stringstatic final StringTheMODIFIED_TIMEattribute constant.static final StringThis flag indicates the creation phase of an item.protected final booleanstatic final StringTheMODIFIED_TIMEattribute constant.static final intThe internal security check result constantNEGATIVE.static final intThe internal security check result constantNOT_FOUND.static final StringTheOWNERattribute constant.static final StringThePKattribute constant.static final intThe internal security check result constantPOSITIVE.static final StringSessionContext attribute flag providing information if the save operation was triggered from Service Layer.protected static final ConcurrentMap<PK,Map<String, Object>> The transient object cache.static final StringTheTYPEattribute constant.Fields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLinkedItems(boolean itemIsSource, String qualifier, Language lang, List itemsToLink) Creates new links between this item and a given list of items.voidaddLinkedItems(boolean itemIsSource, String qualifier, Language lang, List itemsToLink, int position) Creates new links between this item and a given list of items at a speciic position among this items link list.voidaddLinkedItems(boolean itemIsSource, String qualifier, Language lang, List itemsToLink, int position, boolean shift) Creates new links between this item and a given list of items at a speciic position among this items link list.voidaddLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink) Creates new links between this item and a given list of items.voidaddLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, boolean markModified) voidaddLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src) voidaddLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified) voidaddLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, int position) Creates new links between this item and a given list of items at a speciic position among this items link list.voidaddLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, int position, boolean shift) Creates new links between this item and a given list of items at a speciic position among this items link list.voidaddNegativePermission(Principal principal, UserRight right) Add a negative permission for thePrincipaland theUserRighton theItem.voidaddPermission(Principal principal, UserRight right, boolean negative) Add a permission for thePrincipaland theUserRighton theItem.voidaddPositivePermission(Principal principal, UserRight right) Add a positive permission for thePrincipaland theUserRighton theItem.protected voidprotected ItemchangeTypeAfterCreation(Item newOne, ComposedType requestedType) Changes the item type in casecreateItem(SessionContext, ComposedType, ItemAttributeMap)did not set the requested type directly.protected voidcheckConstraint(Item.ItemConstraint constr) Allows to implement transaction safe consistency checking code.protected intcheckItemPermission(Principal principal, UserRight right) protected static booleancheckMandatoryAttribute(String qualifier, Item.ItemAttributeMap allAttributes, Set missingSet) Checks if the attributes map contains a given qualifier.protected static booleancheckMandatoryAttribute(String qualifier, Item.ItemAttributeMap allAttributes, Set missingSet, boolean nullAllowed) Checks if the attributes map contains a given qualifier.booleancheckPermission(Principal principal, UserRight right) Checks if thePrincipalhas the givenUserRighton theItem.booleancheckPermission(UserRight right) Checks if the current session user has the givenUserRighton theItem.protected voidChecks whether or not this it may be removed or not.voidclearPermission(Principal principal, UserRight right) Remove any permission for thePrincipaland theUserRighton theItem.intImplements item comparison by PK.protected abstract ItemcreateItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) Has to be implemented for each concrete subtype of item.protected AttributeAccesscreateNonClassAccessor(AttributeDescriptor fieldDescriptor) protected SessionContextctx()A shortcut forgetSession().getSessionContext().protected voiddoAfterRemove(SessionContext ctx, Map removalCtx) Hook method to perform removal logic just after this item is being deleted from database.protected voiddoBeforeRemove(SessionContext ctx, Map removalCtx) Hook method to perform removal logic just before this item is being deleted from database.final booleanTwo items are equal, if their primary keys are equals.protected final AttributeAccessgetAccessorFor(String qualifier, Class myClass) Tries to find a static AttributeAccess member with_AD_+ {attribute qualifier} as name within this item's class and its super classes.Reads all (readable) attribute values of this item using the current session context.Reads all (readable) attribute values of this item using a specific session context.getAllAttributes(SessionContext ctx, Item.AttributeFilter filter) Reads all attribute values of this item which pass a given attribute filter.getAllAttributes(SessionContext ctx, Set<String> qualfiers) Reads all values of specified attributes for this item.getAllAttributesInternal(SessionContext ctx, Set<String> qualfiers) getAllLinkedItems(boolean itemIsSource, String qualifier) Returns all localized linked items for a given qualifier.<T extends Item>
TgetAttribute(SessionContext ctx, String qualifier) Returns the attribute value for a single item attribute with a specified session context.getAttribute(String qualifier) Returns the attribute value for a single item attribute using the current session context.<T extends Item>
TNOTE: hybris internal method, do not useReturns this Item's type.Directly returns the PK of this item's composed type.Returns the time when this Item was created.static intprotected Map<String,Item.AttributeMode> returns the implementation object of this jalo bridge abstractiongetLinkedItems(boolean itemIsSource, String qualifier, Language lang) Finds items linked to this item for a given link qualifier.getLinkedItems(boolean itemIsSource, String qualifier, Language lang, int start, int count) Finds a range of items linked to this item for a given link qualifier.getLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang) Finds items linked to this item for a given link qualifier.getLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, boolean sortSrc2Tgt, boolean sortTgt2Src) getLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, int start, int count) Finds a range of items linked to this item for a given link qualifier.getLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, int start, int count, boolean sortSrc2Tgt, boolean sortTgt2Src) getLinkedItems(SessionContext ctx, boolean itemIsSource, String relationCode, String relatedItemCode, Language lang, boolean sortSrc2Tgt, boolean sortTgt2Src) longgetLinkedItemsCount(boolean itemIsSource, String qualifier, Language lang) longgetLinkedItemsCount(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang) longgetLinkedItemsCount(SessionContext ctx, boolean itemIsSource, String relationTypeCode, String relatedItemCode, Language lang) Returns the time when this Item was modifed the last time.getNegativePermissions(Principal principal) Finds all negative permissions for the item and the givenPrincipal.protected Item.ItemAttributeMapgetNonInitialAttributes(SessionContext ctx, Item.ItemAttributeMap allAttributes) Defines all attributes which should be set after item creation.getOwner()protected booleangetPermissionMap(List userRights) Finds the all permission settings for a given list of user rights.getPermissions(Principal principal, boolean negative) Finds all positive or negative permissions upon this item and the givenPrincipal.longgetPK()Returns the primary key of this item.getPositivePermissions(Principal principal) Finds all positive permissions for the item and the givenPrincipal.<T extends Item>
Collection<T>getRelatedItems(RelationsInfo relationsInfo) Internal method to directly return related items linked by the One To Many relation.<T extends Item>
Collection<T>getRelatedItems(String relationQualifier) Internal method to directly return related items linked by the One To Many relation.Returns the session which is responsible for managing this item.returns an object that can be used for synchronization on the current item pk.getTransientObject(String key) Get a transient object.Deprecated.since 18.08 - don't operate on transient object map directly.final inthashCode()Returns the hashcode of this item.static booleanhasRegisteredClassAccessorFor(Tenant tenant, Class clazz, String qualifier) protected static final voidinternal_registerClassAccessorFor(Tenant tenant, Class clazz, String qualifier, AttributeAccess access) protected static final voidinternal_registerNonClassAccessorFor(Tenant tenant, AttributeDescriptor attributeDescriptor, AttributeAccess access) voidbooleanisAlive()Istrueif this item is still valid.booleanstatic booleanstatic booleanisCurrentlyRemoving(Item item) protected booleanisEmptyRelationValue(SessionContext ctx, String name, List value) Override this method to implement different language fallback behaviour.static booleanisInCreate(SessionContext ctx) booleanisInstanceOf(ComposedType type) Tells whether this Item is instance of a given type or not.protected booleanbooleanisMarkModifiedDisabled(Item refenrecedItem) Deprecated, for removal: This API element is subject to removal in a future version.protected booleanfinal ItemnewInstance(SessionContext ctx, ComposedType type, Map attributeAssignment) Creates a newItemusing the specified parameters.protected voidnotifyExtensionsAfterItemCreation(SessionContext ctx, ComposedType type, Item createdItem, Item.ItemAttributeMap attributes) protected voidnotifyExtensionsBeforeItemCreation(SessionContext ctx, ComposedType type, Item.ItemAttributeMap attributes) protected voidNotifies all managers (including all extensions) about this item being removed soon.protected voidnotifyManagerAboutItemRemoval(Manager manager, SessionContext ctx) Takes care of the de-serialization of items because we cannot have several instances of one item per PK.static voidregisterAccessFor(Class clazz, String qualifier, AttributeAccess access) Registers an attribute access for a given item class and qualifier.static voidregisterAccessFor(String extensionName, Class clazz, String qualifier, AttributeAccess access) static voidregisterJaloInvalidationListeners(InvalidationManager invMan, Cache cache) voidremove()Removes this item.voidremove(SessionContext ctx) Removes this item.static voidremoveItemCollection(SessionContext ctx, Collection collection) Removes a collection of Items's.static voidremoveItemCollection(Collection collection) Removes a collection of Items's.voidremoveLinkedItems(boolean itemIsSource, String qualifier, Language lang, List itemsToUnlink) Removes all links between this item and the given item list.voidremoveLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToUnlink) Removes all links between this item and the given item list.voidremoveLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToUnlink, boolean sortSrc2Tgt, boolean sortTgt2Src) voidremoveLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToUnlink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified) protected voidprotected voidRemoves all partOf items.protected voidremovePartOfItems(SessionContext ctx, Map<String, Object> emptyValuesMap) voidsetAllAttributes(SessionContext ctx, Map values) Sets multiple attributes at once using a specific session context.voidsetAllAttributes(Map values) Sets multiple attributes at once using the default session context.protected voidsetAllAttributesInternal(SessionContext ctx, Map values) voidsetAllLinkedItems(boolean itemIsSource, String qualifier, Map languageToItemListMap) Replaces the items currently being linked via localized links to this item for the given qualifier.voidsetAllLinkedItems(boolean itemIsSource, String qualifier, Map languageToItemListMap, boolean markModified) Replaces the items currently being linked via localized links to this item for the given qualifier.voidsetAllLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Map languageToItemListMap) Replaces the items currently being linked via localized links to this item for the given qualifier.voidsetAllLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Map languageToItemListMap, boolean markModified) voidsetAttribute(SessionContext ctx, String qualifier, Object value) Sets the value of the attribute specified by the attribute qualifier.voidsetAttribute(String qualifier, Object value) Sets the value of the attribute specified by the attribute qualifier.voidsetAttributeFromString(SessionContext ctx, String qualifier, String value) Still experimental! This method changes the attribute value by parsing a string value representation.voidsetAttributeFromString(String qualifier, String value) Still experimental! This method changes the attribute value by parsing a string value representation.voidsetCacheBound(boolean bound) setComposedType(ComposedType type) Changes the type of an item.protected voidsetCreationTime(Date creationTime) voidAssigns the persistence implementation object to this Item instance.voidsetLinkedItems(boolean itemIsSource, String qualifier, Language lang, List<? extends Item> itemsToLink) Replaces the items currently linked to this item for the given qualifier by the new item list.voidsetLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, Collection<? extends Item> itemsToLink) voidsetLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, Collection<? extends Item> itemsToLink, boolean markModified) voidsetLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, Collection<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src) voidsetLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, Collection<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified) voidsetLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List<? extends Item> itemsToLink) Replaces the items currently linked to this item for the given qualifier by the new item list.voidsetLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src) voidsetLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified) voidsetModificationTime(Date date) voidsetNonInitialAttributes(SessionContext ctx, Item item, Item.ItemAttributeMap nonInitialAttributes) Sets all attributes which could not be set duringcreateItem(SessionContext, ComposedType, ItemAttributeMap).voidvoidsetPermissionsByMap(List userRights, Map permissionMap) Changes permission settings for a given list of user rights.<T extends Item>
booleansetRelatedItems(String relationQualifier, Collection<T> values) Internal method to directly set related items linked by the One To Many relation.voidsetTransientObject(String key, Object value) Sets a transient object.protected voidsetUseTA(SessionContext ctx, boolean use) protected booleansuppressRelation(String relationQualifier, String type) toString()Returns theStringrepresentation of this item.protected booleanuseTA(SessionContext ctx, boolean def) Takes care of serialization of items.Methods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
Field Details
-
accessorLog
public static final org.apache.log4j.Logger accessorLog -
FEATURE_ACCESSMAP_QUALIFIER
-
SAVE_FROM_SERVICE_LAYER
SessionContext attribute flag providing information if the save operation was triggered from Service Layer. If enabled - the allowed principals should not be copied into related categories.- See Also:
-
DISABLE_ITEMCHECK_BEFORE_REMOVABLE
SessionContext Flag. If this Flag is in the ctx set totruethe check before Item removable is disabled.- See Also:
-
isJaloOnly
protected final boolean isJaloOnly -
staticTransientObjects
The transient object cache. Since this is implemented as Guava Cache with maximum capacity, transient objects can disappear when not used for a longer time. -
PK
ThePKattribute constant. -
_CREATION_TIME_INTERNAL
The_CREATION_TIME_INTERNALattribute constant. -
_MODIFIED_TIME_INTERNAL
The_MODIFIED_TIME_INTERNALattribute constant. -
TYPE
TheTYPEattribute constant. -
CREATION_TIME
TheCREATION_TIMEattribute constant. -
MODIFIED_TIME
TheMODIFIED_TIMEattribute constant. -
OWNER
TheOWNERattribute constant. -
NOT_FOUND
public static final int NOT_FOUNDThe internal security check result constantNOT_FOUND. Dont use.- See Also:
-
POSITIVE
public static final int POSITIVEThe internal security check result constantPOSITIVE. Dont use.- See Also:
-
NEGATIVE
public static final int NEGATIVEThe internal security check result constantNEGATIVE. Dont use.- See Also:
-
EVEN
public static final int EVENThe internal security check result constantEVEN. Dont use.- See Also:
-
HJMPTS
TheMODIFIED_TIMEattribute constant. -
INITIAL_CREATION_FLAG
This flag indicates the creation phase of an item. The flag will be set to the session context and can be tested using theisInCreate(SessionContext)method.- See Also:
-
DISABLE_ATTRIBUTE_CHECK
- See Also:
-
-
Constructor Details
-
Item
public Item()The default no-arg constructor which every Jalo Item must provide.Do not use it directly since Item creation and Item retrieval e.g. via FlexibleSearch requires a process within creating the Item object is one part besides several others. For creating Item instances always use the appopriate Manager methods or
ComposedType.newInstance(Map).
-
-
Method Details
-
registerJaloInvalidationListeners
-
isMarkModifiedDisabled
@Deprecated(since="2011", forRemoval=true) public boolean isMarkModifiedDisabled(Item refenrecedItem) Deprecated, for removal: This API element is subject to removal in a future version. -
getImplementation
Description copied from class:BridgeAbstractionreturns the implementation object of this jalo bridge abstraction- Overrides:
getImplementationin classBridgeAbstraction- Returns:
- the implementation object of this jalo bridge abstraction
-
registerAccessFor
Registers an attribute access for a given item class and qualifier.use it in your items as follows:
public class MyJaloItem extends ... { ... public static final String THE_QUALIFIER_CONSTANT = "qualifier"; ... static { registerAccessFor( MyJaloItem.class, THE_QUALIFIER_CONSTANT, new AttributeAccess() { public void setValue(SessionContext ctx, Item item, Object value) throws JaloTypeException, JaloInvalidParameterException, JaloSecurityException { // set the value here } public Object getValue(SessionContext ctx, Item item ) throws JaloTypeException, JaloInvalidParameterException, JaloSecurityException { // get the value here } } ); } ... }if there is no attribute access registered for a jalo class all superclasses are processed to find an access.
this way you may even register attribute accesses outside the actual item class which the attribute belongs to. especially useful for extension programming when adding attributes to core items is required.
- Parameters:
clazz- the item classqualifier- the attribute qualifieraccess- the access object
-
registerAccessFor
public static void registerAccessFor(String extensionName, Class clazz, String qualifier, AttributeAccess access) -
internal_registerNonClassAccessorFor
protected static final void internal_registerNonClassAccessorFor(Tenant tenant, AttributeDescriptor attributeDescriptor, AttributeAccess access) -
internal_registerClassAccessorFor
protected static final void internal_registerClassAccessorFor(Tenant tenant, Class clazz, String qualifier, AttributeAccess access) -
hasRegisteredClassAccessorFor
-
getAccessorFor
Tries to find a static AttributeAccess member with_AD_+ {attribute qualifier} as name within this item's class and its super classes.this method may be overridden if you need to return access objects which cannot be static members of this item's class for some reason. Never forget to call super.getAccessorFor() for all other attributes !
- Parameters:
qualifier- the attribute qualifier to find an access object formyClass- the class to search within- Returns:
- the matching access object or null if none exists
-
createNonClassAccessor
-
assureExtensionsLoaded
protected void assureExtensionsLoaded() -
removeItemCollection
Removes a collection of Items's.This method iterates through the bean collection and calls
remove()on each item.- Parameters:
collection- The collection of items, which will be removed.- Throws:
ConsistencyCheckException- if an error occurs during the remove process.
-
removeItemCollection
public static void removeItemCollection(SessionContext ctx, Collection collection) throws ConsistencyCheckException Removes a collection of Items's.This method iterates through the bean collection and calls
remove()on each item.- Parameters:
ctx- the session context to perform removal withincollection- The collection of items, which will be removed.- Throws:
ConsistencyCheckException- if an error occurs during the remove process.
-
getTenant
- Overrides:
getTenantin classBridgeAbstraction
-
setImplementation
Assigns the persistence implementation object to this Item instance.Do not use directly. This is part of the Item creation and retrieval process.
- Overrides:
setImplementationin classBridgeAbstraction- Parameters:
impl- the BridgeInterface object
-
getPK
Returns the primary key of this item.This is used to get a serializable reference to this Item which can be transfered for example through HTTP POST/GET requests. This PK does not change in the lifetime of an item, so the PK can definitely always be cached. You can be sure that no exception is thrown if the underlaying EJB is no longer valid.
getPK() is a simple Java method invocation which NEVER will hit the network.
- Returns:
- the primary key of this item
-
getCreationTime
Returns the time when this Item was created. Please note that the result describes the time of the application server and is not translated into the possibly different client timezone. -
setCreationTime
-
getModificationTime
Returns the time when this Item was modifed the last time. Please note that the result describes the time of the application server and is not translated into the possibly different client timezone. -
getPersistenceVersion
public long getPersistenceVersion() -
setModificationTime
-
getSession
Returns the session which is responsible for managing this item.When no session instance is available otherwise always use this to access any Jalo Manager:
UserManager um = myItem.getSession().getUserManager();
- Returns:
- the JaloSession object
-
ctx
A shortcut forgetSession().getSessionContext(). -
getComposedTypePK
Directly returns the PK of this item's composed type. -
getComposedType
Returns this Item's type. -
isInstanceOf
Tells whether this Item is instance of a given type or not. This is just a shortcut forComposedType.isInstance(Object).- Parameters:
type- theComposedType- Returns:
trueif thisItemis an instance of the specifiedComposedType
-
setComposedType
Changes the type of an item.Please note that the Item instance class may have changed! The safes way changing the type is as follows:
Item myItem = ... myItem = myItem.setComposedType( someType ); // directly assign new instance here- Parameters:
type- the new type of the item- Returns:
- the new version of this item - the new type may require a new jalo class type !!!
- Throws:
JaloInvalidParameterException- in case the new type is not compatible with the current type. this happens a) if the type is abstract, b) the new type's class is not compatible with the current class, or c) if the new type has a different deployment (JNDI name, Table) than the current one
-
getOwner
-
setOwner
- Throws:
ConsistencyCheckException
-
getAttribute
public Object getAttribute(String qualifier) throws JaloInvalidParameterException, JaloSecurityException Returns the attribute value for a single item attribute using the current session context.- Parameters:
qualifier- the attribute qualifier (case insensitive)- Returns:
- Object the value of the attribute
- Throws:
JaloInvalidParameterException- in case the attribute cannot be readJaloSecurityException- in case it is not allowed to read this attribute
-
getAttribute
public Object getAttribute(SessionContext ctx, String qualifier) throws JaloInvalidParameterException, JaloSecurityException Returns the attribute value for a single item attribute with a specified session context.- Parameters:
qualifier- the attribute qualifier (case insensitive)ctx- the session context defining the language to fetch the value for (applies for to localized attributes only )- Throws:
JaloInvalidParameterException- in case the attribute cannot be readJaloSecurityException- in case it is not allowed to read this attribute
-
setAttributeFromString
public void setAttributeFromString(String qualifier, String value) throws JaloInvalidParameterException, JaloBusinessException Still experimental! This method changes the attribute value by parsing a string value representation.- Parameters:
qualifier- the attribute qualifiervalue- the string value representation- Throws:
JaloInvalidParameterException- in case the attribute cannot be read or is not string-representableJaloBusinessException- if an error occurs during setting the value- Since:
- 2.10
-
setAttributeFromString
public void setAttributeFromString(SessionContext ctx, String qualifier, String value) throws JaloInvalidParameterException, JaloBusinessException Still experimental! This method changes the attribute value by parsing a string value representation.- Parameters:
ctx- the session contextqualifier- the attribute qualifiervalue- the string value representation- Throws:
JaloInvalidParameterException- in case the attribute cannot be read or is not string-representableJaloBusinessException- if an error occurs during setting the value- Since:
- 2.10
-
getAllAttributes
Reads all (readable) attribute values of this item using the current session context. Please note that only non-private attributes are fetched. To read them as well usegetAllAttributes(SessionContext, Set)instead.- Throws:
JaloInvalidParameterException- in case one attribute cannot be readJaloSecurityException- in case one attribute is not allowed to be read
-
getAllAttributes
public Map getAllAttributes(SessionContext ctx) throws JaloInvalidParameterException, JaloSecurityException Reads all (readable) attribute values of this item using a specific session context. Please note that only non-private attributes are fetched. To read them as well usegetAllAttributes(SessionContext, Set)instead.- Parameters:
ctx- the session context defining the language to fetch the value for (applies for to localized attributes only )- Throws:
JaloInvalidParameterException- in case one attribute cannot be readJaloSecurityException- in case one attribute is not allowed to be read
-
getAllAttributes
public Map getAllAttributes(SessionContext ctx, Item.AttributeFilter filter) throws JaloInvalidParameterException, JaloSecurityException Reads all attribute values of this item which pass a given attribute filter. Please note that only non-private attributes are fetched. To read them as well usegetAllAttributes(SessionContext, Set)instead.- Parameters:
ctx- the session context to read values forfilter- the attribute filter to specify which attributes should be read and which should be skipped- Throws:
JaloInvalidParameterException- in case one attribute cannot be readJaloSecurityException- in case one attribute is not allowed to be read
-
setUseTA
-
useTA
-
getAllAttributes
public Map getAllAttributes(SessionContext ctx, Set<String> qualfiers) throws JaloInvalidParameterException, JaloSecurityException Reads all values of specified attributes for this item.- Parameters:
ctx- the session context to read values forqualfiers- the qualifiers of all attributes to read values form- Throws:
JaloInvalidParameterException- in case one attribute cannot be readJaloSecurityException- in case one attribute is not allowed to be read
-
getAllAttributesInternal
protected Map<String,Object> getAllAttributesInternal(SessionContext ctx, Set<String> qualfiers) throws JaloInvalidParameterException, JaloSecurityException -
setAllAttributes
public void setAllAttributes(Map values) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException Sets multiple attributes at once using the default session context.- Parameters:
values- a map containing mapping from attribute qualifier to its new value- Throws:
JaloInvalidParameterException- in case a wrong value was provided or a attribute could not be found at allJaloSecurityException- in case a attribute could not be writtenJaloBusinessException- on misc application errors during attribute writing
-
setAllAttributes
public void setAllAttributes(SessionContext ctx, Map values) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException Sets multiple attributes at once using a specific session context.- Parameters:
values- a map containing mapping from attribute qualifier to its new valuectx- the session context defining the language to fetch the value for (applies for to localized attributes only )- Throws:
JaloInvalidParameterException- in case a wrong value was provided or a attribute could not be found at allJaloSecurityException- in case a attribute could not be writtenJaloBusinessException- on misc application errors during attribute writing
-
setAllAttributesInternal
protected void setAllAttributesInternal(SessionContext ctx, Map values) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException -
checkConstraint
Allows to implement transaction safe consistency checking code. Please refer toItem.ItemConstraintfor more detail.- Parameters:
constr- the consistency checking code object- Throws:
ConsistencyCheckException- in case the constraint is violated
-
isInCreate
-
setAttribute
public void setAttribute(String qualifier, Object value) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException Sets the value of the attribute specified by the attribute qualifier.- Parameters:
qualifier- the attribute qualifier of the attribute, of which the value will be set.value- the attribute value which will be set- Throws:
JaloInvalidParameterExceptionJaloSecurityExceptionJaloBusinessException
-
setAttribute
public void setAttribute(SessionContext ctx, String qualifier, Object value) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException Sets the value of the attribute specified by the attribute qualifier.- Parameters:
ctx- the session contextqualifier- the attribute qualifier of the attribute, of which the value will be set.value- the attribute value which will be set- Throws:
JaloInvalidParameterExceptionJaloSecurityExceptionJaloBusinessException
-
getLinkedItems
Finds items linked to this item for a given link qualifier. The result list is ordered either- by the link sequence number in case this item is link source, or
- by the link creation time if this item is link target.
- Parameters:
itemIsSource- tells whether this item is source or target of the links to findqualifier- the link qualifierlang- optional: the language for localized links
-
getLinkedItems
public List getLinkedItems(boolean itemIsSource, String qualifier, Language lang, int start, int count) Finds a range of items linked to this item for a given link qualifier. The result list is ordered either- by the link sequence number in case this item is link source, or
- by the link creation time if this item is link target.
- Parameters:
itemIsSource- tells whether this item is source or target of the links to findqualifier- the link qualifierlang- optional: the language for localized linksstart- the start index of the item rangecount- the amount of items to fetch, use-1for unlimited amount
-
getLinkedItemsCount
- Parameters:
itemIsSource- tells whether this item is source or target of the links to countqualifier- the link qualifierlang- optional: the link language for localized links- Returns:
- the amount of existing links or localized links for the given qualifier
-
getLinkedItems
public List getLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang) Finds items linked to this item for a given link qualifier. The result list is ordered either- by the link sequence number in case this item is link source, or
- by the link creation time if this item is link target.
- Parameters:
itemIsSource- tells whether this item is source or target of the links to findqualifier- the link qualifierlang- optional: the language for localized linksctx- the session context to execute this method within
-
getLinkedItems
public List getLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, boolean sortSrc2Tgt, boolean sortTgt2Src) -
getLinkedItems
public List getLinkedItems(SessionContext ctx, boolean itemIsSource, String relationCode, String relatedItemCode, Language lang, boolean sortSrc2Tgt, boolean sortTgt2Src) -
isEmptyRelationValue
Override this method to implement different language fallback behaviour. As default onlynullvalues are considered as empty. Example:@Override protected boolean isEmptyRelationValue(SessionContext ctx, String name, Object value) { return super.isEmptyValue(ctx, name, value) || ("myAttr".equals(name) && ((String) value).trim().length() == 0); }- Parameters:
ctx- the session context while getting the propertyname- the property namevalue- the actual stored value- Returns:
- true if the value should be treated as empty - in this case values for fallback languages are fetched
-
isRelationLocalizationFallbackEnabled
-
getLinkedItems
public List getLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, int start, int count) Finds a range of items linked to this item for a given link qualifier. The result list is ordered either- by the link sequence number in case this item is link source, or
- by the link creation time if this item is link target.
- Parameters:
itemIsSource- tells whether this item is source or target of the links to findqualifier- the link qualifierlang- optional: the language for localized linksstart- the start index of the item rangecount- the amount of items to fetch, use-1for unlimited amountctx- the session context to execute this method within
-
getLinkedItems
public List getLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, int start, int count, boolean sortSrc2Tgt, boolean sortTgt2Src) -
getLinkedItemsCount
public long getLinkedItemsCount(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang) - Parameters:
itemIsSource- tells whether this item is source or target of the links to countqualifier- the link qualifierlang- optional: the link language for localized linksctx- the session context to execute this method within- Returns:
- the amount of existing links or localized links for the given qualifier
-
getLinkedItemsCount
public long getLinkedItemsCount(SessionContext ctx, boolean itemIsSource, String relationTypeCode, String relatedItemCode, Language lang) - Parameters:
ctx- the session context to execute this method withinitemIsSource- tells whether this item is source or target of the links to countrelationTypeCode- the link qualifierrelatedItemCode- the related item qualifierlang- optional: the link language for localized links- Returns:
- the amount of existing links or localized links for the given qualifier
-
getAllLinkedItems
Returns all localized linked items for a given qualifier. The map contains{ Language -> [ Item+] }mappings. The item lists are ordered as described ingetLinkedItems(boolean, String, Language).- Parameters:
itemIsSource- tells whether this item is source or target of the links to evaluatequalifier- the link qualifier
-
setLinkedItems
public void setLinkedItems(boolean itemIsSource, String qualifier, Language lang, List<? extends Item> itemsToLink) Replaces the items currently linked to this item for the given qualifier by the new item list. If this item becomes the links source the order of this list is preserved by setting according sequence numbers within the links. Otherwise all existing links keep their sequence numbers ( in case the item has been linked before ) and new links are put at top having 0 as sequence number.- Parameters:
itemIsSource- tells whether this item is link source or targetqualifier- the link qualifierlang- optional: the language if the links should be localizeditemsToLink- the new collection of items to link to
-
setLinkedItems
public void setLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List<? extends Item> itemsToLink) Replaces the items currently linked to this item for the given qualifier by the new item list. If this item becomes the links source the order of this list is preserved by setting according sequence numbers within the links. Otherwise all existing links keep their sequence numbers ( in case the item has been linked before ) and new links are put at top having 0 as sequence number.- Parameters:
itemIsSource- tells whether this item is link source or targetqualifier- the link qualifierlang- optional: the language if the links should be localizeditemsToLink- the new collection of items to link toctx- the session context to execute this method within
-
setLinkedItems
public void setLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, Collection<? extends Item> itemsToLink) -
setLinkedItems
public void setLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, Collection<? extends Item> itemsToLink, boolean markModified) -
setLinkedItems
public void setLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src) -
setLinkedItems
public void setLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified) -
setLinkedItems
public void setLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, Collection<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src) -
setLinkedItems
public void setLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, Collection<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified) -
setAllLinkedItems
Replaces the items currently being linked via localized links to this item for the given qualifier. These items have to be provided within a map containingLanguages as keys and lists of items as values. The order within these lists is preserved if this item is the source item of these links.- Parameters:
itemIsSource- tells whether this item is link source or targetqualifier- the link qualifierlanguageToItemListMap- the new items to link asLanguage-> [Item] map
-
setAllLinkedItems
public void setAllLinkedItems(boolean itemIsSource, String qualifier, Map languageToItemListMap, boolean markModified) Replaces the items currently being linked via localized links to this item for the given qualifier. These items have to be provided within a map containingLanguages as keys and lists of items as values. The order within these lists is preserved if this item is the source item of these links.- Parameters:
itemIsSource- tells whether this item is link source or targetqualifier- the link qualifierlanguageToItemListMap- the new items to link asLanguage-> [Item] map
-
setAllLinkedItems
public void setAllLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Map languageToItemListMap) Replaces the items currently being linked via localized links to this item for the given qualifier. These items have to be provided within a map containingLanguages as keys and lists of items as values. The order within these lists is preserved if this item is the source item of these links.- Parameters:
itemIsSource- tells whether this item is link source or targetqualifier- the link qualifierlanguageToItemListMap- the new items to link asLanguage-> [Item] map
-
setAllLinkedItems
public void setAllLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Map languageToItemListMap, boolean markModified) -
addLinkedItems
Creates new links between this item and a given list of items. These links will be appended to existing links.- Parameters:
itemIsSource- tells whether this item is source or target of the new linksqualifier- specifies the link qualifierlang- optional: the language to create localized links foritemsToLink- the items which will be linked with this item
-
addLinkedItems
public void addLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink) Creates new links between this item and a given list of items. These links will be appended to existing links.- Parameters:
itemIsSource- tells whether this item is source or target of the new linksqualifier- specifies the link qualifierlang- optional: the language to create localized links foritemsToLink- the items which will be linked with this itemctx- the session context to execute this method within
-
addLinkedItems
public void addLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, boolean markModified) -
addLinkedItems
public void addLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src) -
addLinkedItems
public void addLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified) -
addLinkedItems
public void addLinkedItems(boolean itemIsSource, String qualifier, Language lang, List itemsToLink, int position) Creates new links between this item and a given list of items at a speciic position among this items link list. All preceding (existing) links will be shifted.- Parameters:
itemIsSource- tells whether this item is source or target of the new linksqualifier- specifies the link qualifierlang- optional: the language to create localized links foritemsToLink- the items which will be linked with this itemposition- the position where to insert the new links ( -1 means append at the end )
-
addLinkedItems
public void addLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, int position) Creates new links between this item and a given list of items at a speciic position among this items link list. All succeeding (existing) links will be shifted.- Parameters:
itemIsSource- tells whether this item is source or target of the new linksqualifier- specifies the link qualifierlang- optional: the language to create localized links foritemsToLink- the items which will be linked with this itemposition- the position where to insert the new links ( -1 means append at the end )ctx- the session context to execute this method within
-
addLinkedItems
public void addLinkedItems(boolean itemIsSource, String qualifier, Language lang, List itemsToLink, int position, boolean shift) Creates new links between this item and a given list of items at a speciic position among this items link list. Optionally the succeeding (existing) links can be shifted or not. If not they keep their position.Use this to add links at specific positions like this:
Item myItem = ... Item[] toLink = ... // add at 3 myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[0]), 3, false ); // add at 1 *and* avoid shifting the previous link from 3 to 4 ! myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[1]), 1, false ); // add at 7 myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[2]), 7, false );- Parameters:
itemIsSource- tells whether this item is source or target of the new linksqualifier- specifies the link qualifierlang- optional: the language to create localized links foritemsToLink- the items which will be linked with this itemposition- the position where to insert the new links ( -1 means append at the end )shift- thells whether succeeding links should shift their positions accoding to new links size or not
-
addLinkedItems
public void addLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToLink, int position, boolean shift) Creates new links between this item and a given list of items at a speciic position among this items link list. Optionally the succeeding (existing) links can be shifted or not. If not they keep their position.Use this to add links at specific positions like this:
Item myItem = ... Item[] toLink = ... // add at 3 myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[0]), 3, false ); // add at 1 *and* avoid shifting the previous link from 3 to 4 ! myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[1]), 1, false ); // add at 7 myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[2]), 7, false );- Parameters:
itemIsSource- tells whether this item is source or target of the new linksqualifier- specifies the link qualifierlang- optional: the language to create localized links foritemsToLink- the items which will be linked with this itemposition- the position where to insert the new links ( -1 means append at the end )shift- thells whether succeeding links should shift their positions accoding to new links size or notctx- the session context to execute this method within
-
removeLinkedItems
public void removeLinkedItems(boolean itemIsSource, String qualifier, Language lang, List itemsToUnlink) Removes all links between this item and the given item list.- Parameters:
itemIsSource- tells whether this item is source or target of the links to removequalifier- the qualifier of the linkslang- optional: the language of the localized linksitemsToUnlink- the items to unlink (non-existing links will be ignored)
-
removeLinkedItems
public void removeLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToUnlink) Removes all links between this item and the given item list.- Parameters:
itemIsSource- tells whether this item is source or target of the links to removequalifier- the qualifier of the linkslang- optional: the language of the localized linksitemsToUnlink- the items to unlink (non-existing links will be ignored)ctx- the session context to execute this method within
-
removeLinkedItems
public void removeLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToUnlink, boolean sortSrc2Tgt, boolean sortTgt2Src) -
removeLinkedItems
public void removeLinkedItems(SessionContext ctx, boolean itemIsSource, String qualifier, Language lang, List itemsToUnlink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified) -
remove
Removes this item.This method calls
remove(SessionContext)with the current session's SessionContext object. See this method for more details.- Throws:
ConsistencyCheckException- if this item could not be removed for some reason
-
remove
Removes this item.This method is using the following attributes of the given SessionContext:
CacheUsage Language StagingMethod n/a (this is a setter method) no, language doesn't matter for removal yes if called on a StageableItem, no otherwise
- Parameters:
ctx- A SessionContext object- Throws:
ConsistencyCheckException- if this item could not be removed for some reason
-
doBeforeRemove
Hook method to perform removal logic just before this item is being deleted from database. Please prefer this to overridingremove(SessionContext)because this method is guaranteed to be called in synchronized context. -
doAfterRemove
Hook method to perform removal logic just after this item is being deleted from database. Please prefer this to overridingremove(SessionContext)because this method is guaranteed to be called in synchronized context. -
isCurrentlyRemoving
-
isCurrentlyRemoving
-
getCurrentlyRemovingCount
public static int getCurrentlyRemovingCount() -
removePartOfItems
Removes all partOf items. Override to add customized partOf removal logic.- Parameters:
ctx-- Throws:
ConsistencyCheckException
-
suppressRelation
-
getPartOfRemovedSessionMarker
-
removePartOfItems
protected void removePartOfItems(SessionContext ctx, Map<String, Object> emptyValuesMap) throws ConsistencyCheckException- Throws:
ConsistencyCheckException
-
removeLinks
protected void removeLinks() -
checkRemovable
Checks whether or not this it may be removed or not. Called before the actual removal process.- Parameters:
ctx-- Throws:
ConsistencyCheckException- to indicate that the item cannot be removed
-
notifyItemRemoval
Notifies all managers (including all extensions) about this item being removed soon. This method will not throw any exception even if one of the managers raised one. These exceptions will be logged only!- Parameters:
ctx-
-
notifyManagerAboutItemRemoval
-
equals
Two items are equal, if their primary keys are equals.Thus, performing a
item.getPK().equals(item2.getPK() )produces the same result, but this method can use optimized code so you should useitem.equals(item2)whenever you want to compare two items for equality. -
compareTo
Implements item comparison by PK. Subclasses may override this.- Specified by:
compareToin interfaceComparable- Parameters:
object- which will be compared to this item.- Returns:
- the value 0 if the argument item pk is equal to this item pk; a value less than 0 if this item pk is lexicographically less than the argument item pk; and a value greater than 0 if this item pk is lexicographically greater than the argument item pk.
-
hashCode
public final int hashCode()Returns the hashcode of this item.The hashcode of an item is defined as the hashcode of its primary key object.
-
toString
Returns theStringrepresentation of this item. This is by default the representation of the primary key of this item. -
getRestrictedPrincipals
- Returns:
- a set of all principals which own a restriction upon this item
-
getPermissions
Finds all positive or negative permissions upon this item and the givenPrincipal.- Parameters:
principal- thePrincipalwhos permissions will be returnednegative- if set totrue, all negative permissions will be returned, if set tofalse, all positive permission will be returned.- Returns:
- a set of
UserRight
-
getPermissionMap
Finds the all permission settings for a given list of user rights. The result is a map{ Principal -> [ Boolean.TRUE == negative | Boolean.FALSE == positive | null == not set ] }.an example:
rights = [ r1 , r2 , r3 ] result = { user1 -> [ T , F , F ] user2 -> [ null, null, T ] } which means: user1 is denied r1, allowed r2 and r3 user2 is denied r3, others are not set ( default or derived permission is take )- Parameters:
userRights- a list ofUserRights- Returns:
- the permission map.
-
setPermissionsByMap
Changes permission settings for a given list of user rights. This is done by a mapPrincipal -> [ Boolean.TRUE == negative || Boolean.FALSE == positive || null == not set }.An example:
rights = [ r1 , r2 , r3 ] permissionMap = { user1 -> [ T , F , F ] user2 -> [ null, null, T ] } which means: user1 is denied r1, allowed r2 and r3 user2 is denied r3, others are not set ( default or derived permission is take )- Parameters:
userRights- a list ofUserRight, <code> null </code> is not allowedpermissionMap- a map containing the user to permission information.- Throws:
JaloSecurityException
-
getPositivePermissions
Finds all positive permissions for the item and the givenPrincipal.- Parameters:
principal- all returned permissions belong to.- Returns:
- a set of
UserRight
-
getNegativePermissions
Finds all negative permissions for the item and the givenPrincipal.- Parameters:
principal- all returned permissions belong to.- Returns:
- a set of
UserRight
-
addPermission
Add a permission for thePrincipaland theUserRighton theItem.- Parameters:
principal- thePrincipalthe permission belongs to.right- theUserRightthe permission belongs to.negative-trueif the permission should be negative, otherwise a positive permission
-
clearPermission
Remove any permission for thePrincipaland theUserRighton theItem.- Parameters:
principal- thePrincipalthe removed permission belongs to.right- theUserRightthe removed permission belongs to.
-
addPositivePermission
Add a positive permission for thePrincipaland theUserRighton theItem.- Parameters:
principal- thePrincipalthe positive permission belongs to.right- theUserRightthe positive permission belongs to.
-
addNegativePermission
Add a negative permission for thePrincipaland theUserRighton theItem.- Parameters:
principal- thePrincipalthe negative permission belongs to.right- theUserRightthe negative permission belongs to.
-
checkPermission
Checks if the current session user has the givenUserRighton theItem.- Parameters:
right- theUserRightthe permission should be checked for- Returns:
trueif the current session user has theUserRightfor thisItem
-
checkPermission
Checks if thePrincipalhas the givenUserRighton theItem.- Parameters:
principal- thePrincipalthe permission should be checked forright- theUserRightthe permission should be checked for- Returns:
trueif thePrincipalhas theUserRightfor thisItem
-
checkItemPermission
-
setTransientObject
Sets a transient object.the value will be mapped to this object until
- it will be removed with
setTransientObject(key,null) - or the garbage collector will remove this BridgeAbstraction.
- Specified by:
setTransientObjectin classBridgeAbstraction- Parameters:
key- the keyvalue- may be null; this will remove the transient object mapping
- it will be removed with
-
getTransientObject
Get a transient object.nullis returned if no transient object is mapped to the given key.- Specified by:
getTransientObjectin classBridgeAbstraction- Parameters:
key- the key of the transient object which should be returned.- Returns:
- the transient object
-
getTransientObjectMap
Deprecated.since 18.08 - don't operate on transient object map directly. UsesetTransientObject(String, Object)andgetTransientObject(String)Returns the completeMapof transient objects.Note: Changes are directly reflected to the BridgeAbstraction object. The returned map is bound to the object. So be careful when modifying the map.
- Specified by:
getTransientObjectMapin classBridgeAbstraction- Returns:
- a
Mapof all transient objects.
-
isAlive
public boolean isAlive()Istrueif this item is still valid.- Returns:
trueif this item is still valid.
-
getCacheBoundItem
NOTE: hybris internal method, do not use- Returns:
- the Item that is in the cache (either THIS or a new instance which is put in the cache
-
getAndCheckCacheBoundItem
-
setCacheBound
public void setCacheBound(boolean bound) -
isCacheBound
public boolean isCacheBound() -
invalidateLocalCaches
public void invalidateLocalCaches() -
newInstance
public final Item newInstance(SessionContext ctx, ComposedType type, Map attributeAssignment) throws JaloBusinessException Creates a newItemusing the specified parameters.- Parameters:
ctx- the session context which the new item should be created withintype- theComposedTypeof the newly createdItemattributeAssignment- a map containing the attribute values of the newly createdItem- Returns:
- the created
Item - Throws:
JaloBusinessException
-
notifyExtensionsBeforeItemCreation
protected void notifyExtensionsBeforeItemCreation(SessionContext ctx, ComposedType type, Item.ItemAttributeMap attributes) throws JaloBusinessException - Throws:
JaloBusinessException
-
notifyExtensionsAfterItemCreation
protected void notifyExtensionsAfterItemCreation(SessionContext ctx, ComposedType type, Item createdItem, Item.ItemAttributeMap attributes) throws JaloBusinessException - Throws:
JaloBusinessException
-
changeTypeAfterCreation
protected Item changeTypeAfterCreation(Item newOne, ComposedType requestedType) throws JaloInvalidParameterException Changes the item type in casecreateItem(SessionContext, ComposedType, ItemAttributeMap)did not set the requested type directly.overriding this method should hardly be necessary - common case might be disallowing the type to be changed at all.
- Parameters:
newOne- the newly created itemrequestedType- the type which triggered this items creation- Returns:
- the item with the correct type which possibly has to be re-wrapped ( if the requested type declares a jalo class differently from the current items instance class )
- Throws:
JaloInvalidParameterException
-
setNonInitialAttributes
public void setNonInitialAttributes(SessionContext ctx, Item item, Item.ItemAttributeMap nonInitialAttributes) throws JaloBusinessException Sets all attributes which could not be set duringcreateItem(SessionContext, ComposedType, ItemAttributeMap). as default this method just iterates over all attribute mappings and sets the value by invokingsetAttribute(SessionContext, String, Object).- Parameters:
ctx- session context with language = NULLitem- the newly created itemnonInitialAttributes- the non-initial attributed obtained viagetNonInitialAttributes(SessionContext, ItemAttributeMap)- Throws:
JaloBusinessException
-
getNonInitialAttributes
protected Item.ItemAttributeMap getNonInitialAttributes(SessionContext ctx, Item.ItemAttributeMap allAttributes) Defines all attributes which should be set after item creation. this is done be removing all attributes which are already set bycreateItem(SessionContext, ComposedType, ItemAttributeMap).use it like this:
protected ItemAttributeMap getNonInitialAttributes( SessionContext ctx, ItemAttributeMap allAttributes ) { // let all superclasses remove their intial attributes too final ItemAttributeMap attributes = super.getNonInitialAttributes( ctx, allAttributes ); // remove own initial attributes here attributes.remove( MyItem.MY_INITIAL_ATTR ); return ret; }it is vital to optain the map via super.getNonInitialAttributes and pass it on as such since this ensures that attribute qualifiers are treated case insensitive!- Parameters:
ctx- session context with language = NULLallAttributes- aItemAttributeMapcontaning attribute values.- Returns:
- a
ItemAttributeMapcontaining all attribute values, which belong to non-initial attributes.
-
checkMandatoryAttribute
protected static boolean checkMandatoryAttribute(String qualifier, Item.ItemAttributeMap allAttributes, Set missingSet) Checks if the attributes map contains a given qualifier. if the qualifier is mapped to a null value it is treated as missing.- Parameters:
qualifier- the qualifier to checkallAttributes- the creation attributes mapmissingSet- the container to add a missing qualifier to- Returns:
- true if the qualifier is present
-
checkMandatoryAttribute
protected static boolean checkMandatoryAttribute(String qualifier, Item.ItemAttributeMap allAttributes, Set missingSet, boolean nullAllowed) Checks if the attributes map contains a given qualifier. It may be specified if qualifiers mapped to null values are allowed or not.- Parameters:
qualifier- the qualifier to checkallAttributes- the creation attributes mapmissingSet- the container to add a missing qualifier tonullAllowed- tells whether null values are allowed or such qualifiers are treated as missing ones- Returns:
- true if the qualifier is present
-
createItem
protected abstract Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException Has to be implemented for each concrete subtype of item. This method is responsible for creating a new item instance ( by calling managers, ejb homes, etc. ) duringComposedType.newInstance(Map).In case this method uses any of the attribute values during creation it is required to override
getNonInitialAttributes(SessionContext, ItemAttributeMap)too.
Sn example:public static final String MY_ATTRIBUTE = "someAttribute"; ... protected Item createItem(SessionContext ctx, ComposedType type, Map allAttributes ) throws JaloBusinessException { MyManager man = ... return man.createMyItem( (String)allAttributes.get(MY_ATTRIBUTE) ); // here MY_ATTRIBUTE is used for creation, so it must not be set again } protected Map getNonInitialAttributes( SessionContext ctx, Map allAttributes ) { // let superclass remove its own initial attributes Map ret = super.getNonInitialAttributes( ctx, allAttributes ); // remove MY_ATTRIBUTE from all attributes since if has already been set ret.remove(MY_ATTRIBUTE); return ret; }- Parameters:
ctx- the current session context which this item is created withintype- the actual item type ( since subtypes may not provide a own jalo class this may be different from the type which this method was implemented for )allAttributes-- Returns:
- the new item instance
- Throws:
JaloBusinessException- indicates an error during creation - any changes will be rollbacked
-
getSyncObject
returns an object that can be used for synchronization on the current item pk. e.g. synchronized( getSyncObject() ) { ... }. Please do not use the item or PK object for itself, because they might be subject of garbage-collection.- Returns:
- the syncobject
-
writeReplace
Takes care of serialization of items. We don't write the real item instances but new instance of the same class just holding its PK and its removal flag.This is sufficient because reading items is also handled specially by fetching it via PK instead of using the object from the stream ( see
readResolve()).- Throws:
ObjectStreamException
-
readResolve
Takes care of the de-serialization of items because we cannot have several instances of one item per PK. So the actual item is always tried to fetch viaJaloSession.getItem(PK).- Throws:
ObjectStreamException
-
isItemCheckBeforeRemoveableDisabled
- Parameters:
ctx- the sessioncontext- Returns:
- true if in the given SessionContext the attribute
DISABLE_SUBCATEGORY_REMOVALCHECKexists AND the value of this attribute is true
-
getDefaultAttributeModes
-
getRelatedItems
Internal method to directly return related items linked by the One To Many relation. Its purpose is to allow the underlying persistence to intercept this call and handle it in a more efficient way.- Parameters:
relationQualifier- name of the attribute seen from the One end of the relation.- Returns:
- the collection of related items or null if direct access is not supported by the underlying persistence layer.
-
getRelatedItems
Internal method to directly return related items linked by the One To Many relation. Its purpose is to allow the underlying persistence to intercept this call and handle it in a more efficient way.- Parameters:
relationsInfo- consists of relation-related objects- Returns:
- the collection of related items or null if direct access is not supported by the underlying persistence layer.
-
setRelatedItems
Internal method to directly set related items linked by the One To Many relation. Its purpose is to allow the underlying persistence to intercept this call and handle it in a more efficient way.- Parameters:
relationQualifier- name of the attribute seen from the One end of the relation.values- collection of Items to be set.- Returns:
- false if operation is not supported by the underlying persistence layer.
-