Added hproxy check #7807
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@146358 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8a5f01282f
commit
040e2b9e1b
|
@ -79,5 +79,6 @@
|
|||
</Change>
|
||||
<Change>[Task #7626] Fix issue on set/reset scope
|
||||
</Change>
|
||||
<Change>[Task #7807] Provide a check for HAProxy</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.http;
|
||||
|
||||
|
@ -16,4 +16,6 @@ public class ConstantsHttpResolver {
|
|||
public static final String CONTENT_DISPOSITION = "content-disposition";
|
||||
public static final String DEFAULT_CONTENTTYPE_UNKNOWN_UNKNOWN = "unknown/unknown";
|
||||
public static final String DEFAULT_FILENAME_FROM_STORAGE_MANAGER = "fromStorageManager";
|
||||
|
||||
protected static final String HPC = "hproxycheck"; //for hproxycheck
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.io.OutputStream;
|
|||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -16,6 +18,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.Handler;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPURLConnection;
|
||||
import org.gcube.datatransfer.resolver.MultiReadHttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -258,6 +261,33 @@ public class HttpResolver extends HttpServlet {
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.http.HttpServlet#doHead(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
*/
|
||||
@Override
|
||||
protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
logger.info("doHead working..");
|
||||
|
||||
String hpc = req.getParameter(ConstantsHttpResolver.HPC); //for HProxy check
|
||||
try{
|
||||
if(hpc==null || Boolean.parseBoolean(hpc)){
|
||||
logger.trace("returning status 200 for Hproxy check");
|
||||
resp.setStatus(200);
|
||||
return;
|
||||
}
|
||||
}catch (Exception e) {
|
||||
//silent exception to continue..
|
||||
}
|
||||
|
||||
//ADDING PARAMETER TO PERFORM ONLY VALIDATION
|
||||
Map<String, String[]> additionalParams = new HashMap<String, String[]>();
|
||||
String[] value = new String[1];
|
||||
value[0] = "true";
|
||||
additionalParams.put(VALIDATION, value);
|
||||
MultiReadHttpServletRequest request = new MultiReadHttpServletRequest(req, additionalParams);
|
||||
doGet(request, resp);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ public class StorageIDResolver extends HttpServlet {
|
|||
/** The logger. */
|
||||
private static final Logger logger = LoggerFactory.getLogger(StorageIDResolver.class);
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
|
||||
*/
|
||||
|
@ -219,6 +221,17 @@ public class StorageIDResolver extends HttpServlet {
|
|||
protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
logger.info("doHead working..");
|
||||
|
||||
String hpc = req.getParameter(ConstantsHttpResolver.HPC); //for HProxy check
|
||||
try{
|
||||
if(hpc==null || Boolean.parseBoolean(hpc)){
|
||||
logger.trace("returning status 200 for Hproxy check");
|
||||
resp.setStatus(200);
|
||||
return;
|
||||
}
|
||||
}catch (Exception e) {
|
||||
//silent exception to continue..
|
||||
}
|
||||
|
||||
//ADDING PARAMETER TO PERFORM ONLY VALIDATION
|
||||
Map<String, String[]> additionalParams = new HashMap<String, String[]>();
|
||||
String[] value = new String[1];
|
||||
|
|
Loading…
Reference in New Issue