refs:4381: org.gcube.portlets.user.tabular-data-toolbox-widget.1-11-0
https://support.d4science.org/issues/4381 Updated to Liferay 6.2 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@129377 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
caad9e3c97
commit
d93fecc5c1
|
@ -14,8 +14,10 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVFileUtil;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -59,6 +61,18 @@ public class CSVImportFileServlet extends HttpServlet {
|
|||
}
|
||||
logger.info("CSVImportFileServlet import session id: "+session.getId());
|
||||
|
||||
try {
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
CSVFileUploadSession fileUploadSession=SessionUtil.getCSVFileUploadSession(session);
|
||||
|
||||
if (fileUploadSession == null)
|
||||
|
|
|
@ -18,9 +18,11 @@ import org.apache.commons.fileupload.FileItemFactory;
|
|||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.FileUploadListener;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadState;
|
||||
|
@ -29,63 +31,78 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CodelistMappingUploadServlet extends HttpServlet {
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(CodelistMappingUploadServlet.class);
|
||||
|
||||
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(CodelistMappingUploadServlet.class);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4197748678713054285L;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
protected void doPost(HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
logger.trace("Post");
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
if(session==null){
|
||||
logger.error("Error getting the upload session, no session valid found: "+session);
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error getting the user session, no session found"+session);
|
||||
return ;
|
||||
}
|
||||
logger.info("Codelist Mapping session id: "+session.getId());
|
||||
|
||||
CodelistMappingFileUploadSession codelistMappingFileUploadSession=new CodelistMappingFileUploadSession();
|
||||
//CodelistMappingMonitor codelistMappingMonitor=new CodelistMappingMonitor();
|
||||
FileUploadMonitor fileUploadMonitor=new FileUploadMonitor();
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
if (session == null) {
|
||||
logger.error("Error getting the upload session, no session valid found: "
|
||||
+ session);
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
||||
"ERROR-Error getting the user session, no session found"
|
||||
+ session);
|
||||
return;
|
||||
}
|
||||
logger.info("Codelist Mapping session id: " + session.getId());
|
||||
|
||||
codelistMappingFileUploadSession.setId(session.getId());
|
||||
codelistMappingFileUploadSession.setFileUploadState(FileUploadState.STARTED);
|
||||
//codelistMappingFileUploadSession.setCodelistMappingMonitor(codelistMappingMonitor);
|
||||
SessionUtil.setFileUploadMonitor(session,fileUploadMonitor);
|
||||
|
||||
|
||||
try {
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session,codelistMappingFileUploadSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
CodelistMappingFileUploadSession codelistMappingFileUploadSession = new CodelistMappingFileUploadSession();
|
||||
// CodelistMappingMonitor codelistMappingMonitor=new
|
||||
// CodelistMappingMonitor();
|
||||
FileUploadMonitor fileUploadMonitor = new FileUploadMonitor();
|
||||
|
||||
codelistMappingFileUploadSession.setId(session.getId());
|
||||
codelistMappingFileUploadSession
|
||||
.setFileUploadState(FileUploadState.STARTED);
|
||||
// codelistMappingFileUploadSession.setCodelistMappingMonitor(codelistMappingMonitor);
|
||||
SessionUtil.setFileUploadMonitor(session, fileUploadMonitor);
|
||||
|
||||
try {
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session,
|
||||
codelistMappingFileUploadSession);
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
FileItemFactory factory = new DiskFileItemFactory();
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
|
||||
|
||||
FileUploadListener uploadListener = new FileUploadListener(fileUploadMonitor);
|
||||
|
||||
FileUploadListener uploadListener = new FileUploadListener(
|
||||
fileUploadMonitor);
|
||||
upload.setProgressListener(uploadListener);
|
||||
|
||||
|
||||
FileItem uploadItem = null;
|
||||
Log.info("Start upload file ");
|
||||
try {
|
||||
|
@ -93,60 +110,75 @@ public class CodelistMappingUploadServlet extends HttpServlet {
|
|||
Iterator it = items.iterator();
|
||||
while (it.hasNext()) {
|
||||
FileItem item = (FileItem) it.next();
|
||||
if (!item.isFormField() && "uploadFormElement".equals(item.getFieldName())) {
|
||||
if (!item.isFormField()
|
||||
&& "uploadFormElement".equals(item.getFieldName())) {
|
||||
uploadItem = item;
|
||||
}
|
||||
}
|
||||
} catch (FileUploadException e) {
|
||||
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the HTTP request", FileUtil.exceptionDetailMessage(e));
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the HTTP request",
|
||||
FileUtil.exceptionDetailMessage(e));
|
||||
SessionUtil.setFileUploadMonitor(session, fum);
|
||||
codelistMappingFileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
codelistMappingFileUploadSession
|
||||
.setFileUploadState(FileUploadState.FAILED);
|
||||
try {
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session, codelistMappingFileUploadSession);
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session,
|
||||
codelistMappingFileUploadSession);
|
||||
} catch (TDGWTSessionExpiredException e1) {
|
||||
logger.error(e1.getLocalizedMessage());
|
||||
e1.printStackTrace();
|
||||
throw new ServletException(e1.getLocalizedMessage());
|
||||
}
|
||||
logger.error("Error processing request in upload servlet", e);
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error during request processing: "+e.getMessage());
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
||||
"ERROR-Error during request processing: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (uploadItem == null) {
|
||||
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the HTTP request: No file found", "Upload request without file");
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed(
|
||||
"An error occured elaborating the HTTP request: No file found",
|
||||
"Upload request without file");
|
||||
SessionUtil.setFileUploadMonitor(session, fum);
|
||||
|
||||
codelistMappingFileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
|
||||
codelistMappingFileUploadSession
|
||||
.setFileUploadState(FileUploadState.FAILED);
|
||||
try {
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session, codelistMappingFileUploadSession);
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session,
|
||||
codelistMappingFileUploadSession);
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
logger.error("Error processing request in upload servlet: No file to upload");
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file to upload");
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
||||
"No file to upload");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String contentType = uploadItem.getContentType();
|
||||
|
||||
logger.trace("ContentType: "+contentType);
|
||||
|
||||
|
||||
|
||||
logger.trace("ContentType: " + contentType);
|
||||
|
||||
try {
|
||||
FileUtil.setImportFileCodelistMapping(codelistMappingFileUploadSession, uploadItem.getInputStream(), uploadItem.getName(), contentType);
|
||||
FileUtil.setImportFileCodelistMapping(
|
||||
codelistMappingFileUploadSession,
|
||||
uploadItem.getInputStream(), uploadItem.getName(),
|
||||
contentType);
|
||||
} catch (Exception e) {
|
||||
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the file", FileUtil.exceptionDetailMessage(e));
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the file",
|
||||
FileUtil.exceptionDetailMessage(e));
|
||||
SessionUtil.setFileUploadMonitor(session, fum);
|
||||
|
||||
codelistMappingFileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
|
||||
codelistMappingFileUploadSession
|
||||
.setFileUploadState(FileUploadState.FAILED);
|
||||
try {
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session, codelistMappingFileUploadSession);
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session,
|
||||
codelistMappingFileUploadSession);
|
||||
} catch (TDGWTSessionExpiredException e1) {
|
||||
logger.error(e1.getLocalizedMessage());
|
||||
e1.printStackTrace();
|
||||
|
@ -154,19 +186,20 @@ public class CodelistMappingUploadServlet extends HttpServlet {
|
|||
}
|
||||
logger.error("Error elaborating the stream", e);
|
||||
uploadItem.delete();
|
||||
response.getWriter().write("ERROR-"+e.getMessage());
|
||||
response.getWriter().write("ERROR-" + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uploadItem.delete();
|
||||
|
||||
|
||||
logger.trace("changing state");
|
||||
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setState(FileUploadState.COMPLETED);
|
||||
SessionUtil.setFileUploadMonitor(session, fum);
|
||||
|
||||
|
||||
try {
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session, codelistMappingFileUploadSession);
|
||||
SessionUtil.setCodelistMappingFileUploadSession(session,
|
||||
codelistMappingFileUploadSession);
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -18,9 +18,11 @@ import org.apache.commons.fileupload.FileItemFactory;
|
|||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.FileUploadListener;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadState;
|
||||
|
@ -59,6 +61,17 @@ public class LocalUploadServlet extends HttpServlet {
|
|||
return ;
|
||||
}
|
||||
logger.info("CSV Import session id: "+session.getId());
|
||||
|
||||
try {
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
CSVFileUploadSession fileUploadSession=new CSVFileUploadSession();
|
||||
//CSVImportMonitor csvImportMonitor=new CSVImportMonitor();
|
||||
|
|
|
@ -13,7 +13,9 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -63,8 +65,18 @@ public class RetrieveChartFileServlet extends HttpServlet {
|
|||
}
|
||||
logger.debug("RetrieveChartFileServlet session id: "
|
||||
+ session.getId());
|
||||
|
||||
try {
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
SessionUtil.getAslSession(session);
|
||||
String uri = (String) request.getParameter(ATTRIBUTE_STORAGE_URI);
|
||||
logger.debug("Request storage uri: "+uri);
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -59,8 +61,17 @@ public class RetrieveFileAndDiscoverMimeTypeServlet extends HttpServlet {
|
|||
}
|
||||
logger.debug("RetrieveFileAndDiscoverMimeTypeServlet session id: "
|
||||
+ session.getId());
|
||||
try {
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
SessionUtil.getAslSession(session);
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
String uri = (String) request.getParameter(ATTRIBUTE_STORAGE_URI);
|
||||
logger.debug("Request storage uri: " + uri);
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ import javax.servlet.http.HttpSession;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -61,6 +63,17 @@ public class TDLogsServlet extends HttpServlet {
|
|||
|
||||
logger.debug("TDLogsServlet import session id: " + session.getId());
|
||||
|
||||
try {
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
ByteArrayInputStream in = null;
|
||||
ByteArrayOutputStream out = null;
|
||||
try {
|
||||
|
|
|
@ -15,6 +15,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -64,9 +65,20 @@ public class TDRStudioServlet extends HttpServlet {
|
|||
}
|
||||
logger.debug("TDRSTudioServlet session id: "
|
||||
+ session.getId());
|
||||
|
||||
ASLSession aslSession=SessionUtil.getAslSession(session);
|
||||
|
||||
ASLSession aslSession=null;
|
||||
try {
|
||||
aslSession= SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
String tabResourceId=request.getParameter(TAB_RESOURCE_ID_PARAMETER);
|
||||
logger.debug("Request RStudio for TR: "+tabResourceId);
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -55,7 +57,17 @@ public class TabularDataRowsXServlet extends HttpServlet {
|
|||
return ;
|
||||
}
|
||||
logger.info("Session id: "+session.getId());
|
||||
|
||||
try {
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
ServletInputStream in = request.getInputStream();
|
||||
InputStreamReader buffIn = new InputStreamReader(in);
|
||||
|
@ -66,7 +78,6 @@ public class TabularDataRowsXServlet extends HttpServlet {
|
|||
while (-1 != (n = buffIn.read(buffer))) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
;
|
||||
logger.debug("Stream: " + out);
|
||||
|
||||
JSONObject jsonRequest = new JSONObject(out.toString());
|
||||
|
|
Loading…
Reference in New Issue