diff options
author | Jonathan Bauer | 2015-07-23 15:46:40 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-07-23 15:46:40 +0200 |
commit | e8d6bc2bacca3c0a344fc4930bd0ac5658f13c2d (patch) | |
tree | 9d2b1adad09af430946f6430b05fee6c22bd6eff /dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java | |
parent | [client] added isRestricted and isEnalbled to uploadWizwardState (diff) | |
download | tutor-module-e8d6bc2bacca3c0a344fc4930bd0ac5658f13c2d.tar.gz tutor-module-e8d6bc2bacca3c0a344fc4930bd0ac5658f13c2d.tar.xz tutor-module-e8d6bc2bacca3c0a344fc4930bd0ac5658f13c2d.zip |
[client] push permissions to sat when wizard finishes
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java index 3f56f586..1ae87ce0 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java @@ -3,10 +3,14 @@ package org.openslx.dozmod.gui.wizard; import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.eclipse.jface.wizard.Wizard; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; import org.openslx.bwlp.thrift.iface.ImageBaseWrite; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; +import org.openslx.bwlp.thrift.iface.ImageVersionWrite; import org.openslx.dozmod.gui.MainWindow; import org.openslx.dozmod.gui.helper.MessageType; +import org.openslx.dozmod.gui.helper.UserToPermissionLink; import org.openslx.dozmod.gui.wizard.page.ImageCustomPermissionPage; import org.openslx.dozmod.gui.wizard.page.ImageMetaDataPage; import org.openslx.dozmod.gui.wizard.page.ImageUploadPage; @@ -39,6 +43,7 @@ public class ImageWizard extends Wizard { @Override public String getWindowTitle() { return "Neues Image erzeugen"; + } @Override @@ -54,6 +59,14 @@ public class ImageWizard extends Wizard { @Override public boolean performFinish() { + // evaluate table state and create the map of permissions + for (TableItem tc : imageCustomPermissionPage.getTable().getItems()) { + if (tc.getData() instanceof UserToPermissionLink) { + UserToPermissionLink upl = (UserToPermissionLink) tc.getData(); + LOGGER.debug(upl.getUserId() + " has permissions: " + + upl.getPermission()); + } + } // since we only started the download and created a "blank" image entry // we can here do all the sanity checks on the fields of UploadWizardState // and react accordingly. @@ -62,16 +75,7 @@ public class ImageWizard extends Wizard { LOGGER.error("Invalid state!"); return false; } else { - LOGGER.debug(uploadWizardState.name); - LOGGER.debug(uploadWizardState.description); - LOGGER.debug(uploadWizardState.descriptionFile.toString()); - LOGGER.debug(uploadWizardState.diskFile.toString()); - LOGGER.debug(uploadWizardState.selectedOs.toString()); - LOGGER.debug(uploadWizardState.virtualizer.toString()); - LOGGER.debug(uploadWizardState.isTemplate); - LOGGER.debug(uploadWizardState.permissions.toString()); - LOGGER.debug(uploadWizardState.shareMode.toString()); - LOGGER.debug(uploadWizardState.uuid.toString()); + LOGGER.debug(uploadWizardState.toString()); // TODO run the actually request over external threaded class try { // push to sat @@ -87,35 +91,46 @@ public class ImageWizard extends Wizard { ImageDetailsRead imageDetailsRead = null; try { imageDetailsRead = ThriftManager.getSatClient().getImageDetails(Session.getSatelliteToken(), - uploadWizardState.uuid.toString()); + uploadWizardState.uuid); } catch (TException e) { LOGGER.error("Could not fetch image details of newly created image!", e); return false; } - - if (uploadWizardState.permissionList != null) { - // user skipped permission list stuff - // TODO push permission list to servor + if (imageDetailsRead != null) { + // it did work :) + LOGGER.debug(imageDetailsRead.toString()); + // push permissions to satellite server + if (uploadWizardState.permissionList != null) { + // user skipped permission list stuff + try { + ThriftManager.getSatClient().writeImagePermissions( + Session.getSatelliteToken(), + uploadWizardState.uuid, + uploadWizardState.permissionList); + } catch (TException e) { + // TODO Auto-generated catch block + LOGGER.error("Could not write permissions list to satellite: ", e); + return false; + } + } try { - ThriftManager.getSatClient().writeImagePermissions( + // push to sat + ThriftManager.getSatClient().updateImageVersion( Session.getSatelliteToken(), - uploadWizardState.uuid, - uploadWizardState.permissionList); + imageDetailsRead.latestVersionId, + new ImageVersionWrite(uploadWizardState.isEnabled, uploadWizardState.isRestricted)); } catch (TException e) { - // TODO Auto-generated catch block - LOGGER.error("Could not push permission list to satellite: ", e); + LOGGER.error("Could not set active/restricted flags to satellite: ", e); return false; } - } - if (imageDetailsRead != null) { - // it did work :) - LOGGER.debug(imageDetailsRead.toString()); + MainWindow.showMessageBox("Creation of image worked :)", MessageType.INFO, LOGGER, null); return true; } else { MainWindow.showMessageBox("Creation of image failed :(", MessageType.ERROR, LOGGER, null); return false; } + } private boolean isStateValid() { @@ -182,6 +197,12 @@ public class ImageWizard extends Wizard { return false; } } + if (uploadWizardState.permissionList == null) { + LOGGER.error("No share mode set in state!"); + return false; + } else { + LOGGER.debug(uploadWizardState.permissionList); + } if (uploadWizardState.shareMode == null) { LOGGER.error("No share mode set in state!"); return false; @@ -190,7 +211,6 @@ public class ImageWizard extends Wizard { LOGGER.error("No uuid set in state!"); return false; } - return true; } private ImageBaseWrite imageBaseWriteFromState() { |