Commit 93dd552b authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Added busy and immutable management to delete

parent f919f87c
Loading
Loading
Loading
Loading
+34 −21
Original line number Diff line number Diff line
@@ -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);
                }

            }