-
getOwner
-
fulfills
-
getGroupingAttributeValue
Override any methods that you need. At a minimum, you must
override the getOwner
method.
The fulfills
method must be implemented if there is an access control policy that
includes this resource in its resource group, and also specifies a
relationship or relationship group. The getGroupingAttributeValue
method must be implemented if there is an access control policy with
an implicit resource group that includes certain instances of this
resource, based on specific attribute values (for example, if there
were an access control policy that pertains only pertains to Orders
with status = 'P' (pending)).
Note that if the only relationship
needed is "owner", then you do not need to override the fulfills method.
In this case, the policy manager will make use of the result of the
getOwner() method.
The default implementations of these methods
are shown in the following code snippets. These implementations come
from the ECEntityBean class.
************************************************************************
public Long getOwner() throws Exception
{
return null;
}
************************************************************************
************************************************************************
public boolean fulfills(Long member, String relationship)
throws Exception
{
return false;
}
************************************************************************
************************************************************************
public Object getGroupingAttributeValue(String attributeName,
GroupingContext context) throws Exception
{
return null;
}
************************************************************************
The following are sample implementations of these methods
based on the implementations used in the OrderBean bean:
- For the getOwner method, the logic of the provided method is:
***********************************************************************
com.ibm.commerce.common.objects.StoreEntityAccessBean storeEntAB =
new com.ibm.commerce.common.objects.StoreEntityAccessBean();
storeEntAB.setInitKey_storeEntityId(getStoreEntityId().toString());
return storeEntAB.getMemberIdInEJBType();
***********************************************************************
- For the fulfills method, the logic of the provided method is:
************************************************************************
if ("creator".equalsIgnoreCase(relationship))
{
return member.equals(bean.getMemberId());
}
else if ("BuyingOrganizationalEntity".equalsIgnoreCase(relationship))
{
return (member.equals(bean.getOrganizationId()));
}
else if ("sameOrganizationalEntityAsCreator".
equalsIgnoreCase(relationship))
{
com.ibm.commerce.user.objects.UserAccessBean creator =
new com.ibm.commerce.user.objects.UserAccessBean();
creator.setInitKey_MemberId(bean.getMemberId().toString());
com.ibm.commerce.user.objects.UserAccessBean ab =
new com.ibm.commerce.user.objects.UserAccessBean();
ab.setInitKey_MemberId(member.toString());
if (ab.getParentMemberId().equals(creator.getParentMemberId()))
return true;
}
return false;
************************************************************************
- For the getGroupingAttributeValue method, the logic of the provided
method is:
************************************************************************
if (attributeName.equalsIgnoreCase("Status"))
return getStatus();
return null;
************************************************************************