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.server.jaxrs.adapters; 020 021import javax.ws.rs.Produces; 022import javax.ws.rs.core.MediaType; 023 024import org.nuxeo.ecm.core.api.DocumentModel; 025import org.nuxeo.ecm.platform.query.api.PageProviderDefinition; 026import org.nuxeo.ecm.platform.query.api.PageProviderService; 027import org.nuxeo.ecm.webengine.model.WebAdapter; 028import org.nuxeo.runtime.api.Framework; 029 030/** 031 * Adapter that returns the children of the pointed resource 032 * 033 * @since 5.7.2 034 */ 035@WebAdapter(name = ChildrenAdapter.NAME, type = "ChildrenService") 036@Produces({ "application/json+nxentity", "application/json+esentity", MediaType.APPLICATION_JSON }) 037public class ChildrenAdapter extends DocumentModelListPaginableAdapter { 038 039 public static final String NAME = "children"; 040 041 @Override 042 protected PageProviderDefinition getPageProviderDefinition() { 043 PageProviderService ppService = Framework.getLocalService(PageProviderService.class); 044 return ppService.getPageProviderDefinition("CURRENT_DOC_CHILDREN"); 045 } 046 047 @Override 048 protected Object[] getParams() { 049 return new Object[] { getTarget().getAdapter(DocumentModel.class).getId() }; 050 } 051}