Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A Class that represents an XML Text node and its contents,
4
 *             and can build itself from a database connection
5
 *  Copyright: 2000 Regents of the University of California and the
6
 *             National Center for Ecological Analysis and Synthesis
7
 *    Authors: Matt Jones
8
 *    Release: @release@
9
 *
10
 *   '$Author: sgarg $'
11
 *     '$Date: 2005-09-09 13:51:35 -0700 (Fri, 09 Sep 2005) $'
12
 * '$Revision: 2588 $'
13
 *
14
 * This program is free software; you can redistribute it and/or modify
15
 * it under the terms of the GNU General Public License as published by
16
 * the Free Software Foundation; either version 2 of the License, or
17
 * (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
 */
28

    
29
package edu.ucsb.nceas.metacat;
30

    
31
import java.util.Vector;
32

    
33
/**
34
 * A Class that represents an XML access rule. It include principal and 
35
 * permission
36
 */
37
public class AccessRule
38
{
39
  private String permissionType = null;
40
  private Vector principal = new Vector();
41
  private int permission = 0;
42
  
43
  /** Set the permssionType */
44
  public void setPermissionType(String type)
45
  {
46
    permissionType = type;
47
  }
48
  
49
  public String getPermissionType()
50
  {
51
     return permissionType;
52
  }
53
    
54
  /** Set the a principle */
55
  public void addPrincipal(String newPrincipal) 
56
  {
57
    this.principal.addElement(newPrincipal);
58
  }
59

    
60
  /** Get the principle vector */
61
  public Vector getPrincipal() 
62
  {
63
    return principal;
64
  }
65

    
66
  /** 
67
   * Set a permission. 
68
   */
69
  public void setPermission(int myPermission) 
70
  {
71
    permission = myPermission;
72
  }
73
    
74
  /**
75
   * Get permission
76
   */
77
  public int getPermission()
78
  {
79
    return permission;
80
  }
81
  
82
  /**
83
   * Copy a AccessRule to another accessrule object
84
   */
85
  public Object clone()
86
  {
87
    // create a new object
88
    AccessRule newRule = new AccessRule();
89
    // set permissiontype
90
    MetaCatUtil.logMetacat.info("copy permission type: "+
91
                              this.getPermissionType());
92
    newRule.setPermissionType(this.getPermissionType());
93
    // set permission
94
    MetaCatUtil.logMetacat.info("copy permission: "+
95
                              this.getPermission());
96
    newRule.setPermission(this.getPermission());
97
    // walk through all the principals
98
    Vector principalVector = this.getPrincipal();
99
    for (int i=0; i<principalVector.size(); i++)
100
    {
101
      String name = (String)principalVector.elementAt(i);
102
      MetaCatUtil.logMetacat.info("copy principle: "+ name);
103
      // Add this name to newrules
104
      newRule.addPrincipal(name);
105
    }
106
    return newRule;
107
  }
108
  
109
 
110
}//AccessRule
(4-4/63)