refs 6548: TDM - Migrate TabMan to new PortalContext
Task-Url: https://support.d4science.org/issues/6548 Updated to new PortalContext git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@141746 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1f6c3a7fe2
commit
5ff5b86e3b
|
@ -14,7 +14,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
|
@ -71,13 +70,19 @@ public class CSVImportFileServlet extends HttpServlet {
|
|||
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
throw new ServletException(
|
||||
"CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
}
|
||||
|
||||
try {
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
scopeGroupId);
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(
|
||||
"Error retrieving credentials:" + e.getLocalizedMessage(),
|
||||
|
|
|
@ -19,7 +19,6 @@ 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.common.scope.api.ScopeProvider;
|
||||
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;
|
||||
|
@ -69,9 +68,16 @@ public class CodelistMappingUploadServlet extends HttpServlet {
|
|||
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
try {
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
throw new ServletException(
|
||||
"CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
}
|
||||
|
||||
try {
|
||||
// String currUserId = request
|
||||
// .getParameter(Constants.CURR_USER_ID);
|
||||
// serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
|
@ -79,8 +85,6 @@ public class CodelistMappingUploadServlet extends HttpServlet {
|
|||
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
scopeGroupId);
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(
|
||||
"Error retrieving credentials:" + e.getLocalizedMessage(),
|
||||
|
|
|
@ -19,7 +19,6 @@ 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.common.scope.api.ScopeProvider;
|
||||
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;
|
||||
|
@ -69,13 +68,19 @@ public class LocalUploadServlet extends HttpServlet {
|
|||
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
throw new ServletException(
|
||||
"CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
}
|
||||
|
||||
try {
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
scopeGroupId);
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(
|
||||
"Error retrieving credentials:" + e.getLocalizedMessage(),
|
||||
|
|
|
@ -13,7 +13,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
|
@ -68,16 +67,22 @@ public class RetrieveChartFileServlet extends HttpServlet {
|
|||
logger.debug("RetrieveChartFileServlet session id: "
|
||||
+ session.getId());
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
throw new ServletException(
|
||||
"CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
}
|
||||
|
||||
try {
|
||||
String scopeGroupId = request
|
||||
.getParameter(Constants.CURR_GROUP_ID);
|
||||
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
scopeGroupId);
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(
|
||||
"Error retrieving credentials:"
|
||||
|
|
|
@ -11,7 +11,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
|
@ -32,7 +31,8 @@ public class RetrieveFileAndDiscoverMimeTypeServlet extends HttpServlet {
|
|||
.getLogger(RetrieveFileAndDiscoverMimeTypeServlet.class);
|
||||
|
||||
private static final String ATTRIBUTE_STORAGE_URI = "storageURI";
|
||||
//private static final int BUFSIZE = 4096;
|
||||
|
||||
// private static final int BUFSIZE = 4096;
|
||||
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
|
@ -63,18 +63,27 @@ public class RetrieveFileAndDiscoverMimeTypeServlet extends HttpServlet {
|
|||
}
|
||||
logger.debug("RetrieveFileAndDiscoverMimeTypeServlet session id: "
|
||||
+ session.getId());
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
throw new ServletException(
|
||||
"CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
}
|
||||
|
||||
try {
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
scopeGroupId);
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(
|
||||
"Error retrieving credentials:" + e.getLocalizedMessage(),
|
||||
e);
|
||||
"Error retrieving credentials:"
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
@ -90,51 +99,41 @@ public class RetrieveFileAndDiscoverMimeTypeServlet extends HttpServlet {
|
|||
}
|
||||
|
||||
/*
|
||||
|
||||
FilesStorage storage = new FilesStorage();
|
||||
InputStream inMime = storage.retrieveInputStream(uri);
|
||||
|
||||
|
||||
TikaConfig tika = new TikaConfig();
|
||||
|
||||
|
||||
MediaType mimeType=null;
|
||||
try {
|
||||
mimeType = tika.getDetector().detect(
|
||||
inMime, new Metadata());
|
||||
|
||||
} catch(Throwable e){
|
||||
logger.error("RetrieveFileAndDiscoverMimeTypeServlet parse: "+e.getLocalizedMessage());
|
||||
} finally {
|
||||
inMime.close();
|
||||
}
|
||||
|
||||
|
||||
if (mimeType == null) {
|
||||
response.setContentType("unknown");
|
||||
logger.debug("Discover Mime Type: unknown");
|
||||
} else {
|
||||
response.setContentType(mimeType.toString());
|
||||
logger.debug("Discover Mime Type: "+mimeType.toString());
|
||||
|
||||
}
|
||||
|
||||
InputStream in = storage.retrieveInputStream(uri);
|
||||
|
||||
OutputStream out = response.getOutputStream();
|
||||
|
||||
byte[] byteBuffer = new byte[BUFSIZE];
|
||||
|
||||
|
||||
int length = 0;
|
||||
while ((in != null) && ((length = in.read(byteBuffer)) != -1)) {
|
||||
out.write(byteBuffer, 0, length);
|
||||
}
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
in.close();
|
||||
out.close();
|
||||
|
||||
*/
|
||||
*
|
||||
* FilesStorage storage = new FilesStorage(); InputStream inMime =
|
||||
* storage.retrieveInputStream(uri);
|
||||
*
|
||||
*
|
||||
* TikaConfig tika = new TikaConfig();
|
||||
*
|
||||
*
|
||||
* MediaType mimeType=null; try { mimeType =
|
||||
* tika.getDetector().detect( inMime, new Metadata());
|
||||
*
|
||||
* } catch(Throwable e){
|
||||
* logger.error("RetrieveFileAndDiscoverMimeTypeServlet parse: "
|
||||
* +e.getLocalizedMessage()); } finally { inMime.close(); }
|
||||
*
|
||||
*
|
||||
* if (mimeType == null) { response.setContentType("unknown");
|
||||
* logger.debug("Discover Mime Type: unknown"); } else {
|
||||
* response.setContentType(mimeType.toString());
|
||||
* logger.debug("Discover Mime Type: "+mimeType.toString());
|
||||
*
|
||||
* }
|
||||
*
|
||||
* InputStream in = storage.retrieveInputStream(uri);
|
||||
*
|
||||
* OutputStream out = response.getOutputStream();
|
||||
*
|
||||
* byte[] byteBuffer = new byte[BUFSIZE];
|
||||
*
|
||||
*
|
||||
* int length = 0; while ((in != null) && ((length =
|
||||
* in.read(byteBuffer)) != -1)) { out.write(byteBuffer, 0, length);
|
||||
* } response.setStatus(HttpServletResponse.SC_OK); in.close();
|
||||
* out.close();
|
||||
*/
|
||||
logger.trace("Response in "
|
||||
+ (System.currentTimeMillis() - startTime));
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.ResourceBundle;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
||||
|
@ -131,7 +132,12 @@ public class SessionUtil {
|
|||
userName = Constants.DEFAULT_USER;
|
||||
scope = Constants.DEFAULT_SCOPE;
|
||||
token = Constants.DEFAULT_TOKEN;
|
||||
|
||||
|
||||
logger.info("Set SecurityToken: "+token);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
logger.info("Set ScopeProvider: "+scope);
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
sCredentials = new ServiceCredentials(userName, scope, token);
|
||||
|
||||
} else {
|
||||
|
@ -150,9 +156,8 @@ public class SessionUtil {
|
|||
scope = pContext.getCurrentScope(scopeGroupId);
|
||||
} else {
|
||||
scope = pContext.getCurrentScope(httpServletRequest);
|
||||
|
||||
}
|
||||
scope = pContext.getCurrentScope(scopeGroupId);
|
||||
|
||||
if (scope == null || scope.isEmpty()) {
|
||||
String error = "Error retrieving scope: " + scope;
|
||||
logger.error(error);
|
||||
|
@ -195,7 +200,11 @@ public class SessionUtil {
|
|||
String email = gCubeUser.getEmail();
|
||||
|
||||
if (hasScopeGroupId) {
|
||||
|
||||
logger.info("Set SecurityToken: "+token);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
logger.info("Set ScopeProvider: "+scope);
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
groupId = scopeGroupId;
|
||||
|
||||
long gId;
|
||||
|
@ -309,7 +318,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static void setTabularResources(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, List<TabularResource> trs) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<List<TabularResource>> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.SCOPE_TO_TABULAR_RESOURCE_LIST_MAP, trs);
|
||||
|
@ -323,7 +331,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static TRId getTRId(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<TRId> sessionOp = new SessionOp<>();
|
||||
TRId trId = sessionOp.get(httpRequest, serviceCredentials,
|
||||
SessionConstants.SCOPE_TO_CURRENT_TRID_MAP);
|
||||
|
@ -338,7 +345,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static void setTRId(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TRId trId) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<TRId> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.SCOPE_TO_CURRENT_TRID_MAP, trId);
|
||||
|
@ -352,7 +358,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static TabResource getTabResource(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<TabResource> sessionOp = new SessionOp<>();
|
||||
TabResource tabResource = sessionOp.get(httpRequest,
|
||||
serviceCredentials,
|
||||
|
@ -369,7 +374,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static void setTabResource(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TabResource tabResource) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<TabResource> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.SCOPE_TO_CURRENT_TABULAR_RESOURCE_MAP,
|
||||
|
@ -386,7 +390,6 @@ public class SessionUtil {
|
|||
public static ArrayList<TabResource> getCurrentTabularResourcesOpen(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<ArrayList<TabResource>> sessionOp = new SessionOp<>();
|
||||
ArrayList<TabResource> currentTROpen = sessionOp.get(httpRequest,
|
||||
serviceCredentials,
|
||||
|
@ -404,7 +407,6 @@ public class SessionUtil {
|
|||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
ArrayList<TabResource> currentTROpen) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<ArrayList<TabResource>> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.SCOPE_TO_CURRENT_TABULAR_RESOURCES_OPEN_MAP,
|
||||
|
@ -420,9 +422,6 @@ public class SessionUtil {
|
|||
public static void addToCurrentTabularResourcesOpen(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TabResource tabResource) {
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
if (tabResource.getTrId() != null
|
||||
&& tabResource.getTrId().getId() != null
|
||||
&& !tabResource.getTrId().getId().isEmpty()) {
|
||||
|
@ -479,7 +478,6 @@ public class SessionUtil {
|
|||
public static void removeFromCurrentTabularResourcesOpen(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TRId trId) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
if (trId != null && trId.getId() != null & !trId.getId().isEmpty()) {
|
||||
HttpSession httpSession = httpRequest.getSession();
|
||||
|
@ -529,7 +527,6 @@ public class SessionUtil {
|
|||
public static void removeAllFromCurrentTabularResourcesOpen(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<ArrayList<TabResource>> sessionOp = new SessionOp<>();
|
||||
sessionOp.remove(httpRequest, serviceCredentials,
|
||||
SessionConstants.SCOPE_TO_CURRENT_TABULAR_RESOURCES_OPEN_MAP);
|
||||
|
@ -544,7 +541,6 @@ public class SessionUtil {
|
|||
public static TabResource getFirstFromCurrentTabularResourcesOpen(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<ArrayList<TabResource>> sessionOp = new SessionOp<>();
|
||||
ArrayList<TabResource> openList = sessionOp.get(httpRequest,
|
||||
serviceCredentials,
|
||||
|
@ -569,7 +565,6 @@ public class SessionUtil {
|
|||
public static TabResource getFromCurrentTabularResourcesOpen(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TRId trId) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<ArrayList<TabResource>> sessionOp = new SessionOp<>();
|
||||
ArrayList<TabResource> openList = sessionOp.get(httpRequest,
|
||||
serviceCredentials,
|
||||
|
@ -602,7 +597,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static void setTDOpenSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TDOpenSession tdOpenSession) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<TDOpenSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.TDOPEN_SESSION, tdOpenSession);
|
||||
|
@ -611,7 +605,7 @@ public class SessionUtil {
|
|||
// TODO check
|
||||
// public static void retrieveResources(HttpServletRequest httpRequest,
|
||||
// ServiceCredentials serviceCredentials) {
|
||||
// ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
@ -628,7 +622,6 @@ public class SessionUtil {
|
|||
|
||||
public static void setSDMXImportTabResource(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TabResource tabResource) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<TabResource> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.SDMX_IMPORT_TABULAR_RESOURCE, tabResource);
|
||||
|
@ -648,7 +641,6 @@ public class SessionUtil {
|
|||
|
||||
public static void setCSVImportTabResource(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TabResource tabResource) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<TabResource> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.CSV_IMPORT_TABULAR_RESOURCE, tabResource);
|
||||
|
@ -658,7 +650,6 @@ public class SessionUtil {
|
|||
public static void setSDMXImportSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
SDMXImportSession sdmxImportSession) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<SDMXImportSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.SDMX_IMPORT_SESSION, sdmxImportSession);
|
||||
|
@ -679,7 +670,6 @@ public class SessionUtil {
|
|||
public static void setCSVImportSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
CSVImportSession csvImportSession) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<CSVImportSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.CSV_IMPORT_SESSION, csvImportSession);
|
||||
|
@ -698,7 +688,6 @@ public class SessionUtil {
|
|||
public static void setCSVExportSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
CSVExportSession csvExportSession) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<CSVExportSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.CSV_EXPORT_SESSION, csvExportSession);
|
||||
|
@ -718,7 +707,6 @@ public class SessionUtil {
|
|||
public static void setSDMXExportSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
SDMXExportSession sdmxExportSession) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<SDMXExportSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.SDMX_EXPORT_SESSION, sdmxExportSession);
|
||||
|
@ -737,7 +725,6 @@ public class SessionUtil {
|
|||
public static void setJSONExportSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
JSONExportSession jsonExportSession) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<JSONExportSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.JSON_EXPORT_SESSION, jsonExportSession);
|
||||
|
@ -758,7 +745,6 @@ public class SessionUtil {
|
|||
public static void setCSVFileUploadSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
CSVFileUploadSession csvFileUploadSession) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<CSVFileUploadSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.CSV_IMPORT_FILE_UPLOAD_SESSION,
|
||||
|
@ -781,7 +767,6 @@ public class SessionUtil {
|
|||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
CodelistMappingFileUploadSession codelistMappingFileUploadSession) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<CodelistMappingFileUploadSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.CODELIST_MAPPING_FILE_UPLOAD_SESSION,
|
||||
|
@ -860,7 +845,6 @@ public class SessionUtil {
|
|||
|
||||
public static void setSDMXClientInSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, SDMXClient sdmxClient) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<SDMXClient> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.SDMX_CLIENT_ATTRIBUTE, sdmxClient);
|
||||
|
@ -910,7 +894,6 @@ public class SessionUtil {
|
|||
//
|
||||
public static void setCSVExportEnd(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, Boolean end) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<Boolean> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.CSV_EXPORT_END, end);
|
||||
|
@ -1580,7 +1563,6 @@ public class SessionUtil {
|
|||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
CodelistMappingSession codelistMappingSession) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<CodelistMappingSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.CODELIST_MAPPING_SESSION,
|
||||
|
@ -1830,7 +1812,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static TaskWrapper getStartedTask(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, String taskId) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
TaskWrapper taskWrapper = null;
|
||||
|
||||
|
@ -1864,7 +1845,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static void removeStartedTask(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TaskWrapper taskWrapper) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
if (taskWrapper == null) {
|
||||
logger.error("TaskWrapper is null");
|
||||
|
@ -1906,8 +1886,6 @@ public class SessionUtil {
|
|||
public static void setStartedTask(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TaskWrapper taskWrapper) {
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
if (taskWrapper == null) {
|
||||
logger.error("TaskWrapper is null");
|
||||
return;
|
||||
|
@ -1951,7 +1929,6 @@ public class SessionUtil {
|
|||
public static HashMap<String, TaskWrapper> getAbortedTaskMap(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
SessionOp<HashMap<String, TaskWrapper>> sessionOp = new SessionOp<>();
|
||||
HashMap<String, TaskWrapper> tasksAborted = sessionOp.get(httpRequest,
|
||||
|
@ -1969,7 +1946,7 @@ public class SessionUtil {
|
|||
*/
|
||||
public static void setAbortedTasks(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TaskWrapper taskWrapper) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
|
||||
if (taskWrapper == null || taskWrapper.getTask() == null) {
|
||||
logger.error("TaskWrapper is null");
|
||||
|
@ -2015,7 +1992,7 @@ public class SessionUtil {
|
|||
public static HashMap<String, TaskWrapper> getHiddenTaskMap(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
|
||||
SessionOp<HashMap<String, TaskWrapper>> sessionOp = new SessionOp<>();
|
||||
HashMap<String, TaskWrapper> tasksHidden = sessionOp.get(httpRequest,
|
||||
|
@ -2033,7 +2010,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static void setHiddenTask(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TaskWrapper taskWrapper) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
if (taskWrapper == null) {
|
||||
logger.error("TaskWrapper is null");
|
||||
|
@ -2077,7 +2053,6 @@ public class SessionUtil {
|
|||
public static HashMap<String, TaskWrapper> getTaskInBackgroundMap(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
SessionOp<HashMap<String, TaskWrapper>> sessionOp = new SessionOp<>();
|
||||
HashMap<String, TaskWrapper> tasksInBackground = sessionOp.get(
|
||||
|
@ -2096,7 +2071,6 @@ public class SessionUtil {
|
|||
*/
|
||||
public static void setTaskInBackground(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TaskWrapper taskWrapper) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
if (taskWrapper == null) {
|
||||
logger.error("TaskWrapper is null");
|
||||
|
@ -2144,8 +2118,7 @@ public class SessionUtil {
|
|||
public static void removeTaskInBackground(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TaskWrapper taskWrapper) {
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
|
||||
if (taskWrapper == null) {
|
||||
logger.error("TaskWrapper is null");
|
||||
return;
|
||||
|
@ -2188,7 +2161,6 @@ public class SessionUtil {
|
|||
public static void removeAllTasksInBackground(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
SessionOp<HashMap<String, TaskWrapper>> sessionOp = new SessionOp<>();
|
||||
sessionOp.remove(httpRequest, serviceCredentials,
|
||||
|
@ -2207,7 +2179,7 @@ public class SessionUtil {
|
|||
public static void removeTaskInBackgroundOnTRId(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, TRId trId) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
|
||||
if (trId == null) {
|
||||
logger.error("TRId is null");
|
||||
|
|
|
@ -17,7 +17,6 @@ import javax.servlet.http.HttpSession;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
|
@ -65,15 +64,22 @@ public class TDLogsServlet extends HttpServlet {
|
|||
|
||||
logger.debug("TDLogsServlet import session id: " + session.getId());
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
throw new ServletException(
|
||||
"CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
}
|
||||
|
||||
try {
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
scopeGroupId);
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(
|
||||
"Error retrieving credentials:" + e.getLocalizedMessage(),
|
||||
|
|
|
@ -14,7 +14,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
|
@ -68,18 +67,23 @@ public class TDRStudioServlet extends HttpServlet {
|
|||
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
throw new ServletException(
|
||||
"CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
}
|
||||
|
||||
try {
|
||||
String scopeGroupId = request
|
||||
.getParameter(Constants.CURR_GROUP_ID);
|
||||
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
scopeGroupId);
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(
|
||||
"Error retrieving credentials:"
|
||||
+ e.getLocalizedMessage(), e);
|
||||
"Error retrieving credentials:" + e.getLocalizedMessage(),
|
||||
e);
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
|
@ -64,20 +63,26 @@ public class TabularDataRowsXServlet extends HttpServlet {
|
|||
}
|
||||
logger.info("Session id: " + session.getId());
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
if (scopeGroupId == null || scopeGroupId.isEmpty()) {
|
||||
logger.error("CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
throw new ServletException(
|
||||
"CURR_GROUP_ID is null, it is a mandatory parameter in custom servlet: "
|
||||
+ scopeGroupId);
|
||||
}
|
||||
|
||||
try {
|
||||
String scopeGroupId = request
|
||||
.getParameter(Constants.CURR_GROUP_ID);
|
||||
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
scopeGroupId);
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(
|
||||
"Error retrieving credentials:"
|
||||
+ e.getLocalizedMessage(), e);
|
||||
"Error retrieving credentials:" + e.getLocalizedMessage(),
|
||||
e);
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue