01: /**
02: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
03: *
04: * Permission is hereby granted, free of charge, to any person obtaining a copy
05: * of this software and associated documentation files (the "Software"), to deal
06: * in the Software without restriction, including without limitation the rights
07: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
08: * copies of the Software, and to permit persons to whom the Software is
09: * furnished to do so, subject to the following conditions:
10: *
11: * The above copyright notice and this permission notice shall be included in
12: * all copies or substantial portions of the Software.
13: *
14: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20: * SOFTWARE.
21: */package com.liferay.portlet.wiki.util;
22:
23: import com.efsol.friki.BasicDriver;
24:
25: import com.liferay.portlet.wiki.service.WikiPageLocalServiceUtil;
26:
27: import java.util.HashMap;
28: import java.util.Iterator;
29: import java.util.Map;
30:
31: import org.stringtree.util.tract.Tract;
32:
33: /**
34: * <a href="NodeRepository.java.html"><b><i>View Source</i></b></a>
35: *
36: * @author Brian Wing Shun Chan
37: *
38: */
39: public class NodeRepository extends BasicDriver {
40:
41: public NodeRepository(long nodeId) {
42: _nodeId = nodeId;
43: _names = new HashMap();
44: }
45:
46: public Tract get(String name) {
47: return null;
48: }
49:
50: public void put(String name, Tract page) {
51: }
52:
53: public String backup(String name) {
54: return name;
55: }
56:
57: public boolean contains(String name) {
58: boolean exists = false;
59:
60: try {
61: Boolean existsObj = (Boolean) _names.get(name);
62:
63: if (existsObj == null) {
64: if (WikiPageLocalServiceUtil.getPagesCount(_nodeId,
65: name, true) > 0) {
66:
67: existsObj = Boolean.TRUE;
68: } else {
69: existsObj = Boolean.FALSE;
70: }
71:
72: _names.put(name, existsObj);
73: }
74:
75: exists = existsObj.booleanValue();
76: } catch (Exception e) {
77: e.printStackTrace();
78: }
79:
80: return exists;
81: }
82:
83: public Iterator allPageNames() {
84: return _names.keySet().iterator();
85: }
86:
87: public Map getTitles() {
88: return _names;
89: }
90:
91: private long _nodeId;
92: private Map _names;
93:
94: }
|