From fec0e34577c5f2eb752c34d413c927cc40728c5f Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Wed, 7 Aug 2019 16:58:11 +0300 Subject: [PATCH 01/18] Change pref type to object --- .../model/workspace/devfile/Component.java | 2 +- .../shared/dto/devfile/ComponentDto.java | 6 +-- .../PluginComponentToWorkspaceApplier.java | 19 ++++---- .../model/impl/devfile/ComponentImpl.java | 10 ++-- .../model/impl/devfile/ObjectConverter.java | 46 +++++++++++++++++++ .../src/main/resources/schema/devfile.json | 6 ++- ...PluginComponentToWorkspaceApplierTest.java | 12 ++--- .../server/jpa/JpaWorkspaceDaoTest.java | 1 + .../server/jpa/WorkspaceTckModule.java | 2 + .../server/spi/tck/WorkspaceDaoTest.java | 3 +- ...le_plugin_components_with_preferences.yaml | 1 + 11 files changed, 82 insertions(+), 26 deletions(-) create mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ObjectConverter.java diff --git a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Component.java b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Component.java index 26ac5d2011d..4a7073cc8a9 100644 --- a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Component.java +++ b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Component.java @@ -32,7 +32,7 @@ public interface Component { * Returns the preferences of the plugin. Example value of preference: {@code java.home: * /home/user/jdk11} */ - Map getPreferences(); + Map getPreferences(); /** * For 'kubernetes' and 'openshift' components types, returns absolute or devfile-relative diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/ComponentDto.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/ComponentDto.java index 982ce99e50f..321a8365c35 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/ComponentDto.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/ComponentDto.java @@ -49,11 +49,11 @@ public interface ComponentDto extends Component { ComponentDto withRegistryUrl(String registryUrl); @Override - Map getPreferences(); + Map getPreferences(); - void setPreferences(Map preferences); + void setPreferences(Map preferences); - ComponentDto withPreferences(Map preferences); + ComponentDto withPreferences(Map preferences); @Override String getReference(); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplier.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplier.java index 90dd805d484..39ac41401ff 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplier.java @@ -18,11 +18,9 @@ import static org.eclipse.che.api.workspace.server.devfile.Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE; import static org.eclipse.che.api.workspace.server.devfile.Constants.PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE; import static org.eclipse.che.api.workspace.server.devfile.Constants.PLUGIN_COMPONENT_TYPE; -import static org.eclipse.che.api.workspace.shared.Constants.PLUGIN_PREFERENCE_ATTR_TEMPLATE; import static org.eclipse.che.api.workspace.shared.Constants.SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE; import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE; -import java.util.Map.Entry; import javax.inject.Inject; import org.eclipse.che.api.core.model.workspace.devfile.Component; import org.eclipse.che.api.workspace.server.devfile.FileContentProvider; @@ -99,14 +97,15 @@ public void apply( .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, fqn.getPublisherAndName()), memoryLimit); } - for (Entry preference : pluginComponent.getPreferences().entrySet()) { - workspaceConfig - .getAttributes() - .put( - format( - PLUGIN_PREFERENCE_ATTR_TEMPLATE, fqn.getPublisherAndName(), preference.getKey()), - preference.getValue()); - } + // for (Entry preference : pluginComponent.getPreferences().entrySet()) { + // workspaceConfig + // .getAttributes() + // .put( + // format( + // PLUGIN_PREFERENCE_ATTR_TEMPLATE, fqn.getPublisherAndName(), + // preference.getKey()), + // preference.getValue()); + // } for (CommandImpl command : workspaceConfig.getCommands()) { String commandComponent = command.getAttributes().get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java index 9129cca8070..cf0efc02377 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java @@ -21,6 +21,7 @@ import javax.persistence.CascadeType; import javax.persistence.CollectionTable; import javax.persistence.Column; +import javax.persistence.Convert; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -54,8 +55,9 @@ public class ComponentImpl implements Component { name = "devfile_component_preferences", joinColumns = @JoinColumn(name = "devfile_component_id")) @MapKeyColumn(name = "preference_key") + @Convert(converter = ObjectConverter.class) @Column(name = "preference") - private Map preferences; + private Map preferences; @Column(name = "alias") private String alias; @@ -190,7 +192,7 @@ public ComponentImpl( String type, String alias, String id, - Map preferences, + Map preferences, String registryUrl, String reference, String referenceContent, @@ -294,14 +296,14 @@ public void setRegistryUrl(String registryUrl) { this.registryUrl = registryUrl; } - public Map getPreferences() { + public Map getPreferences() { if (preferences == null) { preferences = new HashMap<>(); } return preferences; } - public void setPreferences(Map preferences) { + public void setPreferences(Map preferences) { this.preferences = preferences; } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ObjectConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ObjectConverter.java new file mode 100644 index 00000000000..cec20ac73e1 --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ObjectConverter.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.workspace.server.model.impl.devfile; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import javax.persistence.AttributeConverter; +import javax.persistence.Converter; + +@Converter(autoApply = true) +public class ObjectConverter implements AttributeConverter { + + ObjectMapper mapper = new ObjectMapper(); + + @Override + public String convertToDatabaseColumn(Object attribute) { + try { + return mapper.writeValueAsString(attribute); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return null; + } + + @Override + public Object convertToEntityAttribute(String dbData) { + if (Boolean.TRUE.toString().equals(dbData) || Boolean.FALSE.toString().equals(dbData)) { + return Boolean.getBoolean(dbData); + } else { + try { + return Integer.parseInt(dbData); + } catch (NumberFormatException e) { + return dbData; + } + } + } +} diff --git a/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json b/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json index b8d160180fc..1b27b65dd7a 100644 --- a/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json +++ b/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json @@ -279,7 +279,11 @@ "{\"java.home\": \"/home/user/jdk11\", \"java.jdt.ls.vmargs\": \"-Xmx1G\"}" ], "additionalProperties": { - "type": "string" + "type": [ + "boolean", + "string", + "integer" + ] } } } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java index 543a9c11d34..87893ef3acf 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java @@ -16,7 +16,6 @@ import static org.eclipse.che.api.workspace.server.devfile.Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE; import static org.eclipse.che.api.workspace.server.devfile.Constants.PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE; import static org.eclipse.che.api.workspace.server.devfile.Constants.PLUGIN_COMPONENT_TYPE; -import static org.eclipse.che.api.workspace.shared.Constants.PLUGIN_PREFERENCE_ATTR_TEMPLATE; import static org.eclipse.che.api.workspace.shared.Constants.SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE; import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE; import static org.mockito.ArgumentMatchers.anyString; @@ -92,11 +91,12 @@ public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApply .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, "eclipse/super-plugin")), "1234M"); - assertEquals( - workspaceConfig - .getAttributes() - .get(format(PLUGIN_PREFERENCE_ATTR_TEMPLATE, "eclipse/super-plugin", "java-home")), - "/home/user/jdk11"); + // assertEquals( + // workspaceConfig + // .getAttributes() + // .get(format(PLUGIN_PREFERENCE_ATTR_TEMPLATE, "eclipse/super-plugin", + // "java-home")), + // "/home/user/jdk11"); } @Test diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java index efce708d9d9..5d45fa31d86 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java @@ -132,6 +132,7 @@ public void shouldSynchronizeWorkspaceNameWithDevfileNameWhenDevfileIsUpdated() // make conflict update workspace2.getDevfile().setName(workspace1.getDevfile().getName()); + workspace2.getDevfile().setName(workspace1.getDevfile().getName()); manager.getTransaction().begin(); manager.merge(workspace2); manager.getTransaction().commit(); diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java index ad3e1224c50..ef6b4a7b39c 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java @@ -30,6 +30,7 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; +import org.eclipse.che.api.workspace.server.model.impl.devfile.ObjectConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; @@ -85,6 +86,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") + .addEntityClass(ObjectConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(DBInitializer.class).asEagerSingleton(); diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java index df2a0cdd8f3..b792e75e0d1 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java @@ -927,7 +927,8 @@ private static DevfileImpl createDevfile(String name) { "kubernetes", "component2", "eclipse/che-theia/0.0.1", - ImmutableMap.of("java.home", "/home/user/jdk11"), + ImmutableMap.of( + "java.home", "/home/user/jdk11", "java.boolean", true, "java.integer", 123444), "https://mysite.com/registry/somepath2", "/dev.yaml", "refcontent2", diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_components_with_preferences.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_components_with_preferences.yaml index a43b91b2140..2d666a015d4 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_components_with_preferences.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_components_with_preferences.yaml @@ -19,3 +19,4 @@ components: preferences: java.home: '/home/user/jdk11' java.jdt.ls.vmargs: '-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication' + java.jtg.memory: 12345 From a5f917d70fe94919f8888a569bb84fd35086ccf3 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Fri, 9 Aug 2019 10:34:54 +0300 Subject: [PATCH 02/18] Added converter --- .../src/main/resources/META-INF/persistence.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml b/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml index 13b42273784..1861d5fc019 100644 --- a/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml +++ b/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml @@ -58,6 +58,7 @@ org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl + org.eclipse.che.api.workspace.server.model.impl.devfile.ObjectConverter org.eclipse.che.api.ssh.server.model.impl.SshPairImpl From 51072a5b521a72c9e417ea325796bb0b27e8b74f Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Mon, 12 Aug 2019 14:04:26 +0300 Subject: [PATCH 03/18] Store preferences as serializable --- .../main/resources/META-INF/persistence.xml | 2 +- .../model/workspace/devfile/Component.java | 3 +- .../shared/dto/devfile/ComponentDto.java | 7 +-- .../model/impl/devfile/ComponentImpl.java | 13 ++++-- .../model/impl/devfile/ObjectConverter.java | 46 ------------------- .../server/jpa/WorkspaceTckModule.java | 2 +- .../src/test/resources/devfile/devfile.yaml | 5 ++ .../1__change_preferences_type.sql | 15 ++++++ .../postgresql/1__change_preferences_type.sql | 15 ++++++ .../che/core/db/jpa/CascadeRemovalTest.java | 2 + .../src/test/java/MySqlTckModule.java | 2 + .../src/test/java/PostgreSqlTckModule.java | 2 + 12 files changed, 58 insertions(+), 56 deletions(-) delete mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ObjectConverter.java create mode 100644 wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql create mode 100644 wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql diff --git a/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml b/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml index 1861d5fc019..8363c008582 100644 --- a/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml +++ b/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml @@ -58,7 +58,7 @@ org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl - org.eclipse.che.api.workspace.server.model.impl.devfile.ObjectConverter + org.eclipse.che.api.workspace.server.devfile.ObjectConverter org.eclipse.che.api.ssh.server.model.impl.SshPairImpl diff --git a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Component.java b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Component.java index 4a7073cc8a9..14e80416746 100644 --- a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Component.java +++ b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Component.java @@ -11,6 +11,7 @@ */ package org.eclipse.che.api.core.model.workspace.devfile; +import java.io.Serializable; import java.util.List; import java.util.Map; @@ -32,7 +33,7 @@ public interface Component { * Returns the preferences of the plugin. Example value of preference: {@code java.home: * /home/user/jdk11} */ - Map getPreferences(); + Map getPreferences(); /** * For 'kubernetes' and 'openshift' components types, returns absolute or devfile-relative diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/ComponentDto.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/ComponentDto.java index 321a8365c35..91c38e64f8c 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/ComponentDto.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/ComponentDto.java @@ -11,6 +11,7 @@ */ package org.eclipse.che.api.workspace.shared.dto.devfile; +import java.io.Serializable; import java.util.List; import java.util.Map; import org.eclipse.che.api.core.model.workspace.devfile.Component; @@ -49,11 +50,11 @@ public interface ComponentDto extends Component { ComponentDto withRegistryUrl(String registryUrl); @Override - Map getPreferences(); + Map getPreferences(); - void setPreferences(Map preferences); + void setPreferences(Map preferences); - ComponentDto withPreferences(Map preferences); + ComponentDto withPreferences(Map preferences); @Override String getReference(); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java index cf0efc02377..b80f280659d 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java @@ -13,6 +13,8 @@ import static java.util.stream.Collectors.toCollection; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -36,6 +38,8 @@ import org.eclipse.che.api.core.model.workspace.devfile.Entrypoint; import org.eclipse.che.api.core.model.workspace.devfile.Env; import org.eclipse.che.api.core.model.workspace.devfile.Volume; +import org.eclipse.che.api.workspace.server.devfile.ObjectConverter; +import org.eclipse.che.api.workspace.server.devfile.PreferencesDeserializer; /** @author Sergii Leshchenko */ @Entity(name = "DevfileComponent") @@ -57,7 +61,8 @@ public class ComponentImpl implements Component { @MapKeyColumn(name = "preference_key") @Convert(converter = ObjectConverter.class) @Column(name = "preference") - private Map preferences; + @JsonDeserialize(using = PreferencesDeserializer.class) + private Map preferences; @Column(name = "alias") private String alias; @@ -192,7 +197,7 @@ public ComponentImpl( String type, String alias, String id, - Map preferences, + Map preferences, String registryUrl, String reference, String referenceContent, @@ -296,14 +301,14 @@ public void setRegistryUrl(String registryUrl) { this.registryUrl = registryUrl; } - public Map getPreferences() { + public Map getPreferences() { if (preferences == null) { preferences = new HashMap<>(); } return preferences; } - public void setPreferences(Map preferences) { + public void setPreferences(Map preferences) { this.preferences = preferences; } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ObjectConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ObjectConverter.java deleted file mode 100644 index cec20ac73e1..00000000000 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ObjectConverter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.che.api.workspace.server.model.impl.devfile; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; - -@Converter(autoApply = true) -public class ObjectConverter implements AttributeConverter { - - ObjectMapper mapper = new ObjectMapper(); - - @Override - public String convertToDatabaseColumn(Object attribute) { - try { - return mapper.writeValueAsString(attribute); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - return null; - } - - @Override - public Object convertToEntityAttribute(String dbData) { - if (Boolean.TRUE.toString().equals(dbData) || Boolean.FALSE.toString().equals(dbData)) { - return Boolean.getBoolean(dbData); - } else { - try { - return Integer.parseInt(dbData); - } catch (NumberFormatException e) { - return dbData; - } - } - } -} diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java index ef6b4a7b39c..90c4eaeea4b 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java @@ -30,7 +30,7 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; -import org.eclipse.che.api.workspace.server.model.impl.devfile.ObjectConverter; +import org.eclipse.che.api.workspace.server.devfile.ObjectConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/devfile.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/devfile.yaml index 5b773c141e1..2ce3868e2ff 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/devfile.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/devfile.yaml @@ -28,6 +28,11 @@ components: - alias: jdt.ls type: chePlugin id: org.eclipse.chetheia-jdtls:0.0.3 + preferences: + java.home: '/home/user/jdk11' + java.jdt.ls.vmargs: '-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication' + java.jtg.memory: 12345 + java.boolean: true - type: openshift reference: petclinic.yaml selector: diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql new file mode 100644 index 00000000000..d610364b7f8 --- /dev/null +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql @@ -0,0 +1,15 @@ +-- +-- Copyright (c) 2012-2019 Red Hat, Inc. +-- This program and the accompanying materials are made +-- available under the terms of the Eclipse Public License 2.0 +-- which is available at https://www.eclipse.org/legal/epl-2.0/ +-- +-- SPDX-License-Identifier: EPL-2.0 +-- +-- Contributors: +-- Red Hat, Inc. - initial API and implementation +-- + +-- component preferences + +ALTER TABLE devfile_component_preferences MODIFY COLUMN preference BLOB; \ No newline at end of file diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql new file mode 100644 index 00000000000..989ec9bc845 --- /dev/null +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql @@ -0,0 +1,15 @@ +-- +-- Copyright (c) 2012-2019 Red Hat, Inc. +-- This program and the accompanying materials are made +-- available under the terms of the Eclipse Public License 2.0 +-- which is available at https://www.eclipse.org/legal/epl-2.0/ +-- +-- SPDX-License-Identifier: EPL-2.0 +-- +-- Contributors: +-- Red Hat, Inc. - initial API and implementation +-- + +-- component preferences + +ALTER TABLE devfile_component_preferences ALTER COLUMN preference TYPE bytea USING preference::bytea; \ No newline at end of file diff --git a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java index cc592085d94..5edf39c8b09 100644 --- a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java +++ b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java @@ -92,6 +92,7 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; +import org.eclipse.che.api.workspace.server.devfile.ObjectConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; @@ -217,6 +218,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") + .addEntityClass(ObjectConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(EventService.class).in(Singleton.class); diff --git a/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java b/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java index d5c41c6455a..79c90657609 100644 --- a/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java +++ b/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java @@ -62,6 +62,7 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; +import org.eclipse.che.api.workspace.server.model.impl.devfile.ObjectConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; @@ -164,6 +165,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") + .addEntityClass(ObjectConverter.class) .build()); bind(TckResourcesCleaner.class).to(JpaCleaner.class); diff --git a/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java b/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java index 1ee0425c090..6f60ab81ba0 100644 --- a/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java +++ b/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java @@ -62,6 +62,7 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; +import org.eclipse.che.api.workspace.server.model.impl.devfile.ObjectConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; @@ -159,6 +160,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") + .addEntityClass(ObjectConverter.class) .build()); bind(TckResourcesCleaner.class).to(JpaCleaner.class); From c64972c804126f7eb12a5c1ba8a0bb2168483456 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Mon, 12 Aug 2019 14:04:38 +0300 Subject: [PATCH 04/18] Store preferences as serializable --- .../server/devfile/ObjectConverter.java | 48 +++++++++++++++++ .../devfile/PreferencesDeserializer.java | 54 +++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java create mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java new file mode 100644 index 00000000000..a2f9398c05d --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.workspace.server.devfile; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import javax.persistence.AttributeConverter; +import javax.persistence.Converter; + +@Converter(autoApply = true) +public class ObjectConverter implements AttributeConverter { + + @Override + public byte[] convertToDatabaseColumn(Serializable attribute) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { + oos.writeObject(attribute); + } catch (IOException e) { + e.printStackTrace(); + } + return baos.toByteArray(); + } + + @Override + public Serializable convertToEntityAttribute(byte[] dbData) { + try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(dbData))) { + return (Serializable) ois.readObject(); + } catch (IOException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java new file mode 100644 index 00000000000..e3c889188a7 --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.workspace.server.devfile; + +import static java.lang.String.format; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import java.io.IOException; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class PreferencesDeserializer extends JsonDeserializer> { + + @Override + public Map deserialize(JsonParser jsonParser, DeserializationContext ctxt) + throws IOException { + Map result = new HashMap<>(); + jsonParser.nextToken(); + while (!JsonToken.END_OBJECT.equals(jsonParser.getCurrentToken())) { + JsonToken currentToken = jsonParser.nextValue(); + switch (currentToken) { + case VALUE_NUMBER_INT: + result.put(jsonParser.getCurrentName(), jsonParser.getNumberValue()); + break; + case VALUE_FALSE: + case VALUE_TRUE: + result.put(jsonParser.getCurrentName(), jsonParser.getValueAsBoolean()); + break; + case VALUE_STRING: + result.put(jsonParser.getCurrentName(), jsonParser.getValueAsString()); + break; + default: + throw new JsonParseException( + jsonParser, format("Unexpected preference value '%s' ", jsonParser.getCurrentName())); + } + jsonParser.nextToken(); + } + return result; + } +} From e17ecc44bd45eb3fdded8ec3b724ae20f2293bd7 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Mon, 12 Aug 2019 16:05:42 +0300 Subject: [PATCH 05/18] Code fixups --- .../workspace/server/devfile/ObjectConverter.java | 14 ++++++++------ .../server/devfile/PreferencesDeserializer.java | 8 +++++++- .../workspace/server/jpa/WorkspaceTckModule.java | 2 +- .../1__change_preferences_type.sql | 2 +- .../postgresql/1__change_preferences_type.sql | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java index a2f9398c05d..7f2f3cc56c3 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java @@ -20,6 +20,11 @@ import javax.persistence.AttributeConverter; import javax.persistence.Converter; +/** + * Helps to store and read multi-type preferences map of Devfile {@code Component} into database. + * + * @author Max Shaposhnyk + */ @Converter(autoApply = true) public class ObjectConverter implements AttributeConverter { @@ -29,7 +34,7 @@ public byte[] convertToDatabaseColumn(Serializable attribute) { try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { oos.writeObject(attribute); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException("Unable to store preferences: " + e.getMessage(), e); } return baos.toByteArray(); } @@ -38,11 +43,8 @@ public byte[] convertToDatabaseColumn(Serializable attribute) { public Serializable convertToEntityAttribute(byte[] dbData) { try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(dbData))) { return (Serializable) ois.readObject(); - } catch (IOException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException("Unable to read preferences: " + e.getMessage(), e); } - return null; } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java index e3c889188a7..8fc7e87f1e2 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java @@ -23,6 +23,11 @@ import java.util.HashMap; import java.util.Map; +/** + * Helps to deserialize multi-type preferences map of Devfile {@code Component}. + * + * @author Max Shaposhnyk + */ public class PreferencesDeserializer extends JsonDeserializer> { @Override @@ -45,7 +50,8 @@ public Map deserialize(JsonParser jsonParser, Deserializat break; default: throw new JsonParseException( - jsonParser, format("Unexpected preference value '%s' ", jsonParser.getCurrentName())); + jsonParser, + format("Unexpected value of the preference '%s' ", jsonParser.getCurrentName())); } jsonParser.nextToken(); } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java index 90c4eaeea4b..065a8770f58 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java @@ -14,6 +14,7 @@ import com.google.inject.TypeLiteral; import java.util.Collection; import org.eclipse.che.account.spi.AccountImpl; +import org.eclipse.che.api.workspace.server.devfile.ObjectConverter; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; import org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl; @@ -30,7 +31,6 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; -import org.eclipse.che.api.workspace.server.devfile.ObjectConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql index d610364b7f8..e734cba724b 100644 --- a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql @@ -12,4 +12,4 @@ -- component preferences -ALTER TABLE devfile_component_preferences MODIFY COLUMN preference BLOB; \ No newline at end of file +ALTER TABLE devfile_component_preferences MODIFY COLUMN preference BLOB; diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql index 989ec9bc845..7e9069cc3fa 100644 --- a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql @@ -12,4 +12,4 @@ -- component preferences -ALTER TABLE devfile_component_preferences ALTER COLUMN preference TYPE bytea USING preference::bytea; \ No newline at end of file +ALTER TABLE devfile_component_preferences ALTER COLUMN preference TYPE bytea USING preference::bytea; From d053fd56615900f54a2b992ccd91b7557f9bcd78 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Mon, 12 Aug 2019 17:35:22 +0300 Subject: [PATCH 06/18] Code refactorings --- .../main/resources/META-INF/persistence.xml | 2 +- .../server/devfile/ObjectConverter.java | 50 ------------------- .../devfile/PreferencesDeserializer.java | 2 +- .../model/impl/devfile/ComponentImpl.java | 4 +- .../server/jpa/WorkspaceTckModule.java | 4 +- .../che/core/db/jpa/CascadeRemovalTest.java | 4 +- 6 files changed, 8 insertions(+), 58 deletions(-) delete mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java diff --git a/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml b/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml index 8363c008582..8da2bca06f0 100644 --- a/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml +++ b/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml @@ -58,7 +58,7 @@ org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl - org.eclipse.che.api.workspace.server.devfile.ObjectConverter + org.eclipse.che.api.workspace.server.devfile.PreferenceValuesConverter org.eclipse.che.api.ssh.server.model.impl.SshPairImpl diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java deleted file mode 100644 index 7f2f3cc56c3..00000000000 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/ObjectConverter.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.che.api.workspace.server.devfile; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; - -/** - * Helps to store and read multi-type preferences map of Devfile {@code Component} into database. - * - * @author Max Shaposhnyk - */ -@Converter(autoApply = true) -public class ObjectConverter implements AttributeConverter { - - @Override - public byte[] convertToDatabaseColumn(Serializable attribute) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { - oos.writeObject(attribute); - } catch (IOException e) { - throw new RuntimeException("Unable to store preferences: " + e.getMessage(), e); - } - return baos.toByteArray(); - } - - @Override - public Serializable convertToEntityAttribute(byte[] dbData) { - try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(dbData))) { - return (Serializable) ois.readObject(); - } catch (IOException | ClassNotFoundException e) { - throw new RuntimeException("Unable to read preferences: " + e.getMessage(), e); - } - } -} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java index 8fc7e87f1e2..a391f941968 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java @@ -24,7 +24,7 @@ import java.util.Map; /** - * Helps to deserialize multi-type preferences map of Devfile {@code Component}. + * Helps to deserialize multi-type preferences into {@code Component} as a {@code Map}. * * @author Max Shaposhnyk */ diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java index b80f280659d..dce7d5d3fdf 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java @@ -38,7 +38,7 @@ import org.eclipse.che.api.core.model.workspace.devfile.Entrypoint; import org.eclipse.che.api.core.model.workspace.devfile.Env; import org.eclipse.che.api.core.model.workspace.devfile.Volume; -import org.eclipse.che.api.workspace.server.devfile.ObjectConverter; +import org.eclipse.che.api.workspace.server.devfile.PreferenceValuesConverter; import org.eclipse.che.api.workspace.server.devfile.PreferencesDeserializer; /** @author Sergii Leshchenko */ @@ -59,7 +59,7 @@ public class ComponentImpl implements Component { name = "devfile_component_preferences", joinColumns = @JoinColumn(name = "devfile_component_id")) @MapKeyColumn(name = "preference_key") - @Convert(converter = ObjectConverter.class) + @Convert(converter = PreferenceValuesConverter.class) @Column(name = "preference") @JsonDeserialize(using = PreferencesDeserializer.class) private Map preferences; diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java index 065a8770f58..ef36f620905 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java @@ -14,7 +14,7 @@ import com.google.inject.TypeLiteral; import java.util.Collection; import org.eclipse.che.account.spi.AccountImpl; -import org.eclipse.che.api.workspace.server.devfile.ObjectConverter; +import org.eclipse.che.api.workspace.server.devfile.PreferenceValuesConverter; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; import org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl; @@ -86,7 +86,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(ObjectConverter.class) + .addEntityClass(PreferenceValuesConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(DBInitializer.class).asEagerSingleton(); diff --git a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java index 5edf39c8b09..3b07b629528 100644 --- a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java +++ b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java @@ -92,7 +92,7 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; -import org.eclipse.che.api.workspace.server.devfile.ObjectConverter; +import org.eclipse.che.api.workspace.server.devfile.PreferenceValuesConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; @@ -218,7 +218,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(ObjectConverter.class) + .addEntityClass(PreferenceValuesConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(EventService.class).in(Singleton.class); From 4124a39f297b4291eecfe2da793ae66849e84464 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Mon, 12 Aug 2019 17:42:16 +0300 Subject: [PATCH 07/18] Code refactorings --- .../main/resources/META-INF/persistence.xml | 2 +- .../server/devfile/SerializableConverter.java | 51 +++++++++++++++++++ .../model/impl/devfile/ComponentImpl.java | 4 +- .../server/jpa/WorkspaceTckModule.java | 4 +- .../che/core/db/jpa/CascadeRemovalTest.java | 4 +- 5 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java diff --git a/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml b/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml index 8da2bca06f0..3326c511d48 100644 --- a/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml +++ b/assembly/assembly-wsmaster-war/src/main/resources/META-INF/persistence.xml @@ -58,7 +58,7 @@ org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl - org.eclipse.che.api.workspace.server.devfile.PreferenceValuesConverter + org.eclipse.che.api.workspace.server.devfile.SerializableConverter org.eclipse.che.api.ssh.server.model.impl.SshPairImpl diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java new file mode 100644 index 00000000000..e381ffbb009 --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.workspace.server.devfile; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import javax.persistence.AttributeConverter; +import javax.persistence.Converter; + +/** + * Helps to store and read serializable values of the preferences map in {@code Component} to/from + * database. + * + * @author Max Shaposhnyk + */ +@Converter(autoApply = true) +public class SerializableConverter implements AttributeConverter { + + @Override + public byte[] convertToDatabaseColumn(Serializable value) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { + oos.writeObject(value); + } catch (IOException e) { + throw new RuntimeException("Unable to store preference value: " + e.getMessage(), e); + } + return baos.toByteArray(); + } + + @Override + public Serializable convertToEntityAttribute(byte[] dbData) { + try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(dbData))) { + return (Serializable) ois.readObject(); + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException("Unable to read preferences value: " + e.getMessage(), e); + } + } +} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java index dce7d5d3fdf..7325b7f3f44 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java @@ -38,7 +38,7 @@ import org.eclipse.che.api.core.model.workspace.devfile.Entrypoint; import org.eclipse.che.api.core.model.workspace.devfile.Env; import org.eclipse.che.api.core.model.workspace.devfile.Volume; -import org.eclipse.che.api.workspace.server.devfile.PreferenceValuesConverter; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.devfile.PreferencesDeserializer; /** @author Sergii Leshchenko */ @@ -59,7 +59,7 @@ public class ComponentImpl implements Component { name = "devfile_component_preferences", joinColumns = @JoinColumn(name = "devfile_component_id")) @MapKeyColumn(name = "preference_key") - @Convert(converter = PreferenceValuesConverter.class) + @Convert(converter = SerializableConverter.class) @Column(name = "preference") @JsonDeserialize(using = PreferencesDeserializer.class) private Map preferences; diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java index ef36f620905..83705a3a959 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java @@ -14,7 +14,7 @@ import com.google.inject.TypeLiteral; import java.util.Collection; import org.eclipse.che.account.spi.AccountImpl; -import org.eclipse.che.api.workspace.server.devfile.PreferenceValuesConverter; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; import org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl; @@ -86,7 +86,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(PreferenceValuesConverter.class) + .addEntityClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(DBInitializer.class).asEagerSingleton(); diff --git a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java index 3b07b629528..afcf4768d01 100644 --- a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java +++ b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java @@ -92,7 +92,7 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; -import org.eclipse.che.api.workspace.server.devfile.PreferenceValuesConverter; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; @@ -218,7 +218,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(PreferenceValuesConverter.class) + .addEntityClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(EventService.class).in(Singleton.class); From 9ce061bc47eca7ddab4f7b3cadc3be1670bdd301 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Tue, 13 Aug 2019 10:39:00 +0300 Subject: [PATCH 08/18] Code fixups --- .../plugin/PluginComponentToWorkspaceApplier.java | 10 ---------- .../server/model/impl/devfile/ComponentImpl.java | 2 +- .../plugin/PluginComponentToWorkspaceApplierTest.java | 7 ------- .../api/workspace/server/jpa/JpaWorkspaceDaoTest.java | 1 - 4 files changed, 1 insertion(+), 19 deletions(-) diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplier.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplier.java index 39ac41401ff..3843815af86 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplier.java @@ -97,16 +97,6 @@ public void apply( .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, fqn.getPublisherAndName()), memoryLimit); } - // for (Entry preference : pluginComponent.getPreferences().entrySet()) { - // workspaceConfig - // .getAttributes() - // .put( - // format( - // PLUGIN_PREFERENCE_ATTR_TEMPLATE, fqn.getPublisherAndName(), - // preference.getKey()), - // preference.getValue()); - // } - for (CommandImpl command : workspaceConfig.getCommands()) { String commandComponent = command.getAttributes().get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java index 7325b7f3f44..e8af39b02aa 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/ComponentImpl.java @@ -38,8 +38,8 @@ import org.eclipse.che.api.core.model.workspace.devfile.Entrypoint; import org.eclipse.che.api.core.model.workspace.devfile.Env; import org.eclipse.che.api.core.model.workspace.devfile.Volume; -import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.devfile.PreferencesDeserializer; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; /** @author Sergii Leshchenko */ @Entity(name = "DevfileComponent") diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java index 87893ef3acf..0ecd6f4514e 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java @@ -90,13 +90,6 @@ public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApply .getAttributes() .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, "eclipse/super-plugin")), "1234M"); - - // assertEquals( - // workspaceConfig - // .getAttributes() - // .get(format(PLUGIN_PREFERENCE_ATTR_TEMPLATE, "eclipse/super-plugin", - // "java-home")), - // "/home/user/jdk11"); } @Test diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java index 5d45fa31d86..efce708d9d9 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java @@ -132,7 +132,6 @@ public void shouldSynchronizeWorkspaceNameWithDevfileNameWhenDevfileIsUpdated() // make conflict update workspace2.getDevfile().setName(workspace1.getDevfile().getName()); - workspace2.getDevfile().setName(workspace1.getDevfile().getName()); manager.getTransaction().begin(); manager.merge(workspace2); manager.getTransaction().commit(); From 4657360d26f71798f7b5ec523390d4361c962993 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Wed, 14 Aug 2019 16:23:57 +0300 Subject: [PATCH 09/18] Revert to json serialization --- .../server/devfile/SerializableConverter.java | 40 +++++++++++-------- .../server/spi/tck/WorkspaceDaoTest.java | 7 +++- .../1__change_preferences_type.sql | 4 +- .../postgresql/1__change_preferences_type.sql | 4 +- .../che/core/db/jpa/CascadeRemovalTest.java | 2 +- .../src/test/java/MySqlTckModule.java | 4 +- .../src/test/java/PostgreSqlTckModule.java | 4 +- 7 files changed, 40 insertions(+), 25 deletions(-) diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java index e381ffbb009..a3b0859f70e 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java @@ -11,11 +11,9 @@ */ package org.eclipse.che.api.workspace.server.devfile; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.Serializable; import javax.persistence.AttributeConverter; import javax.persistence.Converter; @@ -27,25 +25,33 @@ * @author Max Shaposhnyk */ @Converter(autoApply = true) -public class SerializableConverter implements AttributeConverter { +public class SerializableConverter implements AttributeConverter { + + private ObjectMapper objectMapper; + + public SerializableConverter() { + this.objectMapper = new ObjectMapper(); + objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE); + } @Override - public byte[] convertToDatabaseColumn(Serializable value) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { - oos.writeObject(value); - } catch (IOException e) { - throw new RuntimeException("Unable to store preference value: " + e.getMessage(), e); + public String convertToDatabaseColumn(Serializable value) { + try { + return objectMapper.writeValueAsString(value); + } catch (JsonProcessingException e) { + e.printStackTrace(); } - return baos.toByteArray(); + return null; } @Override - public Serializable convertToEntityAttribute(byte[] dbData) { - try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(dbData))) { - return (Serializable) ois.readObject(); - } catch (IOException | ClassNotFoundException e) { - throw new RuntimeException("Unable to read preferences value: " + e.getMessage(), e); + public Serializable convertToEntityAttribute(String dbData) { + System.out.println("~~~~~~~~~~~~~~~~~~~~:" + new String(dbData)); + try { + return objectMapper.readValue(dbData, Serializable.class); + } catch (IOException e) { + e.printStackTrace(); } + return null; } } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java index b792e75e0d1..8b1a6be919a 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java @@ -928,7 +928,12 @@ private static DevfileImpl createDevfile(String name) { "component2", "eclipse/che-theia/0.0.1", ImmutableMap.of( - "java.home", "/home/user/jdk11", "java.boolean", true, "java.integer", 123444), + "java.home", + "/home/user/jdk11aertwertert", + "java.boolean", + true, + "java.integer", + 123444), "https://mysite.com/registry/somepath2", "/dev.yaml", "refcontent2", diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql index e734cba724b..4c99c916303 100644 --- a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql @@ -12,4 +12,6 @@ -- component preferences -ALTER TABLE devfile_component_preferences MODIFY COLUMN preference BLOB; +ALTER TABLE devfile_component_preferences MODIFY COLUMN preference TEXT; + +UPDATE devfile_component_preferences SET preference = CONCAT('"',preference,'"'); diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql index 7e9069cc3fa..3ab77e42576 100644 --- a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql @@ -12,4 +12,6 @@ -- component preferences -ALTER TABLE devfile_component_preferences ALTER COLUMN preference TYPE bytea USING preference::bytea; +ALTER TABLE devfile_component_preferences ALTER COLUMN preference TYPE text; + +UPDATE devfile_component_preferences SET preference = CONCAT('"',preference,'"'); \ No newline at end of file diff --git a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java index afcf4768d01..4c83b968399 100644 --- a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java +++ b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java @@ -71,6 +71,7 @@ import org.eclipse.che.api.workspace.server.WorkspaceManager; import org.eclipse.che.api.workspace.server.WorkspaceRuntimes; import org.eclipse.che.api.workspace.server.WorkspaceSharedPool; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.devfile.convert.DevfileConverter; import org.eclipse.che.api.workspace.server.devfile.validator.ComponentIntegrityValidator; import org.eclipse.che.api.workspace.server.hc.probe.ProbeScheduler; @@ -92,7 +93,6 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; -import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; diff --git a/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java b/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java index 79c90657609..141b3fdce3e 100644 --- a/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java +++ b/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java @@ -44,6 +44,7 @@ import org.eclipse.che.api.workspace.activity.WorkspaceActivity; import org.eclipse.che.api.workspace.activity.WorkspaceActivityDao; import org.eclipse.che.api.workspace.activity.WorkspaceExpiration; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.jpa.JpaStackDao; import org.eclipse.che.api.workspace.server.jpa.JpaWorkspaceDao; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; @@ -62,7 +63,6 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; -import org.eclipse.che.api.workspace.server.model.impl.devfile.ObjectConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; @@ -165,7 +165,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(ObjectConverter.class) + .addEntityClass(SerializableConverter.class) .build()); bind(TckResourcesCleaner.class).to(JpaCleaner.class); diff --git a/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java b/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java index 6f60ab81ba0..df52b921156 100644 --- a/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java +++ b/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java @@ -44,6 +44,7 @@ import org.eclipse.che.api.workspace.activity.WorkspaceActivity; import org.eclipse.che.api.workspace.activity.WorkspaceActivityDao; import org.eclipse.che.api.workspace.activity.WorkspaceExpiration; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.jpa.JpaStackDao; import org.eclipse.che.api.workspace.server.jpa.JpaWorkspaceDao; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; @@ -62,7 +63,6 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; -import org.eclipse.che.api.workspace.server.model.impl.devfile.ObjectConverter; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; @@ -160,7 +160,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(ObjectConverter.class) + .addEntityClass(SerializableConverter.class) .build()); bind(TckResourcesCleaner.class).to(JpaCleaner.class); From bc38ec7276c8797ffc5e0f2c8722271c4e15505f Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Thu, 15 Aug 2019 15:01:54 +0300 Subject: [PATCH 10/18] Code fixes & test --- .../devfile/PreferencesDeserializer.java | 4 +- .../server/devfile/SerializableConverter.java | 7 +- .../devfile/PreferencesDeserializerTest.java | 71 +++++++++++++++++++ .../postgresql/1__change_preferences_type.sql | 2 +- 4 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializerTest.java diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java index a391f941968..7a94c6fea20 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java @@ -51,7 +51,9 @@ public Map deserialize(JsonParser jsonParser, Deserializat default: throw new JsonParseException( jsonParser, - format("Unexpected value of the preference '%s' ", jsonParser.getCurrentName())); + format( + "Unexpected value of the preference with key '%s'.", + jsonParser.getCurrentName())); } jsonParser.nextToken(); } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java index a3b0859f70e..43982b9a93a 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java @@ -39,19 +39,16 @@ public String convertToDatabaseColumn(Serializable value) { try { return objectMapper.writeValueAsString(value); } catch (JsonProcessingException e) { - e.printStackTrace(); + throw new RuntimeException("Unable to serialize preference value:" + e.getMessage(), e); } - return null; } @Override public Serializable convertToEntityAttribute(String dbData) { - System.out.println("~~~~~~~~~~~~~~~~~~~~:" + new String(dbData)); try { return objectMapper.readValue(dbData, Serializable.class); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException("Unable to deserialize preference value:" + e.getMessage(), e); } - return null; } } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializerTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializerTest.java new file mode 100644 index 00000000000..a26f46681e5 --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializerTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.workspace.server.devfile; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import java.io.Serializable; +import java.util.Map; +import org.mockito.Mock; +import org.mockito.testng.MockitoTestNGListener; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; + +@Listeners(MockitoTestNGListener.class) +public class PreferencesDeserializerTest { + + @Mock private DeserializationContext ctxt; + + private final JsonFactory factory = new JsonFactory(); + + /** Instance to test. */ + private PreferencesDeserializer preferencesDeserializer = new PreferencesDeserializer(); + + @Test + public void shouldParseSimpleTypesCorrectly() throws Exception { + String json = + "{" + + "\"valid.string\": \"/usr/bin/value\"," + + "\"valid.boolean\": false," + + "\"valid.numeric\": 777555888" + + "}"; + + final JsonParser parser = factory.createParser(json); + Map result = preferencesDeserializer.deserialize(parser, ctxt); + assertEquals(3, result.size()); + assertTrue(result.containsValue(777555888)); + assertTrue(result.containsValue(false)); + assertTrue(result.containsValue("/usr/bin/value")); + } + + @Test( + expectedExceptions = JsonParseException.class, + expectedExceptionsMessageRegExp = + "Unexpected value of the preference with key 'invalid.object'.\n" + + " at \\[Source: \\(String\\)\"\\{\"valid\\.string\": \"/usr/bin/value\",\"invalid\\.object\": \\{\"someobject\": true\\}\\}\"; line: 1, column: 54\\]") + public void shouldThrowExceptionOnUnsupportedPreferenceValue() throws Exception { + + String json = + "{" + + "\"valid.string\": \"/usr/bin/value\"," + + "\"invalid.object\": {\"someobject\": true}" + + "}"; + + final JsonParser parser = factory.createParser(json); + preferencesDeserializer.deserialize(parser, ctxt); + } +} diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql index 3ab77e42576..9e359646a7e 100644 --- a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql @@ -14,4 +14,4 @@ ALTER TABLE devfile_component_preferences ALTER COLUMN preference TYPE text; -UPDATE devfile_component_preferences SET preference = CONCAT('"',preference,'"'); \ No newline at end of file +UPDATE devfile_component_preferences SET preference = CONCAT('"',preference,'"'); From 662f256074ad9b6d403fd01c084f635b51f077f6 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Thu, 15 Aug 2019 15:23:42 +0300 Subject: [PATCH 11/18] Fixup tests --- .../permission/workspace/server/jpa/WorkspaceTckModule.java | 2 ++ .../permission/workspace/server/spi/jpa/JpaTckModule.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/jpa/WorkspaceTckModule.java b/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/jpa/WorkspaceTckModule.java index 7c2e9044c28..e6e482bba3e 100644 --- a/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/jpa/WorkspaceTckModule.java +++ b/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/jpa/WorkspaceTckModule.java @@ -15,6 +15,7 @@ import java.util.Collection; import org.eclipse.che.account.spi.AccountImpl; import org.eclipse.che.api.user.server.model.impl.UserImpl; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.jpa.JpaStackDao; import org.eclipse.che.api.workspace.server.jpa.JpaWorkspaceDao; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; @@ -100,6 +101,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") + .addEntityClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(DBInitializer.class).asEagerSingleton(); diff --git a/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/spi/jpa/JpaTckModule.java b/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/spi/jpa/JpaTckModule.java index adb8065c46e..387d3bc66b3 100644 --- a/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/spi/jpa/JpaTckModule.java +++ b/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/spi/jpa/JpaTckModule.java @@ -14,6 +14,7 @@ import com.google.inject.TypeLiteral; import org.eclipse.che.account.spi.AccountImpl; import org.eclipse.che.api.user.server.model.impl.UserImpl; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; import org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl; @@ -92,6 +93,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") + .addEntityClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); From dd5b82221be038594448f79ddc5d078bc976d345 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Thu, 15 Aug 2019 15:28:34 +0300 Subject: [PATCH 12/18] review fixups --- .../org/eclipse/che/api/workspace/shared/Constants.java | 7 ------- .../src/main/resources/schema/devfile.json | 6 +++--- .../1__change_devfile_component_preferences_type.sql} | 0 .../1__change_devfile_component_preferences_type.sql} | 0 4 files changed, 3 insertions(+), 10 deletions(-) rename wsmaster/che-core-sql-schema/src/main/resources/che-schema/{7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql => 7.1.0/1__change_devfile_component_preferences_type.sql} (100%) rename wsmaster/che-core-sql-schema/src/main/resources/che-schema/{7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql => 7.1.0/postgresql/1__change_devfile_component_preferences_type.sql} (100%) diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java index db0d669f68e..4c8122b0ba2 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java @@ -127,13 +127,6 @@ public final class Constants { */ public static final String SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE = "sidecar.%s.memory_limit"; - /** - * Template for workspace config attribute key that stores plugin component preference. The first - * %s should be replaced with `pluginPublisher/pluginName` and the second one should be replaced - * with preference name. Example value: `plugin.redhat/java.preference.java.home`. - */ - public static final String PLUGIN_PREFERENCE_ATTR_TEMPLATE = "plugin.%s.preference.%s"; - /** * Describes workspace runtimes which perform start/stop of this workspace. Should be set/read * from {@link Workspace#getAttributes} diff --git a/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json b/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json index 1b27b65dd7a..eeb87588c5a 100644 --- a/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json +++ b/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json @@ -280,9 +280,9 @@ ], "additionalProperties": { "type": [ - "boolean", - "string", - "integer" + "boolean", + "string", + "integer" ] } } diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.1.0/1__change_devfile_component_preferences_type.sql similarity index 100% rename from wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/1__change_preferences_type.sql rename to wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.1.0/1__change_devfile_component_preferences_type.sql diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.1.0/postgresql/1__change_devfile_component_preferences_type.sql similarity index 100% rename from wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC5.0/postgresql/1__change_preferences_type.sql rename to wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.1.0/postgresql/1__change_devfile_component_preferences_type.sql From 3681352894a2429e3424522a09fe3066093cc641 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Thu, 15 Aug 2019 16:16:03 +0300 Subject: [PATCH 13/18] review fixups --- .../src/main/resources/schema/devfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json b/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json index eeb87588c5a..965fb9779c4 100644 --- a/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json +++ b/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json @@ -282,7 +282,7 @@ "type": [ "boolean", "string", - "integer" + "number" ] } } From acd6c9a301239cb1f7a71929d64ecd317fbbb48a Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Thu, 15 Aug 2019 17:02:36 +0300 Subject: [PATCH 14/18] Add entities --- .../infrastructure/kubernetes/cache/jpa/JpaTckModule.java | 2 ++ .../src/test/resources/META-INF/persistence.xml | 1 + .../src/test/resources/META-INF/persistence.xml | 1 + .../src/test/resources/META-INF/persistence.xml | 1 + .../server/signature/jpa/SignatureKeyTckModule.java | 2 ++ .../api/workspace/activity/jpa/WorkspaceActivityTckModule.java | 2 ++ 6 files changed, 9 insertions(+) diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/cache/jpa/JpaTckModule.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/cache/jpa/JpaTckModule.java index a3351d477ad..1d6a5a118f0 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/cache/jpa/JpaTckModule.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/cache/jpa/JpaTckModule.java @@ -13,6 +13,7 @@ import com.google.inject.TypeLiteral; import org.eclipse.che.account.spi.AccountImpl; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; import org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl; @@ -91,6 +92,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") + .addEntityClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); diff --git a/multiuser/integration-tests/che-multiuser-cascade-removal/src/test/resources/META-INF/persistence.xml b/multiuser/integration-tests/che-multiuser-cascade-removal/src/test/resources/META-INF/persistence.xml index a577f7d42a0..9b183cf6c63 100644 --- a/multiuser/integration-tests/che-multiuser-cascade-removal/src/test/resources/META-INF/persistence.xml +++ b/multiuser/integration-tests/che-multiuser-cascade-removal/src/test/resources/META-INF/persistence.xml @@ -43,6 +43,7 @@ org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl + org.eclipse.che.api.workspace.server.devfile.SerializableConverter org.eclipse.che.api.workspace.server.model.impl.CommandImpl org.eclipse.che.workspace.infrastructure.docker.snapshot.MachineSourceImpl diff --git a/multiuser/integration-tests/che-multiuser-mysql-tck/src/test/resources/META-INF/persistence.xml b/multiuser/integration-tests/che-multiuser-mysql-tck/src/test/resources/META-INF/persistence.xml index b3562ad44dd..704d35ff282 100644 --- a/multiuser/integration-tests/che-multiuser-mysql-tck/src/test/resources/META-INF/persistence.xml +++ b/multiuser/integration-tests/che-multiuser-mysql-tck/src/test/resources/META-INF/persistence.xml @@ -43,6 +43,7 @@ org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl + org.eclipse.che.api.workspace.server.devfile.SerializableConverter org.eclipse.che.api.workspace.server.model.impl.CommandImpl org.eclipse.che.workspace.infrastructure.docker.snapshot.MachineSourceImpl diff --git a/multiuser/integration-tests/che-multiuser-postgresql-tck/src/test/resources/META-INF/persistence.xml b/multiuser/integration-tests/che-multiuser-postgresql-tck/src/test/resources/META-INF/persistence.xml index 361c54f0fc9..57a3bf215cf 100644 --- a/multiuser/integration-tests/che-multiuser-postgresql-tck/src/test/resources/META-INF/persistence.xml +++ b/multiuser/integration-tests/che-multiuser-postgresql-tck/src/test/resources/META-INF/persistence.xml @@ -43,6 +43,7 @@ org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl + org.eclipse.che.api.workspace.server.devfile.SerializableConverter org.eclipse.che.api.workspace.server.model.impl.CommandImpl org.eclipse.che.workspace.infrastructure.docker.snapshot.MachineSourceImpl diff --git a/multiuser/machine-auth/che-multiuser-machine-authentication/src/test/java/org/eclipse/che/multiuser/machine/authentication/server/signature/jpa/SignatureKeyTckModule.java b/multiuser/machine-auth/che-multiuser-machine-authentication/src/test/java/org/eclipse/che/multiuser/machine/authentication/server/signature/jpa/SignatureKeyTckModule.java index 1690ba7a813..c3a0f4796ea 100644 --- a/multiuser/machine-auth/che-multiuser-machine-authentication/src/test/java/org/eclipse/che/multiuser/machine/authentication/server/signature/jpa/SignatureKeyTckModule.java +++ b/multiuser/machine-auth/che-multiuser-machine-authentication/src/test/java/org/eclipse/che/multiuser/machine/authentication/server/signature/jpa/SignatureKeyTckModule.java @@ -15,6 +15,7 @@ import java.util.Collection; import org.eclipse.che.account.spi.AccountImpl; import org.eclipse.che.api.user.server.model.impl.UserImpl; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; import org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl; @@ -89,6 +90,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") + .addEntityClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); diff --git a/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/jpa/WorkspaceActivityTckModule.java b/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/jpa/WorkspaceActivityTckModule.java index 710fd3b7f72..6e5a7b2553b 100644 --- a/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/jpa/WorkspaceActivityTckModule.java +++ b/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/jpa/WorkspaceActivityTckModule.java @@ -18,6 +18,7 @@ import org.eclipse.che.api.workspace.activity.JpaWorkspaceActivityDao; import org.eclipse.che.api.workspace.activity.WorkspaceActivity; import org.eclipse.che.api.workspace.activity.WorkspaceActivityDao; +import org.eclipse.che.api.workspace.server.devfile.SerializableConverter; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl; import org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl; @@ -86,6 +87,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") + .addEntityClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(DBInitializer.class).asEagerSingleton(); From 5e2f2ef461daaf75e04da2a8fa921fbe365e37f3 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Fri, 16 Aug 2019 10:28:42 +0300 Subject: [PATCH 15/18] Fix reviews --- .../workspace/server/devfile/PreferencesDeserializer.java | 4 +++- .../api/workspace/server/devfile/SerializableConverter.java | 3 ++- .../server/devfile/PreferencesDeserializerTest.java | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java index 7a94c6fea20..3f314633a5e 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializer.java @@ -22,9 +22,10 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import org.eclipse.che.api.core.model.workspace.devfile.Component; /** - * Helps to deserialize multi-type preferences into {@code Component} as a {@code Map}. + * Helps to deserialize multi-type preferences into {@link Component} as a {@code Map}. * * @author Max Shaposhnyk */ @@ -39,6 +40,7 @@ public Map deserialize(JsonParser jsonParser, Deserializat JsonToken currentToken = jsonParser.nextValue(); switch (currentToken) { case VALUE_NUMBER_INT: + case VALUE_NUMBER_FLOAT: result.put(jsonParser.getCurrentName(), jsonParser.getNumberValue()); break; case VALUE_FALSE: diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java index 43982b9a93a..1cb441de7a6 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/SerializableConverter.java @@ -17,9 +17,10 @@ import java.io.Serializable; import javax.persistence.AttributeConverter; import javax.persistence.Converter; +import org.eclipse.che.api.core.model.workspace.devfile.Component; /** - * Helps to store and read serializable values of the preferences map in {@code Component} to/from + * Helps to store and read serializable values of the preferences map in {@link Component} to/from * database. * * @author Max Shaposhnyk diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializerTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializerTest.java index a26f46681e5..0e6c3eb9f38 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializerTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/PreferencesDeserializerTest.java @@ -41,13 +41,15 @@ public void shouldParseSimpleTypesCorrectly() throws Exception { "{" + "\"valid.string\": \"/usr/bin/value\"," + "\"valid.boolean\": false," - + "\"valid.numeric\": 777555888" + + "\"valid.integer\": 777555888," + + "\"valid.float\": 3.1415926" + "}"; final JsonParser parser = factory.createParser(json); Map result = preferencesDeserializer.deserialize(parser, ctxt); - assertEquals(3, result.size()); + assertEquals(4, result.size()); assertTrue(result.containsValue(777555888)); + assertTrue(result.containsValue(3.1415926)); assertTrue(result.containsValue(false)); assertTrue(result.containsValue("/usr/bin/value")); } From 3e9b4bc0910df383d02a89c476bba09a41437b3c Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Fri, 16 Aug 2019 12:07:19 +0300 Subject: [PATCH 16/18] Add addClass() to the persistmodule builder --- .../che/commons/test/db/PersistTestModuleBuilder.java | 6 ++++++ .../infrastructure/kubernetes/cache/jpa/JpaTckModule.java | 2 +- .../server/signature/jpa/SignatureKeyTckModule.java | 2 +- .../permission/workspace/server/jpa/WorkspaceTckModule.java | 2 +- .../permission/workspace/server/spi/jpa/JpaTckModule.java | 2 +- .../workspace/activity/jpa/WorkspaceActivityTckModule.java | 2 +- .../che/api/workspace/server/jpa/WorkspaceTckModule.java | 2 +- .../org/eclipse/che/core/db/jpa/CascadeRemovalTest.java | 2 +- 8 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/commons/che-core-commons-test/src/main/java/org/eclipse/che/commons/test/db/PersistTestModuleBuilder.java b/core/commons/che-core-commons-test/src/main/java/org/eclipse/che/commons/test/db/PersistTestModuleBuilder.java index cbf685bdc58..cfecf0da26a 100644 --- a/core/commons/che-core-commons-test/src/main/java/org/eclipse/che/commons/test/db/PersistTestModuleBuilder.java +++ b/core/commons/che-core-commons-test/src/main/java/org/eclipse/che/commons/test/db/PersistTestModuleBuilder.java @@ -138,6 +138,12 @@ public PersistTestModuleBuilder addEntityClasses(Class... entityClasses) { return this; } + /** Adds another non-entity class (like attribute converters etc) to entities list. */ + public PersistTestModuleBuilder addClass(Class entityClass) { + entityFqnSet.add(entityClass.getName()); + return this; + } + /** Sets persistence unit custom property. */ public PersistTestModuleBuilder setProperty(String name, String value) { if (name != null && value != null) { diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/cache/jpa/JpaTckModule.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/cache/jpa/JpaTckModule.java index 1d6a5a118f0..ffdb2dc9a80 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/cache/jpa/JpaTckModule.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/cache/jpa/JpaTckModule.java @@ -92,7 +92,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(SerializableConverter.class) + .addClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); diff --git a/multiuser/machine-auth/che-multiuser-machine-authentication/src/test/java/org/eclipse/che/multiuser/machine/authentication/server/signature/jpa/SignatureKeyTckModule.java b/multiuser/machine-auth/che-multiuser-machine-authentication/src/test/java/org/eclipse/che/multiuser/machine/authentication/server/signature/jpa/SignatureKeyTckModule.java index c3a0f4796ea..6948194febd 100644 --- a/multiuser/machine-auth/che-multiuser-machine-authentication/src/test/java/org/eclipse/che/multiuser/machine/authentication/server/signature/jpa/SignatureKeyTckModule.java +++ b/multiuser/machine-auth/che-multiuser-machine-authentication/src/test/java/org/eclipse/che/multiuser/machine/authentication/server/signature/jpa/SignatureKeyTckModule.java @@ -90,7 +90,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(SerializableConverter.class) + .addClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); diff --git a/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/jpa/WorkspaceTckModule.java b/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/jpa/WorkspaceTckModule.java index e6e482bba3e..2c259cf9adc 100644 --- a/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/jpa/WorkspaceTckModule.java +++ b/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/jpa/WorkspaceTckModule.java @@ -101,7 +101,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(SerializableConverter.class) + .addClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(DBInitializer.class).asEagerSingleton(); diff --git a/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/spi/jpa/JpaTckModule.java b/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/spi/jpa/JpaTckModule.java index 387d3bc66b3..a682bdcad6b 100644 --- a/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/spi/jpa/JpaTckModule.java +++ b/multiuser/permission/che-multiuser-permission-workspace/src/test/java/org/eclipse/che/multiuser/permission/workspace/server/spi/jpa/JpaTckModule.java @@ -93,7 +93,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(SerializableConverter.class) + .addClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); diff --git a/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/jpa/WorkspaceActivityTckModule.java b/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/jpa/WorkspaceActivityTckModule.java index 6e5a7b2553b..6c735b54b2f 100644 --- a/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/jpa/WorkspaceActivityTckModule.java +++ b/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/jpa/WorkspaceActivityTckModule.java @@ -87,7 +87,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(SerializableConverter.class) + .addClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(DBInitializer.class).asEagerSingleton(); diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java index 83705a3a959..a69357209ec 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/WorkspaceTckModule.java @@ -86,7 +86,7 @@ protected void configure() { org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(SerializableConverter.class) + .addClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(DBInitializer.class).asEagerSingleton(); diff --git a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java index 4c83b968399..84fd19e791d 100644 --- a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java +++ b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/CascadeRemovalTest.java @@ -218,7 +218,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(SerializableConverter.class) + .addClass(SerializableConverter.class) .setExceptionHandler(H2ExceptionHandler.class) .build()); bind(EventService.class).in(Singleton.class); From 0fdb85bc4adc3d3133321f9203d1ec754fad541e Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Fri, 16 Aug 2019 12:23:34 +0300 Subject: [PATCH 17/18] fixup! Add addClass() to the persistmodule builder --- .../eclipse/che/commons/test/db/PersistTestModuleBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/commons/che-core-commons-test/src/main/java/org/eclipse/che/commons/test/db/PersistTestModuleBuilder.java b/core/commons/che-core-commons-test/src/main/java/org/eclipse/che/commons/test/db/PersistTestModuleBuilder.java index cfecf0da26a..567d984fe2d 100644 --- a/core/commons/che-core-commons-test/src/main/java/org/eclipse/che/commons/test/db/PersistTestModuleBuilder.java +++ b/core/commons/che-core-commons-test/src/main/java/org/eclipse/che/commons/test/db/PersistTestModuleBuilder.java @@ -138,7 +138,7 @@ public PersistTestModuleBuilder addEntityClasses(Class... entityClasses) { return this; } - /** Adds another non-entity class (like attribute converters etc) to entities list. */ + /** Adds another non-entity class (like attribute converters etc) to class list. */ public PersistTestModuleBuilder addClass(Class entityClass) { entityFqnSet.add(entityClass.getName()); return this; From f728780107eca6475153781579e63cc6d1d2d5f1 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Fri, 16 Aug 2019 14:20:10 +0300 Subject: [PATCH 18/18] Fix integration module --- .../mysql-tck/src/test/java/MySqlTckModule.java | 2 +- .../postgresql-tck/src/test/java/PostgreSqlTckModule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java b/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java index 141b3fdce3e..cdb61217aad 100644 --- a/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java +++ b/wsmaster/integration-tests/mysql-tck/src/test/java/MySqlTckModule.java @@ -165,7 +165,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(SerializableConverter.class) + .addClass(SerializableConverter.class) .build()); bind(TckResourcesCleaner.class).to(JpaCleaner.class); diff --git a/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java b/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java index df52b921156..90ab119b7d4 100644 --- a/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java +++ b/wsmaster/integration-tests/postgresql-tck/src/test/java/PostgreSqlTckModule.java @@ -160,7 +160,7 @@ protected void configure() { KubernetesServerImpl.ServerId.class) .addEntityClass( "org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute") - .addEntityClass(SerializableConverter.class) + .addClass(SerializableConverter.class) .build()); bind(TckResourcesCleaner.class).to(JpaCleaner.class);