com.evolveum.midpoint.provisioning.impl
Class ShadowCache

java.lang.Object
  extended by com.evolveum.midpoint.provisioning.impl.ShadowCache

@Component
public class ShadowCache
extends java.lang.Object

This class manages the "cache" of ResourceObjectShadows in the repository. In short, this class takes care of aligning the shadow objects in repository with the real state of the resource. The repository content is considered a "cache" when it comes to Shadow objects. That's why they are called "shadow" objects after all. When a new state (values) of the resource object is detected, the shadow in the repository should be updated. No matter if that was detected by synchronization, reconciliation or an ordinary get from resource. This class is supposed to do that. Therefore all operations that deal with "shadows" should pass through this class. It forms yet another layer of the provisioning subsystem. Current implementation assumes we are only storing primary identifier in the repository. That should be made configurable later. It also only support Account objects now.

Author:
Radovan Semancik

Constructor Summary
ShadowCache()
           
 
Method Summary
 java.lang.String addShadow(ResourceObjectShadowType shadow, ScriptsType scripts, ResourceType resource, OperationResult parentResult)
           
 ResourceObjectShadowType assembleShadow(ResourceObject resourceObject, ResourceObjectShadowType repositoryShadow, OperationResult parentResult)
          Creates a shadow object from the supplied resource object.
 ResourceType completeResource(ResourceType resource, Schema resourceSchema, OperationResult result)
          Make sure that the resource is complete.
 void deleteShadow(ObjectType objectType, ScriptsType scripts, ResourceType resource, OperationResult parentResult)
           
 java.util.List<Change> fetchChanges(ResourceType resourceType, Property lastToken, OperationResult parentResult)
           
 Property fetchCurrentToken(ResourceType resourceType, OperationResult parentResult)
           
 RepositoryService getRepositoryService()
          Get the value of repositoryService.
 ResourceObjectShadowType getShadow(java.lang.String oid, ResourceObjectShadowType repositoryShadow, OperationResult parentResult)
          Gets the shadow with specified OID The shadow will be read from the repository and missing information will be fetched from the resource.
 void listShadows(ResourceType resource, javax.xml.namespace.QName objectClass, ShadowHandler handler, boolean readFromRepository, OperationResult parentResult)
          List all shadow objects of specified objectClass.
 void modifyShadow(ObjectType objectType, ResourceType resource, ObjectModificationType objectChange, ScriptsType scripts, OperationResult parentResult)
           
 void searchObjectsIterative(javax.xml.namespace.QName objectClass, ResourceType resourceType, ShadowHandler handler, DiscoveryHandler discoveryHandler, OperationResult parentResult)
           
 void setRepositoryService(RepositoryService repositoryService)
          Set the value of repositoryService Expected to be injected.
 void testConnection(ResourceType resourceType, OperationResult parentResult)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShadowCache

public ShadowCache()
Method Detail

getRepositoryService

public RepositoryService getRepositoryService()
Get the value of repositoryService.

Returns:
the value of repositoryService

setRepositoryService

public void setRepositoryService(RepositoryService repositoryService)
Set the value of repositoryService Expected to be injected.

Parameters:
repositoryService - new value of repositoryService

getShadow

public ResourceObjectShadowType getShadow(java.lang.String oid,
                                          ResourceObjectShadowType repositoryShadow,
                                          OperationResult parentResult)
                                   throws ObjectNotFoundException,
                                          CommunicationException,
                                          SchemaException
Gets the shadow with specified OID The shadow will be read from the repository and missing information will be fetched from the resource. If no repositoryShadow is specified, the shadow will be retrieved from the repository. This is just an optimization if the object was already fetched (which is a usual case). This method is using identification by OID. This is intended for normal usage. Method that uses native identification will be provided later.

Parameters:
oid - OID of shadow to get.
repositoryShadow - shadow that was read from the repository
Returns:
retrieved shadow (merged attributes from repository and resource)
Throws:
ObjectNotFoundException - shadow was not found or object was not found on the resource
CommunicationException - problem communicating with the resource
SchemaException - problem processing schema or schema violation

assembleShadow

public ResourceObjectShadowType assembleShadow(ResourceObject resourceObject,
                                               ResourceObjectShadowType repositoryShadow,
                                               OperationResult parentResult)
                                        throws SchemaException
