diff options
author | Steffen Ritter | 2023-05-17 16:17:06 +0200 |
---|---|---|
committer | Steffen Ritter | 2023-05-17 16:17:06 +0200 |
commit | 0b44ca979ec559c2bc7edc21608f78902014c896 (patch) | |
tree | 6fcb0da0010b5c2e45d2549789acdda6f1284b4a | |
parent | [server] Fix javadoc (diff) | |
download | tutor-module-0b44ca979ec559c2bc7edc21608f78902014c896.tar.gz tutor-module-0b44ca979ec559c2bc7edc21608f78902014c896.tar.xz tutor-module-0b44ca979ec559c2bc7edc21608f78902014c896.zip |
[docker] Fix nullpointer on invalid containers
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java | 77 |
1 files changed, 46 insertions, 31 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java index 0bea8587..266351cf 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java @@ -115,40 +115,43 @@ public class ContainerPanel extends JPanel { image.getLatestVersionId()); rawVirtConfig = ThriftUtil.unwrapByteBuffer(byteBuffer); containerDefinition = ContainerDefinition.fromByteArray(rawVirtConfig); - } catch (TException e) { - LOGGER.error("Failed to retrieve virtualizer config for image version " + "'" + image.getLatestVersionId() - + ", see trace: ", e); - } - txtContainerImageName.setText(image.imageName); - txtContainerImageName.setEnabled(false); - // TODO simplify this mess. ContainerBuildContextMethod is to complex or useless - switch (containerDefinition.getContainerImageContext()) { - case DOCKERFILE: - txtContainerRecipe.setText(containerDefinition.getContainerRecipe()); - break; - case IMAGE_REPOSITORY: - txtContainerRecipe.setText(containerDefinition.getContainerMeta().getImageRepo()); - break; - case GIT_REPOSITORY: - txtContainerRecipe.setText(containerDefinition.getContainerMeta().getBuildContextUrl()); - break; - case DOCKER_ARCHIVE: - txtContainerRecipe.setText(containerDefinition.getContainerMeta().getImageName()); - break; - default: - LOGGER.error("Unknown Build Context"); - break; - } + txtContainerImageName.setText(image.imageName); + txtContainerImageName.setEnabled(false); + // TODO simplify this mess. ContainerBuildContextMethod is to complex or useless + switch (containerDefinition.getContainerImageContext()) { + case DOCKERFILE: + txtContainerRecipe.setText(containerDefinition.getContainerRecipe()); + break; + case IMAGE_REPOSITORY: + txtContainerRecipe.setText(containerDefinition.getContainerMeta().getImageRepo()); + break; + case GIT_REPOSITORY: + txtContainerRecipe.setText(containerDefinition.getContainerMeta().getBuildContextUrl()); + break; + case DOCKER_ARCHIVE: + txtContainerRecipe.setText(containerDefinition.getContainerMeta().getImageName()); + break; + default: + LOGGER.error("Unknown Build Context"); + break; + } - cboContainerImageType.setSelectedItem(containerDefinition.getContainerMeta().getImageType()); + cboContainerImageType.setSelectedItem(containerDefinition.getContainerMeta().getImageType()); - if (context.equals(IMAGE_CONTEXT)) { - initImageDetails(); - } else if (context.equals(CONTAINER_CONTEXT)) { - initContainerDetails(); - } else { - LOGGER.error("Container Panel init failed: Please use proper context"); + if (context.equals(IMAGE_CONTEXT)) { + initImageDetails(); + } else if (context.equals(CONTAINER_CONTEXT)) { + initContainerDetails(); + } else { + LOGGER.error("Container Panel init failed: Please use proper context"); + } + + + } catch (TException e) { + LOGGER.error("Failed to retrieve virtualizer config for image version " + "'" + image.getLatestVersionId() + + ", see trace: ", e); + disableAll(); } } @@ -253,4 +256,16 @@ public class ContainerPanel extends JPanel { cbo.setSelectedItem(ContainerMeta.ContainerImageType.LECTURE); return cbo; } + + public void disableAll() { + + for (Component component : pnlContainerMeta.getComponents()) { + component.setEnabled(false); + } + + txtContainerRecipe.setEnabled(false); + pnlContainerMeta.setEnabled(false); + cboContainerImageType.setEnabled(false); + txtContainerImageName.setEnabled(false); + } } |