ws-wsrf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r326642 - in /webservices/wsrf/trunk/src/java/org/apache/ws: resource/metadataexchange/v2004_09/porttype/impl/MetadataExchangePortTypeImpl.java util/jndi/tools/MetadataConfigImpl.java
Date Wed, 19 Oct 2005 18:40:49 GMT
Author: scamp
Date: Wed Oct 19 11:40:46 2005
New Revision: 326642

URL: http://svn.apache.org/viewcvs?rev=326642&view=rev
Log: (empty)

Modified:
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/metadataexchange/v2004_09/porttype/impl/MetadataExchangePortTypeImpl.java
    webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/tools/MetadataConfigImpl.java

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/metadataexchange/v2004_09/porttype/impl/MetadataExchangePortTypeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/metadataexchange/v2004_09/porttype/impl/MetadataExchangePortTypeImpl.java?rev=326642&r1=326641&r2=326642&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/metadataexchange/v2004_09/porttype/impl/MetadataExchangePortTypeImpl.java
(original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/metadataexchange/v2004_09/porttype/impl/MetadataExchangePortTypeImpl.java
Wed Oct 19 11:40:46 2005
@@ -26,6 +26,7 @@
 import org.apache.ws.resource.AbstractPortType;
 import org.apache.ws.resource.NamespaceVersionHolder;
 import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.faults.FaultException;
 import org.apache.ws.resource.metadataexchange.v2004_09.MetadataExchangeConstants;
 import org.apache.ws.resource.metadataexchange.v2004_09.porttype.MetadataExchangePortType;
 import org.apache.ws.resource.properties.v2004_11.impl.NamespaceVersionHolderImpl;
@@ -73,12 +74,14 @@
 	 */
 	public MetadataDocument getMetadata(GetMetadataDocument request) {
 		MetadataConfigImpl metadataConfig = getResourceContext().getResourceHome().getMetadataConfig();
-
+		
 		// prep the response
 		MetadataDocument responseDoc = createMetadataResponseDoc();
 		MetadataDocument.Metadata responseMetadata = responseDoc
 				.addNewMetadata();
 
+		if(metadataConfig != null)
+		{
 		// get the values from the request
 		GetMetadataDocument.GetMetadata requestMetadata = request
 				.getGetMetadata();
@@ -125,7 +128,7 @@
 				}
 			}
 		}
-
+		}
 		getResourceContext().setResponseAction(
 						URI.create(MetadataExchangeConstants.ACTION_GETMETADATA_RESPONSE));
 		return responseDoc;
@@ -140,6 +143,8 @@
 		AnyXmlType anyXmlType = AnyXmlType.Factory.newInstance();
 		MetadataConfigImpl metadataConfig = getResourceContext().getResourceHome().getMetadataConfig();
 
+		if(metadataConfig != null)
+		{
 		// get all the registered metadata
 		List allMetadata = metadataConfig.getAllMetadata();
 		Iterator iterator = allMetadata.iterator();
@@ -175,7 +180,7 @@
 
 			XmlBeanUtils.addChildElement(anyXmlType, (XmlObject) metadata);
 		}
-
+		}
 		getResourceContext().setResponseAction(
 				URI.create(MetadataExchangeConstants.ACTION_GET_RESPONSE));
 		return anyXmlType;
@@ -190,16 +195,6 @@
 		return NAMESPACE_SET;
 	}
 
-	/**
-	 * Returns the JNDI Contrext name for looking up the metadata
-	 * 
-	 * @return
-	 */
-	private String getMetadataJndiContextName() {
-		return org.apache.ws.resource.JndiConstants.CONTEXT_NAME_SERVICES + "/"
-				+ getResourceContext().getServiceName() + "/"
-				+ org.apache.ws.resource.JndiConstants.ATOMIC_METADATA_CONTEXT;
-	}
 
 	/**
 	 * Builds a SOAP Envelope based on the EPR and makes a request to retrieve

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/tools/MetadataConfigImpl.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/tools/MetadataConfigImpl.java?rev=326642&r1=326641&r2=326642&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/tools/MetadataConfigImpl.java
(original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/tools/MetadataConfigImpl.java
Wed Oct 19 11:40:46 2005
@@ -17,6 +17,7 @@
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -25,157 +26,159 @@
 
 /**
  * A config object to represent the MetadataExchange information from the
- * jndi-config.xml config file.
- * <p/>
- * This class will store any "loadable" metadata documents, this will avoid
- * unnecessary loading of files.
- *
+ * jndi-config.xml config file. <p/> This class will store any "loadable"
+ * metadata documents, this will avoid unnecessary loading of files.
+ * 
  * @author Sal Campana
  */
