added property file with portal url: group/data-e-infrastructure-gateway
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@77327 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2d5ac77f77
commit
a89419f959
|
@ -44,6 +44,7 @@ import org.gcube.portlets.user.homelibrary.util.Extensions;
|
|||
import org.gcube.portlets.user.homelibrary.util.MimeTypeUtil;
|
||||
import org.gcube.portlets.user.homelibrary.util.zip.ZipUtil;
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
||||
|
||||
|
@ -106,7 +107,7 @@ public class DownloadServlet extends HttpServlet{
|
|||
|
||||
item = wa.getItem(itemId);
|
||||
|
||||
if(isValidItem){ //ADDED 25/06/2013
|
||||
if(isValidItem){ //ADDED 25/06/2013 - THIS CODE RETURN A SC_ACCEPT IS ITEM EXIST
|
||||
String message = HttpServletResponse.SC_ACCEPTED+ ": The resource is available";
|
||||
sendMessageResourceAvailable(resp, message);
|
||||
logger.trace("response return: "+message);
|
||||
|
@ -124,7 +125,7 @@ public class DownloadServlet extends HttpServlet{
|
|||
} catch (ItemNotFoundException e) {
|
||||
logger.error("Requested item "+itemId+" not found",e);
|
||||
// sendError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error, no items found");
|
||||
handleError(urlRedirectOnError, req, resp, itemId, "The file has been deleted by another user.");
|
||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": The file has been deleted by another user.");
|
||||
// sendError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": "+ConstantsExplorer.ERROR_ITEM_DOES_NOT_EXIST);
|
||||
|
||||
return;
|
||||
|
@ -557,7 +558,7 @@ public class DownloadServlet extends HttpServlet{
|
|||
|
||||
protected void handleError(boolean urlRedirectOnError, HttpServletRequest req, HttpServletResponse resp, String itemId, String message) throws IOException{
|
||||
|
||||
logger.warn("Handle rrror occurred: "+message);
|
||||
logger.warn("Handle error occurred: "+message);
|
||||
if(urlRedirectOnError){
|
||||
urlRedirect(req, resp, itemId);
|
||||
}else
|
||||
|
@ -599,9 +600,9 @@ public class DownloadServlet extends HttpServlet{
|
|||
|
||||
protected void urlRedirect(HttpServletRequest req, HttpServletResponse response, String fakePath) throws IOException {
|
||||
|
||||
String requestUrl = getRequestURL(req) + "/"+fakePath;
|
||||
String requestUrl = getRequestURL(req) +fakePath;
|
||||
logger.trace("Url redirect on: "+requestUrl);
|
||||
// System.out.println("Url redirect on: "+requestUrl);
|
||||
System.out.println("Url redirect on: "+requestUrl);
|
||||
response.sendRedirect(response.encodeRedirectURL(requestUrl));
|
||||
return;
|
||||
}
|
||||
|
@ -612,7 +613,7 @@ public class DownloadServlet extends HttpServlet{
|
|||
String serverName = req.getServerName(); // hostname.com
|
||||
int serverPort = req.getServerPort(); // 80
|
||||
String contextPath = req.getContextPath(); // /mywebapp
|
||||
String servletPath = req.getServletPath(); // /servlet/MyServlet
|
||||
// String servletPath = req.getServletPath(); // /servlet/MyServlet
|
||||
// String pathInfo = req.getPathInfo(); // /a/b;c=123
|
||||
// String queryString = req.getQueryString(); // d=789
|
||||
|
||||
|
@ -624,14 +625,37 @@ public class DownloadServlet extends HttpServlet{
|
|||
url.append(":").append(serverPort);
|
||||
}
|
||||
|
||||
url.append(contextPath).append(servletPath);
|
||||
logger.trace("server: "+url);
|
||||
logger.trace("contextPath: "+contextPath);
|
||||
// logger.trace("servletPath: "+servletPath);
|
||||
// url.append(contextPath).append(servletPath);
|
||||
|
||||
|
||||
url.append(contextPath);
|
||||
|
||||
// if (pathInfo != null) {
|
||||
// url.append(pathInfo);
|
||||
// }
|
||||
// if (queryString != null) {
|
||||
// url.append("?").append(queryString);
|
||||
|
||||
// }
|
||||
|
||||
PortalUrlGroupGatewayProperty p = new PortalUrlGroupGatewayProperty();
|
||||
|
||||
int lenght = p.getPath().length();
|
||||
|
||||
String groupgatewaypath = "/";
|
||||
|
||||
if(lenght>1){
|
||||
|
||||
String lastChar = p.getPath().substring(lenght-1, lenght-1);
|
||||
|
||||
groupgatewaypath+= lastChar.compareTo("/")!=0?p.getPath()+"/":p.getPath();
|
||||
}
|
||||
|
||||
url.append(groupgatewaypath);
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package org.gcube.portlets.user.workspace.server.property;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Jun 26, 2013
|
||||
*
|
||||
*/
|
||||
public class PortalUrlGroupGatewayProperty {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static final String PORTALURL_PROPERTIES = "portalurl.properties";
|
||||
|
||||
protected static Logger log = Logger.getLogger(PortalUrlGroupGatewayProperty.class);
|
||||
|
||||
private String server = "";
|
||||
private String path = "";
|
||||
|
||||
public PortalUrlGroupGatewayProperty(){
|
||||
|
||||
Properties properties = new Properties();
|
||||
|
||||
try {
|
||||
|
||||
InputStream in = (InputStream) PortalUrlGroupGatewayProperty.class.getResourceAsStream(PORTALURL_PROPERTIES);
|
||||
|
||||
// // load a properties file
|
||||
properties.load(in);
|
||||
// // get the properties value for Portal
|
||||
server = properties.getProperty("SERVER");
|
||||
path = properties.getProperty("PATH");
|
||||
in.close();
|
||||
|
||||
}catch (Exception e) {
|
||||
log.error("error on reading property file: "+PORTALURL_PROPERTIES, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("PortalUrlProperty [server=");
|
||||
builder.append(server);
|
||||
builder.append(", path=");
|
||||
builder.append(path);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
PortalUrlGroupGatewayProperty p = new PortalUrlGroupGatewayProperty();
|
||||
|
||||
int lenght = p.getPath().length();
|
||||
String lastChar = p.getPath().substring(lenght-1, lenght-1);
|
||||
|
||||
String path = lastChar.compareTo("/")!=0?p.getPath()+"/":p.getPath();
|
||||
|
||||
|
||||
System.out.println(p);
|
||||
System.out.println(path);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.server.property;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Jun 26, 2013
|
||||
*
|
||||
*/
|
||||
public class PropertyFileNotFoundException extends Exception {
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
#Property file - portalurl
|
||||
|
||||
SERVER=https://dev.d4science.org
|
||||
PATH=group/data-e-infrastructure-gateway
|
Loading…
Reference in New Issue