Commit d321db54 authored by Spiros Koulouzis's avatar Spiros Koulouzis

set the timestamps on all services

parent c0f77bfa
......@@ -66,11 +66,12 @@ public class AnsibleOutputService {
return ansibleOut;
}
public AnsibleOutput save(AnsibleOutput ansibleOut) {
public AnsibleOutput save(AnsibleOutput ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
ansibleOut.setOwner(owner);
return ansibleOutputDao.save(ansibleOut);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return ansibleOutputDao.save(ownedObject);
}
@PostAuthorize("(hasRole('ROLE_ADMIN'))")
......
......@@ -62,11 +62,12 @@ public class BenchmarkResultService {
return benchmarkResult;
}
public BenchmarkResult save(BenchmarkResult benchmarkResult) {
public BenchmarkResult save(BenchmarkResult ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
benchmarkResult.setOwner(owner);
return benchmarkResultDao.save(benchmarkResult);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return benchmarkResultDao.save(ownedObject);
}
@PostAuthorize("(hasRole('ROLE_ADMIN'))")
......
......@@ -39,12 +39,12 @@ public class CloudCredentialsService {
@Autowired
private CloudCredentialsDao dao;
public CloudCredentials save(CloudCredentials cloudCredentials) {
public CloudCredentials save(CloudCredentials ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
cloudCredentials.setOwner(owner);
cloudCredentials.setTimestamp(System.currentTimeMillis());
return dao.save(cloudCredentials);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return dao.save(ownedObject);
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
......
......@@ -105,11 +105,12 @@ public class ConfigurationService {
return dao.findOne(id);
}
private ConfigurationRepresentation save(ConfigurationRepresentation t) {
private ConfigurationRepresentation save(ConfigurationRepresentation ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
t.setOwner(owner);
return dao.save(t);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return dao.save(ownedObject);
}
@PostAuthorize("(hasRole('ROLE_ADMIN'))")
......
......@@ -123,11 +123,12 @@ public class DeployService {
return creds;
}
public DeployResponse save(DeployResponse clusterCred) {
public DeployResponse save(DeployResponse ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
clusterCred.setOwner(owner);
return deployDao.save(clusterCred);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return deployDao.save(ownedObject);
}
public DeployResponse deploySoftware(DeployRequest deployInfo) throws Exception {
......
......@@ -15,10 +15,8 @@
*/
package nl.uva.sne.drip.api.service;
import java.util.ArrayList;
import java.util.List;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
......@@ -59,11 +57,12 @@ public class KeyPairService {
return k;
}
public KeyPair save(KeyPair keyPair) {
public KeyPair save(KeyPair ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
keyPair.setOwner(owner);
return dao.save(keyPair);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return dao.save(ownedObject);
}
@PostAuthorize("(hasRole('ROLE_ADMIN'))")
......
......@@ -64,10 +64,11 @@ public class MonitorringMessageService {
dao.deleteAll();
}
public MonitorringMessage save(MonitorringMessage message) {
public MonitorringMessage save(MonitorringMessage ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
message.setOwner(owner);
return dao.save(message);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return dao.save(ownedObject);
}
}
......@@ -191,11 +191,12 @@ public class PlannerService {
return topLevel;
}
public PlanResponse save(PlanResponse plan) {
public PlanResponse save(PlanResponse ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
plan.setOwner(owner);
return planDao.save(plan);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return planDao.save(ownedObject);
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
......
......@@ -89,11 +89,12 @@ public class ProvisionService {
@Value("${message.broker.host}")
private String messageBrokerHost;
public ProvisionResponse save(ProvisionResponse provision) {
public ProvisionResponse save(ProvisionResponse ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
provision.setOwner(owner);
return provisionDao.save(provision);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return provisionDao.save(ownedObject);
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
......@@ -487,7 +488,7 @@ public class ProvisionService {
cloudProvider = (String) topology.get("cloudProvider");
domain = (String) topology.get("domain");
scaleNameExists = true;
} else if (topology.get("tag").equals("scaled")
} else if (topology.get("tag").equals("scaled")
&& topology.get("status").equals("running")
&& topology.get("copyOf").equals(scaleName)) {
currentNumOfInstances++;
......
......@@ -38,11 +38,12 @@ public class ScriptService {
@Autowired
ScriptDao dao;
public Script save(Script script) {
public Script save(Script ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
script.setOwner(owner);
return dao.save(script);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return dao.save(ownedObject);
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
......
......@@ -130,11 +130,12 @@ public class ToscaService {
return tr;
}
private ToscaRepresentation save(ToscaRepresentation t) {
private ToscaRepresentation save(ToscaRepresentation ownedObject) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
t.setOwner(owner);
return dao.save(t);
ownedObject.setOwner(owner);
ownedObject.setTimestamp(System.currentTimeMillis());
return dao.save(ownedObject);
}
@PostAuthorize("(hasRole('ROLE_ADMIN'))")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment