Added possibility to exclude single or all user to write to workspace
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@178710 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fc5e616101
commit
fb6c980623
|
@ -265,7 +265,7 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
|
|||
}
|
||||
|
||||
public void setEnvironmentVariableManager(EnvironmentVariableManager env) {
|
||||
|
||||
this.env = env;
|
||||
}
|
||||
|
||||
public void updateComputationOnWS(float status, String exception) {
|
||||
|
@ -334,6 +334,9 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
|
|||
InputsManager inputsManager = null;
|
||||
ConfigurationManager configManager = new ConfigurationManager(this.env); // initializes parameters from web.xml
|
||||
manageUserToken();
|
||||
|
||||
boolean canWriteOnShub = checkWriteAuthorization(tokenm.getUserName());
|
||||
|
||||
Path dir = Paths.get(System.getProperty("java.io.tmpdir"), "dmlocks");
|
||||
if (!Files.exists(dir))
|
||||
dir = Files.createDirectory(dir);
|
||||
|
@ -456,7 +459,7 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
|
|||
endTime = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(System.currentTimeMillis());
|
||||
if (!isCancelled()) {
|
||||
LOGGER.debug("Save Computation Data");
|
||||
saveComputationOnWS(inputsManager.getProvenanceData(), outputmanager.getProvenanceData(), agent, generatedFiles);
|
||||
if (canWriteOnShub) saveComputationOnWS(inputsManager.getProvenanceData(), outputmanager.getProvenanceData(), agent, generatedFiles);
|
||||
} else {
|
||||
LOGGER.debug("Computation interrupted - no update");
|
||||
throw new Exception("Computation cancelled");
|
||||
|
@ -471,9 +474,9 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
|
|||
exitstatus = -1;
|
||||
|
||||
if (inputsManager != null)
|
||||
updateComputationOnWS(exitstatus, e.getMessage(), inputsManager.getProvenanceData(), generatedFiles);
|
||||
if (canWriteOnShub) updateComputationOnWS(exitstatus, e.getMessage(), inputsManager.getProvenanceData(), generatedFiles);
|
||||
else
|
||||
updateComputationOnWS(exitstatus, e.getMessage());
|
||||
if (canWriteOnShub) updateComputationOnWS(exitstatus, e.getMessage());
|
||||
if (isCancelled())
|
||||
throw new Exception("Computation cancelled");
|
||||
else
|
||||
|
@ -500,6 +503,14 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
|
|||
|
||||
}
|
||||
|
||||
private boolean checkWriteAuthorization(String username) {
|
||||
if (env!=null && env.getShubUsersExcluded()!=null) {
|
||||
if (env.getShubUsersExcluded().isEmpty()) return false;
|
||||
else if (env.getShubUsersExcluded().contains(username)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void accountAlgorithmExecution(long start, long end, OperationResult result) {
|
||||
try{
|
||||
JobUsageRecord jobUsageRecord = new JobUsageRecord();
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnvironmentVariableManager {
|
||||
|
||||
public EnvironmentVariableManager(int maxComputation, boolean saveOnStorage, boolean simulationMode) {
|
||||
public EnvironmentVariableManager(int maxComputation, boolean saveOnStorage, boolean simulationMode, List<String> shubUsersExcluded) {
|
||||
super();
|
||||
this.maxComputation = maxComputation;
|
||||
this.saveOnStorage = saveOnStorage;
|
||||
|
@ -12,6 +14,11 @@ public class EnvironmentVariableManager {
|
|||
private boolean saveOnStorage;
|
||||
private boolean simulationMode;
|
||||
|
||||
//null: all users will write on SHub
|
||||
//empty: no one will write on Shub
|
||||
//filled: users reported will not write on Shub
|
||||
private List<String> shubUsersExcluded;
|
||||
|
||||
public int getMaxComputation() {
|
||||
return maxComputation;
|
||||
}
|
||||
|
@ -22,5 +29,9 @@ public class EnvironmentVariableManager {
|
|||
return simulationMode;
|
||||
}
|
||||
|
||||
public List<String> getShubUsersExcluded() {
|
||||
return shubUsersExcluded;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue