001: /*
002: * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.jcr.base;
031:
032: import org.xml.sax.ContentHandler;
033: import org.xml.sax.SAXException;
034:
035: import javax.jcr.*;
036: import javax.jcr.lock.LockException;
037: import javax.jcr.nodetype.ConstraintViolationException;
038: import javax.jcr.nodetype.NoSuchNodeTypeException;
039: import javax.jcr.version.VersionException;
040: import java.io.IOException;
041: import java.io.InputStream;
042: import java.io.OutputStream;
043:
044: /**
045: * Represents an open session to a Repository workspace.
046: */
047: abstract public class BaseSession implements Session {
048: private boolean _isActive = true;
049:
050: /**
051: * Returns the owning repository.
052: */
053: abstract public Repository getRepository();
054:
055: /**
056: * Returns the user who opened this session.
057: */
058: public String getUserID() {
059: return null;
060: }
061:
062: /**
063: * Returns a session attribute.
064: *
065: * @param name the session attribute name
066: */
067: public Object getAttribute(String name) {
068: return null;
069: }
070:
071: /**
072: * Returns an array of the session attribute names.
073: */
074: public String[] getAttributeNames() {
075: return new String[0];
076: }
077:
078: /**
079: * Returns the repository's workspace for this session.
080: */
081: public Workspace getWorkspace() {
082: throw new UnsupportedOperationException();
083: }
084:
085: /**
086: * Create a new session with the new credentials.
087: *
088: * @param credentials security credentials for the new sessions.
089: */
090: public Session impersonate(Credentials credentials)
091: throws LoginException, RepositoryException {
092: throw new UnsupportedRepositoryOperationException(getClass()
093: .getName());
094: }
095:
096: /**
097: * Returns the session's root node.
098: */
099: abstract public Node getRootNode() throws RepositoryException;
100:
101: /**
102: * Finds a node by its UUID
103: *
104: * @param uuid the node's UUID.
105: */
106: public Node getNodeByUUID(String uuid)
107: throws ItemNotFoundException, RepositoryException {
108: throw new UnsupportedRepositoryOperationException(getClass()
109: .getName());
110: }
111:
112: /**
113: * Returns an item based on an absolute path.
114: *
115: * @param absPath the path locating the item.
116: *
117: * @throws PathNotFoundException if the path does not name an item
118: */
119: public Item getItem(String absPath) throws PathNotFoundException,
120: RepositoryException {
121: throw new UnsupportedRepositoryOperationException(getClass()
122: .getName());
123: }
124:
125: /**
126: * Returns true if the item named by the path exists.
127: *
128: * @param absPath a path locating the item.
129: */
130: public boolean itemExists(String absPath)
131: throws RepositoryException {
132: try {
133: return getItem(absPath) != null;
134: } catch (PathNotFoundException e) {
135: return false;
136: }
137: }
138:
139: /**
140: * Moves the node given by the source path to the destination path.
141: *
142: * @param srcAbsPath the absolute path name of the source node
143: * @param destAbsPath the absolute path name of the destination node
144: */
145: public void move(String srcAbsPath, String destAbsPath)
146: throws ItemExistsException, PathNotFoundException,
147: VersionException, ConstraintViolationException,
148: LockException, RepositoryException {
149: throw new UnsupportedRepositoryOperationException(getClass()
150: .getName());
151: }
152:
153: /**
154: * Saves changes to the workspace.
155: */
156: public void save() throws AccessDeniedException,
157: ItemExistsException, ConstraintViolationException,
158: InvalidItemStateException, VersionException, LockException,
159: NoSuchNodeTypeException, RepositoryException {
160: throw new UnsupportedRepositoryOperationException(getClass()
161: .getName());
162: }
163:
164: /**
165: * Updates changes from the repository.
166: */
167: public void refresh(boolean keepChanges) throws RepositoryException {
168: throw new UnsupportedRepositoryOperationException(getClass()
169: .getName());
170: }
171:
172: /**
173: * Returns true if the session has changes.
174: */
175: public boolean hasPendingChanges() throws RepositoryException {
176: return false;
177: }
178:
179: /**
180: * Returns the session's value factory.
181: */
182: public ValueFactory getValueFactory()
183: throws UnsupportedRepositoryOperationException,
184: RepositoryException {
185: throw new UnsupportedRepositoryOperationException(getClass()
186: .getName());
187: }
188:
189: /**
190: * Checks if the session can perform the given actions for the path.
191: *
192: * @param absPath absolute path to a node.
193: * @param actions actions attempted on the node.
194: */
195: public void checkPermission(String absPath, String actions)
196: throws java.security.AccessControlException,
197: RepositoryException {
198: }
199:
200: /**
201: * Returns a SAX ContentHandler to important data.
202: *
203: * @param parentAbsPath the absolute path of the parent node
204: */
205: public ContentHandler getImportContentHandler(String parentAbsPath,
206: int uuidBehavior) throws PathNotFoundException,
207: ConstraintViolationException, VersionException,
208: LockException, RepositoryException {
209: throw new UnsupportedRepositoryOperationException(getClass()
210: .getName());
211: }
212:
213: /**
214: * Import data based on an XML stream.
215: *
216: * @param parentAbsPath path to the node which will be the data's parent.
217: * @param in InputStream to the XML data
218: */
219: public void importXML(String parentAbsPath, InputStream in,
220: int uuidBehavior) throws IOException,
221: PathNotFoundException, ItemExistsException,
222: ConstraintViolationException, VersionException,
223: InvalidSerializedDataException, LockException,
224: RepositoryException {
225: throw new UnsupportedRepositoryOperationException(getClass()
226: .getName());
227: }
228:
229: /**
230: * Exports XML data from the given node based on the system view.
231: *
232: * @param absPath path to the node serving as root to export
233: * @param contentHandler SAX ContentHandler to receive the XML
234: */
235: public void exportSystemView(String absPath,
236: ContentHandler contentHandler, boolean skipBinary,
237: boolean noRecurse) throws PathNotFoundException,
238: SAXException, RepositoryException {
239: throw new UnsupportedRepositoryOperationException(getClass()
240: .getName());
241: }
242:
243: /**
244: * Exports XML data from the given node based on the system view.
245: *
246: * @param absPath path to the node serving as root to export
247: * @param out OutputStream to receive the XML
248: */
249: public void exportSystemView(String absPath, OutputStream out,
250: boolean skipBinary, boolean noRecurse) throws IOException,
251: PathNotFoundException, RepositoryException {
252: throw new UnsupportedRepositoryOperationException(getClass()
253: .getName());
254: }
255:
256: /**
257: * Exports XML data from the given node based on the document view.
258: *
259: * @param absPath path to the node serving as root to export
260: * @param out OutputStream to receive the XML
261: */
262: public void exportDocumentView(String absPath,
263: ContentHandler contentHandler, boolean skipBinary,
264: boolean noRecurse) throws PathNotFoundException,
265: SAXException, RepositoryException {
266: throw new UnsupportedRepositoryOperationException(getClass()
267: .getName());
268: }
269:
270: /**
271: * Exports XML data from the given node based on the document view.
272: *
273: * @param absPath path to the node serving as root to export
274: * @param out OutputStream to receive the XML
275: */
276: public void exportDocumentView(String absPath, OutputStream out,
277: boolean skipBinary, boolean noRecurse) throws IOException,
278: PathNotFoundException, RepositoryException {
279: throw new UnsupportedRepositoryOperationException(getClass()
280: .getName());
281: }
282:
283: /**
284: * Exports XML data from the given node based on the document view.
285: *
286: * @param absPath path to the node serving as root to export
287: * @param out OutputStream to receive the XML
288: */
289: public void setNamespacePrefix(String newPrefix, String existingUri)
290: throws NamespaceException, RepositoryException {
291: throw new UnsupportedRepositoryOperationException(getClass()
292: .getName());
293: }
294:
295: /**
296: * Returns the session's namespace prefixes.
297: */
298: public String[] getNamespacePrefixes() throws RepositoryException {
299: throw new UnsupportedRepositoryOperationException(getClass()
300: .getName());
301: }
302:
303: /**
304: * Returns the URI for a given namespace prefix.
305: */
306: public String getNamespaceURI(String prefix)
307: throws NamespaceException, RepositoryException {
308: return null;
309: }
310:
311: /**
312: * Returns the prefix for a given URI.
313: */
314: public String getNamespacePrefix(String uri)
315: throws NamespaceException, RepositoryException {
316: return null;
317: }
318:
319: /**
320: * Close the session.
321: */
322: public void logout() {
323: _isActive = false;
324: }
325:
326: /**
327: * Return true if the session is active.
328: */
329: public boolean isLive() {
330: return _isActive;
331: }
332:
333: /**
334: * Adds a lock token.
335: */
336: public void addLockToken(String lt) throws LockException,
337: RepositoryException {
338: throw new UnsupportedRepositoryOperationException(getClass()
339: .getName());
340: }
341:
342: /**
343: * Returns the current lock tokens.
344: */
345: public String[] getLockTokens() {
346: return new String[0];
347: }
348:
349: /**
350: * Removes the named lock token.
351: */
352: public void removeLockToken(String lt) {
353: }
354: }
|