diff options
author | Jonathan Bauer | 2018-11-27 17:45:34 +0100 |
---|---|---|
committer | Jonathan Bauer | 2018-11-27 17:45:34 +0100 |
commit | 5674f7e63f599ae71d54e50c1bdb53ef11b4d186 (patch) | |
tree | d83b58530e9ec9181c9f479d555596b753d2ce45 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java | |
parent | [client] fill new form fields on netshare selection (diff) | |
download | tutor-module-5674f7e63f599ae71d54e50c1bdb53ef11b4d186.tar.gz tutor-module-5674f7e63f599ae71d54e50c1bdb53ef11b4d186.tar.xz tutor-module-5674f7e63f599ae71d54e50c1bdb53ef11b4d186.zip |
[client] allow user to choose how long an image is to be extended for
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java index 23f8ed8c..20e5c30c 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java @@ -14,6 +14,7 @@ import java.awt.event.WindowEvent; import java.nio.ByteBuffer; import java.util.Collections; import java.util.Comparator; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -44,6 +45,7 @@ import org.openslx.dozmod.gui.MainWindow; import org.openslx.dozmod.gui.changemonitor.AbstractControlWrapper; import org.openslx.dozmod.gui.changemonitor.DialogChangeMonitor; import org.openslx.dozmod.gui.changemonitor.DialogChangeMonitor.TextNotEmptyConstraint; +import org.openslx.dozmod.gui.helper.ExpiryDateChooser; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.PopupMenu; import org.openslx.dozmod.gui.helper.UiFeedback; @@ -667,16 +669,34 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe /** * Extends the expiration date for given image versions to current date - * plus the configured maximum image validity days. + * plus the user-supplied duration. * * @param versions to extend the validity of */ private void extendVersionExpiry(List<ImageVersionDetails> versions) { + int daysToExtend = -1; + if (versions.size() > 1) { + // more than one version given, ask the user once and use the value for all versions. + daysToExtend = ExpiryDateChooser.askFutureExpiryDate(this, null); + if (daysToExtend == -1) + return; + } int count = 0; for (ImageVersionDetails img : versions) { + long currentExpireDate = img.expireTime; + if (new Date(currentExpireDate).before(new Date(Util.unixTime()))) { + // already expired, use today as starting date for the extension + currentExpireDate = Util.unixTime(); + } + if (daysToExtend == -1) { + daysToExtend = ExpiryDateChooser.askFutureExpiryDate(this, new Date(currentExpireDate * 1000)); + if (daysToExtend == -1) + return; + } + currentExpireDate += daysToExtend * 86400L; try { ThriftManager.getSatClient().setImageVersionExpiry(Session.getSatelliteToken(), img.versionId, - Util.unixTime() + Session.getSatelliteConfig().maxImageValidityDays * 86400); + currentExpireDate); count++; } catch (TException e) { ThriftError.showMessage(this, LOGGER, e, @@ -787,7 +807,6 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe changeMonitor.reset(); // finally do show it all setVisible(true); - } /** |