class BlockManipulationServiceImpl implements IBlockManipulationService {

    @Override
    public String getBlockUuidByNumber(Metafile metafile, int blockNumber)
            throws MetafileIsFolderException, BlockDoesNotExistException {
        List<String> blockUuidList = metafile.getBlockUuidList();
        if (metafile.getProperties().containsValue(FileType.DIR.toString())) {
            StringBuilder sb = new StringBuilder();
            sb.append(getMetafileInfoForLog(metafile, "getBlockUuidByNumber"));
            sb.append(", is folder.");
            throw new MetafileIsFolderException(sb.toString());
        } else {
            if (blockUuidList.size() < blockNumber) {
                StringBuilder sb = new StringBuilder();
                sb.append(getMetafileInfoForLog(metafile, "getBlockUuidByNumber"));
                sb.append(", has block count: ");
                sb.append(blockUuidList.size());
                sb.append(", requested number is: ");
                sb.append(blockNumber);
                throw new BlockDoesNotExistException(sb.toString());
            }
        }

        return blockUuidList.get(blockNumber);
    }

}