001/* 002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 */ 018package org.nuxeo.connect.client.we; 019 020import javax.ws.rs.GET; 021import javax.ws.rs.Path; 022import javax.ws.rs.PathParam; 023import javax.ws.rs.Produces; 024import javax.ws.rs.QueryParam; 025 026import org.apache.commons.logging.Log; 027import org.apache.commons.logging.LogFactory; 028import org.nuxeo.connect.update.Package; 029import org.nuxeo.connect.update.PackageException; 030import org.nuxeo.connect.update.PackageUpdateService; 031import org.nuxeo.ecm.webengine.model.WebObject; 032import org.nuxeo.ecm.webengine.model.impl.DefaultObject; 033import org.nuxeo.runtime.api.Framework; 034 035/** 036 * Provides REST bindings for {@link Package} removal. 037 * 038 * @author <a href="mailto:tm@nuxeo.com">Thierry Martins</a> 039 */ 040@WebObject(type = "removeHandler") 041public class RemoveHandler extends DefaultObject { 042 043 protected static final Log log = LogFactory.getLog(RemoveHandler.class); 044 045 @GET 046 @Produces("text/html") 047 @Path(value = "start/{pkgId}") 048 public Object startInstall(@PathParam("pkgId") String pkgId, @QueryParam("source") String source) { 049 try { 050 PackageUpdateService pus = Framework.getLocalService(PackageUpdateService.class); 051 pus.removePackage(pkgId); 052 return getView("removeDone").arg("pkgId", pkgId).arg("source", source); 053 } catch (PackageException e) { 054 log.error("Error during first step of installation", e); 055 return getView("removeError").arg("e", e); 056 } 057 } 058 059}