org.ow2.petals.microkernel.jbi.management.task.installation.uninstall.component.RemoveComponentRepositoryTask Maven / Gradle / Ivy
/**
* Copyright (c) 2007-2012 EBM WebSourcing, 2012-2016 Linagora
*
* This program/library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or (at your
* option) any later version.
*
* This program/library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program/library; If not, see http://www.gnu.org/licenses/
* for the GNU Lesser General Public License version 2.1.
*/
package org.ow2.petals.microkernel.jbi.management.task.installation.uninstall.component;
import java.io.IOException;
import org.ow2.petals.microkernel.api.configuration.ContainerConfiguration;
import org.ow2.petals.microkernel.api.jbi.management.Context;
import org.ow2.petals.microkernel.api.system.repository.RepositoryService;
import org.ow2.petals.microkernel.jbi.management.task.AbstractLoggableTask;
import com.ebmwebsourcing.easycommons.log.LoggingUtil;
/**
* This task remove the component folder from the Petals repository.
*
* This task MUST be executed with a {@link Context} containing:
*
* - component name as entity name,
*
* and returns no data in the {@link Context}.
*
*
* The task has got a robust approach : it tries to do all the subtasks and
* doesn't have the undo capability.
*
*
* @author Olivier Fabre - EBM WebSourcing
* @author Frederic Gardes - EBM WebSourcing
*/
public class RemoveComponentRepositoryTask extends AbstractLoggableTask {
private final RepositoryService repositoryService;
public RemoveComponentRepositoryTask(final LoggingUtil log,
final RepositoryService repositoryService,
final ContainerConfiguration containerConfiguration) {
super(log, containerConfiguration);
this.repositoryService = repositoryService;
}
public void execute(Context context) throws Exception {
String componentName = context.getEntityName();
try {
this.repositoryService.removeComponent(componentName);
} catch (IOException e) {
// TODO: rnaudin : reactivate the log when the problem of removing
// opened descriptor would be totally solved
// this.log.error(
// "The component " + componentName +
// " can not be removed from repository", e);
}
}
public void undo(Context context) throws Exception {
// TODO : recreate the component folder
}
}