com.ca.jcs.jndi
Class JNDIAttributeStyleOpProcessor

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
                  extended by com.ca.jcs.assoc.NestedAssocDirectAttributeOpProcessor
                      extended by com.ca.jcs.jndi.JNDIAttributeStyleOpProcessor
All Implemented Interfaces:
Activatable, AssocAttributeOpProcessor, AssocDirectAttributeOpProcessor, AttributeStyleOpProcessor, OpProcessor, PostQueryAttributesProcessor

public class JNDIAttributeStyleOpProcessor
extends NestedAssocDirectAttributeOpProcessor

Handles actual delegation of JNDI operations to remote managed system, attribute name mapping and any other registered conversions have been applied. Special mention should be made of the fact that, as this class uses the JNDI API, search results will have CompositeNames returned which (see rules it defines for escaping) will in all likelihood will mean that names containing \s will have more of them then you'd expect. This is also why it is critical this class makes use of javax.naming.Name objects like LdapDN instead of strings when making calls via JNDI too.

Note we use the less-strict BasicAttributes instead of ApacheDS LockableAttributesImpl in order to handle the case where column names (which may include multi-byte characters) are used as attribute ids when passing in-memory query data back to MetaConnector before it is converted from connector-speak to LDAP.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.ca.jcs.assoc.NestedAssocDirectAttributeOpProcessor
NestedAssocDirectAttributeOpProcessor.AssocNestedInfo
 
Nested classes/interfaces inherited from class com.ca.jcs.assoc.DefaultAssocDirectAttributeOpProcessor
DefaultAssocDirectAttributeOpProcessor.AssocAttrValue, DefaultAssocDirectAttributeOpProcessor.AssociationStyle
 
Nested classes/interfaces inherited from interface com.ca.jcs.processor.OpProcessor
OpProcessor.MethodName
 
Field Summary
protected  JNDIMetaConnector connector
           
 
Fields inherited from class com.ca.jcs.assoc.DefaultAssocDirectAttributeOpProcessor
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
 
Constructor Summary
JNDIAttributeStyleOpProcessor(JNDIMetaConnector connector)
           
 
Method Summary
 void activate()
          Sets proxiedSelf to OpBindings-aware proxy if any OpBindings are configured, otherwise left assigned to "this".
 void doAdd(ObjectInfo objInfo, Attributes attrs)
          Create a new object on the managed system with the provided attributes stored for it.
 void doDelete(ObjectInfo objInfo)
          Delete the object referenced by objInfo from a managed system.
protected  Attributes doLookUp(ObjectInfo objInfo, boolean useUpName, String[] attrIds)
           
 Attributes doLookUp(ObjectInfo objInfo, String[] attrIds)
          Look up the provided attribute names on the managed object referenced by objInfo, attribute ids not mapped to connector-speak will either be discarded or cause an error depending on the level of strictness configured for the parent connector.
 NestedAssocDirectAttributeOpProcessor.AssocNestedInfo doLookupNestedAssociations(Association assoc, boolean targetDefinedAssoc)
          Find all information about nested associations for this connector.
 void doModify(ObjectInfo objInfo, ModificationItem[] modItems)
          Apply the provided items to the object on the managed system referenced by objInfo.
 void doModifyRn(ObjectInfo objInfo, Rdn newRn)
          Rename the managed object referenced by objInfo so that it has the new Relative Distinguished Name (RDN) provided (an example newRdn might be nameAttrId=MyNewName).
 void doMove(ObjectInfo objInfo, Name newParentName, Rdn newRdn)
          Move the managed object referenced by objInfo to a new parent whilst also changing its RDN (of form "attr=value").
 NamingEnumeration<SearchResult> doSearch(ObjectInfo baseObjInfo, FilterInfo filterInfo, Map<String,String> environment, SearchControls searchControls)
          Perform search under specified baseName on managed system, using the standard JNDI interfaces and semantics.
 JNDIMetaConnector getConnector()
           
 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.
protected  NamingException handleException(Context connection, String dn, String op, Exception e)
           
 void setMetaData(DataModel dataModel)
          Called when datamodel metadata used to configure this connector is changed.
 
Methods inherited from class com.ca.jcs.assoc.NestedAssocDirectAttributeOpProcessor
doAssocAddNestedReferences, doAssocAddNestedReferences, doLookupAssocs
 
Methods inherited from class com.ca.jcs.assoc.DefaultAssocDirectAttributeOpProcessor
addAttrAssocs, doAssocSearchForReferencesTo, doAssocUpdateReferencesTo, doDeleteAssocs, doLookupExpensiveStub, doModifyAssocs, doModifyRnAssocs, doMoveAssocs, doSearchAssocs, expandTemplateValues, getAssocClassMap, getAssocConnAttrId, getAssocConnAttrIds, getAssocConnectorAttrIds, getAssocDataModelProp, getAssocLdapAttr, getAssocObjectClass, getAttrProc, getMetaConnector, removeAttrAssocs, updateAttrAssocs
 
Methods inherited from class com.ca.jcs.processor.AbstractAttributeStyleOpProcessorAssocDirect
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
 

