001/* 002 * (C) Copyright 2006-2009 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 * Nuxeo - initial API and implementation 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.webengine.admin; 023 024import javax.ws.rs.DELETE; 025import javax.ws.rs.GET; 026import javax.ws.rs.POST; 027import javax.ws.rs.PUT; 028import javax.ws.rs.Path; 029import javax.ws.rs.Produces; 030import javax.ws.rs.core.Response; 031 032import org.nuxeo.ecm.core.api.NuxeoGroup; 033import org.nuxeo.ecm.platform.usermanager.UserManager; 034import org.nuxeo.ecm.webengine.model.WebObject; 035import org.nuxeo.ecm.webengine.model.impl.DefaultObject; 036import org.nuxeo.runtime.api.Framework; 037 038@WebObject(type = "Group") 039@Produces("text/html;charset=UTF-8") 040public class Group extends DefaultObject { 041 042 NuxeoGroup group; 043 044 @Override 045 protected void initialize(Object... args) { 046 assert args != null && args.length > 0; 047 group = (NuxeoGroup) args[0]; 048 } 049 050 @GET 051 public Object doGet() { 052 return getView("index").arg("group", group); 053 } 054 055 @POST 056 public Response doPost() { 057 return redirect(getPrevious().getPath()); 058 } 059 060 @PUT 061 public Response doPut() { 062 return redirect(getPath()); 063 } 064 065 @DELETE 066 public Response doDelete() { 067 UserManager userManager = Framework.getService(UserManager.class); 068 userManager.deleteGroup(group); 069 return redirect(getPrevious().getPath()); 070 } 071 072 @POST 073 @Path("@put") 074 public Response simulatePut() { 075 return doPut(); 076 } 077 078 @GET 079 @Path("@delete") 080 public Response simulateDelete() { 081 return doDelete(); 082 } 083 084}