class SingleRepositoryServiceImpl implements SingleRepositoryService {

    @Override
    public void deleteResource(String uri) throws IllegalParameterValueException, AccessDeniedException {
        if (uri == null || "".equals(uri)) {
            throw new IllegalParameterValueException("uri", uri);
        }
        if(uriHardModifyProtectionChecker.isHardModifyProtected(uri)){
            throw new AccessDeniedException("", uri);
        }

        try {
            Resource resource = repositoryService.getResource(null, uri);
            if (resource != null) {
                List<ResourceLookup> dependentResources = repositoryService.getDependentResources(null, uri, searchCriteriaFactory, 0, 0);

                if (dependentResources == null || dependentResources.isEmpty() || isAllTemporary(dependentResources)){
                    if (dependentResources != null){
                        for (ResourceLookup resourceLookup: dependentResources){
                            repositoryService.deleteResource(null, resourceLookup.getURIString());
                        }
                    }

                    repositoryService.deleteResource(null, uri);
                } else {
                    throw new ResourceInUseException(dependentResources);
                }
            } else {
                resource = repositoryService.getFolder(null, uri);
                if (resource != null) {
                    repositoryService.deleteFolder(null, uri);
                }
            }
        } catch (org.springframework.security.access.AccessDeniedException sse) {
            throw new AccessDeniedException(uri);
        } catch (JSExceptionWrapper w){
            throw getRootException(w);
        }
    }

}