class ConfigurationTypeResourceImpl implements ConfigurationTypeResource {

    @Override
    public Map<String, String> migrate(final String id, final int version, final Map<String, String> config) {
        if (virtualComponents.isExtensionEntity(id)) {
            return config;
        }
        final Config configuration = ofNullable(configurations.findById(id))
                .orElseThrow(() -> new WebApplicationException(Response
                        .status(Response.Status.NOT_FOUND)
                        .entity(new ErrorPayload(ErrorDictionary.CONFIGURATION_MISSING,
                                "Didn't find configuration " + id))
                        .build()));
        final Map<String, String> configToMigrate = new HashMap<>(config);
        final String versionKey = configuration.getMeta().getPath() + ".__version";
        final boolean addedVersion = configToMigrate.putIfAbsent(versionKey, Integer.toString(version)) == null;
        final Map<String, String> migrated = configuration.getMigrationHandler().migrate(version, configToMigrate);
        if (addedVersion) {
            migrated.remove(versionKey);
        }
        return migrated;
    }

}