Skip to content

Commit 3d22484

Browse files
author
Johnny
committed
Add ValidationResult objects to hold conflict check results
Former-commit-id: cbd31411666830c43d5213671bd6212abc1214a5
1 parent 7cf9014 commit 3d22484

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

src/main/java/com/oracle/weblogicx/imagebuilder/builder/util/ARUUtil.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,25 @@ public static List<String> getPatchesFor(String category, String version, List<S
134134
return results;
135135
}
136136

137-
/**
137+
/** Validate patches conflicts by passing a list of patches
138138
*
139139
* @param patches A list of patches number
140140
* @param category wls or fmw
141141
* @param version version of the prduct
142142
* @param userId userid for support account
143143
* @param password password for support account
144+
* @return validationResult validation result object
144145
* @throws IOException when failed to access the aru api
145146
*/
146147

147-
public static boolean validatePatches(List<String> patches, String category, String version, String userId, String
148+
public static ValidationResult validatePatches(List<String> patches, String category, String version, String userId, String
148149
password) throws IOException {
149150

151+
152+
ValidationResult validationResult = new ValidationResult();
153+
validationResult.setSuccess(true);
154+
validationResult.setResults(null);
155+
150156
StringBuffer payload = new StringBuffer
151157
("<conflict_check_request><platform>2000</platform><target_patch_list/>");
152158
String releaseNumber = getReleaseNumber(category, version, userId, password);
@@ -161,7 +167,7 @@ public static boolean validatePatches(List<String> patches, String category, Str
161167

162168
try {
163169
NodeList conflictSets = XPathUtil.applyXPathReturnNodeList(result, "/conflict_sets");
164-
if (conflictSets.getLength() == 0) {
170+
if (conflictSets.getLength() > 0) {
165171

166172

167173
try {
@@ -189,7 +195,7 @@ public static boolean validatePatches(List<String> patches, String category, Str
189195
System.out.println("");
190196
XPathUtil.prettyPrint(doc);
191197

192-
return true;
198+
validationResult.setResults(doc);
193199

194200

195201
} catch (XPathExpressionException | ParserConfigurationException xpe) {
@@ -202,7 +208,7 @@ public static boolean validatePatches(List<String> patches, String category, Str
202208
throw new IOException(xpe);
203209

204210
}
205-
return false;
211+
return validationResult;
206212
}
207213

208214
/**
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.oracle.weblogicx.imagebuilder.builder.util;
2+
3+
import org.w3c.dom.Document;
4+
5+
/**
6+
* ValidaitonResult of patch conflicts check
7+
*/
8+
9+
public class ValidationResult {
10+
private boolean success;
11+
private Document results;
12+
13+
/**
14+
*
15+
* @return true if no conflicts ; false if there is conflicts
16+
*
17+
*/
18+
public boolean isSuccess() {
19+
return success;
20+
}
21+
22+
public void setSuccess(boolean success) {
23+
this.success = success;
24+
}
25+
26+
/**
27+
*
28+
* @return dom document detailing about the conflicts
29+
*/
30+
public Document getResults() {
31+
return results;
32+
}
33+
34+
public void setResults(Document results) {
35+
this.results = results;
36+
}
37+
}

0 commit comments

Comments
 (0)