/*
 * The Gemma project
 * 
 * Copyright (c) 2006 University of British Columbia
 * 
 * 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 ubic.gemma.web.view;

import java.io.Writer;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;
import org.springframework.web.servlet.View;

/**
 * @author paul
 * @version $Id$
 */
public class JSONView implements View {

    private String docType = "text/plain";

    /**
     * @param docType e.g., text/html to switch from the default 'text/plain'.
     */
    public JSONView( String docType ) {
        this.docType = docType;
    }

    /*
     * (non-Javadoc)
     * @see org.springframework.web.servlet.View#getContentType()
     */
    public String getContentType() {
        return this.docType;
    }

    /*
     * (non-Javadoc)
     * @see org.springframework.web.servlet.View#render(java.util.Map, javax.servlet.http.HttpServletRequest,
     * javax.servlet.http.HttpServletResponse)
     */
    @SuppressWarnings("unchecked")
    public void render( Map map, HttpServletRequest reqest, HttpServletResponse response ) throws Exception {
        JSONObject jso = JSONObject.fromObject( map );
        Writer writer = response.getWriter();
        jso.write( writer );
    }

}

@@ -842,16 +842,102 @@
 NObject;
+%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;
 %0Aimport 
@@ -1057,16 +1057,69 @@
 View %7B%0A%0A
+    Log log = LogFactory.getLog( this.getClass() );%0A%0A
     priv
@@ -1942,16 +1942,52 @@
 iter();%0A
+        log.info( jso.toString() );%0A
         

add logging