Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configuration.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<repositories>
<repository active="true" default="true">http://exist-db.org/exist/apps/public-repo</repository>
<repository active="true" default="true">https://exist-db.org/exist/apps/public-repo</repository>
</repositories>
<readonly>
<package>http://exist-db.org/apps/existdb-packageservice</package>
Expand Down
4 changes: 2 additions & 2 deletions modules/config.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ declare variable $config:INSTALL-PACKAGE-PERMISSION := data(doc($config:app-root
declare variable $config:REMOVE-PACKAGE-PERMISSION := data(doc($config:app-root || "/configuration.xml")/settings/authorization/action[@name eq "remove-package"]/@required-level);
:)

(: ### default to first found entry of repository element for now - to be extended for multiple repos ### :)
declare variable $config:DEFAULT-REPO := xs:anyURI($config:SETTINGS//repository[1]);
(: the highlander says: there can only be one default repo :)
declare variable $config:DEFAULT-REPO := xs:anyURI($config:SETTINGS//repository[@default = "true"][1]);

(:~
: Resolve the given path using the current application context.
Expand Down
11 changes: 7 additions & 4 deletions modules/packages.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare option output:method "html5";
declare option output:media-type "text/html";

declare variable $packages:configuration := doc($config:app-root || "/configuration.xml");

declare variable $packages:repos := $packages:configuration//repository[@active='true'];
declare variable $packages:DEFAULTS := doc($config:app-root || "/defaults.xml")/apps;
declare variable $packages:ADMINAPPS := ["dashboard","backup"];
declare variable $packages:HIDE := ("dashboard");
Expand Down Expand Up @@ -101,8 +101,9 @@ declare function packages:get-remote-packages(){
};
:)

(:~ only return repos that are set to active :)
declare function packages:get-repo-locations(){
data($packages:configuration//repository)
data($packages:configuration//repository[@active = 'true'])
};


Expand Down Expand Up @@ -282,10 +283,12 @@ declare function packages:get-package-meta($app as xs:string, $name as xs:string
(: should be private but there seems to be a bug :)
declare function packages:public-repo-contents($installed as element(repo-app)*) {
try {
let $url := $config:DEFAULT-REPO || "/public/apps.xml?version=" || packages:get-version() ||
for $pkgs in $packages:repos
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rename this to $pkg as this will be an item() from the tuple stream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about $pkg-list I really would like to avoid using identical variable names for different things in the library

let $urls := $pkgs || "/public/apps.xml?version=" || packages:get-version() ||
"&amp;source=" || util:system-property("product-source")
(: EXPath client module does not work properly. No idea why. :)
let $request :=
let $request := for $url in $urls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This for doesn't make any sense to me. As a $pkg (or $pkgs) can only be an item() not a sequence. Therefore I think this for is redundant...

Copy link
Contributor Author

@duncdrum duncdrum Oct 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not redundant, without it the sequence of all packages is looked up in both repos, with 1 cannot find package error message for each package from repo a not present in repo b, and vice versa.

The for loop sends the request to the endpoint it should go to, the repo that contains the packages in question.

return
<http:request method="get" href="{$url}" timeout="10">
<http:header name="Cache-Control" value="no-cache"/>
</http:request>
Expand Down