Namespace.java

Index Score
org.apache.slide.common
Jakarta Slide

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
EXEC_COMMENTSComments in executable code
LINE_COMMENTNumber of line comments
SIZESize of the file in bytes
DECL_COMMENTSComments in declarations
COMMENTSComment lines
DOC_COMMENTNumber of javadoc comment lines
LINESNumber of lines in the source file
RETURNSNumber of return points from functions
INTERFACE_COMPLEXITYInterface complexity
EXITSProcedure exits
OPERANDSNumber of operands
UNIQUE_OPERANDSNumber of unique operands
ELOCEffective lines of code
PROGRAM_LENGTHHalstead program length
PROGRAM_VOCABHalstead program vocabulary
LOGICAL_LINESNumber of statements
OPERATORSNumber of operators
WHITESPACENumber of whitespace lines
LOCLines of code
BLOCKSNumber of blocks
JAVA0034JAVA0034 Missing braces in if statement
JAVA0126JAVA0126 Method declares unchecked exception in throws
CYCLOMATICCyclomatic complexity
JAVA0166JAVA0166 Generic exception caught
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0116JAVA0116 Missing javadoc: field 'field'
JAVA0242JAVA0242 Transient field in non-Serializable class
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
PARAMSNumber of formal parameter declarations
LOOPSNumber of loops
JAVA0144JAVA0144 Line exceeds maximum M characters
FUNCTIONSNumber of function declarations
JAVA0009JAVA0009 Protected member in final class
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0160JAVA0160 Method does not throw specified exception
COMPARISONSNumber of comparison operators
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0177JAVA0177 Variable declaration missing initializer
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0174JAVA0174 Assigned local variable never used
UNIQUE_OPERATORSNumber of unique operators
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0075JAVA0075 Method parameter hides field
JAVA0145JAVA0145 Tab character used in source file
/* * $Header$ * $Revision: 231018 $ * $Date: 2005-08-09 06:55:21 -0400 (Tue, 09 Aug 2005) $ * * ==================================================================== * * Copyright 1999-2002 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.slide.common; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.Vector; import javax.transaction.Status; import javax.transaction.SystemException; import javax.transaction.TransactionManager; import org.apache.slide.authenticate.CredentialsToken; import org.apache.slide.content.ContentInterceptor; import org.apache.slide.extractor.Extractor; import org.apache.slide.extractor.ExtractorManager; import org.apache.slide.store.ContentStore; import org.apache.slide.store.DefaultIndexer; import org.apache.slide.store.IndexStore; import org.apache.slide.store.LockStore; import org.apache.slide.store.MacroStore; import org.apache.slide.store.NodeStore; import org.apache.slide.store.RevisionDescriptorStore; import org.apache.slide.store.RevisionDescriptorsStore; import org.apache.slide.store.SecurityStore; import org.apache.slide.store.SequenceStore; import org.apache.slide.store.Store; import org.apache.slide.structure.ObjectAlreadyExistsException; import org.apache.slide.structure.SubjectNode; import org.apache.slide.transaction.SlideTransactionManager; import org.apache.slide.util.conf.Configurable; import org.apache.slide.util.conf.Configuration; import org.apache.slide.util.conf.ConfigurationException; import org.apache.slide.util.logger.Logger; /** * A Namespace contains a hierarchically organized tree of information. * * <p> * Objects in the namespace are generally referred to as <i>Nodes</i>. Nodes * may have a parent, children, content and meta-data. They can also be * versioned (so that multiple revisions of the object's content and * metadata are stored) and locked (so that only specific principals are * allowed to read or modify the object). In addition, access control * information can be assigned to every node. * </p> * <p> * Nodes in the hierarchy are identified by their URI (Unique Resource * Identifier). A URI is analogous to a file path in traditional file * systems. For example: * <pre> * /users/john/documents/my_document.txt * </pre> * As you can see, the slash (&quot;/&quot;) is used to separate nodes in the path. * </p> * <p> * Client applications can not access a Namespace object directly. Instead, * access must be requested from the {@link Domain Domain}, which will hand * out a proxy object ({@link NamespaceAccessToken NamespaceAccessToken}) * that enables the client application to access the namespace using the * helpers. * </p> * <p> * Namespaces are necessarily self-contained. What this means is that a * namespace cannot reference or contain links to another namespace. A * namespace is typically assigned per-application, which effectively * isolates it's data and security context from those of other applications. * </p> * * @version $Revision: 231018 $ */ public final class Namespace { // -------------------------------------------------------------- Constants public static final String REFERENCE = "reference"; public static final String NODE_STORE = "nodestore"; public static final String SECURITY_STORE = "securitystore"; public static final String LOCK_STORE = "lockstore"; public static final String REVISION_DESCRIPTORS_STORE = "revisiondescriptorsstore"; public static final String REVISION_DESCRIPTOR_STORE = "revisiondescriptorstore"; public static final String CONTENT_STORE = "contentstore"; public static final String PROPERTIES_INDEX_STORE = "propertiesindexer"; public static final String CONTENT_INDEX_STORE = "contentindexer"; public static final String SEQUENCE_STORE = "sequencestore"; public static final String MACRO_STORE = "macrostore"; /** * Log channel for logger */ private static final String LOG_CHANNEL = Namespace.class.getName(); protected static final String I_CREATESTORELISTENERCLASS = "createStoreListenerClass"; protected static final String I_CREATESTORELISTENERCLASS_DEFAULT = "org.apache.slide.webdav.util.UriHandler"; protected static Class createStoreListenerClass; static { try { String createStoreListenerClassName = Domain.getParameter(I_CREATESTORELISTENERCLASS, I_CREATESTORELISTENERCLASS_DEFAULT); createStoreListenerClass = Class.forName( createStoreListenerClassName ); } catch( Exception x ) { Domain.warn( "Loading of create_store_listener class failed: "+x.getMessage() ); } } // ----------------------------------------------------- Instance Variables /** * Namespace name. */ private String name; /** * classname of the search implementation */ private String searchClassName; /** * Static Vector which holds a reference, and provides access to all * the services instances used by the Slide namespace. */ private transient Vector connectedServices; /** * Registered DescriptorStores on this Namespace. */ private transient Hashtable stores; /** * Current namespace configuration. */ private NamespaceConfig config; /** * Default descriptors store classname. */ private String defaultStoreClassname = "org.apache.slide.store.ExtendedStore"; /** * Transaction manager associated with this namespace. */ private TransactionManager transactionManager = new SlideTransactionManager(); /** * Logger. */ private Logger logger; /** * Application logger. */ private Logger applicationLogger; // ------------------------------------------------------------ Constructor /** * Constructor. */ Namespace() { stores = new Hashtable(); connectedServices = new Vector(); name = new String(); } // ------------------------------------------------------------- Properties /** * Sets the qualified name of the namespace. * * @param name Name of the namespace */ public void setName(String name) { this.name = name; } /** * Gets the qulified name of the namespace. * * @return String Namespace name */ public String getName() { return name; } /** * Method setSearchClassName * * @param searchClassName classname of the search implementation */ public void setSearchClassName (String searchClassName) { this.searchClassName = searchClassName; } /** * Method getSearchClassName * * @return classname of the search implementation */ public String getSearchClassName() { return searchClassName; } /** * Returns the namespace configuration. * * @return NamespaceConfig Namespace configuration */ public NamespaceConfig getConfig() { return config; } /** * Enumerate all scopes managed by this namespace. * * @return return an enumeration of all scopes */ public Enumeration enumerateScopes() { return stores.keys(); } /** * Transaction manager accessor. */ public TransactionManager getTransactionManager() { return transactionManager; } /** * Allows for overriding the default transaction manager used by this * namespace. * @param transactionManager the new transaction manager */ public void initTransactionManager(TransactionManager transactionManager) { if (this.transactionManager instanceof SlideTransactionManager) { this.transactionManager = transactionManager; } } /** * Return the current logger. */ public Logger getLogger() { if (logger != null) return logger; else return Domain.getLogger(); } /** * Set the logger used by this namespace. */ public void setLogger(Logger logger) { this.logger = logger; if (transactionManager instanceof SlideTransactionManager) { ((SlideTransactionManager) transactionManager).setLogger(logger); } } /** * Return the current application logger. */ public Logger getApplicationLogger() { if (applicationLogger != null) return applicationLogger; else if (logger != null) return logger; else return Domain.getLogger(); } /** * Set the logger used by this namespace. */ public void setApplicationLogger(Logger logger) { this.applicationLogger = logger; } // --------------------------------------------------------- Public Methods /** * Checks if all descendants of the given URI are stored in the same store. * * @param source * root URI of the tree to check * @return <code>true</code> if the whole tree is in a single store, * <code>false</code> otherwise */ public boolean isTreeInSingleStore(Uri source) { Store sourceStore = source.getStore(); String evilPrefix = source.toString(); for (Iterator it = stores.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Scope scope = (Scope) entry.getKey(); Store store = (Store) entry.getValue(); // there is a store that is not the one of the root, but still stores // part of our tree, which means the tree is not in a single store if (store != sourceStore && scope.toString().startsWith(evilPrefix)) { return false; } } return true; } /** * 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 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 * @exception ServiceRegistrationFailed * An error occured during instantiation of the service * @exception ServiceParameterErrorException * Incorrect service parameter * @exception ServiceParameterMissingException * Service parameter missing */ public void registerStore(String storeName, Class storeClass, Hashtable parameters, Scope scope, Hashtable childStores) throws ServiceRegistrationFailedException, ServiceParameterErrorException, ServiceParameterMissingException { if (!stores.containsKey(scope)) { try { Store store = (Store) storeClass.newInstance(); store.setName(storeName); store.setParameters(parameters); stores.put(scope, store); // assign NodeStore NodeStore nodeStore = (NodeStore) dereferenceStore (NODE_STORE, childStores); store.setNodeStore (nodeStore); // assign SecurityStore SecurityStore securityStore = (SecurityStore) dereferenceStore (SECURITY_STORE, childStores); store.setSecurityStore (securityStore); // assign LockStore LockStore lockStore = (LockStore) dereferenceStore (LOCK_STORE, childStores); store.setLockStore (lockStore); // assign RevisionDescriptorsStore RevisionDescriptorsStore revisionDescriptorsStore = (RevisionDescriptorsStore) dereferenceStore (REVISION_DESCRIPTORS_STORE, childStores); store.setRevisionDescriptorsStore (revisionDescriptorsStore); // assign RevisionDescriptorStore RevisionDescriptorStore revisionDescriptorStore = (RevisionDescriptorStore) dereferenceStore (REVISION_DESCRIPTOR_STORE, childStores); store.setRevisionDescriptorStore (revisionDescriptorStore); // assign ContentStore ContentStore contentStore = (ContentStore) dereferenceStore (CONTENT_STORE, childStores); store.setContentStore (contentStore); // assign PropertiesIndexStore IndexStore propertiesIndexer = (IndexStore) dereferenceStore (PROPERTIES_INDEX_STORE, childStores); // if not configured, take the default indexer if (propertiesIndexer == null) { propertiesIndexer = new DefaultIndexer (revisionDescriptorStore); childStores.put (PROPERTIES_INDEX_STORE, propertiesIndexer); } store.setPropertiesIndexer (propertiesIndexer); // assign ContentIndexStore IndexStore contentIndexer = (IndexStore) dereferenceStore (CONTENT_INDEX_STORE, childStores); // if not configured, take the default indexer if (contentIndexer == null) { contentIndexer = new DefaultIndexer (contentStore); childStores.put (CONTENT_INDEX_STORE, contentIndexer); } store.setContentIndexer (contentIndexer); // assign SequenceStore SequenceStore sequenceStore = (SequenceStore) dereferenceStore (SEQUENCE_STORE, childStores); store.setSequenceStore(sequenceStore); // assign MacroStore MacroStore macroStore = (MacroStore) dereferenceStore (MACRO_STORE, childStores); store.setMacroStore(macroStore); // set the scope in the father and child stores store.setScope(scope); // call the create_store_listener notifyStoreCreated( this.name, scope.toString(), storeName ); } catch(InstantiationException e) { throw new ServiceRegistrationFailedException (storeClass); } catch(IllegalAccessException e) { throw new ServiceRegistrationFailedException (storeClass); } catch(NullPointerException e) { throw new ServiceRegistrationFailedException (storeClass); } catch(ClassCastException e) { // TEMP getLogger().log(e,LOG_CHANNEL, Logger.ERROR); // --TEMP throw new ServiceRegistrationFailedException (storeClass); } } } Object dereferenceStore (String storeType, Hashtable childStores) { Object result; Object o = childStores.get(storeType); if (o instanceof String) { result = childStores.get(o); } else { result = o; } return result; } /** * At the end of the service registration, this service is called to * perform any required initialization task. * * @exception ServicesInitializationFailedException One or more * exception occured while initializing services */ public void initializeServices() throws ServicesInitializationFailedException { // We create the nested exception which will hold all thrown exception // during the initialization process. ServicesInitializationFailedException nestedException = new ServicesInitializationFailedException(); // Initializing DesciptorsStores Enumeration serviceList = stores.elements(); while (serviceList.hasMoreElements()) { Service service = (Service) serviceList.nextElement(); try { getLogger().log("Initializing Store " + service,LOG_CHANNEL,Logger.INFO); service.setNamespace(this); 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; } } /** * Reinitialize namespace. */ public void clearNamespace() { stores.clear(); } /** * Connects a data source on demand. * * @param service Service on which a connection attempt will be made * @param token the credentials token containing e.g. the credential * @exception ServiceConnectionFailedException Error connecting service * @exception ServiceAccessException Unspecified low level service * access exception */ public void connectService(Service service, CredentialsToken token) throws ServiceConnectionFailedException, ServiceAccessException { // Try to connect ... boolean newConnection = service.connectIfNeeded(token); // If successfull (ie, no exception was thrown), we add it to the list // of the connected components. if (newConnection) { connectedServices.addElement(service); } } /** * Disconnects all services. * * @exception ServicesShutDownFailedException Error disconnecting one or * more services */ public void disconnectServices() throws ServicesShutDownFailedException { // We create the nested exception which will hold all thrown exception // during shut down of services. ServicesShutDownFailedException nestedException = new ServicesShutDownFailedException(); for (int i=0; i<connectedServices.size(); i++) { try { Service service = (Service) connectedServices.elementAt(i); if (service.isConnected()) { getLogger().log("Shutting down service " + service,LOG_CHANNEL,Logger.INFO); service.disconnect(); } } catch (ServiceDisconnectionFailedException e) { nestedException.addException(e); } catch (ServiceAccessException e) { nestedException.addException(e); } } connectedServices.removeAllElements(); // If the nested exception is not empty, we throw it. if (!nestedException.isEmpty()) { throw nestedException; } } /** * Remove a Store from the registry. * * @param scope Scope to disconnect * @exception ServiceDisconnctionFailedException Error disconnecting * DescriptorsStore * @exception ServiceAccessException Unspecified error during * service access */ public void unregisterStore(Scope scope) throws ServiceDisconnectionFailedException, ServiceAccessException { if (stores.containsKey(scope)) { Store store = (Store) stores.get(scope); if (store.isConnected()) { store.disconnect(); connectedServices.removeElement(store); } stores.remove(scope); store = null; } } /** * Get the Data Source associated with the given scope, if any. * In contrary to the retrieveStore method, this methos does not * perform a connection. * * @param scope Scope to match */ public Store getStore(Scope scope) { Store store = null; if (stores.containsKey(scope)) { store = (Store) stores.get(scope); } return store; } /** * Get the Data Source associated with the given scope, if any and * connect to the store. * * @param scope Scope to match * @param token the Credeantials token containing e.g. the credential * @exception ServiceConnectionFailedException Connection to Store failed * @exception ServiceAccessException Unspecified service access exception */ public Store retrieveStore(Scope scope, CredentialsToken token) throws ServiceConnectionFailedException, ServiceAccessException { Store store = getStore(scope); if (store != null) { connectService(store, token); } return store; } /** * Builds a new uri object to access this namespace. This call will * return a Uri which doesn't have its token field set. The store should * accept such Uri as valid, and bypass any check that is made based on the * state. * * @param uri Requested Uri * @return Uri * @deprecated use signature with SlideToken instead */ public Uri getUri(String uri) { return getUri(null, uri); } /** * Builds a new uri object to access this namespace. * * @param token SlideToken * @param uri Requested Uri * @return Uri */ public Uri getUri(SlideToken token, String uri) { return getUri(token, uri, token==null ?false :token.isForceStoreEnlistment()); } /** * Builds a new uri object to access this namespace. * * @param token SlideToken * @param uri Requested Uri * @param forcedEnlistment may differ from the value set in token * @return Uri */ public Uri getUri(SlideToken token, String uri, boolean forcedEnlistment) { Uri result = new Uri(token, this, uri); // if a different forceEnlistment value want to be used // wrap the used token to reflect the different value if (token != null && token.isForceStoreEnlistment() != forcedEnlistment) { SlideToken wToken = new SlideTokenWrapper(token); wToken.setForceStoreEnlistment(forcedEnlistment); result.setToken(wToken); } return result; } /** * Get content interceptors associated with this namespace. */ public ContentInterceptor[] getContentInterceptors() { return config.getContentInterceptors(); } // -------------------------------------------------------- Package Methods /** * Parses the contents of the specified definition object, and uses that * info to initialize the namespace. * * @param definition Definiton of the scopes and stores of * the namespace * @exception SlideException Something went wrong during registry or * services initialization * @exception ConfigurationException Error parsing configuration file */ void loadDefinition(Configuration definition) throws SlideException, ConfigurationException { getLogger().log("Loading namespace definition",LOG_CHANNEL,Logger.INFO); // Loading stores 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); } Enumeration scopeDefinitions = definition.getConfigurations("scope"); while (scopeDefinitions.hasMoreElements()) { loadScopeDefinition ((Configuration) scopeDefinitions.nextElement(), storesClass, storesParameters, childStores); } // Initialize all loaded services. initializeServices(); } /** * Parses the contents of the specified reader, and uses that info to * initialize the specified Slide namespace. * * @param namespaceBaseDataDefinition Namespace base data * @exception SlideException Something went wrong during registry or * services initialization */ void loadBaseData(Configuration namespaceBaseDataDefinition) throws SlideException, ConfigurationException { getLogger().log("Loading namespace " + getName() + " base data",LOG_CHANNEL,Logger.INFO); // Load Namespace Base Data try { // start transaction for temp object creation getTransactionManager().begin(); SlideToken slideToken = new SlideTokenImpl(new CredentialsToken("")); slideToken.setForceStoreEnlistment(true); // First, we create the root node Uri rootUri = getUri(slideToken, "/"); SubjectNode rootNode = new SubjectNode("/"); try { rootUri.getStore().createObject(rootUri, rootNode); } catch (ObjectAlreadyExistsException e) { // if it is already there, that's fine with us } getLogger().log("Init namespace " + getName() + " configuration",LOG_CHANNEL,Logger.INFO); // Create the dummy configuration config.initializeAsDummyConfig(this); // Create the Access token NamespaceAccessToken token = new NamespaceAccessTokenImpl(this); getLogger().log("Import data into namespace " + getName(),LOG_CHANNEL,Logger.INFO); token.importData(slideToken, namespaceBaseDataDefinition); getLogger().log("Finish init namespace " + getName() + " configuration",LOG_CHANNEL,Logger.INFO); // And remove the all permission from the root node rootNode = (SubjectNode)rootUri.getStore().retrieveObject(rootUri); rootUri.getStore().storeObject(rootUri, rootNode); // end transaction for temp object removal getTransactionManager().commit(); } catch (SlideException e) { // If that occurs, then most likely the base config was // already done before getLogger().log("Namespace base configuration might have been already done before",LOG_CHANNEL,Logger.WARNING); getLogger().log(e,LOG_CHANNEL,Logger.WARNING); try { if (getTransactionManager().getStatus()==Status.STATUS_ACTIVE) getTransactionManager().rollback(); } catch (SystemException ex) { getLogger().log("Could not rollback namespace base configuration: " + ex.toString(),LOG_CHANNEL,Logger.WARNING); } } catch (Exception e) { getLogger().log("Unable to read Namespace base configuration file : ",LOG_CHANNEL,Logger.ERROR); getLogger().log(e,LOG_CHANNEL, Logger.ERROR); // Unable to load the base configuration XML file. // Log the event, and hope it was already done before. try { if (getTransactionManager().getStatus()==Status.STATUS_ACTIVE) getTransactionManager().rollback(); } catch (SystemException ex) { getLogger().log("Could not rollback namespace base configuration after load error: " + ex.toString(),LOG_CHANNEL,Logger.WARNING); } } } /** * Parses the contents of the specified reader, and uses that info to * initialize the specified Slide namespace. * * @param namespaceConfigurationDefinition The configuration to load. * @exception SlideException Something went wrong during registry or * services initialization */ void loadConfiguration(Configuration namespaceConfigurationDefinition) throws SlideException { getLogger().log("Loading namespace " + getName() + " configuration",LOG_CHANNEL,Logger.INFO); // Load Namespace Config config = new NamespaceConfig(); config.initializeNamespaceConfig(this, namespaceConfigurationDefinition); } /** * Parses the contents of the specified reader, and uses that info to * initialize the specified Slide namespace. * * @param namespaceConfigurationDefinition Namespace configuration * @exception SlideException Something went wrong during registry or * services initialization */ void loadParameters(Configuration namespaceConfigurationDefinition) throws SlideException { getLogger().log("Loading namespace " + getName() + " parameters",LOG_CHANNEL,Logger.INFO); // Load Namespace Config config = new NamespaceConfig(); config.initializeNamespaceParameters(this, namespaceConfigurationDefinition); } void loadExtractors(Configuration namespaceExtractorsDefinition) throws SlideException { getLogger().log("Loading namespace " + getName() + " extractors",LOG_CHANNEL,Logger.INFO); Enumeration extractorConfigs = namespaceExtractorsDefinition.getConfigurations("extractor"); while (extractorConfigs.hasMoreElements()) { Configuration extractorConfig = (Configuration) extractorConfigs.nextElement(); String classname = extractorConfig.getAttribute("classname"); String uri = extractorConfig.getAttribute("uri", null); String contentType = extractorConfig.getAttribute("content-type", null); String namespace = getName(); try { Class extractorClass = Class.forName(classname); Extractor extractor = null; Constructor extractorConstructor = extractorClass.getConstructor(new Class[] { String.class, String.class, String.class } ); extractor = (Extractor)extractorConstructor.newInstance(new String[] { uri, contentType, namespace }); if ( extractor instanceof Configurable ) { ((Configurable)extractor).configure(extractorConfig.getConfiguration("configuration")); } ExtractorManager.getInstance().addExtractor(extractor); } catch (ClassCastException e) { throw new ConfigurationException("Extractor '"+classname+"' is not of type Extractor", namespaceExtractorsDefinition); } catch (ConfigurationException e) { throw e; } catch (Exception e) { throw new ConfigurationException("Extractor '"+classname+"' could not be loaded", namespaceExtractorsDefinition); } } } // -------------------------------------------------------- Private Methods /** * Parse the store definition. * * @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 loadStoreDefinition (Configuration storeDefinition, Hashtable storesClass, Hashtable storesParameters, Hashtable childStores) throws ConfigurationException, SlideException { String storeName = storeDefinition.getAttribute("name"); String storeClassname = defaultStoreClassname; try { storeClassname = storeDefinition.getAttribute("classname"); } catch (ConfigurationException e) { } Enumeration storeParametersDefinitions = storeDefinition.getConfigurations("parameter"); // Load descriptors store class Class storeClass = null; try { storeClass = Class.forName(storeClassname); } catch (Exception e) { getLogger().log(e,LOG_CHANNEL, Logger.ERROR); throw new SlideException(e.getMessage()); } storesClass.put(storeName, storeClass); // Load descriptor store parameters Hashtable storeParameters = new Hashtable(); while (storeParametersDefinitions.hasMoreElements()) { Configuration parameterDefinition = (Configuration) storeParametersDefinitions.nextElement(); String parameterName = parameterDefinition.getAttribute("name"); String parameterValue = parameterDefinition.getValue(); storeParameters.put(parameterName, parameterValue); } storesParameters.put(storeName, storeParameters); // Now reading the "child" stores Hashtable currentStoreChildStores = new Hashtable(); // Loading node store (if any) getChildStore (storeDefinition, NODE_STORE, currentStoreChildStores, storeParameters); // Loading security store (if any) getChildStore (storeDefinition, SECURITY_STORE, currentStoreChildStores, storeParameters); // Loading lock store (if any) getChildStore (storeDefinition, LOCK_STORE, currentStoreChildStores, storeParameters); // Loading revision descriptors store (if any) getChildStore (storeDefinition, REVISION_DESCRIPTORS_STORE, currentStoreChildStores, storeParameters); // Loading revision descriptor store (if any) getChildStore (storeDefinition, REVISION_DESCRIPTOR_STORE, currentStoreChildStores, storeParameters); // Loading content store (if any) getChildStore (storeDefinition, CONTENT_STORE, currentStoreChildStores, storeParameters); // Loading descriptorindexstore store (if any) getChildStore (storeDefinition, PROPERTIES_INDEX_STORE, currentStoreChildStores, storeParameters); // Loading contentindexstore store (if any) getChildStore (storeDefinition, CONTENT_INDEX_STORE, currentStoreChildStores, storeParameters); // load default indexer, if no indexer defined // Loading sequence store (if any) getChildStore (storeDefinition, SEQUENCE_STORE, currentStoreChildStores, storeParameters); // Loading macro store (if any) getChildStore (storeDefinition, MACRO_STORE, currentStoreChildStores, storeParameters); childStores.put(storeName, currentStoreChildStores); } private void getChildStore(Configuration storeDefinition, String key, Hashtable currentStoreChildStores, Hashtable storeParameters) throws SlideException { Configuration localStoreDefinition; try { localStoreDefinition = storeDefinition.getConfiguration(key); } catch (ConfigurationException e) { return; // silently ignore as this only indicates there is no such store defined } try { try { Configuration referenceDefinition = localStoreDefinition.getConfiguration(REFERENCE); currentStoreChildStores.put (key, referenceDefinition.getAttribute("store")); getLogger().log(key + " references " + referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO); } catch (ConfigurationException ex) { getLogger().log(key + ": " + localStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO); Service store = loadChildStore(localStoreDefinition, storeParameters); if (store != null) { currentStoreChildStores.put(key, store); } } } catch (ConfigurationException e) { getLogger().log("Exception while loading "+key+"!", e, LOG_CHANNEL, Logger.WARNING); } } /** * Load a child descriptors store. * * @param childStoreDefinition XML definition of the child store * @param fatherParameters XML parameters defined for the father * @return Service Instance of the child store * @exception ConfigurationException Error parsing configuration file * @exception SlideException Error loading the specified class */ private Service loadChildStore(Configuration childStoreDefinition, Hashtable fatherParameters) throws ConfigurationException, SlideException { // Load classname String childStoreClassname = childStoreDefinition.getAttribute("classname"); // Load descriptors store class Service childStore = null; try { Class childStoreClass = Class.forName(childStoreClassname); childStore = (Service) childStoreClass.newInstance(); } catch (Exception e) { getLogger().log(e,LOG_CHANNEL, Logger.ERROR); return null; } // Retrieve parent parameters Hashtable childStoreParameters = new Hashtable(); Enumeration fatherParametersKeys = fatherParameters.keys(); while (fatherParametersKeys.hasMoreElements()) { Object key = fatherParametersKeys.nextElement(); Object value = fatherParameters.get(key); childStoreParameters.put(key, value); } // Load parameters Enumeration childStoreParametersDefinitions = childStoreDefinition.getConfigurations("parameter"); while (childStoreParametersDefinitions.hasMoreElements()) { Configuration parameterDefinition = (Configuration) childStoreParametersDefinitions.nextElement(); String parameterName = parameterDefinition.getAttribute("name"); String parameterValue = parameterDefinition.getValue(); childStoreParameters.put(parameterName, parameterValue); } childStore.setParameters(childStoreParameters); // load configurations if any and the store supports them if (childStore instanceof Configurable) { Configurable configurable = (Configurable)childStore; Enumeration childStoreConfigurations = childStoreDefinition.getConfigurations("configuration"); while(childStoreConfigurations.hasMoreElements()) { configurable.configure( (Configuration)childStoreConfigurations.nextElement()); } } return childStore; } /** * Parse the content store definition. * * @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 * @exception ServiceParameterErrorException Service parameter error * @exception ServiceParameterMissingException Service parameter missing * @exception ServiceRegistrationFailedException Error registering service */ private void loadScopeDefinition(Configuration scopeDefinition, Hashtable storesClass, Hashtable storesParameters, Hashtable childStores) throws ConfigurationException, UnknownServiceDeclarationException, ServiceParameterErrorException, ServiceParameterMissingException, ServiceRegistrationFailedException { String match = scopeDefinition.getAttribute("match"); // First, we get the correct class and parameters from the Hashtables. String storeName = scopeDefinition.getAttribute("store"); if (storeName != null) { if ((!storesClass.containsKey(storeName)) || (!storesParameters.containsKey(storeName))) { throw new UnknownServiceDeclarationException(storeName); } registerStore(storeName, (Class) storesClass.get(storeName), (Hashtable) storesParameters.get(storeName), new Scope(match), (Hashtable) childStores.get(storeName)); getLogger().log("Registering Store " + storeName + " (" + storesClass.get(storeName) + ") with parameters " + storesParameters.get(storeName) + " on scope " + match,LOG_CHANNEL,Logger.INFO); } } /** * */ private void notifyStoreCreated( String namespaceName, String scope, String storeName ) { if( createStoreListenerClass != null ) { try { Method nsc = createStoreListenerClass.getMethod( "notifyStoreCreated", new Class[]{String.class, String.class, String.class} ); nsc.invoke( null, new Object[]{namespaceName, scope, storeName} ); // obj=null since method is static } catch( Exception x ) { Domain.warn( "Notification of store creation "+ "(namespace="+namespaceName+", scope="+scope+", store="+storeName+") failed: "+x.getMessage() ); } } } // --------------------------------------------------------- Object Methods /** * Get a String representation of this namespace. */ public String toString() { return getName(); } }

The table below shows all metrics for Namespace.java.

MetricValueDescription
BLOCKS111.00Number of blocks
BLOCK_COMMENT22.00Number of block comment lines
COMMENTS397.00Comment lines
COMMENT_DENSITY 0.81Comment density
COMPARISONS51.00Number of comparison operators
CYCLOMATIC102.00Cyclomatic complexity
DECL_COMMENTS55.00Comments in declarations
DOC_COMMENT298.00Number of javadoc comment lines
ELOC489.00Effective lines of code
EXEC_COMMENTS61.00Comments in executable code
EXITS97.00Procedure exits
FUNCTIONS38.00Number of function declarations
HALSTEAD_DIFFICULTY77.86Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY142.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 1.00JAVA0008 Empty catch block
JAVA0009 3.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 7.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 1.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 7.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 7.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 2.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 3.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA011611.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 0.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 5.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 2.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 5.00JAVA0144 Line exceeds maximum M characters
JAVA0145 1.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 2.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 6.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 1.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 2.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 2.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 1.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 1.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1201.00Number of lines in the source file
LINE_COMMENT77.00Number of line comments
LOC582.00Lines of code
LOGICAL_LINES290.00Number of statements
LOOPS10.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS1471.00Number of operands
OPERATORS2435.00Number of operators
PARAMS47.00Number of formal parameter declarations
PROGRAM_LENGTH3906.00Halstead program length
PROGRAM_VOCAB491.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS95.00Number of return points from functions
SIZE44440.00Size of the file in bytes
UNIQUE_OPERANDS444.00Number of unique operands
UNIQUE_OPERATORS47.00Number of unique operators
WHITESPACE222.00Number of whitespace lines