#21093 changed status code from 204 to 200

This commit is contained in:
Francesco Mangiacrapa 2021-04-08 10:25:48 +02:00
parent 78784473f6
commit 6038760a39
5 changed files with 86 additions and 21 deletions

View File

@ -4,18 +4,22 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2-5-0-SNAPSHOT] - 2021-30-03 ## [v2-5-0-SNAPSHOT] - 2021-04-08
**New features** **New features**
[Task #20993] Supported new resource "Wekeo Interface" - gettoken. [#20993] Supported new resource "Wekeo Interface" - gettoken.
**Bug fixes**
[#21093] StorageHubResolver HEAD request does not support Content-Length
## [v2-4-1] - 2021-01-13 ## [v2-4-1] - 2021-01-13
**Bug Fixes** **Bug Fixes**
[Task #19942] Fixing master build fails [#19942] Fixing master build fails
## [v2-4-0] [r4-24-0]- 2020-06-18 ## [v2-4-0] [r4-24-0]- 2020-06-18

View File

@ -71,7 +71,7 @@ public class StorageHubResolver {
ItemManagerClient client = AbstractPlugin.item().build(); ItemManagerClient client = AbstractPlugin.item().build();
StreamDescriptor descriptor = client.resolvePublicLink(id); StreamDescriptor descriptor = client.resolvePublicLink(id);
ResponseBuilder response = Response.noContent(); ResponseBuilder response = Response.ok();
response = new StorageHubMetadataResponseBuilder(req, response).fillMetadata(descriptor, id, CONTENT_DISPOSITION_VALUE.attachment); response = new StorageHubMetadataResponseBuilder(req, response).fillMetadata(descriptor, id, CONTENT_DISPOSITION_VALUE.attachment);
return response.build(); return response.build();

View File

@ -3,6 +3,8 @@ package org.gcube.datatransfer.resolver.services;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor; import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor; import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@ -181,23 +183,29 @@ public class WekeoResolver {
} }
@GET @GET
@Produces({MediaType.TEXT_HTML})
@Path("") @Path("")
@Produces(MediaType.TEXT_HTML) public InputStream index(@Context HttpServletRequest req) throws WebApplicationException{
public Response getIndex(@Context HttpServletRequest req) {
logger.info(this.getClass().getSimpleName()+" getIndex starts..."); String indexFile = "/WEB-INF/jsp/wekeo.jsp";
StringBuilder wekeoResponse = new StringBuilder(); try{
wekeoResponse.append("<h1>Welcome to Wekeo Resolver</h1>"); logger.info(UriResolverIndex.class.getSimpleName() +" called");
wekeoResponse.append("<div>See documentation at: "+helpURI +"</div>"); String realPath = req.getServletContext().getRealPath(indexFile);
String wekeoGetTokenURL = String.format("%s/%s", Util.getServerURL(req), "wekeo/gettoken"); return new FileInputStream(new File(realPath));
wekeoResponse.append("<div>Go to <i>gettoken</i> request: "+wekeoGetTokenURL +"</div>"); }catch (Exception e) {
String theResponse = wekeoResponse.toString(); if(!(e instanceof WebApplicationException)){
logger.info("debug: \n"+theResponse); //UNEXPECTED EXCEPTION managing it as WebApplicationException
return Response.ok(theResponse).build(); String error = "Index.jsp not found. Please, contact the support!";
throw ExceptionManager.internalErrorException(req, error, this.getClass(), null);
}
//ALREADY MANAGED AS WebApplicationException
logger.error("Exception:", e);
throw (WebApplicationException) e;
}
} }
/** /**
* Reads the wekeo endpoint information from IS. {The SE name is: @link WekeoResolver#RUNTIME_WKEO_RESOURCE_NAME} * Reads the wekeo endpoint information from IS. {The SE name is: @link WekeoResolver#RUNTIME_WKEO_RESOURCE_NAME}
* *
@ -225,7 +233,7 @@ public class WekeoResolver {
if(toReturn.size()==0){ if(toReturn.size()==0){
String errorMessage = String.format("Missing the RR with Name '%s' and Category '%s' in the scope '%s'. Please contact the support.",RUNTIME_WKEO_RESOURCE_NAME,CATEGORY_WEKEO_TYPE,ScopeProvider.instance.get()); String errorMessage = String.format("Missing the RR with Name '%s' and Category '%s' in the scope '%s'. Please contact the support.",RUNTIME_WKEO_RESOURCE_NAME,CATEGORY_WEKEO_TYPE,ScopeProvider.instance.get());
logger.error(errorMessage); logger.error(errorMessage);
throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class, helpURI); throw ExceptionManager.internalErrorException(req, errorMessage, WekeoResolver.class, helpURI);
} }
String wekeoUsername = null; String wekeoUsername = null;
@ -247,7 +255,7 @@ public class WekeoResolver {
}catch(Exception e){ }catch(Exception e){
String errorMessage = "Error occurred on reading the "+RUNTIME_WKEO_RESOURCE_NAME+" SE registered in the scope: "+ScopeProvider.instance.get(); String errorMessage = "Error occurred on reading the "+RUNTIME_WKEO_RESOURCE_NAME+" SE registered in the scope: "+ScopeProvider.instance.get();
logger.error(errorMessage, e); logger.error(errorMessage, e);
throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class, helpURI); throw ExceptionManager.internalErrorException(req, errorMessage, WekeoResolver.class, helpURI);
}finally{ }finally{
if(callerScope!=null){ if(callerScope!=null){

View File

@ -58,8 +58,10 @@ public class StorageHubMetadataResponseBuilder {
responseBuilder.header("Content-Location", contentLocation); responseBuilder.header("Content-Location", contentLocation);
//Managing "Content-Type" //Managing "Content-Type"
if (streamDescriptor.getContentType()!= null && !streamDescriptor.getContentType().isEmpty()) if (streamDescriptor.getContentType()!= null && !streamDescriptor.getContentType().isEmpty()) {
responseBuilder.header("Content-Type", streamDescriptor.getContentType()); responseBuilder.header("Content-Type", streamDescriptor.getContentType());
}
//Managing "Content-Lenght" //Managing "Content-Lenght"
if(streamDescriptor.getContentLenght()>0) { if(streamDescriptor.getContentLenght()>0) {

View File

@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<style type="text/css">
body {
background-color: #f8f6f2;
color: #225f97;
font-family: 'Droid Sans', arial, sans-serif;
font-size: 16px;
}
.mydiv {
top: 50%;
left: 50%;
width: 600px;
height: 300px;
margin-top: -150px; /*set to a negative number 1/2 of your height*/
margin-left: -300px; /*set to a negative number 1/2 of your width*/
/* border: 1px solid #ccc; */
/* background-color: #9b9b9b; */
position: fixed;
text-align: center;
/* vertical-align: middle; */
}
.myTitle {
font-size: 22px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="mydiv">
<img alt=""
src="https://www.d4science.org/image/layout_set_logo?img_id=12630" />
<div class="myTitle">The Wekeo Resolver</div>
<div>Available Operations:
<ul>
<li> getToken at <%=request.getRequestURL()%>/gettoken
</li>
</ul>
</div>
<p>
See wiki page at <a
href="https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Wekeo_Resolver" target="_blank">gCube Wiki Wekeo
Resolver</a>
</p>
</div>
</body>
</html>