diff options
author | Stephan Schwär | 2020-11-04 08:11:17 +0100 |
---|---|---|
committer | Stephan Schwär | 2020-11-04 08:11:17 +0100 |
commit | 211fb57e8e06f1d2ac5c19a0828a8e9f58d9c037 (patch) | |
tree | 284d73e210f25df9da338e3ee01effb4decc5edc /dozentenmodul/src/main/java/org/openslx/dozmod/gui | |
parent | [client] Allow conversion of VMware OVA images (diff) | |
download | tutor-module-211fb57e8e06f1d2ac5c19a0828a8e9f58d9c037.tar.gz tutor-module-211fb57e8e06f1d2ac5c19a0828a8e9f58d9c037.tar.xz tutor-module-211fb57e8e06f1d2ac5c19a0828a8e9f58d9c037.zip |
[client] Show notification when trying to convert image created with vbox
Feature: #3771
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java | 29 | ||||
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java | 6 |
2 files changed, 31 insertions, 4 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java index 83966486..9ec6c824 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java @@ -2,9 +2,11 @@ package org.openslx.dozmod.gui.wizard.page; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - +import java.io.BufferedReader; import java.io.File; +import java.io.FileReader; import java.io.IOException; +import java.io.Reader; import java.nio.file.Files; import javax.swing.JFileChooser; @@ -54,7 +56,6 @@ public class ImageOvfConversionPage extends ImageOvfConversionPageLayout { if (!(new File(ovfToolPath).exists())) { ovfToolPath = System.getenv("ProgramFiles(X86)") + "\\VMware\\VMware Player\\OVFTool\\ovftool.exe"; } - } else if (os.toLowerCase().contains("mac")) { ovfToolPath = "/Applications/VMware Fusion.app/Contents/Library/VMware OVF Tool"; } @@ -90,6 +91,23 @@ public class ImageOvfConversionPage extends ImageOvfConversionPageLayout { }); } + // Check wether the OVA or OVF was created by VirtualBox + private boolean isVboxImage(File file) { + try (Reader reader = new FileReader(file); BufferedReader buffered = new BufferedReader(reader)) { + String line; + int lineCount = 0; + while ((line = buffered.readLine()) != null && lineCount < 50) { + if (line.toLowerCase().contains("vbox")) { + LOGGER.debug("Detected OVF/OVA created with Virtual Box"); + return true; + } + } + } catch (IOException e) { + e.printStackTrace(); + } + return false; + } + public void browseForOvftoolPath() { QFileChooser fc = new QFileChooser(Config.getUploadPath(), false); int action = fc.showOpenDialog(getDialog()); @@ -170,6 +188,13 @@ public class ImageOvfConversionPage extends ImageOvfConversionPageLayout { @Override protected void onPageEnter() { + if (isVboxImage(state.descriptionFile)) { + Gui.showMessageBox(this, + "Sie haben ein mit VirtualBox erstelltes Image ausgewählt. \n " + + "Die Umwandlung von mit VirtualBox erstellten OVA" + + " und OVF images wird momentan nocht nicht unterstützt.", + MessageType.INFO, LOGGER, null); + } updateConversionProgressbar(0); updateConversionProgressbarText(""); conversionStarted = false; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java index 4326e98b..d8d8b17e 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java @@ -140,7 +140,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { // txtImageName.setText(state.meta.getDisplayName()); state.descriptionFile = file; setErrorMessage(null); - // setDescription("Im nächsten Schritt wird die Konvertierung gestartet."); + setDescription("Bitte starten Sie die Konvertierung."); wizard.showOutOfOrderPage(state.conversionPage); } else { setPageComplete(false); @@ -151,7 +151,9 @@ public class ImageUploadPage extends ImageUploadPageLayout { Config.setUploadPath(file.getParent()); txtImageFile.setText(""); txtImageName.setText(""); - if (FilenameUtils.getExtension(file.getAbsolutePath()).equalsIgnoreCase("ova")) { + // ask to convert OVA and OVF files + String fileExtension = FilenameUtils.getExtension(file.getAbsolutePath()); + if (fileExtension.equalsIgnoreCase("ova") || fileExtension.equalsIgnoreCase("ovf")) { askForConversion(file); return; } |