com.evolveum.midpoint.repo.sql
Class SqlRepositoryServiceImpl

java.lang.Object
  extended by com.evolveum.midpoint.repo.sql.SqlBaseService
      extended by com.evolveum.midpoint.repo.sql.SqlRepositoryServiceImpl
All Implemented Interfaces:
RepositoryService

@Repository
public class SqlRepositoryServiceImpl
extends SqlBaseService
implements RepositoryService

Author:
lazyman

Field Summary
 
Fields inherited from interface com.evolveum.midpoint.repo.api.RepositoryService
ADD_OBJECT, CLAIM_TASK, CLASS_NAME_WITH_DOT, COUNT_OBJECTS, DELETE_OBJECT, GET_OBJECT, LIST_ACCOUNT_SHADOW, LIST_OBJECTS, LIST_RESOURCE_OBJECT_SHADOWS, MODIFY_OBJECT, RELEASE_TASK, SEARCH_OBJECTS
 
Constructor Summary
SqlRepositoryServiceImpl(SqlRepositoryFactory repositoryFactory)
           
 
Method Summary
<T extends ObjectType>
String
addObject(PrismObject<T> object, OperationResult result)
          Add new object.
<T extends ObjectType>
int
countObjects(Class<T> type, ObjectQuery query, OperationResult result)
           
<T extends ObjectType>
void
deleteObject(Class<T> type, String oid, OperationResult result)
          Deletes object with specified OID.
<T extends ObjectType>
PrismObject<T>
getObject(Class<T> type, String oid, OperationResult result)
          Returns object for provided OID.
 RepositoryDiag getRepositoryDiag()
          Provide repository run-time configuration and diagnostic information.
 PrismObject<UserType> listAccountShadowOwner(String accountOid, OperationResult result)
          Returns the User object representing owner of specified account (account shadow).
<T extends ResourceObjectShadowType>
List<PrismObject<T>>
listResourceObjectShadows(String resourceOid, Class<T> resourceObjectShadowType, OperationResult result)
          Search for resource object shadows of a specified type that belong to the specified resource.
<T extends ObjectType>
void
modifyObject(Class<T> type, String oid, Collection<? extends ItemDelta> modifications, OperationResult result)
          Modifies object using relative change description.
 void repositorySelfTest(OperationResult parentResult)
          Runs a short, non-descructive repository self test.
<T extends ObjectType>
List<PrismObject<T>>
searchObjects(Class<T> type, ObjectQuery query, OperationResult result)
          Search for objects in the repository.
 
Methods inherited from class com.evolveum.midpoint.repo.sql.SqlBaseService
beginTransaction, beginTransaction, cleanupSessionAndResult, getPrismContext, getSessionFactory, handleGeneralCheckedException, handleGeneralRuntimeException, logOperationAttempt, rollbackTransaction, rollbackTransaction, rollbackTransaction, setPrismContext, setSessionFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlRepositoryServiceImpl

public SqlRepositoryServiceImpl(SqlRepositoryFactory repositoryFactory)
Method Detail

getObject

public <T extends ObjectType> PrismObject<T> getObject(Class<T> type,
                                                       String oid,
                                                       OperationResult result)
                                            throws ObjectNotFoundException,
                                                   SchemaException
Description copied from interface: RepositoryService
Returns object for provided OID. Must fail if object with the OID does not exists.

Specified by:
getObject in interface RepositoryService
oid - OID of the object to get
result - parent OperationResult (in/out)
Returns:
Object fetched from repository
Throws:
ObjectNotFoundException - requested object does not exist
SchemaException - error dealing with storage schema

listAccountShadowOwner

public PrismObject<UserType> listAccountShadowOwner(String accountOid,
                                                    OperationResult result)
                                             throws ObjectNotFoundException
Description copied from interface: RepositoryService

Returns the User object representing owner of specified account (account shadow).

May return null if there is no owner specified for the account.

May only be called with OID of AccountShadow object.

Implements the backward "owns" association between account shadow and user. Forward association is implemented by property "account" of user object.

This is a "list" operation even though it may return at most one owner. However the operation implies searching the repository for an owner, which may be less efficient that following a direct association. Hence it is called "list" to indicate that there may be non-negligible overhead.

Specified by:
listAccountShadowOwner in interface RepositoryService
Parameters:
accountOid - OID of account shadow
result - parentResult parent OperationResult (in/out)
Returns:
User object representing owner of specified account
Throws:
ObjectNotFoundException - specified object does not exist

addObject

public <T extends ObjectType> String addObject(PrismObject<T> object,
                                               OperationResult result)
                 throws ObjectAlreadyExistsException,
                        SchemaException
Description copied from interface: RepositoryService

Add new object.

The OID provided in the input message may be empty. In that case the OID will be assigned by the implementation of this method and it will be provided as return value.

This operation should fail if such object already exists (if object with the provided OID already exists).

