Skip to content

Commit f7e63e4

Browse files
Jira wdt 400 version file in zip file (#596)
* Fix java.lang.Boolean issues for ActiveDirectoryAuthenticator * add version file to zip * Throw exception on duplicate entry
1 parent c6bb9c2 commit f7e63e4

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

core/src/main/java/oracle/weblogic/deploy/json/AbstractJsonTranslator.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.json;
@@ -9,6 +9,7 @@
99
import java.util.ArrayDeque;
1010
import java.util.Deque;
1111

12+
import oracle.weblogic.deploy.exception.ExceptionHelper;
1213
import oracle.weblogic.deploy.logging.PlatformLogger;
1314
import oracle.weblogic.deploy.util.PyOrderedDict;
1415
import oracle.weblogic.deploy.util.StringUtils;
@@ -17,6 +18,7 @@
1718
import org.antlr.v4.runtime.CharStreams;
1819
import org.antlr.v4.runtime.CommonTokenStream;
1920
import org.antlr.v4.runtime.atn.PredictionMode;
21+
import org.antlr.v4.runtime.misc.ParseCancellationException;
2022
import org.antlr.v4.runtime.tree.ParseTree;
2123
import org.antlr.v4.runtime.tree.ParseTreeWalker;
2224
import org.python.core.Py;
@@ -114,6 +116,7 @@ public void exitPair(JSONParser.PairContext ctx) {
114116
*/
115117
@Override
116118
public void enterJsonObject(JSONParser.JsonObjectContext ctx) {
119+
String METHOD = "enterJsonObject";
117120
if (currentPairName.isEmpty()) {
118121
// This should only happen for the outermost object that the file defines.
119122
//
@@ -128,6 +131,15 @@ public void enterJsonObject(JSONParser.JsonObjectContext ctx) {
128131
} else {
129132
newObjectDict = new PyDictionary();
130133
}
134+
135+
String name = currentPairName.peek();
136+
if (currentDict.peek().has_key(new PyString(name))) {
137+
String message = ExceptionHelper.getMessage("WLSDPLY-18028", name);
138+
ParseCancellationException ex =
139+
new ParseCancellationException(message);
140+
getLogger().throwing(getClassName(), METHOD, ex);
141+
throw ex;
142+
}
131143
currentDict.push(newObjectDict);
132144
currentValueType.push(ValueType.OBJECT);
133145
}

core/src/main/java/oracle/weblogic/deploy/json/JsonTranslator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.json;
@@ -12,6 +12,7 @@
1212
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
1313
import oracle.weblogic.deploy.util.FileUtils;
1414

15+
import org.antlr.v4.runtime.misc.ParseCancellationException;
1516
import org.python.core.PyDictionary;
1617

1718
/**
@@ -59,7 +60,7 @@ public PyDictionary parse() throws JsonException {
5960
PyDictionary result;
6061
try (FileInputStream fis = new FileInputStream(jsonFile)) {
6162
result = parseInternal(jsonFile.getPath(), fis);
62-
} catch (IOException ioe) {
63+
} catch (IOException | ParseCancellationException ioe) {
6364
JsonException ex =
6465
new JsonException("WLSDPLY-18007", ioe, "JSON", jsonFile.getPath(), ioe.getLocalizedMessage());
6566
LOGGER.throwing(CLASS, METHOD, ex);

core/src/main/java/oracle/weblogic/deploy/yaml/AbstractYamlTranslator.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.ArrayDeque;
1111
import java.util.Deque;
1212

13+
import oracle.weblogic.deploy.exception.ExceptionHelper;
1314
import oracle.weblogic.deploy.logging.PlatformLogger;
1415
import oracle.weblogic.deploy.util.PyOrderedDict;
1516
import oracle.weblogic.deploy.util.StringUtils;
@@ -20,6 +21,7 @@
2021
import org.antlr.v4.runtime.atn.PredictionMode;
2122
import org.antlr.v4.runtime.tree.ParseTree;
2223
import org.antlr.v4.runtime.tree.ParseTreeWalker;
24+
import org.antlr.v4.runtime.misc.ParseCancellationException;
2325
import org.python.core.Py;
2426
import org.python.core.PyDictionary;
2527
import org.python.core.PyFloat;
@@ -119,15 +121,22 @@ public void enterYamlListItemObject(YamlParser.YamlListItemObjectContext ctx) {
119121
*/
120122
@Override
121123
public void enterObject(YamlParser.ObjectContext ctx) {
124+
String METHOD = "enterObject";
122125
String name = getQuotedStringText(ctx.name().getText());
123126
PyDictionary objDict;
124127
if (useOrderedDict) {
125128
objDict = new PyOrderedDict();
126129
} else {
127130
objDict = new PyDictionary();
128131
}
129-
130132
PyDictionary container = currentDict.peek();
133+
if (container.has_key(new PyString(name))) {
134+
String message = ExceptionHelper.getMessage("WLSDPLY-18028", name);
135+
ParseCancellationException ex =
136+
new ParseCancellationException(message);
137+
getLogger().throwing(getClassName(), METHOD, ex);
138+
throw ex;
139+
}
131140
container.__setitem__(new PyString(name), objDict);
132141
currentDict.push(objDict);
133142

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,7 @@ WLSDPLY-18015=File {0} does not appear to be a valid file for JSON output: {1}
12511251
WLSDPLY-18016=An error occurred while closing the JSON file output stream...continuing: {0}
12521252
WLSDPLY-18017=The {0} parser encountered {1} error(s) while parsing {2}
12531253

1254+
12541255
# oracle.weblogic.deploy.util.ParsingErrorListener.java
12551256
WLSDPLY-18018=Parse error for file {0} at line {1} position {2}: {3}
12561257
WLSDPLY-18019=Parser reported ambiguous decision {0} from alternatives {1} while parsing "{2}" from file {3}
@@ -1263,6 +1264,7 @@ WLSDPLY-18024=Detected integer value {0} that could not be parsed to an integer
12631264
WLSDPLY-18025=Detected float value {0} that could not be parsed to a floating point number so it will be set to 0: {1}
12641265
WLSDPLY-18026=Detected number field with an empty value so it will be set to 0
12651266
WLSDPLY-18027=Element {0} has an unknown value type {1} so its value will be set to None
1267+
WLSDPLY-18028=Unable to parse the model file because it contains a duplicate category entry {0}
12661268

12671269
###############################################################################
12681270
# Tool Util Messages (19000 - 19999) #

0 commit comments

Comments
 (0)