View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" 
13   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License.
16   */
17  
18  package org.apache.jetspeed.prefs.impl;
19  
20  
21  import java.sql.Timestamp;
22  import java.util.Collection;
23  
24  import org.apache.jetspeed.prefs.om.Node;
25  
26  public class NodeImplProxy implements  Node
27  {
28      private Node node = null;
29      private boolean dirty = false;
30      private static PersistenceBrokerPreferencesProvider provider;
31  
32  
33      protected Object clone() throws CloneNotSupportedException
34  	{
35  		return super.clone();
36  	}
37  
38  	public Timestamp getCreationDate()
39  	{
40  		return getNode().getCreationDate();
41  		}
42  
43  	public String getFullPath()
44  	{
45  		return getNode().getFullPath();
46  	}
47  
48  	public Timestamp getModifiedDate()
49  	{
50  		return getNode().getModifiedDate();
51  	}
52  
53  	public long getNodeId()
54  	{
55  		return getNode().getNodeId();
56  	}
57  
58  	public Collection getNodeKeys()
59  	{
60  		return getNode().getNodeKeys();
61  	}
62  
63  	public String getNodeName()
64  	{
65  		return getNode().getNodeName();
66  	}
67  
68  	public Collection getNodeProperties()
69  	{
70  		return getNode().getNodeProperties();	
71  	}
72  
73  	public int getNodeType()
74  	{
75  		return getNode().getNodeType();
76  	}
77  
78  	public Long getParentNodeId()
79  	{
80  		return getNode().getParentNodeId();
81  	}
82  
83  	public void setCreationDate(Timestamp creationDate)
84  	{
85  		getNode().setCreationDate(creationDate);		
86  	}
87  
88  	public void setFullPath(String fullPath)
89  	{
90  		getNode().setFullPath(fullPath);		
91  	}
92  
93  	public void setModifiedDate(Timestamp modifiedDate)
94  	{
95  		getNode().setModifiedDate(modifiedDate);		
96  	}
97  
98  	public void setNodeId(long nodeId)
99  	{
100 		getNode().setNodeId(nodeId);		
101 	}
102 
103 	public void setNodeKeys(Collection nodeKeys)
104 	{
105 		getNode().setNodeKeys(nodeKeys);
106 	}
107 
108 	public void setNodeName(String nodeName)
109 	{
110 		getNode().setNodeName(nodeName);
111 		
112 	}
113 
114 	public void setNodeProperties(Collection nodeProperties)
115 	{
116 		getNode().setNodeProperties(nodeProperties);		
117 	}
118 
119 	public void setNodeType(int nodeType)
120 	{
121 		getNode().setNodeType(nodeType);		
122 	}
123 
124 	public void setParentNodeId(Long parentNodeId)
125 	{
126 		getNode().setParentNodeId(parentNodeId);
127 	}
128 
129 	public NodeImplProxy(Node node)
130     {
131         this.node = node;
132     }
133 
134     public static void setProvider(PersistenceBrokerPreferencesProvider p)
135     {
136     	provider = p;
137     }
138     
139     public Node getNode() 
140     {
141         if (dirty)
142         	reset();
143         return node;
144     }
145     
146 
147     protected void invalidate()
148     {
149         this.dirty = true;
150     }
151     
152     public void setNode(Node node)
153     {
154     	this.node = node;
155     }
156     protected void reset()
157     {
158     	try
159     	{
160     		provider.redoNode(this,node.getFullPath(), node.getNodeType());
161     		dirty = false;
162     	}
163     	catch (Exception e)
164     	{
165     		e.printStackTrace();
166     		node = null;
167     	}
168     }
169     
170 
171 }