You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by da...@apache.org on 2018/04/17 11:00:25 UTC
[08/23] atlas git commit: ATLAS-1775 Enterprise OMRS Connector
Initial Impl 2
http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java
index 544085a..c8d074a 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java
@@ -20,9 +20,9 @@ package org.apache.atlas.omrs.localrepository.repositoryconnector;
import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor;
import org.apache.atlas.omrs.ffdc.*;
import org.apache.atlas.omrs.ffdc.exception.*;
-import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager;
import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefManager;
import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
import org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria;
import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder;
@@ -38,42 +38,48 @@ import java.util.Date;
*/
public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
{
- private static final String repositoryName = "Local Repository";
-
private OMRSMetadataCollection realMetadataCollection;
private String localServerName;
private String localServerType;
private String localOrganizationName;
private OMRSRepositoryEventProcessor outboundRepositoryEventProcessor;
- private OMRSRepositoryContentManager localRepositoryContentManager;
- private OMRSRepositoryValidator repositoryValidator;
- private OMRSRepositoryHelper repositoryHelper;
+ private OMRSTypeDefManager localTypeDefManager;
+
/**
* Constructor used by LocalOMRSRepositoryConnector
*
- * @param localMetadataConnectionId - unique identifier for the local metadata collection.
+ * @param parentConnector - connector that this metadata collection supports. The connector has the information
+ * to call the metadata repository.
+ * @param repositoryName - name of the repository - used for logging.
+ * @param repositoryHelper - class used to build type definitions and instances.
+ * @param repositoryValidator - class used to validate type definitions and instances.
+ * @param metadataCollectionId - unique Identifier of the metadata collection Id.
* @param localServerName - name of the local server.
* @param localServerType - type of the local server.
* @param localOrganizationName - name of the organization that owns the local server.
* @param realMetadataCollection - metadata collection of the real local connector.
* @param outboundRepositoryEventProcessor - outbound event processor
* (may be null if a repository event mapper is deployed).
- * @param repositoryContentManager - manager of in-memory cache of type definitions (TypeDefs).
+ * @param typeDefManager - manager of in-memory cache of type definitions (TypeDefs).
*/
- LocalOMRSMetadataCollection(String localMetadataConnectionId,
+ LocalOMRSMetadataCollection(LocalOMRSRepositoryConnector parentConnector,
+ String repositoryName,
+ OMRSRepositoryHelper repositoryHelper,
+ OMRSRepositoryValidator repositoryValidator,
+ String metadataCollectionId,
String localServerName,
String localServerType,
String localOrganizationName,
OMRSMetadataCollection realMetadataCollection,
OMRSRepositoryEventProcessor outboundRepositoryEventProcessor,
- OMRSRepositoryContentManager repositoryContentManager)
+ OMRSTypeDefManager typeDefManager)
{
/*
* The super class manages the local metadata collection id. This is a locally managed value.
*/
- super(localMetadataConnectionId);
+ super(parentConnector, repositoryName, metadataCollectionId, repositoryHelper, repositoryValidator);
/*
* Save the metadata collection object for the real repository. This is the metadata collection that
@@ -104,9 +110,36 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
this.localServerType = localServerType;
this.localOrganizationName = localOrganizationName;
this.outboundRepositoryEventProcessor = outboundRepositoryEventProcessor;
- this.localRepositoryContentManager = repositoryContentManager;
- this.repositoryValidator = new OMRSRepositoryValidator(repositoryContentManager);
- this.repositoryHelper = new OMRSRepositoryHelper(repositoryContentManager);
+ this.localTypeDefManager = typeDefManager;
+ }
+
+
+ /* ======================================================================
+ * Group 1: Confirm the identity of the metadata repository being called.
+ */
+
+ /**
+ * Returns the identifier of the metadata repository. This is the identifier used to register the
+ * metadata repository with the metadata repository cohort. It is also the identifier used to
+ * identify the home repository of a metadata instance.
+ *
+ * @return String - metadata collection id.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ */
+ public String getMetadataCollectionId() throws RepositoryErrorException
+ {
+ final String methodName = "getMetadataCollectionId";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
+
+ /*
+ * Perform operation
+ */
+ return super.metadataCollectionId;
}
@@ -129,11 +162,19 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
public TypeDefGallery getAllTypes(String userId) throws RepositoryErrorException,
UserNotAuthorizedException
{
- final String methodName = "getAllTypes";
+ final String methodName = "getAllTypes";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getAllTypes(userId);
}
@@ -155,11 +196,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
RepositoryErrorException,
UserNotAuthorizedException
{
- final String methodName = "findTypesByName";
+ final String methodName = "findTypesByName";
+ final String nameParameterName = "name";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeName(repositoryName, nameParameterName, name, methodName);
+ /*
+ * Perform operation
+ */
return realMetadataCollection.findTypesByName(userId, name);
}
@@ -179,10 +230,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
RepositoryErrorException,
UserNotAuthorizedException
{
- final String methodName = "findTypeDefsByCategory";
+ final String methodName = "findTypeDefsByCategory";
+ final String categoryParameterName = "category";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeDefCategory(repositoryName, categoryParameterName, category, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.findTypeDefsByCategory(userId, category);
}
@@ -203,11 +265,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
RepositoryErrorException,
UserNotAuthorizedException
{
- final String methodName = "findAttributeTypeDefsByCategory";
+ final String methodName = "findAttributeTypeDefsByCategory";
+ final String categoryParameterName = "category";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateAttributeTypeDefCategory(repositoryName, categoryParameterName, category, methodName);
+ /*
+ * Perform operation
+ */
return realMetadataCollection.findAttributeTypeDefsByCategory(userId, category);
}
@@ -228,10 +300,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
RepositoryErrorException,
UserNotAuthorizedException
{
- final String methodName = "findTypeDefsByProperty";
+ final String methodName = "findTypeDefsByProperty";
+ final String matchCriteriaParameterName = "matchCriteria";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateMatchCriteria(repositoryName, matchCriteriaParameterName, matchCriteria, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.findTypeDefsByProperty(userId, matchCriteria);
}
@@ -257,10 +340,20 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
RepositoryErrorException,
UserNotAuthorizedException
{
- final String methodName = "findTypesByExternalID";
+ final String methodName = "findTypesByExternalID";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateExternalId(repositoryName, standard, organization, identifier, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.findTypesByExternalID(userId, standard, organization, identifier);
}
@@ -281,10 +374,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
RepositoryErrorException,
UserNotAuthorizedException
{
- final String methodName = "searchForTypeDefs";
+ final String methodName = "searchForTypeDefs";
+ final String searchCriteriaParameterName = "searchCriteria";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateSearchCriteria(repositoryName, searchCriteriaParameterName, searchCriteria, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.searchForTypeDefs(userId, searchCriteria);
}
@@ -308,10 +412,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
TypeDefNotKnownException,
UserNotAuthorizedException
{
- final String methodName = "getTypeDefByGUID";
+ final String methodName = "getTypeDefByGUID";
+ final String guidParameterName = "guid";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getTypeDefByGUID(userId, guid);
}
@@ -335,10 +450,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
TypeDefNotKnownException,
UserNotAuthorizedException
{
- final String methodName = "getAttributeTypeDefByGUID";
+ final String methodName = "getAttributeTypeDefByGUID";
+ final String guidParameterName = "guid";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getAttributeTypeDefByGUID(userId, guid);
}
@@ -362,10 +488,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
TypeDefNotKnownException,
UserNotAuthorizedException
{
- final String methodName = "getTypeDefByName";
+ final String methodName = "getTypeDefByName";
+ final String nameParameterName = "name";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeName(repositoryName, nameParameterName, name, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getTypeDefByName(userId, name);
}
@@ -389,10 +526,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
TypeDefNotKnownException,
UserNotAuthorizedException
{
- final String methodName = "getAttributeTypeDefByName";
+ final String methodName = "getAttributeTypeDefByName";
+ final String nameParameterName = "name";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeName(repositoryName, nameParameterName, name, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getAttributeTypeDefByName(userId, name);
}
@@ -423,46 +571,41 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "addTypeDefGallery";
+ final String methodName = "addTypeDefGallery";
+ final String galleryParameterName = "newTypes";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeDefGallery(repositoryName, galleryParameterName, newTypes, methodName);
- if (newTypes != null)
- {
- List<AttributeTypeDef> attributeTypeDefs = newTypes.getAttributeTypeDefs();
+ /*
+ * Perform operation - the gallery is passed to the real repository connector one type at a time
+ * to ensure the proper management and caching of types.
+ */
+ List<AttributeTypeDef> attributeTypeDefs = newTypes.getAttributeTypeDefs();
- if (attributeTypeDefs != null)
+ if (attributeTypeDefs != null)
+ {
+ for (AttributeTypeDef attributeTypeDef : attributeTypeDefs)
{
- for (AttributeTypeDef attributeTypeDef : attributeTypeDefs)
- {
- this.addAttributeTypeDef(userId, attributeTypeDef);
- }
+ this.addAttributeTypeDef(userId, attributeTypeDef);
}
+ }
- List<TypeDef> typeDefs = newTypes.getTypeDefs();
+ List<TypeDef> typeDefs = newTypes.getTypeDefs();
- if (typeDefs != null)
+ if (typeDefs != null)
+ {
+ for (TypeDef typeDef : typeDefs)
{
- for (TypeDef typeDef : typeDefs)
- {
- this.addTypeDef(userId, typeDef);
- }
+ this.addTypeDef(userId, typeDef);
}
}
- else
- {
- OMRSErrorCode errorCode = OMRSErrorCode.NULL_TYPEDEF_GALLERY;
- String errorMessage = errorCode.getErrorMessageId()
- + errorCode.getFormattedErrorMessage();
-
- throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
- this.getClass().getName(),
- methodName,
- errorMessage,
- errorCode.getSystemAction(),
- errorCode.getUserAction());
- }
}
@@ -491,16 +634,28 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "addTypeDef";
+ final String methodName = "addTypeDef";
+ final String typeDefParameterName = "newTypeDef";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeDef(repositoryName, typeDefParameterName, newTypeDef, methodName);
+ repositoryValidator.validateUnknownTypeDef(repositoryName, typeDefParameterName, newTypeDef, methodName);
+
+ /*
+ * Perform operation
+ */
realMetadataCollection.addTypeDef(userId, newTypeDef);
- if (localRepositoryContentManager != null)
+ if (localTypeDefManager != null)
{
- localRepositoryContentManager.addTypeDef(repositoryName, newTypeDef);
+ localTypeDefManager.addTypeDef(repositoryName, newTypeDef);
}
if (outboundRepositoryEventProcessor != null)
@@ -539,16 +694,28 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "addAttributeTypeDef";
+ final String methodName = "addAttributeTypeDef";
+ final String typeDefParameterName = "newAttributeTypeDef";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateAttributeTypeDef(repositoryName, typeDefParameterName, newAttributeTypeDef, methodName);
+ repositoryValidator.validateUnknownAttributeTypeDef(repositoryName, typeDefParameterName, newAttributeTypeDef, methodName);
+
+ /*
+ * Perform operation
+ */
realMetadataCollection.addAttributeTypeDef(userId, newAttributeTypeDef);
- if (localRepositoryContentManager != null)
+ if (localTypeDefManager != null)
{
- localRepositoryContentManager.addAttributeTypeDef(repositoryName, newAttributeTypeDef);
+ localTypeDefManager.addAttributeTypeDef(repositoryName, newAttributeTypeDef);
}
if (outboundRepositoryEventProcessor != null)
@@ -585,10 +752,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
InvalidTypeDefException,
UserNotAuthorizedException
{
- final String methodName = "verifyTypeDef";
+ final String methodName = "verifyTypeDef";
+ final String typeDefParameterName = "typeDef";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeDef(repositoryName, typeDefParameterName, typeDef, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.verifyTypeDef(userId, typeDef);
}
@@ -616,10 +794,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
InvalidTypeDefException,
UserNotAuthorizedException
{
- final String methodName = "verifyAttributeTypeDef";
+ final String methodName = "verifyAttributeTypeDef";
+ final String typeDefParameterName = "attributeTypeDef";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateAttributeTypeDef(repositoryName, typeDefParameterName, attributeTypeDef, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.verifyAttributeTypeDef(userId, attributeTypeDef);
}
@@ -649,16 +838,26 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "updateTypeDef";
+ final String methodName = "updateTypeDef";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeDefPatch(repositoryName, typeDefPatch, methodName);
+
+ /*
+ * Perform operation
+ */
TypeDef updatedTypeDef = realMetadataCollection.updateTypeDef(userId, typeDefPatch);
- if (localRepositoryContentManager != null)
+ if (localTypeDefManager != null)
{
- localRepositoryContentManager.updateTypeDef(repositoryName, updatedTypeDef);
+ localTypeDefManager.updateTypeDef(repositoryName, updatedTypeDef);
}
if (outboundRepositoryEventProcessor != null)
@@ -701,34 +900,37 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "deleteTypeDef";
+ final String methodName = "deleteTypeDef";
+ final String guidParameterName = "obsoleteTypeDefGUID";
+ final String nameParameterName = "obsoleteTypeDefName";
- validateRepository(methodName);
- repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- if ((obsoleteTypeDefGUID == null) || (obsoleteTypeDefName == null))
- {
- OMRSErrorCode errorCode = OMRSErrorCode.NULL_TYPEDEF_IDENTIFIER;
- String errorMessage = errorCode.getErrorMessageId()
- + errorCode.getFormattedErrorMessage();
+ repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeDefIds(repositoryName,
+ guidParameterName,
+ nameParameterName,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName,
+ methodName);
- throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
- this.getClass().getName(),
- methodName,
- errorMessage,
- errorCode.getSystemAction(),
- errorCode.getUserAction());
- }
+ /*
+ * Perform operation
+ */
realMetadataCollection.deleteTypeDef(userId,
obsoleteTypeDefGUID,
obsoleteTypeDefName);
- if (localRepositoryContentManager != null)
+ if (localTypeDefManager != null)
{
- localRepositoryContentManager.deleteTypeDef(repositoryName,
- obsoleteTypeDefGUID,
- obsoleteTypeDefName);
+ localTypeDefManager.deleteTypeDef(repositoryName,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName);
}
if (outboundRepositoryEventProcessor != null)
@@ -770,35 +972,37 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "deleteAttributeTypeDef";
+ final String methodName = "deleteAttributeTypeDef";
+ final String guidParameterName = "obsoleteTypeDefGUID";
+ final String nameParameterName = "obsoleteTypeDefName";
- validateRepository(methodName);
- repositoryValidator.validateUserId(repositoryName, userId, methodName);
-
- if ((obsoleteTypeDefGUID == null) || (obsoleteTypeDefName == null))
- {
- OMRSErrorCode errorCode = OMRSErrorCode.NULL_TYPEDEF_IDENTIFIER;
- String errorMessage = errorCode.getErrorMessageId()
- + errorCode.getFormattedErrorMessage();
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
- this.getClass().getName(),
- methodName,
- errorMessage,
- errorCode.getSystemAction(),
- errorCode.getUserAction());
+ repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateAttributeTypeDefIds(repositoryName,
+ guidParameterName,
+ nameParameterName,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName,
+ methodName);
- }
+ /*
+ * Perform operation
+ */
realMetadataCollection.deleteAttributeTypeDef(userId,
obsoleteTypeDefGUID,
obsoleteTypeDefName);
- if (localRepositoryContentManager != null)
+ if (localTypeDefManager != null)
{
- localRepositoryContentManager.deleteAttributeTypeDef(repositoryName,
- obsoleteTypeDefGUID,
- obsoleteTypeDefName);
+ localTypeDefManager.deleteAttributeTypeDef(repositoryName,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName);
}
if (outboundRepositoryEventProcessor != null)
@@ -843,25 +1047,35 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "reIdentifyTypeDef";
+ final String methodName = "reIdentifyTypeDef";
+ final String originalGUIDParameterName = "originalTypeDefGUID";
+ final String originalNameParameterName = "originalTypeDefName";
+ final String newGUIDParameterName = "newTypeDefGUID";
+ final String newNameParameterName = "newTypeDefName";
- validateRepository(methodName);
- repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- if ((originalTypeDefGUID == null) || (originalTypeDefName == null) ||
- (newTypeDefGUID == null) || (newTypeDefName == null))
- {
- OMRSErrorCode errorCode = OMRSErrorCode.NULL_TYPEDEF_IDENTIFIER;
- String errorMessage = errorCode.getErrorMessageId()
- + errorCode.getFormattedErrorMessage();
+ repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeDefIds(repositoryName,
+ originalGUIDParameterName,
+ originalNameParameterName,
+ originalTypeDefGUID,
+ originalTypeDefName,
+ methodName);
+ repositoryValidator.validateTypeDefIds(repositoryName,
+ newGUIDParameterName,
+ newNameParameterName,
+ newTypeDefGUID,
+ newTypeDefName,
+ methodName);
- throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
- this.getClass().getName(),
- methodName,
- errorMessage,
- errorCode.getSystemAction(),
- errorCode.getUserAction());
- }
+ /*
+ * Perform operation
+ */
TypeDef originalTypeDef = realMetadataCollection.getTypeDefByGUID(userId, originalTypeDefGUID);
@@ -871,12 +1085,12 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
newTypeDefGUID,
newTypeDefName);
- if (localRepositoryContentManager != null)
+ if (localTypeDefManager != null)
{
- localRepositoryContentManager.reIdentifyTypeDef(repositoryName,
- originalTypeDefGUID,
- originalTypeDefName,
- newTypeDef);
+ localTypeDefManager.reIdentifyTypeDef(repositoryName,
+ originalTypeDefGUID,
+ originalTypeDefName,
+ newTypeDef);
}
if (outboundRepositoryEventProcessor != null)
@@ -923,25 +1137,35 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "reIdentifyAttributeTypeDef";
+ final String methodName = "reIdentifyAttributeTypeDef";
+ final String originalGUIDParameterName = "originalAttributeTypeDefGUID";
+ final String originalNameParameterName = "originalAttributeTypeDefName";
+ final String newGUIDParameterName = "newAttributeTypeDefGUID";
+ final String newNameParameterName = "newAttributeTypeDefName";
- validateRepository(methodName);
- repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- if ((originalAttributeTypeDefGUID == null) || (originalAttributeTypeDefName == null) ||
- (newAttributeTypeDefGUID == null) || (newAttributeTypeDefName == null))
- {
- OMRSErrorCode errorCode = OMRSErrorCode.NULL_TYPEDEF_IDENTIFIER;
- String errorMessage = errorCode.getErrorMessageId()
- + errorCode.getFormattedErrorMessage();
+ repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeDefIds(repositoryName,
+ originalGUIDParameterName,
+ originalNameParameterName,
+ originalAttributeTypeDefGUID,
+ originalAttributeTypeDefName,
+ methodName);
+ repositoryValidator.validateTypeDefIds(repositoryName,
+ newGUIDParameterName,
+ newNameParameterName,
+ newAttributeTypeDefGUID,
+ newAttributeTypeDefName,
+ methodName);
- throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
- this.getClass().getName(),
- methodName,
- errorMessage,
- errorCode.getSystemAction(),
- errorCode.getUserAction());
- }
+ /*
+ * Perform operation
+ */
AttributeTypeDef originalAttributeTypeDef = realMetadataCollection.getAttributeTypeDefByGUID(userId, originalAttributeTypeDefGUID);
@@ -951,12 +1175,12 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
newAttributeTypeDefGUID,
newAttributeTypeDefName);
- if (localRepositoryContentManager != null)
+ if (localTypeDefManager != null)
{
- localRepositoryContentManager.reIdentifyAttributeTypeDef(repositoryName,
- originalAttributeTypeDefGUID,
- originalAttributeTypeDefName,
- newAttributeTypeDef);
+ localTypeDefManager.reIdentifyAttributeTypeDef(repositoryName,
+ originalAttributeTypeDefGUID,
+ originalAttributeTypeDefName,
+ newAttributeTypeDef);
}
if (outboundRepositoryEventProcessor != null)
@@ -996,10 +1220,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
RepositoryErrorException,
UserNotAuthorizedException
{
- final String methodName = "isEntityKnown";
+ final String methodName = "isEntityKnown";
+ final String guidParameterName = "guid";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
+
+ /*
+ * Perform operation
+ */
EntityDetail entity = realMetadataCollection.isEntityKnown(userId, guid);
@@ -1040,10 +1275,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
EntityNotKnownException,
UserNotAuthorizedException
{
- final String methodName = "getEntitySummary";
+ final String methodName = "getEntitySummary";
+ final String guidParameterName = "guid";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
+
+ /*
+ * Perform operation
+ */
EntitySummary entity = realMetadataCollection.getEntitySummary(userId, guid);
@@ -1086,10 +1332,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
EntityProxyOnlyException,
UserNotAuthorizedException
{
- final String methodName = "getEntityDetail";
+ final String methodName = "getEntityDetail";
+ final String guidParameterName = "guid";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
+
+ /*
+ * Perform operation
+ */
EntityDetail entity = realMetadataCollection.getEntityDetail(userId, guid);
@@ -1137,10 +1394,23 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "getEntityDetail";
+ final String methodName = "getEntityDetail";
+ final String guidParameterName = "guid";
+ final String asOfTimeParameter = "asOfTime";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+
+ /*
+ * Perform operation
+ */
EntityDetail entity = realMetadataCollection.getEntityDetail(userId, guid, asOfTime);
@@ -1208,10 +1478,25 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "getRelationshipsForEntity";
+ final String methodName = "getRelationshipsForEntity";
+ final String guidParameterName = "entityGUID";
+ final String asOfTimeParameter = "asOfTime";
+ final String pageSizeParameter = "pageSize";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, guidParameterName, entityGUID, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+ repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getRelationshipsForEntity(userId,
entityGUID,
@@ -1277,10 +1562,33 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "findEntitiesByProperty";
+ final String methodName = "findEntitiesByProperty";
+ final String matchCriteriaParameterName = "matchCriteria";
+ final String matchPropertiesParameterName = "matchProperties";
+ final String guidParameterName = "entityTypeGUID";
+ final String asOfTimeParameter = "asOfTime";
+ final String pageSizeParameter = "pageSize";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, entityTypeGUID, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+ repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
+ repositoryValidator.validateMatchCriteria(repositoryName,
+ matchCriteriaParameterName,
+ matchPropertiesParameterName,
+ matchCriteria,
+ matchProperties,
+ methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.findEntitiesByProperty(userId,
entityTypeGUID,
@@ -1349,10 +1657,49 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "findEntitiesByClassification";
+ final String methodName = "findEntitiesByClassification";
+ final String classificationParameterName = "classificationName";
+ final String entityTypeGUIDParameterName = "entityTypeGUID";
+
+ final String matchCriteriaParameterName = "matchCriteria";
+ final String matchPropertiesParameterName = "matchClassificationProperties";
+ final String asOfTimeParameter = "asOfTime";
+ final String pageSizeParameter = "pageSize";
+
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, entityTypeGUIDParameterName, entityTypeGUID, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+ repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
+
+ /*
+ * Validate TypeDef
+ */
+ TypeDef entityTypeDef = repositoryHelper.getTypeDef(repositoryName, entityTypeGUID);
+
+ repositoryValidator.validateTypeDefForInstance(repositoryName, entityTypeGUIDParameterName, entityTypeDef, methodName);
+
+ repositoryValidator.validateMatchCriteria(repositoryName,
+ matchCriteriaParameterName,
+ matchPropertiesParameterName,
+ matchCriteria,
+ matchClassificationProperties,
+ methodName);
+ repositoryValidator.validateClassification(repositoryName,
+ classificationParameterName,
+ classificationName,
+ entityTypeDef.getName(),
+ methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.findEntitiesByClassification(userId,
entityTypeGUID,
@@ -1369,10 +1716,14 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
/**
- * Return a list of entities matching the search criteria.
+ * Return a list of entities whose string based property values match the search criteria. The
+ * search criteria may include regex style wild cards.
*
* @param userId - unique identifier for requesting user.
- * @param searchCriteria - String expression of the characteristics of the required relationships.
+ * @param entityTypeGUID - GUID of the type of entity to search for. Null means all types will
+ * be searched (could be slow so not recommended).
+ * @param searchCriteria - String expression contained in any of the property values within the entities
+ * of the supplied type.
* @param fromEntityElement - the starting element number of the entities to return.
* This is used when retrieving elements
* beyond the first page of results. Zero means start from the first element.
@@ -1397,35 +1748,52 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
* @throws FunctionNotSupportedException - the repository does not support the asOfTime parameter.
* @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
*/
- public List<EntityDetail> searchForEntities(String userId,
- String searchCriteria,
- int fromEntityElement,
- List<InstanceStatus> limitResultsByStatus,
- List<String> limitResultsByClassification,
- Date asOfTime,
- String sequencingProperty,
- SequencingOrder sequencingOrder,
- int pageSize) throws InvalidParameterException,
- RepositoryErrorException,
- PropertyErrorException,
- PagingErrorException,
- FunctionNotSupportedException,
- UserNotAuthorizedException
+ public List<EntityDetail> findEntitiesByPropertyValue(String userId,
+ String entityTypeGUID,
+ String searchCriteria,
+ int fromEntityElement,
+ List<InstanceStatus> limitResultsByStatus,
+ List<String> limitResultsByClassification,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ FunctionNotSupportedException,
+ UserNotAuthorizedException
{
- final String methodName = "searchForEntities";
+ final String methodName = "findEntitiesByPropertyValue";
+ final String searchCriteriaParameterName = "searchCriteria";
+ final String asOfTimeParameter = "asOfTime";
+ final String pageSizeParameter = "pageSize";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateSearchCriteria(repositoryName, searchCriteriaParameterName, searchCriteria, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+ repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
- return realMetadataCollection.searchForEntities(userId,
- searchCriteria,
- fromEntityElement,
- limitResultsByStatus,
- limitResultsByClassification,
- asOfTime,
- sequencingProperty,
- sequencingOrder,
- pageSize);
+ /*
+ * Process operation
+ */
+
+ return realMetadataCollection.findEntitiesByPropertyValue(userId,
+ entityTypeGUID,
+ searchCriteria,
+ fromEntityElement,
+ limitResultsByStatus,
+ limitResultsByClassification,
+ asOfTime,
+ sequencingProperty,
+ sequencingOrder,
+ pageSize);
}
@@ -1445,10 +1813,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
RepositoryErrorException,
UserNotAuthorizedException
{
- final String methodName = "isRelationshipKnown";
+ final String methodName = "isRelationshipKnown";
+ final String guidParameterName = "guid";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
+
+ /*
+ * Process operation
+ */
return realMetadataCollection.isRelationshipKnown(userId, guid);
}
@@ -1473,10 +1852,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
RelationshipNotKnownException,
UserNotAuthorizedException
{
- final String methodName = "getRelationship";
+ final String methodName = "getRelationship";
+ final String guidParameterName = "guid";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
+
+ /*
+ * Process operation
+ */
return realMetadataCollection.getRelationship(userId, guid);
}
@@ -1505,10 +1895,23 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "getRelationship";
+ final String methodName = "getRelationship";
+ final String guidParameterName = "guid";
+ final String asOfTimeParameter = "asOfTime";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getRelationship(userId, guid, asOfTime);
}
@@ -1564,10 +1967,33 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "findRelationshipsByProperty";
+ final String methodName = "findRelationshipsByProperty";
+ final String matchCriteriaParameterName = "matchCriteria";
+ final String matchPropertiesParameterName = "matchProperties";
+ final String guidParameterName = "relationshipTypeGUID";
+ final String asOfTimeParameter = "asOfTime";
+ final String pageSizeParameter = "pageSize";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, relationshipTypeGUID, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+ repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
+ repositoryValidator.validateMatchCriteria(repositoryName,
+ matchCriteriaParameterName,
+ matchPropertiesParameterName,
+ matchCriteria,
+ matchProperties,
+ methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.findRelationshipsByProperty(userId,
relationshipTypeGUID,
@@ -1583,10 +2009,14 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
/**
- * Return a list of relationships that match the search criteria. The results can be paged.
+ * Return a list of relationships whose string based property values match the search criteria. The
+ * search criteria may include regex style wild cards.
*
* @param userId - unique identifier for requesting user.
- * @param searchCriteria - String expression of the characteristics of the required relationships.
+ * @param relationshipTypeGUID - GUID of the type of entity to search for. Null means all types will
+ * be searched (could be slow so not recommended).
+ * @param searchCriteria - String expression contained in any of the property values within the entities
+ * of the supplied type.
* @param fromRelationshipElement - Element number of the results to skip to when building the results list
* to return. Zero means begin at the start of the results. This is used
* to retrieve the results over a number of pages.
@@ -1609,33 +2039,48 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
* @throws FunctionNotSupportedException - the repository does not support the asOfTime parameter.
* @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
*/
- public List<Relationship> searchForRelationships(String userId,
- String searchCriteria,
- int fromRelationshipElement,
- List<InstanceStatus> limitResultsByStatus,
- Date asOfTime,
- String sequencingProperty,
- SequencingOrder sequencingOrder,
- int pageSize) throws InvalidParameterException,
- RepositoryErrorException,
- PropertyErrorException,
- PagingErrorException,
- FunctionNotSupportedException,
- UserNotAuthorizedException
+ public List<Relationship> findRelationshipsByPropertyValue(String userId,
+ String relationshipTypeGUID,
+ String searchCriteria,
+ int fromRelationshipElement,
+ List<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ FunctionNotSupportedException,
+ UserNotAuthorizedException
{
- final String methodName = "searchForRelationships";
+ final String methodName = "findRelationshipsByPropertyValue";
+ final String asOfTimeParameter = "asOfTime";
+ final String pageSizeParameter = "pageSize";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+ repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
- return realMetadataCollection.searchForRelationships(userId,
- searchCriteria,
- fromRelationshipElement,
- limitResultsByStatus,
- asOfTime,
- sequencingProperty,
- sequencingOrder,
- pageSize);
+ /*
+ * Perform operation
+ */
+
+ return realMetadataCollection.findRelationshipsByPropertyValue(userId,
+ relationshipTypeGUID,
+ searchCriteria,
+ fromRelationshipElement,
+ limitResultsByStatus,
+ asOfTime,
+ sequencingProperty,
+ sequencingOrder,
+ pageSize);
}
@@ -1671,10 +2116,25 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "getLinkingEntities";
+ final String methodName = "getLinkingEntities";
+ final String startEntityGUIDParameterName = "startEntityGUID";
+ final String endEntityGUIDParameterName = "entityGUID";
+ final String asOfTimeParameter = "asOfTime";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, startEntityGUIDParameterName, startEntityGUID, methodName);
+ repositoryValidator.validateGUID(repositoryName, endEntityGUIDParameterName, endEntityGUID, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getLinkingEntities(userId,
startEntityGUID,
@@ -1722,16 +2182,59 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
Date asOfTime,
int level) throws InvalidParameterException,
RepositoryErrorException,
- TypeErrorException,
EntityNotKnownException,
+ TypeErrorException,
PropertyErrorException,
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "getEntityNeighborhood";
+ final String methodName = "getEntityNeighborhood";
+ final String entityGUIDParameterName = "entityGUID";
+ final String entityTypeGUIDParameterName = "entityTypeGUIDs";
+ final String relationshipTypeGUIDParameterName = "relationshipTypeGUIDs";
+ final String limitedResultsByClassificationParameterName = "limitResultsByClassification";
+ final String asOfTimeParameter = "asOfTime";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, entityGUIDParameterName, entityGUID, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+
+ if (entityTypeGUIDs != null)
+ {
+ for (String guid : entityTypeGUIDs)
+ {
+ repositoryValidator.validateGUID(repositoryName, entityTypeGUIDParameterName, guid, methodName);
+ }
+ }
+
+ if (relationshipTypeGUIDs != null)
+ {
+ for (String guid : relationshipTypeGUIDs)
+ {
+ repositoryValidator.validateGUID(repositoryName, relationshipTypeGUIDParameterName, guid, methodName);
+ }
+ }
+
+ if (relationshipTypeGUIDs != null)
+ {
+ for (String classificationName : limitResultsByClassification)
+ {
+ repositoryValidator.validateClassificationName(repositoryName,
+ limitedResultsByClassificationParameterName,
+ classificationName,
+ methodName);
+ }
+ }
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getEntityNeighborhood(userId,
entityGUID,
@@ -1795,10 +2298,25 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "getRelatedEntities";
+ final String methodName = "getRelatedEntities";
+ final String entityGUIDParameterName = "startEntityGUID";
+ final String asOfTimeParameter = "asOfTime";
+ final String pageSizeParameter = "pageSize";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, entityGUIDParameterName, startEntityGUID, methodName);
+ repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
+ repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
+
+ /*
+ * Perform operation
+ */
return realMetadataCollection.getRelatedEntities(userId,
startEntityGUID,
@@ -1852,10 +2370,45 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
StatusNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "addEntity";
+ final String methodName = "addEntity";
+ final String entityGUIDParameterName = "entityTypeGUID";
+ final String propertiesParameterName = "initialProperties";
+ final String classificationsParameterName = "initialClassifications";
+ final String initialStatusParameterName = "initialStatus";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeGUID(repositoryName, entityGUIDParameterName, entityTypeGUID, methodName);
+
+ TypeDef typeDef = repositoryHelper.getTypeDef(repositoryName, entityTypeGUID);
+
+ repositoryValidator.validateTypeDefForInstance(repositoryName, entityGUIDParameterName, typeDef, methodName);
+ repositoryValidator.validateClassificationList(repositoryName,
+ classificationsParameterName,
+ initialClassifications,
+ typeDef.getName(),
+ methodName);
+
+ repositoryValidator.validatePropertiesForType(repositoryName,
+ propertiesParameterName,
+ typeDef,
+ initialProperties,
+ methodName);
+
+ repositoryValidator.validateInstanceStatus(repositoryName,
+ initialStatusParameterName,
+ initialStatus,
+ typeDef,
+ methodName);
+
+ /*
+ * Validation complete - ok to create new instance
+ */
EntityDetail entity = realMetadataCollection.addEntity(userId,
entityTypeGUID,
@@ -1925,12 +2478,51 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "addEntityProxy";
+ final String methodName = "addEntityProxy";
+ final String proxyParameterName = "entityProxy";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateEntityProxy(repositoryName,
+ metadataCollectionId,
+ proxyParameterName,
+ entityProxy,
+ methodName);
+
+ repositoryValidator.validateInstanceType(repositoryName, entityProxy);
+
+ String entityTypeGUID = entityProxy.getType().getTypeDefGUID();
+
+ TypeDef typeDef = repositoryHelper.getTypeDef(repositoryName, entityTypeGUID);
+
+ repositoryValidator.validateTypeDefForInstance(repositoryName, proxyParameterName, typeDef, methodName);
+ repositoryValidator.validateClassificationList(repositoryName,
+ proxyParameterName,
+ entityProxy.getClassifications(),
+ typeDef.getName(),
+ methodName);
+
+ repositoryValidator.validatePropertiesForType(repositoryName,
+ proxyParameterName,
+ typeDef,
+ entityProxy.getUniqueProperties(),
+ methodName);
+
+ repositoryValidator.validateInstanceStatus(repositoryName,
+ proxyParameterName,
+ entityProxy.getStatus(),
+ typeDef,
+ methodName);
+
/*
+ * Validation complete
+ *
* EntityProxies are used to store a relationship where the entity at one end of the relationship is
* not stored locally.
*/
@@ -1961,14 +2553,25 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
StatusNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "updateEntityStatus";
+ final String methodName = "updateEntityStatus";
+ final String entityGUIDParameterName = "entityGUID";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, entityGUIDParameterName, entityGUID, methodName);
+
+ /*
+ * Locate entity
+ */
EntityDetail entity = realMetadataCollection.updateEntityStatus(userId, entityGUID, newStatus);
- notifyOfUpdatedEntity(entity);
+ this.notifyOfUpdatedEntity(entity);
return entity;
}
@@ -1997,10 +2600,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
PropertyErrorException,
UserNotAuthorizedException
{
- final String methodName = "updateEntityProperties";
+ final String methodName = "updateEntityProperties";
+ final String entityGUIDParameterName = "entityGUID";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, entityGUIDParameterName, entityGUID, methodName);
+
+ /*
+ * Locate entity
+ */
EntityDetail entity = realMetadataCollection.updateEntityProperties(userId, entityGUID, properties);
@@ -2067,10 +2681,21 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "undoEntityUpdate";
+ final String methodName = "undoEntityUpdate";
+ final String entityGUIDParameterName = "entityGUID";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateGUID(repositoryName, entityGUIDParameterName, entityGUID, methodName);
+
+ /*
+ * Validation complete - ok to restore entity
+ */
EntityDetail entity = realMetadataCollection.undoEntityUpdate(userId, entityGUID);
@@ -2134,10 +2759,29 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
FunctionNotSupportedException,
UserNotAuthorizedException
{
- final String methodName = "deleteEntity";
+ final String methodName = "deleteEntity";
+ final String typeDefGUIDParameterName = "typeDefGUID";
+ final String typeDefNameParameterName = "typeDefName";
+ final String entityGUIDParameterName = "obsoleteEntityGUID";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(methodName);
+ parentConnector.validateRepositoryIsActive(methodName);
- validateRepository(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
+ repositoryValidator.validateTypeDefIds(repositoryName,
+ typeDefGUIDParameterName,
+ typeDefNameParameterName,
+ typeDefGUID,
+ typeDefName,
+ methodName);
+ repositoryValidator.validateGUID(repositoryName, entityGUIDParameterName, obsoleteEntityGUID, methodName);
+
+ /*
+ * Locate Entity
+ */
EntityDetail entity = realMetadataCollection.deleteEntity(userId,
typeDefGUID,
@@ -2181,10 +2825,29 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
EntityNotDeletedException,
UserNotAuthorizedException
{
- final String methodName = "purgeEntity";
+ final String methodName = "purgeEntity";
+ final String typeDefGUIDParameterName = "typeDefGUID";
+ final String typeDefNameParameterName = "typeDefName";
+ final String entityGUIDParameterName = "deletedEntityGUID";
+
+ /*
+ * Validate parameters
+ */
+ this.validateRepositoryConnector(metho
<TRUNCATED>