Field Detail

connector

protected final JNDIMetaConnector connector
Constructor Detail

JNDIAttributeStyleOpProcessor

public JNDIAttributeStyleOpProcessor(JNDIMetaConnector connector)
Method Detail

activate

public void activate()
              throws NamingException
Description copied from class: AbstractAttributeStyleOpProcessor
Sets proxiedSelf to OpBindings-aware proxy if any OpBindings are configured, otherwise left assigned to "this".

Specified by:
activate in interface Activatable
Specified by:
activate in interface AttributeStyleOpProcessor
Overrides:
activate in class AbstractAttributeStyleOpProcessorAssocDirect
Throws:
NamingException

getConnector

public JNDIMetaConnector getConnector()

getMetaData

public DataModel getMetaData()
Description copied from class: DefaultAssocDirectAttributeOpProcessor
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.

Specified by:
getMetaData in interface AttributeStyleOpProcessor
Overrides:
getMetaData in class DefaultAssocDirectAttributeOpProcessor
Returns:
Metadata used to configure this processor.

setMetaData

public void setMetaData(DataModel dataModel)
Description copied from interface: AttributeStyleOpProcessor
Called when datamodel metadata used to configure this connector is changed.

Parameters:
dataModel - New metadata to be internalised.

handleException

protected NamingException handleException(Context connection,
                                          String dn,
                                          String op,
                                          Exception e)

doDelete

public void doDelete(ObjectInfo objInfo)
              throws NamingException
Description copied from interface: OpProcessor
Delete the object referenced by objInfo from a managed system. Called by Partition.delete(org.apache.directory.shared.ldap.name.LdapDN) after mapping/validation/type conversion has been performed.

Parameters:
objInfo - References managed object to be deleted.
Throws:
LdapNameNotFoundException - (or NameNotFoundException) when target object doesn't exist.
NamingException - (usually exception should implement LdapException or arrangements to map it into such an exception should be in place). Pay attention to retriable exceptions as documented in RetryOpProcessorProxy.

doAdd

public void doAdd(ObjectInfo objInfo,
                  Attributes attrs)
           throws NamingException
Description copied from interface: OpProcessor
Create a new object on the managed system with the provided attributes stored for it. Called by Partition.add(org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes) after mapping has been performed.

Parameters:
objInfo - Contains information for the managed object which is to be created, where its connector-speak distinguished Name (DN) is dictated by objInfo.getConnectorDn() and its objectClass= is dictated by objInfo.getobjectClassMapping().
attrs - Attributes to be stored on the managed object.
Throws:
LdapNameAlreadyBoundException - Should be thrown if an object with the specified name already exists, other NamingExceptions (preferably implementing LdapException) may also be thrown. Pay attention to retriable exceptions as documented in RetryOpProcessorProxy.
NamingException - (usually exception should implement LdapException or arrangements to map it into such an exception should be in place). Pay attention to retriable exceptions as documented in RetryOpProcessorProxy.

doModify

public void doModify(ObjectInfo objInfo,
                     ModificationItem[] modItems)
              throws NamingException
Description copied from interface: OpProcessor
Apply the provided items to the object on the managed system referenced by objInfo. Called by Partition.modify(org.apache.directory.shared.ldap.name.LdapDN, int, javax.naming.directory.Attributes) after mapping has been performed.

Parameters:
objInfo - References managed object which is to be modified.
modItems - Items to be modified.
Throws:
LdapNameNotFoundException - (or NameNotFoundException) when target object doesn't exist.
NamingException - (usually exception should implement LdapException or arrangements to map it into such an exception should be in place). Pay attention to retriable exceptions as documented in RetryOpProcessorProxy.

doSearch

public NamingEnumeration<SearchResult> doSearch(ObjectInfo baseObjInfo,
                                                FilterInfo filterInfo,
                                                Map<String,String> environment,
                                                SearchControls searchControls)
                                         throws NamingException
Description copied from interface: OpProcessor
Perform search under specified baseName on managed system, using the standard JNDI interfaces and semantics. All values (DN/filter/return attribute ids) have been mapped into connector-speak by the time this method is called. Called by Partition.search(org.apache.directory.shared.ldap.name.LdapDN, java.util.Map, org.apache.directory.shared.ldap.filter.ExprNode, javax.naming.directory.SearchControls) with mapping performed on the result entries to map/convert them from connector-speak to LDAP.

Parameters:
baseObjInfo - Specifies base object for the search, scope in searchControls is relative to this object.
filterInfo - Information regarding the filter to be used for the search, including referenced objectClass= values. Note that attribute names have been converted to connector-speak and any required validators/converters have been run by the framework prior to this method being invoked. The filter's text can be retrieved via ExprNode.printToBuffer(StringBuffer) on contained mappedFilter. If required this mappedFilter can be converted to a different syntax, refer to SimpleFilterVisitor / FilterVisitor and related classes.
environment - Defines any values effecting how the search is performed (eg whether to follow referrals etc). Can usually be ignored.
searchControls - Defines important information about the search itself, for instance what scope the search should have under baseName and which attributes should be returned for each object matching the provided filter. Note that specifying a null String[] for the returned attributes will cause all non-expensive attributes to be returned for each matching objects, whereas specifying String[0] will cause not attributes to be returned except for the DNs of matching objects.
Returns:
Enumeration of SearchResult objects, one per object falling within the specified scope under baseName which matches the provided filter. Results can be handled in two different manners depending on the connector's requirement (indeed, an advanced connector can implement both and choose the best one based on heuristics and a threshold):
  1. Pass back results "all at once" (faster, but impractical for very large numbers of matching objects) or
  2. "stream" results back one at a time by wrapping in a NamingEnumeration that actually extracts results after this doSearch() call has returned.
