Skip to content

Commit

Permalink
Merge pull request #597 from opengeospatial/issue#589
Browse files Browse the repository at this point in the history
Closes #589
  • Loading branch information
dstenger committed Dec 14, 2023
2 parents a2c9428 + 360b9c8 commit d0e7a04
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 16 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@
<artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static PrintWriter createLog(File logDir, String callpath)
}
String path=logDir.toString() + "/" + callpath.split("/")[0];
System.setProperty("PATH", path);
dir.mkdir();
dir.mkdirs();
File f = new File(dir, "log.xml");
f.delete();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
Expand Down Expand Up @@ -549,7 +549,9 @@ public static void createFullReportLog(String sessionLogDir)
File dir = new File(sessionLogDir);
if( ! dir.exists() ) {
if( ! dir.mkdir() ) {
throw new RuntimeException("Unable to create report log directory " + sessionLogDir);
if(! dir.mkdirs()) {
throw new RuntimeException("Unable to create report log directory " + sessionLogDir);
}
}
}
File xml_logs_report_file = new File(sessionLogDir + File.separator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class TEStatistics {
static Logger logger = Logger.getLogger(TEStatistics.class.getName());

@GET
@Produces("application/zip;qs=0.25;charset='utf-8'")
@Produces("application/zip;qs=0.25;charset=utf-8")
public Response generateStatisticsReport() throws IOException {
Source results = generateStatisticsReports();
String htmlOutput = results.getSystemId().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
Expand All @@ -44,6 +45,8 @@
import com.occamlab.te.spi.jaxrs.TestSuiteRegistry;
import com.occamlab.te.spi.util.TestRunUtils;
import com.occamlab.te.util.LogUtils;

import org.glassfish.jersey.internal.util.collection.ImmutableMultivaluedMap;
import org.glassfish.jersey.media.multipart.FormDataParam;

/**
Expand Down Expand Up @@ -86,7 +89,7 @@ public class TestRunResource {
* @return An RDF (EARL) representation of the test results.
*/
@GET
@Produces("application/rdf+xml;qs=0.75;charset='utf-8'")
@Produces("application/rdf+xml;qs=0.75;charset=utf-8")
public Source handleGetRdf( @PathParam("etsCode") String etsCode, @PathParam("etsVersion") String etsVersion ) {
return handleGet( etsCode, etsVersion, APPLICATION_RDF_XML );
}
Expand All @@ -102,7 +105,7 @@ public Source handleGetRdf( @PathParam("etsCode") String etsCode, @PathParam("et
* @return An XML representation of the test results.
*/
@GET
@Produces("application/xml;qs=0.5;charset='utf-8'")
@Produces("application/xml;qs=0.5;charset=utf-8")
public Source handleGetXml( @PathParam("etsCode") String etsCode, @PathParam("etsVersion") String etsVersion ) {
return handleGet( etsCode, etsVersion, APPLICATION_XML );
}
Expand All @@ -118,10 +121,11 @@ public Source handleGetXml( @PathParam("etsCode") String etsCode, @PathParam("et
* @return An zip archive containing the HTML representation of the test results.
*/
@GET
@Produces("application/zip;qs=0.25;charset='utf-8'")
@Produces("application/zip;qs=0.25;charset=utf-8")
public Response handleGetZip( @PathParam("etsCode") String etsCode, @PathParam("etsVersion") String etsVersion )
throws IOException {
MultivaluedMap<String, String> params = this.reqUriInfo.getQueryParameters();
params = toMutableMultivaluedMap(params);
Source results = executeTestRun( etsCode, params, APPLICATION_ZIP );

String htmlOutput = results.getSystemId().toString();
Expand Down Expand Up @@ -151,7 +155,7 @@ public Response handleGetZip( @PathParam("etsCode") String etsCode, @PathParam("
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML })
@Produces("application/rdf+xml;qs=0.75;charset='utf-8'")
@Produces("application/rdf+xml;qs=0.75;charset=utf-8")
public Source handlePostRdf( @PathParam("etsCode") String etsCode, @PathParam("etsVersion") String etsVersion,
File entityBody ) {
return handlePost( etsCode, etsVersion, entityBody, APPLICATION_RDF_XML );
Expand All @@ -172,7 +176,7 @@ public Source handlePostRdf( @PathParam("etsCode") String etsCode, @PathParam("e
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML })
@Produces("application/xml;qs=0.5;charset='utf-8'")
@Produces("application/xml;qs=0.5;charset=utf-8")
public Source handlePostXml( @PathParam("etsCode") String etsCode, @PathParam("etsVersion") String etsVersion,
File entityBody ) {
return handlePost( etsCode, etsVersion, entityBody, APPLICATION_XML );
Expand All @@ -193,7 +197,7 @@ public Source handlePostXml( @PathParam("etsCode") String etsCode, @PathParam("e
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML })
@Produces("application/zip;qs=0.25;charset='utf-8'")
@Produces("application/zip;qs=0.25;charset=utf-8")
public Source handlePostZip( @PathParam("etsCode") String etsCode, @PathParam("etsVersion") String etsVersion,
File entityBody ) {
return handlePost( etsCode, etsVersion, entityBody, APPLICATION_ZIP );
Expand Down Expand Up @@ -226,7 +230,7 @@ public Source handlePostZip( @PathParam("etsCode") String etsCode, @PathParam("e
*/
@POST
@Consumes({ MediaType.MULTIPART_FORM_DATA })
@Produces("application/rdf+xml;qs=0.75;charset='utf-8'")
@Produces("application/rdf+xml;qs=0.75;charset=utf-8")
public Source handleMultipartFormDataRdf( @PathParam("etsCode") String etsCode,
@PathParam("etsVersion") String etsVersion,
@FormDataParam("iut") File entityBody, @FormDataParam("sch") File schBody ) {
Expand Down Expand Up @@ -260,7 +264,7 @@ public Source handleMultipartFormDataRdf( @PathParam("etsCode") String etsCode,
*/
@POST
@Consumes({ MediaType.MULTIPART_FORM_DATA })
@Produces("application/xml;qs=0.5;charset='utf-8'")
@Produces("application/xml;qs=0.5;charset=utf-8")
public Source handleMultipartFormDataXml( @PathParam("etsCode") String etsCode,
@PathParam("etsVersion") String etsVersion,
@FormDataParam("iut") File entityBody, @FormDataParam("sch") File schBody ) {
Expand Down Expand Up @@ -294,7 +298,7 @@ public Source handleMultipartFormDataXml( @PathParam("etsCode") String etsCode,
*/
@POST
@Consumes({ MediaType.MULTIPART_FORM_DATA })
@Produces("application/zip;qs=0.25;charset='utf-8'")
@Produces("application/zip;qs=0.25;charset=utf-8")
public Source handleMultipartFormDataZip( @PathParam("etsCode") String etsCode,
@PathParam("etsVersion") String etsVersion,
@FormDataParam("iut") File entityBody, @FormDataParam("sch") File schBody ) {
Expand All @@ -303,6 +307,7 @@ public Source handleMultipartFormDataZip( @PathParam("etsCode") String etsCode,

private Source handleGet( String etsCode, String etsVersion, String preferredMediaType ) {
MultivaluedMap<String, String> params = this.reqUriInfo.getQueryParameters();
params = toMutableMultivaluedMap(params);
if ( LOGR.isLoggable( Level.FINE ) ) {
StringBuilder msg = new StringBuilder( TEST_RUN_ARGUMENTS );
msg.append( etsCode ).append( "/" ).append( etsVersion ).append( "\n" );
Expand Down Expand Up @@ -472,4 +477,22 @@ private Document readTestRunArguments( Map<String, java.util.List<String>> reque
return propsDoc;
}

/**
* Checks if the input MulivalueMap is immutable. If this is the case,
* a new mutable MultivaluedHashMap is created containing the values of the input map.
*
* @param multivaluedMap A MultivalueMap
* @return A mutable MultivalueMap
*/
private MultivaluedMap<String, String> toMutableMultivaluedMap(MultivaluedMap<String, String> multivaluedMap) {
if(multivaluedMap instanceof ImmutableMultivaluedMap<?, ?>) {
MultivaluedMap<String, String> newMultivaluedMap = new MultivaluedHashMap<String, String>();
for (String key : multivaluedMap.keySet()) {
newMultivaluedMap.put(key, multivaluedMap.get(key));
}
multivaluedMap = newMultivaluedMap;
}
return multivaluedMap;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class TestSuiteOverviewResource {
* HTML-Compatible XHTML Documents</a>
*/
@GET
@Produces("text/html; charset='utf-8'")
@Produces("text/html; charset=utf-8")
public InputStream getTestSuiteDescriptionAsHTML(@PathParam("etsCode") String etsCode) {
InputStream atsStream = getTestSuiteDescription(etsCode, APPLICATION_TEXT_HTML);

Expand All @@ -75,7 +75,7 @@ public InputStream getTestSuiteDescriptionAsHTML(@PathParam("etsCode") String et
* <code>/doc/{etsCode}/{etsVersion}/overview.xml</code>).
*/
@GET
@Produces("application/xml; charset='utf-8'")
@Produces("application/xml; charset=utf-8")
public InputStream getTestSuiteDescriptionAsXML(@PathParam("etsCode") String etsCode) {
InputStream atsStream = getTestSuiteDescription(etsCode, APPLICATION_XML);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public TestSuiteSetResource() {
* syntax).
*/
@GET
@Produces("application/xhtml+xml; charset='utf-8'")
@Produces("application/xhtml+xml; charset=utf-8")
public Source listTestSuites() {
Document xhtmlDoc = readTemplate();
if (null == xhtmlDoc) {
Expand Down Expand Up @@ -118,7 +118,7 @@ public Source listTestSuites() {
* collection (an XML document).
*/
@GET
@Produces("application/xml; charset='utf-8'")
@Produces("application/xml; charset=utf-8")
public Source listTestSuitesAsXML() {
Document xmlDoc = this.docBuilder.newDocument();

Expand Down
5 changes: 5 additions & 0 deletions teamengine-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
<artifactId>jersey-hk2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-jakarta</artifactId>
Expand Down Expand Up @@ -143,6 +147,7 @@
<packagingExcludes>
WEB-INF/lib/teamengine-resources*.jar,
WEB-INF/lib/teamengine-realm*.jar,
WEB-INF/lib/jersey-*.jar,
WEB-INF/lib/jakarta.ws.rs-api-*.jar,
WEB-INF/lib/asm-*.jar,
WEB-INF/lib/derby-*.jar,
Expand Down

0 comments on commit d0e7a04

Please sign in to comment.