comparison src/main/java/de/mpiwg/itgroup/annotations/Actor.java @ 10:90911b2da322

more work on permissions...
author casties
date Thu, 12 Jul 2012 17:01:32 +0200
parents b2bfc3bc9ba8
children abe25edf2178
comparison
equal deleted inserted replaced
9:b2bfc3bc9ba8 10:90911b2da322
1 /** 1 /**
2 * 2 *
3 */ 3 */
4 package de.mpiwg.itgroup.annotations; 4 package de.mpiwg.itgroup.annotations;
5 5
6 import de.mpiwg.itgroup.annotations.old.NS;
7
6 /** 8 /**
7 * @author casties 9 * @author casties
8 * 10 *
9 */ 11 */
10 public class Actor { 12 public abstract class Actor {
11 13
12 public boolean isGroup;
13 public String uri; 14 public String uri;
14 public String name; 15 public String name;
16 public String id;
15 17
16 /** 18 /**
17 * @param isGroup 19 * @return if this Actor is a Group
18 * @param id
19 * @param uri
20 * @param name
21 */ 20 */
22 public Actor(boolean isGroup, String uri, String name) { 21 public abstract boolean isGroup();
23 super();
24 this.isGroup = isGroup;
25 this.uri = uri;
26 this.name = name;
27 }
28 22
29 /**
30 * @return the isGroup
31 */
32 public boolean isGroup() {
33 return isGroup;
34 }
35 /**
36 * @param isGroup the isGroup to set
37 */
38 public void setGroup(boolean isGroup) {
39 this.isGroup = isGroup;
40 }
41 /** 23 /**
42 * @return the uri 24 * @return the uri
43 */ 25 */
44 public String getUri() { 26 public String getUri() {
45 return uri; 27 return uri;
60 * @param name the name to set 42 * @param name the name to set
61 */ 43 */
62 public void setName(String name) { 44 public void setName(String name) {
63 this.name = name; 45 this.name = name;
64 } 46 }
47
48 /**
49 * @return the id
50 */
51 public String getId() {
52 return id;
53 }
54
55 /**
56 * Returns id as a String starting with "group:" for groups.
57 *
58 * @return
59 */
60 public abstract String getIdString();
61
62 /**
63 * @param id the id to set
64 */
65 public void setId(String id) {
66 this.id = id;
67 }
68
69 /**
70 * Returns a short id from an uri.
71 *
72 * @param uri
73 * @return
74 */
75 public static String getIdFromUri(String uri, boolean isGroup) {
76 String id = null;
77 String prefix = NS.MPIWG_PERSONS_URL;
78 if (isGroup) {
79 prefix = NS.MPIWG_GROUPS_URL;
80 }
81 if (uri != null && uri.startsWith(prefix)) {
82 id = uri.replace(prefix, "");
83 }
84 return id;
85 }
86
87 /**
88 * Returns an uri from a short id.
89 *
90 * @param id
91 * @return
92 */
93 public static String getUriFromId(String id, boolean isGroup) {
94 String uri = null;
95 String prefix = NS.MPIWG_PERSONS_URL;
96 if (isGroup) {
97 prefix = NS.MPIWG_GROUPS_URL;
98 }
99 if (id != null && ! id.startsWith("http://")) {
100 uri = prefix + id;
101 }
102 return uri;
103 }
104
65 } 105 }