Throws:
LdapNameNotFoundException - (or NameNotFoundException) when target object doesn't exist.
NamingException - (usually exception should implement LdapException or arrangements to map it into such an exception should be in place). Pay attention to retriable exceptions as documented in RetryOpProcessorProxy.

doLookUp

protected Attributes doLookUp(ObjectInfo objInfo,
                              boolean useUpName,
                              String[] attrIds)
                       throws NamingException,
                              LdapNameNotFoundException
Throws:
NamingException
LdapNameNotFoundException

doLookUp

public Attributes doLookUp(ObjectInfo objInfo,
                           String[] attrIds)
                    throws NamingException,
                           LdapNameNotFoundException
Description copied from interface: OpProcessor
Look up the provided attribute names on the managed object referenced by objInfo, attribute ids not mapped to connector-speak will either be discarded or cause an error depending on the level of strictness configured for the parent connector. Extra attributes may also be returned. Called by Partition.lookup(org.apache.directory.shared.ldap.name.LdapDN) after mapping has been performed.

Parameters:
objInfo - Managed object for which attributes are to be looked up.
attrIds - Connector-speak identifiers of attributes which are to be returned, null means return all attributes and a zero length array means return no attributes (just a way to check an object's existance).
Returns:
Attributes values on specified managed object, where connector-speak mappings exist for specified attrIds, can be null when the target object exists but has none of the requested
Throws:
LdapNameNotFoundException - (or NameNotFoundException) when target object doesn't exist.
NamingException - (usually exception should implement LdapException or arrangements to map it into such an exception should be in place). Pay attention to retriable exceptions as documented in RetryOpProcessorProxy.

doModifyRn

public void doModifyRn(ObjectInfo objInfo,
                       Rdn newRn)
                throws NamingException
Description copied from interface: OpProcessor
Rename the managed object referenced by objInfo so that it has the new Relative Distinguished Name (RDN) provided (an example newRdn might be nameAttrId=MyNewName). Called by Partition.modifyRn(org.apache.directory.shared.ldap.name.LdapDN, java.lang.String, boolean) after mapping has been performed.

Parameters:
objInfo - References managed object.
newRn - New terminal name (having form "attr=val") for managed object.
Throws:
LdapNameNotFoundException - (or NameNotFoundException) when target object doesn't exist.
NamingException - (usually exception should implement LdapException or arrangements to map it into such an exception should be in place). Pay attention to retriable exceptions as documented in RetryOpProcessorProxy.

doMove

public void doMove(ObjectInfo objInfo,
                   Name newParentName,
                   Rdn newRdn)
            throws NamingException
Description copied from interface: OpProcessor
Move the managed object referenced by objInfo to a new parent whilst also changing its RDN (of form "attr=value"). Called by Partition.move(org.apache.directory.shared.ldap.name.LdapDN, org.apache.directory.shared.ldap.name.LdapDN, String, boolean) after mapping has been performed.

Parameters:
objInfo - References managed object to be moved.
newParentName - New parent for managed object.
newRdn - New relative distinguished name (RDN) for managed object, will be either be null (just a move) or different from the object's current RDN (move and rename).
Throws:
LdapNameNotFoundException - (or NameNotFoundException) when target object doesn't exist.
NamingException - (usually exception should implement LdapException or arrangements to map it into such an exception should be in place). Pay attention to retriable exceptions as documented in RetryOpProcessorProxy.

doLookupNestedAssociations

public NestedAssocDirectAttributeOpProcessor.AssocNestedInfo doLookupNestedAssociations(Association assoc,
                                                                                        boolean targetDefinedAssoc)
                                                                                 throws LdapNamingException,
                                                                                        NamingException
Find all information about nested associations for this connector. JNDI supports nested NIS netgroup associations. Build NIS netgroup nested association information representing 'snapshot' of the nisNetgroup nesting on the endpoint at the time of call. This is done in multiple passes: - LDAP search for (oc=nisNetgroup) returning memberNisNetgroup attribute - Parse returned results to calculate direct membership nisNetgroup information - Process each netgroup and calculate nested membership information.

Overrides:
doLookupNestedAssociations in class NestedAssocDirectAttributeOpProcessor
Parameters:
assoc - Association details
Returns:
AssocNestedInfo instance containing nested association information on the endpoint as well as information about nisNetgroup->DN conversion.
Throws:
LdapNamingException
NamingException


Created 2011-07-14 13:27 EST