001/*
002 * (C) Copyright 2013 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 *     dmetzler
018 */
019package org.nuxeo.ecm.restapi.jaxrs.io.usermanager;
020
021import java.io.IOException;
022
023import javax.ws.rs.Produces;
024import javax.ws.rs.ext.Provider;
025
026import org.codehaus.jackson.JsonGenerator;
027import org.nuxeo.ecm.automation.jaxrs.io.EntityListWriter;
028import org.nuxeo.ecm.core.api.NuxeoPrincipal;
029import org.nuxeo.ecm.platform.usermanager.io.NuxeoPrincipalListJsonWriter;
030import org.nuxeo.ecm.webengine.jaxrs.coreiodelegate.JsonCoreIODelegate;
031
032/**
033 * @since 5.7.3
034 * @deprecated since 7.10 The Nuxeo JSON marshalling was migrated to nuxeo-core-io. This class is replaced by
035 *             {@link NuxeoPrincipalListJsonWriter} which is registered by default and available to marshal
036 *             {@link NuxeoPrincipal}'s list from the Nuxeo Rest API thanks to the JAX-RS marshaller
037 *             {@link JsonCoreIODelegate}
038 */
039@Deprecated
040@Provider
041@Produces({ "application/json+nxentity", "application/json" })
042public class NuxeoPrincipalListWriter extends EntityListWriter<NuxeoPrincipal> {
043
044    /**
045     *
046     */
047    public static final String ENTITY_TYPE = "users";
048
049    @Override
050    protected String getEntityType() {
051        return ENTITY_TYPE;
052    }
053
054    @Override
055    protected void writeItem(JsonGenerator jg, NuxeoPrincipal item) throws IOException {
056
057        NuxeoPrincipalWriter npw = new NuxeoPrincipalWriter();
058        npw.writeEntity(jg, item);
059    }
060
061}