Project

General

Profile

1 1400 tao
/**
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$'
10
 *     '$Date$'
11
 * '$Revision$'
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 5089 daigle
package edu.ucsb.nceas.metacat.accesscontrol;
29 1400 tao
30
import java.util.Vector;
31 1543 tao
import java.util.Stack;
32 1400 tao
33 2663 sgarg
import org.apache.log4j.Logger;
34
35 5089 daigle
import edu.ucsb.nceas.metacat.NodeRecord;
36
import edu.ucsb.nceas.metacat.SubTree;
37
38 1400 tao
/**
39 2245 sgarg
 * A Class that represents an XML access rule. It include principal and
40 1400 tao
 * permission
41
 */
42 1539 tao
public class AccessSection extends SubTree
43 1400 tao
{
44 1539 tao
  //private String accessSectionId = null;
45 1400 tao
  private String permissionOrder = null;
46 4469 daigle
  private Vector<AccessRule> accessRules = new Vector<AccessRule>();
47 1472 tao
  private String references = null;
48 1539 tao
  private String controlLevel = null;
49 4469 daigle
  private Stack<NodeRecord> storedTmpNodeStack = null;
50
  private Vector<String> describedIdList = new Vector<String>();
51 2245 sgarg
  private long startedDescribesNodeId = -1;
52 4675 daigle
  private String dataFileName = null;
53 2663 sgarg
  private Logger logMetacat = Logger.getLogger(AccessSection.class);
54 2245 sgarg
55
56
    /**
57 1543 tao
     * Set a storedTempNodeStack
58
     */
59 4469 daigle
    public void setStoredTmpNodeStack(Stack<NodeRecord> myStack)
60 1543 tao
    {
61
      this.storedTmpNodeStack = myStack;
62
    }
63 2245 sgarg
64 1543 tao
    /**
65
     * Get storedTempNodeStack
66
     */
67 4469 daigle
    public Stack<NodeRecord> getStoredTmpNodeStack()
68 1543 tao
    {
69
      return this.storedTmpNodeStack;
70
    }
71 2245 sgarg
72
    /**
73 1539 tao
     * Set a controllevel
74
     */
75 2245 sgarg
    public void setControlLevel(String myLevel)
76 1400 tao
    {
77 1539 tao
      this.controlLevel = myLevel;
78 1400 tao
    }
79 2245 sgarg
80 1539 tao
    /**
81
     * Get controllevel
82
     */
83
    public String getControlLevel()
84 1400 tao
    {
85 1539 tao
      return this.controlLevel;
86 1400 tao
    }
87 2245 sgarg
88
   /**
89 1400 tao
     * Set a permissionOrder
90
     */
91 2245 sgarg
    public void setPermissionOrder(String myOrder)
92 1400 tao
    {
93
      this.permissionOrder = myOrder;
94
    }
95 2245 sgarg
96 1400 tao
    /**
97
     * Get permissionOrder
98
     */
99
    public String getPermissionOrder()
100
    {
101
      return this.permissionOrder;
102
    }
103 2245 sgarg
104 1403 tao
    /** Add an access rule */
105
    public void addAccessRule(AccessRule rule)
106 1400 tao
    {
107 1403 tao
      this.accessRules.addElement(rule);
108 1400 tao
    }
109 2245 sgarg
110 1403 tao
    /** Get all access rule */
111 4469 daigle
    public Vector<AccessRule> getAccessRules()
112 1400 tao
    {
113 1403 tao
      return this.accessRules;
114 1400 tao
    }
115 2245 sgarg
116 1472 tao
    /** Set a references */
117
    public void setReferences(String myReferences)
118
    {
119
      this.references = myReferences;
120
    }
121 2245 sgarg
122 1472 tao
    /** Get the references */
123
    public String getReferences()
124
    {
125
      return this.references;
126
    }
127 1539 tao
128 2245 sgarg
    /** Set a described id list (in data access part)*/
129 4469 daigle
    public void setDescribedIdList(Vector<String> list)
130 2245 sgarg
    {
131
      describedIdList = list;
132
    }
133
134
    /** Get a described id list */
135 4469 daigle
    public Vector<String> getDescribedIdList()
136 2245 sgarg
    {
137
      return describedIdList;
138
    }
139
140 4469 daigle
    /** Set the start "describes" node id*/
141
   public void setStartedDescribesNodeId(long id)
142 2245 sgarg
   {
143
     startedDescribesNodeId = id;
144
   }
145
146
   /** Get the start described id */
147
   public long getStartedDescribesNodeId()
148
   {
149
     return startedDescribesNodeId;
150
   }
151 4469 daigle
152 4675 daigle
   /** Set the dataFileName */
153
   public void setDataFileName(String fileName)
154 4469 daigle
   {
155 4675 daigle
     dataFileName = fileName;
156 4469 daigle
   }
157
158 4675 daigle
   /** Get the dataFileName */
159
   public String getDataFileName()
160 4469 daigle
   {
161 4675 daigle
     return dataFileName;
162 4469 daigle
   }
163 2245 sgarg
164 1406 tao
    /** Method to copy a accesssection object to a new one */
165 2245 sgarg
    public void copyPermOrderAndAccessRules(AccessSection newAccessSection)
166 1400 tao
    {
167 2245 sgarg
168 1406 tao
      // set parameters
169 2663 sgarg
      logMetacat.info("Copy permission order: " +
170 2589 sgarg
                                this.getPermissionOrder());
171 1406 tao
      newAccessSection.setPermissionOrder(this.getPermissionOrder());
172 4469 daigle
      Vector<AccessRule> accessRuleVector = this.getAccessRules();
173 1406 tao
      // 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 1400 tao
    }
180 2245 sgarg
181 1400 tao
}