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

Last change on this file since 10:90911b2da322 was 10:90911b2da322, checked in by casties, 12 years ago

more work on permissions...

File size: 2.0 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     * @param uri the uri to set
31     */
32    public void setUri(String uri) {
33        this.uri = uri;
34    }
35    /**
36     * @return the name
37     */
38    public String getName() {
39        return name;
40    }
41    /**
42     * @param name the name to set
43     */
44    public void setName(String name) {
45        this.name = name;
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
105}
Note: See TracBrowser for help on using the repository browser.