summaryrefslogtreecommitdiffstats
path: root/dozentenmodul
diff options
context:
space:
mode:
authorralph isenmann2020-08-18 17:47:35 +0200
committerralph isenmann2020-09-15 13:48:16 +0200
commit01abac4916a41f6ea1c3f780cd5a5f659aa2923b (patch)
tree0e613fd9894b8480190362a0409e4a08c9b463b5 /dozentenmodul
parent[server] Modify sql Statement to receive metadata (diff)
downloadtutor-module-01abac4916a41f6ea1c3f780cd5a5f659aa2923b.tar.gz
tutor-module-01abac4916a41f6ea1c3f780cd5a5f659aa2923b.tar.xz
tutor-module-01abac4916a41f6ea1c3f780cd5a5f659aa2923b.zip
[client] Allow to upload image file
Try to select docker image (tar-file) for uploading if that is not possible create a special tmpFile (zerofile)
Diffstat (limited to 'dozentenmodul')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java
index 2961d78c..324b3112 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java
@@ -1,5 +1,6 @@
package org.openslx.dozmod.gui.wizard.page;
+import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.ImageDetailsRead;
import org.openslx.dozmod.Config;
@@ -114,7 +115,24 @@ public class DockerfileUploadPage extends ImageUploadPageLayout {
txtImageName.setText(existingImage.getImageName());
state.descriptionFile = file;
- state.diskFile = file; // TODO no disk file in docker context (DUMMY SET)
+ // TESTING: Upload also a prematurely created image (tar)
+ String imageName = file.getParentFile().getName();
+ String tarExt = ".tar";
+ File imageTarFile = new File(file.getParentFile(),imageName.concat(tarExt));
+ if(imageTarFile.exists()) {
+ LOGGER.info("Upload also an created Image");
+ state.diskFile = imageTarFile;
+ } else {
+ try {
+ // create a temp file with dummy content.
+ File tmpFile = File.createTempFile("tmp","img");
+ FileUtils.writeStringToFile(tmpFile,"ZERO\n","UTF-8");
+ state.diskFile = tmpFile; //
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
state.meta = new DockerMetaDataDummy(MetaDataCache.getOperatingSystems(),file);
Config.setUploadPath(file.getParent());