001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS"
013: * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.jetspeed.prefs.impl;
019:
020: import java.sql.Timestamp;
021: import java.util.Collection;
022:
023: import org.apache.jetspeed.prefs.om.Node;
024:
025: public class NodeImplProxy implements Node {
026: private Node node = null;
027: private boolean dirty = false;
028: private static PersistenceBrokerPreferencesProvider provider;
029:
030: protected Object clone() throws CloneNotSupportedException {
031: return super .clone();
032: }
033:
034: public Timestamp getCreationDate() {
035: return getNode().getCreationDate();
036: }
037:
038: public String getFullPath() {
039: return getNode().getFullPath();
040: }
041:
042: public Timestamp getModifiedDate() {
043: return getNode().getModifiedDate();
044: }
045:
046: public long getNodeId() {
047: return getNode().getNodeId();
048: }
049:
050: public Collection getNodeKeys() {
051: return getNode().getNodeKeys();
052: }
053:
054: public String getNodeName() {
055: return getNode().getNodeName();
056: }
057:
058: public Collection getNodeProperties() {
059: return getNode().getNodeProperties();
060: }
061:
062: public int getNodeType() {
063: return getNode().getNodeType();
064: }
065:
066: public Long getParentNodeId() {
067: return getNode().getParentNodeId();
068: }
069:
070: public void setCreationDate(Timestamp creationDate) {
071: getNode().setCreationDate(creationDate);
072: }
073:
074: public void setFullPath(String fullPath) {
075: getNode().setFullPath(fullPath);
076: }
077:
078: public void setModifiedDate(Timestamp modifiedDate) {
079: getNode().setModifiedDate(modifiedDate);
080: }
081:
082: public void setNodeId(long nodeId) {
083: getNode().setNodeId(nodeId);
084: }
085:
086: public void setNodeKeys(Collection nodeKeys) {
087: getNode().setNodeKeys(nodeKeys);
088: }
089:
090: public void setNodeName(String nodeName) {
091: getNode().setNodeName(nodeName);
092:
093: }
094:
095: public void setNodeProperties(Collection nodeProperties) {
096: getNode().setNodeProperties(nodeProperties);
097: }
098:
099: public void setNodeType(int nodeType) {
100: getNode().setNodeType(nodeType);
101: }
102:
103: public void setParentNodeId(Long parentNodeId) {
104: getNode().setParentNodeId(parentNodeId);
105: }
106:
107: public NodeImplProxy(Node node) {
108: this .node = node;
109: }
110:
111: public static void setProvider(
112: PersistenceBrokerPreferencesProvider p) {
113: provider = p;
114: }
115:
116: public Node getNode() {
117: if (dirty)
118: reset();
119: return node;
120: }
121:
122: protected void invalidate() {
123: this .dirty = true;
124: }
125:
126: public void setNode(Node node) {
127: this .node = node;
128: }
129:
130: protected void reset() {
131: try {
132: provider.redoNode(this , node.getFullPath(), node
133: .getNodeType());
134: dirty = false;
135: } catch (Exception e) {
136: e.printStackTrace();
137: node = null;
138: }
139: }
140:
141: }
|