if (parent == null) {
throw new ResourceNotFoundException("Intended parent for new resource does not exist.");
}
if (!authorizationManager.hasResourcePermission(user, Permission.CREATE_CHILD_RESOURCES, parent.getId())) {
throw new PermissionException("You do not have permission to add this resource as a child.");
}
if (getResourceByParentAndKey(user, parent, resource.getResourceKey(), resource.getResourceType()
.getPlugin(), resource.getResourceType().getName()) != null) {
throw new ResourceAlreadyExistsException("Resource with key '" + resource.getResourceKey()