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.automation.io.services.enricher;
020
021import java.io.IOException;
022import java.util.List;
023
024import org.codehaus.jackson.JsonGenerator;
025import org.nuxeo.ecm.automation.jaxrs.io.documents.JsonDocumentListWriter;
026import org.nuxeo.ecm.core.api.CoreSession;
027import org.nuxeo.ecm.core.api.DocumentModel;
028import org.nuxeo.ecm.core.api.impl.DocumentModelListImpl;
029import org.nuxeo.ecm.core.io.marshallers.json.enrichers.BreadcrumbJsonEnricher;
030
031/**
032 * @since 5.7.3
033 * @deprecated This enricher was migrated to {@link BreadcrumbJsonEnricher}. The content enricher service doesn't work
034 *             anymore.
035 */
036@Deprecated
037public class BreadcrumbEnricher extends AbstractContentEnricher {
038
039    @Override
040    public void enrich(JsonGenerator jg, RestEvaluationContext ec) throws IOException {
041        DocumentModel doc = ec.getDocumentModel();
042        CoreSession session = doc.getCoreSession();
043        List<DocumentModel> parentDocuments = session.getParentDocuments(doc.getRef());
044        JsonDocumentListWriter.writeDocuments(jg, new DocumentModelListImpl(parentDocuments), new String[] {},
045                ec.getRequest());
046    }
047
048}