class ApplicationV1FilterTransformer {

    public void transformJson(final JsonValue jsonValue, final Subject callingSubject, final String realm)
            throws EntitlementException {

        final Map<String, Boolean> actions = new HashMap<>();
        final Set<String> resources = new HashSet<>();

        final Set<String> resourceTypeUuids = jsonValue
                .get(RESOURCE_TYPE_UUIDS)
                .required()
                .asSet(String.class);

        for (String resourceTypeUuid : resourceTypeUuids) {
            final ResourceType resourceType = resourceTypeService
                    .getResourceType(callingSubject, realm, resourceTypeUuid);

            if (resourceType == null) {
                throw new EntitlementException(EntitlementException.NO_SUCH_RESOURCE_TYPE, resourceTypeUuid);
            }

            actions.putAll(resourceType.getActions());
            resources.addAll(resourceType.getPatterns());
        }

        jsonValue.remove(RESOURCE_TYPE_UUIDS);
        jsonValue.remove(APPLICATION_DISPLAY_NAME);
        jsonValue.add(ACTIONS, actions);
        jsonValue.add(RESOURCES, resources);
        jsonValue.add(REALM, realm);
    }

    @Inject public  ApplicationV1FilterTransformer(ContextHelper contextHelper, ResourceTypeService resourceTypeService,
            ExceptionMappingHandler<EntitlementException, ResourceException> resourceErrorHandler);

}