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
 *
9
 *   '$Author: daigle $'
10
 *     '$Date: 2009-10-16 11:10:05 -0700 (Fri, 16 Oct 2009) $'
11
 * '$Revision: 5089 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27

    
28
package edu.ucsb.nceas.metacat.accesscontrol;
29

    
30
import java.util.Vector;
31
import java.util.Stack;
32

    
33
import org.apache.log4j.Logger;
34

    
35
import edu.ucsb.nceas.metacat.NodeRecord;
36
import edu.ucsb.nceas.metacat.SubTree;
37

    
38
/**
39
 * A Class that represents an XML access rule. It include principal and
40
 * permission
41
 */
42
public class AccessSection extends SubTree
43
{
44
  //private String accessSectionId = null;
45
  private String permissionOrder = null;
46
  private Vector<AccessRule> accessRules = new Vector<AccessRule>();
47
  private String references = null;
48
  private String controlLevel = null;
49
  private Stack<NodeRecord> storedTmpNodeStack = null;
50
  private Vector<String> describedIdList = new Vector<String>();
51
  private long startedDescribesNodeId = -1;
52
  private String dataFileName = null;
53
  private Logger logMetacat = Logger.getLogger(AccessSection.class);
54

    
55

    
56
    /**
57
     * Set a storedTempNodeStack
58
     */
59
    public void setStoredTmpNodeStack(Stack<NodeRecord> myStack)
60
    {
61
      this.storedTmpNodeStack = myStack;
62
    }
63

    
64
    /**
65
     * Get storedTempNodeStack
66
     */
67
    public Stack<NodeRecord> getStoredTmpNodeStack()
68
    {
69
      return this.storedTmpNodeStack;
70
    }
71

    
72
    /**
73
     * Set a controllevel
74
     */
75
    public void setControlLevel(String myLevel)
76
    {
77
      this.controlLevel = myLevel;
78
    }
79

    
80
    /**
81
     * Get controllevel
82
     */
83
    public String getControlLevel()
84
    {
85
      return this.controlLevel;
86
    }
87

    
88
   /**
89
     * Set a permissionOrder
90
     */
91
    public void setPermissionOrder(String myOrder)
92
    {
93
      this.permissionOrder = myOrder;
94
    }
95

    
96
    /**
97
     * Get permissionOrder
98
     */
99
    public String getPermissionOrder()
100
    {
101
      return this.permissionOrder;
102
    }
103

    
104
    /** Add an access rule */
105
    public void addAccessRule(AccessRule rule)
106
    {
107
      this.accessRules.addElement(rule);
108
    }
109

    
110
    /** Get all access rule */
111
    public Vector<AccessRule> getAccessRules()
112
    {
113
      return this.accessRules;
114
    }
115

    
116
    /** Set a references */
117
    public void setReferences(String myReferences)
118
    {
119
      this.references = myReferences;
120
    }
121

    
122
    /** Get the references */
123
    public String getReferences()
124
    {
125
      return this.references;
126
    }
127

    
128
    /** Set a described id list (in data access part)*/
129
    public void setDescribedIdList(Vector<String> list)
130
    {
131
      describedIdList = list;
132
    }
133

    
134
    /** Get a described id list */
135
    public Vector<String> getDescribedIdList()
136
    {
137
      return describedIdList;
138
    }
139

    
140
    /** Set the start "describes" node id*/
141
   public void setStartedDescribesNodeId(long id)
142
   {
143
     startedDescribesNodeId = id;
144
   }
145

    
146
   /** Get the start described id */
147
   public long getStartedDescribesNodeId()
148
   {
149
     return startedDescribesNodeId;
150
   }
151
   
152
   /** Set the dataFileName */
153
   public void setDataFileName(String fileName)
154
   {
155
     dataFileName = fileName;
156
   }
157
   
158
   /** Get the dataFileName */
159
   public String getDataFileName()
160
   {
161
     return dataFileName;
162
   }
163

    
164
    /** Method to copy a accesssection object to a new one */
165
    public void copyPermOrderAndAccessRules(AccessSection newAccessSection)
166
    {
167

    
168
      // set parameters
169
      logMetacat.info("Copy permission order: " +
170
                                this.getPermissionOrder());
171
      newAccessSection.setPermissionOrder(this.getPermissionOrder());
172
      Vector<AccessRule> accessRuleVector = this.getAccessRules();
173
      // go through access rule vector
174
      for (int i=0; i< accessRuleVector.size(); i++)
175
      {
176
        AccessRule access = (AccessRule)accessRuleVector.elementAt(i);
177
        newAccessSection.addAccessRule(access);
178
      }
179
    }
180

    
181
}
(6-6/9)