Skip to content
Snippets Groups Projects
Commit 93dd552b authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Added busy and immutable management to delete

parent f919f87c
No related branches found
No related tags found
1 merge request!1Immutable
......@@ -20,13 +20,14 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Isolation;
import it.inaf.ia2.aa.data.User;
import it.inaf.oats.vospace.exception.InternalFaultException;
import it.inaf.oats.vospace.exception.NodeBusyException;
import org.springframework.transaction.annotation.Transactional;
/**
*
* @author Nicola Fulvio Calabria <nicola.calabria at inaf.it>
*/
@Service
@EnableTransactionManagement
public class DeleteNodeService {
......@@ -48,6 +49,16 @@ public class DeleteNodeService {
throw PermissionDeniedException.forPath(path);
}
Long nodeId = nodeDao.getNodeId(path).get();
if (nodeDao.isBranchBusy(nodeId)) {
throw new NodeBusyException(path);
}
if (nodeDao.isBranchImmutable(nodeId)) {
throw new InternalFaultException("Target branch contains immutable nodes");
}
nodeDao.deleteNode(path);
}
......@@ -79,7 +90,9 @@ public class DeleteNodeService {
Node mynode = nodeDao.listNode(tmpPath)
.orElseThrow(() -> new NodeNotFoundException(tmpPath));
if (mynode.getType().equals("vos:LinkNode") && i < pathComponents.size() - 1) // a LinkNode leaf can be deleted
{
throw new LinkFoundException(tmpPath);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment