001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bjalon 018 */ 019package org.nuxeo.ecm.mobile.webengine.adapter; 020 021import javax.ws.rs.GET; 022import javax.ws.rs.Path; 023import javax.ws.rs.Produces; 024import javax.ws.rs.QueryParam; 025 026import org.nuxeo.ecm.webengine.WebException; 027import org.nuxeo.ecm.webengine.model.WebAdapter; 028 029/** 030 * Adapter that expose a document according the DForm Jquery Framework structure. 031 * 032 * @author <a href="mailto:bjalon@nuxeo.com">Benjamin JALON</a> 033 * @since 5.5 034 */ 035@WebAdapter(name = "jsonExport", type = "JSONExport", targetType = "MobileDocument") 036@Produces("application/json;charset=UTF-8") 037public class JSonExportAdapter extends DefaultMobileAdapter { 038 039 /** 040 * Return the JSON export of document for dform layout manager 041 * 042 * @param action 043 * @param actionType 044 * @return 045 */ 046 @GET 047 @Path("dform") 048 public Object doGet(@QueryParam("action") String action, @QueryParam("actionType") String actionType) { 049 050 if (action == null && ctx == null) { 051 throw new WebException("No action given into parameters and no " 052 + "context found, can't generate json document export"); 053 } 054 055 if (action == null) { 056 action = ctx.getRequest().getRequestURI(); 057 } 058 059 if (actionType == null) { 060 actionType = "post"; 061 } 062 063 return getView("index").render(); 064 } 065 066}