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 javax.jcr.*;
033:
034: /**
035: * Abstract interface for a content repository. The Repository
036: * object will generally live in JNDI in java:comp/env/jcr/*
037: */
038: public class BaseRepository implements Repository {
039: /**
040: * Returns the Repository's feature descriptor keys.
041: */
042: public String[] getDescriptorKeys() {
043: return new String[] { SPEC_VERSION_DESC, SPEC_NAME_DESC,
044: REP_VENDOR_DESC, REP_VENDOR_URL_DESC, REP_NAME_DESC,
045: LEVEL_1_SUPPORTED, LEVEL_2_SUPPORTED,
046: OPTION_TRANSACTIONS_SUPPORTED,
047: OPTION_VERSIONING_SUPPORTED,
048: OPTION_OBSERVATION_SUPPORTED, OPTION_LOCKING_SUPPORTED,
049: OPTION_QUERY_SQL_SUPPORTED, QUERY_XPATH_POS_INDEX,
050: QUERY_XPATH_DOC_ORDER };
051: }
052:
053: /**
054: * Returns the value for Repository feature descriptor keys.
055: */
056: public String getDescriptor(String key) {
057: if (SPEC_VERSION_DESC.equals(key))
058: return "1.0.1";
059: else if (SPEC_NAME_DESC.equals(key))
060: return "Java Content Repository";
061: else if (REP_VENDOR_DESC.equals(key))
062: return "Caucho Technology, inc.";
063: else if (REP_VENDOR_URL_DESC.equals(key))
064: return "http://www.caucho.com";
065: else if (REP_NAME_DESC.equals(key))
066: return "Resin";
067: else if (LEVEL_1_SUPPORTED.equals(key))
068: return "false";
069: else if (LEVEL_2_SUPPORTED.equals(key))
070: return "false";
071: else if (OPTION_TRANSACTIONS_SUPPORTED.equals(key))
072: return "false";
073: else if (OPTION_OBSERVATION_SUPPORTED.equals(key))
074: return "false";
075: else if (OPTION_VERSIONING_SUPPORTED.equals(key))
076: return "false";
077: else if (OPTION_LOCKING_SUPPORTED.equals(key))
078: return "false";
079: else if (OPTION_QUERY_SQL_SUPPORTED.equals(key))
080: return "false";
081: else if (QUERY_XPATH_POS_INDEX.equals(key))
082: return "1";
083: else if (QUERY_XPATH_DOC_ORDER.equals(key))
084: return "true";
085: else
086: return null;
087: }
088:
089: /**
090: * Opens a new session, specifying the security credentials
091: * and a workspace.
092: *
093: * @param credentials the security credentials
094: * @param workspaceName select an optional workspace
095: */
096: public Session login(Credentials credentials, String workspaceName)
097: throws LoginException, NoSuchWorkspaceException,
098: RepositoryException {
099: throw new UnsupportedRepositoryOperationException(getClass()
100: .getName());
101: }
102:
103: /**
104: * Opens a new session with the default workspace.
105: *
106: * @param credentials security credentials
107: */
108: public Session login(Credentials credentials)
109: throws LoginException, RepositoryException {
110: return login(credentials, null);
111: }
112:
113: /**
114: * Opens a new session with the default (anonymous) security
115: * credentials.
116: *
117: * @param workspaceName the name of the workspace to open.
118: */
119: public Session login(String workspaceName) throws LoginException,
120: NoSuchWorkspaceException, RepositoryException {
121: return login(null, workspaceName);
122: }
123:
124: /**
125: * Opens a new session with the default workspace and security credentials.
126: */
127: public Session login() throws LoginException, RepositoryException {
128: return login(null, null);
129: }
130: }
|