- userConfig file moved to a configurable path
 - RStudio server protocol configuration added.
This commit is contained in:
lucio 2020-03-04 12:36:20 +01:00
parent 51cf1be90c
commit abb51ffc59
4 changed files with 20 additions and 8 deletions

View File

@ -23,6 +23,14 @@
<param-name>rStudioAddress</param-name> <param-name>rStudioAddress</param-name>
<param-value>rstudio-dev.d4science.org</param-value> <param-value>rstudio-dev.d4science.org</param-value>
</context-param> </context-param>
<context-param>
<param-name>rStudioProtocol</param-name>
<param-value>https</param-value>
</context-param>
<context-param>
<param-name>userConfigBasePath</param-name>
<param-value>/srv/rconnector/</param-value>
</context-param>
<servlet> <servlet>
<servlet-name>org.gcube.data.analysis.rconnector.RConnector</servlet-name> <servlet-name>org.gcube.data.analysis.rconnector.RConnector</servlet-name>
</servlet> </servlet>

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.data.analysis</groupId> <groupId>org.gcube.data.analysis</groupId>
<artifactId>r-connector</artifactId> <artifactId>r-connector</artifactId>
<version>2.1.4-SNAPSHOT</version> <version>2.1.5-SNAPSHOT</version>
<name>RConnector</name> <name>RConnector</name>
<description>makes R available in the infrastructure</description> <description>makes R available in the infrastructure</description>

View File

@ -16,10 +16,12 @@ import lombok.extern.slf4j.Slf4j;
public class ConfigFileWriter { public class ConfigFileWriter {
public boolean write(Info info, String login, String usersHome, String fileName, String scriptToExecute){ public boolean write(Info info, String login, String fileName, String configFilePath, String scriptToExecute){
if (!usersHome.endsWith("/")) if (!configFilePath.endsWith("/"))
usersHome=usersHome+"/"; configFilePath=configFilePath+"/";
File userDir = new File(usersHome+login); File userDir = new File(configFilePath+login);
if (!userDir.exists())
userDir.mkdir();
File configFile= new File(userDir, fileName); File configFile= new File(userDir, fileName);
Utils.executeCommandLine(scriptToExecute,login, SecurityTokenProvider.instance.get(), ScopeProvider.instance.get()); Utils.executeCommandLine(scriptToExecute,login, SecurityTokenProvider.instance.get(), ScopeProvider.instance.get());
return writeFile(info, configFile); return writeFile(info, configFile);

View File

@ -45,8 +45,9 @@ public class Resource {
log.info("connect called with user {} and trID {} in scope {}",AuthorizationProvider.instance.get().getClient().getId(), tabularResourceId, ScopeProvider.instance.get()); log.info("connect called with user {} and trID {} in scope {}",AuthorizationProvider.instance.get().getClient().getId(), tabularResourceId, ScopeProvider.instance.get());
String login = AuthorizationProvider.instance.get().getClient().getId(); String login = AuthorizationProvider.instance.get().getClient().getId();
String usersHome = context.getInitParameter("usersHome"); //String usersHome = context.getInitParameter("usersHome");
String filename = context.getInitParameter("filename"); String filename = context.getInitParameter("filename");
String configFilePath = context.getInitParameter("userConfigBasePath");
String scriptToExecute = context.getInitParameter("addUserScript"); String scriptToExecute = context.getInitParameter("addUserScript");
if (ScopeProvider.instance.get()==null || login == null || tabularResourceId ==null ) return Response.serverError().build(); if (ScopeProvider.instance.get()==null || login == null || tabularResourceId ==null ) return Response.serverError().build();
Info info; Info info;
@ -57,7 +58,7 @@ public class Resource {
log.error("error connecting to r",e); log.error("error connecting to r",e);
return Response.serverError().build(); return Response.serverError().build();
} }
if (!writer.write(info, login, usersHome, filename, scriptToExecute)) return Response.serverError().build(); if (!writer.write(info, login, filename, configFilePath, scriptToExecute)) return Response.serverError().build();
return createResponse(login); return createResponse(login);
} }
@ -83,6 +84,7 @@ public class Resource {
try{ try{
String keyFilePath = context.getInitParameter("storedKeyPath"); String keyFilePath = context.getInitParameter("storedKeyPath");
String rStudioServerAddress = context.getInitParameter("rStudioAddress"); String rStudioServerAddress = context.getInitParameter("rStudioAddress");
String rStudioProtocol = context.getInitParameter("rStudioProtocol");
log.debug("key file path: "+keyFilePath); log.debug("key file path: "+keyFilePath);
log.debug("rstudio server address: "+rStudioServerAddress); log.debug("rstudio server address: "+rStudioServerAddress);
@ -113,7 +115,7 @@ public class Resource {
"/", rStudioServerAddress, "", -1, false, true ); "/", rStudioServerAddress, "", -1, false, true );
return Response.seeOther(new URI("http://"+rStudioServerAddress)) return Response.seeOther(new URI(String.format("%s://%s", rStudioProtocol, rStudioServerAddress)))
.cookie(cookie).build(); .cookie(cookie).build();
}catch(Exception e){ }catch(Exception e){
log.error("error creating response", e); log.error("error creating response", e);