blob: 0e5a1d15b3bee8c0772fb6a9e1361b2bf304735a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package org.openslx.dozmod.util;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
import org.openslx.bwlp.thrift.iface.LectureSummary;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.thrift.cache.LectureCache;
import org.openslx.thrifthelper.TConst;
import java.awt.*;
import java.util.List;
/**
* Class with some temporally Helper Functions.
*/
public class ContainerUtils {
/**
* Checks ImageBaseId of image if already linked with existing Lectures in LectureCache.
*
* @param image The image to check.
* @return true if the images imageBaseId is already linked with a lecture.
*/
public static boolean isContainerImageLinked(ImageSummaryRead image) {
if (image != null && image.getVirtId().equals(TConst.VIRT_DOCKER)) {
List<LectureSummary> lectureSummaries = LectureCache.get(true);
for (LectureSummary lecture : lectureSummaries) {
// lecture.imageBaseId is null when no image linked to it -> NullPointer on equals
if (image.imageBaseId.equals(lecture.imageBaseId)) {
return true;
}
}
}
return false;
}
public static void showWarning(Component c, Logger logger) {
Gui.showMessageBox(c, I18n.WINDOW.getString("LectureDetails.Message.error.containerLinkedWithLecture"),
MessageType.WARNING, logger, null);
}
}
|