From ee4de05ebeb46ca2818fbea996206ac6f51ea12e Mon Sep 17 00:00:00 2001 From: jampukka Date: Fri, 16 Dec 2022 14:50:32 +0200 Subject: [PATCH 01/26] Use Oskari 2.x artifacts --- hsy-resources/pom.xml | 10 ++-------- pom.xml | 8 ++++---- server-extension/pom.xml | 6 +++--- webapp-map/pom.xml | 40 +++++++++++++++++++++------------------- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/hsy-resources/pom.xml b/hsy-resources/pom.xml index 9f6f5d5..9121356 100644 --- a/hsy-resources/pom.xml +++ b/hsy-resources/pom.xml @@ -6,21 +6,15 @@ fi.hsy.oskari hsy-parent - 1.5.3 + 1.6.0-SNAPSHOT hsy-resources jar Resources for application - - fi.nls.oskari - content-resources - ${oskari.version} - org.oskari - service-capabilities-update - 1.55.1 + content-resources org.oskari diff --git a/pom.xml b/pom.xml index c9b2087..60e0050 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ 4.0.0 fi.hsy.oskari hsy-parent - 1.5.3 + 1.6.0-SNAPSHOT pom HSY applications - 1.56.0 + 2.9.0 UTF-8 1.8 @@ -39,8 +39,8 @@ - fi.nls.oskari - oskari-parent + org.oskari + oskari-server ${oskari.version} import pom diff --git a/server-extension/pom.xml b/server-extension/pom.xml index 03cff77..9dbdb21 100755 --- a/server-extension/pom.xml +++ b/server-extension/pom.xml @@ -3,7 +3,7 @@ fi.hsy.oskari hsy-parent - 1.5.3 + 1.6.0-SNAPSHOT server-extension @@ -11,8 +11,8 @@ - fi.nls.oskari.service - oskari-control-base + org.oskari + control-base diff --git a/webapp-map/pom.xml b/webapp-map/pom.xml index acc1d36..e77b31b 100755 --- a/webapp-map/pom.xml +++ b/webapp-map/pom.xml @@ -5,7 +5,7 @@ hsy-parent fi.hsy.oskari - 1.5.3 + 1.6.0-SNAPSHOT 4.0.0 @@ -41,14 +41,14 @@ - fi.nls.oskari.service - oskari-control-example + org.oskari + control-example - - fi.nls.oskari.service - oskari-control-admin - + + org.oskari + control-admin + org.oskari @@ -56,12 +56,12 @@ - fi.nls.oskari.service - oskari-control-myplaces + org.oskari + control-myplaces - fi.nls.oskari + org.oskari servlet-map @@ -72,22 +72,24 @@ - fi.nls.oskari.extras - oskari-search-nls - 2.1 - - - - fi.nls.oskari + org.oskari service-logging - fi.nls.oskari + org.oskari download-basket + + + fi.nls.oskari.extras + oskari-search-nls + 3.7.0 + + + org.slf4j slf4j-api @@ -122,4 +124,4 @@ ${appName} - \ No newline at end of file + From 5704ef624da372ae4b6a89b3f7a44fb67753bc1b Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 11:00:07 +0200 Subject: [PATCH 02/26] Remove transport era cache flush --- .../java/hsy/general/actions/SaveMultipleFeaturesHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server-extension/src/main/java/hsy/general/actions/SaveMultipleFeaturesHandler.java b/server-extension/src/main/java/hsy/general/actions/SaveMultipleFeaturesHandler.java index 81a84e7..5037638 100755 --- a/server-extension/src/main/java/hsy/general/actions/SaveMultipleFeaturesHandler.java +++ b/server-extension/src/main/java/hsy/general/actions/SaveMultipleFeaturesHandler.java @@ -59,7 +59,6 @@ public void handlePost(ActionParameters params) throws ActionException { requestData.append(""); String responseString = postPayload(layer.getUsername(), layer.getPassword(), requestData.toString(), getURLForNamespace(layer.getName(),layer.getUrl())); - flushLayerTilesCache(layer.getId()); if (responseString.indexOf("Exception") > -1) { ResponseHelper.writeResponse(params, "Exception"); From 5e37e6cb46c521d5920bd557c457c7621325e44c Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 11:32:48 +0200 Subject: [PATCH 03/26] Refactoring --- .../pipe/actions/TagPipeActionHandler.java | 78 ++++++++----------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java b/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java index ca93fd9..5e447e4 100755 --- a/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java +++ b/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java @@ -54,7 +54,7 @@ public void handleDelete(ActionParameters params) throws ActionException { // Only admin user params.requireAdminUser(); - int tagPipeId = ConversionHelper.getInt(params.getRequiredParam(PARAM_TAG_ID), -1); + int tagPipeId = params.getRequiredParamInt(PARAM_TAG_ID); try { if(tagPipeId>0) { @@ -70,33 +70,15 @@ public void handleDelete(ActionParameters params) throws ActionException { @Override public void handlePost(ActionParameters params) throws ActionException { - // Only admin user params.requireAdminUser(); try { - - TagPipeConfiguration conf = new TagPipeConfiguration(); - - conf.setTagType(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_TYPE),"")); - conf.setTagAddress(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_ADDRESS),"")); - conf.setTagPipeSize(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_PIPE_SIZE), 0)); - conf.setTagLowPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_PRESSURE_LEVEL), 0)); - conf.setTagMaxPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_PRESSURE_LEVEL), 0)); - conf.setTagMaxWaterTake(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_WATER_TAKE), 0)); - conf.setTagMinPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MIN_PRESSURE_LEVEL), 0)); - conf.setTagBottomHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BOTTOM_HEIGHT), 0)); - conf.setTagLowTagHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_TAG_HEIGHT), 0)); - conf.setTagBarrageHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BARRAGE_HEIGHT), 0)); - conf.setTagGroundHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_GROUND_HEIGHT), 0)); - conf.setTagOtherIssue(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_OTHER_ISSUE),"")); - conf.setTagGeoJson(new JSONObject(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_GEOJSON),""))); - conf.setTagMunicipality(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_MUNICIPALITY),"")); - conf.setTagNeighborhood(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_NEIGHBORHOOD),"")); - conf.setTagBlock(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_BLOCK),"")); - conf.setTagPlot(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_PLOT),"")); - - ResponseHelper.writeResponse(params, TagPipeHelper.insert(conf)); + TagPipeConfiguration conf = paramsToTagConfiguration(params); + // tag_type required on POST / INSERT -- can't be changed with PUT / UPDATE + conf.setTagType(params.getRequiredParam(PARAM_TAG_TYPE)); + JSONObject response = TagPipeHelper.insert(conf); + ResponseHelper.writeResponse(params, response); } catch (Exception ex){ log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); throw new ActionParamsException("Couldn't insert tagpipe"); @@ -109,32 +91,36 @@ public void handlePut(ActionParameters params) throws ActionException { params.requireAdminUser(); try { - TagPipeConfiguration conf = new TagPipeConfiguration(); - //conf.setTagType(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_TYPE),"")); - conf.setTagAddress(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_ADDRESS),"")); - conf.setTagPipeSize(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_PIPE_SIZE), 0)); - conf.setTagLowPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_PRESSURE_LEVEL), 0)); - conf.setTagMaxPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_PRESSURE_LEVEL), 0)); - conf.setTagMaxWaterTake(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_WATER_TAKE), 0)); - conf.setTagMinPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MIN_PRESSURE_LEVEL), 0)); - conf.setTagBottomHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BOTTOM_HEIGHT), 0)); - conf.setTagLowTagHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_TAG_HEIGHT), 0)); - conf.setTagBarrageHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BARRAGE_HEIGHT), 0)); - conf.setTagGroundHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_GROUND_HEIGHT), 0)); - conf.setTagOtherIssue(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_OTHER_ISSUE),"")); - conf.setTagGeoJson(new JSONObject(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_GEOJSON),""))); - conf.setTagId(ConversionHelper.getInt(params.getRequiredParam(PARAM_TAG_ID), -1)); - conf.setTagMunicipality(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_MUNICIPALITY),"")); - conf.setTagNeighborhood(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_NEIGHBORHOOD),"")); - conf.setTagBlock(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_BLOCK),"")); - conf.setTagPlot(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_PLOT),"")); - - ResponseHelper.writeResponse(params, TagPipeHelper.update(conf)); + TagPipeConfiguration conf = paramsToTagConfiguration(params); + // tag_id (server created) is required on PUT / UPDATE -- can't be set on POST / INSERT + conf.setTagId(params.getRequiredParamInt(PARAM_TAG_ID)); + JSONObject response = TagPipeHelper.update(conf); + ResponseHelper.writeResponse(params, response); } catch (Exception ex){ log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); throw new ActionParamsException("Couldn't update tagpipe"); } - + } + + private TagPipeConfiguration paramsToTagConfiguration(ActionParameters params) throws Exception { + TagPipeConfiguration conf = new TagPipeConfiguration(); + conf.setTagAddress(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_ADDRESS),"")); + conf.setTagPipeSize(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_PIPE_SIZE), 0)); + conf.setTagLowPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_PRESSURE_LEVEL), 0)); + conf.setTagMaxPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_PRESSURE_LEVEL), 0)); + conf.setTagMaxWaterTake(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_WATER_TAKE), 0)); + conf.setTagMinPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MIN_PRESSURE_LEVEL), 0)); + conf.setTagBottomHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BOTTOM_HEIGHT), 0)); + conf.setTagLowTagHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_TAG_HEIGHT), 0)); + conf.setTagBarrageHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BARRAGE_HEIGHT), 0)); + conf.setTagGroundHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_GROUND_HEIGHT), 0)); + conf.setTagOtherIssue(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_OTHER_ISSUE),"")); + conf.setTagGeoJson(new JSONObject(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_GEOJSON),""))); + conf.setTagMunicipality(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_MUNICIPALITY),"")); + conf.setTagNeighborhood(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_NEIGHBORHOOD),"")); + conf.setTagBlock(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_BLOCK),"")); + conf.setTagPlot(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_PLOT),"")); + return conf; } } From 196e56822e047932c641fda187bc4e217e597f46 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 11:34:09 +0200 Subject: [PATCH 04/26] reformat to use 4 spaces, remove end of line whitepsace --- .../pipe/actions/TagPipeActionHandler.java | 204 +++++++++--------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java b/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java index 5e447e4..29327c7 100755 --- a/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java +++ b/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java @@ -16,111 +16,111 @@ @OskariActionRoute("SearchTagPipe") public class TagPipeActionHandler extends RestActionHandler { - - private static final Logger log = LogFactory.getLogger(TagPipeActionHandler.class); - - protected final static String PARAM_TAG_ID = "tag_id"; - protected final static String PARAM_TAG_TYPE = "tag_type"; - protected final static String PARAM_TAG_ADDRESS = "tag_address"; - protected final static String PARAM_TAG_PIPE_SIZE = "tag_pipe_size"; - protected final static String PARAM_TAG_LOW_PRESSURE_LEVEL = "tag_low_pressure_level"; - protected final static String PARAM_TAG_MAX_PRESSURE_LEVEL = "tag_max_pressure_level"; - protected final static String PARAM_TAG_MAX_WATER_TAKE = "tag_max_water_take"; - protected final static String PARAM_TAG_MIN_PRESSURE_LEVEL = "tag_min_pressure_level"; - protected final static String PARAM_TAG_BOTTOM_HEIGHT = "tag_bottom_height"; - protected final static String PARAM_TAG_LOW_TAG_HEIGHT = "tag_low_tag_height"; - protected final static String PARAM_TAG_BARRAGE_HEIGHT = "tag_barrage_height"; - protected final static String PARAM_TAG_GROUND_HEIGHT = "tag_ground_height"; - protected final static String PARAM_TAG_OTHER_ISSUE = "tag_other_issue"; - protected final static String PARAM_TAG_GEOJSON = "tag_geojson"; - //Separate Finnish kiinteistötunnus (real estate ID) into 4 different fields - protected final static String PARAM_TAG_MUNICIPALITY = "tag_municipality"; - protected final static String PARAM_TAG_NEIGHBORHOOD = "tag_neighborhood"; - protected final static String PARAM_TAG_BLOCK = "tag_block"; - protected final static String PARAM_TAG_PLOT = "tag_plot"; - - @Override - public void handleGet(ActionParameters params) throws ActionException { - try { - ResponseHelper.writeResponse(params, TagPipeHelper.getTagPipes(params.getUser(), params.getLocale().getLanguage())); - } catch (Exception ex){ - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); - throw new ActionParamsException("Couldn't get tagpipes"); - } - } - - @Override - public void handleDelete(ActionParameters params) throws ActionException { - // Only admin user - params.requireAdminUser(); - - int tagPipeId = params.getRequiredParamInt(PARAM_TAG_ID); - - try { - if(tagPipeId>0) { - ResponseHelper.writeResponse(params, TagPipeHelper.delete(tagPipeId)); - } else { - throw new ActionParamsException("Couldn't delete tagpipe"); - } - } catch (Exception ex){ - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); - throw new ActionParamsException("Couldn't delete tagpipe"); - } - } - - @Override - public void handlePost(ActionParameters params) throws ActionException { - // Only admin user - params.requireAdminUser(); - - try { + + private static final Logger log = LogFactory.getLogger(TagPipeActionHandler.class); + + protected final static String PARAM_TAG_ID = "tag_id"; + protected final static String PARAM_TAG_TYPE = "tag_type"; + protected final static String PARAM_TAG_ADDRESS = "tag_address"; + protected final static String PARAM_TAG_PIPE_SIZE = "tag_pipe_size"; + protected final static String PARAM_TAG_LOW_PRESSURE_LEVEL = "tag_low_pressure_level"; + protected final static String PARAM_TAG_MAX_PRESSURE_LEVEL = "tag_max_pressure_level"; + protected final static String PARAM_TAG_MAX_WATER_TAKE = "tag_max_water_take"; + protected final static String PARAM_TAG_MIN_PRESSURE_LEVEL = "tag_min_pressure_level"; + protected final static String PARAM_TAG_BOTTOM_HEIGHT = "tag_bottom_height"; + protected final static String PARAM_TAG_LOW_TAG_HEIGHT = "tag_low_tag_height"; + protected final static String PARAM_TAG_BARRAGE_HEIGHT = "tag_barrage_height"; + protected final static String PARAM_TAG_GROUND_HEIGHT = "tag_ground_height"; + protected final static String PARAM_TAG_OTHER_ISSUE = "tag_other_issue"; + protected final static String PARAM_TAG_GEOJSON = "tag_geojson"; + //Separate Finnish kiinteistötunnus (real estate ID) into 4 different fields + protected final static String PARAM_TAG_MUNICIPALITY = "tag_municipality"; + protected final static String PARAM_TAG_NEIGHBORHOOD = "tag_neighborhood"; + protected final static String PARAM_TAG_BLOCK = "tag_block"; + protected final static String PARAM_TAG_PLOT = "tag_plot"; + + @Override + public void handleGet(ActionParameters params) throws ActionException { + try { + ResponseHelper.writeResponse(params, TagPipeHelper.getTagPipes(params.getUser(), params.getLocale().getLanguage())); + } catch (Exception ex){ + log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); + throw new ActionParamsException("Couldn't get tagpipes"); + } + } + + @Override + public void handleDelete(ActionParameters params) throws ActionException { + // Only admin user + params.requireAdminUser(); + + int tagPipeId = params.getRequiredParamInt(PARAM_TAG_ID); + + try { + if(tagPipeId>0) { + ResponseHelper.writeResponse(params, TagPipeHelper.delete(tagPipeId)); + } else { + throw new ActionParamsException("Couldn't delete tagpipe"); + } + } catch (Exception ex){ + log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); + throw new ActionParamsException("Couldn't delete tagpipe"); + } + } + + @Override + public void handlePost(ActionParameters params) throws ActionException { + // Only admin user + params.requireAdminUser(); + + try { TagPipeConfiguration conf = paramsToTagConfiguration(params); // tag_type required on POST / INSERT -- can't be changed with PUT / UPDATE - conf.setTagType(params.getRequiredParam(PARAM_TAG_TYPE)); - JSONObject response = TagPipeHelper.insert(conf); - ResponseHelper.writeResponse(params, response); - } catch (Exception ex){ - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); - throw new ActionParamsException("Couldn't insert tagpipe"); - } - } - - @Override - public void handlePut(ActionParameters params) throws ActionException { - // Only admin user - params.requireAdminUser(); - - try { - TagPipeConfiguration conf = paramsToTagConfiguration(params); + conf.setTagType(params.getRequiredParam(PARAM_TAG_TYPE)); + JSONObject response = TagPipeHelper.insert(conf); + ResponseHelper.writeResponse(params, response); + } catch (Exception ex){ + log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); + throw new ActionParamsException("Couldn't insert tagpipe"); + } + } + + @Override + public void handlePut(ActionParameters params) throws ActionException { + // Only admin user + params.requireAdminUser(); + + try { + TagPipeConfiguration conf = paramsToTagConfiguration(params); // tag_id (server created) is required on PUT / UPDATE -- can't be set on POST / INSERT - conf.setTagId(params.getRequiredParamInt(PARAM_TAG_ID)); - JSONObject response = TagPipeHelper.update(conf); - ResponseHelper.writeResponse(params, response); - } catch (Exception ex){ - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); - throw new ActionParamsException("Couldn't update tagpipe"); - } - } + conf.setTagId(params.getRequiredParamInt(PARAM_TAG_ID)); + JSONObject response = TagPipeHelper.update(conf); + ResponseHelper.writeResponse(params, response); + } catch (Exception ex){ + log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); + throw new ActionParamsException("Couldn't update tagpipe"); + } + } - private TagPipeConfiguration paramsToTagConfiguration(ActionParameters params) throws Exception { - TagPipeConfiguration conf = new TagPipeConfiguration(); - conf.setTagAddress(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_ADDRESS),"")); - conf.setTagPipeSize(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_PIPE_SIZE), 0)); - conf.setTagLowPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_PRESSURE_LEVEL), 0)); - conf.setTagMaxPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_PRESSURE_LEVEL), 0)); - conf.setTagMaxWaterTake(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_WATER_TAKE), 0)); - conf.setTagMinPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MIN_PRESSURE_LEVEL), 0)); - conf.setTagBottomHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BOTTOM_HEIGHT), 0)); - conf.setTagLowTagHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_TAG_HEIGHT), 0)); - conf.setTagBarrageHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BARRAGE_HEIGHT), 0)); - conf.setTagGroundHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_GROUND_HEIGHT), 0)); - conf.setTagOtherIssue(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_OTHER_ISSUE),"")); - conf.setTagGeoJson(new JSONObject(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_GEOJSON),""))); - conf.setTagMunicipality(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_MUNICIPALITY),"")); - conf.setTagNeighborhood(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_NEIGHBORHOOD),"")); - conf.setTagBlock(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_BLOCK),"")); - conf.setTagPlot(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_PLOT),"")); - return conf; - } + private TagPipeConfiguration paramsToTagConfiguration(ActionParameters params) throws Exception { + TagPipeConfiguration conf = new TagPipeConfiguration(); + conf.setTagAddress(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_ADDRESS),"")); + conf.setTagPipeSize(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_PIPE_SIZE), 0)); + conf.setTagLowPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_PRESSURE_LEVEL), 0)); + conf.setTagMaxPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_PRESSURE_LEVEL), 0)); + conf.setTagMaxWaterTake(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_WATER_TAKE), 0)); + conf.setTagMinPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MIN_PRESSURE_LEVEL), 0)); + conf.setTagBottomHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BOTTOM_HEIGHT), 0)); + conf.setTagLowTagHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_TAG_HEIGHT), 0)); + conf.setTagBarrageHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BARRAGE_HEIGHT), 0)); + conf.setTagGroundHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_GROUND_HEIGHT), 0)); + conf.setTagOtherIssue(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_OTHER_ISSUE),"")); + conf.setTagGeoJson(new JSONObject(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_GEOJSON),""))); + conf.setTagMunicipality(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_MUNICIPALITY),"")); + conf.setTagNeighborhood(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_NEIGHBORHOOD),"")); + conf.setTagBlock(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_BLOCK),"")); + conf.setTagPlot(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_PLOT),"")); + return conf; + } } From 83fbb4826389b91ce21337864473893922b1126f Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 11:38:50 +0200 Subject: [PATCH 05/26] Remove duplicated code --- .../pipe/actions/TagPipeActionHandler.java | 26 ++------------- .../hsy/pipe/domain/TagPipeConfiguration.java | 32 ++++++++++++++++--- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java b/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java index 29327c7..6b0744a 100755 --- a/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java +++ b/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java @@ -11,7 +11,6 @@ import fi.nls.oskari.control.RestActionHandler; import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; -import fi.nls.oskari.util.ConversionHelper; import fi.nls.oskari.util.ResponseHelper; @OskariActionRoute("SearchTagPipe") @@ -74,7 +73,7 @@ public void handlePost(ActionParameters params) throws ActionException { params.requireAdminUser(); try { - TagPipeConfiguration conf = paramsToTagConfiguration(params); + TagPipeConfiguration conf = new TagPipeConfiguration(params); // tag_type required on POST / INSERT -- can't be changed with PUT / UPDATE conf.setTagType(params.getRequiredParam(PARAM_TAG_TYPE)); JSONObject response = TagPipeHelper.insert(conf); @@ -91,7 +90,7 @@ public void handlePut(ActionParameters params) throws ActionException { params.requireAdminUser(); try { - TagPipeConfiguration conf = paramsToTagConfiguration(params); + TagPipeConfiguration conf = new TagPipeConfiguration(params); // tag_id (server created) is required on PUT / UPDATE -- can't be set on POST / INSERT conf.setTagId(params.getRequiredParamInt(PARAM_TAG_ID)); JSONObject response = TagPipeHelper.update(conf); @@ -102,25 +101,4 @@ public void handlePut(ActionParameters params) throws ActionException { } } - private TagPipeConfiguration paramsToTagConfiguration(ActionParameters params) throws Exception { - TagPipeConfiguration conf = new TagPipeConfiguration(); - conf.setTagAddress(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_ADDRESS),"")); - conf.setTagPipeSize(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_PIPE_SIZE), 0)); - conf.setTagLowPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_PRESSURE_LEVEL), 0)); - conf.setTagMaxPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_PRESSURE_LEVEL), 0)); - conf.setTagMaxWaterTake(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_WATER_TAKE), 0)); - conf.setTagMinPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MIN_PRESSURE_LEVEL), 0)); - conf.setTagBottomHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BOTTOM_HEIGHT), 0)); - conf.setTagLowTagHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_TAG_HEIGHT), 0)); - conf.setTagBarrageHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BARRAGE_HEIGHT), 0)); - conf.setTagGroundHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_GROUND_HEIGHT), 0)); - conf.setTagOtherIssue(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_OTHER_ISSUE),"")); - conf.setTagGeoJson(new JSONObject(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_GEOJSON),""))); - conf.setTagMunicipality(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_MUNICIPALITY),"")); - conf.setTagNeighborhood(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_NEIGHBORHOOD),"")); - conf.setTagBlock(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_BLOCK),"")); - conf.setTagPlot(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_PLOT),"")); - return conf; - } - } diff --git a/server-extension/src/main/java/hsy/pipe/domain/TagPipeConfiguration.java b/server-extension/src/main/java/hsy/pipe/domain/TagPipeConfiguration.java index 18b0076..1565b2e 100755 --- a/server-extension/src/main/java/hsy/pipe/domain/TagPipeConfiguration.java +++ b/server-extension/src/main/java/hsy/pipe/domain/TagPipeConfiguration.java @@ -2,14 +2,12 @@ import org.json.JSONObject; -import fi.nls.oskari.log.LogFactory; -import fi.nls.oskari.log.Logger; +import fi.nls.oskari.control.ActionParameters; +import fi.nls.oskari.util.ConversionHelper; import fi.nls.oskari.util.JSONHelper; public class TagPipeConfiguration { - private static final Logger log = LogFactory.getLogger(TagPipeConfiguration.class); - protected final static String PARAM_TAG_ID = "tag_id"; protected final static String PARAM_TAG_TYPE = "tag_type"; protected final static String PARAM_TAG_ADDRESS = "tag_address"; @@ -49,7 +47,31 @@ public class TagPipeConfiguration { private String tagBlock; private String tagPlot; - public JSONObject getAsJSONObject() { + /** + * Constructor from action parameters + * NOTE: Doesn't set tagType or tagId! + * This is because insert/update logic might differ + */ + public TagPipeConfiguration(ActionParameters params) throws Exception { + setTagAddress(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_ADDRESS),"")); + setTagPipeSize(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_PIPE_SIZE), 0)); + setTagLowPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_PRESSURE_LEVEL), 0)); + setTagMaxPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_PRESSURE_LEVEL), 0)); + setTagMaxWaterTake(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MAX_WATER_TAKE), 0)); + setTagMinPressureLevel(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_MIN_PRESSURE_LEVEL), 0)); + setTagBottomHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BOTTOM_HEIGHT), 0)); + setTagLowTagHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_LOW_TAG_HEIGHT), 0)); + setTagBarrageHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_BARRAGE_HEIGHT), 0)); + setTagGroundHeight(ConversionHelper.getDouble(params.getHttpParam(PARAM_TAG_GROUND_HEIGHT), 0)); + setTagOtherIssue(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_OTHER_ISSUE),"")); + setTagGeoJson(new JSONObject(ConversionHelper.getString(params.getHttpParam(PARAM_TAG_GEOJSON),""))); + setTagMunicipality(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_MUNICIPALITY),"")); + setTagNeighborhood(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_NEIGHBORHOOD),"")); + setTagBlock(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_BLOCK),"")); + setTagPlot(ConversionHelper.getString(params.getRequiredParam(PARAM_TAG_PLOT),"")); + } + + public JSONObject getAsJSONObject() { final JSONObject root = new JSONObject(); JSONHelper.putValue(root, PARAM_TAG_ID, this.getTagId()); JSONHelper.putValue(root, PARAM_TAG_TYPE, this.getTagType()); From 88b23b44a8cb5d061e14d58a9c6c9ea10b0b0d03 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 11:45:50 +0200 Subject: [PATCH 06/26] Move all pipe stuff to same package --- .../java/hsy/pipe/{actions => }/GetPipesWithParams.java | 4 +--- .../src/main/java/hsy/pipe/{helpers => }/Helpers.java | 2 +- .../java/hsy/pipe/{actions => }/TagPipeActionHandler.java | 4 +--- .../java/hsy/pipe/{domain => }/TagPipeConfiguration.java | 2 +- .../hsy/pipe/{tagpipe => }/TagPipeConfigurationService.java | 6 ++---- .../src/main/java/hsy/pipe/{helpers => }/TagPipeHelper.java | 6 +----- 6 files changed, 7 insertions(+), 17 deletions(-) rename server-extension/src/main/java/hsy/pipe/{actions => }/GetPipesWithParams.java (97%) rename server-extension/src/main/java/hsy/pipe/{helpers => }/Helpers.java (98%) rename server-extension/src/main/java/hsy/pipe/{actions => }/TagPipeActionHandler.java (97%) rename server-extension/src/main/java/hsy/pipe/{domain => }/TagPipeConfiguration.java (99%) rename server-extension/src/main/java/hsy/pipe/{tagpipe => }/TagPipeConfigurationService.java (60%) rename server-extension/src/main/java/hsy/pipe/{helpers => }/TagPipeHelper.java (93%) diff --git a/server-extension/src/main/java/hsy/pipe/actions/GetPipesWithParams.java b/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java similarity index 97% rename from server-extension/src/main/java/hsy/pipe/actions/GetPipesWithParams.java rename to server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java index bd0c9af..b96a039 100755 --- a/server-extension/src/main/java/hsy/pipe/actions/GetPipesWithParams.java +++ b/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java @@ -1,6 +1,4 @@ -package hsy.pipe.actions; - -import hsy.pipe.helpers.Helpers; +package hsy.pipe; import java.io.BufferedReader; import java.io.IOException; diff --git a/server-extension/src/main/java/hsy/pipe/helpers/Helpers.java b/server-extension/src/main/java/hsy/pipe/Helpers.java similarity index 98% rename from server-extension/src/main/java/hsy/pipe/helpers/Helpers.java rename to server-extension/src/main/java/hsy/pipe/Helpers.java index 795ca8a..fb54332 100755 --- a/server-extension/src/main/java/hsy/pipe/helpers/Helpers.java +++ b/server-extension/src/main/java/hsy/pipe/Helpers.java @@ -1,4 +1,4 @@ -package hsy.pipe.helpers; +package hsy.pipe; import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; diff --git a/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java b/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java similarity index 97% rename from server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java rename to server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java index 6b0744a..ee4d5e6 100755 --- a/server-extension/src/main/java/hsy/pipe/actions/TagPipeActionHandler.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java @@ -1,9 +1,7 @@ -package hsy.pipe.actions; +package hsy.pipe; import org.json.JSONObject; -import hsy.pipe.domain.TagPipeConfiguration; -import hsy.pipe.helpers.TagPipeHelper; import fi.nls.oskari.annotation.OskariActionRoute; import fi.nls.oskari.control.ActionException; import fi.nls.oskari.control.ActionParameters; diff --git a/server-extension/src/main/java/hsy/pipe/domain/TagPipeConfiguration.java b/server-extension/src/main/java/hsy/pipe/TagPipeConfiguration.java similarity index 99% rename from server-extension/src/main/java/hsy/pipe/domain/TagPipeConfiguration.java rename to server-extension/src/main/java/hsy/pipe/TagPipeConfiguration.java index 1565b2e..a3d4e1a 100755 --- a/server-extension/src/main/java/hsy/pipe/domain/TagPipeConfiguration.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeConfiguration.java @@ -1,4 +1,4 @@ -package hsy.pipe.domain; +package hsy.pipe; import org.json.JSONObject; diff --git a/server-extension/src/main/java/hsy/pipe/tagpipe/TagPipeConfigurationService.java b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java similarity index 60% rename from server-extension/src/main/java/hsy/pipe/tagpipe/TagPipeConfigurationService.java rename to server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java index 3069a86..27dc544 100755 --- a/server-extension/src/main/java/hsy/pipe/tagpipe/TagPipeConfigurationService.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java @@ -1,11 +1,9 @@ -package hsy.pipe.tagpipe; +package hsy.pipe; import java.util.List; -import hsy.pipe.domain.TagPipeConfiguration; -import fi.nls.oskari.service.db.BaseService; +public interface TagPipeConfigurationService { -public interface TagPipeConfigurationService extends BaseService{ public List findTagPipes(); public TagPipeConfiguration findTagPipeById(final int tagPipeId); public void delete(final int tagPipeId); diff --git a/server-extension/src/main/java/hsy/pipe/helpers/TagPipeHelper.java b/server-extension/src/main/java/hsy/pipe/TagPipeHelper.java similarity index 93% rename from server-extension/src/main/java/hsy/pipe/helpers/TagPipeHelper.java rename to server-extension/src/main/java/hsy/pipe/TagPipeHelper.java index 9947f78..6c57453 100755 --- a/server-extension/src/main/java/hsy/pipe/helpers/TagPipeHelper.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeHelper.java @@ -1,7 +1,4 @@ -package hsy.pipe.helpers; - -import hsy.pipe.tagpipe.TagPipeConfigurationService; -import hsy.pipe.tagpipe.TagPipeConfigurationServiceIbatisImpl; +package hsy.pipe; import java.util.ArrayList; import java.util.List; @@ -10,7 +7,6 @@ import org.json.JSONException; import org.json.JSONObject; -import hsy.pipe.domain.TagPipeConfiguration; import fi.nls.oskari.domain.User; import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; From 664c486343c3e17facecae27deb3abb545c83275 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 11:46:42 +0200 Subject: [PATCH 07/26] Remove duplicated PARAM fields --- .../java/hsy/pipe/TagPipeActionHandler.java | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java b/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java index ee4d5e6..9c59229 100755 --- a/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java @@ -16,26 +16,6 @@ public class TagPipeActionHandler extends RestActionHandler { private static final Logger log = LogFactory.getLogger(TagPipeActionHandler.class); - protected final static String PARAM_TAG_ID = "tag_id"; - protected final static String PARAM_TAG_TYPE = "tag_type"; - protected final static String PARAM_TAG_ADDRESS = "tag_address"; - protected final static String PARAM_TAG_PIPE_SIZE = "tag_pipe_size"; - protected final static String PARAM_TAG_LOW_PRESSURE_LEVEL = "tag_low_pressure_level"; - protected final static String PARAM_TAG_MAX_PRESSURE_LEVEL = "tag_max_pressure_level"; - protected final static String PARAM_TAG_MAX_WATER_TAKE = "tag_max_water_take"; - protected final static String PARAM_TAG_MIN_PRESSURE_LEVEL = "tag_min_pressure_level"; - protected final static String PARAM_TAG_BOTTOM_HEIGHT = "tag_bottom_height"; - protected final static String PARAM_TAG_LOW_TAG_HEIGHT = "tag_low_tag_height"; - protected final static String PARAM_TAG_BARRAGE_HEIGHT = "tag_barrage_height"; - protected final static String PARAM_TAG_GROUND_HEIGHT = "tag_ground_height"; - protected final static String PARAM_TAG_OTHER_ISSUE = "tag_other_issue"; - protected final static String PARAM_TAG_GEOJSON = "tag_geojson"; - //Separate Finnish kiinteistötunnus (real estate ID) into 4 different fields - protected final static String PARAM_TAG_MUNICIPALITY = "tag_municipality"; - protected final static String PARAM_TAG_NEIGHBORHOOD = "tag_neighborhood"; - protected final static String PARAM_TAG_BLOCK = "tag_block"; - protected final static String PARAM_TAG_PLOT = "tag_plot"; - @Override public void handleGet(ActionParameters params) throws ActionException { try { @@ -51,7 +31,7 @@ public void handleDelete(ActionParameters params) throws ActionException { // Only admin user params.requireAdminUser(); - int tagPipeId = params.getRequiredParamInt(PARAM_TAG_ID); + int tagPipeId = params.getRequiredParamInt(TagPipeConfiguration.PARAM_TAG_ID); try { if(tagPipeId>0) { @@ -73,7 +53,7 @@ public void handlePost(ActionParameters params) throws ActionException { try { TagPipeConfiguration conf = new TagPipeConfiguration(params); // tag_type required on POST / INSERT -- can't be changed with PUT / UPDATE - conf.setTagType(params.getRequiredParam(PARAM_TAG_TYPE)); + conf.setTagType(params.getRequiredParam(TagPipeConfiguration.PARAM_TAG_TYPE)); JSONObject response = TagPipeHelper.insert(conf); ResponseHelper.writeResponse(params, response); } catch (Exception ex){ @@ -90,7 +70,7 @@ public void handlePut(ActionParameters params) throws ActionException { try { TagPipeConfiguration conf = new TagPipeConfiguration(params); // tag_id (server created) is required on PUT / UPDATE -- can't be set on POST / INSERT - conf.setTagId(params.getRequiredParamInt(PARAM_TAG_ID)); + conf.setTagId(params.getRequiredParamInt(TagPipeConfiguration.PARAM_TAG_ID)); JSONObject response = TagPipeHelper.update(conf); ResponseHelper.writeResponse(params, response); } catch (Exception ex){ From e14854dd26c82ef9d71a8bfe5aa97d1cfa3083bb Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 11:53:05 +0200 Subject: [PATCH 08/26] Remove TagPipeHelper --- .../java/hsy/pipe/TagPipeActionHandler.java | 73 +++++++++++- .../hsy/pipe/TagPipeConfigurationService.java | 14 ++- .../src/main/java/hsy/pipe/TagPipeHelper.java | 109 ------------------ 3 files changed, 77 insertions(+), 119 deletions(-) delete mode 100755 server-extension/src/main/java/hsy/pipe/TagPipeHelper.java diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java b/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java index 9c59229..b1edfb6 100755 --- a/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java @@ -1,5 +1,9 @@ package hsy.pipe; +import java.util.List; + +import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import fi.nls.oskari.annotation.OskariActionRoute; @@ -7,8 +11,10 @@ import fi.nls.oskari.control.ActionParameters; import fi.nls.oskari.control.ActionParamsException; import fi.nls.oskari.control.RestActionHandler; +import fi.nls.oskari.domain.User; import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; +import fi.nls.oskari.service.OskariComponentManager; import fi.nls.oskari.util.ResponseHelper; @OskariActionRoute("SearchTagPipe") @@ -16,10 +22,12 @@ public class TagPipeActionHandler extends RestActionHandler { private static final Logger log = LogFactory.getLogger(TagPipeActionHandler.class); + private final TagPipeConfigurationService tagpipeService = OskariComponentManager.getComponentOfType(TagPipeConfigurationService.class); + @Override public void handleGet(ActionParameters params) throws ActionException { try { - ResponseHelper.writeResponse(params, TagPipeHelper.getTagPipes(params.getUser(), params.getLocale().getLanguage())); + ResponseHelper.writeResponse(params, getTagPipes(params.getUser(), params.getLocale().getLanguage())); } catch (Exception ex){ log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); throw new ActionParamsException("Couldn't get tagpipes"); @@ -35,7 +43,7 @@ public void handleDelete(ActionParameters params) throws ActionException { try { if(tagPipeId>0) { - ResponseHelper.writeResponse(params, TagPipeHelper.delete(tagPipeId)); + ResponseHelper.writeResponse(params, delete(tagPipeId)); } else { throw new ActionParamsException("Couldn't delete tagpipe"); } @@ -54,7 +62,7 @@ public void handlePost(ActionParameters params) throws ActionException { TagPipeConfiguration conf = new TagPipeConfiguration(params); // tag_type required on POST / INSERT -- can't be changed with PUT / UPDATE conf.setTagType(params.getRequiredParam(TagPipeConfiguration.PARAM_TAG_TYPE)); - JSONObject response = TagPipeHelper.insert(conf); + JSONObject response = insert(conf); ResponseHelper.writeResponse(params, response); } catch (Exception ex){ log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); @@ -71,7 +79,7 @@ public void handlePut(ActionParameters params) throws ActionException { TagPipeConfiguration conf = new TagPipeConfiguration(params); // tag_id (server created) is required on PUT / UPDATE -- can't be set on POST / INSERT conf.setTagId(params.getRequiredParamInt(TagPipeConfiguration.PARAM_TAG_ID)); - JSONObject response = TagPipeHelper.update(conf); + JSONObject response = update(conf); ResponseHelper.writeResponse(params, response); } catch (Exception ex){ log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); @@ -79,4 +87,61 @@ public void handlePut(ActionParameters params) throws ActionException { } } + private JSONObject getTagPipes(User user, String lang) throws JSONException { + JSONObject job = new JSONObject(); + List tagpipes = tagpipeService.findTagPipes(); + JSONArray tagpipesJSONArray = new JSONArray(); + + for(int i=0;i 0); + } catch (Exception e) { + log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); + try{ + job.put("success", false); + } catch (Exception ex) {} + } + return job; + } + + private JSONObject update(final TagPipeConfiguration tagpipe) { + JSONObject job = new JSONObject(); + try{ + tagpipeService.update(tagpipe); + job.put("success", true); + } catch (Exception e) { + log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); + try{ + job.put("success", false); + } catch (Exception ex) {} + } + return job; + } + } diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java index 27dc544..5de979f 100755 --- a/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java @@ -2,11 +2,13 @@ import java.util.List; -public interface TagPipeConfigurationService { +import fi.nls.oskari.service.OskariComponent; - public List findTagPipes(); - public TagPipeConfiguration findTagPipeById(final int tagPipeId); - public void delete(final int tagPipeId); - public int insert(final TagPipeConfiguration tagpipe); - public void update(final TagPipeConfiguration tagpipe); +public abstract class TagPipeConfigurationService extends OskariComponent { + + public abstract List findTagPipes(); + public abstract TagPipeConfiguration findTagPipeById(final int tagPipeId); + public abstract void delete(final int tagPipeId); + public abstract int insert(final TagPipeConfiguration tagpipe); + public abstract void update(final TagPipeConfiguration tagpipe); } diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeHelper.java b/server-extension/src/main/java/hsy/pipe/TagPipeHelper.java deleted file mode 100755 index 6c57453..0000000 --- a/server-extension/src/main/java/hsy/pipe/TagPipeHelper.java +++ /dev/null @@ -1,109 +0,0 @@ -package hsy.pipe; - -import java.util.ArrayList; -import java.util.List; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import fi.nls.oskari.domain.User; -import fi.nls.oskari.log.LogFactory; -import fi.nls.oskari.log.Logger; - -public class TagPipeHelper { - - private static final Logger log = LogFactory.getLogger(TagPipeHelper.class); - private static TagPipeConfigurationService tagpipeService = new TagPipeConfigurationServiceIbatisImpl(); - - /** - * Get tagpipes - * @param string - * @param user - * @return - */ - public static JSONObject getTagPipes(User user, String lang) throws JSONException{ - JSONObject job = new JSONObject(); - List tagpipes = tagpipeService.findTagPipes(); - JSONArray tagpipesJSONArray = new JSONArray(); - - for(int i=0;i getTagPipeById(JSONArray tagPipeIds) throws JSONException{ - - List tagpipes = new ArrayList(); - for (int i = 0; i < tagPipeIds.length(); i++) { - tagpipes.add(tagpipeService.findTagPipeById(tagPipeIds.getInt(i))); - } - - return tagpipes; - } - - /** - * Delete selected tagpipe - * @param tagpipeId - */ - public static JSONObject delete(final int tagPipeId) { - JSONObject job = new JSONObject(); - try{ - tagpipeService.delete(tagPipeId); - job.put("success", true); - } catch (Exception e) { - try{ - job.put("success", false); - } catch (Exception ex) {} - } - return job; - } - - /** - * Add tagpipe - * @param tagpipe - */ - public static JSONObject insert(final TagPipeConfiguration tagpipe) { - JSONObject job = new JSONObject(); - try{ - int newId = tagpipeService.insert(tagpipe); - job.put("success", newId > 0); - } catch (Exception e) { - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); - try{ - job.put("success", false); - } catch (Exception ex) {} - } - return job; - } - - /** - * Update tagpipe - * @param tagpipe - */ - public static JSONObject update(final TagPipeConfiguration tagpipe) { - JSONObject job = new JSONObject(); - try{ - tagpipeService.update(tagpipe); - job.put("success", true); - } catch (Exception e) { - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); - try{ - job.put("success", false); - } catch (Exception ex) {} - } - return job; - } -} From 81b32c2d1090158299bb48648f8214fc9d229c78 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 11:55:01 +0200 Subject: [PATCH 09/26] Remove Helpers class --- .../java/hsy/pipe/GetPipesWithParams.java | 25 +++++++-- .../src/main/java/hsy/pipe/Helpers.java | 51 ------------------- 2 files changed, 22 insertions(+), 54 deletions(-) delete mode 100755 server-extension/src/main/java/hsy/pipe/Helpers.java diff --git a/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java b/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java index b96a039..3f69d6d 100755 --- a/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java +++ b/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java @@ -22,8 +22,10 @@ @OskariActionRoute("GetPipesWithParams") public class GetPipesWithParams extends ActionHandler { - private final Logger LOGGER = LogFactory.getLogger(GetPipesWithParams.class); - + private static final Logger LOGGER = LogFactory.getLogger(GetPipesWithParams.class); + + private static final int MAX_FEATURE_COUNT = 50; + private static final String PARAM_LAYERS = "layers"; private static final String PARAM_X = "x"; private static final String PARAM_Y = "y"; @@ -38,7 +40,7 @@ public void handleAction(final ActionParameters params) throws ActionException { final JSONArray data = new JSONArray(); - String wmsUrl = Helpers.getGetFeatureInfoUrlForProxy(params.getHttpParam(PARAM_URL).toString(), params.getHttpParam(PARAM_SRS).toString(), + String wmsUrl = getGetFeatureInfoUrlForProxy(params.getHttpParam(PARAM_URL).toString(), params.getHttpParam(PARAM_SRS).toString(), params.getHttpParam(PARAM_BBOX).toString(), params.getHttpParam(PARAM_WIDTH).toString(), params.getHttpParam(PARAM_HEIGHT).toString(), params.getHttpParam(PARAM_X).toString(), params.getHttpParam(PARAM_Y).toString(), params.getHttpParam(PARAM_LAYERS).toString()); @@ -69,4 +71,21 @@ public void handleAction(final ActionParameters params) throws ActionException { throw new ActionException("Could not populate Response JSON: " + LOGGER.getAsString(data), e); } } + + private static String getGetFeatureInfoUrlForProxy(String url, String projection, String bbox, String width, String height, String x, String y, String layerName) { + String wmsUrl = url+"?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS="+projection + +"&BBOX="+bbox + +"&WIDTH="+width + +"&HEIGHT="+height + +"&QUERY_LAYERS="+layerName + +"&X="+Math.round(Float.parseFloat(x)) + +"&Y="+Math.round(Float.parseFloat(y)) + +"&LAYERS="+layerName + +"&FEATURE_COUNT="+MAX_FEATURE_COUNT + +"&INFO_FORMAT=application/json" + +"&EXCEPTIONS=application/vnd.ogc.se_xml" + +"&BUFFER=10"; + return wmsUrl; + } + } \ No newline at end of file diff --git a/server-extension/src/main/java/hsy/pipe/Helpers.java b/server-extension/src/main/java/hsy/pipe/Helpers.java deleted file mode 100755 index fb54332..0000000 --- a/server-extension/src/main/java/hsy/pipe/Helpers.java +++ /dev/null @@ -1,51 +0,0 @@ -package hsy.pipe; - -import fi.nls.oskari.log.LogFactory; -import fi.nls.oskari.log.Logger; - -public class Helpers { - - private static final Logger log = LogFactory.getLogger(Helpers.class); - private static final int MAX_FEATURE_COUNT = 50; - /** - * Get GetFeatureInfoUrl for proxy - * @param url a url - * @param projection a projection - * @param bbox a bbox - * @param width a width - * @param height a heigth - * @param x a x - * @param y a y - * @param layerName a layer name - * @return getFeatureInfoUrl - */ - public static String getGetFeatureInfoUrlForProxy(String url, String projection, String bbox, String width, String height, String x, String y, String layerName) { - String wmsUrl = url+"?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS="+projection - +"&BBOX="+bbox - +"&WIDTH="+width - +"&HEIGHT="+height - +"&QUERY_LAYERS="+layerName - +"&X="+Math.round(Float.parseFloat(x)) - +"&Y="+Math.round(Float.parseFloat(y)) - +"&LAYERS="+layerName - +"&FEATURE_COUNT="+MAX_FEATURE_COUNT - +"&INFO_FORMAT=application/json" - +"&EXCEPTIONS=application/vnd.ogc.se_xml" - +"&BUFFER=10"; - return wmsUrl; - } - - /** - * Get layer name without namespace. - * @param layerName layer name - * @return layer name without namespace - */ - public static String getLayerNameWithoutNameSpace(String layerName) { - String[] temp = layerName.split(":"); - String layerNameWithoutNameSpace = layerName; - if(temp.length==2){ - layerNameWithoutNameSpace = temp[1]; - } - return layerNameWithoutNameSpace; - } -} From 59b36d7193f618446f736b95fa2e0a75f456d375 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 12:01:44 +0200 Subject: [PATCH 10/26] Refactor GetPipesWithParams --- .../java/hsy/pipe/GetPipesWithParams.java | 52 ++++++------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java b/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java index 3f69d6d..e040c52 100755 --- a/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java +++ b/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java @@ -1,29 +1,21 @@ package hsy.pipe; -import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.InputStreamReader; -import java.net.MalformedURLException; +import java.io.InputStream; import java.net.URL; import java.net.URLConnection; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - import fi.nls.oskari.annotation.OskariActionRoute; import fi.nls.oskari.control.ActionException; import fi.nls.oskari.control.ActionHandler; import fi.nls.oskari.control.ActionParameters; -import fi.nls.oskari.log.LogFactory; -import fi.nls.oskari.log.Logger; +import fi.nls.oskari.util.IOHelper; import fi.nls.oskari.util.ResponseHelper; @OskariActionRoute("GetPipesWithParams") public class GetPipesWithParams extends ActionHandler { - private static final Logger LOGGER = LogFactory.getLogger(GetPipesWithParams.class); - private static final int MAX_FEATURE_COUNT = 50; private static final String PARAM_LAYERS = "layers"; @@ -37,43 +29,29 @@ public class GetPipesWithParams extends ActionHandler { @Override public void handleAction(final ActionParameters params) throws ActionException { - - final JSONArray data = new JSONArray(); - String wmsUrl = getGetFeatureInfoUrlForProxy(params.getHttpParam(PARAM_URL).toString(), params.getHttpParam(PARAM_SRS).toString(), params.getHttpParam(PARAM_BBOX).toString(), params.getHttpParam(PARAM_WIDTH).toString(), params.getHttpParam(PARAM_HEIGHT).toString(), params.getHttpParam(PARAM_X).toString(), params.getHttpParam(PARAM_Y).toString(), params.getHttpParam(PARAM_LAYERS).toString()); - - URL wms; try { - wms = new URL(wmsUrl); + URL wms = new URL(wmsUrl); URLConnection wmsConn = wms.openConnection(); wmsConn.setRequestProperty("Accept-Charset", "UTF-8"); - BufferedReader in = new BufferedReader( new InputStreamReader( wmsConn.getInputStream(), "UTF-8" ) ); - - String inputLine; - String html = ""; - - while ((inputLine = in.readLine()) != null) { - html += inputLine; - } - in.close(); - - JSONObject jsoni = new JSONObject(html); - - ResponseHelper.writeResponse(params, jsoni); - - } catch (JSONException e) { - throw new ActionException("Could not populate Response JSON: " + LOGGER.getAsString(data), e); - } catch (MalformedURLException e) { - throw new ActionException("Could not populate Response JSON: " + LOGGER.getAsString(data), e); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (InputStream in = wmsConn.getInputStream()) { + IOHelper.copy(in, baos); + } + ResponseHelper.writeResponse(params, 200, ResponseHelper.CONTENT_TYPE_JSON_UTF8, baos); } catch (IOException e) { - throw new ActionException("Could not populate Response JSON: " + LOGGER.getAsString(data), e); + throw new ActionException("Could not populate Response", e); } } private static String getGetFeatureInfoUrlForProxy(String url, String projection, String bbox, String width, String height, String x, String y, String layerName) { - String wmsUrl = url+"?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS="+projection + String wmsUrl = url+"?SERVICE=WMS" + +"&VERSION=1.1.1&" + +"REQUEST=GetFeatureInfo" + +"&SRS="+projection +"&BBOX="+bbox +"&WIDTH="+width +"&HEIGHT="+height From 157cd0ddefd94732e7440e5cebe2aeedaec7eaff Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 12:04:22 +0200 Subject: [PATCH 11/26] Remove user and lang from getTagPipes method as un-used --- .../src/main/java/hsy/pipe/TagPipeActionHandler.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java b/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java index b1edfb6..c959e3a 100755 --- a/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java @@ -11,7 +11,6 @@ import fi.nls.oskari.control.ActionParameters; import fi.nls.oskari.control.ActionParamsException; import fi.nls.oskari.control.RestActionHandler; -import fi.nls.oskari.domain.User; import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; import fi.nls.oskari.service.OskariComponentManager; @@ -27,7 +26,7 @@ public class TagPipeActionHandler extends RestActionHandler { @Override public void handleGet(ActionParameters params) throws ActionException { try { - ResponseHelper.writeResponse(params, getTagPipes(params.getUser(), params.getLocale().getLanguage())); + ResponseHelper.writeResponse(params, getTagPipes()); } catch (Exception ex){ log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(ex)); throw new ActionParamsException("Couldn't get tagpipes"); @@ -87,7 +86,7 @@ public void handlePut(ActionParameters params) throws ActionException { } } - private JSONObject getTagPipes(User user, String lang) throws JSONException { + private JSONObject getTagPipes() throws JSONException { JSONObject job = new JSONObject(); List tagpipes = tagpipeService.findTagPipes(); JSONArray tagpipesJSONArray = new JSONArray(); From 24754bf51b6ef23f6651af2458c7b1c2936ef987 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 12:07:17 +0200 Subject: [PATCH 12/26] Rename classes handling GetPipesWithParams and SearchTagPipe action routes to follow the Oskari way --- ...GetPipesWithParams.java => GetPipesWithParamsHandler.java} | 2 +- .../{TagPipeActionHandler.java => SearchTagPipeHandler.java} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename server-extension/src/main/java/hsy/pipe/{GetPipesWithParams.java => GetPipesWithParamsHandler.java} (97%) rename server-extension/src/main/java/hsy/pipe/{TagPipeActionHandler.java => SearchTagPipeHandler.java} (97%) diff --git a/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java b/server-extension/src/main/java/hsy/pipe/GetPipesWithParamsHandler.java similarity index 97% rename from server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java rename to server-extension/src/main/java/hsy/pipe/GetPipesWithParamsHandler.java index e040c52..3c4cfb1 100755 --- a/server-extension/src/main/java/hsy/pipe/GetPipesWithParams.java +++ b/server-extension/src/main/java/hsy/pipe/GetPipesWithParamsHandler.java @@ -14,7 +14,7 @@ import fi.nls.oskari.util.ResponseHelper; @OskariActionRoute("GetPipesWithParams") -public class GetPipesWithParams extends ActionHandler { +public class GetPipesWithParamsHandler extends ActionHandler { private static final int MAX_FEATURE_COUNT = 50; diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java b/server-extension/src/main/java/hsy/pipe/SearchTagPipeHandler.java similarity index 97% rename from server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java rename to server-extension/src/main/java/hsy/pipe/SearchTagPipeHandler.java index c959e3a..1178bfd 100755 --- a/server-extension/src/main/java/hsy/pipe/TagPipeActionHandler.java +++ b/server-extension/src/main/java/hsy/pipe/SearchTagPipeHandler.java @@ -17,9 +17,9 @@ import fi.nls.oskari.util.ResponseHelper; @OskariActionRoute("SearchTagPipe") -public class TagPipeActionHandler extends RestActionHandler { +public class SearchTagPipeHandler extends RestActionHandler { - private static final Logger log = LogFactory.getLogger(TagPipeActionHandler.class); + private static final Logger log = LogFactory.getLogger(SearchTagPipeHandler.class); private final TagPipeConfigurationService tagpipeService = OskariComponentManager.getComponentOfType(TagPipeConfigurationService.class); From f9ef83107d3557a39c939be353df4d53818cfeb9 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 13:16:07 +0200 Subject: [PATCH 13/26] Replace ibatis impl with mybatis impl --- .../hsy/pipe/TagPipeConfigurationMapper.java | 124 +++++++++++++++ .../hsy/pipe/TagPipeConfigurationService.java | 2 +- ...agPipeConfigurationServiceMyBatisImpl.java | 64 ++++++++ .../domain/utils/JSONArrayTypeHandler.java | 45 ------ ...TagPipeConfigurationServiceIbatisImpl.java | 122 --------------- .../SqlMapConfig-tagpipe-configuration.xml | 23 --- .../META-INF/TagPipeConfiguration.xml | 142 ------------------ 7 files changed, 189 insertions(+), 333 deletions(-) create mode 100644 server-extension/src/main/java/hsy/pipe/TagPipeConfigurationMapper.java create mode 100644 server-extension/src/main/java/hsy/pipe/TagPipeConfigurationServiceMyBatisImpl.java delete mode 100755 server-extension/src/main/java/hsy/pipe/domain/utils/JSONArrayTypeHandler.java delete mode 100755 server-extension/src/main/java/hsy/pipe/tagpipe/TagPipeConfigurationServiceIbatisImpl.java delete mode 100755 server-extension/src/main/resources/META-INF/SqlMapConfig-tagpipe-configuration.xml delete mode 100755 server-extension/src/main/resources/META-INF/TagPipeConfiguration.xml diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationMapper.java b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationMapper.java new file mode 100644 index 0000000..b0bfda4 --- /dev/null +++ b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationMapper.java @@ -0,0 +1,124 @@ +package hsy.pipe; + +import java.util.List; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.type.JdbcType; +import org.json.JSONObject; + +public interface TagPipeConfigurationMapper { + + @Results(id = "TagPipeResult", value = { + @Result(property="tagId", column="tag_id"), + @Result(property="tagType", column="tag_type"), + @Result(property="tagAddress", column="tag_address"), + @Result(property="tagPipeSize", column="tag_pipe_size"), + @Result(property="tagLowPressureLevel", column="tag_low_pressure_level"), + @Result(property="tagMaxPressureLevel", column="tag_max_pressure_level"), + @Result(property="tagMaxWaterTake", column="tag_max_water_take"), + @Result(property="tagMinPressureLevel", column="tag_min_pressure_level"), + @Result(property="tagBottomHeight", column="tag_bottom_height"), + @Result(property="tagLowTagHeight", column="tag_low_tag_height"), + @Result(property="tagBarrageHeight", column="tag_barrage_height"), + @Result(property="tagGroundHeight", column="tag_ground_height"), + @Result(property="tagOtherIssue", column="tag_other_issue"), + @Result(property="tagGeoJson", column="tag_geojson", jdbcType = JdbcType.VARCHAR, javaType = JSONObject.class), + @Result(property="tagMunicipality", column="tag_municipality"), + @Result(property="tagNeighborhood", column="tag_neighborhood"), + @Result(property="tagBlock", column="tag_block"), + @Result(property="tagPlot", column="tag_plot"), + }) + @Select("SELECT " + + "tag_id," + + "tag_type," + + "tag_address," + + "tag_pipe_size," + + "tag_low_pressure_level," + + "tag_max_pressure_level," + + "tag_max_water_take," + + "tag_min_pressure_level," + + "tag_bottom_height," + + "tag_low_tag_height," + + "tag_barrage_height," + + "tag_ground_height," + + "tag_other_issue," + + "tag_geojson," + + "tag_municipality," + + "tag_neighborhood," + + "tag_block," + + "tag_plot" + + " FROM oskari_tagpipes") + List findAll(); + + @Insert("INSERT INTO oskari_tagpipes (" + + "tag_type," + + "tag_address," + + "tag_pipe_size," + + "tag_low_pressure_level," + + "tag_max_pressure_level," + + "tag_max_water_take," + + "tag_min_pressure_level," + + "tag_bottom_height," + + "tag_low_tag_height," + + "tag_barrage_height," + + "tag_ground_height," + + "tag_other_issue," + + "tag_geojson," + + "tag_municipality," + + "tag_neighborhood," + + "tag_block," + + "tag_plot" + + ") VALUES (" + + "${tagType}," + + "${tagAddress}," + + "${tagPipeSize}," + + "${tagLowPressureLevel}," + + "${tagMaxPressureLevel}," + + "${tagMaxWaterTake}," + + "${tagMinPressureLevel}," + + "${tagBottomHeight}," + + "${tagLowTagHeight}," + + "${tagBarrageHeight}," + + "${tagGroundHeight}," + + "${tagOtherIssue}," + + "${tagGeoJson}," + + "${tagMunicipality}," + + "${tagNeighborhood}," + + "${tagBlock}," + + "${tagPlot}" + + ")") + @Options(useGeneratedKeys=true, keyColumn="tag_id", keyProperty="tagId") + int insert(TagPipeConfiguration tagpipe); + + @Update("UPDATE oskari_tagpipes SET " + + "tag_type = ${tagType}," + + "tag_address = ${tagAddress}," + + "tag_pipe_size = ${tagPipeSize}," + + "tag_low_pressure_level = ${tagLowPressureLevel}," + + "tag_max_pressure_level = ${tagMaxPressureLevel}," + + "tag_max_water_take = ${tagMaxWaterTake}," + + "tag_min_pressure_level = ${tagMinPressureLevel}," + + "tag_bottom_height = ${tagBottomHeight}," + + "tag_low_tag_height = ${tagLowTagHeight}," + + "tag_barrage_height = ${tagBarrageHeight}," + + "tag_ground_height = ${tagGroundHeight}," + + "tag_other_issue = ${tagOtherIssue}," + + "tag_geojson = ${tagGeoJson}," + + "tag_municipality = ${tagMunicipality}," + + "tag_neighborhood = ${tagNeighborhood}," + + "tag_block = ${tagBlock}," + + "tag_plot = ${tagPlot}" + + " WHERE tag_id = ${tagId}") + void update(TagPipeConfiguration tagpipe); + + @Delete("DELETE FROM oskari_tagpipes WHERE tag_id=#{id}") + void delete(@Param("id") int tagPipeId); + +} diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java index 5de979f..e618c1a 100755 --- a/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationService.java @@ -7,8 +7,8 @@ public abstract class TagPipeConfigurationService extends OskariComponent { public abstract List findTagPipes(); - public abstract TagPipeConfiguration findTagPipeById(final int tagPipeId); public abstract void delete(final int tagPipeId); public abstract int insert(final TagPipeConfiguration tagpipe); public abstract void update(final TagPipeConfiguration tagpipe); + } diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationServiceMyBatisImpl.java b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationServiceMyBatisImpl.java new file mode 100644 index 0000000..292f85f --- /dev/null +++ b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationServiceMyBatisImpl.java @@ -0,0 +1,64 @@ +package hsy.pipe; + +import java.util.List; + +import javax.sql.DataSource; + +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; + +import fi.nls.oskari.annotation.Oskari; +import fi.nls.oskari.db.DatasourceHelper; +import fi.nls.oskari.log.LogFactory; +import fi.nls.oskari.log.Logger; +import fi.nls.oskari.mybatis.MyBatisHelper; + +@Oskari +public class TagPipeConfigurationServiceMyBatisImpl extends TagPipeConfigurationService { + + private static final Logger LOG = LogFactory.getLogger(TagPipeConfigurationServiceMyBatisImpl.class); + private static final Class MAPPER = TagPipeConfigurationMapper.class; + + private final SqlSessionFactory factory; + + public TagPipeConfigurationServiceMyBatisImpl() { + this(DatasourceHelper.getInstance().getDataSource()); + } + + public TagPipeConfigurationServiceMyBatisImpl(DataSource ds) { + super(); + if (ds == null) { + LOG.warn("DataSource was null, all future calls will throw NPEs!"); + factory = null; + } else { + factory = MyBatisHelper.initMyBatis(ds, MAPPER); + } + + } + + public List findTagPipes() { + try (SqlSession session = factory.openSession()) { + return session.getMapper(MAPPER).findAll(); + } + } + + public void delete(final int tagPipeId) { + try (SqlSession session = factory.openSession()) { + session.getMapper(MAPPER).delete(tagPipeId); + } + } + + public int insert(final TagPipeConfiguration tagpipe) { + try (SqlSession session = factory.openSession()) { + session.getMapper(MAPPER).insert(tagpipe); + return tagpipe.getTagId(); + } + } + + public void update(final TagPipeConfiguration tagpipe) { + try (SqlSession session = factory.openSession()) { + session.getMapper(MAPPER).update(tagpipe); + } + } + +} diff --git a/server-extension/src/main/java/hsy/pipe/domain/utils/JSONArrayTypeHandler.java b/server-extension/src/main/java/hsy/pipe/domain/utils/JSONArrayTypeHandler.java deleted file mode 100755 index 57c7f7f..0000000 --- a/server-extension/src/main/java/hsy/pipe/domain/utils/JSONArrayTypeHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -package hsy.pipe.domain.utils; - -import java.sql.SQLException; -import java.sql.Types; - -import org.json.JSONArray; -import org.json.JSONException; - -import com.ibatis.sqlmap.client.extensions.ParameterSetter; -import com.ibatis.sqlmap.client.extensions.ResultGetter; -import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback; - -import fi.nls.oskari.log.LogFactory; -import fi.nls.oskari.log.Logger; - -public class JSONArrayTypeHandler implements TypeHandlerCallback { - private final static Logger log = LogFactory.getLogger(JSONArrayTypeHandler.class); - - public void setParameter(ParameterSetter parameterSetter, Object parameter) throws SQLException { - if (parameter == null) { - parameterSetter.setNull(Types.VARCHAR); - } else { - parameterSetter.setString(((JSONArray)parameter).toString()); - } - } - - public Object getResult(ResultGetter resultGetter) throws SQLException { - String value = resultGetter.getString(); - if (resultGetter.wasNull()) { - return null; - } - return valueOf(value); - } - - public Object valueOf(String s) { - JSONArray jsonArray = null; - try { - jsonArray = new JSONArray(s); - } catch (JSONException e) { - log.error("Couldn't parse DB string to JSONArray:", s, e); - return new JSONArray(); - } - return jsonArray; - } -} diff --git a/server-extension/src/main/java/hsy/pipe/tagpipe/TagPipeConfigurationServiceIbatisImpl.java b/server-extension/src/main/java/hsy/pipe/tagpipe/TagPipeConfigurationServiceIbatisImpl.java deleted file mode 100755 index cb7f442..0000000 --- a/server-extension/src/main/java/hsy/pipe/tagpipe/TagPipeConfigurationServiceIbatisImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -package hsy.pipe.tagpipe; - -import java.io.Reader; -import java.sql.SQLException; -import java.util.List; - -import com.ibatis.common.resources.Resources; -import com.ibatis.sqlmap.client.SqlMapClient; -import com.ibatis.sqlmap.client.SqlMapClientBuilder; -import com.ibatis.sqlmap.client.SqlMapSession; - -import fi.nls.oskari.log.LogFactory; -import fi.nls.oskari.log.Logger; -import fi.nls.oskari.service.db.BaseIbatisService; -import hsy.pipe.domain.TagPipeConfiguration; - -public class TagPipeConfigurationServiceIbatisImpl extends BaseIbatisService implements TagPipeConfigurationService{ - private final static Logger log = LogFactory.getLogger(TagPipeConfigurationServiceIbatisImpl.class); - private SqlMapClient client = null; - - @Override - protected String getNameSpace() { - return "TagPipeConfiguration"; - } - - public List findTagPipes() { - List tagpipes = queryForList(getNameSpace() + ".findTagPipes"); - return tagpipes; - } - - public TagPipeConfiguration findTagPipeById(final int tagPipeId) { - long tagpipe_id = Long.valueOf(tagPipeId); - TagPipeConfiguration tagpipe = queryForObject(getNameSpace() + ".findTagPipeById", tagpipe_id); - return tagpipe; - } - - - /* - * The purpose of this method is to allow many SqlMapConfig.xml files in a - * single portlet - */ - protected String getSqlMapLocation() { - return "META-INF/SqlMapConfig-tagpipe-configuration.xml"; - } - - /** - * Returns SQLmap - * - * @return - */ - @Override - protected SqlMapClient getSqlMapClient() { - if (client != null) { - return client; - } - - Reader reader = null; - try { - String sqlMapLocation = getSqlMapLocation(); - reader = Resources.getResourceAsReader(sqlMapLocation); - client = SqlMapClientBuilder.buildSqlMapClient(reader); - return client; - } catch (Exception e) { - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); - throw new RuntimeException("Failed to retrieve SQL client", e); - } finally { - if (reader != null) { - try { - reader.close(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - } - - public void delete(final int tagPipeId) { - long tagpipe_id = Long.valueOf(tagPipeId); - final SqlMapSession session = openSession(); - try { - session.startTransaction(); - // remove tagpipe - session.delete(getNameSpace() + ".delete", tagpipe_id); - session.commitTransaction(); - } catch (Exception e) { - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); - new RuntimeException("Error deleting tagpipe with id:" + Long.toString(tagpipe_id), e); - } finally { - endSession(session); - } - }; - - public synchronized int insert(final TagPipeConfiguration tagpipe) { - SqlMapClient client = null; - try { - client = getSqlMapClient(); - client.startTransaction(); - client.insert(getNameSpace() + ".insert", tagpipe); - Integer id = (Integer) client.queryForObject(getNameSpace() + ".maxId"); - client.commitTransaction(); - return id; - } catch (Exception e) { - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); - throw new RuntimeException("Failed to insert tagpipe", e); - } finally { - if (client != null) { - try { - client.endTransaction(); - } catch (SQLException ignored) { } - } - } - } - - public void update(final TagPipeConfiguration tagpipe) { - try { - getSqlMapClient().update(getNameSpace() + ".update", tagpipe); - } catch (Exception e) { - log.error(org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); - throw new RuntimeException("Failed to update tagpipe", e); - } - }; -} diff --git a/server-extension/src/main/resources/META-INF/SqlMapConfig-tagpipe-configuration.xml b/server-extension/src/main/resources/META-INF/SqlMapConfig-tagpipe-configuration.xml deleted file mode 100755 index 4e84a81..0000000 --- a/server-extension/src/main/resources/META-INF/SqlMapConfig-tagpipe-configuration.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/server-extension/src/main/resources/META-INF/TagPipeConfiguration.xml b/server-extension/src/main/resources/META-INF/TagPipeConfiguration.xml deleted file mode 100755 index 3e2bf12..0000000 --- a/server-extension/src/main/resources/META-INF/TagPipeConfiguration.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SELECT - * - FROM oskari_tagpipes - ORDER BY tag_id ASC; - - - - SELECT - * - FROM oskari_tagpipes - WHERE tag_id=#tagpipe_id#; - - - - DELETE FROM oskari_tagpipes WHERE tag_id=#tagpipe_id#; - - - - INSERT INTO oskari_tagpipes ( - tag_type, - tag_address, - tag_pipe_size, - tag_low_pressure_level, - tag_max_pressure_level, - tag_max_water_take, - tag_min_pressure_level, - tag_bottom_height, - tag_low_tag_height, - tag_barrage_height, - tag_ground_height, - tag_other_issue, - tag_geojson, - tag_municipality, - tag_neighborhood, - tag_block, - tag_plot) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - - - - UPDATE oskari_tagpipes - SET - tag_address=?, - tag_pipe_size=?, - tag_low_pressure_level=?, - tag_max_pressure_level=?, - tag_max_water_take=?, - tag_min_pressure_level=?, - tag_bottom_height=?, - tag_low_tag_height=?, - tag_barrage_height=?, - tag_ground_height=?, - tag_other_issue=?, - tag_geojson=?, - tag_municipality=?, - tag_neighborhood=?, - tag_block=?, - tag_plot=? - WHERE tag_id = ? - - \ No newline at end of file From 5f06cfa748636eca653b6d8fb47c38c01b8b3442 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 15:05:34 +0200 Subject: [PATCH 14/26] Migrate migrations to Oskari 2.x --- .../dev/V1_00_0__add_default_admin_user.java | 21 ++++---- ...00_0__register_download_basket_bundle.java | 17 ++++--- ...V1_00_1__add_download_basket_to_views.java | 48 +++-------------- .../V1_00_2__register_link_panel_bundle.java | 16 +++--- .../hsy/V1_00_3__add_link_panel_to_views.java | 48 +++-------------- ...1_00_4__register_lang_override_bundle.java | 19 ++++--- .../V1_00_5__add_lang_override_to_views.java | 49 +++--------------- ..._00_6__register_content_editor_bundle.java | 28 +++++----- ...groundlayerselectionplugin_to_mapfull.java | 11 ++-- ..._register_selected_featuredata_bundle.java | 16 +++--- ..._9__add_selected_featuredata_to_views.java | 51 +++---------------- ...tor2_bundle_to_hierarchical_layerlist.java | 32 +++++------- ...erselection_bundle_from_default_views.java | 29 +++++------ ...e_background_selection_plugins_layers.java | 13 ++--- .../V1_02_3__add_logoplugin_to_mapfull.java | 13 ++--- ..._4__add_selected_featuredata_to_views.java | 17 ++++--- .../V1_02_6__update_logoplugin_config.java | 13 ++--- ...00_0__register_water_pipe_tool_bundle.java | 15 +++--- 18 files changed, 148 insertions(+), 308 deletions(-) diff --git a/hsy-resources/src/main/java/flyway/dev/V1_00_0__add_default_admin_user.java b/hsy-resources/src/main/java/flyway/dev/V1_00_0__add_default_admin_user.java index 201b5d1..787bddc 100755 --- a/hsy-resources/src/main/java/flyway/dev/V1_00_0__add_default_admin_user.java +++ b/hsy-resources/src/main/java/flyway/dev/V1_00_0__add_default_admin_user.java @@ -1,30 +1,29 @@ package flyway.dev; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; + import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; import fi.nls.oskari.service.ServiceException; import fi.nls.oskari.service.UserService; import fi.nls.oskari.user.DatabaseUserService; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; - -import java.sql.Connection; -public class V1_00_0__add_default_admin_user implements JdbcMigration { +public class V1_00_0__add_default_admin_user extends BaseJavaMigration { private Logger log = LogFactory.getLogger(V1_00_0__add_default_admin_user.class); - public void migrate(Connection connection) { - + public void migrate(Context context) { UserService dbService = null; try { dbService = DatabaseUserService.getInstance(); + try { + dbService.updateUserPassword("admin", "oskari"); + } catch (ServiceException se) { + log.error(se, "Cannot update password"); + } } catch (ServiceException se) { log.error(se, "Unable to initialize User service!"); } - try { - dbService.updateUserPassword("admin", "oskari"); - } catch (ServiceException se) { - log.error(se, "Cannot update password"); - } } } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_0__register_download_basket_bundle.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_0__register_download_basket_bundle.java index 66f984f..95add19 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_0__register_download_basket_bundle.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_0__register_download_basket_bundle.java @@ -1,24 +1,25 @@ package flyway.hsy; -import java.sql.Connection; +import java.sql.SQLException; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.BundleHelper; -import fi.nls.oskari.db.BundleHelper; import fi.nls.oskari.domain.map.view.Bundle; -public class V1_00_0__register_download_basket_bundle implements JdbcMigration{ +public class V1_00_0__register_download_basket_bundle extends BaseJavaMigration { - private static final String NAMESPACE = "hsy"; private static final String DOWNLOAD_BASKET = "download-basket"; - public void migrate(Connection connection) { + public void migrate(Context context) throws SQLException { // BundleHelper checks if these bundles are already registered Bundle downloadBasket = new Bundle(); downloadBasket.setConfig("{}"); downloadBasket.setState("{}"); downloadBasket.setName(DOWNLOAD_BASKET); - downloadBasket.setStartup(BundleHelper.getDefaultBundleStartup(NAMESPACE, DOWNLOAD_BASKET, "Download basket")); - BundleHelper.registerBundle(downloadBasket); + //downloadBasket.setStartup(BundleHelper.getDefaultBundleStartup(NAMESPACE, DOWNLOAD_BASKET, "Download basket")); + BundleHelper.registerBundle(context.getConnection(), downloadBasket); } + } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_1__add_download_basket_to_views.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_1__add_download_basket_to_views.java index e02d6e4..a14f0d3 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_1__add_download_basket_to_views.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_1__add_download_basket_to_views.java @@ -1,49 +1,15 @@ package flyway.hsy; -import java.sql.Connection; -import java.sql.PreparedStatement; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.AppSetupHelper; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; - -import fi.nls.oskari.map.view.ViewService; -import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; - -public class V1_00_1__add_download_basket_to_views implements JdbcMigration { +public class V1_00_1__add_download_basket_to_views extends BaseJavaMigration { - private static final ViewService VIEW_SERVICE = new AppSetupServiceMybatisImpl(); private static final String DOWNLOAD_BASKET = "download-basket"; - public void migrate(Connection connection) throws Exception { - long viewId = VIEW_SERVICE.getDefaultViewId(); - makeInsert(viewId,connection); - } - - private void makeInsert(long viewId, Connection connection) - throws Exception { - - final PreparedStatement statement = - connection.prepareStatement("INSERT INTO portti_view_bundle_seq" + - "(view_id, bundle_id, seqno, config, state, startup, bundleinstance) " + - "VALUES (" + - "?, " + - "(SELECT id FROM portti_bundle WHERE name=?), " + - "(SELECT max(seqno)+1 FROM portti_view_bundle_seq WHERE view_id=?), " + - "?, ?, " + - "(SELECT startup FROM portti_bundle WHERE name=?), " + - "?)"); - - statement.setLong(1, viewId); - statement.setString(2, DOWNLOAD_BASKET); - statement.setLong(3, viewId); - statement.setString(4, "{}"); - statement.setString(5, "{}"); - statement.setString(6, DOWNLOAD_BASKET); - statement.setString(7, DOWNLOAD_BASKET); - - try { - statement.execute(); - } finally { - statement.close(); - } + public void migrate(Context context) throws Exception { + AppSetupHelper.addBundleToApps(context.getConnection(), DOWNLOAD_BASKET); } + } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_2__register_link_panel_bundle.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_2__register_link_panel_bundle.java index 8ea970e..52f9e50 100644 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_2__register_link_panel_bundle.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_2__register_link_panel_bundle.java @@ -1,24 +1,22 @@ package flyway.hsy; -import java.sql.Connection; +import java.sql.SQLException; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.BundleHelper; -import fi.nls.oskari.db.BundleHelper; import fi.nls.oskari.domain.map.view.Bundle; -public class V1_00_2__register_link_panel_bundle implements JdbcMigration{ +public class V1_00_2__register_link_panel_bundle extends BaseJavaMigration { - private static final String NAMESPACE = "hsy"; private static final String LINK_PANEL = "link-panel"; - public void migrate(Connection connection) { - // BundleHelper checks if these bundles are already registered + public void migrate(Context context) throws SQLException { Bundle linkPanel = new Bundle(); linkPanel.setConfig("{}"); linkPanel.setState("{}"); linkPanel.setName(LINK_PANEL); - linkPanel.setStartup(BundleHelper.getDefaultBundleStartup(NAMESPACE, LINK_PANEL, "Link panel")); - BundleHelper.registerBundle(linkPanel); + BundleHelper.registerBundle(context.getConnection(), linkPanel); } } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_3__add_link_panel_to_views.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_3__add_link_panel_to_views.java index 231199d..92c21f4 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_3__add_link_panel_to_views.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_3__add_link_panel_to_views.java @@ -1,49 +1,15 @@ package flyway.hsy; -import java.sql.Connection; -import java.sql.PreparedStatement; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.AppSetupHelper; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; - -import fi.nls.oskari.map.view.ViewService; -import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; - -public class V1_00_3__add_link_panel_to_views implements JdbcMigration{ +public class V1_00_3__add_link_panel_to_views extends BaseJavaMigration { - private static final ViewService VIEW_SERVICE = new AppSetupServiceMybatisImpl(); - private static final String LINK_PANEL = "link-panel"; + private static final String LINK_PANEL = "link-panel"; - public void migrate(Connection connection) throws Exception { - long viewId = VIEW_SERVICE.getDefaultViewId(); - makeInsert(viewId,connection); + public void migrate(Context context) throws Exception { + AppSetupHelper.addBundleToApps(context.getConnection(), LINK_PANEL); } - private void makeInsert(long viewId, Connection connection) - throws Exception { - - final PreparedStatement statement = - connection.prepareStatement("INSERT INTO portti_view_bundle_seq" + - "(view_id, bundle_id, seqno, config, state, startup, bundleinstance) " + - "VALUES (" + - "?, " + - "(SELECT id FROM portti_bundle WHERE name=?), " + - "(SELECT max(seqno)+1 FROM portti_view_bundle_seq WHERE view_id=?), " + - "?, ?, " + - "(SELECT startup FROM portti_bundle WHERE name=?), " + - "?)"); - - statement.setLong(1, viewId); - statement.setString(2, LINK_PANEL); - statement.setLong(3, viewId); - statement.setString(4, "{}"); - statement.setString(5, "{}"); - statement.setString(6, LINK_PANEL); - statement.setString(7, LINK_PANEL); - - try { - statement.execute(); - } finally { - statement.close(); - } - } } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_4__register_lang_override_bundle.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_4__register_lang_override_bundle.java index 2ac4d93..25d4044 100644 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_4__register_lang_override_bundle.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_4__register_lang_override_bundle.java @@ -1,23 +1,22 @@ package flyway.hsy; -import java.sql.Connection; +import java.sql.SQLException; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.BundleHelper; -import fi.nls.oskari.db.BundleHelper; import fi.nls.oskari.domain.map.view.Bundle; -public class V1_00_4__register_lang_override_bundle implements JdbcMigration{ - private static final String NAMESPACE = "hsy"; - private static final String LANG_OVERRIDES = "hsy-lang-overrides"; +public class V1_00_4__register_lang_override_bundle extends BaseJavaMigration { - public void migrate(Connection connection) { - // BundleHelper checks if these bundles are already registered + private static final String LANG_OVERRIDES = "hsy-lang-overrides"; + + public void migrate(Context context) throws SQLException { Bundle linkPanel = new Bundle(); linkPanel.setConfig("{}"); linkPanel.setState("{}"); linkPanel.setName(LANG_OVERRIDES); - linkPanel.setStartup(BundleHelper.getDefaultBundleStartup(NAMESPACE, LANG_OVERRIDES, "Lang overrides")); - BundleHelper.registerBundle(linkPanel); + BundleHelper.registerBundle(context.getConnection(), linkPanel); } } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_5__add_lang_override_to_views.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_5__add_lang_override_to_views.java index e509347..6636147 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_5__add_lang_override_to_views.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_5__add_lang_override_to_views.java @@ -1,48 +1,15 @@ package flyway.hsy; -import java.sql.Connection; -import java.sql.PreparedStatement; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.AppSetupHelper; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; +public class V1_00_5__add_lang_override_to_views extends BaseJavaMigration { -import fi.nls.oskari.map.view.ViewService; -import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; + private static final String LANG_OVERRIDES = "hsy-lang-overrides"; -public class V1_00_5__add_lang_override_to_views implements JdbcMigration{ - private static final ViewService VIEW_SERVICE = new AppSetupServiceMybatisImpl(); - private static final String LANG_OVERRIDES = "hsy-lang-overrides"; - - public void migrate(Connection connection) throws Exception { - long viewId = VIEW_SERVICE.getDefaultViewId(); - makeInsert(viewId,connection); - } - - private void makeInsert(long viewId, Connection connection) - throws Exception { - - final PreparedStatement statement = - connection.prepareStatement("INSERT INTO portti_view_bundle_seq" + - "(view_id, bundle_id, seqno, config, state, startup, bundleinstance) " + - "VALUES (" + - "?, " + - "(SELECT id FROM portti_bundle WHERE name=?), " + - "(SELECT max(seqno)+1 FROM portti_view_bundle_seq WHERE view_id=?), " + - "?, ?, " + - "(SELECT startup FROM portti_bundle WHERE name=?), " + - "?)"); - - statement.setLong(1, viewId); - statement.setString(2, LANG_OVERRIDES); - statement.setLong(3, viewId); - statement.setString(4, "{}"); - statement.setString(5, "{}"); - statement.setString(6, LANG_OVERRIDES); - statement.setString(7, LANG_OVERRIDES); - - try { - statement.execute(); - } finally { - statement.close(); - } + public void migrate(Context context) throws Exception { + AppSetupHelper.addBundleToApps(context.getConnection(), LANG_OVERRIDES); } + } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_6__register_content_editor_bundle.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_6__register_content_editor_bundle.java index 602d229..b395564 100644 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_6__register_content_editor_bundle.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_6__register_content_editor_bundle.java @@ -1,24 +1,22 @@ package flyway.hsy; -import java.sql.Connection; +import java.sql.SQLException; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.BundleHelper; -import fi.nls.oskari.db.BundleHelper; import fi.nls.oskari.domain.map.view.Bundle; -public class V1_00_6__register_content_editor_bundle implements JdbcMigration{ +public class V1_00_6__register_content_editor_bundle extends BaseJavaMigration { - private static final String NAMESPACE = "tampere"; - private static final String CONTENT_EDITOR = "content-editor"; + private static final String CONTENT_EDITOR = "content-editor"; - public void migrate(Connection connection) { - // BundleHelper checks if these bundles are already registered - Bundle contenEditorTool = new Bundle(); - contenEditorTool.setConfig("{}"); - contenEditorTool.setState("{}"); - contenEditorTool.setName(CONTENT_EDITOR); - contenEditorTool.setStartup(BundleHelper.getDefaultBundleStartup(NAMESPACE, CONTENT_EDITOR, "content-editor")); - BundleHelper.registerBundle(contenEditorTool); - } + public void migrate(Context context) throws SQLException { + Bundle contenEditorTool = new Bundle(); + contenEditorTool.setConfig("{}"); + contenEditorTool.setState("{}"); + contenEditorTool.setName(CONTENT_EDITOR); + BundleHelper.registerBundle(context.getConnection(), contenEditorTool); + } } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_7__add_backgroundlayerselectionplugin_to_mapfull.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_7__add_backgroundlayerselectionplugin_to_mapfull.java index 7b65913..1b15f6f 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_7__add_backgroundlayerselectionplugin_to_mapfull.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_7__add_backgroundlayerselectionplugin_to_mapfull.java @@ -7,19 +7,20 @@ import fi.nls.oskari.map.layer.OskariLayerServiceMybatisImpl; import fi.nls.oskari.map.view.ViewService; import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import java.sql.Connection; import java.util.List; /** * Created by * @author Heikki Ylitalo */ -public class V1_00_7__add_backgroundlayerselectionplugin_to_mapfull implements JdbcMigration { +public class V1_00_7__add_backgroundlayerselectionplugin_to_mapfull extends BaseJavaMigration { private static final ViewService VIEW_SERVICE = new AppSetupServiceMybatisImpl(); private static final OskariLayerService LAYER_SERVICE = new OskariLayerServiceMybatisImpl(); private static final String PLUGIN_NAME = "Oskari.mapframework.bundle.mapmodule.plugin.BackgroundLayerSelectionPlugin"; @@ -27,8 +28,8 @@ public class V1_00_7__add_backgroundlayerselectionplugin_to_mapfull implements J private static final String OPASKARTTA_NAME = "Opaskartta_PKS"; private static final String ORTOILMAKUVA2015_NAME = "taustakartat_ja_aluejaot:ortoilmakuva2015"; private static final String OSM_NAME = "osm-finland"; - public void migrate(Connection connection) - throws Exception { + + public void migrate(Context context) throws Exception { List views = VIEW_SERVICE.getViewsForUser(-1); for(View v : views) { if(v.isDefault()) { diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_8__register_selected_featuredata_bundle.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_8__register_selected_featuredata_bundle.java index 8b8cd4c..7c617e3 100644 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_8__register_selected_featuredata_bundle.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_8__register_selected_featuredata_bundle.java @@ -1,24 +1,22 @@ package flyway.hsy; -import java.sql.Connection; +import java.sql.SQLException; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.BundleHelper; -import fi.nls.oskari.db.BundleHelper; import fi.nls.oskari.domain.map.view.Bundle; -public class V1_00_8__register_selected_featuredata_bundle implements JdbcMigration{ +public class V1_00_8__register_selected_featuredata_bundle extends BaseJavaMigration { - private static final String NAMESPACE = "framework"; private static final String SELECTED_FEATUREDATA = "selected-featuredata"; - public void migrate(Connection connection) { - // BundleHelper checks if these bundles are already registered + public void migrate(Context context) throws SQLException { Bundle selectedFeatureData = new Bundle(); selectedFeatureData.setConfig("{}"); selectedFeatureData.setState("{}"); selectedFeatureData.setName(SELECTED_FEATUREDATA); - selectedFeatureData.setStartup(BundleHelper.getDefaultBundleStartup(NAMESPACE, SELECTED_FEATUREDATA, "Selected Featuredata")); - BundleHelper.registerBundle(selectedFeatureData); + BundleHelper.registerBundle(context.getConnection(), selectedFeatureData); } } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_00_9__add_selected_featuredata_to_views.java b/hsy-resources/src/main/java/flyway/hsy/V1_00_9__add_selected_featuredata_to_views.java index efda476..121a44c 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_00_9__add_selected_featuredata_to_views.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_00_9__add_selected_featuredata_to_views.java @@ -1,50 +1,15 @@ package flyway.hsy; -import java.sql.Connection; -import java.sql.PreparedStatement; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.AppSetupHelper; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; - -import fi.nls.oskari.map.view.ViewService; -import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; - -public class V1_00_9__add_selected_featuredata_to_views implements JdbcMigration { +public class V1_00_9__add_selected_featuredata_to_views extends BaseJavaMigration { - private static final ViewService VIEW_SERVICE = new AppSetupServiceMybatisImpl(); - private static final String SELECTED_FEATUREDATA = "selected-featuredata"; + private static final String SELECTED_FEATUREDATA = "selected-featuredata"; - public void migrate(Connection connection) throws Exception { - long viewId = VIEW_SERVICE.getDefaultViewId(); - makeInsert(viewId,connection); - makeInsert(1,connection); - } - - private void makeInsert(long viewId, Connection connection) - throws Exception { - - final PreparedStatement statement = - connection.prepareStatement("INSERT INTO portti_view_bundle_seq" + - "(view_id, bundle_id, seqno, config, state, startup, bundleinstance) " + - "VALUES (" + - "?, " + - "(SELECT id FROM portti_bundle WHERE name=?), " + - "(SELECT max(seqno)+1 FROM portti_view_bundle_seq WHERE view_id=?), " + - "?, ?, " + - "(SELECT startup FROM portti_bundle WHERE name=?), " + - "?)"); - - statement.setLong(1, viewId); - statement.setString(2, SELECTED_FEATUREDATA); - statement.setLong(3, viewId); - statement.setString(4, "{}"); - statement.setString(5, "{}"); - statement.setString(6, SELECTED_FEATUREDATA); - statement.setString(7, SELECTED_FEATUREDATA); - - try { - statement.execute(); - } finally { - statement.close(); - } + public void migrate(Context context) throws Exception { + AppSetupHelper.addBundleToApps(context.getConnection(), SELECTED_FEATUREDATA); } + } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_02_0__replace_layerselector2_bundle_to_hierarchical_layerlist.java b/hsy-resources/src/main/java/flyway/hsy/V1_02_0__replace_layerselector2_bundle_to_hierarchical_layerlist.java index b4dc649..7e5443c 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_02_0__replace_layerselector2_bundle_to_hierarchical_layerlist.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_02_0__replace_layerselector2_bundle_to_hierarchical_layerlist.java @@ -7,35 +7,29 @@ import java.util.ArrayList; import java.util.List; -import fi.nls.oskari.db.BundleHelper; import fi.nls.oskari.domain.map.view.Bundle; import fi.nls.oskari.domain.map.view.View; import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; -import fi.nls.oskari.util.FlywayHelper; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; -import fi.nls.oskari.map.view.ViewService; -import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.BundleHelper; - -public class V1_02_0__replace_layerselector2_bundle_to_hierarchical_layerlist implements JdbcMigration { +public class V1_02_0__replace_layerselector2_bundle_to_hierarchical_layerlist extends BaseJavaMigration { private static final Logger LOG = LogFactory.getLogger(V1_02_0__replace_layerselector2_bundle_to_hierarchical_layerlist.class); private static final String BUNDLE_LAYERSELECTOR2 = "layerselector2"; private static final String BUNDLE_HIERARCHICAL_LAYERLIST = "hierarchical-layerlist"; private int updatedViewCount = 0; - private ViewService service = null; - public void migrate(Connection connection) throws Exception { - service = new AppSetupServiceMybatisImpl(); + public void migrate(Context context) throws Exception { try { - updateViews(connection); + updateViews(context.getConnection()); } finally { LOG.info("Updated views:", updatedViewCount); - service = null; } } @@ -52,11 +46,11 @@ private void updateViews(Connection conn) private List getOutdatedViews(Connection conn) throws SQLException { List list = new ArrayList<>(); - final String sql = "SELECT id FROM portti_view " + + final String sql = "SELECT id FROM oskari_appsetup " + "WHERE (type = 'USER' OR type = 'DEFAULT') AND " + "id IN (" + - "SELECT distinct view_id FROM portti_view_bundle_seq WHERE bundle_id IN (" + - "SELECT id FROM portti_bundle WHERE name='layerselection2' OR name='layerselector2'" + + "SELECT distinct appsetup_id FROM oskari_appsetup_bundles WHERE bundle_id IN (" + + "SELECT id FROM oskari_bundle WHERE name='layerselection2' OR name='layerselector2'" + "));"; try (PreparedStatement statement = conn.prepareStatement(sql)) { try (ResultSet rs = statement.executeQuery()) { @@ -72,12 +66,12 @@ private List getOutdatedViews(Connection conn) throws SQLException { public void addHierarchicalLayerListBundle(Connection conn, final long viewId) throws SQLException { - Bundle layerselectorBundle = BundleHelper.getRegisteredBundle(BUNDLE_LAYERSELECTOR2, conn); + Bundle layerselectorBundle = BundleHelper.getRegisteredBundle(conn, BUNDLE_LAYERSELECTOR2); if( layerselectorBundle == null) { // not even registered so migration not needed return; } - Bundle newBundle = BundleHelper.getRegisteredBundle(BUNDLE_HIERARCHICAL_LAYERLIST, conn); + Bundle newBundle = BundleHelper.getRegisteredBundle(conn, BUNDLE_HIERARCHICAL_LAYERLIST); if(newBundle == null) { throw new RuntimeException("Bundle not registered: " + BUNDLE_HIERARCHICAL_LAYERLIST); } @@ -88,12 +82,12 @@ public void addHierarchicalLayerListBundle(Connection conn, final long viewId) t } public void replaceLayerselectorBundleToHierarchicalLayerlist(Connection conn, final long viewId, final Bundle oldBundle, final Bundle newBundle) throws SQLException { - final String sql = "UPDATE portti_view_bundle_seq " + + final String sql = "UPDATE oskari_appsetup_bundles " + "SET " + " bundle_id=?, " + " startup=?, " + " bundleinstance=?" + - "WHERE bundle_id = ? and view_id=?"; + "WHERE bundle_id = ? and appsetup_id=?"; try (PreparedStatement statement = conn.prepareStatement(sql)){ diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_02_1__remove_layerselection_bundle_from_default_views.java b/hsy-resources/src/main/java/flyway/hsy/V1_02_1__remove_layerselection_bundle_from_default_views.java index 16fc8d1..98eda27 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_02_1__remove_layerselection_bundle_from_default_views.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_02_1__remove_layerselection_bundle_from_default_views.java @@ -1,13 +1,13 @@ package flyway.hsy; -import fi.nls.oskari.db.BundleHelper; import fi.nls.oskari.domain.map.view.Bundle; import fi.nls.oskari.domain.map.view.View; import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; -import fi.nls.oskari.map.view.ViewService; -import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.BundleHelper; import java.sql.Connection; import java.sql.PreparedStatement; @@ -16,22 +16,19 @@ import java.util.ArrayList; import java.util.List; -public class V1_02_1__remove_layerselection_bundle_from_default_views implements JdbcMigration { +public class V1_02_1__remove_layerselection_bundle_from_default_views extends BaseJavaMigration { private static final Logger LOG = LogFactory.getLogger(V1_02_1__remove_layerselection_bundle_from_default_views.class); private static final String BUNDLE_LAYERSELECTION2 = "layerselection2"; private int updatedViewCount = 0; - private ViewService service = null; - public void migrate(Connection connection) throws Exception { - service = new AppSetupServiceMybatisImpl(); + public void migrate(Context context) throws Exception { try { - updateViews(connection); + updateViews(context.getConnection()); } finally { LOG.info("Updated views:", updatedViewCount); - service = null; } } @@ -48,11 +45,11 @@ private void updateViews(Connection conn) private List getOutdatedViews(Connection conn) throws SQLException { List list = new ArrayList<>(); - final String sql = "SELECT id FROM portti_view " + + final String sql = "SELECT id FROM oskari_appsetup " + "WHERE (type = 'USER' OR type = 'DEFAULT') AND " + "id IN (" + - "SELECT distinct view_id FROM portti_view_bundle_seq WHERE bundle_id IN (" + - "SELECT id FROM portti_bundle WHERE name='layerselection2'" + + "SELECT distinct appsetup_id FROM oskari_appsetup_bundles WHERE bundle_id IN (" + + "SELECT id FROM oskari_bundle WHERE name='layerselection2'" + "));"; try (PreparedStatement statement = conn.prepareStatement(sql)) { try (ResultSet rs = statement.executeQuery()) { @@ -68,15 +65,15 @@ private List getOutdatedViews(Connection conn) throws SQLException { public void removeLayerselectionBundle(Connection conn, final long viewId) throws SQLException { - Bundle layerselectionBundle = BundleHelper.getRegisteredBundle(BUNDLE_LAYERSELECTION2, conn); + Bundle layerselectionBundle = BundleHelper.getRegisteredBundle(conn, BUNDLE_LAYERSELECTION2); if(layerselectionBundle == null) { // not even registered so migration not needed return; } // remove layerselection2 bundle - final String sql = "DELETE FROM portti_view_bundle_seq " + - "WHERE bundle_id = ? AND view_id=?;"; + final String sql = "DELETE FROM oskari_appsetup_bundles " + + "WHERE bundle_id = ? AND appsetup_id=?;"; try (PreparedStatement statement = conn.prepareStatement(sql)){ diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_02_2__update_background_selection_plugins_layers.java b/hsy-resources/src/main/java/flyway/hsy/V1_02_2__update_background_selection_plugins_layers.java index d6a1d85..899cf8b 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_02_2__update_background_selection_plugins_layers.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_02_2__update_background_selection_plugins_layers.java @@ -1,21 +1,18 @@ package flyway.hsy; -import fi.nls.oskari.log.LogFactory; -import fi.nls.oskari.log.Logger; import fi.nls.oskari.util.PropertyUtil; import helpers.LayerHelper; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; -import java.sql.Connection; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; -public class V1_02_2__update_background_selection_plugins_layers implements JdbcMigration { - private static final Logger LOG = LogFactory.getLogger(V1_02_2__update_background_selection_plugins_layers.class); +public class V1_02_2__update_background_selection_plugins_layers extends BaseJavaMigration { - public void migrate(Connection connection) throws Exception { + public void migrate(Context context) throws Exception { String[] layers = PropertyUtil.getCommaSeparatedList("flyway.hsy.V1_02_2.layers"); boolean skip = PropertyUtil.getOptional("flyway.hsy.V1_02_2.skip", false); if (!skip) { - LayerHelper.setBackgroundSelectionPluginLayers(connection, layers); + LayerHelper.setBackgroundSelectionPluginLayers(context.getConnection(), layers); } } } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_02_3__add_logoplugin_to_mapfull.java b/hsy-resources/src/main/java/flyway/hsy/V1_02_3__add_logoplugin_to_mapfull.java index a614af8..839655b 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_02_3__add_logoplugin_to_mapfull.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_02_3__add_logoplugin_to_mapfull.java @@ -1,26 +1,23 @@ package flyway.hsy; -import fi.nls.oskari.domain.map.OskariLayer; import fi.nls.oskari.domain.map.view.Bundle; import fi.nls.oskari.domain.map.view.View; -import fi.nls.oskari.map.layer.OskariLayerService; -import fi.nls.oskari.map.layer.OskariLayerServiceMybatisImpl; import fi.nls.oskari.map.view.ViewService; import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import java.sql.Connection; import java.util.List; -public class V1_02_3__add_logoplugin_to_mapfull implements JdbcMigration { +public class V1_02_3__add_logoplugin_to_mapfull extends BaseJavaMigration { private static final ViewService VIEW_SERVICE = new AppSetupServiceMybatisImpl(); - private static final OskariLayerService LAYER_SERVICE = new OskariLayerServiceMybatisImpl(); private static final String PLUGIN_NAME = "Oskari.mapframework.bundle.mapmodule.plugin.LogoPlugin"; private static final String MAPFULL = "mapfull"; - public void migrate(Connection connection) + public void migrate(Context context) throws Exception { List views = VIEW_SERVICE.getViewsForUser(-1); for(View v : views) { diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_02_4__add_selected_featuredata_to_views.java b/hsy-resources/src/main/java/flyway/hsy/V1_02_4__add_selected_featuredata_to_views.java index 08dd321..966eb22 100755 --- a/hsy-resources/src/main/java/flyway/hsy/V1_02_4__add_selected_featuredata_to_views.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_02_4__add_selected_featuredata_to_views.java @@ -1,27 +1,28 @@ package flyway.hsy; -import fi.nls.oskari.domain.map.view.Bundle; import fi.nls.oskari.domain.map.view.View; import fi.nls.oskari.map.view.ViewService; import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; -import fi.nls.oskari.util.FlywayHelper; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.AppSetupHelper; import java.sql.Connection; import java.util.List; -public class V1_02_4__add_selected_featuredata_to_views implements JdbcMigration { +public class V1_02_4__add_selected_featuredata_to_views extends BaseJavaMigration { private static final ViewService VIEW_SERVICE = new AppSetupServiceMybatisImpl(); private static final String BUNDLE_ID = "selected-featuredata"; - public void migrate(Connection connection) throws Exception { + public void migrate(Context context) throws Exception { + Connection connection = context.getConnection(); List views = VIEW_SERVICE.getViewsForUser(-1); for (View v : views) { if (v.isDefault()) { - if (FlywayHelper.viewContainsBundle(connection, BUNDLE_ID, v.getId())) { - continue; + if (!AppSetupHelper.appContainsBundle(connection, v.getId(), BUNDLE_ID)) { + AppSetupHelper.addBundleToApp(connection, v.getId(), BUNDLE_ID); } - FlywayHelper.addBundleWithDefaults(connection, v.getId(), BUNDLE_ID); } } } diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_02_6__update_logoplugin_config.java b/hsy-resources/src/main/java/flyway/hsy/V1_02_6__update_logoplugin_config.java index ecb16c4..6d5e5e4 100644 --- a/hsy-resources/src/main/java/flyway/hsy/V1_02_6__update_logoplugin_config.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_02_6__update_logoplugin_config.java @@ -1,27 +1,24 @@ package flyway.hsy; -import fi.nls.oskari.domain.map.OskariLayer; import fi.nls.oskari.domain.map.view.Bundle; import fi.nls.oskari.domain.map.view.View; -import fi.nls.oskari.map.layer.OskariLayerService; -import fi.nls.oskari.map.layer.OskariLayerServiceMybatisImpl; import fi.nls.oskari.map.view.ViewService; import fi.nls.oskari.map.view.AppSetupServiceMybatisImpl; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import java.sql.Connection; import java.util.List; -public class V1_02_6__update_logoplugin_config implements JdbcMigration { +public class V1_02_6__update_logoplugin_config extends BaseJavaMigration { private static final ViewService VIEW_SERVICE = new AppSetupServiceMybatisImpl(); - private static final OskariLayerService LAYER_SERVICE = new OskariLayerServiceMybatisImpl(); private static final String PLUGIN_NAME = "Oskari.mapframework.bundle.mapmodule.plugin.LogoPlugin"; private static final String MAPFULL = "mapfull"; - public void migrate(Connection connection) + public void migrate(Context context) throws Exception { List views = VIEW_SERVICE.getViewsForUser(-1); for(View v : views) { diff --git a/hsy-resources/src/main/java/flyway/pipe/V1_00_0__register_water_pipe_tool_bundle.java b/hsy-resources/src/main/java/flyway/pipe/V1_00_0__register_water_pipe_tool_bundle.java index d3837e6..f9e0660 100755 --- a/hsy-resources/src/main/java/flyway/pipe/V1_00_0__register_water_pipe_tool_bundle.java +++ b/hsy-resources/src/main/java/flyway/pipe/V1_00_0__register_water_pipe_tool_bundle.java @@ -1,24 +1,23 @@ package flyway.pipe; -import java.sql.Connection; +import java.sql.SQLException; -import org.flywaydb.core.api.migration.jdbc.JdbcMigration; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.BundleHelper; -import fi.nls.oskari.db.BundleHelper; import fi.nls.oskari.domain.map.view.Bundle; -public class V1_00_0__register_water_pipe_tool_bundle implements JdbcMigration{ +public class V1_00_0__register_water_pipe_tool_bundle extends BaseJavaMigration { - private static final String NAMESPACE = "hsy"; private static final String WATER_PIPE_TOOL = "water-pipe-tool"; - public void migrate(Connection connection) { + public void migrate(Context context) throws SQLException { // BundleHelper checks if these bundles are already registered Bundle waterPipeTool = new Bundle(); waterPipeTool.setConfig("{}"); waterPipeTool.setState("{}"); waterPipeTool.setName(WATER_PIPE_TOOL); - waterPipeTool.setStartup(BundleHelper.getDefaultBundleStartup(NAMESPACE, WATER_PIPE_TOOL, "Waterpipe tool")); - BundleHelper.registerBundle(waterPipeTool); + BundleHelper.registerBundle(context.getConnection(), waterPipeTool); } } From a19ce88ec04da9dc955c06041152609db5d27304 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 15:13:50 +0200 Subject: [PATCH 15/26] Migrate LayerHelper --- .../src/main/java/helpers/LayerHelper.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/hsy-resources/src/main/java/helpers/LayerHelper.java b/hsy-resources/src/main/java/helpers/LayerHelper.java index 498b4d7..f067db0 100644 --- a/hsy-resources/src/main/java/helpers/LayerHelper.java +++ b/hsy-resources/src/main/java/helpers/LayerHelper.java @@ -1,13 +1,12 @@ package helpers; -import fi.mml.map.mapwindow.service.db.OskariMapLayerGroupService; import fi.nls.oskari.control.ActionException; import fi.nls.oskari.control.ActionParamsException; import fi.nls.oskari.map.view.util.ViewHelper; import fi.nls.oskari.service.ServiceException; -import fi.nls.oskari.service.capabilities.CapabilitiesCacheService; + +import org.oskari.capabilities.CapabilitiesService; import org.oskari.capabilities.CapabilitiesUpdateResult; -import org.oskari.capabilities.CapabilitiesUpdateService; import org.oskari.permissions.PermissionService; import fi.nls.oskari.domain.Role; import fi.nls.oskari.domain.map.DataProvider; @@ -17,7 +16,6 @@ import fi.nls.oskari.domain.map.view.View; import fi.nls.oskari.log.LogFactory; import fi.nls.oskari.log.Logger; -import org.oskari.permissions.model.OskariLayerResource; import fi.nls.oskari.map.layer.DataProviderService; import fi.nls.oskari.map.layer.OskariLayerService; import fi.nls.oskari.map.layer.OskariLayerServiceMybatisImpl; @@ -25,12 +23,15 @@ import fi.nls.oskari.map.layer.group.link.OskariLayerGroupLinkService; import fi.nls.oskari.map.view.ViewException; import fi.nls.oskari.map.view.ViewService; + +import org.oskari.permissions.model.OskariLayerResource; import org.oskari.permissions.model.Permission; import org.oskari.permissions.model.Resource; import fi.nls.oskari.user.MybatisRoleService; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import org.oskari.service.maplayer.OskariMapLayerGroupService; import org.oskari.service.util.ServiceFactory; import java.sql.Connection; @@ -74,9 +75,6 @@ public class LayerHelper { private static final String BACKGROUND_LAYER_SELECTION_PLUGIN = "Oskari.mapframework.bundle.mapmodule.plugin.BackgroundLayerSelectionPlugin"; private static OskariLayerService LAYER_SERVICE = ServiceFactory.getMapLayerService(); - private static CapabilitiesCacheService CAPABILITIES_CACHE_SERVICE = ServiceFactory.getCapabilitiesCacheService(); - private static CapabilitiesUpdateService CAPABILITIES_SERVICE = new CapabilitiesUpdateService( - LAYER_SERVICE, CAPABILITIES_CACHE_SERVICE); /** @@ -554,7 +552,7 @@ public static boolean updateCapabilities(String layerId) throws ActionParamsExce Set systemCRSs = getSystemCRSs(); List result = - CAPABILITIES_SERVICE.updateCapabilities(layers, systemCRSs); + CapabilitiesService.updateCapabilities(layers, systemCRSs); return layers.size() == result.size(); } From b38de31616a4f3c3f03610698709ebedb0239c2b Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 19 Dec 2022 15:15:46 +0200 Subject: [PATCH 16/26] Move ammassuo and seutumaisa migrations to src/main/resources so they dont block building --- .../ammassuo/V1_00_0__add_ammassyo_view_and_ammassyo_role.java | 0 ...__add_backgroundlayersselectionplugin_to_ammassuo_mapfull.java | 0 .../V1_00_2__add_selected_featuredata_to_ammassuo_view.java | 0 .../ammassuo/V1_00_3__set_selected_layers_ammassuo_view.java | 0 .../ammassuo/V1_00_4__add_more_ammassuo_roles.java | 0 .../ammassuo/V1_01_0__add_download_basket_to_ammassuo_view.java | 0 .../ammassuo/V1_01_1__add_link_panel_to_ammassuo_view.java | 0 .../ammassuo/V1_01_2__add_lang_override_to_ammassuo_view.java | 0 .../ammassuo/V1_01_3__add_drawtools_to_ammassuo_view.java | 0 .../ammassuo/V1_01_4__add_logoplugin_to_mapfull.java | 0 .../ammassuo/V1_02_0__add_sijoituspaikat_maplayers.java | 0 .../ammassuo/V1_03_0__update_maplayer_styles.java | 0 .../ammassuo/V1_03_1__update_logoplugin_config.java | 0 .../seutumaisa/V1_03_0__add_seutumaisa_view.java | 0 .../seutumaisa/V1_03_10__add_logoplugin_to_mapfull.java | 0 .../seutumaisa/V1_03_11__add_selected_featuredata_to_view.java | 0 .../seutumaisa/V1_03_12__fix_printout_config.java | 0 .../seutumaisa/V1_03_13__register_timeseries_bundle.java | 0 .../seutumaisa/V1_03_14__add_timeseries_to_views.java | 0 ...15__register_seutumaisa_search_bundle_and_add_it_to_views.java | 0 .../V1_03_16__reorder_seutumaisa_view_bundle_startsequences.java | 0 .../seutumaisa/V1_03_17__fix_userguide_configuration.java | 0 .../seutumaisa/V1_03_18__add_drawtools_to_views.java | 0 ...add_backgroundlayersselectionplugin_to_seutumaisa_mapfull.java | 0 .../seutumaisa/V1_03_2__set_map_center_and_zoom_to_hsy_area.java | 0 .../seutumaisa/V1_03_3__register_map_location_bundle.java | 0 .../seutumaisa/V1_03_4__add_map_location_to_seutumaisa_view.java | 0 .../V1_03_5__add_backgroundlayerselectionplugin_to_mapfull.java | 0 .../seutumaisa/V1_03_6__mappfull_add_selected_layers.java | 0 .../seutumaisa/V1_03_7__update_userguide_configuration.java | 0 .../flyway => resources}/seutumaisa/V1_03_9__add_layers.java | 0 ...ster_seutumaisa_history_search_bundle_and_add_it_to_views.java | 0 .../seutumaisa/V1_04_01__update_logoplugin_config.java | 0 33 files changed, 0 insertions(+), 0 deletions(-) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_00_0__add_ammassyo_view_and_ammassyo_role.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_00_1__add_backgroundlayersselectionplugin_to_ammassuo_mapfull.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_00_2__add_selected_featuredata_to_ammassuo_view.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_00_3__set_selected_layers_ammassuo_view.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_00_4__add_more_ammassuo_roles.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_01_0__add_download_basket_to_ammassuo_view.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_01_1__add_link_panel_to_ammassuo_view.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_01_2__add_lang_override_to_ammassuo_view.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_01_3__add_drawtools_to_ammassuo_view.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_01_4__add_logoplugin_to_mapfull.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_02_0__add_sijoituspaikat_maplayers.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_03_0__update_maplayer_styles.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/ammassuo/V1_03_1__update_logoplugin_config.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_0__add_seutumaisa_view.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_10__add_logoplugin_to_mapfull.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_11__add_selected_featuredata_to_view.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_12__fix_printout_config.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_13__register_timeseries_bundle.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_14__add_timeseries_to_views.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_15__register_seutumaisa_search_bundle_and_add_it_to_views.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_16__reorder_seutumaisa_view_bundle_startsequences.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_17__fix_userguide_configuration.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_18__add_drawtools_to_views.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_1__add_backgroundlayersselectionplugin_to_seutumaisa_mapfull.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_2__set_map_center_and_zoom_to_hsy_area.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_3__register_map_location_bundle.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_4__add_map_location_to_seutumaisa_view.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_5__add_backgroundlayerselectionplugin_to_mapfull.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_6__mappfull_add_selected_layers.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_7__update_userguide_configuration.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_03_9__add_layers.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_04_00__register_seutumaisa_history_search_bundle_and_add_it_to_views.java (100%) rename hsy-resources/src/main/{java/flyway => resources}/seutumaisa/V1_04_01__update_logoplugin_config.java (100%) diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_00_0__add_ammassyo_view_and_ammassyo_role.java b/hsy-resources/src/main/resources/ammassuo/V1_00_0__add_ammassyo_view_and_ammassyo_role.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_00_0__add_ammassyo_view_and_ammassyo_role.java rename to hsy-resources/src/main/resources/ammassuo/V1_00_0__add_ammassyo_view_and_ammassyo_role.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_00_1__add_backgroundlayersselectionplugin_to_ammassuo_mapfull.java b/hsy-resources/src/main/resources/ammassuo/V1_00_1__add_backgroundlayersselectionplugin_to_ammassuo_mapfull.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_00_1__add_backgroundlayersselectionplugin_to_ammassuo_mapfull.java rename to hsy-resources/src/main/resources/ammassuo/V1_00_1__add_backgroundlayersselectionplugin_to_ammassuo_mapfull.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_00_2__add_selected_featuredata_to_ammassuo_view.java b/hsy-resources/src/main/resources/ammassuo/V1_00_2__add_selected_featuredata_to_ammassuo_view.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_00_2__add_selected_featuredata_to_ammassuo_view.java rename to hsy-resources/src/main/resources/ammassuo/V1_00_2__add_selected_featuredata_to_ammassuo_view.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_00_3__set_selected_layers_ammassuo_view.java b/hsy-resources/src/main/resources/ammassuo/V1_00_3__set_selected_layers_ammassuo_view.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_00_3__set_selected_layers_ammassuo_view.java rename to hsy-resources/src/main/resources/ammassuo/V1_00_3__set_selected_layers_ammassuo_view.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_00_4__add_more_ammassuo_roles.java b/hsy-resources/src/main/resources/ammassuo/V1_00_4__add_more_ammassuo_roles.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_00_4__add_more_ammassuo_roles.java rename to hsy-resources/src/main/resources/ammassuo/V1_00_4__add_more_ammassuo_roles.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_01_0__add_download_basket_to_ammassuo_view.java b/hsy-resources/src/main/resources/ammassuo/V1_01_0__add_download_basket_to_ammassuo_view.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_01_0__add_download_basket_to_ammassuo_view.java rename to hsy-resources/src/main/resources/ammassuo/V1_01_0__add_download_basket_to_ammassuo_view.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_01_1__add_link_panel_to_ammassuo_view.java b/hsy-resources/src/main/resources/ammassuo/V1_01_1__add_link_panel_to_ammassuo_view.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_01_1__add_link_panel_to_ammassuo_view.java rename to hsy-resources/src/main/resources/ammassuo/V1_01_1__add_link_panel_to_ammassuo_view.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_01_2__add_lang_override_to_ammassuo_view.java b/hsy-resources/src/main/resources/ammassuo/V1_01_2__add_lang_override_to_ammassuo_view.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_01_2__add_lang_override_to_ammassuo_view.java rename to hsy-resources/src/main/resources/ammassuo/V1_01_2__add_lang_override_to_ammassuo_view.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_01_3__add_drawtools_to_ammassuo_view.java b/hsy-resources/src/main/resources/ammassuo/V1_01_3__add_drawtools_to_ammassuo_view.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_01_3__add_drawtools_to_ammassuo_view.java rename to hsy-resources/src/main/resources/ammassuo/V1_01_3__add_drawtools_to_ammassuo_view.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_01_4__add_logoplugin_to_mapfull.java b/hsy-resources/src/main/resources/ammassuo/V1_01_4__add_logoplugin_to_mapfull.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_01_4__add_logoplugin_to_mapfull.java rename to hsy-resources/src/main/resources/ammassuo/V1_01_4__add_logoplugin_to_mapfull.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_02_0__add_sijoituspaikat_maplayers.java b/hsy-resources/src/main/resources/ammassuo/V1_02_0__add_sijoituspaikat_maplayers.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_02_0__add_sijoituspaikat_maplayers.java rename to hsy-resources/src/main/resources/ammassuo/V1_02_0__add_sijoituspaikat_maplayers.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_03_0__update_maplayer_styles.java b/hsy-resources/src/main/resources/ammassuo/V1_03_0__update_maplayer_styles.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_03_0__update_maplayer_styles.java rename to hsy-resources/src/main/resources/ammassuo/V1_03_0__update_maplayer_styles.java diff --git a/hsy-resources/src/main/java/flyway/ammassuo/V1_03_1__update_logoplugin_config.java b/hsy-resources/src/main/resources/ammassuo/V1_03_1__update_logoplugin_config.java similarity index 100% rename from hsy-resources/src/main/java/flyway/ammassuo/V1_03_1__update_logoplugin_config.java rename to hsy-resources/src/main/resources/ammassuo/V1_03_1__update_logoplugin_config.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_0__add_seutumaisa_view.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_0__add_seutumaisa_view.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_0__add_seutumaisa_view.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_0__add_seutumaisa_view.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_10__add_logoplugin_to_mapfull.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_10__add_logoplugin_to_mapfull.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_10__add_logoplugin_to_mapfull.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_10__add_logoplugin_to_mapfull.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_11__add_selected_featuredata_to_view.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_11__add_selected_featuredata_to_view.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_11__add_selected_featuredata_to_view.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_11__add_selected_featuredata_to_view.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_12__fix_printout_config.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_12__fix_printout_config.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_12__fix_printout_config.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_12__fix_printout_config.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_13__register_timeseries_bundle.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_13__register_timeseries_bundle.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_13__register_timeseries_bundle.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_13__register_timeseries_bundle.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_14__add_timeseries_to_views.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_14__add_timeseries_to_views.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_14__add_timeseries_to_views.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_14__add_timeseries_to_views.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_15__register_seutumaisa_search_bundle_and_add_it_to_views.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_15__register_seutumaisa_search_bundle_and_add_it_to_views.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_15__register_seutumaisa_search_bundle_and_add_it_to_views.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_15__register_seutumaisa_search_bundle_and_add_it_to_views.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_16__reorder_seutumaisa_view_bundle_startsequences.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_16__reorder_seutumaisa_view_bundle_startsequences.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_16__reorder_seutumaisa_view_bundle_startsequences.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_16__reorder_seutumaisa_view_bundle_startsequences.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_17__fix_userguide_configuration.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_17__fix_userguide_configuration.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_17__fix_userguide_configuration.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_17__fix_userguide_configuration.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_18__add_drawtools_to_views.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_18__add_drawtools_to_views.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_18__add_drawtools_to_views.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_18__add_drawtools_to_views.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_1__add_backgroundlayersselectionplugin_to_seutumaisa_mapfull.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_1__add_backgroundlayersselectionplugin_to_seutumaisa_mapfull.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_1__add_backgroundlayersselectionplugin_to_seutumaisa_mapfull.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_1__add_backgroundlayersselectionplugin_to_seutumaisa_mapfull.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_2__set_map_center_and_zoom_to_hsy_area.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_2__set_map_center_and_zoom_to_hsy_area.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_2__set_map_center_and_zoom_to_hsy_area.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_2__set_map_center_and_zoom_to_hsy_area.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_3__register_map_location_bundle.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_3__register_map_location_bundle.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_3__register_map_location_bundle.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_3__register_map_location_bundle.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_4__add_map_location_to_seutumaisa_view.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_4__add_map_location_to_seutumaisa_view.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_4__add_map_location_to_seutumaisa_view.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_4__add_map_location_to_seutumaisa_view.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_5__add_backgroundlayerselectionplugin_to_mapfull.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_5__add_backgroundlayerselectionplugin_to_mapfull.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_5__add_backgroundlayerselectionplugin_to_mapfull.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_5__add_backgroundlayerselectionplugin_to_mapfull.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_6__mappfull_add_selected_layers.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_6__mappfull_add_selected_layers.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_6__mappfull_add_selected_layers.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_6__mappfull_add_selected_layers.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_7__update_userguide_configuration.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_7__update_userguide_configuration.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_7__update_userguide_configuration.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_7__update_userguide_configuration.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_03_9__add_layers.java b/hsy-resources/src/main/resources/seutumaisa/V1_03_9__add_layers.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_03_9__add_layers.java rename to hsy-resources/src/main/resources/seutumaisa/V1_03_9__add_layers.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_04_00__register_seutumaisa_history_search_bundle_and_add_it_to_views.java b/hsy-resources/src/main/resources/seutumaisa/V1_04_00__register_seutumaisa_history_search_bundle_and_add_it_to_views.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_04_00__register_seutumaisa_history_search_bundle_and_add_it_to_views.java rename to hsy-resources/src/main/resources/seutumaisa/V1_04_00__register_seutumaisa_history_search_bundle_and_add_it_to_views.java diff --git a/hsy-resources/src/main/java/flyway/seutumaisa/V1_04_01__update_logoplugin_config.java b/hsy-resources/src/main/resources/seutumaisa/V1_04_01__update_logoplugin_config.java similarity index 100% rename from hsy-resources/src/main/java/flyway/seutumaisa/V1_04_01__update_logoplugin_config.java rename to hsy-resources/src/main/resources/seutumaisa/V1_04_01__update_logoplugin_config.java From 5a63c80e7003d6ea03284ad5b669b258fbfe381c Mon Sep 17 00:00:00 2001 From: jampukka Date: Tue, 20 Dec 2022 12:09:32 +0200 Subject: [PATCH 17/26] Add typeHandler --- .../src/main/java/hsy/pipe/TagPipeConfigurationMapper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationMapper.java b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationMapper.java index b0bfda4..53b99d9 100644 --- a/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationMapper.java +++ b/server-extension/src/main/java/hsy/pipe/TagPipeConfigurationMapper.java @@ -13,6 +13,8 @@ import org.apache.ibatis.type.JdbcType; import org.json.JSONObject; +import fi.nls.oskari.mybatis.JSONObjectMybatisTypeHandler; + public interface TagPipeConfigurationMapper { @Results(id = "TagPipeResult", value = { @@ -29,7 +31,7 @@ public interface TagPipeConfigurationMapper { @Result(property="tagBarrageHeight", column="tag_barrage_height"), @Result(property="tagGroundHeight", column="tag_ground_height"), @Result(property="tagOtherIssue", column="tag_other_issue"), - @Result(property="tagGeoJson", column="tag_geojson", jdbcType = JdbcType.VARCHAR, javaType = JSONObject.class), + @Result(property="tagGeoJson", column="tag_geojson", jdbcType = JdbcType.VARCHAR, javaType = JSONObject.class, typeHandler = JSONObjectMybatisTypeHandler.class), @Result(property="tagMunicipality", column="tag_municipality"), @Result(property="tagNeighborhood", column="tag_neighborhood"), @Result(property="tagBlock", column="tag_block"), From 6813190fbffb06a38f4826b9908ced4f1dae5d7b Mon Sep 17 00:00:00 2001 From: jampukka Date: Tue, 20 Dec 2022 15:31:44 +0200 Subject: [PATCH 18/26] Use layerlist instead of hierarchical-layerlist bundle --- ...e_hierarchical_layerlist_to_layerlist.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 hsy-resources/src/main/java/flyway/hsy/V1_03_0__change_hierarchical_layerlist_to_layerlist.java diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_03_0__change_hierarchical_layerlist_to_layerlist.java b/hsy-resources/src/main/java/flyway/hsy/V1_03_0__change_hierarchical_layerlist_to_layerlist.java new file mode 100644 index 0000000..e234978 --- /dev/null +++ b/hsy-resources/src/main/java/flyway/hsy/V1_03_0__change_hierarchical_layerlist_to_layerlist.java @@ -0,0 +1,46 @@ +package flyway.hsy; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.oskari.helpers.AppSetupHelper; +import org.oskari.helpers.BundleHelper; + +import fi.nls.oskari.domain.map.view.Bundle; + +public class V1_03_0__change_hierarchical_layerlist_to_layerlist extends BaseJavaMigration { + + public void migrate(Context context) throws Exception { + String bundleToAdd = "layerlist"; + String bundleToRemove = "hierarchical-layerlist"; + + Connection c = context.getConnection(); + + List appsetupIds = AppSetupHelper.getSetupsForUserAndDefaultType(c); + + BundleHelper.registerBundle(c, bundleToAdd); + for (long appsetupId : appsetupIds) { + swapBundle(c, appsetupId, bundleToAdd, bundleToRemove); + } + BundleHelper.unregisterBundle(c, bundleToRemove); + } + + private void swapBundle(Connection c, long appsetupId, String bundleToAdd, String bundleToRemove) throws SQLException { + Bundle bundle = AppSetupHelper.getAppBundle(c, appsetupId, bundleToRemove); + if (bundle == null) { + return; + } + + final int seqno = bundle.getSeqNo(); + AppSetupHelper.removeBundleFromApp(c, appsetupId, bundleToRemove); + + AppSetupHelper.addBundleToApp(c, appsetupId, bundleToAdd); + Bundle added = AppSetupHelper.getAppBundle(c, appsetupId, bundleToAdd); + added.setSeqNo(seqno); + AppSetupHelper.updateAppBundle(c, appsetupId, added); + } + +} From 161ce121f368ad477d124a4dccdf7d04fcb0c45d Mon Sep 17 00:00:00 2001 From: jampukka Date: Tue, 20 Dec 2022 21:03:10 +0200 Subject: [PATCH 19/26] Update null and empty options to empty json object to fix bug with frontend --- .../hsy/V1_03_1__update_null_and_non_empty_layer_options.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 hsy-resources/src/main/resources/flyway/hsy/V1_03_1__update_null_and_non_empty_layer_options.sql diff --git a/hsy-resources/src/main/resources/flyway/hsy/V1_03_1__update_null_and_non_empty_layer_options.sql b/hsy-resources/src/main/resources/flyway/hsy/V1_03_1__update_null_and_non_empty_layer_options.sql new file mode 100644 index 0000000..632da7c --- /dev/null +++ b/hsy-resources/src/main/resources/flyway/hsy/V1_03_1__update_null_and_non_empty_layer_options.sql @@ -0,0 +1,3 @@ +UPDATE oskari_maplayer +SET options = '{}' +WHERE options IS NULL OR options = ''; From 7f5428b31e6179d45e07b76dac680b606787ec4e Mon Sep 17 00:00:00 2001 From: jampukka Date: Wed, 21 Dec 2022 09:31:40 +0200 Subject: [PATCH 20/26] Add +axis=neu to EPSG:3879 projectionDef to all appsetups --- ...mapfull_projectiondefs_gk25_axisorder.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 hsy-resources/src/main/java/flyway/hsy/V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.java diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.java b/hsy-resources/src/main/java/flyway/hsy/V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.java new file mode 100644 index 0000000..db44565 --- /dev/null +++ b/hsy-resources/src/main/java/flyway/hsy/V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.java @@ -0,0 +1,70 @@ +package flyway.hsy; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.json.JSONException; +import org.json.JSONObject; +import org.oskari.helpers.AppSetupHelper; + +import fi.nls.oskari.domain.map.view.Bundle; +import fi.nls.oskari.log.LogFactory; +import fi.nls.oskari.log.Logger; + +public class V1_03_2__update_mapfull_projectiondefs_gk25_axisorder extends BaseJavaMigration { + + private static final Logger LOG = LogFactory.getLogger(V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.class); + + public void migrate(Context context) throws Exception { + Connection c = context.getConnection(); + List allAppsetupIds = AppSetupHelper.getSetupsForType(c); + for (long appsetupId : allAppsetupIds) { + setGK25ProjDefAxisOrder(c, appsetupId); + } + } + + private void setGK25ProjDefAxisOrder(Connection c, long appsetupId) + throws SQLException, JSONException { + Bundle mapfull = AppSetupHelper.getAppBundle(c, appsetupId, "mapfull"); + if (mapfull == null) { + LOG.debug("Skipping appsetup " + appsetupId + + " no mapfull bundle"); + return; + } + + JSONObject config = mapfull.getConfigJSON(); + if (config == null) { + LOG.debug("Skipping appsetup " + appsetupId + + " mapfull config is null"); + return; + } + + JSONObject projectionDefs = config.optJSONObject("projectionDefs"); + if (projectionDefs == null) { + LOG.debug("Skipping appsetup " + appsetupId + + " mapfull config does not contain value for key 'projectionDefs'"); + return; + } + + String projDef = projectionDefs.optString("EPSG:3879"); + if (projDef == null) { + LOG.debug("Skipping appsetup " + appsetupId + + " mapfull config projectionDefs does not contain value for key 'EPSG:3879'"); + return; + } + + if (projDef.contains("+axis=neu")) { + LOG.debug("Skipping appsetup " + appsetupId + + " +axis=neu already present in EPSG:3897 projDef"); + return; + } + + projectionDefs.put("EPSG:3879", projDef + " +axis=neu"); + AppSetupHelper.updateAppBundle(c, appsetupId, mapfull); + LOG.info("Updated " + appsetupId + " mapfull config to: " + config.toString()); + } + +} From 6c859d7740d2feeba96d9a60a8a572e3da0236dd Mon Sep 17 00:00:00 2001 From: jampukka Date: Fri, 28 Apr 2023 15:26:10 +0300 Subject: [PATCH 21/26] Fix logging --- .../V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hsy-resources/src/main/java/flyway/hsy/V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.java b/hsy-resources/src/main/java/flyway/hsy/V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.java index db44565..f02cf87 100644 --- a/hsy-resources/src/main/java/flyway/hsy/V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.java +++ b/hsy-resources/src/main/java/flyway/hsy/V1_03_2__update_mapfull_projectiondefs_gk25_axisorder.java @@ -64,7 +64,7 @@ private void setGK25ProjDefAxisOrder(Connection c, long appsetupId) projectionDefs.put("EPSG:3879", projDef + " +axis=neu"); AppSetupHelper.updateAppBundle(c, appsetupId, mapfull); - LOG.info("Updated " + appsetupId + " mapfull config to: " + config.toString()); + LOG.info("Updated " + appsetupId + " mapfull config to: " + mapfull.getConfig()); } } From 5dd678eb559f58d7d61e4bdae56e45cd70100ddb Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 29 May 2023 14:51:36 +0300 Subject: [PATCH 22/26] Change property to inspect to determine if seutumassa should be enabled or not --- .../hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java index 3801a7b..dde9836 100755 --- a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java +++ b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java @@ -6,13 +6,11 @@ import fi.nls.oskari.util.PropertyUtil; public class SeutumaisaRestActionHandler extends RestActionHandler { - private final static String PROPERTY_MODULES = "db.additional.modules"; + private final static String PROPERTY_ENABLED = "seutumassa.enabled"; public void requireSeutumaisaConfigured() throws ActionException { - String modules = PropertyUtil.get(PROPERTY_MODULES, ""); - if(!modules.contains("seutumaisa")) { + if (!PropertyUtil.getOptional(PROPERTY_ENABLED, false)) { throw new ActionDeniedException("Not seutumaisa configured"); } - } } From a15136898906742da4fa439bdffae4cc4dd9a4a6 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 29 May 2023 14:52:11 +0300 Subject: [PATCH 23/26] Remove System.out.println --- .../java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java index b3f3ead..5ea8118 100644 --- a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java +++ b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java @@ -20,9 +20,6 @@ public void handlePost(ActionParameters params) throws ActionException { requireSeutumaisaConfigured(); try { - System.out.println("=======================PARAMS============================="); - System.out.println(params); - System.out.println("===================================================="); JSONObject result = SeutumaisaHistoryDBHelper.search(params); ResponseHelper.writeResponse(params, result); } catch (JSONException e) { From ff7fe41a3488f49f58424ec1dfba48631e5d0582 Mon Sep 17 00:00:00 2001 From: jampukka Date: Mon, 29 May 2023 14:55:29 +0300 Subject: [PATCH 24/26] Use common preProcess function instead of calling it directly from each child class --- .../actions/GetSeutumaisaHistorySearchFieldsHandler.java | 2 -- .../seutumaisa/actions/GetSeutumaisaSearchFieldsHandler.java | 2 -- .../java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java | 2 -- .../hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java | 3 ++- .../src/main/java/hsy/seutumaisa/actions/SeutumaisaSearch.java | 2 -- 5 files changed, 2 insertions(+), 9 deletions(-) diff --git a/server-extension/src/main/java/hsy/seutumaisa/actions/GetSeutumaisaHistorySearchFieldsHandler.java b/server-extension/src/main/java/hsy/seutumaisa/actions/GetSeutumaisaHistorySearchFieldsHandler.java index a598447..ec54be4 100644 --- a/server-extension/src/main/java/hsy/seutumaisa/actions/GetSeutumaisaHistorySearchFieldsHandler.java +++ b/server-extension/src/main/java/hsy/seutumaisa/actions/GetSeutumaisaHistorySearchFieldsHandler.java @@ -18,8 +18,6 @@ public class GetSeutumaisaHistorySearchFieldsHandler extends SeutumaisaRestActio @Override public void handleGet(ActionParameters params) throws ActionException { - requireSeutumaisaConfigured(); - try { JSONArray fields = SeutumaisaHistoryDBHelper.getHistorySearchFields(); ResponseHelper.writeResponse(params, fields); diff --git a/server-extension/src/main/java/hsy/seutumaisa/actions/GetSeutumaisaSearchFieldsHandler.java b/server-extension/src/main/java/hsy/seutumaisa/actions/GetSeutumaisaSearchFieldsHandler.java index b888199..6b3480a 100755 --- a/server-extension/src/main/java/hsy/seutumaisa/actions/GetSeutumaisaSearchFieldsHandler.java +++ b/server-extension/src/main/java/hsy/seutumaisa/actions/GetSeutumaisaSearchFieldsHandler.java @@ -17,8 +17,6 @@ public class GetSeutumaisaSearchFieldsHandler extends SeutumaisaRestActionHandle @Override public void handleGet(ActionParameters params) throws ActionException { - requireSeutumaisaConfigured(); - try { JSONArray fields = SeutumaisaDBHelper.getSearchFields(); ResponseHelper.writeResponse(params, fields); diff --git a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java index 5ea8118..ff1b5c7 100644 --- a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java +++ b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaHistorySearch.java @@ -17,8 +17,6 @@ public class SeutumaisaHistorySearch extends SeutumaisaRestActionHandler { @Override public void handlePost(ActionParameters params) throws ActionException { - requireSeutumaisaConfigured(); - try { JSONObject result = SeutumaisaHistoryDBHelper.search(params); ResponseHelper.writeResponse(params, result); diff --git a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java index dde9836..46fd6b7 100755 --- a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java +++ b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaRestActionHandler.java @@ -2,13 +2,14 @@ import fi.nls.oskari.control.ActionDeniedException; import fi.nls.oskari.control.ActionException; +import fi.nls.oskari.control.ActionParameters; import fi.nls.oskari.control.RestActionHandler; import fi.nls.oskari.util.PropertyUtil; public class SeutumaisaRestActionHandler extends RestActionHandler { private final static String PROPERTY_ENABLED = "seutumassa.enabled"; - public void requireSeutumaisaConfigured() throws ActionException { + public void preProcess(ActionParameters params) throws ActionException { if (!PropertyUtil.getOptional(PROPERTY_ENABLED, false)) { throw new ActionDeniedException("Not seutumaisa configured"); } diff --git a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaSearch.java b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaSearch.java index 1374981..dc723e0 100755 --- a/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaSearch.java +++ b/server-extension/src/main/java/hsy/seutumaisa/actions/SeutumaisaSearch.java @@ -16,8 +16,6 @@ public class SeutumaisaSearch extends SeutumaisaRestActionHandler { @Override public void handlePost(ActionParameters params) throws ActionException { - requireSeutumaisaConfigured(); - try { JSONObject result = SeutumaisaDBHelper.search(params); ResponseHelper.writeResponse(params, result); From e11da9934610d9dab54e77b3221218a588588a8e Mon Sep 17 00:00:00 2001 From: jampukka Date: Fri, 4 Aug 2023 03:37:12 +0300 Subject: [PATCH 25/26] Bump oskari version to 2.9.0-1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 60e0050..5fc329b 100755 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ HSY applications - 2.9.0 + 2.9.0-1 UTF-8 1.8 From 201c9e1385f131e123fac23d81d4b1f13c3a68d3 Mon Sep 17 00:00:00 2001 From: jampukka Date: Thu, 31 Aug 2023 21:23:03 +0300 Subject: [PATCH 26/26] Version 1.6.0 --- hsy-resources/pom.xml | 2 +- pom.xml | 2 +- server-extension/pom.xml | 2 +- webapp-map/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hsy-resources/pom.xml b/hsy-resources/pom.xml index 9121356..8eb475f 100644 --- a/hsy-resources/pom.xml +++ b/hsy-resources/pom.xml @@ -6,7 +6,7 @@ fi.hsy.oskari hsy-parent - 1.6.0-SNAPSHOT + 1.6.0 hsy-resources jar diff --git a/pom.xml b/pom.xml index 5fc329b..725c9d6 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 fi.hsy.oskari hsy-parent - 1.6.0-SNAPSHOT + 1.6.0 pom HSY applications diff --git a/server-extension/pom.xml b/server-extension/pom.xml index 9dbdb21..726ca68 100755 --- a/server-extension/pom.xml +++ b/server-extension/pom.xml @@ -3,7 +3,7 @@ fi.hsy.oskari hsy-parent - 1.6.0-SNAPSHOT + 1.6.0 server-extension diff --git a/webapp-map/pom.xml b/webapp-map/pom.xml index e77b31b..50e2fa2 100755 --- a/webapp-map/pom.xml +++ b/webapp-map/pom.xml @@ -5,7 +5,7 @@ hsy-parent fi.hsy.oskari - 1.6.0-SNAPSHOT + 1.6.0 4.0.0