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.MediaType; 024import javax.ws.rs.ext.Provider; 025 026import org.codehaus.jackson.JsonGenerator; 027import org.nuxeo.ecm.automation.jaxrs.io.EntityWriter; 028import org.nuxeo.ecm.core.convert.api.ConversionStatus; 029 030/** 031 * @since 7.4 032 */ 033@Provider 034@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON + "+nxentity" }) 035public class ConversionStatusWriter extends EntityWriter<ConversionStatus> { 036 037 public static final String ENTITY_TYPE = "conversionStatus"; 038 039 @Override 040 protected void writeEntityBody(JsonGenerator jg, ConversionStatus conversionStatus) throws IOException { 041 jg.writeStringField("conversionId", conversionStatus.id); 042 jg.writeStringField("status", conversionStatus.status.name().toLowerCase()); 043 } 044 045 @Override 046 protected String getEntityType() { 047 return ENTITY_TYPE; 048 } 049}