summaryrefslogtreecommitdiffstats
path: root/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
diff options
context:
space:
mode:
Diffstat (limited to 'aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java')
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java120
1 files changed, 47 insertions, 73 deletions
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
index 2205b14b..028ebdeb 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
@@ -2,13 +2,13 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,7 +25,6 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
-import javax.xml.validation.Schema;
import java.util.List;
import java.util.stream.Collectors;
@@ -36,124 +35,99 @@ public class SchemaVersions {
@Value("#{'${schema.version.list}'.split(',')}")
private List<String> apiVersions;
-
@Value("${schema.version.api.default}")
private String defaultApiVersion;
-
@Value("${schema.version.edge.label.start}")
private String edgeLabelStartVersion;
-
@Value("${schema.version.depth.start}")
private String depthStartVersion;
-
@Value("${schema.version.app.root.start}")
private String appRootStartVersion;
-
@Value("${schema.version.related.link.start}")
private String relatedLinkStartVersion;
-
@Value("${schema.version.namespace.change.start}")
- private String namespaceChangeStartVersion;
- private List<SchemaVersion> versions;
-
- private SchemaVersion edgeLabelVersion;
- private SchemaVersion defaultVersion;
- private SchemaVersion depthVersion;
- private SchemaVersion appRootVersion;
- private SchemaVersion relatedLinkVersion;
- private SchemaVersion namespaceChangeVersion;
+ protected String namespaceChangeStartVersion;
+ protected List<SchemaVersion> versionsValue;
+ protected SchemaVersion edgeLabelVersionValue;
+ protected SchemaVersion defaultVersionValue;
+ protected SchemaVersion depthVersionValue;
+ protected SchemaVersion appRootVersionValue;
+ protected SchemaVersion relatedLinkVersionValue;
+ protected SchemaVersion namespaceChangeVersionValue;
@PostConstruct
public void initialize() {
- versions = apiVersions.stream().map(SchemaVersion::new).collect(Collectors.toList());
-
- edgeLabelVersion = new SchemaVersion(edgeLabelStartVersion);
- defaultVersion = new SchemaVersion(defaultApiVersion);
- depthVersion = new SchemaVersion(depthStartVersion);
- appRootVersion = new SchemaVersion(appRootStartVersion);
- relatedLinkVersion = new SchemaVersion(relatedLinkStartVersion);
- namespaceChangeVersion = new SchemaVersion(namespaceChangeStartVersion);
-
- if (!versions.contains(edgeLabelVersion)) {
- throw new AAISchemaValidationException(
- "Invalid, edge label version is not in the api versions list"
+ versionsValue = apiVersions.stream().map(SchemaVersion::new).collect(Collectors.toList());
+ edgeLabelVersionValue = new SchemaVersion(edgeLabelStartVersion);
+ defaultVersionValue = new SchemaVersion(defaultApiVersion);
+ depthVersionValue = new SchemaVersion(depthStartVersion);
+ appRootVersionValue = new SchemaVersion(appRootStartVersion);
+ relatedLinkVersionValue = new SchemaVersion(relatedLinkStartVersion);
+ namespaceChangeVersionValue = new SchemaVersion(namespaceChangeStartVersion);
+ this.validate();
+ }
+
+
+ protected void validate() {
+ String errorMessage = "Invalid, edge label version is not in the api versions list"
+ ", please check schema.version.list and ensure that the"
- + " schema.version.edge.label.start is in that list"
- );
+ + " schema.version.edge.label.start is in that list";
+ if (!versionsValue.contains(edgeLabelVersionValue)) {
+ throw new AAISchemaValidationException(errorMessage);
}
- if (!versions.contains(defaultVersion)) {
- throw new AAISchemaValidationException(
- "Invalid, default version is not in the api versions list"
- + ", please check schema.version.list and ensure that the"
- + " schema.version.api.default is in that list"
- );
+ if (!versionsValue.contains(defaultVersionValue)) {
+ throw new AAISchemaValidationException(errorMessage);
}
- if (!versions.contains(depthVersion)) {
- throw new AAISchemaValidationException(
- "Invalid, depth version is not in the api versions list"
- + ", please check schema.version.list and ensure that the"
- + " schema.version.depth.start is in that list"
- );
+ if (!versionsValue.contains(depthVersionValue)) {
+ throw new AAISchemaValidationException(errorMessage);
}
- if(!versions.contains(appRootVersion)){
- throw new AAISchemaValidationException(
- "Invalid, app root version is not in the api versions list"
- + ", please check schema.version.list and ensure that the"
- + " schema.version.app.root.start is in that list"
- );
+ if (!versionsValue.contains(appRootVersionValue)) {
+ throw new AAISchemaValidationException(errorMessage);
}
- if(!versions.contains(relatedLinkVersion)){
- throw new AAISchemaValidationException(
- "Invalid, related link version is not in the api versions list"
- + ", please check schema.version.list and ensure that the"
- + " schema.version.related.link.start is in that list"
- );
+ if (!versionsValue.contains(relatedLinkVersionValue)) {
+ throw new AAISchemaValidationException(errorMessage);
}
- if(!versions.contains(namespaceChangeVersion)){
- throw new AAISchemaValidationException(
- "Invalid, namespace change start version is not in the api versions list"
- + ", please check schema.version.list and ensure that the"
- + " schema.version.related.link.start is in that list"
- );
+ if (!versionsValue.contains(namespaceChangeVersionValue)) {
+ throw new AAISchemaValidationException(errorMessage);
}
}
-
+
public List<SchemaVersion> getVersions() {
- return versions;
+ return versionsValue;
}
public SchemaVersion getEdgeLabelVersion() {
- return edgeLabelVersion;
+ return edgeLabelVersionValue;
}
public SchemaVersion getDefaultVersion() {
- return defaultVersion;
+ return defaultVersionValue;
}
public SchemaVersion getDepthVersion() {
- return depthVersion;
+ return depthVersionValue;
}
- public SchemaVersion getAppRootVersion(){
- return appRootVersion;
+ public SchemaVersion getAppRootVersion() {
+ return appRootVersionValue;
}
- public SchemaVersion getRelatedLinkVersion(){
- return relatedLinkVersion;
+ public SchemaVersion getRelatedLinkVersion() {
+ return relatedLinkVersionValue;
}
public SchemaVersion getNamespaceChangeVersion() {
- return namespaceChangeVersion;
+ return namespaceChangeVersionValue;
}
public void setNamespaceChangeVersion(SchemaVersion namespaceChangeVersion) {
- this.namespaceChangeVersion = namespaceChangeVersion;
+ this.namespaceChangeVersionValue = namespaceChangeVersion;
}
}