-public class MetadataConfigImpl
-{
-   private static final Log LOG = LogFactory.getLog( MetadataConfigImpl.class );
-
-   /**
-    * Internal Map for storing metatdata.
-    *
-    * The map will have the structure of:
-    *
-    * key=dialect
-    * value=Map (dialect-specific Map)
-    *
-    * The dialect-specific Map will have the structure:
-    *
-    * Two Entries:
-    * key= IDENTIFIER_MAP
-    * value= A Map keyed on Identifier keyed-to the metatdata
-    *
-    * key= COMPLETE_METADATA_LIST
-    * value= A List containing ALL metadata given this dialect (this includes all entries
from IDENTIFIER_MAP)
-    *
-    **/
-   private Map m_dialectToMetadataListMap = new HashMap(  );
-
-   private List m_metadataList = new ArrayList(  );
-   
-   /**
-    * Creates a new {@link MetadataConfigImpl} object.
-    *
-    * @param metadata DOCUMENT_ME
-    */
-   public MetadataConfigImpl( List metadataEntryList )
-   {
-      m_metadataList = metadataEntryList;
-      loadMetadata(  );      
-   }
-
-    public void addMetadataEntry( MetadataEntry metadataEntry )
-    {
-        m_metadataList.add( metadataEntry );
-        addToMetadataMap( metadataEntry );        
-    }
-
-    /**
-     * Returns all known metadata for all dialects.
-     *
-     * @return A list of all metadata
-     */
-    public List getAllMetadata(  )
-    {
-       return m_metadataList;
-    }
-
-   /**
-    * Returns the metadata given a dialect and an identifier.
-    *
-    * @param dialect
-    * @param identifierUri
-    * @return  A Map keyed on dialect keyed-to a List of metadata
-    */
-   public Map getMetadata( String dialect,
-                           String identifierUri )
-   {
-      Map results = new HashMap(  );
-      if ( ( dialect != null ) && !"".equals( dialect ) ) //only get metatdata for
specific dialect
-      {
-         Map dialectMap = (Map) m_dialectToMetadataListMap.get( dialect );
-         if ( dialectMap != null )
-         {
-            if ( identifierUri != null )
-            {                              
-               Object metatdata = dialectMap.get(identifierUri);
-               if ( metatdata != null )
-               {
-                  List list = new ArrayList(  );
-                  list.add( metatdata );
-                  results.put( dialect, list );
-               }
-            }
-            else
-            { 
-               //based on dialect get all entries                              
-               results.put( dialect, new ArrayList(dialectMap.values()) );
-            }
-         }
-      }
-  
-      return results;
-   }
-
-   /**
-    * Returns metadata based on dialect
-    *
-    * @param dialect
-    * @return A Map keyed on dialect keyed-to a List of metadata
-    */
-   public Map getMetadata( String dialect )
-   {
-      return getMetadata( dialect, null );
-   }
-
-   /**
-    * Adds the parsed-in metadata to the undelying lookup structures.
-    *
-    * precondition: The structures have already been setup for the metadata
-    *
-    * @param dialect
-    * @param identifier
-    * @param metadata   The "parsed" metadata (could be XmlObject, MetadataReference or Location
)
-    */
-   protected void addToMetadataMap( MetadataEntry metadataEntry )
-   {
-	  String dialect = metadataEntry.getDialect();
-	  String identifier = metadataEntry.getIdentifier();
-      Map dialectMap = (Map) m_dialectToMetadataListMap.get( dialect );
-      if ( dialectMap == null )
-      {
-    	 //build the entries for the maps
-         dialectMap = new HashMap(  );
-         m_dialectToMetadataListMap.put( dialect, dialectMap ); //add to metadatamap
-
-      }
-      //if there is an identifier then the metadata is registered with it
-      //else it only lives in the list of all metadata
-      if ( ( identifier != null ) && !"".equals( identifier ) )
-      {         
-         dialectMap.put( identifier, metadataEntry );
-      }
-   }
-
-   /**
-    * Loads up lookup structures with the metadata.
-    *
-    * This method initializes a Map for a given dialect if it doesn't already exist.  The
Map is keyed using
-    * 2 constants for pulling a map of identifiers->metatada AND a List of all metatdata.
-    */
-   private synchronized void loadMetadata(  )
-   {
-       for ( int i = 0; i < m_metadataList.size(); i++ )
-       {
-           MetadataEntry metadataEntry = (MetadataEntry) m_metadataList.get( i );
-           addToMetadataMap( metadataEntry );
-       }
-   }
+public class MetadataConfigImpl {
+	private static final Log LOG = LogFactory.getLog(MetadataConfigImpl.class);
 
-}
+	/**
+	 * Internal Map for storing metatdata.
+	 * 
+	 * The map will have the structure of:
+	 * 
+	 * key=dialect value=Map (dialect-specific Map)
+	 * 
+	 * The dialect-specific Map will have the structure:
+	 * 
+	 * Two Entries: key= IDENTIFIER_MAP value= A Map keyed on Identifier
+	 * keyed-to the metatdata
+	 * 
+	 * key= COMPLETE_METADATA_LIST value= A List containing ALL metadata given
+	 * this dialect (this includes all entries from IDENTIFIER_MAP)
+	 * 
+	 */
+	private Map m_dialectToMetadataListMap = new HashMap();
+
+	private List m_metadataList = new ArrayList();
+
+	/**
+	 * Creates a new {@link MetadataConfigImpl} object.
+	 * 
+	 * @param metadata
+	 *            DOCUMENT_ME
+	 */
+	public MetadataConfigImpl(List metadataEntryList) {
+		m_metadataList = metadataEntryList;
+		loadMetadata();
+	}
+
+	public void addMetadataEntry(MetadataEntry metadataEntry) {
+		m_metadataList.add(metadataEntry);
+		addToMetadataMap(metadataEntry);
+	}
+
+	/**
+	 * Returns all known metadata for all dialects.
+	 * 
+	 * @return A list of all metadata
+	 */
+	public List getAllMetadata() {
+		return m_metadataList;
+	}
+
+	/**
+	 * Returns the metadata given a dialect and an identifier.
+	 * 
+	 * @param dialect
+	 * @param identifierUri
+	 * @return A Map keyed on dialect keyed-to a List of metadata
+	 */
+	public Map getMetadata(String dialect, String identifierUri) {
+		Map results = new HashMap();
+		if ((dialect != null) && !"".equals(dialect)) // only get metatdata
+														// for specific dialect
+		{
+			Map dialectMap = (Map) m_dialectToMetadataListMap.get(dialect);
+			if (dialectMap != null) {
+				if (identifierUri != null) {
+					Object metatdata = dialectMap.get(identifierUri);
+					if (metatdata != null) {
+						List list = new ArrayList();
+						list.add(metatdata);
+						results.put(dialect, list);
+					}
+				} else {
+					// based on dialect get all entries
+					results.put(dialect, new ArrayList(dialectMap.values()));
+				}
+			}
+		}
+		// if dialect was not defined then they are saying "send all!"
+		else {
+			return buildDialectToListMap();
+		}
+		return results;
+	}
+
+	private Map buildDialectToListMap() {
+		Map dialectToMetadataList = new HashMap();
+
+		Iterator iter = m_dialectToMetadataListMap.keySet().iterator();
+		while (iter.hasNext()) {
+			String dialect = (String) iter.next();
+			Map identifierMap = (Map) m_dialectToMetadataListMap.get(dialect);
+			dialectToMetadataList.put(dialect, new ArrayList(identifierMap
+					.values()));
+		}
+		return dialectToMetadataList;
+	}
+
+	/**
+	 * Returns metadata based on dialect
+	 * 
+	 * @param dialect
+	 * @return A Map keyed on dialect keyed-to a List of metadata
+	 */
+	public Map getMetadata(String dialect) {
+		return getMetadata(dialect, null);
+	}
+
+	/**
+	 * Adds the parsed-in metadata to the undelying lookup structures.
+	 * 
+	 * precondition: The structures have already been setup for the metadata
+	 * 
+	 * @param dialect
+	 * @param identifier
+	 * @param metadata
+	 *            The "parsed" metadata (could be XmlObject, MetadataReference
+	 *            or Location )
+	 */
+	protected void addToMetadataMap(MetadataEntry metadataEntry) {
+		String dialect = metadataEntry.getDialect();
+		String identifier = metadataEntry.getIdentifier();
+		Map dialectIdentifierMap = (Map) m_dialectToMetadataListMap
+				.get(dialect);
+		if (dialectIdentifierMap == null) {
+			// build the entries for the maps
+			dialectIdentifierMap = new HashMap();
+			m_dialectToMetadataListMap.put(dialect, dialectIdentifierMap); // add
+																			// to
+																			// metadatamap
+
+		}
+		// if there is an identifier then the metadata is registered with it
+		// else it only lives in the list of all metadata
+		if ((identifier != null) && !"".equals(identifier)) {
+			dialectIdentifierMap.put(identifier, metadataEntry);
+		}
+	}
+
+	/**
+	 * Loads up lookup structures with the metadata.
+	 * 
+	 * This method initializes a Map for a given dialect if it doesn't already
+	 * exist. The Map is keyed using 2 constants for pulling a map of
+	 * identifiers->metatada AND a List of all metatdata.
+	 */
+	private synchronized void loadMetadata() {
+		for (int i = 0; i < m_metadataList.size(); i++) {
+			MetadataEntry metadataEntry = (MetadataEntry) m_metadataList.get(i);
+			addToMetadataMap(metadataEntry);
+		}
+	}
 
+}



Mime
View raw message