001/* 002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Thomas Roger 016 */ 017 018package org.nuxeo.ecm.restapi.jaxrs.io.conversion; 019 020import java.io.IOException; 021 022import javax.ws.rs.Produces; 023import javax.ws.rs.core.Context; 024import javax.ws.rs.core.MediaType; 025import javax.ws.rs.ext.Provider; 026 027import org.codehaus.jackson.JsonGenerator; 028import org.nuxeo.ecm.automation.jaxrs.io.EntityWriter; 029import org.nuxeo.ecm.core.convert.api.ConversionStatus; 030import org.nuxeo.ecm.webengine.model.WebContext; 031 032/** 033 * @since 7.4 034 */ 035@Provider 036@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON + "+nxentity" }) 037public class ConversionStatusWriter extends EntityWriter<ConversionStatus> { 038 039 public static final String ENTITY_TYPE = "conversionStatus"; 040 041 @Override 042 protected void writeEntityBody(JsonGenerator jg, ConversionStatus conversionStatus) throws IOException { 043 jg.writeStringField("conversionId", conversionStatus.id); 044 jg.writeStringField("status", conversionStatus.status.name().toLowerCase()); 045 } 046 047 @Override 048 protected String getEntityType() { 049 return ENTITY_TYPE; 050 } 051}