The operation may fail if provided OID is in an unusable format for the storage. Generating own OIDs and providing them to this method is not recommended for normal operation.

Should be atomic. Should not allow creation of two objects with the same OID (even if created in parallel).

The operation may fail if the object to be created does not conform to the underlying schema of the storage system or the schema enforced by the implementation.

Note: no need for explicit type parameter here. The object parameter contains the information.

Specified by:
addObject in interface RepositoryService
Parameters:
object - object to create
result - parent OperationResult (in/out)
Returns:
OID assigned to the created object
Throws:
ObjectAlreadyExistsException - object with specified identifiers already exists, cannot add
SchemaException - error dealing with storage schema, e.g. schema violation

deleteObject

public <T extends ObjectType> void deleteObject(Class<T> type,
                                                String oid,
                                                OperationResult result)
                  throws ObjectNotFoundException
Description copied from interface: RepositoryService

Deletes object with specified OID.

Must fail if object with specified OID does not exists. Should be atomic.

Specified by:
deleteObject in interface RepositoryService
oid - OID of object to delete
result - parent OperationResult (in/out)
Throws:
ObjectNotFoundException - specified object does not exist

countObjects

public <T extends ObjectType> int countObjects(Class<T> type,
                                               ObjectQuery query,
                                               OperationResult result)
Specified by:
countObjects in interface RepositoryService

searchObjects

public <T extends ObjectType> List<PrismObject<T>> searchObjects(Class<T> type,
                                                                 ObjectQuery query,
                                                                 OperationResult result)
                                                      throws SchemaException
Description copied from interface: RepositoryService

Search for objects in the repository.

If no search criteria specified, list objects of specified type is returned.

Searches through all object types. Returns a list of objects that match search criteria.

Returns empty list if object type is correct but there are no objects of that type. The ordering of the results is not significant and may be arbitrary unless sorting in the paging is used.

Should fail if object type is wrong. Should fail if unknown property is specified in the query.

Specified by:
searchObjects in interface RepositoryService
query - search query
result - parent OperationResult (in/out)
Returns:
all objects of specified type that match search criteria (subject to paging)
Throws:
SchemaException - unknown property used in search query

modifyObject

public <T extends ObjectType> void modifyObject(Class<T> type,
                                                String oid,
                                                Collection<? extends ItemDelta> modifications,
                                                OperationResult result)
                  throws ObjectNotFoundException,
                         SchemaException,
                         ObjectAlreadyExistsException
Description copied from interface: RepositoryService

Modifies object using relative change description.

Must fail if user with provided OID does not exists. Must fail if any of the described changes cannot be applied. Should be atomic.

If two or more modify operations are executed in parallel, the operations should be merged. In case that the operations are in conflict (e.g. one operation adding a value and the other removing the same value), the result is not deterministic.

The operation may fail if the modified object does not conform to the underlying schema of the storage system or the schema enforced by the implementation.

TODO: optimistic locking

Specified by:
modifyObject in interface RepositoryService
result - parent OperationResult (in/out)
Throws:
ObjectNotFoundException - specified object does not exist
SchemaException - resulting object would violate the schema
ObjectAlreadyExistsException - if resulting object would have name which already exists in another object of the same type

listResourceObjectShadows

public <T extends ResourceObjectShadowType> List<PrismObject<T>> listResourceObjectShadows(String resourceOid,
                                                                                           Class<T> resourceObjectShadowType,
                                                                                           OperationResult result)
                                                                                throws ObjectNotFoundException
Description copied from interface: RepositoryService

Search for resource object shadows of a specified type that belong to the specified resource.

Returns a list of such object shadows or empty list if nothing was found.

Implements the backward "has" association between resource and resource object shadows. Forward association is implemented by property "resource" of resource object shadow.

May only be called with OID of Resource object.

Specified by:
listResourceObjectShadows in interface RepositoryService
Parameters:
resourceOid - OID of resource definition (ResourceType)
result - parentResult parent OperationResult (in/out)
Returns:
resource object shadows of a specified type from specified resource
Throws:
ObjectNotFoundException - specified object does not exist

getRepositoryDiag

public RepositoryDiag getRepositoryDiag()
Description copied from interface: RepositoryService
Provide repository run-time configuration and diagnostic information.

Specified by:
getRepositoryDiag in interface RepositoryService

repositorySelfTest

public void repositorySelfTest(OperationResult parentResult)
Description copied from interface: RepositoryService
Runs a short, non-descructive repository self test. This methods should never throw a (checked) exception. All the results should be recorded under the provided result structure (including fatal errors). This should implement ONLY self-tests that are IMPLEMENTATION-SPECIFIC. It must not implement self-tests that are generic and applies to all repository implementations. Such self-tests must be implemented in higher layers. If the repository has no self-tests then the method should return immediately without changing the result structure. It must not throw an exception in this case.

Specified by:
repositorySelfTest in interface RepositoryService


Copyright © 2013 evolveum. All Rights Reserved.