com.ca.jcs.assoc
Class DefaultAssocDirectAttributeOpProcessor

java.lang.Object
  extended by com.ca.jcs.processor.AbstractBaseProcessor
      extended by com.ca.jcs.processor.AbstractAttributeStyleOpProcessor
          extended by com.ca.jcs.processor.AbstractAttributeStyleOpProcessorAssocDirect
              extended by com.ca.jcs.assoc.DefaultAssocDirectAttributeOpProcessor
All Implemented Interfaces:
Activatable, AssocAttributeOpProcessor, AssocDirectAttributeOpProcessor, AttributeStyleOpProcessor, OpProcessor, PostQueryAttributesProcessor
Direct Known Subclasses:
DefaultAssocAttributeOpProcessor, NestedAssocDirectAttributeOpProcessor, SDKAttributeStyleOpProcessor, SDKWSAttributeStyleOpProcessor, StubDirectAssocAttributeStyleOpProcessor

public abstract class DefaultAssocDirectAttributeOpProcessor
extends AbstractAttributeStyleOpProcessorAssocDirect

Default implementation of "direct" associations, where the associative link between an object and another is stored directly in one of their attributes. In this case links are often only stored on the endpoint in one direction and reverse lookups are used to populate a calculate an expensive virtual attribute in the other direction. For instance, the list of member accounts for a group might be the data actually stored on the endpoint and accessed as an attribute called group.member, and arriving at the list of groups to which an account belongs may involve a computationally expensive search to populate values of a virtual account.memberOf attribute. As well as populating values for virtual association attributes, this class also automatically update references in the values of non-virtual association attributes to objects which are deleted, renamed or moved.


Nested Class Summary
protected static class DefaultAssocDirectAttributeOpProcessor.AssocAttrValue
          Wraps an associative attribute value which is either a DN or other attribute value
static class DefaultAssocDirectAttributeOpProcessor.AssociationStyle
          Classifies styles of associations
 
Nested classes/interfaces inherited from interface com.ca.jcs.processor.OpProcessor
OpProcessor.MethodName
 
Field Summary
 MetaConnector metaConnector
           
 
Fields inherited from class com.ca.jcs.processor.AbstractAttributeStyleOpProcessorAssocDirect
proxiedAssocSelf
 
Fields inherited from class com.ca.jcs.processor.AbstractAttributeStyleOpProcessor
proxiedSelf
 
Fields inherited from class com.ca.jcs.processor.AbstractBaseProcessor
ldapExceptionPrefix, log
 
Constructor Summary
DefaultAssocDirectAttributeOpProcessor(MetaConnector connector)
          Hang on to some important contextual values.
 
Method Summary
 void addAttrAssocs(ObjectInfo objInfo, Association assoc, Attribute attr, Object context)
          Simply calls updateAttrAssocs(ObjectInfo, int, Association, Attribute).
 NamingEnumeration<SearchResult> doAssocSearchForReferencesTo(ObjectInfo targetObjInfo, Association assoc, boolean targetDefinedAssoc, MetaConnector connector)
          Given a targetInfo object and association, returns search result (in connector-speak) for each instance of assoc's class which references the targetInfo object.
 void doAssocUpdateReferencesTo(ObjectInfo targetObjInfo, Name newConnDn, MetaConnector connector)
          Handle updating all reverse associative pointers referring to the target object referred to by targetObjInfo (whether single or multi-valued), with its new DN.
 void doDeleteAssocs(ObjectInfo targetObjInfo, Object opContext)
          Delete all associations referencing target object referred to by objInfo.
 void doLookupAssocs(ObjectInfo objInfo, Association[] associations, Attributes attrs, Object opContext)
          Lookup all associations for the target object referred to be objInfo and add them as multi-valued associative attributes to attrs.
 Attribute doLookupExpensiveStub(ObjectInfo objInfo, String attrId)
          Default implementation is to simply do a lookup but derived classes may be able to efficiently find out if the attribute is set or not.
 void doModifyAssocs(ObjectInfo objInfo, AssocModificationItem[] items, Object opContext)
          Break down provided association modification into addAttrAssocs(com.ca.jcs.ObjectInfo, com.ca.jcs.assoc.Association, javax.naming.directory.Attribute, java.lang.Object) or removeAttrAssocs(com.ca.jcs.ObjectInfo, com.ca.jcs.assoc.Association, javax.naming.directory.Attribute, java.lang.Object) calls as appropriate.
 void doModifyRnAssocs(ObjectInfo objInfo, Rdn newRdn, Object opContext)
          Update association attributes after the target object denoted by objInfo (which still refers to the old name) is renamed.
 void doMoveAssocs(ObjectInfo objInfo, Name newName, Object opContext)
          Update association attributes after the target object denoted by objInfo (which still refers to the old name) is moved to newName.
 NamingEnumeration<SearchResult> doSearchAssocs(MetaObjectClassMappings classMapping, Association[] associations, NamingEnumeration<SearchResult> searchResults, String filterExpr, Object opContext)
          Wrap provided queryNum with logic to provide values for association attributes on search results.
 String expandTemplateValues(String nameTemplate, String dn)
          Expand template value using a DN/RDN or a string
