From 375fef4559a49b937fe757e228ad284b2910de46 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Fri, 15 Mar 2024 15:13:29 -0700 Subject: [PATCH 1/3] Added Dockerfile to build image that will build Science Portal. --- Dockerfile.build | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Dockerfile.build diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..edab93b --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,16 @@ +ARG JAVA_VERSION=8 + +FROM gradle:7-jdk${JAVA_VERSION} as builder + +RUN apt update \ + && apt install -y rsync xz-utils + +ADD https://nodejs.org/dist/v18.18.0/node-v18.18.0-linux-x64.tar.xz /tmp/ + +RUN cd /tmp/ \ + && tar xvf node-v18.18.0-linux-x64.tar.xz \ + && rsync -arvc node-v18.18.0-linux-x64/* /usr/local/ + +FROM gradle:7-jdk${JAVA_VERSION} + +COPY --from=builder /usr/local/ /usr/local/ From 491328175a1d0f0666d6708549e28053934c5e8e Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Mon, 13 May 2024 13:17:57 -0700 Subject: [PATCH 2/3] Cleanup before merging to master. --- public/dev/js/science_portal.js | 17 +++++++--------- public/dev/js/science_portal_core.js | 30 +--------------------------- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/public/dev/js/science_portal.js b/public/dev/js/science_portal.js index f026050..66cd3b8 100644 --- a/public/dev/js/science_portal.js +++ b/public/dev/js/science_portal.js @@ -96,7 +96,7 @@ // Nothing happens if user is not authenticated, so no other page // load information is done until this call comes back (see onAuthenticated event below) // onAuthenticated event triggered if everything is OK. - portalCore.checkAuthentication(_selfPortalApp.isDev) + portalCore.checkAuthentication() } function attachListeners() { @@ -224,7 +224,7 @@ portalSessions.loadPlatformUsage(_selfPortalApp.handlePlatformUsage) } - function handleSessionActionError(e, request) { + function handleSessionActionError(_e, request) { portalCore.setAjaxFail(portalCore.pageSections.sessionList, request) } @@ -247,11 +247,9 @@ } function populateSessionList(sessionData) { - var $sessionListDiv = $("#sp_session_list") - if (JSON.stringify(sessionData) === "[]") { // Pass list to the react app portion for rendering - var sessDataObj = { + const sessDataObj = { "listType" : "empty", "sessData" : [] } @@ -260,13 +258,13 @@ // Build new list // Assuming a list of sessions is provided, with connect url, name, type - var newSessionList = new Array() + const newSessionList = [] $(sessionData).each(function () { var mapEntry = portalForm.getMapEntry(this.type) // Check to see if there are any items in the sessionType_map that // may override the defaults - var iconSrc= _selfPortalApp.baseURL + "/science-portal/images/" + var iconSrc = _selfPortalApp.baseURL + "/science-portal/images/" if (mapEntry != null) { if (typeof mapEntry.portal_icon != "undefined") { iconSrc += mapEntry.portal_icon @@ -281,7 +279,7 @@ } } - var nextSessionItem = { + const nextSessionItem = { "id" : this.id, "name" : this.name, "status": this.status, @@ -308,11 +306,10 @@ // Add to the list newSessionList.push(nextSessionItem) - }) // Pass list to the react app portion for rendering - var sessDataObj = { + const sessDataObj = { "listType" : "list", "sessData" : newSessionList } diff --git a/public/dev/js/science_portal_core.js b/public/dev/js/science_portal_core.js index dbab723..8bc0840 100644 --- a/public/dev/js/science_portal_core.js +++ b/public/dev/js/science_portal_core.js @@ -348,12 +348,7 @@ // ------------ Authentication functions ------------ - function checkAuthentication(isDev) { - // From cadc.user.js. Listens for when user logs in - // _selfPortalCore.userManager.subscribe(cadc.web.events.onUserLoad, - // function (_event, data) { - // // Check to see if user is logged in or not - // if (typeof(data.error) !== "undefined") { + function checkAuthentication() { fetch(baseURL + cadc.web.science.portal.core.userInfoEndpoint) .then((response) => { if (!response.ok) { @@ -377,29 +372,6 @@ }).catch((error) => { console.warn(error) }) - // hideModal() - // var userState = { - // loginHandler : portalLogin.handleLoginRequest - // } - // _rApp.setNotAuthenticated(userState) - // } else { - // // Don't directly access react app from here so this - // // function can be connected to the portalLogin - // // cadc.web.science.portal.login.events.onAuthenticateOK event as well. - // // That event is fired after the login form is submitted. - // setAuthenticated() - // } - // }) - - // if (isDev === true) { - // _selfPortalCore.userManager.user = {name: "dev user"} - // setAuthenticated() - // } else { - // // Call the whoami endpoint to get the user details - // // if they are not logged in, same event is thrown, return payload - // // needs to be checked - // _selfPortalCore.userManager.loadCurrent() - // } } function setAuthenticated() { From 3033cc94a72780662b7baa06c4b5ccc366bd7a04 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 13 Jun 2024 10:15:33 -0700 Subject: [PATCH 3/3] Update to include session ID in URL. --- Dockerfile.build | 2 +- .../org/opencadc/scienceportal/session/GetAction.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile.build b/Dockerfile.build index edab93b..7176810 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -1,4 +1,4 @@ -ARG JAVA_VERSION=8 +ARG JAVA_VERSION=11 FROM gradle:7-jdk${JAVA_VERSION} as builder diff --git a/src/main/java/org/opencadc/scienceportal/session/GetAction.java b/src/main/java/org/opencadc/scienceportal/session/GetAction.java index a0f12c5..f591e53 100644 --- a/src/main/java/org/opencadc/scienceportal/session/GetAction.java +++ b/src/main/java/org/opencadc/scienceportal/session/GetAction.java @@ -71,6 +71,7 @@ import ca.nrc.cadc.auth.AuthMethod; import ca.nrc.cadc.reg.Standards; import ca.nrc.cadc.reg.client.RegistryClient; +import ca.nrc.cadc.util.StringUtil; import org.opencadc.scienceportal.ApplicationConfiguration; import org.opencadc.scienceportal.SciencePortalAuthGetAction; @@ -82,7 +83,13 @@ public class GetAction extends SciencePortalAuthGetAction { @Override protected String getEndpoint() { - return GetAction.SESSION_ENDPOINT; + final String path = this.syncInput.getPath(); + if (StringUtil.hasText(path)) { + final String trimPath = path.trim(); + return GetAction.SESSION_ENDPOINT + (trimPath.startsWith("/") ? path : "/" + path); + } else { + return GetAction.SESSION_ENDPOINT; + } } @Override