diff options
author | Jonathan Bauer | 2016-05-04 18:21:47 +0200 |
---|---|---|
committer | Jonathan Bauer | 2016-05-04 18:21:47 +0200 |
commit | 2420003d435ba1800c6ec0874c08bef1c1cd9a7a (patch) | |
tree | 288c9058f308d16fd719ac3bd223b1f7244d6419 | |
parent | [client] only switch to 'Advanced' tab if its input fields contain errors (diff) | |
download | tutor-module-2420003d435ba1800c6ec0874c08bef1c1cd9a7a.tar.gz tutor-module-2420003d435ba1800c6ec0874c08bef1c1cd9a7a.tar.xz tutor-module-2420003d435ba1800c6ec0874c08bef1c1cd9a7a.zip |
[client] publish image stuff 2.0
17 files changed, 181 insertions, 97 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java index 97384ab0..01fcf515 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java @@ -131,16 +131,6 @@ public class App { setupLogger(); - if (Config.getProxyMode() == ProxyMode.AUTO) { - // Initialize the proxy settings - proxyThread = new Thread() { - @Override - public void run() { - ProxyConfigurator.init(); - } - }; - proxyThread.start(); - } // Setup swing style System.setProperty("awt.useSystemAAFontSettings", "on"); @@ -171,6 +161,18 @@ public class App { } // remember masterserver host masterServerHost = host; + // now start the proxy + if (Config.getProxyMode() == ProxyMode.AUTO) { + // Initialize the proxy settings + proxyThread = new Thread() { + @Override + public void run() { + ProxyConfigurator.init(); + } + }; + proxyThread.start(); + } + // SSL if (useSsl) { try { SSLContext ctx = SSLContext.getInstance("TLSv1.2"); 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 3d4b7d0d..7d7a813e 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 @@ -77,7 +77,12 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe * Self-reference */ private final ImageDetailsWindow me = this; + + /** + * Action handler proxying thrift calls to differentiate between local and published image mode + */ private final ImageDetailsActions actionHandler; + /** * Callback interface to refresh image list after changing image details */ @@ -379,7 +384,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe }; // ThriftActions.getImageFullDetails(JOptionPane.getFrameForComponent(me), imageBaseId, callback); - actionHandler.getImageDetails(JOptionPane.getFrameForComponent(me), imageBaseId, callback); + actionHandler.getImageDetails(imageBaseId, callback); //ThriftActions.getImageFullDetails(JOptionPane.getFrameForComponent(me), imageBaseId, callback); } @@ -389,7 +394,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe * @param user UserInfo to set the owner to */ private void setImageOwner(final UserInfo user) { - if (!actionHandler.setImageOwner(JOptionPane.getFrameForComponent(me), image.getImageBaseId(), user)) { + if (!actionHandler.setImageOwner(image.getImageBaseId(), user)) { return; } Gui.showMessageBox(me, "Besitzrechte übertragen an " + FormatHelper.userName(user), MessageType.INFO, @@ -519,7 +524,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe private void deleteVersion(final ImageVersionDetails version) { if (version == null) return; - actionHandler.deleteImageVersion(JOptionPane.getFrameForComponent(this), version, + actionHandler.deleteImageVersion(version, new DeleteCallback() { @Override public void isDeleted(boolean success) { @@ -716,6 +721,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe btnPermissions.setEnabled(editable && ImagePerms.canAdmin(image)); btnChangeOwner.setEnabled(editable && ImagePerms.canAdmin(image)); btnUpdateImage.setEnabled(editable); + btnUploadToMaster.setEnabled(editable && actionHandler.canPublish()); } /** diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java index b4814713..fed5c1ab 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java @@ -32,6 +32,7 @@ import org.openslx.dozmod.gui.wizard.ImageCreationWizard; import org.openslx.dozmod.gui.wizard.LectureWizard; import org.openslx.dozmod.permissions.ImagePerms; import org.openslx.dozmod.thrift.ImageLocalDetailsActions; +import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.ThriftActions; import org.openslx.dozmod.thrift.ThriftActions.DeleteCallback; import org.openslx.dozmod.thrift.ThriftActions.DownloadCallback; @@ -312,7 +313,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa public void updated() { ctlImageListViewer.refreshList(true, 100); } - }, new ImageLocalDetailsActions()); + }, new ImageLocalDetailsActions(JOptionPane.getFrameForComponent(me))); } /** @@ -413,6 +414,9 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa @Override public void requestShow() { + // we need to enable the "Show published images" button here, since we need to check + // Session.getSatApiVersion() which is not set when this class is instantiated + btnShowPublishedImages.setEnabled(Session.getSatApiVersion() >= 3); ctlImageListViewer.refreshList(false, 1); } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImagePublishedWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImagePublishedWindow.java index 056b1a4d..d58b5be9 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImagePublishedWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImagePublishedWindow.java @@ -10,11 +10,15 @@ import java.awt.event.WindowEvent; import java.util.List; import javax.swing.JFrame; +import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ImageSummaryRead; +import org.openslx.bwlp.thrift.iface.TAuthorizationException; +import org.openslx.bwlp.thrift.iface.TInvocationException; +import org.openslx.bwlp.thrift.iface.TNotFoundException; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.MainWindow; import org.openslx.dozmod.gui.helper.UiFeedback; @@ -97,9 +101,9 @@ public class ImagePublishedWindow extends ImagePublishedWindowLayout implements if (item == null || item.getImageBaseId() == null) return; ImageDetailsWindow.open( - (JFrame) SwingUtilities.getWindowAncestor(me), + JOptionPane.getFrameForComponent(ImagePublishedWindow.this), item.getImageBaseId(), null, - new ImagePublishedDetailsActions()); + new ImagePublishedDetailsActions(JOptionPane.getFrameForComponent(ImagePublishedWindow.this))); } processClick(e); } @@ -118,14 +122,24 @@ public class ImagePublishedWindow extends ImagePublishedWindowLayout implements // TODO popup menu? } }); + LOGGER.debug(Session.getSatelliteAddress()); + try { + + ThriftManager.getMasterClient().downloadImage("asd", "123"); + } catch (TException e1) { + ThriftError.showMessage(this, LOGGER, e1, "fail"); + } + // init data refreshList(true, 0); } + /** * Callback when download initialized * - * @param success true if downloading, false otherwise + * @param success + * true if downloading, false otherwise */ @Override public void downloadInitialized(boolean success) { @@ -138,6 +152,7 @@ public class ImagePublishedWindow extends ImagePublishedWindowLayout implements }); } } + /** * Refreshes the image list in the table * diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java index 3dd86974..504cf6d6 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java @@ -360,7 +360,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements toggleEditable(false); return; } - LOGGER.debug("LECT: " + lecture); + if (image == null) { txtImageName.setText("-"); lblImageNameInfo.setText("-"); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java index 90404916..6064aa49 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java @@ -245,7 +245,7 @@ public class LectureListWindow extends LectureListWindowLayout { } if (e.getSource().equals(popupItemLinked)) { - ImageDetailsWindow.open(JOptionPane.getFrameForComponent(me), lecture.imageBaseId, null, new ImageLocalDetailsActions()); + ImageDetailsWindow.open(JOptionPane.getFrameForComponent(me), lecture.imageBaseId, null, new ImageLocalDetailsActions(JOptionPane.getFrameForComponent(me))); } if (e.getSource().equals(popupItemDelete)) { deleteLectures(tblLectures.getSelectedItems()); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java index 5e84ea98..5f521394 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java @@ -209,7 +209,7 @@ public abstract class ImageDetailsWindowLayout extends JDialog { btnClose = new JButton("Schließen"); btnUpdateImage = new JButton("Neue VM-Version hochladen", Gui.getScaledIconResource("/img/upload-icon.png", "New VM", ICON_SIZE_Y, buttonPanel)); buttonPanel.add(btnUpdateImage); - btnUploadToMaster = new JButton("Landesweit veröffentlichen" /* TODO: Button image */); + btnUploadToMaster = new JButton("Landesweit veröffentlichen", Gui.getScaledIconResource("/img/publish.png", "Publish VM", ICON_SIZE_Y, buttonPanel)); buttonPanel.add(btnUploadToMaster); buttonPanel.add(Box.createGlue()); // user feedback slot diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java index c38686a3..c4e76566 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java @@ -73,9 +73,9 @@ public abstract class ImageListWindowLayout extends CompositePage { "Delete VM", ICON_SIZE_Y, buttonPanel)); btnDownload = new JButton(downloadButtonLabel, Gui.getScaledIconResource("/img/download-icon.png", "New VM", ICON_SIZE_Y, buttonPanel)); - btnNewLecture = new JButton(newLectureButtonLabel, Gui.getScaledIconResource( - "/img/new-lecture-icon.png", "New Lecture", ICON_SIZE_Y, buttonPanel)); - btnShowPublishedImages = new JButton(showPublishedImagesLabel, null); // TODO icon + btnNewLecture = new JButton(newLectureButtonLabel, Gui.getScaledIconResource("/img/new-lecture-icon.png", + "New Lecture", ICON_SIZE_Y, buttonPanel)); + btnShowPublishedImages = new JButton(showPublishedImagesLabel, null); btnSwitchView = new JButton(switchViewButtonLabel, Gui.getScaledIconResource("/img/switch-icon.png", "Switch", ICON_SIZE_Y, buttonPanel)); buttonPanel.add(btnNewVm); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java index 26e11504..b8ceb6b5 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/GuiErrorCallback.java @@ -3,7 +3,10 @@ package org.openslx.dozmod.thrift; import java.awt.Frame; import org.apache.log4j.Logger; +import org.apache.thrift.TException; import org.apache.thrift.transport.TTransportException; +import org.openslx.bwlp.thrift.iface.AuthorizationError; +import org.openslx.bwlp.thrift.iface.TAuthorizationException; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.Gui.GuiCallable; import org.openslx.dozmod.gui.helper.MessageType; @@ -25,7 +28,7 @@ public class GuiErrorCallback implements ErrorCallback { @Override public boolean thriftError(int failCount, final String method, final Throwable t) { // if it's not a transport exception, do not retry - if (t != null && !(t instanceof TTransportException)) + if (t != null && !(t instanceof TException)) return false; // if it's the first fail, retry immediately if (failCount == 1) @@ -33,20 +36,40 @@ public class GuiErrorCallback implements ErrorCallback { // Some methods are non-critical, so don't show a pop-up if (ThriftError.failSilently(method)) return failCount == 2; // As it's silent, give it a second try... - // Otherwise, ask user if we should retry - final TTransportException tex = (TTransportException) t; - return Gui.syncExec(new GuiCallable<Boolean>() { - @Override - public Boolean run() { - String errMsg = null; - if (tex != null) { - errMsg = " (Fehler " + tex.getType() + ")"; - } - return Gui.showMessageBox(parent, "Die Kommunikation mit " + serverString + " ist" - + " gestört. Der Aufruf der Funktion " + method + " ist fehlgeschlagen" + errMsg - + ".\n\n" + "Möchten Sie den Aufruf wiederholen?", MessageType.ERROR_RETRY, LOGGER, t); + if (t instanceof TAuthorizationException) { + final TAuthorizationException taex = (TAuthorizationException) t; + if (taex.getNumber() == AuthorizationError.NOT_AUTHENTICATED || taex.getNumber() == AuthorizationError.INVALID_TOKEN) { + // TODO somehow reauth the user :) + return Gui.syncExec(new GuiCallable<Boolean>() { + @Override + public Boolean run() { + if (Gui.showMessageBox(parent, "Ungültiges Sitzungstoken oder fehlerhafte Authentifizierung am " + serverString + "!" + + //"\n" + errMsg + "\n" + + "\nBitte starten Sie das Programm neu. Jetzt beenden?", MessageType.ERROR_RETRY, LOGGER, t)) { + // user confirmed exit + Gui.exit(0); + } + return false; + } + }); } - }); + } + if (t instanceof TTransportException) { + // Otherwise, ask user if we should retry + final TTransportException tex = (TTransportException) t; + return Gui.syncExec(new GuiCallable<Boolean>() { + @Override + public Boolean run() { + String errMsg = null; + if (tex != null) { + errMsg = " (Fehler " + tex.getType() + ")"; + } + return Gui.showMessageBox(parent, "Die Kommunikation mit " + serverString + " ist" + + " gestört. Der Aufruf der Funktion " + method + " ist fehlgeschlagen" + errMsg + + ".\n\n" + "Möchten Sie den Aufruf wiederholen?", MessageType.ERROR_RETRY, LOGGER, t); + } + }); + } + return false; } - } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImageDetailsActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImageDetailsActions.java index 2f8ad062..71615723 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImageDetailsActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImageDetailsActions.java @@ -1,6 +1,5 @@ package org.openslx.dozmod.thrift; -import java.awt.Frame; import java.util.Map; import org.apache.thrift.TException; @@ -12,16 +11,13 @@ import org.openslx.bwlp.thrift.iface.TInvocationException; import org.openslx.bwlp.thrift.iface.TNotFoundException; import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.dozmod.thrift.ThriftActions.DeleteCallback; -import org.openslx.dozmod.thrift.ThriftActions.DownloadCallback; import org.openslx.dozmod.thrift.ThriftActions.ImageMetaCallback; public interface ImageDetailsActions { - public void getImageDetails(final Frame parent, final String imageBaseId, final ImageMetaCallback callback); - public boolean setImageOwner(final Frame parent, final String imageBaseId, final UserInfo user); + public void getImageDetails(final String imageBaseId, final ImageMetaCallback callback); + public boolean setImageOwner(final String imageBaseId, final UserInfo user); public void updateImageBase(final String imageBaseId, final ImageBaseWrite data) throws TException, TAuthorizationException, TNotFoundException, TInvocationException; public void writeImagePermissions(final String imageBaseId, Map<String, ImagePermissions> customPermissions) throws TException, TAuthorizationException, TNotFoundException, TInvocationException; - public void initDownload(final Frame frame, final String imageVersionId, final String imageName, - final String virtualizerId, final int osId, final long imageSize, final DownloadCallback callback); - public void deleteImageVersion(final Frame frame, final ImageVersionDetails version, final DeleteCallback callback); - // TODO button enable function + public void deleteImageVersion(final ImageVersionDetails version, final DeleteCallback callback); + public boolean canPublish(); } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImageLocalDetailsActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImageLocalDetailsActions.java index c72ad67e..64ee8d25 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImageLocalDetailsActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImageLocalDetailsActions.java @@ -3,6 +3,7 @@ package org.openslx.dozmod.thrift; import java.awt.Frame; import java.util.Map; +import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ImageBaseWrite; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; @@ -14,15 +15,21 @@ import org.openslx.bwlp.thrift.iface.TNotFoundException; import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.thrift.ThriftActions.DeleteCallback; -import org.openslx.dozmod.thrift.ThriftActions.DownloadCallback; import org.openslx.dozmod.thrift.ThriftActions.ImageMetaCallback; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; public class ImageLocalDetailsActions implements ImageDetailsActions { + private final static Logger LOGGER = Logger.getLogger(ImageLocalDetailsActions.class); + private final Frame parent; + public ImageLocalDetailsActions(final Frame parent) { + this.parent = parent; + } + @Override - public void getImageDetails(final Frame parent, final String imageBaseId, final ImageMetaCallback callback) { + public void getImageDetails(final String imageBaseId, + final ImageMetaCallback callback) { QuickTimer.scheduleOnce(new Task() { ImageDetailsRead details = null; Map<String, ImagePermissions> permissions = null; @@ -30,7 +37,8 @@ public class ImageLocalDetailsActions implements ImageDetailsActions { @Override public void fire() { details = ThriftActions.getImageDetails(parent, imageBaseId); - permissions = ThriftActions.getImagePermissions(parent, imageBaseId); + permissions = ThriftActions.getImagePermissions(parent, + imageBaseId); Gui.asyncExec(new Runnable() { @Override public void run() { @@ -44,35 +52,45 @@ public class ImageLocalDetailsActions implements ImageDetailsActions { } @Override - public boolean setImageOwner(final Frame parent, final String imageBaseId, final UserInfo user) { + public boolean setImageOwner(final String imageBaseId, final UserInfo user) { return ThriftActions.setImageOwner(parent, imageBaseId, user); } @Override - public void updateImageBase(final String imageBaseId, final ImageBaseWrite data) throws TException, TAuthorizationException, TNotFoundException, TInvocationException { + public void updateImageBase(final String imageBaseId, + final ImageBaseWrite data) throws TException, + TAuthorizationException, TNotFoundException, TInvocationException { ThriftActions.updateImageBase(imageBaseId, data); } @Override - public void writeImagePermissions(final String imageBaseId, Map<String, ImagePermissions> customPermissions) throws TException { + public void writeImagePermissions(final String imageBaseId, + final Map<String, ImagePermissions> customPermissions) throws TException { + QuickTimer.scheduleOnce(new Task() { + @Override + public void fire() { + try { + ThriftActions.writeImagePermissions(imageBaseId, customPermissions); + } catch (TException e) { + ThriftError.showMessage(parent, LOGGER, e, "Could not write permissions"); + } + } + }); ThriftActions.writeImagePermissions(imageBaseId, customPermissions); } @Override - public void initDownload(final Frame parent, final String imageVersionId, - final String imageName, final String virtualizerId, final int osId, final long imageSize, - final DownloadCallback callback) { - // TODO Auto-generated method stub - - } - - @Override - public void deleteImageVersion(final Frame parent, final ImageVersionDetails version, + public void deleteImageVersion(final ImageVersionDetails version, final DeleteCallback callback) { ThriftActions.deleteImageVersion(parent, version, callback); - + } + @Override + public boolean canPublish() { + // check that the API of the satellite server is at least 3 + // (anything > 3 supports publications of images) + return Session.getSatApiVersion() >= 3; + } - } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImagePublishedDetailsActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImagePublishedDetailsActions.java index c60b2dfa..81d8332c 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImagePublishedDetailsActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ImagePublishedDetailsActions.java @@ -3,6 +3,7 @@ package org.openslx.dozmod.thrift; import java.awt.Frame; import java.util.Map; +import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.ImageBaseWrite; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; import org.openslx.bwlp.thrift.iface.ImagePermissions; @@ -10,22 +11,25 @@ import org.openslx.bwlp.thrift.iface.ImageVersionDetails; import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.thrift.ThriftActions.DeleteCallback; -import org.openslx.dozmod.thrift.ThriftActions.DownloadCallback; import org.openslx.dozmod.thrift.ThriftActions.ImageMetaCallback; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; -public class ImagePublishedDetailsActions implements ImageDetailsActions{ +public class ImagePublishedDetailsActions implements ImageDetailsActions { + + private final static Logger LOGGER = Logger.getLogger(ImagePublishedDetailsActions.class); + + public ImagePublishedDetailsActions(final Frame parent) { + } @Override - public void getImageDetails(final Frame parent, final String imageBaseId, final ImageMetaCallback callback) { + public void getImageDetails(final String imageBaseId, final ImageMetaCallback callback) { QuickTimer.scheduleOnce(new Task() { ImageDetailsRead details = null; @Override public void fire() { details = ThriftActions.getPublishedImageDetails(imageBaseId); - Gui.asyncExec(new Runnable() { @Override public void run() { @@ -37,11 +41,10 @@ public class ImagePublishedDetailsActions implements ImageDetailsActions{ }); } }); - } @Override - public boolean setImageOwner(Frame parent, String imageBaseId, UserInfo user) { + public boolean setImageOwner(String imageBaseId, UserInfo user) { return false; } @@ -57,18 +60,13 @@ public class ImagePublishedDetailsActions implements ImageDetailsActions{ } @Override - public void initDownload(Frame frame, String imageVersionId, - String imageName, String virtualizerId, int osId, long imageSize, - DownloadCallback callback) { - // TODO download stuff - } - - @Override - public void deleteImageVersion(Frame frame, ImageVersionDetails version, + public void deleteImageVersion(ImageVersionDetails version, DeleteCallback callback) { return; } - - + @Override + public boolean canPublish() { + return false; + } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java index 2f5059b5..c5170681 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java @@ -14,13 +14,17 @@ public class Session { private static WhoamiInfo data = null; + private static String satelliteAddress = null; + private static String satelliteToken = null; private static String masterToken = null; - private static String satelliteAddress = null; + private static long satelliteApiVersion = -1; + + private static SatelliteConfig satConf = null; - public static void initialize(WhoamiInfo whoami, String satAddress, String satToken, String masToken) { + public static void initialize(WhoamiInfo whoami, String satAddress, String satToken, String masToken, long satApiVersion) { if (whoami == null || whoami.user == null || whoami.user.userId == null) { throw new IllegalArgumentException( "Cannot initialize session: whoami-Information from satellite incomplete"); @@ -33,6 +37,7 @@ public class Session { masterToken = masToken; satelliteToken = satToken; satelliteAddress = satAddress; + satelliteApiVersion = satApiVersion; } /** @@ -121,7 +126,12 @@ public class Session { return satelliteAddress; } - private static SatelliteConfig satConf = null; + /** + * @return the satellite server's API version + */ + public static long getSatApiVersion() { + return satelliteApiVersion; + } /** * Query the satellite server for its configuration and default values. diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java index 3467e4e9..78d2e416 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java @@ -68,9 +68,9 @@ public class ThriftActions { /* ******************************************************************************* * - * LOGIN + * SESSION * - * Login methods + * Session initialization * * ******************************************************************************* */ @@ -90,6 +90,7 @@ public class ThriftActions { String address = null; String satToken = null; String masterToken = null; + long remoteVersion = -1; if (interactive && !forceCustomSatellite && (data.satellites == null || data.satellites.isEmpty())) { Gui.asyncMessageBox("Login erfolgreich, aber es wurde kein Satelliten-Server gefunden.\n" @@ -154,7 +155,6 @@ public class ThriftActions { address, App.THRIFT_SSL_PORT, 5000); // RPC version check - long remoteVersion = -1; if (client != null) { try { remoteVersion = client.getVersion(Version.VERSION); @@ -175,7 +175,7 @@ public class ThriftActions { return false; } - if (remoteVersion != Version.VERSION) { + if (remoteVersion < Version.MIN_VERSION || remoteVersion > Version.VERSION) { if (interactive) { Gui.asyncMessageBox("Das von Ihnen verwendete Dozentenmodul ist nicht mit dem" + " gewählten Satelliten-Server kompatibel.\n" + "Ihre Version: " @@ -215,7 +215,7 @@ public class ThriftActions { } while (interactive && whoami == null); if (whoami != null) { - Session.initialize(whoami, address, satToken, masterToken); + Session.initialize(whoami, address, satToken, masterToken, remoteVersion); ThriftManager.setSatelliteAddress( GraphicalCertHandler.getSslContext(Session.getSatelliteAddress()), Session.getSatelliteAddress(), App.THRIFT_SSL_PORT, App.THRIFT_TIMEOUT_MS); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/ImagePublishedCache.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/ImagePublishedCache.java index e57a4a24..a137d84e 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/ImagePublishedCache.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/ImagePublishedCache.java @@ -4,11 +4,13 @@ import java.util.List; import org.apache.log4j.Logger; import org.apache.thrift.TException; -import org.openslx.bwlp.thrift.iface.ImagePublishData; import org.openslx.bwlp.thrift.iface.ImageSummaryRead; import org.openslx.bwlp.thrift.iface.TAuthorizationException; import org.openslx.bwlp.thrift.iface.TInvocationException; -import org.openslx.dozmod.gui.window.ImageListWindow; +import org.openslx.dozmod.Config; +import org.openslx.dozmod.gui.Gui; +import org.openslx.dozmod.gui.MainWindow; +import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.thrift.Session; import org.openslx.thrifthelper.ThriftManager; import org.openslx.util.GenericDataCache; @@ -16,7 +18,8 @@ import org.openslx.util.GenericDataCache.CacheMode; public class ImagePublishedCache { - private final static Logger LOGGER = Logger.getLogger(ImagePublishedCache.class); + private final static Logger LOGGER = Logger + .getLogger(ImagePublishedCache.class); private static final int CACHE_TIME_LIST_MS = 30 * 1000; @@ -30,11 +33,19 @@ public class ImagePublishedCache { int pageSize = Session.getSatelliteConfig().pageSize; for (int i = 0;; ++i) { List<ImageSummaryRead> page = null; - try { - page = ThriftManager.getMasterClient().getPublicImages(Session.getMasterToken(), i); - } catch (TException e) { - LOGGER.error("Could not get the list of public images from the masterserver.", e); - } +// try { + page = ThriftManager.getMasterClient().getPublicImages( + Session.getMasterToken(), i); +// } catch (TAuthorizationException e) { +// if (Gui.showMessageBox( +// "Sitzung abgelaufen. Um diese Funktion zu nutzen, melden Sie sich erneut ein. Jetzt abmelden und beenden?", +// MessageType.QUESTION_YESNO, LOGGER, e)) { +// Config.saveCurrentSession("", "", ""); +// +// } +// +// return null; +// } if (result == null) { result = page; } else { diff --git a/dozentenmodul/src/main/resources/img/publish.png b/dozentenmodul/src/main/resources/img/publish.png Binary files differnew file mode 100644 index 00000000..1dfa03c6 --- /dev/null +++ b/dozentenmodul/src/main/resources/img/publish.png diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java index ed8cbb7e..637fd0ce 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java @@ -13,6 +13,7 @@ import org.apache.log4j.BasicConfigurator; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; +import org.apache.thrift.TException; import org.apache.thrift.transport.TTransportException; import org.openslx.bwlp.sat.database.Updater; import org.openslx.bwlp.sat.database.mappers.DbUser; @@ -84,11 +85,11 @@ public class App { public boolean thriftError(int failCount, String method, Throwable t) { if (failFastMethods.contains(method)) return false; - if (failCount > 2 || t == null || !(t instanceof TTransportException)) { + if (failCount > 2 || t == null) { LOGGER.warn("Thrift Client error for " + method + ", FAIL."); return false; } - LOGGER.info("Thrift transport error " + ((TTransportException) t).getType() + " for " + LOGGER.info("Thrift error " + ((TException) t).getCause().toString() + " for " + method + ", retrying..."); try { Thread.sleep(failCount * 250); |