diff options
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java | 36 |
1 files changed, 32 insertions, 4 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 c7e85d22..907c1c3b 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 @@ -4,14 +4,16 @@ import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; import org.openslx.dozmod.Config; +import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.helper.I18n; +import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.QFileChooser; import org.openslx.dozmod.gui.helper.TextChangeListener; import org.openslx.dozmod.gui.wizard.Wizard; import org.openslx.dozmod.gui.wizard.layout.ContainerUploadPageLayout; import org.openslx.dozmod.model.ContainerDefinition; import org.openslx.dozmod.state.UploadWizardState; -import org.openslx.dozmod.thrift.ThriftActions; +import org.openslx.dozmod.thrift.*; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.dozmod.util.ContainerUtils; import org.openslx.virtualization.configuration.VirtualizationConfigurationDocker; @@ -24,6 +26,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; +import java.nio.ByteBuffer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -63,7 +66,6 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { } // This constructor is used in case the user wants do upload a new version. - // TODO currently unused public ContainerUploadPage(Wizard wizard, UploadWizardState uploadWizardState, ImageDetailsRead imageDetailsRead) { super(wizard); @@ -71,13 +73,16 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { state = uploadWizardState; existingImage = imageDetailsRead; - // TODO fix this! - containerDefinition = null; + containerDefinition = ContainerUtils.getContainerDefinition( + Session.getSatelliteToken(), + imageDetailsRead.getLatestVersionId()); lblImageName.setEnabled(existingImage == null); txtImageName.setEnabled(existingImage == null); + txtImageName.setText(existingImage.getImageName()); txtInfoText.setVisible(existingImage == null); + state.name = imageDetailsRead.imageName; state.defaultPermissions = imageDetailsRead.getDefaultPermissions(); state.description = imageDetailsRead.getDescription(); @@ -311,6 +316,29 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { state.uuid = existingImage.getImageBaseId(); state.name = existingImage.getImageName(); } + + // TODO copy/paste from ImageCreationWizard.wantFinish() + // Do this only if the user wants to upload a new image version! + if (existingImage != null) { + // Create upload initiator that will manage requesting a token, hashing the + // file, connecting for upload... + if (state.upload == null) { + try { + state.upload = new UploadInitiator(state.uuid, state.diskFile, + ByteBuffer.wrap(state.virtualizationConfig.getConfigurationAsByteArray())); + } catch (WrappedException e) { + ThriftError.showMessage(this, LOGGER, e.exception, e.displayMessage); + return false; + } catch (IOException e) { + Gui.showMessageBox(this, + I18n.PAGE.getString("ImageUpload.Message.error.uploadInitiatorFailed"), + MessageType.ERROR, LOGGER, e); + return false; + } + } + // Start the hash check now + state.upload.startHashing(); + } return true; } |