Creates a shadow object from the supplied resource object. If an optional resourceObject is specified, it will be used as a base for creating the shadow. In this case the same instance is returned, but it is enriched with attributes from the resource object.

Parameters:
resourceObject -
repositoryShadow -
Returns:
Throws:
SchemaException

listShadows

public void listShadows(ResourceType resource,
                        javax.xml.namespace.QName objectClass,
                        ShadowHandler handler,
                        boolean readFromRepository,
                        OperationResult parentResult)
                 throws CommunicationException,
                        ObjectNotFoundException,
                        SchemaException
List all shadow objects of specified objectClass. Not used now. Will be used in import. Only provided for demonstration how to map ResourceObject to shadow.

Parameters:
resource -
objectClass -
handler -
parentResult -
Throws:
CommunicationException
ObjectNotFoundException - the connector object was not found
SchemaException

addShadow

public java.lang.String addShadow(ResourceObjectShadowType shadow,
                                  ScriptsType scripts,
                                  ResourceType resource,
                                  OperationResult parentResult)
                           throws CommunicationException,
                                  GenericFrameworkException,
                                  ObjectAlreadyExistsException,
                                  SchemaException,
                                  ObjectNotFoundException
Throws:
CommunicationException
GenericFrameworkException
ObjectAlreadyExistsException
SchemaException
ObjectNotFoundException

deleteShadow

public void deleteShadow(ObjectType objectType,
                         ScriptsType scripts,
                         ResourceType resource,
                         OperationResult parentResult)
                  throws CommunicationException,
                         GenericFrameworkException,
                         ObjectNotFoundException,
                         SchemaException
Throws:
CommunicationException
GenericFrameworkException
ObjectNotFoundException
SchemaException

modifyShadow

public void modifyShadow(ObjectType objectType,
                         ResourceType resource,
                         ObjectModificationType objectChange,
                         ScriptsType scripts,
                         OperationResult parentResult)
                  throws CommunicationException,
                         GenericFrameworkException,
                         ObjectNotFoundException,
                         SchemaException
Throws:
CommunicationException
GenericFrameworkException
ObjectNotFoundException
SchemaException

testConnection

public void testConnection(ResourceType resourceType,
                           OperationResult parentResult)

searchObjectsIterative

public void searchObjectsIterative(javax.xml.namespace.QName objectClass,
                                   ResourceType resourceType,
                                   ShadowHandler handler,
                                   DiscoveryHandler discoveryHandler,
                                   OperationResult parentResult)
                            throws ObjectNotFoundException,
                                   CommunicationException,
                                   SchemaException
Throws:
ObjectNotFoundException
CommunicationException
SchemaException

fetchCurrentToken

public Property fetchCurrentToken(ResourceType resourceType,
                                  OperationResult parentResult)
                           throws ObjectNotFoundException,
                                  CommunicationException,
                                  SchemaException
Throws:
ObjectNotFoundException
CommunicationException
SchemaException

fetchChanges

public java.util.List<Change> fetchChanges(ResourceType resourceType,
                                           Property lastToken,
                                           OperationResult parentResult)
                                    throws ObjectNotFoundException,
                                           CommunicationException,
                                           GenericFrameworkException,
                                           SchemaException
Throws:
ObjectNotFoundException
CommunicationException
GenericFrameworkException
SchemaException

completeResource

public ResourceType completeResource(ResourceType resource,
                                     Schema resourceSchema,
                                     OperationResult result)
                              throws ObjectNotFoundException,
                                     SchemaException,
                                     CommunicationException
Make sure that the resource is complete. It will check if the resource has a sufficiently fresh schema, etc. Returned resource may be the same or may be a different instance, but it is guaranteed that it will be "fresher" and will correspond to the repository state (assuming that the provided resource also corresponded to the repository state). The connector schema that was fetched before can be supplied to this method. This is just an optimization. It comes handy e.g. in test connection case. Note: This is not really the best place for this method. Need to figure out correct place later.

Parameters:
resource - Resource to check
resourceSchema - schema that was freshly pre-fetched (or null)
result -
Returns:
completed resource
Throws:
ObjectNotFoundException - connector instance was not found
SchemaException
CommunicationException - cannot fetch resource schema


Copyright © 2011 evolveum. All Rights Reserved.