- 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-value>rstudio-dev.d4science.org</param-value>
</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-name>org.gcube.data.analysis.rconnector.RConnector</servlet-name>
</servlet>

View File

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

View File

@ -16,10 +16,12 @@ import lombok.extern.slf4j.Slf4j;
public class ConfigFileWriter {
public boolean write(Info info, String login, String usersHome, String fileName, String scriptToExecute){
if (!usersHome.endsWith("/"))
usersHome=usersHome+"/";
File userDir = new File(usersHome+login);
public boolean write(Info info, String login, String fileName, String configFilePath, String scriptToExecute){
if (!configFilePath.endsWith("/"))
configFilePath=configFilePath+"/";
File userDir = new File(configFilePath+login);
if (!userDir.exists())
userDir.mkdir();
File configFile= new File(userDir, fileName);
Utils.executeCommandLine(scriptToExecute,login, SecurityTokenProvider.instance.get(), ScopeProvider.instance.get());
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());
String login = AuthorizationProvider.instance.get().getClient().getId();
String usersHome = context.getInitParameter("usersHome");
//String usersHome = context.getInitParameter("usersHome");
String filename = context.getInitParameter("filename");
String configFilePath = context.getInitParameter("userConfigBasePath");
String scriptToExecute = context.getInitParameter("addUserScript");
if (ScopeProvider.instance.get()==null || login == null || tabularResourceId ==null ) return Response.serverError().build();
Info info;
@ -57,7 +58,7 @@ public class Resource {
log.error("error connecting to r",e);
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);
}
@ -83,6 +84,7 @@ public class Resource {
try{
String keyFilePath = context.getInitParameter("storedKeyPath");
String rStudioServerAddress = context.getInitParameter("rStudioAddress");
String rStudioProtocol = context.getInitParameter("rStudioProtocol");
log.debug("key file path: "+keyFilePath);
log.debug("rstudio server address: "+rStudioServerAddress);
@ -113,7 +115,7 @@ public class Resource {
"/", 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();
}catch(Exception e){
log.error("error creating response", e);