protected  MetaObjectClassMapping getAssocClassMap(Association assoc, boolean targetDefinedAssoc)
           
protected  String getAssocConnAttrId(Association assoc, boolean targetDefinedAssoc)
          Get the single connector speak associative attribute
protected  String[] getAssocConnAttrIds(Association assoc, String ldapAttrId, boolean targetDefinedAssoc)
           
protected  String[] getAssocConnectorAttrIds(Association assoc, boolean targetDefinedAssoc)
           
protected  DataModelProperty getAssocDataModelProp(String refLdapAttr, MetaObjectClassMapping refClassMap)
           
protected  String getAssocLdapAttr(Association assoc, boolean targetDefinedAssoc)
           
protected  String getAssocObjectClass(Association assoc, boolean targetDefinedAssoc)
           
 AttributeStyleOpProcessor getAttrProc()
           
 MetaConnector getMetaConnector()
           
 DataModel getMetaData()
          Needed to get around spelling error of geMetaData() in JCS 1.0 release, ideally would be left abstract here and should be overridden in the concrete processor, for instance SDKAttributeStyleOpProcessor.
 void removeAttrAssocs(ObjectInfo objInfo, Association assoc, Attribute attr, Object opContext)
          Simply calls updateAttrAssocs(ObjectInfo, int, Association, Attribute).
 void updateAttrAssocs(ObjectInfo objInfo, int modOp, Association assoc, Attribute attr)
          Handle updating the reverse associative membership list based on changes to the target object referred to by objInfo, eg when changing account.memberOf the membership lists of the referenced groups are what actually needs to be updated.
 
Methods inherited from class com.ca.jcs.processor.AbstractAttributeStyleOpProcessorAssocDirect
activate, convertConnectorDNToKey, convertConnectorDNToKeys, convertKeyToConnectorDN
 
Methods inherited from class com.ca.jcs.processor.AbstractAttributeStyleOpProcessor
deactivate, isPostQueryPocessingActive, processPostQueryAttributes, processPostQuerySearchResult, setPostQueryPocessingActive
 
Methods inherited from class com.ca.jcs.processor.AbstractBaseProcessor
getBaseConnector, makeNamingException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ca.jcs.processor.AttributeStyleOpProcessor
deactivate, setMetaData
 
Methods inherited from interface com.ca.jcs.processor.OpProcessor
doAdd, doDelete, doLookUp, doModify, doModifyRn, doMove, doSearch
 

Field Detail

metaConnector

public final MetaConnector metaConnector
Constructor Detail

DefaultAssocDirectAttributeOpProcessor

public DefaultAssocDirectAttributeOpProcessor(MetaConnector connector)
Hang on to some important contextual values.

Parameters:
connector - Parent baseConnector.
Method Detail

getAttrProc

public AttributeStyleOpProcessor getAttrProc()

getMetaConnector

public MetaConnector getMetaConnector()

getMetaData

public DataModel getMetaData()
Needed to get around spelling error of geMetaData() in JCS 1.0 release, ideally would be left abstract here and should be overridden in the concrete processor, for instance SDKAttributeStyleOpProcessor. Always throws a RuntimeException to ensure the fact it must be overridden is noticed if the method is ever called.

Returns:
Metadata used to configure this processor.

doLookupExpensiveStub

public Attribute doLookupExpensiveStub(ObjectInfo objInfo,
                                       String attrId)
                                throws NamingException
Default implementation is to simply do a lookup but derived classes may be able to efficiently find out if the attribute is set or not.

Specified by:
doLookupExpensiveStub in interface AttributeStyleOpProcessor
Overrides:
doLookupExpensiveStub in class AbstractAttributeStyleOpProcessor
Parameters:
objInfo - Object for which attribute should be looked up.
attrId - Id for expensive attribute.
Returns:
Possibly less expensive placeholder for expensive attribute, if its possible to avoid looking it up fully.
Throws:
NamingException
See Also:
ValidationLazyAttributesProxy

doAssocUpdateReferencesTo

@OpBindingMethod(operation=ASSOC_UPDATE_REFERENCES_TO)
public void doAssocUpdateReferencesTo(ObjectInfo targetObjInfo,
                                                                                         Name newConnDn,
                                                                                         MetaConnector connector)
                               throws NamingException
