@@ -101,11 +101,49 @@ Method UpdatePackagesFromOneUpLink() As %Status
101
101
While iter .%GetNext (.key , .package ) {
102
102
Do ..AddPackage (package )
103
103
}
104
- } Catch {
105
- Return 0
104
+ } Catch ex {
105
+ Do ex .Log ()
106
+ Return ex .AsStatus ()
107
+ }
108
+ }
109
+
110
+ Method FindPackageInOneUpLink (pkg As %String )
111
+ {
112
+ If ('..MatchAllowlist (pkg )) {
113
+ Return $$$ERROR($$$GeneralError, " invalid package name " _pkg )
114
+ }
115
+ Set httprequest = ..GetHttpRequest ()
116
+ Set searchStr = " packages/" _pkg
117
+ Set tSC = httprequest .Get (..Location _searchStr )
118
+ If ($$$ISERR(tSC )) { Return tSC }
119
+ Try {
120
+ Set package = {}.%FromJSON (httprequest .HttpResponse .Data )
121
+ Set iter = package .versions .%GetIterator ()
122
+ While iter .%GetNext (.key , .version ) {
123
+ set tPackage = {" name" :(package .name ), " description" :" " , " repository" :(package .repository ), " versions" :[(version )]}
124
+ Do ..AddPackage (tPackage )
125
+ }
126
+ } Catch ex {
127
+ Do ex .Log ()
128
+ Return ex .AsStatus ()
106
129
}
107
130
}
108
131
132
+ ClassMethod FindPackagInAllUpLinks (pkg As %String ) As %Status
133
+ {
134
+ Do ..ReadUplinksFromFile ()
135
+ Set sql = " SELECT ID FROM ZPM.UpLink WHERE Active = 1 ORDER BY Position"
136
+ Set statement = ##class (%SQL.Statement ).%New ()
137
+ Set tSC = statement .%Prepare (sql )
138
+ If $$$ISERR(tSC ) { Return tSC }
139
+ Set resultset =statement .%Execute ()
140
+ While resultset .%Next () {
141
+ Set uplink = ..%OpenId (resultset .ID )
142
+ Do uplink .FindPackageInOneUpLink (pkg )
143
+ }
144
+ Return $$$OK
145
+ }
146
+
109
147
ClassMethod LoadPackageFromAllUpLinks (pkg As %String = " " , version As %String = " " ) As ZPM .Package
110
148
{
111
149
Do ..ReadUplinksFromFile ()
@@ -145,6 +183,7 @@ Method LoadPackageFromOneUpLink(pPackage As ZPM.Package, pkg As %String = "", ve
145
183
$$$ThrowOnError(..LoadPackage (pPackage , pkg , version ))
146
184
$$$ThrowOnError(..LoadInstaller (pPackage , pkg , version ))
147
185
} Catch ex {
186
+ do ex .Log ()
148
187
Return ex .AsStatus ()
149
188
}
150
189
Return $$$OK
@@ -314,6 +353,7 @@ ClassMethod ReadUplinksFromFile() As %Status
314
353
}
315
354
}
316
355
} Catch ex {
356
+ do ex .Log ()
317
357
Set sc = ex .AsStatus ()
318
358
}
319
359
Return sc
@@ -366,7 +406,11 @@ ClassMethod AddUplink(name, url, allowList, position) As %Status
366
406
If $Data (tComponents (" port" ), port ), port '=" " {
367
407
Set tUplink .Port = port
368
408
}
369
- Set tUplink .Location = tComponents (" path" )
409
+ Set tPath = tComponents (" path" )
410
+ If ($EXTRACT (tPath ,*) = " /" ) {
411
+ Set tPath = $EXTRACT (tPath ,1 ,*-1 )
412
+ }
413
+ Set tUplink .Location = tPath
370
414
If $Get (tComponents (" scheme" ))=" https" {
371
415
Set tUplink .SSL = 1
372
416
}
0 commit comments