@@ -0,0 +1,2822 @@
+package flyway.asdi;%0A%0Aimport fi.nls.oskari.domain.map.view.Bundle;%0Aimport fi.nls.oskari.domain.map.view.View;%0Aimport fi.nls.oskari.log.LogFactory;%0Aimport fi.nls.oskari.log.Logger;%0Aimport fi.nls.oskari.map.view.ViewService;%0Aimport fi.nls.oskari.map.view.ViewServiceIbatisImpl;%0Aimport fi.nls.oskari.view.modifier.ViewModifier;%0Aimport org.flywaydb.core.api.migration.jdbc.JdbcMigration;%0Aimport org.json.JSONArray;%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;%0A%0Aimport java.sql.Connection;%0Aimport java.util.List;%0A%0A/**%0A * Removed mapUrlPrefix and termsUrl config from LogoPlugin if available%0A */%0Apublic class V1_5_0__Remove_LogoPlugin_config implements JdbcMigration %7B%0A%0A    private static final Logger LOG = LogFactory.getLogger(V1_5_0__Remove_LogoPlugin_config.class);%0A%0A    private ViewService service = new ViewServiceIbatisImpl();%0A    private static final int BATCH_SIZE = 50;%0A    private int updatedViewCount = 0;%0A%0A    private static final String PLUGIN_NAME = %22Oskari.mapframework.bundle.mapmodule.plugin.LogoPlugin%22;%0A%0A    public void migrate(Connection connection)%0A            throws Exception %7B%0A        int page = 1;%0A        while(updateViews(page)) %7B%0A            page++;%0A        %7D%0A        LOG.info(%22Updated views:%22, updatedViewCount);%0A    %7D%0A    private boolean updateViews(int page)%0A            throws Exception %7B%0A        List%3CView%3E list = service.getViews(page, BATCH_SIZE);%0A        LOG.info(%22Got%22, list.size(), %22views on page%22, page);%0A        for(View view : list) %7B%0A            final Bundle mapfull = view.getBundleByName(ViewModifier.BUNDLE_MAPFULL);%0A            boolean changed = adjustPlugin(mapfull);%0A            if(!changed) %7B%0A                // if neither was done, skip update%0A                continue;%0A            %7D%0A            service.updateBundleSettingsForView(view.getId(), mapfull);%0A            updatedViewCount++;%0A        %7D%0A        return list.size() == BATCH_SIZE;%0A    %7D%0A%0A%0A    private boolean adjustPlugin(final Bundle mapfull) throws JSONException %7B%0A        final JSONObject config = mapfull.getConfigJSON();%0A        final JSONArray plugins = config.optJSONArray(%22plugins%22);%0A        if(plugins == null) %7B%0A            throw new RuntimeException(%22No plugins%22 + config.toString(2));%0A            //continue;%0A        %7D%0A        boolean found = false;%0A        for(int i = 0; i %3C plugins.length(); ++i) %7B%0A            JSONObject plugin = plugins.getJSONObject(i);%0A            if(PLUGIN_NAME.equals(plugin.optString(%22id%22))) %7B%0A                JSONObject pluginConfig = plugin.getJSONObject(%22config%22);%0A                if(pluginConfig == null) %7B%0A                    break;%0A                %7D%0A                pluginConfig.remove(%22mapUrlPrefix%22);%0A                pluginConfig.remove(%22termsUrl%22);%0A                found = true;%0A                break;%0A            %7D%0A        %7D%0A        return found;%0A    %7D%0A%7D%0A

Add migration to remove unnecessary config in db