KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > common > IsOnline


1 /*
2  * ĻON content management system.
3  * Copyright (C) 2002 Guillaume Bort(gbort@msn.com). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  * Copyright 2000-2002 (C) Intalio Inc. All Rights Reserved.
7  *
8  * ĻON is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * ĻON core framework, ĻON content server, ĻON backoffice, ĻON frontoffice
14  * and ĻON admin application are parts of ĻON and are distributed under
15  * same terms of licence.
16  *
17  *
18  * ĻON includes software developed by the Apache Software Foundation (http://www.apache.org/)
19  * and software developed by the Exolab Project (http://www.exolab.org).
20  *
21  * ĻON is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  */

26
27 package org.nextime.ion.common;
28
29 import java.text.SimpleDateFormat JavaDoc;
30 import java.util.Date JavaDoc;
31 import java.util.Vector JavaDoc;
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 JavaDoc frontUserLogin = "visiteurAnonyme";
40
41     public static boolean getStatus(Publication p) {
42         try {
43             Vector JavaDoc 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 JavaDoc e) {
53             e.printStackTrace();
54         }
55         return false;
56     }
57
58     public static boolean getStatus(Object JavaDoc p) {
59         try {
60             return getStatus((Publication) p);
61         } catch (Exception JavaDoc e) {
62             return false;
63         }
64     }
65
66     public static int getMostRecentVersion(Publication p) {
67         try {
68             Vector JavaDoc 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 JavaDoc e) {
78             e.printStackTrace();
79         }
80         return -1;
81     }
82
83 }
84
Popular Tags