b06111a1d0b28781b200d2d9ea9c6a2b335b2305
[smo/teiv.git] /
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2024 Ericsson
4  *  Modifications Copyright (C) 2024 OpenInfra Foundation Europe
5  *  ================================================================================
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21 package org.oran.smo.teiv.pgsqlgenerator;
22
23 import lombok.Getter;
24
25 @Getter
26 public class PgSchemaGeneratorException extends RuntimeException {
27     private PgSchemaGeneratorException(String errorMessage, Throwable err) {
28         super(errorMessage, err);
29     }
30
31     public static PgSchemaGeneratorException extractYangDataException(Exception ex) {
32         return new PgSchemaGeneratorException("Unable to load YAM!", ex);
33     }
34
35     public static PgSchemaGeneratorException prepareBaselineException(final String schemaName, Exception ex) { //
36         return new PgSchemaGeneratorException(String.format("%s : Failed to copy skeleton schema file!", schemaName), ex);
37     }
38
39     public static PgSchemaGeneratorException readBaselineException(final String schemaName, Exception ex) {
40         return new PgSchemaGeneratorException(String.format("%s : Failed to read baseline sql file!", schemaName), ex);
41     }
42
43     public static PgSchemaGeneratorException writeGeneratedSchemaException(final String schemaName, Exception ex) {
44         return new PgSchemaGeneratorException(String.format("%s :  data writing failed!", schemaName), ex);
45     }
46
47     public static PgSchemaGeneratorException generateSHA1HashException(Exception ex) {
48         return new PgSchemaGeneratorException("Error occurred while generating hash for hash_info table entry", ex);
49     }
50
51     public static PgSchemaGeneratorException extractMoTypeFromUrnException(final String urn, Exception ex) {
52         return new PgSchemaGeneratorException(String.format("Unable to extract Managed object from urn - %s", urn), ex);
53     }
54
55     public static PgSchemaGeneratorException assignModuleRefException(final String relationshipName, Exception ex) {
56         return new PgSchemaGeneratorException(String.format("ties.model : Unable to assign module reference to - %s",
57                 relationshipName), ex);
58     }
59
60     public static PgSchemaGeneratorException assignRelationshipDataLocation(final String relationshipName, Exception ex) {
61         return new PgSchemaGeneratorException(String.format(
62                 "Unable to assign RelationshipDataLocation to - %s, unknown cardinalities", relationshipName), ex);
63     }
64
65     public static PgSchemaGeneratorException nbcChangeIdentifiedException(String errorMsg, Exception ex) {
66         return new PgSchemaGeneratorException(String.format(
67                 "NBC change has been introduced: %s, please make sure you've enabled green-field installation!!%nFor more info please refer to README",
68                 errorMsg), ex);
69     }
70
71     public static PgSchemaGeneratorException readCustomSqlFileException(final String schemaName, Exception ex) {
72         return new PgSchemaGeneratorException(String.format("%s : Failed to read custom sql file!", schemaName), ex);
73     }
74
75 }