@@ -10,22 +10,22 @@ XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
10
10
<!-- Server Info -->
11
11
<Route Url =" /" Method =" GET" Call =" GetInfo" Cors =" true" />
12
12
<Route Url =" /_ping" Method =" GET" Call =" Ping" Cors =" true" />
13
-
13
+
14
14
<!-- Reset registry for debug purposes , limited access -->
15
15
<Route Url =" /_reset" Method =" GET" Call =" Reset" Cors =" true" />
16
-
16
+
17
17
<!-- Swagger specs -->
18
18
<Route Url =" /_spec" Method =" GET" Call =" SwaggerSpec" Cors =" true" />
19
-
19
+
20
20
<!-- All packages -->
21
21
<Route Url =" /packages/-/all" Method =" GET" Call =" AllPackages" Cors =" true" />
22
-
22
+
23
23
<!-- Package manifest -->
24
24
<Route Url =" /packages/:package/:version/:platformVersion/manifest" Method =" GET" Call =" PackageManifest" Cors =" true" />
25
25
<Route Url =" /packages/:package/:version/manifest" Method =" GET" Call =" PackageManifest" Cors =" true" />
26
26
<!-- Package installer -->
27
27
<Route Url =" /packages/:package/:version/installer" Method =" GET" Call =" PackageInstaller" Cors =" true" />
28
-
28
+
29
29
<!-- Package information -->
30
30
<Route Url =" /packages/:package/?" Method =" GET" Call =" Package" Cors =" true" />
31
31
<!-- Package information with specified version -->
@@ -36,7 +36,7 @@ XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
36
36
<Route Url =" /packages" Method =" POST" Call =" PublishPackage" Cors =" true" />
37
37
<!-- Unpublish Package -->
38
38
<Route Url =" /packages/:package/:version" Method =" Delete" Call =" UnPublishPackageVersion" Cors =" true" />
39
-
39
+
40
40
<!-- Package Archive -->
41
41
<Route Url =" /download/:package/:platformVersion/:file" Method =" GET" Call =" GetArchive" Cors =" true" />
42
42
<!-- <Route Url =" /download/:package/-/:file" Method =" GET" Call =" GetArchive" Cors =" true" /> -->
@@ -45,7 +45,7 @@ XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
45
45
<!-- Temp url , update package , should be combined with " POST /packages" -->
46
46
<Route Url =" /package" Method =" POST" Call =" UpdatePackage" Cors =" true" />
47
47
48
-
48
+
49
49
<!-- Analytics -->
50
50
<Route Url =" /collect/:action" Method =" POST" Call =" CollectAnalytics" Cors =" true" />
51
51
@@ -137,7 +137,7 @@ ClassMethod Package(pkg As %String = "", version As %String = "", platformVersio
137
137
138
138
ClassMethod PackageManifest (pkg As %String = " " , version As %String = " " , platformVersion As %String = " " ) As %Status
139
139
{
140
- Set pkg = $$$lcase(pkg )
140
+ Set pkg = $$$lcase(pkg )
141
141
Set version = ##class (ZPM.Package ).VersionFind (pkg , version )
142
142
If (version = " " ) {
143
143
Return ..ReportHttpStatusCode (..#HTTP404NOTFOUND)
@@ -159,7 +159,7 @@ ClassMethod PackageManifest(pkg As %String = "", version As %String = "", platfo
159
159
160
160
ClassMethod PackageInstaller (pkg As %String = " " , version As %String = " " ) As %Status
161
161
{
162
- Set pkg = $$$lcase(pkg )
162
+ Set pkg = $$$lcase(pkg )
163
163
Set version = ##class (ZPM.Package ).VersionFind (pkg , version )
164
164
If (version = " " ) {
165
165
Return ..ReportHttpStatusCode (..#HTTP404NOTFOUND)
@@ -185,15 +185,28 @@ ClassMethod OptionsPackageVersion(pkg As %String = "", version As %String = "")
185
185
Set settingsFile = ##class (ZPM.Settings ).%New ()
186
186
Set tSCAuth = ##class (ZPM.Owner ).IsAuth ()
187
187
Set pkg = $$$lcase(pkg )
188
- Set tSCOwner = ##class (ZPM.Owner ).IsOwner (pkg )
188
+
189
+ If ('##class (ZPM.Package ).NameExists (pkg )) {
190
+ Do %response .SetHeader (" ALLOW" ,options )
191
+ Return $$$OK
192
+ }
193
+
194
+ If ( ($$$lcase(version )'=" all" ) && '##class (ZPM.Package ).NameVersionExists (pkg , version ) ) {
195
+ // version doesn't exit
196
+ Do %response .SetHeader (" ALLOW" ,options )
197
+ Return $$$OK
198
+ }
199
+
200
+ Set tSCOwner = ##class (ZPM.Owner ).IsOwner (pkg , " delete" )
201
+
189
202
If $$$ISOK(tSCAuth ),$$$ISOK(tSCOwner ),settingsFile .GetDeleteEnable () {
190
203
Set options = options _" ,DELETE"
191
204
}
192
205
Do %response .SetHeader (" ALLOW" ,options )
193
206
Return $$$OK
194
207
}
195
208
196
- /// Unpublish (delete) directly published package version
209
+ /// Unpublish (delete) directly published package version
197
210
ClassMethod UnPublishPackageVersion (pkg As %String = " " , version As %String = " " ) As %Status
198
211
{
199
212
Set tSC = $$$OK
@@ -206,7 +219,7 @@ ClassMethod UnPublishPackageVersion(pkg As %String = "", version As %String = ""
206
219
Return ..ReportHttpStatusCode (..#HTTP403FORBIDDEN, $$$ERROR(5001 ," Delete not allowed for this registry" ))
207
220
}
208
221
Set pkg = $$$lcase(pkg )
209
- Set tSC = ##class (ZPM.Owner ).IsOwner (pkg )
222
+ Set tSC = ##class (ZPM.Owner ).IsOwner (pkg , " delete " )
210
223
If ($$$ISERR(tSC )) {
211
224
Return ..ReportHttpStatusCode (..#HTTP403FORBIDDEN, tSC )
212
225
}
@@ -252,22 +265,23 @@ ClassMethod PublishPackage() As %Status
252
265
If (%request .ContentType '= ..#CONTENTTYPEJSON) {
253
266
Return ..ReportHttpStatusCode (..#HTTP400BADREQUEST)
254
267
}
255
-
268
+
256
269
If ##class (ZPM.Package ).NameVersionExists (name , version , .id ) {
257
- Set package = ##class (ZPM.Package ).%OpenId (id )
270
+ Set package = ##class (ZPM.Package ).%OpenId (id )
271
+ Set package .UpLink = " "
258
272
}
259
273
Else {
260
- Set package = ##class (ZPM.Package ).%New ()
274
+ Set package = ##class (ZPM.Package ).%New ()
261
275
}
262
276
263
277
$$$ThrowOnError(package .%JSONImport (%request .Content ))
264
278
$$$ThrowOnError(package .UpdateDescriptionFromManifest ())
265
279
If deployed {
266
280
If ##class (ZPM.DeployedPackage ).NameVersionPlatformExists (name , version , platformVersion , .id ) {
267
- Set deployedPackage = ##class (ZPM.DeployedPackage ).%OpenId (id , , .tSC )
281
+ Set deployedPackage = ##class (ZPM.DeployedPackage ).%OpenId (id , , .tSC )
268
282
}
269
283
Else {
270
- Set deployedPackage = ##class (ZPM.DeployedPackage ).%New ()
284
+ Set deployedPackage = ##class (ZPM.DeployedPackage ).%New ()
271
285
}
272
286
$$$ThrowOnError(deployedPackage .%JSONImport (%request .Content ))
273
287
$$$ThrowOnError(deployedPackage .manifest .CopyFrom (package .manifest ))
@@ -289,7 +303,7 @@ ClassMethod PublishPackage() As %Status
289
303
290
304
ClassMethod UpdatePackage () As %Status
291
305
{
292
- If (%request .ContentType '= ..#CONTENTTYPEJSON) {
306
+ If (%request .ContentType '= ..#CONTENTTYPEJSON) {
293
307
Return ..ReportHttpStatusCode (..#HTTP400BADREQUEST)
294
308
}
295
309
Return ##class (ZPM.Package ).UpdatePackage (%request .Content )
@@ -341,11 +355,11 @@ ClassMethod AllPackages() As %Status
341
355
Set searchTerms = [].%FromJSON (%request .Get (" q" ))
342
356
} Catch ex {}
343
357
$$$ThrowOnError(##class (ZPM.UpLink ).UpdatePackagesFromAllUpLinks ())
344
-
358
+
345
359
Set manifest = %request .Get (" manifest" ," " )
346
360
Set allVersions = %request .Get (" allVersions" ," " )
347
361
Set owner = ##class (ZPM.Owner ).GetId ()
348
- Set tList = ##class (ZPM.Package ).GetLatest (searchTerms , manifest , allVersions , owner , .tSC )
362
+ Set tList = ##class (ZPM.Package ).GetLatest (searchTerms , manifest , allVersions , owner , .tSC )
349
363
350
364
If ($$$ISERR(tSC )) {
351
365
Return ..ReportHttpStatusCode (..#HTTP400BADREQUEST, tSC )
@@ -355,17 +369,17 @@ ClassMethod AllPackages() As %Status
355
369
356
370
ClassMethod CollectAnalytics (action As %String = " " ) As %Status
357
371
{
358
- If (%request .ContentType '= ..#CONTENTTYPEJSON) {
372
+ If (%request .ContentType '= ..#CONTENTTYPEJSON) {
359
373
Return ..ReportHttpStatusCode (..#HTTP400BADREQUEST)
360
374
}
361
- If (action = " " ) {
375
+ If (action = " " ) {
362
376
Return ..ReportHttpStatusCode (..#HTTP404NOTFOUND)
363
377
}
364
378
Set token = %request .GetCgiEnv (" HTTP_INSTALLTOKEN" )
365
379
If token '=" " , $Data (^IRIS .TempZPMRInst (token )) {
366
380
Kill ^IRIS .TempZPMRInst (token )
367
381
Return ##class (ZPM.Analytics.Event ).SaveEvent (action , ..GetRemoteAddr (), %request .Content )
368
- }
382
+ }
369
383
Return $$$ERROR(5001 , " Invalid token" )
370
384
}
371
385
0 commit comments