001/* 002 * (C) Copyright 2016 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 * "Guillaume Renard" 018 */ 019 020package org.nuxeo.ecm.restapi.server.jaxrs.adapters; 021 022import org.nuxeo.ecm.core.api.NuxeoGroup; 023import org.nuxeo.ecm.platform.query.api.PageProviderDefinition; 024import org.nuxeo.ecm.platform.query.api.PageProviderService; 025import org.nuxeo.ecm.restapi.server.jaxrs.adapters.PaginableAdapter; 026import org.nuxeo.ecm.restapi.server.jaxrs.usermanager.GroupObject; 027import org.nuxeo.ecm.webengine.model.WebAdapter; 028import org.nuxeo.runtime.api.Framework; 029 030import javax.ws.rs.Produces; 031import javax.ws.rs.core.MediaType; 032 033/** 034 * @since 8.2 035 */ 036@WebAdapter(name = GroupMemberGroupsAdapter.NAME, type = "GroupMemberGroups") 037@Produces({ "application/json+nxentity", MediaType.APPLICATION_JSON }) 038public class GroupMemberGroupsAdapter extends PaginableAdapter<NuxeoGroup> { 039 040 public static final String NAME = "groups"; 041 public static final String PAGE_PROVIDER_NAME = "nuxeo_group_member_groups_listing"; 042 043 protected String query; 044 045 @Override 046 protected void initialize(Object... args) { 047 super.initialize(args); 048 query = ctx.getRequest().getParameter("q"); 049 } 050 051 @Override 052 protected PageProviderDefinition getPageProviderDefinition() { 053 PageProviderService ppService = Framework.getLocalService(PageProviderService.class); 054 return ppService.getPageProviderDefinition(PAGE_PROVIDER_NAME); 055 } 056 057 @Override 058 protected Object[] getParams() { 059 return new Object[] { ((GroupObject) getTarget()).doGetArtifact(), query }; 060 } 061 062}