Ignore:
Timestamp:
Jul 12, 2012, 3:01:32 PM (12 years ago)
Author:
casties
Branch:
default
Message:

more work on permissions...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/de/mpiwg/itgroup/annotations/Actor.java

    r9 r10  
    44package de.mpiwg.itgroup.annotations;
    55
     6import de.mpiwg.itgroup.annotations.old.NS;
     7
    68/**
    79 * @author casties
    810 *
    911 */
    10 public class Actor {
     12public abstract class Actor {
    1113
    12     public boolean isGroup;
    1314    public String uri;
    1415    public String name;
     16    public String id;
    1517   
    1618    /**
    17      * @param isGroup
    18      * @param id
    19      * @param uri
    20      * @param name
     19     * @return if this Actor is a Group
    2120     */
    22     public Actor(boolean isGroup, String uri, String name) {
    23         super();
    24         this.isGroup = isGroup;
    25         this.uri = uri;
    26         this.name = name;
    27     }
     21    public abstract boolean isGroup();
    2822   
    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     }
    4123    /**
    4224     * @return the uri
     
    6345        this.name = name;
    6446    }
     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
    65105}
Note: See TracChangeset for help on using the changeset viewer.