KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jcr > Session


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package javax.jcr;
31
32 import org.xml.sax.ContentHandler JavaDoc;
33 import org.xml.sax.SAXException JavaDoc;
34
35 import javax.jcr.lock.LockException;
36 import javax.jcr.nodetype.ConstraintViolationException;
37 import javax.jcr.nodetype.NoSuchNodeTypeException;
38 import javax.jcr.version.VersionException;
39 import java.io.IOException JavaDoc;
40 import java.io.InputStream JavaDoc;
41 import java.io.OutputStream JavaDoc;
42
43 /**
44  * Represents an open session to a Repository workspace.
45  */

46 public interface Session {
47   /**
48    * Returns the owning repository.
49    */

50   public Repository getRepository();
51
52   /**
53    * Returns the user who opened this session.
54    */

55   public String JavaDoc getUserID();
56
57   /**
58    * Returns a session attribute.
59    *
60    * @param name the session attribute name
61    */

62   public Object JavaDoc getAttribute(String JavaDoc name);
63
64   /**
65    * Returns an array of the session attribute names.
66    */

67   public String JavaDoc[] getAttributeNames();
68
69   /**
70    * Returns the repository's workspace for this session.
71    */

72   public Workspace getWorkspace();
73
74   /**
75    * Create a new session with the new credentials.
76    *
77    * @param credentials security credentials for the new sessions.
78    */

79   public Session impersonate(Credentials credentials)
80     throws LoginException, RepositoryException;
81
82   /**
83    * Returns the session's root node.
84    */

85   public Node getRootNode()
86     throws RepositoryException;
87
88   /**
89    * Finds a node by its UUID
90    *
91    * @param uuid the node's UUID.
92    */

93   public Node getNodeByUUID(String JavaDoc uuid)
94     throws ItemNotFoundException,
95        RepositoryException;
96
97   /**
98    * Returns an item based on an absolute path.
99    *
100    * @param absPath the path locating the item.
101    *
102    * @throws PathNotFoundException if the path does not name an item
103    */

104   public Item getItem(String JavaDoc absPath)
105     throws PathNotFoundException,
106        RepositoryException;
107
108   /**
109    * Returns true if the item named by the path exists.
110    *
111    * @param absPath a path locating the item.
112    */

113   public boolean itemExists(String JavaDoc absPath)
114     throws RepositoryException;
115
116   /**
117    * Moves the node given by the source path to the destination path.
118    *
119    * @param srcAbsPath the absolute path name of the source node
120    * @param destAbsPath the absolute path name of the destination node
121    */

122   public void move(String JavaDoc srcAbsPath, String JavaDoc destAbsPath)
123     throws ItemExistsException,
124        PathNotFoundException,
125        VersionException,
126        ConstraintViolationException,
127        LockException,
128        RepositoryException;
129
130   /**
131    * Saves changes to the workspace.
132    */

133   public void save()
134     throws AccessDeniedException,
135        ItemExistsException,
136        ConstraintViolationException,
137        InvalidItemStateException,
138        VersionException, LockException,
139        NoSuchNodeTypeException,
140        RepositoryException;
141
142   /**
143    * Updates changes from the repository.
144    */

145   public void refresh(boolean keepChanges)
146     throws RepositoryException;
147
148   /**
149    * Returns true if the session has changes.
150    */

151   public boolean hasPendingChanges()
152     throws RepositoryException;
153
154   /**
155    * Returns the session's value factory.
156    */

157   public ValueFactory getValueFactory()
158     throws UnsupportedRepositoryOperationException,
159        RepositoryException;
160
161   /**
162    * Checks if the session can perform the given actions for the path.
163    *
164    * @param absPath absolute path to a node.
165    * @param actions actions attempted on the node.
166    */

167   public void checkPermission(String JavaDoc absPath, String JavaDoc actions)
168     throws java.security.AccessControlException JavaDoc,
169        RepositoryException;
170
171   /**
172    * Returns a SAX ContentHandler to important data.
173    *
174    * @param parentAbsPath the absolute path of the parent node
175    */

176   public ContentHandler JavaDoc getImportContentHandler(String JavaDoc parentAbsPath,
177                         int uuidBehavior)
178     throws PathNotFoundException,
179        ConstraintViolationException,
180        VersionException,
181        LockException,
182        RepositoryException;
183
184   /**
185    * Import data based on an XML stream.
186    *
187    * @param parentAbsPath path to the node which will be the data's parent.
188    * @param in InputStream to the XML data
189    */

190   public void importXML(String JavaDoc parentAbsPath,
191             InputStream JavaDoc in,
192             int uuidBehavior)
193     throws IOException JavaDoc,
194        PathNotFoundException,
195        ItemExistsException,
196        ConstraintViolationException,
197        VersionException,
198        InvalidSerializedDataException,
199        LockException,
200        RepositoryException;
201
202   /**
203    * Exports XML data from the given node based on the system view.
204    *
205    * @param absPath path to the node serving as root to export
206    * @param contentHandler SAX ContentHandler to receive the XML
207    */

208   public void exportSystemView(String JavaDoc absPath,
209                    ContentHandler JavaDoc contentHandler,
210                    boolean skipBinary,
211                    boolean noRecurse)
212     throws PathNotFoundException,
213        SAXException JavaDoc,
214        RepositoryException;
215   
216   /**
217    * Exports XML data from the given node based on the system view.
218    *
219    * @param absPath path to the node serving as root to export
220    * @param out OutputStream to receive the XML
221    */

222   public void exportSystemView(String JavaDoc absPath,
223                    OutputStream JavaDoc out,
224                    boolean skipBinary,
225                    boolean noRecurse)
226     throws IOException JavaDoc,
227        PathNotFoundException,
228        RepositoryException;
229   
230   /**
231    * Exports XML data from the given node based on the document view.
232    *
233    * @param absPath path to the node serving as root to export
234    * @param out OutputStream to receive the XML
235    */

236   public void exportDocumentView(String JavaDoc absPath,
237                  ContentHandler JavaDoc contentHandler,
238                  boolean skipBinary,
239                  boolean noRecurse)
240     throws PathNotFoundException,
241        SAXException JavaDoc,
242        RepositoryException;
243   
244   /**
245    * Exports XML data from the given node based on the document view.
246    *
247    * @param absPath path to the node serving as root to export
248    * @param out OutputStream to receive the XML
249    */

250   public void exportDocumentView(String JavaDoc absPath,
251                  OutputStream JavaDoc out,
252                  boolean skipBinary,
253                  boolean noRecurse)
254     throws IOException JavaDoc,
255        PathNotFoundException,
256        RepositoryException;
257   
258   /**
259    * Exports XML data from the given node based on the document view.
260    *
261    * @param absPath path to the node serving as root to export
262    * @param out OutputStream to receive the XML
263    */

264   public void setNamespacePrefix(String JavaDoc newPrefix,
265                  String JavaDoc existingUri)
266     throws NamespaceException,
267        RepositoryException;
268   
269   /**
270    * Returns the session's namespace prefixes.
271    */

272   public String JavaDoc[] getNamespacePrefixes()
273     throws RepositoryException;
274   
275   /**
276    * Returns the URI for a given namespace prefix.
277    */

278   public String JavaDoc getNamespaceURI(String JavaDoc prefix)
279     throws NamespaceException,
280        RepositoryException;
281   
282   /**
283    * Returns the prefix for a given URI.
284    */

285   public String JavaDoc getNamespacePrefix(String JavaDoc uri)
286     throws NamespaceException,
287        RepositoryException;
288   
289   /**
290    * Close the session.
291    */

292   public void logout();
293   
294   /**
295    * Return true if the session is active.
296    */

297   public boolean isLive();
298   
299   /**
300    * Adds a lock token.
301    */

302   public void addLockToken(String JavaDoc lt)
303     throws LockException,
304        RepositoryException;
305   
306   /**
307    * Returns the current lock tokens.
308    */

309   public String JavaDoc[] getLockTokens();
310   
311   /**
312    * Removes the named lock token.
313    */

314   public void removeLockToken(String JavaDoc lt);
315 }
316
Popular Tags