From 994ccb035e237f1d5da5f6db2383cd3c87db55b8 Mon Sep 17 00:00:00 2001 From: Nino Breuer Date: Fri, 10 Oct 2014 13:22:33 +0200 Subject: added autocomplete and autocheck for setting new image rights --- .../src/main/java/util/CheckIntegrity.java | 79 +++++++++++++++------- 1 file changed, 53 insertions(+), 26 deletions(-) (limited to 'dozentenmodul/src/main/java/util/CheckIntegrity.java') diff --git a/dozentenmodul/src/main/java/util/CheckIntegrity.java b/dozentenmodul/src/main/java/util/CheckIntegrity.java index d87a8579..bb5becbd 100644 --- a/dozentenmodul/src/main/java/util/CheckIntegrity.java +++ b/dozentenmodul/src/main/java/util/CheckIntegrity.java @@ -2,46 +2,73 @@ package util; public class CheckIntegrity { - private static boolean isFine = false; + //private static boolean isFine = false; - // integrety check on permissions put by user - public static boolean[] isIntegre(boolean isRead, boolean isWrite, - boolean isLink, boolean isAdmin) { + // integrity check on permissions put by user + public static boolean[] isIntegre(boolean isRead, boolean isWrite,boolean isLink, boolean isAdmin) + { + // boolean array for the correct result values boolean[] rights = new boolean[4]; rights[0] = isRead; rights[1] = isWrite; rights[2] = isLink; rights[3] = isAdmin; + + System.out.println("*****************************"); + System.out.println(isRead+" "+isWrite+" "+isLink+" "+isAdmin); + - // do all checks and only change wrong settings - if (isAdmin == true) { - // set true for everything + if(isRead) //if read is allowed, only read is allowed + { + rights[0] = true; //read allowed + } + else //if read is not allowed, nothing is allowed + { + rights[0] = false; + rights[1] = false; + rights[2] = false; + rights[3] = false; + } + + if(isWrite) //if write was selected + { + rights[0] = true; + rights[1] = true; + } + else //if write was unselected + { + //rights[0] = false; + rights[1] = false; + } + + if(isLink) //if link was selected, read and link are allowed + { + rights[0] = true; + rights[2] = true; + } + else //if link is unselected, link is not allowed + { + rights[2] = false; + } + + if(isAdmin) //if admin is selected, anything is allowed + { rights[0] = true; rights[1] = true; rights[2] = true; rights[3] = true; - return rights; - } else { - if(isRead == false){ - //if user may not read, then he may not do anything - rights[0] = false; - rights[1] = false; - rights[2] = false; - rights[3] = false; - } - if (isWrite == true) { - // if user can write, then he must also be allowed to read - rights[0] = true; - } - - if (isLink == true) { - // if user may link, then he may also read - - } } - + else //if admin is unselected, admin is not allowed + { + rights[3] = false; + } + + System.out.println(">-------------<"); + System.out.println(rights[0]+" "+rights[1]+" "+rights[2]+" "+rights[3]); + return rights; + } } -- cgit v1.2.3-55-g7522