/*
* (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Contributors:
* Nuxeo - initial API and implementation
*
*/
package org.nuxeo.connect.client.we;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuxeo.connect.update.Package;
import org.nuxeo.connect.update.PackageException;
import org.nuxeo.connect.update.PackageUpdateService;
import org.nuxeo.ecm.webengine.model.WebObject;
import org.nuxeo.ecm.webengine.model.impl.DefaultObject;
import org.nuxeo.runtime.api.Framework;
/**
* Provides REST bindings for {@link Package} removal.
*
* @author <a href="mailto:tm@nuxeo.com">Thierry Martins</a>
*/
@WebObject(type = "removeHandler")
public class RemoveHandler extends DefaultObject {
protected static final Log log = LogFactory.getLog(RemoveHandler.class);
@GET
@Produces("text/html")
@Path(value = "start/{pkgId}")
public Object startInstall(@PathParam("pkgId") String pkgId, @QueryParam("source") String source) {
try {
PackageUpdateService pus = Framework.getLocalService(PackageUpdateService.class);
pus.removePackage(pkgId);
return getView("removeDone").arg("pkgId", pkgId).arg("source", source);
} catch (PackageException e) {
log.error("Error during first step of installation", e);
return getView("removeError").arg("e", e);
}
}
}