source: AnnotationManagerN4J/src/main/java/de/mpiwg/itgroup/annotations/Actor.java @ 13:abe25edf2178

Last change on this file since 13:abe25edf2178 was 13:abe25edf2178, checked in by casties, 12 years ago

storing and retrieving permissions works now.

File size: 2.2 KB
Line 
1/**
2 *
3 */
4package de.mpiwg.itgroup.annotations;
5
6import de.mpiwg.itgroup.annotations.old.NS;
7
8/**
9 * @author casties
10 *
11 */
12public abstract class Actor {
13
14    public String uri;
15    public String name;
16    public String id;
17   
18    /**
19     * @return if this Actor is a Group
20     */
21    public abstract boolean isGroup();
22   
23    /**
24     * @return the uri
25     */
26    public String getUri() {
27        return uri;
28    }
29
30    /**
31     * Returns the uri (uses id if empty).
32     *
33     * @return the uri
34     */
35    public String getUriString() {
36        if (uri == null) {
37                return getUriFromId(id, isGroup());
38        }
39        return uri;
40    }
41
42    /**
43     * @param uri the uri to set
44     */
45    public void setUri(String uri) {
46        this.uri = uri;
47    }
48    /**
49     * @return the name
50     */
51    public String getName() {
52        return name;
53    }
54    /**
55     * @param name the name to set
56     */
57    public void setName(String name) {
58        this.name = name;
59    }
60
61    /**
62     * @return the id
63     */
64    public String getId() {
65        return id;
66    }
67   
68    /**
69     * Returns id as a String starting with "group:" for groups.
70     *
71     * @return
72     */
73    public abstract String getIdString();
74   
75    /**
76     * @param id the id to set
77     */
78    public void setId(String id) {
79        this.id = id;
80    }
81   
82    /**
83     * Returns a short id from an uri.
84     *
85     * @param uri
86     * @return
87     */
88    public static String getIdFromUri(String uri, boolean isGroup) {
89        String id = null;
90        String prefix = NS.MPIWG_PERSONS_URL;
91        if (isGroup) {
92            prefix = NS.MPIWG_GROUPS_URL;
93        }
94        if (uri != null && uri.startsWith(prefix)) {
95            id = uri.replace(prefix, "");
96        }
97        return id;
98    }
99
100    /**
101     * Returns an uri from a short id.
102     *
103     * @param id
104     * @return
105     */
106    public static String getUriFromId(String id, boolean isGroup) {
107        String uri = null;
108        String prefix = NS.MPIWG_PERSONS_URL;
109        if (isGroup) {
110            prefix = NS.MPIWG_GROUPS_URL;
111        }
112        if (id != null && ! id.startsWith("http://")) {
113            uri = prefix + id; 
114        }
115        return uri;
116    }
117
118}
Note: See TracBrowser for help on using the repository browser.