summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorralph isenmann2021-02-17 12:08:47 +0100
committerralph isenmann2021-02-17 12:08:47 +0100
commitcf3455de563edf0b73e3debf1a30e4c12094f8a3 (patch)
tree5cf36778ae36547ecab6200a96c0c1ce60bc9cb9
parent[client] Refactoring: Remove unused code (diff)
downloadtutor-module-cf3455de563edf0b73e3debf1a30e4c12094f8a3.tar.gz
tutor-module-cf3455de563edf0b73e3debf1a30e4c12094f8a3.tar.xz
tutor-module-cf3455de563edf0b73e3debf1a30e4c12094f8a3.zip
[client] Fix "download image"
Some line delets not present after merge
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java31
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java33
2 files changed, 18 insertions, 46 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
index 96c4d1f6..ab3db38b 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
@@ -450,37 +450,6 @@ public class ThriftActions {
return;
ImageWrapper.unpack(virtualizerId, tmpDiskFile, imageName, destDir, osId,
fTransInf.getMachineDescription());
- DiskImage diskImage = null;
- String ext = virtualizerId;
- try {
- diskImage = new DiskImage(tmpDiskFile);
- } catch (IOException | UnknownImageFormatException e) {
- LOGGER.warn("Could not open downloaded image for analyze step", e);
- }
- if (diskImage != null) {
- if (diskImage.format != null) {
- ext = diskImage.format.extension;
- }
- if (diskImage.isCompressed) {
- Gui.asyncMessageBox(
- I18n.THRIFT.getString("ThriftActions.Message.warning.diskImageCompressed",
- imageName, Branding.getServiceFAQWebsite()),
- MessageType.WARNING, null, null);
- }
- }
- File destImage = new File(destDir.getAbsolutePath(), VmWrapper.generateFilename(
- imageName, ext));
- destImage.delete();
- if (!tmpDiskFile.renameTo(destImage)) {
- destImage = tmpDiskFile; // Must be Windows...
- }
- try {
- VmWrapper.wrapVm(destImage, imageName, fTransInf.getMachineDescription(),
- virtualizerId, osId, diskImage);
- } catch (MetaDataMissingException | IOException e) {
- Gui.asyncMessageBox(I18n.THRIFT.getString("ThriftActions.Message.warning.couldNotWrapVM"),
- MessageType.WARNING, LOGGER, e);
- }
}
});
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java
index c86ddfa9..05ba40bd 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java
@@ -1,9 +1,9 @@
package org.openslx.dozmod.util;
import org.apache.log4j.Logger;
-
import org.openslx.dozmod.Branding;
import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.model.ContainerDefinition;
import org.openslx.thrifthelper.TConst;
@@ -13,14 +13,22 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+/**
+ * This Class handle the unpacking of Images downloaded from
+ * the server individually (VM-Images, Docker-Images (Container Images)).
+ *
+ * In case of Container-Images the Image-Blob is not important because it can be recreated with the
+ * recipe (e.g. dockerfile).
+ * TODO Do not download the Image-Blob of a Container-Image.
+ */
public class ImageWrapper {
private static final Logger LOGGER = Logger.getLogger(ImageWrapper.class);
/**
* @param virtualizerId string constant defined in @link org.openslx.thrifthelper.TConst
- * @param tmpDiskFile dont no!
- * @param imageName The name of that image in the list.
+ * @param tmpDiskFile dont no! Maybe the part file
+ * @param imageName The name of the image in the list.
* @param destDir Destination directory on the local host.
* @param osId Operating system identifier of the selected image.
* @param virtualizerConfig raw byte array of virtualizerconfig in imageversion table. Only the Image knows
@@ -31,7 +39,6 @@ public class ImageWrapper {
// after the whole image is downloaded and persisted as a .part file,
// this will be executed to unpack it.
- // TODO Move into new Class (implements TransferEventListener)
DiskImage diskImage = null;
String ext = virtualizerId;
@@ -46,10 +53,9 @@ public class ImageWrapper {
try {
// delete image file, unused in container Context.
Files.delete(tmpDiskFile.toPath());
-
} catch (IOException e) {
- Gui.asyncMessageBox("Konnte temporäre Download Datei nicht löschen", MessageType.WARNING, LOGGER,
- e);
+ Gui.asyncMessageBox("Konnte temporäre Download Datei nicht löschen", MessageType.WARNING,
+ LOGGER, e);
}
} else {
@@ -64,13 +70,11 @@ public class ImageWrapper {
ext = diskImage.format.extension;
}
if (diskImage.isCompressed) {
- String msg = "<html>Die heruntergeladene VM '" + imageName + "' ist ein komprimiertes "
- + "Abbild.<br>Sie müssen das Abbild dekomprimieren, bevor Sie es verändern "
- + "können.<br> Die VM wird lokal voraussichtlich nicht startfähig sein!"
- + "<br><br>Bitte lesen Sie die Hinweise unter " + "<a href=\""
- + Branding.getServiceFAQWebsite() + "\">" + "VMDK Disk Types</a>";
- Gui.asyncMessageBox(msg, MessageType.WARNING, null, null);
+ Gui.asyncMessageBox(
+ I18n.THRIFT.getString("ThriftActions.Message.warning.diskImageCompressed",
+ imageName, Branding.getServiceFAQWebsite()), MessageType.WARNING, null,
+ null);
}
}
File destImage = new File(destDir.getAbsolutePath(), VmWrapper.generateFilename(imageName, ext));
@@ -84,8 +88,7 @@ public class ImageWrapper {
VmWrapper.wrapVm(destImage, imageName, virtualizerConfig, virtualizerId, osId, diskImage);
} catch (VmWrapper.MetaDataMissingException | IOException e) {
- Gui.asyncMessageBox("Zur heruntergeladenen VM konnte keine vmx-Datei angelegt werden."
- + "\nSie können versuchen, das Abbild manuell in den VMWare-Player zu importieren.",
+ Gui.asyncMessageBox(I18n.THRIFT.getString("ThriftActions.Message.warning.couldNotWrapVM"),
MessageType.WARNING, LOGGER, e);
}
}