Commit fb964b1c authored by Spiros Koulouzis's avatar Spiros Koulouzis

Added delete all

parent f8bf53aa
......@@ -174,7 +174,7 @@ Accept: application/json
}, {
"name" : "...",
"id" : "...",
"type" : "PRIVATE",
"type" : "PUBLIC",
"attributes" : {
"property1" : "...",
"property2" : "..."
......@@ -429,7 +429,7 @@ Content-Type: application/json
}, {
"name" : "...",
"id" : "...",
"type" : "PUBLIC",
"type" : "PRIVATE",
"attributes" : {
"property1" : "...",
"property2" : "..."
......
......@@ -17,6 +17,7 @@ package nl.uva.sne.drip.api.service;
import java.util.List;
import nl.uva.sne.drip.api.dao.CloudCredentialsDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.commons.v1.types.CloudCredentials;
import nl.uva.sne.drip.commons.v1.types.User;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -47,12 +48,18 @@ public class CloudCredentialsService {
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public CloudCredentials findOne(String id) {
CloudCredentials creds = dao.findOne(id);
if (creds == null) {
throw new NotFoundException();
}
return creds;
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public CloudCredentials delete(String id) {
CloudCredentials creds = dao.findOne(id);
if (creds == null) {
throw new NotFoundException();
}
dao.delete(creds);
return creds;
}
......
......@@ -69,7 +69,11 @@ public class DeployClusterService {
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public ClusterCredentials findOne(String id) {
return dao.findOne(id);
ClusterCredentials creds = dao.findOne(id);
if (creds == null) {
throw new NotFoundException();
}
return creds;
}
@PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
......@@ -79,9 +83,12 @@ public class DeployClusterService {
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public ClusterCredentials delete(String id) {
ClusterCredentials cred = dao.findOne(id);
dao.delete(cred);
return cred;
ClusterCredentials creds = dao.findOne(id);
if (creds == null) {
throw new NotFoundException();
}
dao.delete(creds);
return creds;
}
public ClusterCredentials save(ClusterCredentials clusterCred) {
......
......@@ -187,7 +187,12 @@ public class PlannerService {
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public Plan findOne(String lowiID) {
return planDao.findOne(lowiID);
Plan plan = planDao.findOne(lowiID);
if (plan == null) {
throw new NotFoundException();
}
return plan;
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
......
......@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import nl.uva.sne.drip.api.dao.ScriptDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.commons.v1.types.Script;
import nl.uva.sne.drip.commons.v1.types.User;
import org.springframework.security.access.prepost.PostAuthorize;
......@@ -47,12 +48,18 @@ public class UserScriptService {
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public Script findOne(String id) {
Script script = dao.findOne(id);
if (script == null) {
throw new NotFoundException();
}
return script;
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public Script delete(String id) {
Script script = dao.findOne(id);
if (script == null) {
throw new NotFoundException();
}
dao.delete(script);
return script;
}
......
......@@ -33,7 +33,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.service.UserService;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.RequestBody;
......
......@@ -31,7 +31,6 @@ import org.springframework.web.multipart.MultipartFile;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.commons.v1.types.Script;
import org.springframework.web.bind.annotation.PathVariable;
import nl.uva.sne.drip.api.dao.ScriptDao;
import nl.uva.sne.drip.api.service.UserScriptService;
/**
......
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