Handle updating all reverse associative pointers referring to the target object referred to by targetObjInfo (whether single or multi-valued), with its new DN. For instance when changing a person's DN the "member" attributes of all groups referencing it need to be updated to refer to the new DN. Note where the reverse membership attribute has ambiguous mappings to two or more connector attribute ids, the method MetaConnector.getAssocReverseConnectorAttrId(com.ca.jcs.ObjectInfo, com.ca.jcs.assoc.Association) will be used to determine the correct choice (as happens for groups in the LDA connector).

Note that updates are only applied to non-virtual attributes actually persisted in the managed system, and are done using REPLACE_ATTRIBUTE to avoid the case where changing a single-valued attribute from one DN to another using deltas would temporarily lead to no values or two values being stored. This doesn't represent a violation of any "forceModificationMode" specified for an attribute, because we are effectively writing directly to managed system.

Parameters:
targetObjInfo - References target object whose DN is being changed.
newConnDn - New connector-speak DN for the target object, null if target object is being deleted.
Throws:
NamingException

doAssocSearchForReferencesTo

@OpBindingMethod(operation=ASSOC_SEARCH_FOR_REFERENCES_TO)
public NamingEnumeration<SearchResult> doAssocSearchForReferencesTo(ObjectInfo targetObjInfo,
                                                                                                                           Association assoc,
                                                                                                                           boolean targetDefinedAssoc,
                                                                                                                           MetaConnector connector)
                                                             throws NamingException
Given a targetInfo object and association, returns search result (in connector-speak) for each instance of assoc's class which references the targetInfo object.

Parameters:
targetObjInfo - The referenced object representing an association which is to be searched for, may either be a DN or a simple string value depending on metadata used to define the attribute in which it is contained.
assoc - Describes association between attribute on targetInfo object and optional reciprocal attribute stored on referencing objects
targetDefinedAssoc - True if targetInfo's objectClass defined the association, and false if it was defined by the referencing object class.
Returns:
Enumeration containing DNs of referencing objects (+ objectclass and current attribute values, or null if none are found.
Throws:
NamingException

expandTemplateValues

public String expandTemplateValues(String nameTemplate,
                                   String dn)
Expand template value using a DN/RDN or a string

Parameters:
nameTemplate - Template to expand
dn - DN/RDN or a string to use in the expansion
Returns:
expanded value

doModifyAssocs

@OpBindingMethod(operation=MODIFY_ASSOCS)
public void doModifyAssocs(ObjectInfo objInfo,
                                                                 AssocModificationItem[] items,
                                                                 Object opContext)
                    throws NamingException
Break down provided association modification into addAttrAssocs(com.ca.jcs.ObjectInfo, com.ca.jcs.assoc.Association, javax.naming.directory.Attribute, java.lang.Object) or removeAttrAssocs(com.ca.jcs.ObjectInfo, com.ca.jcs.assoc.Association, javax.naming.directory.Attribute, java.lang.Object) calls as appropriate.

Parameters:
objInfo - Information about target object whose associations are to be updated.
items - Modifications to associative relationships, which can be additions, deletions or replacements.
opContext - Optional field which can be provided additional context for the requested updates, eg transactional connectors may want the updates of the associative relationships to occur within a larger transaction.
Throws:
NamingException

doModifyRnAssocs

@OpBindingMethod(operation=MODIFY_RN_ASSOCS)
public void doModifyRnAssocs(ObjectInfo objInfo,
                                                                      Rdn newRdn,
                                                                      Object opContext)
                      throws NamingException
Update association attributes after the target object denoted by objInfo (which still refers to the old name) is renamed.

Parameters:
objInfo - Object to be modified, contains "old" name.
newRdn - New relative name (RN) for object, eg "namingAttr=newName".
opContext - Optional field which can be provided additional context for the requested updates, eg transactional connectors
Throws:
NamingException

doMoveAssocs

@OpBindingMethod(operation=MOVE_ASSOCS)
public void doMoveAssocs(ObjectInfo objInfo,
                                                             Name newName,
                                                             Object opContext)
                  throws NamingException
Update association attributes after the target object denoted by objInfo (which still refers to the old name) is moved to newName.

Parameters:
objInfo - Object to be modified, contains "old" name.
newName - New DN (distinguished name) for object, where parent folder and RN may have changed.
opContext - Optional field which can be provided additional context for the requested updates, eg transactional connectors may want the updates of the associative relationships to occur within a larger transaction.
Throws:
NamingException

doDeleteAssocs

@OpBindingMethod(operation=DELETE_ASSOCS)
public void doDeleteAssocs(ObjectInfo targetObjInfo,
                                                                 Object opContext)
                    throws NamingException
Delete all associations referencing target object referred to by objInfo.

Parameters:
targetObjInfo - Object to be deleted.
opContext - Optional field which can be provided additional context for the requested updates, eg transactional connectors may want the updates of the associative relationships to occur within a larger transaction.
Throws:
NamingException

updateAttrAssocs

@OpBindingMethod(operation=MODIFY_UPDATE_ATTRS_ASSOCS)
public void updateAttrAssocs(ObjectInfo objInfo,
                                                                                int modOp,
                                                                                Association assoc,
                                                                                Attribute attr)
                      throws NamingException
Handle updating the reverse associative membership list based on changes to the target object referred to by objInfo, eg when changing account.memberOf the membership lists of the referenced groups are what actually needs to be updated. Note where there reverse membership attribute has ambiguous mappings to two or more connector attribute ids, the method MetaConnector.getAssocReverseConnectorAttrId(com.ca.jcs.ObjectInfo, com.ca.jcs.assoc.Association) will be used to determine the correct choice (as happens for groups in the LDA connector).

Parameters:
objInfo - References target object whose virtual membership attribute is being changed (eg the "person" whose person.memberOf attribute is being modified).
modOp - Modification operation, refer ModificationItem.getModificationOp() }.
assoc - Record of metadata for relevant association.
attr - Virtual membership attribute being modified, containing DNs of intended owners of the target object (eg a list of groupOfNames whose member attributes need to be updated to persist the change to person.memberOf)
Throws:
NamingException

