KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.jcr.*;
33
34 /**
35  * Abstract interface for a content repository. The Repository
36  * object will generally live in JNDI in java:comp/env/jcr/*
37  */

38 public class BaseRepository implements Repository {
39   /**
40    * Returns the Repository's feature descriptor keys.
41    */

42   public String JavaDoc []getDescriptorKeys()
43   {
44     return new String JavaDoc[] {
45       SPEC_VERSION_DESC,
46       SPEC_NAME_DESC,
47       REP_VENDOR_DESC,
48       REP_VENDOR_URL_DESC,
49       REP_NAME_DESC,
50       LEVEL_1_SUPPORTED,
51       LEVEL_2_SUPPORTED,
52       OPTION_TRANSACTIONS_SUPPORTED,
53       OPTION_VERSIONING_SUPPORTED,
54       OPTION_OBSERVATION_SUPPORTED,
55       OPTION_LOCKING_SUPPORTED,
56       OPTION_QUERY_SQL_SUPPORTED,
57       QUERY_XPATH_POS_INDEX,
58       QUERY_XPATH_DOC_ORDER
59     };
60   }
61
62   /**
63    * Returns the value for Repository feature descriptor keys.
64    */

65   public String JavaDoc getDescriptor(String JavaDoc key)
66   {
67     if (SPEC_VERSION_DESC.equals(key))
68       return "1.0.1";
69     else if (SPEC_NAME_DESC.equals(key))
70       return "Java Content Repository";
71     else if (REP_VENDOR_DESC.equals(key))
72       return "Caucho Technology, inc.";
73     else if (REP_VENDOR_URL_DESC.equals(key))
74       return "http://www.caucho.com";
75     else if (REP_NAME_DESC.equals(key))
76       return "Resin";
77     else if (LEVEL_1_SUPPORTED.equals(key))
78       return "false";
79     else if (LEVEL_2_SUPPORTED.equals(key))
80       return "false";
81     else if (OPTION_TRANSACTIONS_SUPPORTED.equals(key))
82       return "false";
83     else if (OPTION_OBSERVATION_SUPPORTED.equals(key))
84       return "false";
85     else if (OPTION_VERSIONING_SUPPORTED.equals(key))
86       return "false";
87     else if (OPTION_LOCKING_SUPPORTED.equals(key))
88       return "false";
89     else if (OPTION_QUERY_SQL_SUPPORTED.equals(key))
90       return "false";
91     else if (QUERY_XPATH_POS_INDEX.equals(key))
92       return "1";
93     else if (QUERY_XPATH_DOC_ORDER.equals(key))
94       return "true";
95     else
96       return null;
97   }
98
99   /**
100    * Opens a new session, specifying the security credentials
101    * and a workspace.
102    *
103    * @param credentials the security credentials
104    * @param workspaceName select an optional workspace
105    */

106   public Session login(Credentials credentials, String JavaDoc workspaceName)
107     throws LoginException,
108        NoSuchWorkspaceException,
109        RepositoryException
110   {
111     throw new UnsupportedRepositoryOperationException(getClass().getName());
112   }
113
114   /**
115    * Opens a new session with the default workspace.
116    *
117    * @param credentials security credentials
118    */

119   public Session login(Credentials credentials)
120     throws LoginException, RepositoryException
121   {
122     return login(credentials, null);
123   }
124   
125   /**
126    * Opens a new session with the default (anonymous) security
127    * credentials.
128    *
129    * @param workspaceName the name of the workspace to open.
130    */

131   public Session login(String JavaDoc workspaceName)
132     throws LoginException,
133        NoSuchWorkspaceException,
134        RepositoryException
135   {
136     return login(null, workspaceName);
137   }
138
139   /**
140    * Opens a new session with the default workspace and security credentials.
141    */

142   public Session login()
143     throws LoginException,
144        RepositoryException
145   {
146     return login(null, null);
147   }
148 }
149
Popular Tags