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