Skip to content

Commit f9b0ec9

Browse files
authored
Merge pull request #268 from pdowler/main
cadc-rest: capture multiple inline content objects with same name
2 parents 4eb2ee7 + fe43f27 commit f9b0ec9

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

.github/workflows/gradle.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ jobs:
3535
- name: build and test cadc-vodml
3636
run: cd cadc-vodml && ../gradlew --info clean build javadoc checkstyleMain install
3737

38-
- name: build and test cadc-test-servlet
39-
run: cd cadc-test-servlet && ../gradlew --info clean build javadoc
40-
4138
- name: build and test cadc-http-client
4239
run: cd cadc-http-client && ../gradlew --info clean build
4340

cadc-log/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ repositories {
99
mavenLocal()
1010
}
1111

12-
sourceCompatibility = 1.8
12+
sourceCompatibility = 11
1313

1414
group = 'org.opencadc'
1515

16-
version = '1.2.2'
16+
version = '1.2.3'
1717

1818
description = 'OpenCADC Logging Init server library'
1919
def git_url = 'https://github.com/opencadc/core'

cadc-rest/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ repositories {
1111

1212
apply from: '../opencadc.gradle'
1313

14-
sourceCompatibility = 1.8
14+
sourceCompatibility = 11
1515

1616
group = 'org.opencadc'
1717

18-
version = '1.4.5'
18+
version = '1.4.6'
1919

2020
description = 'OpenCADC REST server library'
2121
def git_url = 'https://github.com/opencadc/core'
@@ -25,7 +25,7 @@ dependencies {
2525
api 'commons-io:commons-io:[2.18.0,3.0)' // force this because of CVE-2024-47554
2626
implementation 'javax.servlet:javax.servlet-api:3.1.0'
2727
implementation 'org.opencadc:cadc-util:[1.12.4,2.0)'
28-
implementation 'org.opencadc:cadc-registry:[1.7,)'
28+
implementation 'org.opencadc:cadc-registry:[1.8.0,)'
2929

30-
testCompile 'junit:junit:4.13'
30+
testImplementation 'junit:junit:4.13'
3131
}

cadc-rest/src/main/java/ca/nrc/cadc/rest/RestAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
import ca.nrc.cadc.net.ResourceLockedException;
8282
import ca.nrc.cadc.net.ResourceNotFoundException;
8383
import ca.nrc.cadc.net.TransientException;
84-
import ca.nrc.cadc.reg.client.RegistryClient;
8584
import ca.nrc.cadc.util.StringUtil;
8685
import java.io.IOException;
8786
import java.io.OutputStream;

cadc-rest/src/main/java/ca/nrc/cadc/rest/SyncInput.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ public SyncInput(HttpServletRequest request, InlineContentHandler handler)
120120
}
121121
}
122122
}
123+
124+
// for subclass stubs used in unit tests
125+
protected SyncInput() {
126+
this.request = null;
127+
this.inlineContentHandler = null;
128+
}
123129

124130
/**
125131
* Get the real client IP address. The REST binding is split up as follows:
@@ -268,7 +274,8 @@ public Set<String> getContentNames() {
268274
}
269275

270276
/**
271-
* Get an inline content object.
277+
* Get an inline content object. The returned object may be a List if multiple
278+
* inline objects were captured.
272279
*
273280
* @param name name of inline object
274281
* @return an object for the specified content name; may be null
@@ -280,6 +287,7 @@ public Object getContent(String name) {
280287
/**
281288
* Process all input. For HEAD, GET, and DELETE: process parameters.
282289
* For POST and PUT: process parameters, bare content stream, and multipart.
290+
* TBD: DELETE with parameters is sketchy.
283291
*
284292
* @throws IOException fail to read
285293
* @throws ResourceNotFoundException thrown by InlineContentHandler
@@ -359,7 +367,19 @@ private void processStream(String name, String contentType, InputStream inputStr
359367
}
360368

361369
InlineContentHandler.Content c = inlineContentHandler.accept(name, contentType, new CloseWrapper(inputStream));
362-
content.put(c.name, c.value);
370+
Object o = content.get(c.name);
371+
if (o == null) {
372+
content.put(c.name, c.value);
373+
} else if (o instanceof List) {
374+
List cur = (List) o;
375+
cur.add(c);
376+
} else {
377+
// multipart: replace single item with list
378+
List<Object> cur = new ArrayList<>();
379+
cur.add(o);
380+
cur.add(c.value);
381+
content.put(c.name, cur);
382+
}
363383
}
364384

365385
// this is here to aid in debugging InputStream failures like the one where some library code

cadc-util/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ sourceCompatibility = 1.8
1515

1616
group = 'org.opencadc'
1717

18-
version = '1.12.4'
18+
version = '1.12.5'
1919

2020
description = 'OpenCADC core utility library'
2121
def git_url = 'https://github.com/opencadc/core'

cadc-util/src/main/java/ca/nrc/cadc/net/HttpDelete.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ protected void doAction()
125125
conn.setUseCaches(false);
126126
conn.setDoInput(true);
127127
conn.setDoOutput(false);
128+
conn.setInstanceFollowRedirects(followRedirects);
128129

129130
setRequestHeaders(conn);
130131
setRequestAuthHeaders(conn);

0 commit comments

Comments
 (0)