1 /***************************************************************************
2 * Copyright (C) 2003-2009 eXo Platform SAS.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Affero General Public License
6 * as published by the Free Software Foundation; either version 3
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see<http://www.gnu.org/licenses/>.
16 *
17 **************************************************************************/
18 package org.exoplatform.services.cms.link;
19
20 import javax.jcr.Item;
21 import javax.jcr.Node;
22 import javax.jcr.PathNotFoundException;
23 import javax.jcr.RepositoryException;
24 import javax.jcr.Session;
25
26 /**
27 * Finds a node with a given path.
28 * If the node path contains sub-paths to exo:symlink nodes,
29 * the real link node will be found.
30 *
31 * @LevelAPI Experimental
32 */
33 public interface NodeFinder {
34
35 /**
36 * Gets a node at the relative path related to the ancestor node.
37 *
38 * @param ancestorNode The ancestor node.
39 * @param relativePath The relative path.
40 * @throws PathNotFoundException if no node exists at the specified path.
41 * @throws RepositoryException if another error occurs.
42 */
43 public Node getNode(Node ancestorNode, String relativePath) throws PathNotFoundException,
44 RepositoryException;
45
46 /**
47 * Gets a node at the relative path related to the ancestor node.
48 *
49 * @param ancestorNode The ancestor node.
50 * @param relativePath The relative path.
51 * @param giveTarget If the node is link and giveTarget has been set to "true",
52 * the target node will be returned.
53 * @throws PathNotFoundException if no node exists at the specified path.
54 * @throws RepositoryException if another error occurs.
55 */
56 public Node getNode(Node ancestorNode, String relativePath, boolean giveTarget) throws PathNotFoundException,
57 RepositoryException;
58
59 /**
60 * Gets an item at the specified absolute path.
61 *
62 * @param workspace The workspace name.
63 * @param absPath The absolute path.
64 * @throws PathNotFoundException if the specified path cannot be found.
65 * @throws RepositoryException if another error occurs.
66 */
67 public Item getItem(String workspace, String absPath) throws PathNotFoundException,
68 RepositoryException;
69
70 /**
71 * Gets an item at the specified absolute path.
72 *
73 * @param workspace The workspace name.
74 * @param absPath The absolute path.
75 * @param system If "true", the system session is used. If "false", the user session is used.
76 * @throws PathNotFoundException if the specified path cannot be found.
77 * @throws RepositoryException if another error occurs.
78 */
79 public Item getItemSys(String workspace, String absPath, boolean system) throws PathNotFoundException,
80 RepositoryException;
81
82 /**
83 * Gets an item at the specified absolute path.
84 *
85 * @param workspace The workspace name.
86 * @param absPath The absolute path.
87 * @param giveTarget If the item is link and giveTarget has been
88 * set to "true", the target node will be returned.
89 * @throws PathNotFoundException if the specified path cannot be found.
90 * @throws RepositoryException if another error occurs.
91 */
92 public Item getItem(String workspace, String absPath, boolean giveTarget) throws PathNotFoundException,
93 RepositoryException;
94
95 /**
96 * Gets an item at the specified absolute path.
97 *
98 * @param workspace The workspace name.
99 * @param absPath The absolute path.
100 * @param giveTarget If the item is link and giveTarget has been set to "true",
101 * the target node will be returned.
102 * @param system If "true", the system session is used. If "false", the user session is used.
103 * @throws PathNotFoundException if the specified path cannot be found.
104 * @throws RepositoryException if another error occurs.
105 */
106 public Item getItemGiveTargetSys(String workspace,
107 String absPath,
108 boolean giveTarget,
109 boolean system) throws PathNotFoundException,
110 RepositoryException;
111
112 /**
113 * Gets an item at the specified absolute path.
114 *
115 * @param session The session that is used to get the item.
116 * @param absPath The absolute path.
117 * @throws PathNotFoundException if the specified path cannot be found.
118 * @throws RepositoryException if another error occurs.
119 */
120 public Item getItem(Session session, String absPath) throws PathNotFoundException,
121 RepositoryException;
122
123 /**
124 * Gets an item at the specified absolute path.
125 *
126 * @param session The session is used to get the item.
127 * @param absPath The absolute path.
128 * @param giveTarget If the item is link and giveTarget has been set to "true",
129 * the target node will be returned.
130 * @throws PathNotFoundException if the specified path cannot be found.
131 * @throws RepositoryException if another error occurs.
132 */
133 public Item getItem(Session session, String absPath, boolean giveTarget) throws PathNotFoundException,
134 RepositoryException;
135
136 /**
137 * Gets an item at the specified absolute path.
138 *
139 * @param session The session which is used to get the item.
140 * @param absPath The absolute path.
141 * @param giveTarget If the item is link and giveTarget has been set to "true",
142 * the target node will be returned.
143 * @param system If "true", the system session is used. If "false", the user session is used.
144 * @throws PathNotFoundException if the specified path cannot be found.
145 * @throws RepositoryException if another error occurs.
146 */
147 public Item getItemTarget(Session session, String absPath, boolean giveTarget, boolean system) throws PathNotFoundException,
148 RepositoryException;
149
150 /**
151 * Checks if an item exists at the specified absolute path.
152 *
153 * @param session The session that is used to get the item.
154 * @param absPath The absolute path.
155 * @return "True" if the item exists at the absolute path.
156 * "False" if the item does not exist or the specified absolute path is malformed.
157 * @throws RepositoryException if an error occurs.
158 */
159 public boolean itemExists(Session session, String absPath) throws RepositoryException;
160 }