2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.sdc.toscaparser.api;
23 import org.onap.sdc.toscaparser.api.common.JToscaValidationIssue;
24 import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
26 public class UnsupportedType {
28 // Note: TOSCA spec version related
31 The tosca.nodes.Storage.ObjectStorage and tosca.nodes.Storage.BlockStorage
32 used here as un_supported_types are part of the name changes in TOSCA spec
33 version 1.1. The original name as specified in version 1.0 are,
34 tosca.nodes.BlockStorage and tosca.nodes.ObjectStorage which are supported
35 by the tosca-parser. Since there are little overlapping in version support
36 currently in the tosca-parser, the names tosca.nodes.Storage.ObjectStorage
37 and tosca.nodes.Storage.BlockStorage are used here to demonstrate the usage
38 of un_supported_types. As tosca-parser move to provide support for version
39 1.1 and higher, they will be removed.
42 private UnsupportedType() {
45 private static final String[] UNSUPPORTED_TYPES = {
46 "tosca.test.invalidtype",
47 "tosca.nodes.Storage.ObjectStorage",
48 "tosca.nodes.Storage.BlockStorage"};
50 public static boolean validateType(String entityType) {
51 for (String ust : UNSUPPORTED_TYPES) {
52 if (ust.equals(entityType)) {
53 ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE251", String.format(
54 "UnsupportedTypeError: Entity type \"%s\" is not supported", entityType)));
64 from toscaparser.common.exception import ValidationIssueCollector
65 from toscaparser.common.exception import UnsupportedTypeError
66 from toscaparser.utils.gettextutils import _
68 log = logging.getLogger('tosca')
71 class UnsupportedType(object):
73 """Note: TOSCA spec version related
75 The tosca.nodes.Storage.ObjectStorage and tosca.nodes.Storage.BlockStorage
76 used here as un_supported_types are part of the name changes in TOSCA spec
77 version 1.1. The original name as specified in version 1.0 are,
78 tosca.nodes.BlockStorage and tosca.nodes.ObjectStorage which are supported
79 by the tosca-parser. Since there are little overlapping in version support
80 currently in the tosca-parser, the names tosca.nodes.Storage.ObjectStorage
81 and tosca.nodes.Storage.BlockStorage are used here to demonstrate the usage
82 of un_supported_types. As tosca-parser move to provide support for version
83 1.1 and higher, they will be removed.
85 un_supported_types = ['tosca.test.invalidtype',
86 'tosca.nodes.Storage.ObjectStorage',
87 'tosca.nodes.Storage.BlockStorage']
93 def validate_type(entitytype):
94 if entitytype in UnsupportedType.un_supported_types:
95 ValidationIssueCollector.appendException(UnsupportedTypeError(