Skip to content

Commit

Permalink
odpi#5399 remove provenance tests
Browse files Browse the repository at this point in the history
Signed-off-by: David Radley <david_radley@uk.ibm.com>
  • Loading branch information
davidradl committed Jul 26, 2021
1 parent 29b985b commit b53355d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,6 @@ public enum SubjectAreaErrorCode implements ExceptionMessageSet {
"Cannot continue with create with the supplied Categories, as they do not exist",
"The system is unable to process the request as the Term create requires the supplied Categories to exist.",
"Correct the code in the caller to create Terms specifying not categories opr existing categories."),
MODIFICATION_OPERATION_ATTEMPTED_ON_READ_ONLY_NODE(400, "OMAS-SUBJECT-AREA-400-074",
"Cannot continue with the {0} operation with the supplied Node - {1}, as it is read only",
"The system is unable to process the request the modification request is not allowed on a read-only Node.",
"Amend the code to not issue modification requests on a read-only Node."),
MODIFICATION_OPERATION_ATTEMPTED_ON_READ_ONLY_RELATIONSHIP(400, "OMAS-SUBJECT-AREA-400-075",
"Cannot continue with the {0} operation with the supplied Relationship {1}, as it is read only",
"The system is unable to process the request the modification request is not allowed on a read-only Relationship.",
"Amend the code to not issue modification requests on a read-only Relationship."),
INVALID_RELATIONSHIPTYPES_FOR_GRAPH(400, "OMAS-SUBJECT-AREA-400-076",
"Cannot continue with the {0} operation because an invalid relationship name {1} was supplied in the filter",
"The system is unable to process the request as it cannot identify the requested Relationship type.",
Expand All @@ -269,9 +261,6 @@ public enum SubjectAreaErrorCode implements ExceptionMessageSet {
"Cannot continue with the {0} operation because there is the Unknown relationship name {1} was supplied in the filter",
"The system is unable to process the request as it cannot identify the requested Unknown Relationship type.",
"Amend the code to supply only known Relationship Types for the graph operation."),



OMRS_NOT_INITIALIZED(404, "OMAS-SUBJECT-AREA-404-001",
"The open metadata repository services are not initialized for the {0} operation",
"The system is unable to connect to the open metadata property server.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ public SubjectAreaOMASAPIResponse<Category> updateCategory(String userId, String
response = getCategoryByGuid(userId, guid);
if (response.head().isPresent()) {
Category storedCategory = response.head().get();
checkReadOnly(methodName, storedCategory, "update");
CategoryMapper categoryMapper = mappersFactory.get(CategoryMapper.class);

EntityDetail suppliedEntity = categoryMapper.map(suppliedCategory);
Expand Down Expand Up @@ -426,21 +425,16 @@ public SubjectAreaOMASAPIResponse<Category> deleteCategory(String userId, String
SubjectAreaOMASAPIResponse<Category> response = new SubjectAreaOMASAPIResponse<>();

try {
response = getCategoryByGuid(userId, guid);
if (response.head().isPresent()) {
Category categoryToBeDeleted = response.head().get();
checkReadOnly(methodName, categoryToBeDeleted, "delete");
}
genericHandler.deleteBeanInRepository(userId,
null,
null,
guid,
"guid",
OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_GUID,
OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_NAME,
null,
null,
methodName);
genericHandler.deleteBeanInRepository(userId,
null,
null,
guid,
"guid",
OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_GUID,
OpenMetadataAPIMapper.GLOSSARY_CATEGORY_TYPE_NAME,
null,
null,
methodName);
} catch (PropertyServerException | UserNotAuthorizedException | InvalidParameterException e) {
response.setExceptionInfo(e, className);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ public SubjectAreaOMASAPIResponse<Glossary> updateGlossary(String userId, String
response = getGlossaryByGuid(userId, guid);
if (response.head().isPresent()) {
Glossary currentGlossary = response.head().get();
checkReadOnly(methodName, currentGlossary, "update");

GlossaryMapper glossaryMapper = mappersFactory.get(GlossaryMapper.class);
EntityDetail entityDetail = glossaryMapper.map(currentGlossary);
genericHandler.updateBeanInRepository(userId,
Expand Down Expand Up @@ -320,11 +318,6 @@ public SubjectAreaOMASAPIResponse<Glossary> deleteGlossary(String userId, String
SubjectAreaOMASAPIResponse<Glossary> response = new SubjectAreaOMASAPIResponse<>();
boolean issueDelete = false;
try {
response = getGlossaryByGuid(userId, guid);
Glossary currentGlossary = response.head().get();
if (response.head().isPresent()) {
checkReadOnly(methodName, currentGlossary, "delete");
}
// if this is a not a purge then check there are no relationships before deleting,
// otherwise the deletion could remove all anchored entities.
if (genericHandler.isBeanIsolated(userId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,34 +451,6 @@ protected void setUniqueQualifiedNameIfBlank(Node node) {
node.setQualifiedName(node.getName() + "@" + UUID.randomUUID().toString());
}
}
/**
* Check whether the node is readonly and throw and exception if it is
* @param methodName calling methodName
* @param node node to check
* @param operation operation being attempted
* @throws PropertyServerException exception thrown when the node is readonly
*/
protected void checkReadOnly(String methodName, Node node, String operation ) throws PropertyServerException {
if (node.isReadOnly()) {
// reject
ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.MODIFICATION_OPERATION_ATTEMPTED_ON_READ_ONLY_NODE.getMessageDefinition(operation, node.getNodeType().toString());
throw new PropertyServerException(messageDefinition, className , methodName);
}
}
/**
* Check whether the relationship is readonly and throw and exception if it is
* @param methodName calling methodName
* @param relationship relationship to check
* @param operation operation being attempted
* @throws PropertyServerException exception thrown when the relationship is readonly
*/
protected void checkRelationshipReadOnly(String methodName, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship relationship, String operation ) throws PropertyServerException {
if (relationship.getInstanceProvenanceType() != InstanceProvenanceType.LOCAL_COHORT) {
// reject
ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.MODIFICATION_OPERATION_ATTEMPTED_ON_READ_ONLY_RELATIONSHIP.getMessageDefinition(operation, relationship.getType().getTypeDefName());
throw new PropertyServerException(messageDefinition, className , methodName);
}
}

/**
* Set the effectivity to and from dates date for a Node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public SubjectAreaOMASAPIResponse<Project> updateProject(String userId, String g
//

Project storedProject = response.head().get();
checkReadOnly(methodName, storedProject, "update");
ProjectMapper projectMapper = mappersFactory.get(ProjectMapper.class);

EntityDetail suppliedEntity = projectMapper.map(suppliedProject);
Expand Down Expand Up @@ -315,11 +314,6 @@ public SubjectAreaOMASAPIResponse<Project> deleteProject(String userId, String g
final String methodName = "deleteProject";
SubjectAreaOMASAPIResponse<Project> response = new SubjectAreaOMASAPIResponse<>();
boolean issueDelete = false; try {
response = getProjectByGuid(userId, guid);
if (response.head().isPresent()) {
Project currentProject = response.head().get();
checkReadOnly(methodName, currentProject, "delete");
}
if (genericHandler.isBeanIsolated(userId,
guid,
OpenMetadataAPIMapper.PROJECT_TYPE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ public <R extends Relationship> SubjectAreaOMASAPIResponse<R> updateRelationship
response = getRelationship(methodName, userId, clazz, relationshipGuid);
R storedOMASRelationship = response.results().get(0);
org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship storedRelationship = mapper.map(storedOMASRelationship);

checkRelationshipReadOnly(methodName, storedRelationship, "update");

org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship relationshipToUpdate = mapper.map(relationship);
relationshipToUpdate.setGUID(relationshipGuid);

Expand Down Expand Up @@ -278,8 +275,6 @@ public <R extends Relationship> SubjectAreaOMASAPIResponse<R> deleteRelationship
mapper.getTypeName(),
restAPIName);

checkRelationshipReadOnly(methodName, oMRSRelationship, "delete");

genericHandler.unlinkElementFromElement(userId,
false,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ public SubjectAreaOMASAPIResponse<Term> updateTerm(String userId, String guid, T
response = getTermByGuid(userId, guid);
if (response.head().isPresent()) {
Term storedTerm = response.head().get();
checkReadOnly(methodName, storedTerm, "update");
TermMapper termMapper = mappersFactory.get(TermMapper.class);

EntityDetail suppliedEntity = termMapper.map(suppliedTerm);
Expand Down Expand Up @@ -680,10 +679,6 @@ public SubjectAreaOMASAPIResponse<Term> deleteTerm(String userId, String guid) {
final String methodName = "deleteTerm";
SubjectAreaOMASAPIResponse<Term> response = new SubjectAreaOMASAPIResponse<>();
try {
if (response.head().isPresent()) {
Term termToBeDeleted = response.head().get();
checkReadOnly(methodName, termToBeDeleted, "delete");
}
genericHandler.deleteBeanInRepository(userId,
null,
null,
Expand Down

0 comments on commit b53355d

Please sign in to comment.