@@ -120,6 +120,7 @@ public static List<String> getPatchesFor(String category, String version, List<S
120
120
}
121
121
return results ;
122
122
}
123
+
123
124
/**
124
125
*
125
126
* @param patches A list of patches number
@@ -130,17 +131,30 @@ public static List<String> getPatchesFor(String category, String version, List<S
130
131
* @throws IOException when failed to access the aru api
131
132
*/
132
133
133
- public static void validatePatches (List <String > patches , String category , String version , String userId , String
134
+ public static boolean validatePatches (List <String > patches , String category , String version , String userId , String
134
135
password ) throws IOException {
135
136
136
- // TODO
137
+ StringBuffer payload = new StringBuffer
138
+ ("<conflict_check_request><platform>2000</platform><target_patch_list/>" );
139
+ String releaseNumber = getReleaseNumber (category , version , userId , password );
137
140
138
- // find the release number first based on the version
139
- // build the xml
140
- //String payload = null;
141
+ for (String patch : patches ) {
142
+ payload .append (String .format ("<candidate_patch_list rel_id=\" %s\" >%s</conflict_check_request>" ,
143
+ releaseNumber , patch ));
144
+ }
145
+ payload .append ("</conflict_check_request>" );
141
146
142
- // HttpUtil.checkConflicts(CONFLICTCHECKER_URL, payload, userId, password);
147
+ Document result = HttpUtil .checkConflicts (CONFLICTCHECKER_URL , payload . toString () , userId , password );
143
148
149
+ try {
150
+ NodeList conflictSets = XPathUtil .applyXPathReturnNodeList (result , "/conflict_sets" );
151
+ if (conflictSets .getLength () == 0 )
152
+ return true ;
153
+ } catch (XPathExpressionException xpe ) {
154
+ throw new IOException (xpe );
155
+
156
+ }
157
+ return false ;
144
158
}
145
159
146
160
private static Document getAllReleases (String category , String userId , String password ) throws IOException {
0 commit comments