You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@locus.apache.org on 2000/11/19 05:18:39 UTC
cvs commit: jakarta-slide/src/share/org/apache/slide/structure StructureImpl.java
remm 00/11/18 20:18:38
Modified: src/share/org/apache/slide/common Namespace.java
NamespaceConfig.java Uri.java
src/share/org/apache/slide/content ContentImpl.java
src/share/org/apache/slide/lock LockImpl.java
src/share/org/apache/slide/security SecurityImpl.java
src/share/org/apache/slide/structure StructureImpl.java
Added: src/share/org/apache/slide/store StandardStore.java
Store.java
Removed: src/share/org/apache/slide/store DescriptorsStore.java
StandardDescriptorsStore.java
Log:
- Merge the ContentStore with the DescriptorsStore.
- DescriptorsStore is renamed Store, which is much better :)
- Nothing needs to be changed is the client programs. Configuration files
need to be slightly modified, but nothing major. Basically, the <contentstore>
element is now a child of what was the <descriptorsstore> element. The
<descriptorsstore> element is renamed to <store>, which again, is a nice
improvement.
- Removes lots of now unnecessary code in the core.
Revision Changes Path
1.10 +161 -340 jakarta-slide/src/share/org/apache/slide/common/Namespace.java
Index: Namespace.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Namespace.java 2000/09/26 02:44:04 1.9
+++ Namespace.java 2000/11/19 04:18:35 1.10
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v 1.9 2000/09/26 02:44:04 remm Exp $
- * $Revision: 1.9 $
- * $Date: 2000/09/26 02:44:04 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v 1.10 2000/11/19 04:18:35 remm Exp $
+ * $Revision: 1.10 $
+ * $Date: 2000/11/19 04:18:35 $
*
* ====================================================================
*
@@ -85,7 +85,7 @@
* Namespace class.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public final class Namespace {
@@ -101,6 +101,7 @@
"revisiondescriptorsstore";
public static final String REVISION_DESCRIPTOR_STORE =
"revisiondescriptorstore";
+ public static final String CONTENT_STORE = "contentstore";
// ----------------------------------------------------- Instance Variables
@@ -120,15 +121,9 @@
/**
- * Registered Stores on this Namespace.
- */
- private transient Hashtable contentStores;
-
-
- /**
* Registered DescriptorStores on this Namespace.
*/
- private transient Hashtable descriptorsStores;
+ private transient Hashtable stores;
/**
@@ -146,8 +141,8 @@
/**
* Default descriptors store classname.
*/
- private String defaultDescriptorsStoreClassname =
- "org.apache.slide.store.StandardDescriptorsStore";
+ private String defaultStoreClassname =
+ "org.apache.slide.store.StandardStore";
// ------------------------------------------------------------ Constructor
@@ -157,8 +152,7 @@
* Constructor.
*/
Namespace() {
- contentStores = new Hashtable();
- descriptorsStores = new Hashtable();
+ stores = new Hashtable();
connectedServices = new Vector();
name = new String();
uriCache = new Hashtable();
@@ -202,13 +196,12 @@
/**
- * Used to register a Descriptor Store in the namespace for the specified
- * scope.
- * First, the function instantiate the Descriptor Store, then gives it
- * its init parameters. It is then stored in the descriptorsStores
+ * Used to register a Store in the namespace for the specified scope.
+ * First, the function instantiate the Store, then gives it
+ * its init parameters. It is then stored in the stores
* Hashtable, associated with the given scope.
*
- * @param descriptorsStoreClass Class of the Data Source
+ * @param storeClass Class of the Data Source
* @param parameters Init parameters for the Data Source
* @param scope Scope for which the Data Source is registered
* @param childStores Instances of the typed stores
@@ -217,117 +210,89 @@
* @exception ServiceParameterErrorException Incorrect service parameter
* @exception ServiceParameterMissingException Service parameter missing
*/
- public void registerDescriptorsStore(Class descriptorsStoreClass,
- Hashtable parameters, Scope scope,
- Hashtable childStores)
+ public void registerStore(Class storeClass, Hashtable parameters,
+ Scope scope, Hashtable childStores)
throws ServiceRegistrationFailedException,
ServiceParameterErrorException, ServiceParameterMissingException {
- if (!descriptorsStores.containsKey(scope)) {
+ if (!stores.containsKey(scope)) {
try {
- DescriptorsStore descriptorsStore =
- (DescriptorsStore) descriptorsStoreClass.newInstance();
- descriptorsStore.setParameters(parameters);
- descriptorsStores.put(scope, descriptorsStore);
+ Store store = (Store) storeClass.newInstance();
+ store.setParameters(parameters);
+ stores.put(scope, store);
// Now assigning the child stores
Object nodeStore = childStores.get(NODE_STORE);
if (nodeStore instanceof String) {
// Resolving reference
- descriptorsStore
- .setNodeStore((NodeStore) childStores.get(nodeStore));
+ store.setNodeStore((NodeStore) childStores.get(nodeStore));
} else {
- descriptorsStore.setNodeStore((NodeStore) nodeStore);
+ store.setNodeStore((NodeStore) nodeStore);
}
Object securityStore = childStores.get(SECURITY_STORE);
if (securityStore instanceof String) {
// Resolving reference
- descriptorsStore.setSecurityStore
+ store.setSecurityStore
((SecurityStore) childStores.get(securityStore));
} else {
- descriptorsStore.setSecurityStore
+ store.setSecurityStore
((SecurityStore) securityStore);
}
Object lockStore = childStores.get(LOCK_STORE);
if (lockStore instanceof String) {
- descriptorsStore.setLockStore
+ store.setLockStore
((LockStore) childStores.get(lockStore));
} else {
- descriptorsStore.setLockStore((LockStore) lockStore);
+ store.setLockStore((LockStore) lockStore);
}
Object revisionDescriptorsStore = childStores
.get(REVISION_DESCRIPTORS_STORE);
if (revisionDescriptorsStore instanceof String) {
- descriptorsStore.setRevisionDescriptorsStore
+ store.setRevisionDescriptorsStore
((RevisionDescriptorsStore) childStores
.get(revisionDescriptorsStore));
} else {
- descriptorsStore
- .setRevisionDescriptorsStore
+ store.setRevisionDescriptorsStore
((RevisionDescriptorsStore) revisionDescriptorsStore);
}
Object revisionDescriptorStore = childStores
.get(REVISION_DESCRIPTOR_STORE);
if (revisionDescriptorStore instanceof String) {
- descriptorsStore.setRevisionDescriptorStore
+ store.setRevisionDescriptorStore
((RevisionDescriptorStore) childStores
.get(revisionDescriptorStore));
} else {
- descriptorsStore
- .setRevisionDescriptorStore
+ store.setRevisionDescriptorStore
((RevisionDescriptorStore) revisionDescriptorStore);
}
+ Object contentStore = childStores.get(CONTENT_STORE);
+ if (contentStore instanceof String) {
+ // Resolving reference
+ store.setContentStore
+ ((ContentStore) childStores.get(contentStore));
+ } else {
+ store.setContentStore((ContentStore) contentStore);
+ }
+
} catch(InstantiationException e) {
throw new ServiceRegistrationFailedException
- (descriptorsStoreClass);
+ (storeClass);
} catch(IllegalAccessException e) {
+ throw new ServiceRegistrationFailedException
+ (storeClass);
+ } catch(NullPointerException e) {
throw new ServiceRegistrationFailedException
- (descriptorsStoreClass);
+ (storeClass);
} catch(ClassCastException e) {
// TEMP
e.printStackTrace();
// --TEMP
throw new ServiceRegistrationFailedException
- (descriptorsStoreClass);
- }
- }
- }
-
-
- /**
- * Used to register a Store in the namespace for the specified scope.
- * First, the function instantiate the Store, then gives it its init
- * parameters. It is then stored in the stores Hashtable, associated
- * with the given scope.
- *
- * @param contentStoreClass Class of the Store
- * @param parameters Init parameters for the Store
- * @param scope Scope for which the Store is registered
- * @exception ServiceRegistrationFailed An error occured during
- * instantiation of the service
- * @exception ServiceParameterErrorException Incorrect service parameter
- * @exception ServiceParameterMissingException Service parameter missing
- */
- public void registerContentStore(Class contentStoreClass,
- Hashtable parameters, Scope scope)
- throws ServiceRegistrationFailedException,
- ServiceParameterErrorException, ServiceParameterMissingException {
- if (!contentStores.containsKey(scope)) {
- try {
- ContentStore contentStore =
- (ContentStore) contentStoreClass.newInstance();
- contentStore.setParameters(parameters);
- contentStores.put(scope, contentStore);
- } catch(InstantiationException e) {
- throw
- new ServiceRegistrationFailedException(contentStoreClass);
- } catch(IllegalAccessException e) {
- throw
- new ServiceRegistrationFailedException(contentStoreClass);
+ (storeClass);
}
}
}
@@ -349,7 +314,7 @@
= new ServicesInitializationFailedException();
// Initializing DesciptorsStores
- Enumeration serviceList = descriptorsStores.elements();
+ Enumeration serviceList = stores.elements();
while (serviceList.hasMoreElements()) {
Service service = (Service) serviceList.nextElement();
try {
@@ -362,20 +327,6 @@
}
}
- // Initializing ContentStores
- serviceList = contentStores.elements();
- while (serviceList.hasMoreElements()) {
- Service service = (Service) serviceList.nextElement();
- try {
- Domain.info("Initializing service " + service);
- service.initialize(new NamespaceAccessTokenImpl(this));
- } catch (ServiceInitializationFailedException e) {
- // We add the exception which just occured to the
- // nested exception
- nestedException.addException(e);
- }
- }
-
// If the nested exception is not empty, we throw it.
if (!nestedException.isEmpty()) {
throw nestedException;
@@ -388,8 +339,7 @@
* Reinitialize namespace.
*/
public void clearNamespace() {
- descriptorsStores.clear();
- contentStores.clear();
+ stores.clear();
}
@@ -452,7 +402,7 @@
/**
- * Remove a DescriptorsStore from the registry.
+ * Remove a Store from the registry.
*
* @param scope Scope to disconnect
* @exception ServiceDisconnctionFailedException Error disconnecting
@@ -460,78 +410,35 @@
* @exception ServiceAccessException Unspecified error during
* service access
*/
- public void unregisterDescriptorsStore(Scope scope)
+ public void unregisterStore(Scope scope)
throws ServiceDisconnectionFailedException, ServiceAccessException {
- if (descriptorsStores.containsKey(scope)) {
- DescriptorsStore descriptorsStore =
- (DescriptorsStore) descriptorsStores.get(scope);
- if (descriptorsStore.isConnected()) {
- descriptorsStore.disconnect();
- connectedServices.removeElement(descriptorsStore);
+ if (stores.containsKey(scope)) {
+ Store store = (Store) stores.get(scope);
+ if (store.isConnected()) {
+ store.disconnect();
+ connectedServices.removeElement(store);
}
- descriptorsStores.remove(scope);
- descriptorsStore = null;
+ stores.remove(scope);
+ store = null;
}
}
/**
- * Remove a ContentStore from the registry.
- *
- * @param scope Scope to disconnect
- * @exception ServiceDisconnctionFailedException Error disconnecting Store
- * @exception ServiceAccessException Unspecified error during
- * service access
- */
- public void unregisterContentStore(Scope scope)
- throws ServiceDisconnectionFailedException, ServiceAccessException {
- if (contentStores.containsKey(scope)) {
- ContentStore contentStore =
- (ContentStore) contentStores.get(scope);
- if (contentStore.isConnected()) {
- contentStore.disconnect();
- connectedServices.removeElement(contentStore);
- }
- contentStores.remove(scope);
- contentStore = null;
- }
- }
-
-
- /**
* Get the Data Source associated with the given scope, if any.
*
* @param scope Scope to match
- * @exception ServiceConnectionFailedException Connection to
- * DescriptorsStore failed
- * @exception ServiceAccessException Unspecified service access exception
- */
- public DescriptorsStore retrieveDescriptorsStore(Scope scope)
- throws ServiceConnectionFailedException, ServiceAccessException {
- DescriptorsStore descriptorsStore = null;
- if (descriptorsStores.containsKey(scope)) {
- descriptorsStore = (DescriptorsStore) descriptorsStores.get(scope);
- connectService(descriptorsStore);
- }
- return descriptorsStore;
- }
-
-
- /**
- * Get the Store associated with the given scope, if any.
- *
- * @param scope Scope to match
* @exception ServiceConnectionFailedException Connection to Store failed
* @exception ServiceAccessException Unspecified service access exception
*/
- public ContentStore retrieveContentStore(Scope scope)
+ public Store retrieveStore(Scope scope)
throws ServiceConnectionFailedException, ServiceAccessException {
- ContentStore contentStore = null;
- if (contentStores.containsKey(scope)) {
- contentStore = (ContentStore) contentStores.get(scope);
- connectService(contentStore);
+ Store store = null;
+ if (stores.containsKey(scope)) {
+ store = (Store) stores.get(scope);
+ connectService(store);
}
- return contentStore;
+ return store;
}
@@ -585,45 +492,28 @@
Domain.info("Loading namespace definition");
- // Loading Descriptors stores
+ // Loading stores
- Hashtable descriptorsStoresClass = new Hashtable();
- Hashtable descriptorsStoresParameters = new Hashtable();
- Hashtable descriptorsChildStores = new Hashtable();
-
- Enumeration descriptorsStoreDefinitions =
- definition.getConfigurations("descriptorsstore");
-
- while (descriptorsStoreDefinitions.hasMoreElements()) {
- loadDescriptorsStoreDefinition
- ((Configuration) descriptorsStoreDefinitions.nextElement(),
- descriptorsStoresClass, descriptorsStoresParameters,
- descriptorsChildStores);
+ Hashtable storesClass = new Hashtable();
+ Hashtable storesParameters = new Hashtable();
+ Hashtable childStores = new Hashtable();
+
+ Enumeration storeDefinitions =
+ definition.getConfigurations("store");
+
+ while (storeDefinitions.hasMoreElements()) {
+ loadStoreDefinition
+ ((Configuration) storeDefinitions.nextElement(),
+ storesClass, storesParameters, childStores);
}
- // Loading Content stores
-
- Hashtable contentStoresClass = new Hashtable();
- Hashtable contentStoresParameters = new Hashtable();
-
- Enumeration contentStoreDefinitions =
- definition.getConfigurations("contentstore");
-
- while (contentStoreDefinitions.hasMoreElements()) {
- loadContentStoreDefinition
- ((Configuration) contentStoreDefinitions.nextElement(),
- contentStoresClass, contentStoresParameters);
- }
-
Enumeration scopeDefinitions =
definition.getConfigurations("scope");
while (scopeDefinitions.hasMoreElements()) {
loadScopeDefinition
((Configuration) scopeDefinitions.nextElement(),
- descriptorsStoresClass, descriptorsStoresParameters,
- descriptorsChildStores, contentStoresClass,
- contentStoresParameters);
+ storesClass, storesParameters, childStores);
}
// Initialize all loaded services.
@@ -652,15 +542,13 @@
Uri rootUri = getUri("/");
SubjectNode rootNode = new SubjectNode("/");
NodePermission allAccess = new NodePermission("/", "/", "/");
- rootUri.getDescriptorsStore().createObject(rootUri, rootNode);
- rootUri.getDescriptorsStore()
- .grantPermission(rootUri, allAccess);
+ rootUri.getStore().createObject(rootUri, rootNode);
+ rootUri.getStore().grantPermission(rootUri, allAccess);
// Create a dummy action
Uri tempActionUri = getUri("/tempaction");
ActionNode tempAction = new ActionNode("/tempaction");
- tempActionUri.getDescriptorsStore()
- .createObject(tempActionUri, tempAction);
+ tempActionUri.getStore().createObject(tempActionUri, tempAction);
// Create the dummy configuration
config = new NamespaceConfig();
@@ -674,14 +562,13 @@
namespaceBaseDataDefinition);
// Then, destroy the temp action
- tempActionUri.getDescriptorsStore()
- .removeObject(tempActionUri, tempAction);
+ tempActionUri.getStore().removeObject(tempActionUri, tempAction);
// And remove the all permission from the root node
- rootNode = (SubjectNode) rootUri.getDescriptorsStore()
- .retrieveObject(rootUri);
- rootUri.getDescriptorsStore().revokePermission(rootUri, allAccess);
- rootUri.getDescriptorsStore().storeObject(rootUri, rootNode);
+ rootNode =
+ (SubjectNode) rootUri.getStore().retrieveObject(rootUri);
+ rootUri.getStore().revokePermission(rootUri, allAccess);
+ rootUri.getStore().storeObject(rootUri, rootNode);
} catch (SlideException e) {
// If that occurs, then most likely the base config was
@@ -725,61 +612,54 @@
/**
- * Parse the descriptors store definition.
+ * Parse the store definition.
*
- * @param descriptorsStoreDefinition Descriptors store definition
- * @param descriptorsStoresClass Class names of the descriptors stores
- * @param descriptorsStoresParameters Parameters of the descriptors stores
- * @param descriptorsChildStores Child stores
+ * @param storeDefinition store definition
+ * @param storesClass Class names of the stores
+ * @param storesParameters Parameters of the stores
+ * @param childStores Child stores
* @exception ConfigurationException Error parsing configuration file
* @exception SlideException Error loading the specified class
*/
- private void loadDescriptorsStoreDefinition
- (Configuration descriptorsStoreDefinition,
- Hashtable descriptorsStoresClass,
- Hashtable descriptorsStoresParameters,
- Hashtable descriptorsChildStores)
+ private void loadStoreDefinition
+ (Configuration storeDefinition,
+ Hashtable storesClass,
+ Hashtable storesParameters,
+ Hashtable childStores)
throws ConfigurationException, SlideException {
- String descriptorsStoreName =
- descriptorsStoreDefinition.getAttribute("name");
- String descriptorsStoreClassname =
- defaultDescriptorsStoreClassname;
+ String storeName = storeDefinition.getAttribute("name");
+ String storeClassname = defaultStoreClassname;
try {
- descriptorsStoreClassname =
- descriptorsStoreDefinition.getAttribute("classname");
+ storeClassname = storeDefinition.getAttribute("classname");
} catch (ConfigurationException e) {
}
- Enumeration descriptorsStoreParametersDefinitions =
- descriptorsStoreDefinition.getConfigurations("parameter");
+ Enumeration storeParametersDefinitions =
+ storeDefinition.getConfigurations("parameter");
// Load descriptors store class
- Class descriptorsStoreClass = null;
+ Class storeClass = null;
try {
- descriptorsStoreClass =
- Class.forName(descriptorsStoreClassname);
+ storeClass = Class.forName(storeClassname);
} catch (Exception e) {
e.printStackTrace();
throw new SlideException(e.getMessage());
}
- descriptorsStoresClass.put(descriptorsStoreName,
- descriptorsStoreClass);
+ storesClass.put(storeName, storeClass);
// Load descriptor store parameters
- Hashtable descriptorsStoreParameters = new Hashtable();
- while (descriptorsStoreParametersDefinitions.hasMoreElements()) {
+ Hashtable storeParameters = new Hashtable();
+ while (storeParametersDefinitions.hasMoreElements()) {
Configuration parameterDefinition = (Configuration)
- descriptorsStoreParametersDefinitions.nextElement();
+ storeParametersDefinitions.nextElement();
String parameterName = parameterDefinition.getAttribute("name");
String parameterValue = parameterDefinition.getValue();
- descriptorsStoreParameters.put(parameterName,
- parameterValue);
+ storeParameters.put(parameterName, parameterValue);
}
- descriptorsStoresParameters.put(descriptorsStoreName,
- descriptorsStoreParameters);
+ storesParameters.put(storeName, storeParameters);
// Now reading the "child" stores
@@ -788,10 +668,10 @@
// Loading node store (if any)
try {
Configuration nodeStoreDefinition =
- descriptorsStoreDefinition.getConfiguration(NODE_STORE);
+ storeDefinition.getConfiguration(NODE_STORE);
try {
Configuration referenceDefinition =
- descriptorsStoreDefinition.getConfiguration(REFERENCE);
+ storeDefinition.getConfiguration(REFERENCE);
currentStoreChildStores.put
(NODE_STORE, referenceDefinition.getAttribute("store"));
} catch (ConfigurationException ex) {
@@ -807,12 +687,13 @@
// Loading security store (if any)
try {
Configuration securityStoreDefinition =
- descriptorsStoreDefinition.getConfiguration(SECURITY_STORE);
+ storeDefinition.getConfiguration(SECURITY_STORE);
try {
Configuration referenceDefinition =
- descriptorsStoreDefinition.getConfiguration(REFERENCE);
+ storeDefinition.getConfiguration(REFERENCE);
currentStoreChildStores.put
- (NODE_STORE, referenceDefinition.getAttribute("store"));
+ (SECURITY_STORE,
+ referenceDefinition.getAttribute("store"));
} catch (ConfigurationException ex) {
SecurityStore securityStore =
(SecurityStore) loadChildStore(securityStoreDefinition);
@@ -826,12 +707,12 @@
// Loading lock store (if any)
try {
Configuration lockStoreDefinition =
- descriptorsStoreDefinition.getConfiguration(LOCK_STORE);
+ storeDefinition.getConfiguration(LOCK_STORE);
try {
Configuration referenceDefinition =
- descriptorsStoreDefinition.getConfiguration(REFERENCE);
+ storeDefinition.getConfiguration(REFERENCE);
currentStoreChildStores.put
- (NODE_STORE, referenceDefinition.getAttribute("store"));
+ (LOCK_STORE, referenceDefinition.getAttribute("store"));
} catch (ConfigurationException ex) {
LockStore lockStore =
(LockStore) loadChildStore(lockStoreDefinition);
@@ -845,13 +726,14 @@
// Loading revision descriptors store (if any)
try {
Configuration revisionDescriptorsStoreDefinition =
- descriptorsStoreDefinition.getConfiguration
+ storeDefinition.getConfiguration
(REVISION_DESCRIPTORS_STORE);
try {
Configuration referenceDefinition =
- descriptorsStoreDefinition.getConfiguration(REFERENCE);
+ storeDefinition.getConfiguration(REFERENCE);
currentStoreChildStores.put
- (NODE_STORE, referenceDefinition.getAttribute("store"));
+ (REVISION_DESCRIPTORS_STORE,
+ referenceDefinition.getAttribute("store"));
} catch (ConfigurationException ex) {
RevisionDescriptorsStore revisionDescriptorsStore =
(RevisionDescriptorsStore) loadChildStore
@@ -867,13 +749,13 @@
// Loading revision descriptor store (if any)
try {
Configuration revisionDescriptorStoreDefinition =
- descriptorsStoreDefinition.getConfiguration
- (REVISION_DESCRIPTOR_STORE);
+ storeDefinition.getConfiguration(REVISION_DESCRIPTOR_STORE);
try {
Configuration referenceDefinition =
- descriptorsStoreDefinition.getConfiguration(REFERENCE);
+ storeDefinition.getConfiguration(REFERENCE);
currentStoreChildStores.put
- (NODE_STORE, referenceDefinition.getAttribute("store"));
+ (REVISION_DESCRIPTOR_STORE,
+ referenceDefinition.getAttribute("store"));
} catch (ConfigurationException ex) {
RevisionDescriptorStore revisionDescriptorStore =
(RevisionDescriptorStore) loadChildStore
@@ -886,8 +768,26 @@
} catch (Exception e) {
}
- descriptorsChildStores.put(descriptorsStoreName,
- currentStoreChildStores);
+ // Loading content store (if any)
+ try {
+ Configuration contentStoreDefinition =
+ storeDefinition.getConfiguration(CONTENT_STORE);
+ try {
+ Configuration referenceDefinition =
+ storeDefinition.getConfiguration(REFERENCE);
+ currentStoreChildStores.put
+ (CONTENT_STORE, referenceDefinition.getAttribute("store"));
+ } catch (ConfigurationException ex) {
+ ContentStore contentStore =
+ (ContentStore) loadChildStore(contentStoreDefinition);
+ if (contentStore != null) {
+ currentStoreChildStores.put(CONTENT_STORE, contentStore);
+ }
+ }
+ } catch (Exception e) {
+ }
+
+ childStores.put(storeName, currentStoreChildStores);
}
@@ -938,58 +838,10 @@
/**
* Parse the content store definition.
- *
- * @param contentStoreDefinition Content store definition
- * @param contentStoresClass Class names of the content stores
- * @param contentStoresParameters Parameters of the content stores
- * @exception ConfigurationException Error parsing configuration file
- * @exception SlideException Error loading the specified class
- */
- private void loadContentStoreDefinition
- (Configuration contentStoreDefinition,
- Hashtable contentStoresClass, Hashtable contentStoresParameters)
- throws ConfigurationException, SlideException {
-
- String contentStoreName = contentStoreDefinition.getAttribute("name");
- String contentStoreClassname =
- contentStoreDefinition.getAttribute("classname");
- Enumeration contentStoreParametersDefinitions =
- contentStoreDefinition.getConfigurations("parameter");
-
- // Load content store class
- Class contentStoreClass = null;
- try {
- contentStoreClass = Class.forName(contentStoreClassname);
- } catch (Exception e) {
- e.printStackTrace();
- throw new SlideException(e.getMessage());
- }
- contentStoresClass.put(contentStoreName, contentStoreClass);
-
- // Load content store parameters
- Hashtable contentStoreParameters = new Hashtable();
- while (contentStoreParametersDefinitions.hasMoreElements()) {
- Configuration parameterDefinition = (Configuration)
- contentStoreParametersDefinitions.nextElement();
- String parameterName = parameterDefinition.getAttribute("name");
- String parameterValue = parameterDefinition.getValue();
- contentStoreParameters.put(parameterName, parameterValue);
- }
- contentStoresParameters.put(contentStoreName, contentStoreParameters);
-
- }
-
-
-
- /**
- * Parse the content store definition.
*
- * @param contentStoreDefinition Content store definition
- * @param contentStoresClass Class names of the content stores
- * @param contentStoresParameters Parameters of the content stores
- * @param descriptorsStoresClass Class names of the descriptors stores
- * @param descriptorsStoresParameters Parameters of the descriptors stores
- * @param descriptorsChildStores Child stores instances
+ * @param storesClass Class names of the descriptors stores
+ * @param storesParameters Parameters of the descriptors stores
+ * @param childStores Child stores instances
* @exception ConfigurationException Error parsing configuration file
* @exception UnknownServiceDeclarationException Reference to
* unknown service
@@ -998,11 +850,9 @@
* @exception ServiceRegistrationFailedException Error registering service
*/
private void loadScopeDefinition(Configuration scopeDefinition,
- Hashtable descriptorsStoresClass,
- Hashtable descriptorsStoresParameters,
- Hashtable descriptorsChildStores,
- Hashtable contentStoresClass,
- Hashtable contentStoresParameters)
+ Hashtable storesClass,
+ Hashtable storesParameters,
+ Hashtable childStores)
throws ConfigurationException, UnknownServiceDeclarationException,
ServiceParameterErrorException, ServiceParameterMissingException,
ServiceRegistrationFailedException {
@@ -1010,52 +860,23 @@
String match = scopeDefinition.getAttribute("match");
// First, we get the correct class and parameters from the Hashtables.
- String descriptorsStoreName =
- scopeDefinition.getAttribute("descriptorsstore");
+ String storeName = scopeDefinition.getAttribute("store");
- if (descriptorsStoreName != null) {
- if ((!descriptorsStoresClass.containsKey(descriptorsStoreName)) ||
- (!descriptorsStoresParameters.containsKey
- (descriptorsStoreName))) {
- throw new UnknownServiceDeclarationException
- (descriptorsStoreName);
- }
- registerDescriptorsStore((Class) descriptorsStoresClass
- .get(descriptorsStoreName),
- (Hashtable) descriptorsStoresParameters
- .get(descriptorsStoreName),
- new Scope(match),
- (Hashtable) descriptorsChildStores
- .get(descriptorsStoreName));
+ if (storeName != null) {
+ if ((!storesClass.containsKey(storeName)) ||
+ (!storesParameters.containsKey(storeName))) {
+ throw new UnknownServiceDeclarationException(storeName);
+ }
+ registerStore((Class) storesClass.get(storeName),
+ (Hashtable) storesParameters.get(storeName),
+ new Scope(match),
+ (Hashtable) childStores.get(storeName));
Domain.info("Registering Data Source name "
- + descriptorsStoreName
- + " of class "
- + descriptorsStoresClass.get(descriptorsStoreName)
- + " with parameters "
- + descriptorsStoresParameters
- .get(descriptorsStoreName)
- + " on scope " + match);
- }
-
- // Load and Register store with the current path.
-
- String contentStoreName = scopeDefinition.getAttribute("contentstore");
-
- if (contentStoreName != null) {
- if ((!contentStoresClass.containsKey(contentStoreName)) ||
- (!contentStoresParameters.containsKey(contentStoreName))) {
- throw new UnknownServiceDeclarationException(contentStoreName);
- }
- registerContentStore((Class) contentStoresClass
- .get(contentStoreName),
- (Hashtable) contentStoresParameters
- .get(contentStoreName),
- new Scope(match));
- Domain.info("Registering Store name " + contentStoreName
+ + storeName
+ " of class "
- + contentStoresClass.get(contentStoreName)
+ + storesClass.get(storeName)
+ " with parameters "
- + contentStoresParameters.get(contentStoreName)
+ + storesParameters.get(storeName)
+ " on scope " + match);
}
1.9 +7 -7 jakarta-slide/src/share/org/apache/slide/common/NamespaceConfig.java
Index: NamespaceConfig.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/NamespaceConfig.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- NamespaceConfig.java 2000/09/26 02:44:05 1.8
+++ NamespaceConfig.java 2000/11/19 04:18:35 1.9
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/NamespaceConfig.java,v 1.8 2000/09/26 02:44:05 remm Exp $
- * $Revision: 1.8 $
- * $Date: 2000/09/26 02:44:05 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/NamespaceConfig.java,v 1.9 2000/11/19 04:18:35 remm Exp $
+ * $Revision: 1.9 $
+ * $Date: 2000/11/19 04:18:35 $
*
* ====================================================================
*
@@ -79,7 +79,7 @@
* Configuration of the Namespace.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
public final class NamespaceConfig {
@@ -637,7 +637,7 @@
try {
Uri tempActionUri = namespace.getUri("/tempaction");
- defaultAction = (ActionNode) tempActionUri.getDescriptorsStore()
+ defaultAction = (ActionNode) tempActionUri.getStore()
.retrieveObject(tempActionUri);
readObjectAction = defaultAction;
createObjectAction = defaultAction;
@@ -697,8 +697,8 @@
if (actionPath != null) {
Uri actionUri = namespace.getUri(actionPath);
- result = (ActionNode) actionUri
- .getDescriptorsStore().retrieveObject(actionUri);
+ result = (ActionNode) actionUri.getStore()
+ .retrieveObject(actionUri);
} else {
if (defaultAction != null) {
result = defaultAction;
1.4 +18 -50 jakarta-slide/src/share/org/apache/slide/common/Uri.java
Index: Uri.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Uri.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Uri.java 2000/11/16 07:23:46 1.3
+++ Uri.java 2000/11/19 04:18:35 1.4
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Uri.java,v 1.3 2000/11/16 07:23:46 remm Exp $
- * $Revision: 1.3 $
- * $Date: 2000/11/16 07:23:46 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Uri.java,v 1.4 2000/11/19 04:18:35 remm Exp $
+ * $Revision: 1.4 $
+ * $Date: 2000/11/19 04:18:35 $
*
* ====================================================================
*
@@ -74,7 +74,7 @@
* manipulated by Slide.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public final class Uri implements java.io.Serializable {
@@ -128,17 +128,11 @@
/**
- * Associated DescriptorsStore instance.
+ * Associated Store instance.
*/
- private transient DescriptorsStore descriptorsStore;
+ private transient Store store;
- /**
- * Associated ContentStore instance.
- */
- private transient ContentStore contentStore;
-
-
// ------------------------------------------------------------- Properties
@@ -174,25 +168,15 @@
/**
- * DescriptorsStore accessor.
+ * Store accessor.
*
- * @return DescriptorsStore
+ * @return Store
*/
- public DescriptorsStore getDescriptorsStore() {
- return this.descriptorsStore;
+ public Store getStore() {
+ return this.store;
}
- /**
- * ContentStore accessor.
- *
- * @return ContentStore
- */
- public ContentStore getContentStore() {
- return this.contentStore;
- }
-
-
// --------------------------------------------------------- Public Methods
@@ -221,8 +205,7 @@
* the namespace at runtime.
*/
public void invalidateServices() {
- descriptorsStore = null;
- contentStore = null;
+ store = null;
pk = 0;
parseUri(this.uri);
}
@@ -233,8 +216,7 @@
*/
public void reconnectServices() {
try {
- descriptorsStore.connectIfNeeded();
- contentStore.connectIfNeeded();
+ store.connectIfNeeded();
} catch (ServiceConnectionFailedException e) {
parseUri(this.uri);
} catch (ServiceAccessException e) {
@@ -318,16 +300,13 @@
// Find the qualifiying stuff from the registry.
// Then we contentStore the scope of the found Data Source
// within scope.
- descriptorsStore = null;
- contentStore = null;
- while (((descriptorsStore == null) || (contentStore == null))
- && (scopes.hasMoreElements())) {
+ store = null;
+ while ((store == null) && (scopes.hasMoreElements())) {
Scope courScope = scopes.nextScope();
try {
- if (descriptorsStore == null) {
- descriptorsStore = namespace.retrieveDescriptorsStore
- (courScope);
- if (descriptorsStore != null) {
+ if (store == null) {
+ store = namespace.retrieveStore(courScope);
+ if (store != null) {
scope = courScope;
// The PK in the current descriptorsStore is the
// portion of the URI relative
@@ -343,22 +322,11 @@
// Problem ...
// FIXME : Throw a RuntimeException ??
}
- try {
- if (contentStore == null) {
- contentStore = namespace.retrieveContentStore(courScope);
- }
- } catch (ServiceConnectionFailedException e) {
- // Problem ...
- // FIXME : Throw a RuntimeException ??
- } catch (ServiceAccessException e) {
- // Problem ...
- // FIXME : Throw a RuntimeException ??
- }
}
// If descriptorsStore or contentStore is still null, then no valid
// scope is defined in the namespace ...
- if ((descriptorsStore == null) || (contentStore == null)) {
+ if (store == null) {
throw new ServiceMissingOnRootNodeException();
}
1.6 +28 -28 jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java
Index: ContentImpl.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ContentImpl.java 2000/09/26 02:44:13 1.5
+++ ContentImpl.java 2000/11/19 04:18:36 1.6
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java,v 1.5 2000/09/26 02:44:13 remm Exp $
- * $Revision: 1.5 $
- * $Date: 2000/09/26 02:44:13 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java,v 1.6 2000/11/19 04:18:36 remm Exp $
+ * $Revision: 1.6 $
+ * $Date: 2000/11/19 04:18:36 $
*
* ====================================================================
*
@@ -77,7 +77,7 @@
* Implementation of the content interface.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public final class ContentImpl implements Content {
@@ -164,13 +164,13 @@
Uri objectUri = namespace.getUri(strUri);
NodeRevisionDescriptors revisionDescriptors = null;
try {
- revisionDescriptors = objectUri.getDescriptorsStore()
+ revisionDescriptors = objectUri.getStore()
.retrieveRevisionDescriptors(objectUri);
} catch (RevisionDescriptorNotFoundException e) {
// No revision descriptors. We have to create some.
revisionDescriptors = new NodeRevisionDescriptors();
revisionDescriptors.setUri(strUri);
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.createRevisionDescriptors(objectUri, revisionDescriptors);
}
return revisionDescriptors;
@@ -200,7 +200,7 @@
namespaceConfig.getReadRevisionMetadataAction());
Uri objectUri = namespace.getUri(revisionDescriptors.getUri());
- return objectUri.getDescriptorsStore()
+ return objectUri.getStore()
.retrieveRevisionDescriptor(objectUri, revisionNumber);
}
@@ -262,7 +262,7 @@
namespaceConfig.getReadRevisionContentAction());
Uri objectUri = namespace.getUri(strUri);
- return objectUri.getContentStore()
+ return objectUri.getStore()
.retrieveRevisionContent(objectUri,
revisionDescriptor.getRevisionNumber());
}
@@ -302,13 +302,13 @@
NodeRevisionDescriptors revisionDescriptors = null;
try {
- revisionDescriptors = objectUri.getDescriptorsStore()
+ revisionDescriptors = objectUri.getStore()
.retrieveRevisionDescriptors(objectUri);
} catch (RevisionDescriptorNotFoundException e) {
// No revision descriptors. We have to create some.
revisionDescriptors = new NodeRevisionDescriptors();
revisionDescriptors.setUri(strUri);
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.createRevisionDescriptors(objectUri, revisionDescriptors);
}
@@ -339,12 +339,12 @@
revisionDescriptor.setCreationDate(new Date());
}
// Now creating the revision desriptor in the store
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.createRevisionDescriptor(objectUri, revisionDescriptor);
if (revisionContent != null) {
// Storing the new revision contents
- objectUri.getContentStore()
+ objectUri.getStore()
.createRevisionContent(objectUri, revisionDescriptor,
revisionContent);
}
@@ -362,12 +362,12 @@
}
if (!revisionDescriptors.hasRevisions()) {
// Now creating the revision desriptor in the store
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.createRevisionDescriptor(objectUri, revisionDescriptor);
if (revisionContent != null) {
// Storing the new revision contents
- objectUri.getContentStore()
+ objectUri.getStore()
.createRevisionContent(objectUri, revisionDescriptor,
revisionContent);
}
@@ -375,7 +375,7 @@
try {
// We update the descriptor's properties
NodeRevisionDescriptor oldRevisionDescriptor =
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.retrieveRevisionDescriptor(objectUri,
newRevisionNumber);
Enumeration newPropertiesList =
@@ -385,7 +385,7 @@
.setProperty( (NodeProperty) newPropertiesList
.nextElement() );
}
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.storeRevisionDescriptor(objectUri,
oldRevisionDescriptor);
} catch (RevisionDescriptorNotFoundException e) {
@@ -393,7 +393,7 @@
// Basically, it would mean that there is no initial
// revision, which is incorrect since the object
// HAS revisions.
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.createRevisionDescriptor(objectUri,
revisionDescriptor);
}
@@ -401,12 +401,12 @@
if (revisionContent != null) {
// Storing the new revision contents
try {
- objectUri.getContentStore()
+ objectUri.getStore()
.storeRevisionContent(objectUri,
revisionDescriptor,
revisionContent);
} catch (RevisionNotFoundException e) {
- objectUri.getContentStore()
+ objectUri.getStore()
.createRevisionContent(objectUri,
revisionDescriptor,
revisionContent);
@@ -421,7 +421,7 @@
// We now store the updated revision descriptors
try {
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.storeRevisionDescriptors(objectUri, revisionDescriptors);
} catch (RevisionDescriptorNotFoundException e) {
// Problem ...
@@ -469,7 +469,7 @@
// Retrieve the revision table
NodeRevisionDescriptors revisionDescriptors =
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.retrieveRevisionDescriptors(objectUri);
if (!revisionDescriptors.isVersioned()) {
@@ -481,7 +481,7 @@
// Retrieve the old revision descriptor, just to make sure that the old
// revision we base the new one upon really exists
NodeRevisionDescriptor realOldRevisionDescriptor =
- objectUri.getDescriptorsStore().retrieveRevisionDescriptor
+ objectUri.getStore().retrieveRevisionDescriptor
(objectUri, oldRevisionDescriptor.getRevisionNumber());
// We check that the old revision doesn't have successors, that is we :
@@ -515,19 +515,19 @@
.setLatestRevision(newRevisionDescriptor.getBranchName(),
newRevisionDescriptor.getRevisionNumber());
// Now creating the revision desriptor in the store
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.createRevisionDescriptor(objectUri, newRevisionDescriptor);
if (revisionContent != null) {
// Storing the new revision contents
- objectUri.getContentStore()
+ objectUri.getStore()
.createRevisionContent(objectUri, newRevisionDescriptor,
revisionContent);
}
// We now store the updated revision descriptors
try {
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.storeRevisionDescriptors(objectUri, revisionDescriptors);
} catch (RevisionDescriptorNotFoundException e) {
// Problem ...
@@ -676,7 +676,7 @@
Uri objectUri = namespace.getUri(revisionDescriptors.getUri());
- objectUri.getDescriptorsStore().removeRevisionDescriptors(objectUri);
+ objectUri.getStore().removeRevisionDescriptors(objectUri);
}
@@ -725,9 +725,9 @@
Uri objectUri = namespace.getUri(strUri);
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.removeRevisionDescriptor(objectUri, revisionNumber);
- objectUri.getContentStore()
+ objectUri.getStore()
.removeRevisionContent(objectUri, revisionNumber);
}
1.10 +19 -19 jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java
Index: LockImpl.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- LockImpl.java 2000/11/16 07:34:50 1.9
+++ LockImpl.java 2000/11/19 04:18:36 1.10
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java,v 1.9 2000/11/16 07:34:50 remm Exp $
- * $Revision: 1.9 $
- * $Date: 2000/11/16 07:34:50 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/LockImpl.java,v 1.10 2000/11/19 04:18:36 remm Exp $
+ * $Revision: 1.10 $
+ * $Date: 2000/11/19 04:18:36 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* Lock helper class.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public final class LockImpl implements Lock {
@@ -149,13 +149,13 @@
// thrown by this function.
if (canLock) {
Uri objectUri = namespace.getUri(token.getObjectUri());
- ObjectNode lockedObject = objectUri.getDescriptorsStore()
+ ObjectNode lockedObject = objectUri.getStore()
.retrieveObject(objectUri);
securityHelper
.checkCredentials(credentialsToken, lockedObject,
namespaceConfig.getLockObjectAction());
Uri lockedUri = namespace.getUri(token.getObjectUri());
- lockedUri.getDescriptorsStore().putLock(lockedUri, token);
+ lockedUri.getStore().putLock(lockedUri, token);
} else {
throw new ObjectIsAlreadyLockedException(token.getObjectUri());
}
@@ -175,7 +175,7 @@
public void unlock(CredentialsToken credentialsToken, NodeLock token)
throws ServiceAccessException, LockTokenNotFoundException {
Uri lockedUri = namespace.getUri(token.getObjectUri());
- lockedUri.getDescriptorsStore().removeLock(lockedUri, token);
+ lockedUri.getStore().removeLock(lockedUri, token);
}
@@ -220,7 +220,7 @@
throws ServiceAccessException, LockTokenNotFoundException {
token.setExpirationDate(newExpirationDate);
Uri lockedUri = namespace.getUri(token.getObjectUri());
- lockedUri.getDescriptorsStore().renewLock(lockedUri, token);
+ lockedUri.getStore().renewLock(lockedUri, token);
}
@@ -270,14 +270,14 @@
// We retrieve the enumeration of locks which have been put on the
// subject.
Uri subjectUri = namespace.getUri(subject.getUri());
- Enumeration locks = subjectUri.getDescriptorsStore()
+ Enumeration locks = subjectUri.getStore()
.enumerateLocks(subjectUri);
// Then, try to kill each individual lock.
while (locks.hasMoreElements()) {
securityHelper
.checkCredentials(credentialsToken, subject,
namespaceConfig.getKillLockAction());
- subjectUri.getDescriptorsStore()
+ subjectUri.getStore()
.killLock(subjectUri, (NodeLock) locks.nextElement());
}
@@ -307,13 +307,13 @@
String currentScope = (String) scopes.nextElement();
Uri currentScopeUri = namespace.getUri(currentScope);
Enumeration currentLocks =
- currentScopeUri.getDescriptorsStore()
+ currentScopeUri.getStore()
.enumerateLocks(currentScopeUri);
while (currentLocks.hasMoreElements()) {
NodeLock currentLockToken =
(NodeLock) currentLocks.nextElement();
if (currentLockToken.hasExpired()) {
- currentScopeUri.getDescriptorsStore()
+ currentScopeUri.getStore()
.removeLock(currentScopeUri, currentLockToken);
} else {
locksVector.addElement(currentLockToken);
@@ -345,13 +345,13 @@
if (Configuration.useIntegratedLocking()) {
Uri objectUri = namespace.getUri(object.getUri());
- ObjectNode realObject = objectUri.getDescriptorsStore()
+ ObjectNode realObject = objectUri.getStore()
.retrieveObject(objectUri);
Uri subjectUri = null;
subjectUri = namespace.getUri(namespaceConfig.getUsersPath() + "/"
+ token.getPublicCredentials());
SubjectNode subject = (SubjectNode) subjectUri
- .getDescriptorsStore().retrieveObject(subjectUri);
+ .getStore().retrieveObject(subjectUri);
checkLock(token, realObject, subject, action);
}
@@ -449,7 +449,7 @@
throws ServiceAccessException, ObjectNotFoundException {
Uri objectUri = namespace.getUri(token.getObjectUri());
- ObjectNode initialObject = objectUri.getDescriptorsStore()
+ ObjectNode initialObject = objectUri.getStore()
.retrieveObject(objectUri);
Enumeration scopes = objectUri.getScopes();
@@ -463,7 +463,7 @@
while (!isLocked && scopes.hasMoreElements()) {
String currentScope = (String) scopes.nextElement();
Uri currentScopeUri = namespace.getUri(currentScope);
- Enumeration locks = currentScopeUri.getDescriptorsStore()
+ Enumeration locks = currentScopeUri.getStore()
.enumerateLocks(currentScopeUri);
while (locks.hasMoreElements()) {
@@ -486,7 +486,7 @@
Uri currentObjectUri =
namespace.getUri(currentObject.getUri());
// We test the compatibility of the child
- Enumeration locks = currentObjectUri.getDescriptorsStore()
+ Enumeration locks = currentObjectUri.getStore()
.enumerateLocks(currentObjectUri);
while (locks.hasMoreElements()) {
@@ -504,7 +504,7 @@
while (childrenUri.hasMoreElements()) {
String childUri = (String) childrenUri.nextElement();
Uri tempUri = namespace.getUri(childUri);
- ObjectNode child = tempUri.getDescriptorsStore()
+ ObjectNode child = tempUri.getStore()
.retrieveObject(tempUri);
childrenVector.addElement(child);
}
@@ -561,7 +561,7 @@
// Since the lock has expired, it is removed
try {
Uri token2Uri = namespace.getUri(token2.getObjectUri());
- token2Uri.getDescriptorsStore().removeLock(token2Uri, token2);
+ token2Uri.getStore().removeLock(token2Uri, token2);
} catch (SlideException e) {
e.printStackTrace();
}
1.10 +12 -12 jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java
Index: SecurityImpl.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SecurityImpl.java 2000/10/08 22:49:28 1.9
+++ SecurityImpl.java 2000/11/19 04:18:37 1.10
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java,v 1.9 2000/10/08 22:49:28 remm Exp $
- * $Revision: 1.9 $
- * $Date: 2000/10/08 22:49:28 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java,v 1.10 2000/11/19 04:18:37 remm Exp $
+ * $Revision: 1.10 $
+ * $Date: 2000/11/19 04:18:37 $
*
* ====================================================================
*
@@ -73,7 +73,7 @@
* Security helper.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public final class SecurityImpl implements Security {
@@ -171,7 +171,7 @@
throws ServiceAccessException, ObjectNotFoundException,
AccessDeniedException {
Uri objectUri = namespace.getUri(permission.getObjectUri());
- ObjectNode object = objectUri.getDescriptorsStore()
+ ObjectNode object = objectUri.getStore()
.retrieveObject(objectUri);
// Checking if the permission is already present
@@ -186,7 +186,7 @@
if (!alreadyPresent) {
checkCredentials(token, object, namespaceConfig
.getGrantPermissionAction());
- objectUri.getDescriptorsStore().grantPermission(objectUri,
+ objectUri.getStore().grantPermission(objectUri,
permission);
}
}
@@ -281,7 +281,7 @@
NodePermission permission = new NodePermission(object, subject,
action);
Uri objectUri = namespace.getUri(object.getUri());
- objectUri.getDescriptorsStore()
+ objectUri.getStore()
.revokePermission(objectUri, permission);
}
@@ -303,14 +303,14 @@
try {
if (Configuration.useIntegratedSecurity()) {
Uri objectUri = namespace.getUri(object.getUri());
- ObjectNode realObject = objectUri.getDescriptorsStore()
+ ObjectNode realObject = objectUri.getStore()
.retrieveObject(objectUri);
Uri subjectUri = null;
subjectUri = namespace.getUri(namespaceConfig.getUsersPath()
+ "/"
+ token.getPublicCredentials());
SubjectNode subject = (SubjectNode) subjectUri
- .getDescriptorsStore().retrieveObject(subjectUri);
+ .getStore().retrieveObject(subjectUri);
checkPermission(realObject, subject, action);
}
} catch (ObjectNotFoundException e) {
@@ -350,7 +350,7 @@
while (!granted && !denied && !rootObjectReached) {
Uri courUri = namespace.getUri(courObject.getUri());
- Enumeration permissions = courUri.getDescriptorsStore()
+ Enumeration permissions = courUri.getStore()
.enumeratePermissions(courUri);
while ((!granted) && (permissions.hasMoreElements())) {
@@ -379,7 +379,7 @@
Uri parentUri = courUri.getParentUri();
if (parentUri != null) {
- courObject = parentUri.getDescriptorsStore()
+ courObject = parentUri.getStore()
.retrieveObject(parentUri);
} else {
rootObjectReached = true;
@@ -433,7 +433,7 @@
throws ServiceAccessException, ObjectNotFoundException,
AccessDeniedException {
Uri objectUri = namespace.getUri(object);
- return objectUri.getDescriptorsStore().enumeratePermissions(objectUri);
+ return objectUri.getStore().enumeratePermissions(objectUri);
}
1.1 jakarta-slide/src/share/org/apache/slide/store/StandardStore.java
Index: StandardStore.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/store/StandardStore.java,v 1.1 2000/11/19 04:18:38 remm Exp $
* $Revision: 1.1 $
* $Date: 2000/11/19 04:18:38 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.store;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.slide.common.*;
import org.apache.slide.structure.*;
import org.apache.slide.security.*;
import org.apache.slide.lock.*;
import org.apache.slide.content.*;
import org.apache.slide.util.ObjectCache;
import org.apache.slide.util.HashMapObjectCache;
/**
* Abstract implementation of a store. Handles all caching operations.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @version $Revision: 1.1 $
*/
public class StandardStore extends ServiceImpl
implements Store {
// ----------------------------------------------------------- Constructors
/**
* Constructor. Handles caches initialization.
*/
public StandardStore() {
super();
objectsCache = new HashMapObjectCache(1000, 10000, 0.95);
permissionsCache = new HashMapObjectCache(1000, 10000, 0.95);
locksCache = new HashMapObjectCache(1000, 10000, 0.95);
descriptorsCache = new HashMapObjectCache(1000, 10000, 0.95);
descriptorCache = new HashMapObjectCache(1000, 10000, 0.8);
}
// ----------------------------------------------------- Instance Variables
/**
* Default store classname.
*/
private String defaultStore =
"slidestore.memory.MemoryDescriptorsStore";
/**
* Nodes cache.
*/
private ObjectCache objectsCache;
/**
* Node store.
*/
private NodeStore nodeStore;
/**
* Permissions cache.
*/
private ObjectCache permissionsCache;
/**
* Security store.
*/
private SecurityStore securityStore;
/**
* Locks cache.
*/
private ObjectCache locksCache;
/**
* Lock store.
*/
private LockStore lockStore;
/**
* Revision descriptors cache.
*/
private ObjectCache descriptorsCache;
/**
* Revision descriptors store.
*/
private RevisionDescriptorsStore revisionDescriptorsStore;
/**
* Revision descriptor cache.
*/
private ObjectCache descriptorCache;
/**
* Revision descriptor store.
*/
private RevisionDescriptorStore revisionDescriptorStore;
/**
* Content store.
*/
private ContentStore contentStore;
// ---------------------------------------------------- ServiceImpl Methods
/**
* Initializes the descriptors store with a set of parameters.
* Those could be :
* <li>User name, login info
* <li>Host name on which to connect
* <li>Remote port
* <li>JDBC driver whoich is to be used :-)
* <li>Anything else ...
*
* @param parameters Hashtable containing the parameters' name
* and associated value
* @exception ServiceParameterErrorException Incorrect service parameter
* @exception ServiceParameterMissingException Service parameter missing
*/
public void setParameters(Hashtable parameters)
throws ServiceParameterErrorException,
ServiceParameterMissingException {
}
/**
* Connects to descriptors store.
*
* @exception DataException
*/
public void connect()
throws ServiceConnectionFailedException {
lockStore.connect();
nodeStore.connect();
securityStore.connect();
revisionDescriptorsStore.connect();
revisionDescriptorStore.connect();
contentStore.connect();
}
/**
* Disconnects from descriptors store.
*
* @exception ServiceDisconnectionFailedException
*/
public void disconnect()
throws ServiceDisconnectionFailedException {
lockStore.disconnect();
nodeStore.disconnect();
securityStore.disconnect();
revisionDescriptorsStore.disconnect();
revisionDescriptorStore.disconnect();
contentStore.disconnect();
}
/**
* Initializes descriptors store.
*
* @exception ServiceInitializationFailedException Throws an exception
* if the descriptors store has already been initialized before
*/
public void initialize(NamespaceAccessToken token)
throws ServiceInitializationFailedException {
Service defaultStore = null;
try {
defaultStore =
(Service) Class.forName(this.defaultStore).newInstance();
defaultStore.initialize(token);
} catch (Throwable t) {
// Should never happen ...
t.printStackTrace();
}
if (lockStore != null) {
lockStore.initialize(token);
} else {
lockStore = (LockStore) defaultStore;
}
if (nodeStore != null) {
nodeStore.initialize(token);
} else {
nodeStore = (NodeStore) defaultStore;
}
if (securityStore != null) {
securityStore.initialize(token);
} else {
securityStore = (SecurityStore) defaultStore;
}
if (revisionDescriptorsStore != null) {
revisionDescriptorsStore.initialize(token);
} else {
revisionDescriptorsStore = (RevisionDescriptorsStore) defaultStore;
}
if (revisionDescriptorStore != null) {
revisionDescriptorStore.initialize(token);
} else {
revisionDescriptorStore = (RevisionDescriptorStore) defaultStore;
}
if (contentStore != null) {
contentStore.initialize(token);
} else {
contentStore = (ContentStore) defaultStore;
}
}
/**
* Deletes descriptors store. Should remove stored data if possible.
*
* @exception ServiceResetFailedException Reset failed
*/
public void reset()
throws ServiceResetFailedException {
lockStore.reset();
nodeStore.reset();
securityStore.reset();
revisionDescriptorsStore.reset();
revisionDescriptorStore.reset();
}
/**
* Does nothing.
*
* @exception ServiceAccessException Service access error
*/
public void commit()
throws ServiceAccessException {
lockStore.commit();
nodeStore.commit();
securityStore.commit();
revisionDescriptorsStore.commit();
revisionDescriptorStore.commit();
}
/**
* This function tells whether or not the descriptors store is connected.
*
* @return boolean true if we are connected
* @exception ServiceAccessException Service access error
*/
public boolean isConnected()
throws ServiceAccessException {
return (lockStore.isConnected() && nodeStore.isConnected() &&
securityStore.isConnected() &&
revisionDescriptorsStore.isConnected() &&
revisionDescriptorStore.isConnected());
}
// ----------------------------------------------- DescriptorsStore Methods
/**
* Set the node store associated with this store.
*/
public void setNodeStore(NodeStore nodeStore) {
this.nodeStore = nodeStore;
}
/**
* Set the security store associated with this store.
*/
public void setSecurityStore(SecurityStore securityStore) {
this.securityStore = securityStore;
}
/**
* Set the lock store associated with this store.
*/
public void setLockStore(LockStore lockStore) {
this.lockStore = lockStore;
}
/**
* Set the revision descriptors store associated with this store.
*/
public void setRevisionDescriptorsStore
(RevisionDescriptorsStore revisionDescriptorsStore) {
this.revisionDescriptorsStore = revisionDescriptorsStore;
}
/**
* Set the revision descriptor store associated with this store.
*/
public void setRevisionDescriptorStore
(RevisionDescriptorStore revisionDescriptorStore) {
this.revisionDescriptorStore = revisionDescriptorStore;
}
/**
* Set the content store associated with this store.
*/
public void setContentStore(ContentStore contentStore) {
this.contentStore = contentStore;
}
/**
* Retrive an object from the Descriptors Store.
*
* @param uri Uri of the object we want to retrieve
* @exception ServiceAccessException Error accessing the Descriptors Store
* @exception ObjectNotFoundException The object to retrieve was not found
*/
public ObjectNode retrieveObject(Uri uri)
throws ServiceAccessException, ObjectNotFoundException {
if (nodeStore.cacheResults()) {
Object tempObject = objectsCache.get(uri.toString());
if (tempObject != null) {
return ((ObjectNode) tempObject).cloneObject();
} else {
ObjectNode objectNode = nodeStore.retrieveObject(uri);
objectsCache.put(uri.toString(), objectNode.cloneObject());
return objectNode;
}
} else {
return nodeStore.retrieveObject(uri);
}
}
/**
* Store an object in the Descriptors Store.
*
* @param object Object to update
* @exception ServiceAccessException Error accessing the Descriptors Store
* @exception ObjectNotFoundException The object to update was not found
*/
public void storeObject(Uri uri, ObjectNode object)
throws ServiceAccessException, ObjectNotFoundException {
ObjectNode tempObject = object.cloneObject();
nodeStore.storeObject(uri, tempObject);
if (nodeStore.cacheResults()) {
objectsCache.put(uri.toString(), tempObject);
}
}
/**
* Create a new object in the Descriptors Store.
*
* @param object SlideObject
* @param uri Uri of the object we want to create
* @exception ServiceAccessException Error accessing the Descriptors Store
* @exception ObjectAlreadyExistsException An object already exists
* at this Uri
*/
public void createObject(Uri uri, ObjectNode object)
throws ServiceAccessException, ObjectAlreadyExistsException {
ObjectNode tempObject = object.cloneObject();
nodeStore.createObject(uri, tempObject);
if (nodeStore.cacheResults()) {
objectsCache.put(uri.toString(), tempObject);
}
}
/**
* Remove an object from the Descriptors Store.
*
* @param object Object to remove
* @exception ServiceAccessException Error accessing the Descriptors Store
* @exception ObjectNotFoundException The object to remove was not found
*/
public void removeObject(Uri uri, ObjectNode object)
throws ServiceAccessException, ObjectNotFoundException {
nodeStore.removeObject(uri, object);
if (nodeStore.cacheResults()) {
objectsCache.remove(uri.toString());
}
}
/**
* Store an object permissions in the Descriptors Store.
*
* @param permission Permission we want to create
* @exception ServiceAccessException Error accessing the Descriptors Store
*/
public void grantPermission(Uri uri, NodePermission permission)
throws ServiceAccessException {
NodePermission tempPermission = permission.cloneObject();
securityStore.grantPermission(uri, tempPermission);
if (securityStore.cacheResults()) {
Object value = permissionsCache.get(uri.toString());
Vector permissionsVector = null;
if (value == null) {
permissionsVector = new Vector();
permissionsCache.put(uri.toString(), permissionsVector);
} else {
permissionsVector = (Vector) value;
}
permissionsVector.addElement(tempPermission);
}
}
/**
* Store an object permissions in the Descriptors Store.
*
* @param permission Permission we want to create
* @exception ServiceAccessException Error accessing the Descriptors Store
*/
public void revokePermission(Uri uri, NodePermission permission)
throws ServiceAccessException {
securityStore.revokePermission(uri, permission);
if (securityStore.cacheResults()) {
Object value = permissionsCache.get(uri.toString());
Vector permissionsVector = null;
if (value != null) {
permissionsVector = (Vector) value;
permissionsVector.removeElement(permission);
}
}
}
/**
* Revoke all the permissions on the object.
*
* @param permission Permission we want to create
* @exception ServiceAccessException Error accessing the Descriptors Store
*/
public void revokePermissions(Uri uri)
throws ServiceAccessException {
securityStore.revokePermissions(uri);
if (securityStore.cacheResults()) {
Object value = permissionsCache.get(uri.toString());
Vector permissionsVector = null;
if (value != null) {
permissionsVector = (Vector) value;
permissionsVector.removeAllElements();
}
}
}
/**
* Read an object permissions.
*
* @param permission Permission we want to create
* @exception ServiceAccessException Error accessing the Descriptors Store
*/
public Enumeration enumeratePermissions(Uri uri)
throws ServiceAccessException {
// TODO : The vectors elements MUST be cloned
if (securityStore.cacheResults()) {
Object value = permissionsCache.get(uri.toString());
Vector permissionsVector = null;
if (value != null) {
permissionsVector = (Vector) value;
return permissionsVector.elements();
} else {
permissionsVector = new Vector();
Enumeration tempEnum = securityStore.enumeratePermissions(uri);
while (tempEnum.hasMoreElements()) {
permissionsVector.addElement(tempEnum.nextElement());
}
permissionsCache.put(uri.toString(), permissionsVector);
return permissionsVector.elements();
}
} else {
return securityStore.enumeratePermissions(uri);
}
}
/**
* Puts a lock on a subject.
*
* @param lock Lock token
* @exception ServiceAccessException Service access error
*/
public void putLock(Uri uri, NodeLock lock)
throws ServiceAccessException {
lockStore.putLock(uri, lock);
if (lockStore.cacheResults()) {
Object value = locksCache.get(uri.toString());
Vector locksVector = null;
if (value == null) {
locksVector = new Vector();
locksCache.put(uri.toString(), locksVector);
} else {
locksVector = (Vector) value;
}
locksVector.addElement(lock.cloneObject());
}
}
/**
* Renews a lock.
*
* @param lock Token to renew
* @exception ServiceAccessException Service access error
* @exception LockTokenNotFoundException Lock token was not found
*/
public void renewLock(Uri uri, NodeLock lock)
throws ServiceAccessException, LockTokenNotFoundException {
lockStore.renewLock(uri, lock);
if (lockStore.cacheResults()) {
Object value = locksCache.get(uri.toString());
Vector locksVector = null;
if (value != null) {
locksVector = (Vector) value;
boolean wasPresent = locksVector.removeElement(lock);
if (!wasPresent) {
throw new LockTokenNotFoundException(lock);
}
locksVector.addElement(lock.cloneObject());
}
}
}
/**
* Removes (cancels) a lock.
*
* @param lock Token to remove
* @exception ServiceAccessException Service access error
* @exception LockTokenNotFoundException Lock token was not found
*/
public void removeLock(Uri uri, NodeLock lock)
throws ServiceAccessException, LockTokenNotFoundException {
lockStore.removeLock(uri, lock);
if (lockStore.cacheResults()) {
Object value = locksCache.get(uri.toString());
Vector locksVector = null;
if (value != null) {
locksVector = (Vector) value;
boolean wasPresent = locksVector.removeElement(lock);
if (!wasPresent) {
throw new LockTokenNotFoundException(lock);
}
}
}
}
/**
* Kills a lock.
*
* @param lock Token to remove
* @exception ServiceAccessException Service access error
* @exception LockTokenNotFoundException Lock token was not found
*/
public void killLock(Uri uri, NodeLock lock)
throws ServiceAccessException, LockTokenNotFoundException {
lockStore.killLock(uri, lock);
if (lockStore.cacheResults()) {
Object value = locksCache.get(uri.toString());
Vector locksVector = null;
if (value != null) {
locksVector = (Vector) value;
boolean wasPresent = locksVector.removeElement(lock);
if (!wasPresent) {
throw new LockTokenNotFoundException(lock);
}
}
}
}
/**
* Returns the list of locks put on a subject.
*
* @param subject Subject
* @return Enumeration List of locks which have been put on the subject
* @exception ServiceAccessException Service access error
*/
public Enumeration enumerateLocks(Uri uri)
throws ServiceAccessException {
if (lockStore.cacheResults()) {
Object value = locksCache.get(uri.toString());
Vector locksVector = null;
if (value == null) {
locksVector = new Vector();
Enumeration lockList = lockStore.enumerateLocks(uri);
while (lockList.hasMoreElements()) {
locksVector.addElement(lockList.nextElement());
}
locksCache.put(uri.toString(), locksVector);
} else {
locksVector = (Vector) value;
}
return locksVector.elements();
} else {
return lockStore.enumerateLocks(uri);
}
}
/**
* Retrieve a revision descriptors.
*
* @param uri Uri
* @exception ServiceAccessException Service access error
* @exception RevisionDescriptorNotFoundException Revision descriptor
* was not found
*/
public NodeRevisionDescriptors retrieveRevisionDescriptors(Uri uri)
throws ServiceAccessException, RevisionDescriptorNotFoundException {
if (revisionDescriptorsStore.cacheResults()) {
Object tempObject = descriptorsCache.get(uri.toString());
if (tempObject != null) {
return ((NodeRevisionDescriptors) tempObject).cloneObject();
} else {
NodeRevisionDescriptors revisionDescriptors =
revisionDescriptorsStore.retrieveRevisionDescriptors(uri);
revisionDescriptors = revisionDescriptors.cloneObject();
descriptorsCache.put(uri.toString(),
revisionDescriptors);
return revisionDescriptors;
}
} else {
return
revisionDescriptorsStore.retrieveRevisionDescriptors(uri);
}
}
/**
* Create new revision descriptors.
*
* @param uri Uri
* @param revisionDescriptors Node revision descriptors
* @exception ServiceAccessException Service access error
*/
public void createRevisionDescriptors
(Uri uri, NodeRevisionDescriptors revisionDescriptors)
throws ServiceAccessException {
if (revisionDescriptorsStore.cacheResults()) {
descriptorsCache.put(uri.toString(),
revisionDescriptors.cloneObject());
}
revisionDescriptorsStore.createRevisionDescriptors
(uri, revisionDescriptors);
}
/**
* Update revision descriptors.
*
* @param uri Uri
* @param revisionDescriptors Node revision descriptors
* @exception ServiceAccessException Service access error
* @exception RevisionDescriptorNotFoundException Revision descriptor
* was not found
*/
public void storeRevisionDescriptors
(Uri uri, NodeRevisionDescriptors revisionDescriptors)
throws ServiceAccessException, RevisionDescriptorNotFoundException {
if (revisionDescriptorsStore.cacheResults()) {
descriptorsCache.put(uri.toString(),
revisionDescriptors.cloneObject());
}
revisionDescriptorsStore.storeRevisionDescriptors
(uri, revisionDescriptors);
}
/**
* Remove revision descriptors.
*
* @param uri Uri
* @exception ServiceAccessException Service access error
*/
public void removeRevisionDescriptors(Uri uri)
throws ServiceAccessException {
if (revisionDescriptorsStore.cacheResults()) {
descriptorsCache.remove(uri.toString());
}
revisionDescriptorsStore.removeRevisionDescriptors(uri);
}
/**
* Retrieve revision descriptor.
*
* @param Uri uri
* @param revisionNumber Node revision number
*/
public NodeRevisionDescriptor retrieveRevisionDescriptor
(Uri uri, NodeRevisionNumber revisionNumber)
throws ServiceAccessException, RevisionDescriptorNotFoundException {
if (revisionDescriptorStore.cacheResults()) {
Object result = descriptorCache.get(uri + "-" + revisionNumber);
if (result != null) {
return ((NodeRevisionDescriptor) result).cloneObject();
} else {
NodeRevisionDescriptor revisionDescriptor =
revisionDescriptorStore
.retrieveRevisionDescriptor(uri, revisionNumber)
.cloneObject();
descriptorCache.put(uri + "-" + revisionNumber,
revisionDescriptor);
return revisionDescriptor;
}
} else {
return revisionDescriptorStore
.retrieveRevisionDescriptor(uri, revisionNumber);
}
}
/**
* Create new revision descriptor.
*
* @param uri Uri
* @param revisionDescriptor Node revision descriptor
* @exception ServiceAccessException Service access error
*/
public void createRevisionDescriptor
(Uri uri, NodeRevisionDescriptor revisionDescriptor)
throws ServiceAccessException {
revisionDescriptorStore.createRevisionDescriptor
(uri, revisionDescriptor);
if (revisionDescriptorStore.cacheResults()) {
descriptorCache.put(uri + "-"
+ revisionDescriptor.getRevisionNumber(),
revisionDescriptor.cloneObject());
}
}
/**
* Update revision descriptor.
*
* @param uri Uri
* @param revisionDescriptors Node revision descriptor
* @exception ServiceAccessException Service access error
* @exception RevisionDescriptorNotFoundException Revision descriptor
* was not found
*/
public void storeRevisionDescriptor
(Uri uri, NodeRevisionDescriptor revisionDescriptor)
throws ServiceAccessException, RevisionDescriptorNotFoundException {
revisionDescriptorStore.storeRevisionDescriptor
(uri, revisionDescriptor);
if (revisionDescriptorStore.cacheResults()) {
String key = uri + "-" + revisionDescriptor.getRevisionNumber();
descriptorCache.put(key, revisionDescriptor.cloneObject());
}
}
/**
* Remove revision descriptor.
*
* @param uri Uri
* @param revisionNumber Revision number
* @exception ServiceAccessException Service access error
*/
public void removeRevisionDescriptor(Uri uri, NodeRevisionNumber number)
throws ServiceAccessException {
revisionDescriptorStore.removeRevisionDescriptor(uri, number);
if (revisionDescriptorStore.cacheResults()) {
descriptorCache.remove(uri + "-" + number);
}
}
/**
* Retrive revision content.
*
* @param uri Uri
* @param revisionNumber Node revision number
*/
public NodeRevisionContent retrieveRevisionContent
(Uri uri, NodeRevisionNumber revisionNumber)
throws ServiceAccessException, RevisionNotFoundException {
return contentStore.retrieveRevisionContent(uri, revisionNumber);
}
/**
* Create a new revision
*
* @param uri Uri
* @param revisionDescriptor Node revision descriptor
* @param revisionContent Node revision content
*/
public void createRevisionContent
(Uri uri, NodeRevisionDescriptor revisionDescriptor,
NodeRevisionContent revisionContent)
throws ServiceAccessException, RevisionAlreadyExistException {
contentStore.createRevisionContent(uri, revisionDescriptor,
revisionContent);
}
/**
* Modify the latest revision of an object.
*
* @param uri Uri
* @param revisionDescriptor Node revision descriptor
* @param revisionContent Node revision content
*/
public void storeRevisionContent
(Uri uri, NodeRevisionDescriptor revisionDescriptor,
NodeRevisionContent revisionContent)
throws ServiceAccessException, RevisionNotFoundException {
contentStore.storeRevisionContent(uri, revisionDescriptor,
revisionContent);
}
/**
* Remove revision.
*
* @param uri Uri
* @param revisionNumber Node revision number
*/
public void removeRevisionContent(Uri uri,
NodeRevisionNumber revisionNumber)
throws ServiceAccessException {
contentStore.removeRevisionContent(uri, revisionNumber);
}
}
1.1 jakarta-slide/src/share/org/apache/slide/store/Store.java
Index: Store.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/store/Store.java,v 1.1 2000/11/19 04:18:38 remm Exp $
* $Revision: 1.1 $
* $Date: 2000/11/19 04:18:38 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.store;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Date;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.slide.common.*;
import org.apache.slide.structure.*;
import org.apache.slide.security.*;
import org.apache.slide.lock.*;
import org.apache.slide.content.*;
/**
* Represents a store which is used by the Slide API to access data.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @version $Revision: 1.1 $
*/
public interface Store extends Service {
// ------------------------------------------------------ Interface Methods
/**
* Set the node store associated with this store.
*/
void setNodeStore(NodeStore nodeStore);
/**
* Set the security store associated with this store.
*/
void setSecurityStore(SecurityStore securityStore);
/**
* Set the lock store associated with this store.
*/
void setLockStore(LockStore lockStore);
/**
* Set the revision descriptors store associated with this store.
*/
void setRevisionDescriptorsStore
(RevisionDescriptorsStore revisionDescriptorsStore);
/**
* Set the revision descriptor store associated with this store.
*/
void setRevisionDescriptorStore
(RevisionDescriptorStore revisionDescriptorStore);
/**
* Set the content store associated with this store.
*/
void setContentStore(ContentStore contentStore);
/**
* Retrive an object.
*
* @param uri Uri of the object we want to retrieve
* @exception ServiceAccessException Error accessing the Data Source
* @exception ObjectNotFoundException The object to retrieve was not found
*/
ObjectNode retrieveObject(Uri uri)
throws ServiceAccessException, ObjectNotFoundException;
/**
* Update an object.
*
* @param object Object to update
* @exception ServiceAccessException Error accessing the Data Source
* @exception ObjectNotFoundException The object to update was not found
*/
void storeObject(Uri uri, ObjectNode object)
throws ServiceAccessException, ObjectNotFoundException;
/**
* Create a new object.
*
* @param object ObjectNode
* @param uri Uri of the object we want to create
* @exception ServiceAccessException Error accessing the Data Source
* @exception ObjectAlreadyExistsException An object already exists
* at this Uri
*/
void createObject(Uri uri, ObjectNode object)
throws ServiceAccessException, ObjectAlreadyExistsException;
/**
* Remove an object.
*
* @param object Object to remove
* @exception ServiceAccessException Error accessing the Data Source
* @exception ObjectNotFoundException The object to remove was not found
*/
void removeObject(Uri uri, ObjectNode object)
throws ServiceAccessException, ObjectNotFoundException;
/**
* Grant a new permission.
*
* @param permission Permission we want to create
* @exception ServiceAccessException Error accessing the Data Source
*/
void grantPermission(Uri uri, NodePermission permission)
throws ServiceAccessException;
/**
* Revoke a permission.
*
* @param permission Permission we want to create
* @exception ServiceAccessException Error accessing the Data Source
*/
void revokePermission(Uri uri, NodePermission permission)
throws ServiceAccessException;
/**
* Revoke all the permissions on an object.
*
* @param permission Permission we want to create
* @exception ServiceAccessException Error accessing the Data Source
*/
void revokePermissions(Uri uri)
throws ServiceAccessException;
/**
* Enumerate permissions on an object.
*
* @param permission Permission we want to create
* @exception ServiceAccessException Error accessing the Data Source
*/
Enumeration enumeratePermissions(Uri uri)
throws ServiceAccessException;
/**
* Create a new lock.
*
* @param lock Lock token
* @exception ServiceAccessException Service access error
*/
void putLock(Uri uri, NodeLock lock)
throws ServiceAccessException;
/**
* Renew a lock.
*
* @param lock Token to renew
* @exception ServiceAccessException Service access error
* @exception LockTokenNotFoundException Lock token was not found
*/
void renewLock(Uri uri, NodeLock lock)
throws ServiceAccessException, LockTokenNotFoundException;
/**
* Unlock.
*
* @param lock Token to remove
* @exception ServiceAccessException Service access error
* @exception LockTokenNotFoundException Lock token was not found
*/
void removeLock(Uri uri, NodeLock lock)
throws ServiceAccessException, LockTokenNotFoundException;
/**
* Kill a lock.
*
* @param lock Token to remove
* @exception ServiceAccessException Service access error
* @exception LockTokenNotFoundException Lock token was not found
*/
void killLock(Uri uri, NodeLock lock)
throws ServiceAccessException, LockTokenNotFoundException;
/**
* Enumerate locks on an object.
*
* @param subject Subject
* @return Enumeration List of locks which have been put on the subject
* @exception ServiceAccessException Service access error
*/
Enumeration enumerateLocks(Uri uri)
throws ServiceAccessException;
/**
* Retrieve the revisions informations of an object.
*
* @param uri Uri
* @exception ServiceAccessException Service access error
* @exception RevisionDescriptorNotFoundException Revision descriptor
* was not found
*/
NodeRevisionDescriptors retrieveRevisionDescriptors(Uri uri)
throws ServiceAccessException, RevisionDescriptorNotFoundException;
/**
* Create a new revision information object.
*
* @param uri Uri
* @param revisionDescriptors Node revision descriptors
* @exception ServiceAccessException Service access error
*/
void createRevisionDescriptors(Uri uri,
NodeRevisionDescriptors revisionDescriptors)
throws ServiceAccessException;
/**
* Update revision information.
*
* @param uri Uri
* @param revisionDescriptors Node revision descriptors
* @exception ServiceAccessException Service access error
* @exception RevisionDescriptorNotFoundException Revision descriptor
* was not found
*/
void storeRevisionDescriptors(Uri uri,
NodeRevisionDescriptors revisionDescriptors)
throws ServiceAccessException, RevisionDescriptorNotFoundException;
/**
* Remove revision information.
*
* @param uri Uri
* @exception ServiceAccessException Service access error
*/
void removeRevisionDescriptors(Uri uri)
throws ServiceAccessException;
/**
* Retrieve an individual object's revision descriptor.
*
* @param Uri uri
* @param revisionNumber Node revision number
*/
NodeRevisionDescriptor retrieveRevisionDescriptor
(Uri uri, NodeRevisionNumber revisionNumber)
throws ServiceAccessException, RevisionDescriptorNotFoundException;
/**
* Create a new revision descriptor.
*
* @param uri Uri
* @param revisionDescriptor Node revision descriptor
* @exception ServiceAccessException Service access error
*/
void createRevisionDescriptor(Uri uri,
NodeRevisionDescriptor revisionDescriptor)
throws ServiceAccessException;
/**
* Update a revision descriptor.
*
* @param uri Uri
* @param revisionDescriptors Node revision descriptor
* @exception ServiceAccessException Service access error
* @exception RevisionDescriptorNotFoundException Revision descriptor
* was not found
*/
void storeRevisionDescriptor(Uri uri,
NodeRevisionDescriptor revisionDescriptor)
throws ServiceAccessException, RevisionDescriptorNotFoundException;
/**
* Remove a revision descriptor.
*
* @param uri Uri
* @param revisionNumber Revision number
* @exception ServiceAccessException Service access error
*/
void removeRevisionDescriptor(Uri uri, NodeRevisionNumber number)
throws ServiceAccessException;
/**
* Retrive revision content.
*
* @param uri Uri
* @param revisionNumber Node revision number
*/
NodeRevisionContent retrieveRevisionContent
(Uri uri, NodeRevisionNumber revisionNumber)
throws ServiceAccessException, RevisionNotFoundException;
/**
* Create a new revision
*
* @param uri Uri
* @param revisionDescriptor Node revision descriptor
* @param revisionContent Node revision content
*/
void createRevisionContent
(Uri uri, NodeRevisionDescriptor revisionDescriptor,
NodeRevisionContent revisionContent)
throws ServiceAccessException, RevisionAlreadyExistException;
/**
* Modify the latest revision of an object.
*
* @param uri Uri
* @param revisionDescriptor Node revision descriptor
* @param revisionContent Node revision content
*/
void storeRevisionContent
(Uri uri, NodeRevisionDescriptor revisionDescriptor,
NodeRevisionContent revisionContent)
throws ServiceAccessException, RevisionNotFoundException;
/**
* Remove revision.
*
* @param uri Uri
* @param revisionNumber Node revision number
*/
void removeRevisionContent(Uri uri, NodeRevisionNumber revisionNumber)
throws ServiceAccessException;
}
1.7 +12 -13 jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java
Index: StructureImpl.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StructureImpl.java 2000/09/26 02:44:26 1.6
+++ StructureImpl.java 2000/11/19 04:18:38 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java,v 1.6 2000/09/26 02:44:26 remm Exp $
- * $Revision: 1.6 $
- * $Date: 2000/09/26 02:44:26 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java,v 1.7 2000/11/19 04:18:38 remm Exp $
+ * $Revision: 1.7 $
+ * $Date: 2000/11/19 04:18:38 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* Data helper class.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public final class StructureImpl implements Structure {
@@ -233,13 +233,13 @@
// First of all, we try to load the object directly from the given Uri.
try {
- result = uri.getDescriptorsStore().retrieveObject(uri);
+ result = uri.getStore().retrieveObject(uri);
securityHelper.checkCredentials
(token, result, namespaceConfig.getReadObjectAction());
if ((translateLastUriElement) && (result instanceof LinkNode)) {
LinkNode link = (LinkNode) result;
Uri linkedUri = namespace.getUri(link.getLinkedUri());
- result = linkedUri.getDescriptorsStore()
+ result = linkedUri.getStore()
.retrieveObject(linkedUri);
securityHelper.checkCredentials
(token, result, namespaceConfig.getReadObjectAction());
@@ -266,7 +266,7 @@
// 3 - Load object's class from the uri. If the object
// does not exist, a DataException is thrown.
courUri = uriTokenizer.nextUri();
- courObject = courUri.getDescriptorsStore()
+ courObject = courUri.getStore()
.retrieveObject(courUri);
// We check to see if the credentials gives access to
@@ -370,7 +370,7 @@
// not exist, a DataException is thrown.
courUri = uriTokenizer.nextUri();
try {
- courObject = courUri.getDescriptorsStore()
+ courObject = courUri.getStore()
.retrieveObject(courUri);
securityHelper
.checkCredentials(token, courObject,
@@ -464,7 +464,7 @@
// Now creating the new object
newObject.setUri(courUri.toString());
- courUri.getDescriptorsStore().createObject
+ courUri.getStore().createObject
(courUri, newObject);
// Add the newly created object to its parent's
@@ -576,7 +576,7 @@
.checkCredentials(token, realObject,
namespaceConfig.getCreateObjectAction());
Uri realObjectUri = namespace.getUri(realObject.getUri());
- realObjectUri.getDescriptorsStore().storeObject(realObjectUri, object);
+ realObjectUri.getStore().storeObject(realObjectUri, object);
}
@@ -610,13 +610,12 @@
if (!object.getUri().equals("/")) {
Uri curUri = namespace.getUri(realObject.getUri());
Uri parentUri = curUri.getParentUri();
- ObjectNode obj = parentUri.getDescriptorsStore()
- .retrieveObject(parentUri);
+ ObjectNode obj = parentUri.getStore().retrieveObject(parentUri);
obj.removeChild(realObject.getUri());
securityHelper.checkCredentials
(token, realObject, namespaceConfig.getRemoveObjectAction());
store(token, obj);
- uri.getDescriptorsStore().removeObject(uri, realObject);
+ uri.getStore().removeObject(uri, realObject);
}
}