KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jcr > base > BaseSession


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 com.caucho.jcr.base;
31
32 import org.xml.sax.ContentHandler JavaDoc;
33 import org.xml.sax.SAXException JavaDoc;
34
35 import javax.jcr.*;
36 import javax.jcr.lock.LockException;
37 import javax.jcr.nodetype.ConstraintViolationException;
38 import javax.jcr.nodetype.NoSuchNodeTypeException;
39 import javax.jcr.version.VersionException;
40 import java.io.IOException JavaDoc;
41 import java.io.InputStream JavaDoc;
42 import java.io.OutputStream JavaDoc;
43
44 /**
45  * Represents an open session to a Repository workspace.
46  */

47 abstract public class BaseSession implements Session {
48   private boolean _isActive = true;
49   
50   /**
51    * Returns the owning repository.
52    */

53   abstract public Repository getRepository();
54
55   /**
56    * Returns the user who opened this session.
57    */

58   public String JavaDoc getUserID()
59   {
60     return null;
61   }
62
63   /**
64    * Returns a session attribute.
65    *
66    * @param name the session attribute name
67    */

68   public Object JavaDoc getAttribute(String JavaDoc name)
69   {
70     return null;
71   }
72
73   /**
74    * Returns an array of the session attribute names.
75    */

76   public String JavaDoc[] getAttributeNames()
77   {
78     return new String JavaDoc[0];
79   }
80
81   /**
82    * Returns the repository's workspace for this session.
83    */

84   public Workspace getWorkspace()
85   {
86     throw new UnsupportedOperationException JavaDoc();
87   }
88
89   /**
90    * Create a new session with the new credentials.
91    *
92    * @param credentials security credentials for the new sessions.
93    */

94   public Session impersonate(Credentials credentials)
95     throws LoginException, RepositoryException
96   {
97     throw new UnsupportedRepositoryOperationException(getClass().getName());
98   }
99
100   /**
101    * Returns the session's root node.
102    */

103   abstract public Node getRootNode()
104     throws RepositoryException;
105
106   /**
107    * Finds a node by its UUID
108    *
109    * @param uuid the node's UUID.
110    */

111   public Node getNodeByUUID(String JavaDoc uuid)
112     throws ItemNotFoundException,
113        RepositoryException
114   {
115     throw new UnsupportedRepositoryOperationException(getClass().getName());
116   }
117
118   /**
119    * Returns an item based on an absolute path.
120    *
121    * @param absPath the path locating the item.
122    *
123    * @throws PathNotFoundException if the path does not name an item
124    */

125   public Item getItem(String JavaDoc absPath)
126     throws PathNotFoundException,
127        RepositoryException
128   {
129     throw new UnsupportedRepositoryOperationException(getClass().getName());
130   }
131
132   /**
133    * Returns true if the item named by the path exists.
134    *
135    * @param absPath a path locating the item.
136    */

137   public boolean itemExists(String JavaDoc absPath)
138     throws RepositoryException
139   {
140     try {
141       return getItem(absPath) != null;
142     } catch (PathNotFoundException e) {
143       return false;
144     }
145   }
146
147   /**
148    * Moves the node given by the source path to the destination path.
149    *
150    * @param srcAbsPath the absolute path name of the source node
151    * @param destAbsPath the absolute path name of the destination node
152    */

153   public void move(String JavaDoc srcAbsPath, String JavaDoc destAbsPath)
154     throws ItemExistsException,
155        PathNotFoundException,
156        VersionException,
157        ConstraintViolationException,
158        LockException,
159        RepositoryException
160   {
161     throw new UnsupportedRepositoryOperationException(getClass().getName());
162   }
163
164   /**
165    * Saves changes to the workspace.
166    */

167   public void save()
168     throws AccessDeniedException,
169        ItemExistsException,
170        ConstraintViolationException,
171        InvalidItemStateException,
172        VersionException, LockException,
173        NoSuchNodeTypeException,
174        RepositoryException
175   {
176     throw new UnsupportedRepositoryOperationException(getClass().getName());
177   }
178
179   /**
180    * Updates changes from the repository.
181    */

182   public void refresh(boolean keepChanges)
183     throws RepositoryException
184   {
185     throw new UnsupportedRepositoryOperationException(getClass().getName());
186   }
187
188   /**
189    * Returns true if the session has changes.
190    */

191   public boolean hasPendingChanges()
192     throws RepositoryException
193   {
194     return false;
195   }
196
197   /**
198    * Returns the session's value factory.
199    */

200   public ValueFactory getValueFactory()
201     throws UnsupportedRepositoryOperationException,
202        RepositoryException
203   {
204     throw new UnsupportedRepositoryOperationException(getClass().getName());
205   }
206
207   /**
208    * Checks if the session can perform the given actions for the path.
209    *
210    * @param absPath absolute path to a node.
211    * @param actions actions attempted on the node.
212    */

213   public void checkPermission(String JavaDoc absPath, String JavaDoc actions)
214     throws java.security.AccessControlException JavaDoc,
215        RepositoryException
216   {
217   }
218
219   /**
220    * Returns a SAX ContentHandler to important data.
221    *
222    * @param parentAbsPath the absolute path of the parent node
223    */

224   public ContentHandler JavaDoc getImportContentHandler(String JavaDoc parentAbsPath,
225                         int uuidBehavior)
226     throws PathNotFoundException,
227        ConstraintViolationException,
228        VersionException,
229        LockException,
230        RepositoryException
231   {
232     throw new UnsupportedRepositoryOperationException(getClass().getName());
233   }
234
235   /**
236    * Import data based on an XML stream.
237    *
238    * @param parentAbsPath path to the node which will be the data's parent.
239    * @param in InputStream to the XML data
240    */

241   public void importXML(String JavaDoc parentAbsPath,
242             InputStream JavaDoc in,
243             int uuidBehavior)
244     throws IOException JavaDoc,
245        PathNotFoundException,
246        ItemExistsException,
247        ConstraintViolationException,
248        VersionException,
249        InvalidSerializedDataException,
250        LockException,
251        RepositoryException
252   {
253     throw new UnsupportedRepositoryOperationException(getClass().getName());
254   }
255
256   /**
257    * Exports XML data from the given node based on the system view.
258    *
259    * @param absPath path to the node serving as root to export
260    * @param contentHandler SAX ContentHandler to receive the XML
261    */

262   public void exportSystemView(String JavaDoc absPath,
263                    ContentHandler JavaDoc contentHandler,
264                    boolean skipBinary,
265                    boolean noRecurse)
266     throws PathNotFoundException,
267        SAXException JavaDoc,
268        RepositoryException
269   {
270     throw new UnsupportedRepositoryOperationException(getClass().getName());
271   }
272   
273   /**
274    * Exports XML data from the given node based on the system view.
275    *
276    * @param absPath path to the node serving as root to export
277    * @param out OutputStream to receive the XML
278    */

279   public void exportSystemView(String JavaDoc absPath,
280                    OutputStream JavaDoc out,
281                    boolean skipBinary,
282                    boolean noRecurse)
283     throws IOException JavaDoc,
284        PathNotFoundException,
285        RepositoryException
286   {
287     throw new UnsupportedRepositoryOperationException(getClass().getName());
288   }
289   
290   /**
291    * Exports XML data from the given node based on the document view.
292    *
293    * @param absPath path to the node serving as root to export
294    * @param out OutputStream to receive the XML
295    */

296   public void exportDocumentView(String JavaDoc absPath,
297                  ContentHandler JavaDoc contentHandler,
298                  boolean skipBinary,
299                  boolean noRecurse)
300     throws PathNotFoundException,
301        SAXException JavaDoc,
302        RepositoryException
303   {
304     throw new UnsupportedRepositoryOperationException(getClass().getName());
305   }
306   
307   /**
308    * Exports XML data from the given node based on the document view.
309    *
310    * @param absPath path to the node serving as root to export
311    * @param out OutputStream to receive the XML
312    */

313   public void exportDocumentView(String JavaDoc absPath,
314                  OutputStream JavaDoc out,
315                  boolean skipBinary,
316                  boolean noRecurse)
317     throws IOException JavaDoc,
318        PathNotFoundException,
319        RepositoryException
320   {
321     throw new UnsupportedRepositoryOperationException(getClass().getName());
322   }
323   
324   /**
325    * Exports XML data from the given node based on the document view.
326    *
327    * @param absPath path to the node serving as root to export
328    * @param out OutputStream to receive the XML
329    */

330   public void setNamespacePrefix(String JavaDoc newPrefix,
331                  String JavaDoc existingUri)
332     throws NamespaceException,
333        RepositoryException
334   {
335     throw new UnsupportedRepositoryOperationException(getClass().getName());
336   }
337   
338   /**
339    * Returns the session's namespace prefixes.
340    */

341   public String JavaDoc[] getNamespacePrefixes()
342     throws RepositoryException
343   {
344     throw new UnsupportedRepositoryOperationException(getClass().getName());
345   }
346   
347   /**
348    * Returns the URI for a given namespace prefix.
349    */

350   public String JavaDoc getNamespaceURI(String JavaDoc prefix)
351     throws NamespaceException,
352        RepositoryException
353   {
354     return null;
355   }
356   
357   /**
358    * Returns the prefix for a given URI.
359    */

360   public String JavaDoc getNamespacePrefix(String JavaDoc uri)
361     throws NamespaceException,
362        RepositoryException
363   {
364     return null;
365   }
366   
367   /**
368    * Close the session.
369    */

370   public void logout()
371   {
372     _isActive = false;
373   }
374   
375   /**
376    * Return true if the session is active.
377    */

378   public boolean isLive()
379   {
380     return _isActive;
381   }
382   
383   /**
384    * Adds a lock token.
385    */

386   public void addLockToken(String JavaDoc lt)
387     throws LockException,
388        RepositoryException
389   {
390     throw new UnsupportedRepositoryOperationException(getClass().getName());
391   }
392   
393   /**
394    * Returns the current lock tokens.
395    */

396   public String JavaDoc[] getLockTokens()
397   {
398     return new String JavaDoc[0];
399   }
400   
401   /**
402    * Removes the named lock token.
403    */

404   public void removeLockToken(String JavaDoc lt)
405   {
406   }
407 }
408
Popular Tags