Skip to content
Snippets Groups Projects
Commit b1ed2b5f authored by tpylak's avatar tpylak
Browse files

LMS-547 authorization for datasets: check for tryGetDataSet

SVN: 7969
parent 7c9118ef
No related branches found
No related tags found
No related merge requests found
...@@ -41,10 +41,10 @@ final class DataSetService implements IDataSetService ...@@ -41,10 +41,10 @@ final class DataSetService implements IDataSetService
// IDataSetService // IDataSetService
// //
public final ExternalData getDataSet(final String sessionToken, final String dataSetCode) public final ExternalData tryGetDataSet(final String sessionToken, final String dataSetCode)
throws UserFailureException throws UserFailureException
{ {
return service.getDataSet(sessionToken, dataSetCode); return service.tryGetDataSet(sessionToken, dataSetCode);
} }
public final String authenticate(final String user, final String password) public final String authenticate(final String user, final String password)
......
...@@ -391,15 +391,20 @@ public class DatasetDownloadServlet extends HttpServlet ...@@ -391,15 +391,20 @@ public class DatasetDownloadServlet extends HttpServlet
if (sessionIdOrNull != null) if (sessionIdOrNull != null)
{ {
IDataSetService dataSetService = applicationContext.getDataSetService(); IDataSetService dataSetService = applicationContext.getDataSetService();
ExternalData dataSet = dataSetService.getDataSet(sessionIdOrNull, dataSetCode); ExternalData dataSet = dataSetService.tryGetDataSet(sessionIdOrNull, dataSetCode);
if (operationLog.isInfoEnabled()) if (operationLog.isInfoEnabled())
{ {
operationLog.info("Data set '" + dataSetCode + "' obtained from openBIS server."); String actionDesc = (dataSet != null) ? "obtained from" : "not found in";
operationLog.info(String.format("Data set '%s' %s openBIS server.", dataSetCode,
actionDesc));
} }
HttpSession session = request.getSession(true); HttpSession session = request.getSession(true);
ConfigParameters configParameters = applicationContext.getConfigParameters(); ConfigParameters configParameters = applicationContext.getConfigParameters();
session.setMaxInactiveInterval(configParameters.getSessionTimeout()); session.setMaxInactiveInterval(configParameters.getSessionTimeout());
putDataSetToMap(session, dataSetCode, dataSet); if (dataSet != null)
{
putDataSetToMap(session, dataSetCode, dataSet);
}
} }
} }
......
...@@ -495,7 +495,7 @@ public class DatasetDownloadServletTest ...@@ -495,7 +495,7 @@ public class DatasetDownloadServletTest
context.checking(new Expectations() context.checking(new Expectations()
{ {
{ {
one(dataSetService).getDataSet(EXAMPLE_SESSION_ID, EXAMPLE_DATA_SET_CODE); one(dataSetService).tryGetDataSet(EXAMPLE_SESSION_ID, EXAMPLE_DATA_SET_CODE);
will(returnValue(externalData)); will(returnValue(externalData));
one(request).getSession(true); one(request).getSession(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment