package jnpf.dmsEntity.storage; import jnpf.dmsEntity.storage.enums.DmsWorkflowFileType; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.HexFormat; public final class DmsWorkflowSourceKey { private DmsWorkflowSourceKey() { } public static String of(String flowId, String taskId, DmsWorkflowFileType type) { String flow = flowId.trim(); String task = taskId.trim(); String identity = type.name() + ":" + flow.length() + ":" + flow + ":" + task; try { return "workflow:" + HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256") .digest(identity.getBytes(StandardCharsets.UTF_8))); } catch (NoSuchAlgorithmException exception) { throw new IllegalStateException(exception); } } }