summaryrefslogtreecommitdiffstats
path: root/dozentenmodul
diff options
context:
space:
mode:
authorralph isenmann2022-01-24 17:09:41 +0100
committerralph isenmann2022-01-24 17:09:41 +0100
commit474e572587290ead1c26c2f17eb7d98f157daf0c (patch)
treeb807d32c2d665699ab96122a77641286b3fce856 /dozentenmodul
parent[CLIENT] data container can not be used as images for lectures (diff)
downloadtutor-module-474e572587290ead1c26c2f17eb7d98f157daf0c.tar.gz
tutor-module-474e572587290ead1c26c2f17eb7d98f157daf0c.tar.xz
tutor-module-474e572587290ead1c26c2f17eb7d98f157daf0c.zip
[CLIENT] fix nullpointer for images which does not have an latest imageVersionId
Diffstat (limited to 'dozentenmodul')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java1
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java19
2 files changed, 12 insertions, 8 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java
index 389e4005..d0f562b6 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java
@@ -76,6 +76,7 @@ public class ContainerUploadPage extends ContainerUploadPageLayout {
containerDefinition = ContainerUtils.getContainerDefinition(
Session.getSatelliteToken(),
+ imageDetailsRead.getImageName(),
imageDetailsRead.getLatestVersionId());
lblImageName.setEnabled(existingImage == null);
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
index d6836c8d..5f0dd887 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
@@ -62,7 +62,7 @@ public class ContainerUtils {
public static boolean isDataContainer(ImageSummaryRead image) {
- ContainerDefinition containerDefinition = getContainerDefinition(Session.getSatelliteToken(), image.getLatestVersionId());
+ ContainerDefinition containerDefinition = getContainerDefinition(Session.getSatelliteToken(), image.getImageName(), image.getLatestVersionId());
if (containerDefinition.getContainerMeta().getImageType() == ContainerMeta.ContainerImageType.DATA) {
return true;
}
@@ -75,10 +75,9 @@ public class ContainerUtils {
List<ImageSummaryRead> dataContainerImages = new ArrayList<>();
for (ImageSummaryRead image : images) {
if (image.getVirtId().equals(TConst.VIRT_DOCKER)) {
-
- ContainerDefinition containerDefinition = getContainerDefinition(satelliteToken, image.getLatestVersionId());
- if (containerDefinition.getContainerMeta().getImageType() == ContainerMeta.ContainerImageType.DATA)
- dataContainerImages.add(image);
+ ContainerDefinition containerDefinition = getContainerDefinition(satelliteToken, image.getImageName(), image.getLatestVersionId());
+ if (containerDefinition != null && containerDefinition.getContainerMeta().getImageType() == ContainerMeta.ContainerImageType.DATA)
+ dataContainerImages.add(image);
}
}
return dataContainerImages;
@@ -89,15 +88,19 @@ public class ContainerUtils {
MessageType.WARNING, logger, null);
}
- public static ContainerDefinition getContainerDefinition(String satelliteToken, String latestVersionId) {
+ public static ContainerDefinition getContainerDefinition(String satelliteToken, String imageName, String latestVersionId) {
byte[] rawVirtConfig = null;
+ if (latestVersionId == null) {
+ LOGGER.warn(String.format("LatestVersionID is null, cannot retrieve virtualizer config for image '%s'",imageName));
+ return null;
+ }
try {
ByteBuffer byteBuffer = ThriftManager.getSatClient().getImageVersionVirtConfig(satelliteToken,
latestVersionId);
rawVirtConfig = ThriftUtil.unwrapByteBuffer(byteBuffer);
} catch (TException e) {
- LOGGER.error("Failed to retrieve virtualizer config for image version " + "'" + latestVersionId
- + ", see trace: ", e);
+ LOGGER.error(String.format(" Failed to retrieve virtualizer config for image '%s' with image version '%s', see trace:",
+ imageName, latestVersionId), e);
return null;
}
return ContainerDefinition.fromByteArray(rawVirtConfig);