Index: metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrIndex.java
===================================================================
--- metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrIndex.java	(revision 7545)
+++ metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrIndex.java	(revision 7546)
@@ -26,16 +26,38 @@
  */
 package edu.ucsb.nceas.metacat.index;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
+import org.apache.commons.codec.EncoderException;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.common.SolrInputDocument;
 import org.dataone.cn.indexer.XMLNamespaceConfig;
+import org.dataone.cn.indexer.XPathDocumentParser;
 import org.dataone.cn.indexer.parser.IDocumentSubprocessor;
+import org.dataone.cn.indexer.parser.SolrField;
+import org.dataone.cn.indexer.solrhttp.SolrDoc;
+import org.dataone.cn.indexer.solrhttp.SolrElementAdd;
+import org.dataone.cn.indexer.solrhttp.SolrElementField;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 
 /**
  * A class does insert, update and remove indexes to a SOLR server
@@ -43,9 +65,13 @@
  *
  */
 public class SolrIndex {
+    
+    //private static final String INPUT_ENCODING = "UTF-8";
+    
     private List<IDocumentSubprocessor> subprocessors = null;
     private SolrServer solrServer = null;
     private XMLNamespaceConfig xmlNamespaceConfig = null;
+    private List<SolrField> sysmetaSolrFields = null;
 
     private static DocumentBuilderFactory documentBuilderFactory = null;
     private static DocumentBuilder builder = null;
@@ -52,15 +78,43 @@
 
     private static XPathFactory xpathFactory = null;
     private static XPath xpath = null;
+    Log log = LogFactory.getLog(SolrIndex.class);
     
+    static {
+        documentBuilderFactory = DocumentBuilderFactory.newInstance();
+        documentBuilderFactory.setNamespaceAware(true);
+        try {
+            builder = documentBuilderFactory.newDocumentBuilder();
+        } catch (ParserConfigurationException e) {
+            e.printStackTrace();
+        }
+        xpathFactory = XPathFactory.newInstance();
+        xpath = xpathFactory.newXPath();
+    }
+    
     /**
      * Constructor
      */
-    public SolrIndex() {
-        
+    public SolrIndex(XMLNamespaceConfig xmlNamespaceConfig, List<SolrField> sysmetaSolrFields)
+                    throws XPathExpressionException, ParserConfigurationException {
+                this.xmlNamespaceConfig = xmlNamespaceConfig;
+                this.sysmetaSolrFields = sysmetaSolrFields;
+                init();
     }
     
+    private void init() throws ParserConfigurationException, XPathExpressionException {
+        xpath.setNamespaceContext(xmlNamespaceConfig);
+        initExpressions();
+    }
+
+    private void initExpressions() throws XPathExpressionException {
+        for (SolrField field : sysmetaSolrFields) {
+            field.initExpression(xpath);
+        }
+
+    }
     
+    
     /**
      * Get the list of the Subprocessors in this index.
      * @return the list of the Subprocessors.
@@ -74,9 +128,155 @@
      * @param subprocessorList  the list will be set.
      */
     public void setSubprocessors(List<IDocumentSubprocessor> subprocessorList) {
-        /*for (IDocumentSubprocessor subprocessor : subprocessorList) {
+        for (IDocumentSubprocessor subprocessor : subprocessorList) {
             subprocessor.initExpression(xpath);
-        }*/
+        }
         this.subprocessors = subprocessorList;
     }
+    
+    /**
+     * Generate the index for the given information
+     * @param id
+     * @param systemMetaDataStream
+     * @param dataStream
+     * @return
+     * @throws IOException
+     * @throws SAXException
+     * @throws ParserConfigurationException
+     * @throws XPathExpressionException
+     * @throws EncoderException
+     */
+    private Map<String, SolrDoc> process(String id, InputStream systemMetaDataStream, InputStream dataStream)
+                    throws IOException, SAXException, ParserConfigurationException,
+                    XPathExpressionException{
+
+        // Load the System Metadata document
+        Document sysMetaDoc = generateXmlDocument(systemMetaDataStream);
+        if (sysMetaDoc == null) {
+            log.error("Could not load System metadata for ID: " + id);
+            return null;
+        }
+
+        // Extract the field values from the System Metadata
+        List<SolrElementField> sysSolrFields = processSysmetaFields(sysMetaDoc, id);
+        SolrDoc indexDocument = new SolrDoc(sysSolrFields);
+        Map<String, SolrDoc> docs = new HashMap<String, SolrDoc>();
+        docs.put(id, indexDocument);
+
+        // Determine if subprocessors are available for this ID
+        if (subprocessors != null) {
+                    // for each subprocessor loaded from the spring config
+                    for (IDocumentSubprocessor subprocessor : subprocessors) {
+                        // Does this subprocessor apply?
+                        if (subprocessor.canProcess(sysMetaDoc)) {
+                            // if so, then extract the additional information from the
+                            // document.
+                            try {
+                                // docObject = the resource map document or science
+                                // metadata document.
+                                // note that resource map processing touches all objects
+                                // referenced by the resource map.
+                                Document docObject = generateXmlDocument(dataStream);
+                                if (docObject == null) {
+                                    log.error("Could not load OBJECT for ID " + id );
+                                } else {
+                                    docs = subprocessor.processDocument(id, docs, docObject);
+                                }
+                            } catch (Exception e) {
+                                log.error(e.getStackTrace().toString());
+                            }
+                        }
+                    }
+       }
+
+       // TODO: in the XPathDocumentParser class in d1_cn_index_process module,
+       // merge is only for resource map. We need more work here.
+       for (SolrDoc mergeDoc : docs.values()) {
+           if (!mergeDoc.isMerged()) {
+                 //mergeWithIndexedDocument(mergeDoc);
+           }
+       }
+
+       //SolrElementAdd addCommand = getAddCommand(new ArrayList<SolrDoc>(docs.values()));
+               
+       return docs;
+    }
+    
+    /*
+     * Generate a Document from the InputStream
+     */
+    private Document generateXmlDocument(InputStream smdStream) throws SAXException {
+        Document doc = null;
+
+        try {
+            doc = builder.parse(smdStream);
+        } catch (IOException e) {
+            log.error(e.getMessage(), e);
+        }
+
+        return doc;
+    }
+    
+    /*
+     * Index the fields of the system metadata
+     */
+    private List<SolrElementField> processSysmetaFields(Document doc, String identifier) {
+
+        List<SolrElementField> fieldList = new ArrayList<SolrElementField>();
+        // solrFields is the list of fields defined in the application context
+       
+        for (SolrField field : sysmetaSolrFields) {
+            try {
+                // the field.getFields method can return a single value or
+                // multiple values for multi-valued fields
+                // or can return multiple SOLR document fields.
+                fieldList.addAll(field.getFields(doc, identifier));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return fieldList;
+
+    }
+    
+    /**
+     * Generate indexes for a newly inserted document.
+     * @param pid  the id of this document
+     * @param systemMetadata  the system metadata associated with the data object
+     * @param data  the data object itself
+     * @throws SolrServerException 
+     */
+    public void insert(String pid, InputStream systemMetadata, InputStream data) 
+                    throws IOException, SAXException, ParserConfigurationException,
+                    XPathExpressionException, SolrServerException {
+        Map<String, SolrDoc> docs = process(pid, systemMetadata, data);
+        
+        //transform the Map to the SolrInputDocument which can be used by the solr server
+        if(docs != null) {
+            Set<String> ids = docs.keySet();
+            for(String id : ids) {
+                SolrInputDocument solrDoc = new SolrInputDocument();
+                if(id != null) {
+                    SolrDoc doc = docs.get(id);
+                    if(doc != null) {
+                        List<SolrElementField> list = doc.getFieldList();
+                        if(list != null) {
+                            Iterator<SolrElementField> iterator = list.iterator();
+                            while (iterator.hasNext()) {
+                                SolrElementField field = iterator.next();
+                                if(field != null) {
+                                    String value = field.getValue();
+                                    String name = field.getName();
+                                    solrDoc.addField(name, value);
+                                }
+                            }
+                        }
+                    }
+                }
+                if(!solrDoc.isEmpty()) {
+                    solrServer.add(solrDoc);
+                }
+            }
+        }
+    }
 }
Index: metacat-index/src/main/resources/index-processor-context.xml
===================================================================
--- metacat-index/src/main/resources/index-processor-context.xml	(revision 7545)
+++ metacat-index/src/main/resources/index-processor-context.xml	(revision 7546)
@@ -40,10 +40,10 @@
   <constructor-arg>
    <list>
     <bean class="edu.ucsb.nceas.metacat.index.SolrIndex">
-     <!--  <constructor-arg name="fields" ref="xpath_system_metadata_100">
+     <constructor-arg name="sysmetaSolrFields" ref="xpath_system_metadata_100">
      </constructor-arg>
      <constructor-arg name="xmlNamespaceConfig" ref="xmlNamespaceConfig" />
-     <property name="solrBaseUri" value="${solr.base.uri}" />
+     <!--<property name="solrBaseUri" value="${solr.base.uri}" />
      <property name="httpService" ref="httpService" /> -->
      <property name="subprocessors">
       <list>
