@Test void migrate() { final Map<String, String> config = ws .read(Map.class, "post", "/configurationtype/migrate/amRiYy1jb21wb25lbnQjamRiYyNkYXRhc2V0I2pkYmM/-2", "{}"); assertEquals("true", config.get("configuration.migrated")); assertEquals("1", config.get("configuration.size")); }
@Override public Map<String, String> migrate(final String id, final int version, final Map<String, String> config) { if (virtualComponents.isExtensionEntity(id)) { return config; } final Config configuration = ofNullable(configurations.findById(id)) .orElseThrow(() -> new WebApplicationException(Response .status(Response.Status.NOT_FOUND) .entity(new ErrorPayload(ErrorDictionary.CONFIGURATION_MISSING, "Didn't find configuration " + id)) .build())); final Map<String, String> configToMigrate = new HashMap<>(config); final String versionKey = configuration.getMeta().getPath() + ".__version"; final boolean addedVersion = configToMigrate.putIfAbsent(versionKey, Integer.toString(version)) == null; final Map<String, String> migrated = configuration.getMigrationHandler().migrate(version, configToMigrate); if (addedVersion) { migrated.remove(versionKey); } return migrated; }
ConfigurationTypeResourceImpl implements ConfigurationTypeResource { @Override public Map<String, String> migrate(final String id, final int version, final Map<String, String> config) { if (virtualComponents.isExtensionEntity(id)) { return config; } final Config configuration = ofNullable(configurations.findById(id)) .orElseThrow(() -> new WebApplicationException(Response .status(Response.Status.NOT_FOUND) .entity(new ErrorPayload(ErrorDictionary.CONFIGURATION_MISSING, "Didn't find configuration " + id)) .build())); final Map<String, String> configToMigrate = new HashMap<>(config); final String versionKey = configuration.getMeta().getPath() + ".__version"; final boolean addedVersion = configToMigrate.putIfAbsent(versionKey, Integer.toString(version)) == null; final Map<String, String> migrated = configuration.getMigrationHandler().migrate(version, configToMigrate); if (addedVersion) { migrated.remove(versionKey); } return migrated; } }
ConfigurationTypeResourceImpl implements ConfigurationTypeResource { @Override public Map<String, String> migrate(final String id, final int version, final Map<String, String> config) { if (virtualComponents.isExtensionEntity(id)) { return config; } final Config configuration = ofNullable(configurations.findById(id)) .orElseThrow(() -> new WebApplicationException(Response .status(Response.Status.NOT_FOUND) .entity(new ErrorPayload(ErrorDictionary.CONFIGURATION_MISSING, "Didn't find configuration " + id)) .build())); final Map<String, String> configToMigrate = new HashMap<>(config); final String versionKey = configuration.getMeta().getPath() + ".__version"; final boolean addedVersion = configToMigrate.putIfAbsent(versionKey, Integer.toString(version)) == null; final Map<String, String> migrated = configuration.getMigrationHandler().migrate(version, configToMigrate); if (addedVersion) { migrated.remove(versionKey); } return migrated; }  }
ConfigurationTypeResourceImpl implements ConfigurationTypeResource { @Override public Map<String, String> migrate(final String id, final int version, final Map<String, String> config) { if (virtualComponents.isExtensionEntity(id)) { return config; } final Config configuration = ofNullable(configurations.findById(id)) .orElseThrow(() -> new WebApplicationException(Response .status(Response.Status.NOT_FOUND) .entity(new ErrorPayload(ErrorDictionary.CONFIGURATION_MISSING, "Didn't find configuration " + id)) .build())); final Map<String, String> configToMigrate = new HashMap<>(config); final String versionKey = configuration.getMeta().getPath() + ".__version"; final boolean addedVersion = configToMigrate.putIfAbsent(versionKey, Integer.toString(version)) == null; final Map<String, String> migrated = configuration.getMigrationHandler().migrate(version, configToMigrate); if (addedVersion) { migrated.remove(versionKey); } return migrated; }  void clearCache(@Observes final DeployedComponent deployedComponent); @Override ConfigTypeNodes getRepositoryModel(final String language, final boolean lightPayload, final String query); @Override ConfigTypeNodes getDetail(final String language, final String[] ids); @Override Map<String, String> migrate(final String id, final int version, final Map<String, String> config); }
ConfigurationTypeResourceImpl implements ConfigurationTypeResource { @Override public Map<String, String> migrate(final String id, final int version, final Map<String, String> config) { if (virtualComponents.isExtensionEntity(id)) { return config; } final Config configuration = ofNullable(configurations.findById(id)) .orElseThrow(() -> new WebApplicationException(Response .status(Response.Status.NOT_FOUND) .entity(new ErrorPayload(ErrorDictionary.CONFIGURATION_MISSING, "Didn't find configuration " + id)) .build())); final Map<String, String> configToMigrate = new HashMap<>(config); final String versionKey = configuration.getMeta().getPath() + ".__version"; final boolean addedVersion = configToMigrate.putIfAbsent(versionKey, Integer.toString(version)) == null; final Map<String, String> migrated = configuration.getMigrationHandler().migrate(version, configToMigrate); if (addedVersion) { migrated.remove(versionKey); } return migrated; }  void clearCache(@Observes final DeployedComponent deployedComponent); @Override ConfigTypeNodes getRepositoryModel(final String language, final boolean lightPayload, final String query); @Override ConfigTypeNodes getDetail(final String language, final String[] ids); @Override Map<String, String> migrate(final String id, final int version, final Map<String, String> config);  }