Skip to content

Commit

Permalink
Merge pull request #69 from at88mph/refresh-fix
Browse files Browse the repository at this point in the history
Preserve path information.
  • Loading branch information
at88mph authored Jul 10, 2024
2 parents 3fb11be + b7b2b81 commit 42e48a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# tags with and without build number so operators use the versioned
# tag but we always keep a timestamped tag in case a semantic tag gets
# replaced accidentally
VER=0.2.4
VER=0.2.5
TAGS="${VER} ${VER}-$(date -u +"%Y%m%dT%H%M%S")"
unset VER
16 changes: 14 additions & 2 deletions src/main/java/org/opencadc/scienceportal/session/PostAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.RegistryClient;
import ca.nrc.cadc.rest.InlineContentHandler;
import ca.nrc.cadc.util.StringUtil;
import org.opencadc.scienceportal.ApplicationConfiguration;
import org.opencadc.scienceportal.SciencePortalAuthAction;

Expand All @@ -92,12 +93,23 @@ public class PostAction extends SciencePortalAuthAction {

@Override
public void doAction() throws Exception {
final URL apiURL = new URL(getAPIURL().toExternalForm() + PostAction.SESSION_ENDPOINT);
final StringBuilder apiURLBuilder = new StringBuilder(getAPIURL().toExternalForm() + PostAction.SESSION_ENDPOINT);

// Preserve path items.
final String path = this.syncInput.getPath();
if (StringUtil.hasText(path)) {
if (!path.trim().startsWith("/")) {
apiURLBuilder.append("/");
}

apiURLBuilder.append(path);
}

final URL apiURL = new URL(apiURLBuilder.toString());
final Subject authenticatedUser = getCurrentSubject(apiURL);
final Map<String, Object> payload = new HashMap<>();
payload.putAll(syncInput.getParameterNames().stream().collect(
Collectors.toMap(key -> key, key -> syncInput.getParameter(key))));

Subject.doAs(authenticatedUser, (PrivilegedExceptionAction<?>) () -> {
final HttpPost httpPost = new HttpPost(apiURL, payload, false);
httpPost.prepare();
Expand Down

0 comments on commit 42e48a5

Please sign in to comment.