Mercurial > hg > AnnotationManagerN4J
annotate src/main/java/de/mpiwg/itgroup/annotations/Person.java @ 105:7417f5915181 default tip
check admin permission before changing permissions.
Enum for typesafe actions.
author | casties |
---|---|
date | Fri, 10 Feb 2017 15:45:35 +0100 |
parents | f83eb8b335b1 |
children |
rev | line source |
---|---|
10 | 1 package de.mpiwg.itgroup.annotations; |
2 | |
70 | 3 /* |
4 * #%L | |
5 * AnnotationManager | |
6 * %% | |
7 * Copyright (C) 2012 - 2014 MPIWG Berlin | |
8 * %% | |
9 * This program is free software: you can redistribute it and/or modify | |
10 * it under the terms of the GNU Lesser General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Lesser Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Lesser Public | |
20 * License along with this program. If not, see | |
21 * <http://www.gnu.org/licenses/lgpl-3.0.html>. | |
22 * #L% | |
23 */ | |
24 | |
88 | 25 import java.util.Set; |
26 | |
32
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
27 import de.mpiwg.itgroup.annotations.restlet.BaseRestlet; |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
28 |
10 | 29 /** |
30 * @author casties | |
31 * | |
32 */ | |
33 public class Person extends Actor { | |
34 | |
88 | 35 public Set<String> groups; |
36 | |
12 | 37 public Person() { |
38 } | |
39 | |
40 public Person(String id) { | |
41 super(); | |
42 this.id = id; | |
43 } | |
44 | |
10 | 45 public Person(String uri, String name) { |
46 super(); | |
47 this.uri = uri; | |
48 this.name = name; | |
49 } | |
50 | |
15 | 51 public Person(String id, String uri, String name) { |
52 super(); | |
53 this.id = id; | |
54 this.uri = uri; | |
55 this.name = name; | |
56 } | |
57 | |
10 | 58 @Override |
59 public boolean isGroup() { | |
60 return false; | |
61 } | |
62 | |
63 public String getIdString() { | |
64 if (id == null) { | |
65 id = getIdFromUri(uri, false); | |
66 } | |
67 return id; | |
68 } | |
69 | |
15 | 70 /** |
71 * Returns a Person with this id or null. | |
72 * | |
73 * @param id | |
74 * @return | |
75 */ | |
76 public static Person createPersonWithId(String id) { | |
77 if (id != null) { | |
78 return new Person(id); | |
79 } | |
80 return null; | |
81 } | |
32
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
82 |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
83 /** |
87 | 84 * Sets the name from the id using getFullNameForId of the Application. |
32
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
85 * |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
86 * @param application |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
87 * @return |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
88 */ |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
89 public String updateName(BaseRestlet application) { |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
90 if (id != null) { |
86 | 91 name = application.getFullNameForId(id); |
32
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
92 } |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
93 return name; |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
15
diff
changeset
|
94 } |
88 | 95 |
96 /** | |
97 * Returns the anonymous Person. | |
98 * | |
99 * @return | |
100 */ | |
101 public static Person getAnonymous() { | |
103 | 102 return new Person("anonymous", null, "Anonymous"); |
88 | 103 } |
69 | 104 |
105 /* (non-Javadoc) | |
106 * @see java.lang.Object#toString() | |
107 */ | |
108 @Override | |
109 public String toString() { | |
110 String s = "PERSON["+id+"]"; | |
111 if (name != null) { | |
112 s += ": "+name; | |
113 } | |
114 return s; | |
115 } | |
10 | 116 } |