001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors. 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 * Vladimir Pasquier <vpasquier@nuxeo.com> 016 */ 017package org.nuxeo.ecm.automation.jaxrs.io.audit; 018 019import java.io.IOException; 020import java.lang.annotation.Annotation; 021import java.lang.reflect.Type; 022 023import javax.ws.rs.Produces; 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.EntityListWriter; 029import org.nuxeo.ecm.platform.audit.api.LogEntry; 030import org.nuxeo.ecm.platform.audit.api.LogEntryList; 031import org.nuxeo.ecm.webengine.jaxrs.coreiodelegate.JsonCoreIODelegate; 032 033/** 034 * @since 5.7.3 - LogEntries Writer for Audit 035 * @deprecated this marshaller was migrated to org.nuxeo.ecm.platform.audit.io.LogEntryListJsonWriter. To use it in 036 * JAX-RS, register the {@link JsonCoreIODelegate} to forward the JAX-RS marshalling to nuxeo-core-io. 037 */ 038@Deprecated 039@Provider 040@Produces({ "application/json+nxentity", "application/json" }) 041public class LogEntryListWriter extends EntityListWriter<LogEntry> { 042 043 @Override 044 protected String getEntityType() { 045 return "logEntries"; 046 } 047 048 @Override 049 public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) { 050 if (LogEntryList.class.isAssignableFrom(arg0)) { 051 return true; 052 } else { 053 return super.isWriteable(arg0, arg1, arg2, arg3); 054 } 055 } 056 057 @Override 058 protected void writeItem(JsonGenerator jg, LogEntry item) throws IOException { 059 LogEntryWriter ngw = new LogEntryWriter(); 060 ngw.writeEntity(jg, item); 061 } 062 063}