class WorkflowAction {

    protected Resource extractResourceIdAndTypeFromUri(String uri) {
        Pattern patt = Pattern.compile("[vV]\\d+.*?(?:(?:/(?<type>" + SUPPORTEDTYPES
                + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?(?:/resume)?)?$");
        Matcher m = patt.matcher(uri);
        boolean generated = false;

        if (m.find()) {
            logger.debug("found match on {} : {} ", uri, m);
            String type = m.group("type");
            String id = m.group("id");
            String action = m.group("action");
            if (type == null) {
                throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri);
            }
            if (action == null) {
                if (type.equals(SERVICE_INSTANCES) && (id == null || "assign".equals(id))) {
                    id = UUID.randomUUID().toString();
                    generated = true;
                } else if (type.equals(VF_MODULES) && "scaleOut".equals(id)) {
                    id = UUID.randomUUID().toString();
                    generated = true;
                }
            } else {
                if (action.matches(SUPPORTEDTYPES)) {
                    id = UUID.randomUUID().toString();
                    generated = true;
                    type = action;
                }
            }
            return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated);
        } else {
            throw new IllegalArgumentException("Uri could not be parsed: " + uri);
        }
    }

}