1 26 27 package org.nextime.ion.common; 28 29 import java.text.SimpleDateFormat ; 30 import java.util.Date ; 31 import java.util.Vector ; 32 33 import org.nextime.ion.framework.business.Publication; 34 import org.nextime.ion.framework.business.PublicationVersion; 35 import org.nextime.ion.framework.business.User; 36 37 public class IsOnline { 38 39 public static String frontUserLogin = "visiteurAnonyme"; 40 41 public static boolean getStatus(Publication p) { 42 try { 43 Vector v = p.getVersions(); 44 for (int i = 1; i <= v.size(); i++) { 45 if (p 46 .getVersion(i) 47 .getWorkflow(User.getInstance(frontUserLogin)) 48 .getPermissions() 49 .contains("canDisplay")) 50 return true; 51 } 52 } catch (Exception e) { 53 e.printStackTrace(); 54 } 55 return false; 56 } 57 58 public static boolean getStatus(Object p) { 59 try { 60 return getStatus((Publication) p); 61 } catch (Exception e) { 62 return false; 63 } 64 } 65 66 public static int getMostRecentVersion(Publication p) { 67 try { 68 Vector v = p.getVersions(); 69 for (int i = 0; i < v.size(); i++) { 70 PublicationVersion ver = (PublicationVersion) v.get(i); 71 if (ver 72 .getWorkflow(User.getInstance(frontUserLogin)) 73 .getPermissions() 74 .contains("canDisplay")) 75 return ver.getVersion(); 76 } 77 } catch (Exception e) { 78 e.printStackTrace(); 79 } 80 return -1; 81 } 82 83 } 84 | Popular Tags |