addAttrAssocs

public void addAttrAssocs(ObjectInfo objInfo,
                          Association assoc,
                          Attribute attr,
                          Object context)
                   throws NamingException
Simply calls updateAttrAssocs(ObjectInfo, int, Association, Attribute).

Parameters:
objInfo - Object referenced.
assoc - Association through which object is referenced.
attr - Attribute containing new references to object which are to be stored.
context - Context if relevant to connector implementation (eg transaction, if supported).
Throws:
NamingException

removeAttrAssocs

public void removeAttrAssocs(ObjectInfo objInfo,
                             Association assoc,
                             Attribute attr,
                             Object opContext)
                      throws NamingException
Simply calls updateAttrAssocs(ObjectInfo, int, Association, Attribute).

Parameters:
objInfo - Object referenced.
assoc - Association through which object is referenced.
attr - Attribute containing references to object, if null means "remove all references" (only supported by internal agreement within connector implementation, eg JDBC which uses indirect associations can remove all references without wasting time determining all currently existing links).
opContext - Context if relevant to connector implementation (eg transaction, if supported).
Throws:
NamingException

doLookupAssocs

@OpBindingMethod(operation=LOOKUP_ASSOCS)
public void doLookupAssocs(ObjectInfo objInfo,
                                                                 Association[] associations,
                                                                 Attributes attrs,
                                                                 Object opContext)
                    throws NamingException
Lookup all associations for the target object referred to be objInfo and add them as multi-valued associative attributes to attrs.

Parameters:
objInfo - Target object for which associations need to be worked out.
associations - Associations declared against target's objectclass, all of which need to be checked.
attrs - Attributes to be returned for target object, multi-valued associative attribute settings may be added to them by this method.
opContext - Unused.
Throws:
NamingException

doSearchAssocs

@OpBindingMethod(operation=SEARCH_ASSOCS)
public NamingEnumeration<SearchResult> doSearchAssocs(MetaObjectClassMappings classMapping,
                                                                                            Association[] associations,
                                                                                            NamingEnumeration<SearchResult> searchResults,
                                                                                            String filterExpr,
                                                                                            Object opContext)
                                               throws NamingException
Wrap provided queryNum with logic to provide values for association attributes on search results.

Throws:
NamingException

getAssocDataModelProp

protected DataModelProperty getAssocDataModelProp(String refLdapAttr,
                                                  MetaObjectClassMapping refClassMap)

getAssocLdapAttr

protected String getAssocLdapAttr(Association assoc,
                                  boolean targetDefinedAssoc)

getAssocClassMap

protected MetaObjectClassMapping getAssocClassMap(Association assoc,
                                                  boolean targetDefinedAssoc)

getAssocObjectClass

protected String getAssocObjectClass(Association assoc,
                                     boolean targetDefinedAssoc)

getAssocConnAttrId

protected String getAssocConnAttrId(Association assoc,
                                    boolean targetDefinedAssoc)
Get the single connector speak associative attribute


getAssocConnectorAttrIds

protected String[] getAssocConnectorAttrIds(Association assoc,
                                            boolean targetDefinedAssoc)

getAssocConnAttrIds

protected String[] getAssocConnAttrIds(Association assoc,
                                       String ldapAttrId,
                                       boolean targetDefinedAssoc)


Created 2011-07-14 13:27 EST