fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major/**
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major *
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major *
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * The contents of this file are subject to the terms
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * of the Common Development and Distribution License
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * (the License). You may not use this file except in
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * compliance with the License.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major *
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * You can obtain a copy of the License at
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * https://opensso.dev.java.net/public/CDDLv1.0.html or
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * opensso/legal/CDDLv1.0.txt
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * See the License for the specific language governing
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * permission and limitations under the License.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major *
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * When distributing Covered Code, include this CDDL
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Header Notice in each file and include the License file
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * at opensso/legal/CDDLv1.0.txt.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * If applicable, add the following below the CDDL Header,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * with the fields enclosed by brackets [] replaced by
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * your own identifying information:
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * "Portions Copyrighted [year] [name of copyright owner]"
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major *
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * $Id: DeleteLayoutTask.java,v 1.2 2008/06/25 05:51:18 qcheng Exp $
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major *
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major */
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorpackage com.sun.identity.install.tools.configurator;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorimport java.io.File;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorimport java.util.Map;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorimport com.sun.identity.install.tools.util.Debug;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorimport com.sun.identity.install.tools.util.FileUtils;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorimport com.sun.identity.install.tools.util.LocalizedMessage;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorimport com.sun.identity.install.tools.util.ConfigUtil;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorpublic class DeleteLayoutTask implements ITask, InstallConstants {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public boolean execute(String name, IStateAccess stateAccess,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major Map properties) throws InstallException {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major String configDirPath = getConfigDirPath(stateAccess);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major Debug.log("DeleteLayoutTask.execute() - Deleting directory '"
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major + configDirPath + "' and its contents.");
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major File configDir = new File(configDirPath);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major return FileUtils.removeDir(configDir);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major }
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public LocalizedMessage getExecutionMessage(IStateAccess stateAccess,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major Map properties) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major Object[] args = { getConfigDirPath(stateAccess) };
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major LocalizedMessage message = LocalizedMessage.get(
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major LOC_TSK_MSG_DELETE_LAYOUT_EXECUTE, args);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major return message;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major }
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public LocalizedMessage getRollBackMessage(IStateAccess stateAccess,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major Map properties) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // There is no roll back for uninstall tasks
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major return null;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major }
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public boolean rollBack(String name, IStateAccess state, Map properties)
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major throws InstallException {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // Nothing to roll back during uninstall
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major return true;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major }
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major private String getConfigDirPath(IStateAccess stateAccess) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major String productHome = ConfigUtil.getHomePath();
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major String configDirPath = productHome + FILE_SEP
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major + stateAccess.getInstanceName() + FILE_SEP
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major + INSTANCE_CONFIG_DIR_NAME;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major return configDirPath;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major }
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public static final String LOC_TSK_MSG_DELETE_LAYOUT_EXECUTE =
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major "TSK_MSG_DELETE_LAYOUT_EXECUTE";
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major}