Index: src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/dataone/MNodeService.java	(revision 7647)
+++ src/edu/ucsb/nceas/metacat/dataone/MNodeService.java	(revision 7648)
@@ -1458,22 +1458,23 @@
 	public InputStream query(String engine, String query) throws InvalidToken,
 			ServiceFailure, NotAuthorized, InvalidRequest, NotImplemented,
 			NotFound {
+	    String user = Constants.SUBJECT_PUBLIC;
+        String[] groups= null;
+        if (session != null) {
+            user = session.getSubject().getValue();
+            Set<Subject> subjects = AuthUtils.authorizedClientSubjects(session);
+            if (subjects != null) {
+                List<String> groupList = new ArrayList<String>();
+                for (Subject subject: subjects) {
+                    groupList.add(subject.getValue());
+                }
+                groups = groupList.toArray(new String[0]);
+            }
+        }
 		if (engine != null && engine.equals(PATHQUERY)) {
 			try {
 				DBQuery queryobj = new DBQuery();
-				String user = Constants.SUBJECT_PUBLIC;
-				String[] groups= null;
-				if (session != null) {
-					user = session.getSubject().getValue();
-					Set<Subject> subjects = AuthUtils.authorizedClientSubjects(session);
-					if (subjects != null) {
-						List<String> groupList = new ArrayList<String>();
-						for (Subject subject: subjects) {
-							groupList.add(subject.getValue());
-						}
-						groups = groupList.toArray(new String[0]);
-					}
-				}
+				
 				String results = queryobj.performPathquery(query, user, groups);
 				return new ByteArrayInputStream(results.getBytes(MetaCatServlet.DEFAULT_ENCODING));
 
@@ -1485,7 +1486,7 @@
 		    logMetacat.info("The query is ==================================== \n"+query);
 		    try {
 		        
-                return MetacatSolrIndex.getInstance().query(query);
+                return MetacatSolrIndex.getInstance().query(query, user, groups);
             } catch (Exception e) {
                 // TODO Auto-generated catch block
                 throw new ServiceFailure("Solr server error", e.getMessage());
Index: src/edu/ucsb/nceas/metacat/index/MetacatSolrIndex.java
===================================================================
--- src/edu/ucsb/nceas/metacat/index/MetacatSolrIndex.java	(revision 7647)
+++ src/edu/ucsb/nceas/metacat/index/MetacatSolrIndex.java	(revision 7648)
@@ -47,8 +47,10 @@
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
 import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.params.AppendedSolrParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrCore;
@@ -61,6 +63,7 @@
 import org.apache.solr.response.QueryResponseWriter;
 import org.apache.solr.response.RubyResponseWriter;
 import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.response.VelocityResponseWriter;
 import org.apache.solr.response.XMLResponseWriter;
 import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
@@ -102,12 +105,18 @@
     private static final String VERSION = "3.4";
     private static final String SOLRCONFDIR = "/conf";
     private static final String SOLRSCHEMAFILEPATH = SOLRCONFDIR+"/schema.xml";
+    private static final String FILTERQUERY = "fq";
+    private static final String READPERMISSION = "readPermission";
+    private static final String OPENPARENTHESE = "(";
+    private static final String CLOSEPARENTHESE = ")";
+    private static final String COLON = ":";
+    private static final String OR = "OR";
     //private static final String SOLRCONFIGPATH = "/conf/solrconfig.xml";
     
     private static Log log = LogFactory.getLog(MetacatSolrIndex.class);
     private CoreContainer coreContainer = null;
     private SolrServer solrServer = null;
-    private String wt = null;//specify the return format.
+    //private String wt = null;//specify the return format.
     private String collectionName = null;
     private String solrHomeDir = null;
     private static MetacatSolrIndex  solrIndex = null;
@@ -165,16 +174,17 @@
      * @throws SQLException 
      * @throws PropertyNotFoundException 
      */
-    public InputStream query(String query) throws SolrServerException, IOException, PropertyNotFoundException, SQLException, ClassNotFoundException {
+    public InputStream query(String query, String user, String[] groups) throws SolrServerException, IOException, PropertyNotFoundException, SQLException, ClassNotFoundException {
         InputStream inputStream = null;
         SolrParams solrParams = SolrRequestParsers.parseQueryString(query);
-        wt = solrParams.get(WT);
+        solrParams = appendAccessFilterParams(solrParams, user, groups);
+        String wt = solrParams.get(WT);
         
         // handle normal and skin-based queries
-        if (supportedWriterTypes.contains(wt)) {
+        if (wt == null ||supportedWriterTypes.contains(wt)) {
         	// just handle as normal solr query
 	        QueryResponse response = solrServer.query(solrParams);
-	        inputStream = transformResults(solrParams, response);
+	        inputStream = transformResults(solrParams, response, wt);
         }
         else {
         	// assume it is a skin name
@@ -185,7 +195,7 @@
         	ModifiableSolrParams msp = new ModifiableSolrParams(solrParams);
         	msp.set(WT, wt);
         	QueryResponse response = solrServer.query(msp);
-	        inputStream = transformResults(msp, response);
+	        inputStream = transformResults(msp, response, wt);
         	
 	        // apply the stylesheet (XML->HTML)
 	        DBTransform transformer = new DBTransform();
@@ -214,13 +224,50 @@
         return inputStream;
     }
     
+    
+    /*
+     * Append the access filter query to the params
+     */
+    private SolrParams appendAccessFilterParams(SolrParams solrParams, String user, String[] groups) {
+        SolrParams append = null;
+        if(solrParams != null) {
+            StringBuffer query = new StringBuffer();
+            if (user != null && groups != null) {
+                query.append(OPENPARENTHESE+READPERMISSION+COLON+user+CLOSEPARENTHESE);
+                for(int i=0; i<groups.length; i++) {
+                    query.append(OR + OPENPARENTHESE+READPERMISSION+COLON+groups[i]+CLOSEPARENTHESE);
+                }
+            } else if (user != null && groups == null) {
+                query.append(OPENPARENTHESE+READPERMISSION+COLON+user+CLOSEPARENTHESE);
+            } else if ( user == null && groups != null) {
+                for (int i=0; i<groups.length; i++) {
+                    if(i==0) {
+                        query.append(OPENPARENTHESE+READPERMISSION+COLON+groups[i]+CLOSEPARENTHESE);
+                    } else {
+                        query.append(OR + OPENPARENTHESE+READPERMISSION+COLON+groups[i]+CLOSEPARENTHESE);
+                    }
+                }
+            }
+            if(query.length() != 0) {
+                //System.out.println("=================== fq query is "+query.toString());
+                NamedList fq = new NamedList();
+                fq.add(FILTERQUERY, query.toString());
+                SolrParams fqParam = SolrParams.toSolrParams(fq);
+                append = new AppendedSolrParams(solrParams, fqParam);
+            } else {
+                append = solrParams;
+            }
+        }
+        return append;
+    }
+    
    
     /*
      * Transform the Queryresponse to the InputStream
      */
-    private InputStream transformResults(SolrParams request, QueryResponse response) throws SolrServerException, IOException {
+    private InputStream transformResults(SolrParams request, QueryResponse response, String wt) throws SolrServerException, IOException {
         //InputStream stream = null;
-        QueryResponseWriter writer = generateResponseWriter();
+        QueryResponseWriter writer = generateResponseWriter(wt);
         Writer results = new StringWriter();
         SolrQueryResponse sResponse = new SolrQueryResponse();
         sResponse.setAllValues(response.getResponse());
@@ -240,7 +287,7 @@
      * <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter"/>
      * <queryResponseWriter name="csv" class="solr.CSVResponseWriter"/>
      */
-    private QueryResponseWriter generateResponseWriter() throws SolrServerException {
+    private QueryResponseWriter generateResponseWriter(String wt) throws SolrServerException {
         QueryResponseWriter writer = null;
         if(wt == null || wt.trim().equals("") || wt.equals(XML)) {
             writer = new XMLResponseWriter();
@@ -254,8 +301,8 @@
             writer = new PHPResponseWriter();
         } else if(wt.equals(PHPS)) {
             writer = new PHPSerializedResponseWriter();
-        /*} else if(wt.equals(VELOCITY)) {
-            writer = new VelocityResponseWriter();*/
+        } else if(wt.equals(VELOCITY)) {
+            writer = new VelocityResponseWriter();
         } else if(wt.equals(CSV)) {
             writer = new CSVResponseWriter();
         } else {
