Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #589 #597

Merged
merged 6 commits into from
Dec 14, 2023
Merged
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
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,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