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-10-10 11:06:55 -0700 (Mon, 10 Oct 2005) $'
12
 * '$Revision: 2663 $'
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
import org.apache.log4j.Logger;
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
  private Logger logMetacat = Logger.getLogger(AccessRule.class);
43
  
44
  /** Set the permssionType */
45
  public void setPermissionType(String type)
46
  {
47
    permissionType = type;
48
  }
49
  
50
  public String getPermissionType()
51
  {
52
     return permissionType;
53
  }
54
    
55
  /** Set the a principle */
56
  public void addPrincipal(String newPrincipal) 
57
  {
58
    this.principal.addElement(newPrincipal);
59
  }
60

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

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