1
1
package com .oracle .weblogicx .imagebuilder .builder .util ;
2
2
3
3
import java .io .IOException ;
4
+ import java .util .List ;
4
5
5
6
import javax .xml .parsers .DocumentBuilder ;
6
7
import javax .xml .parsers .DocumentBuilderFactory ;
9
10
10
11
import org .w3c .dom .Document ;
11
12
import org .w3c .dom .Element ;
12
- import org .w3c .dom .Node ;
13
13
import org .w3c .dom .NodeList ;
14
14
15
15
public class ARUUtil {
@@ -19,8 +19,37 @@ public void getAllWLSReleases(String userId, String password) throws IOException
19
19
getAllReleases ("wls" , userId , password );
20
20
}
21
21
22
- public void getLatestWLSPatches (String version , String userId , String password ) throws IOException {
23
- getLatestReleases ("wls" , version , userId , password );
22
+ public void getLatestWLSPatches (String release , String userId , String password ) throws IOException {
23
+ getLatestPSU ("wls" , release , userId , password );
24
+ }
25
+
26
+ public void getPatches (String category , List <String > patches , String userId , String password ) throws IOException {
27
+ for (String patch : patches )
28
+ getPatch ("wls" , patch , userId , password );
29
+ }
30
+
31
+ public void validatePatches (List <String > patches , String category , String version ) {
32
+
33
+ // TODO
34
+
35
+ // find the release number first based on the version
36
+ // build the xml
37
+
38
+ // <conflict_check_request>
39
+ // <platform>912</platform>
40
+ // <target_patch_list>
41
+ // <installed_patch/>
42
+ // </target_patch_list>
43
+ // <candidate_patch_list>
44
+ // <patch_group rel_id="80111060" language_id="0">7044721</patch_group>
45
+ // <patch_group rel_id="80111060" language_id="0">7156923</patch_group>
46
+ // <patch_group rel_id="80111060" language_id="0">7210195</patch_group>
47
+ // <patch_group rel_id="80111060" language_id="0">7256747</patch_group>
48
+ // </candidate_patch_list>
49
+ //</conflict_check_request>
50
+
51
+ // Run against POST /Orion/Services/conflict_checks
52
+
24
53
}
25
54
26
55
private Document getAllReleases (String category , String userId , String password ) throws IOException {
@@ -29,7 +58,7 @@ private Document getAllReleases(String category, String userId, String password)
29
58
// "https://updates.oracle.com/Orion/Services/metadata?table=aru_releases" -o allarus.xml)
30
59
31
60
Document allReleases = HttpUtil .getXMLContent ("https://updates.oracle"
32
- + ".com/Orion/Services/metadata?table=aru_releases" );
61
+ + ".com/Orion/Services/metadata?table=aru_releases" , userId , password );
33
62
34
63
try {
35
64
@@ -62,31 +91,60 @@ private Document getAllReleases(String category, String userId, String password)
62
91
63
92
}
64
93
65
- private void getLatestReleases (String category , String version , String userId , String password ) throws IOException {
94
+ private void getLatestPSU (String category , String release , String userId , String password ) throws IOException {
66
95
67
96
// HTTP_STATUS=$(curl -v -w "%{http_code}" -b cookies.txt -L --header 'Authorization: Basic ${basicauth}' "https://updates.oracle.com/Orion/Services/search?product=15991&release=$releaseid&include_prereqs=true" -o latestpsu.xml)
68
97
69
98
70
99
Document allPatches = HttpUtil .getXMLContent ("https://updates.oracle"
71
- + ".com/Orion/Services/search?product=15991&release=" + version );
100
+ + ".com/Orion/Services/search?product=15991&release=" + release , userId , password );
101
+
102
+ savepatch (allPatches , userId , password );
103
+ }
104
+
105
+ private void getPatch (String category , String patchNumber , String userId , String password ) throws IOException {
106
+
107
+ // HTTP_STATUS=$(curl -v -w "%{http_code}" -b cookies.txt -L --header 'Authorization: Basic ${basicauth}' "https://updates.oracle.com/Orion/Services/search?product=15991&release=$releaseid&include_prereqs=true" -o latestpsu.xml)
108
+
109
+
110
+ Document allPatches = HttpUtil .getXMLContent ("https://updates.oracle"
111
+ + ".com/Orion/Services/search?product=15991&bug=" + patchNumber , userId , password );
112
+
113
+ savepatch (allPatches , userId , password );
114
+
115
+
116
+
117
+ }
72
118
119
+ private void savepatch (Document allPatches , String userId , String password ) throws IOException {
73
120
try {
121
+
122
+ // TODO: needs to make sure there is one and some filtering if not sorting
123
+
74
124
String downLoadLink = XPathUtil .applyXPathReturnString (allPatches , "string"
75
125
+ "(/results/patch[1]/files/file/download_url/text())" );
76
126
77
127
String doloadHost = XPathUtil .applyXPathReturnString (allPatches , "string"
78
128
+ "(/results/patch[1]/files/file/download_url/@host)" );
79
129
130
+ String bugname = XPathUtil .applyXPathReturnString (allPatches , "string"
131
+ + "(/results/patch[1]/name" );
132
+
133
+ // TODO find the download location
134
+
135
+ String fileName = bugname + ".zip" ;
80
136
81
- HttpUtil .downloadFile (doloadHost +downLoadLink , "todo" );
137
+ HttpUtil .downloadFile (doloadHost +downLoadLink , fileName , userId , password );
138
+
139
+ // TODO need method to update the cache data table ?
82
140
83
141
} catch (XPathExpressionException xpe ) {
84
142
throw new IOException (xpe );
85
143
}
86
144
145
+ }
87
146
88
147
89
- }
90
148
91
149
}
92
150
0 commit comments