package io.corbel.resources.rem.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;

import io.corbel.resources.rem.model.AclPermission;

/**
 * @author Cristian del Cerro
 */
public class AclUtils {

    private AclUtils() {}

    public static String buildMessage(AclPermission permission) {
        return permission + " permission is required to perform the operation";
    }

    public static boolean entityIsEmpty(Optional<InputStream> entity) {
        return !entity.filter(e -> !entityIsEmpty(e)).isPresent();
    }

    public static boolean entityIsEmpty(InputStream entity) {
        try {
            return entity.available() == 0;
        } catch (IOException e) {
            return true;
        }
    }
}

@@ -170,16 +170,74 @@
 ssion;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A
 /**%0A * @
@@ -291,16 +291,96 @@
 tils %7B%0A%0A
+    private static final Logger LOG = LoggerFactory.getLogger(AclUtils.class);%0A%0A
     priv
@@ -847,24 +847,93 @@
 eption e) %7B%0A
+            LOG.error(%22Fail to check input stream availability%22, e);%0A
             

add log to acl utils