summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
blob: 1b83fdfc7aa35d588a9dfffc94547a03308dcf16 (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
package org.openslx.dozmod.util;

import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
import org.openslx.bwlp.thrift.iface.LectureSummary;
import org.openslx.dozmod.thrift.cache.LectureCache;
import org.openslx.thrifthelper.TConst;

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) {
				if (lecture.imageBaseId.equals(image.imageBaseId)) {
					return true;
				}
			}
		}
		return false;
	}
}