80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * Copyright (c) 2008 Sun Microsystems Inc. All Rights Reserved
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * The contents of this file are subject to the terms
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * of the Common Development and Distribution License
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * (the License). You may not use this file except in
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * compliance with the License.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * You can obtain a copy of the License at
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * https://opensso.dev.java.net/public/CDDLv1.0.html or
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * See the License for the specific language governing
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * permission and limitations under the License.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * When distributing Covered Code, include this CDDL
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * Header Notice in each file and include the License file
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * If applicable, add the following below the CDDL Header,
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * with the fields enclosed by brackets [] replaced by
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * your own identifying information:
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * "Portions Copyrighted [year] [name of copyright owner]"
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * $Id: MigrateUnconfigureDomainXMLTask.java,v 1.2 2008/06/25 05:52:11 qcheng Exp $
80c77071c6700660c39046da32a0d7953620f608Mark de Reeperpackage com.sun.identity.agents.install.appserver.v81;
80c77071c6700660c39046da32a0d7953620f608Mark de Reeperimport com.sun.identity.install.tools.util.Debug;
80c77071c6700660c39046da32a0d7953620f608Mark de Reeperimport com.sun.identity.install.tools.configurator.MigrateFromInstFinderStore;
80c77071c6700660c39046da32a0d7953620f608Mark de Reeperimport com.sun.identity.install.tools.configurator.IStateAccess;
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * Class to remove previous agent's config in domain.xml.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeperpublic class MigrateUnconfigureDomainXMLTask extends UnconfigureDomainXMLTask {
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper private static final String STR_AM_CLIENT_SDK_JAR = "amclientsdk.jar";
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper private static final String STR_AM_CLIENT_SDK_JAR2 = "famclientsdk.jar";
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * For remote application server instance, set
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * STR_SAVE_REMOTE_AGENT_INSTALL_DIR_KEY
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * as previous agent's install directory before unconfigure.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper protected void preUnconfigureTasks(IStateAccess stateAccess) {
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String remoteHomeDir = getRemoteHomeDir(stateAccess);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String saveRemoteHomeDir = (String)stateAccess.get(
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper if (saveRemoteHomeDir != null && saveRemoteHomeDir.length() > 0) {
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper stateAccess.put(STR_REMOTE_AGENT_INSTALL_DIR_KEY,
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper stateAccess.put(STR_SAVE_REMOTE_AGENT_INSTALL_DIR_KEY,
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String remoteAgentName = (String) stateAccess.get(
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String saveAgentName = (String)stateAccess.get(
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper if (saveAgentName != null && saveAgentName.length() > 0) {
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper stateAccess.put(STR_AGENT_INSTANCE_NAME_KEY, saveAgentName);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper stateAccess.put(STR_SAVE_AGENT_INSTANCE_NAME_KEY, remoteAgentName);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * For remote application server instance, set
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * STR_SAVE_REMOTE_AGENT_INSTALL_DIR_KEY as new agent's install directory
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * after unconfigure, so other install tasks will use the new one.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper protected void postUnconfigureTasks(IStateAccess stateAccess) {
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String remoteHomeDir = getRemoteHomeDir(stateAccess);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String migrateRemoteHomeDir = (String)stateAccess.get(
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper if (migrateRemoteHomeDir != null && migrateRemoteHomeDir.length() > 0) {
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper stateAccess.put(STR_REMOTE_AGENT_INSTALL_DIR_KEY,
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String migrateRemoteAgentName = (String)stateAccess.get(
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * get previous agent's classpath for unconfiguring.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper protected String[] getAgentClasspathEntries(IStateAccess stateAccess) {
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String remoteHomeDir = getRemoteHomeDir(stateAccess);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper // get the agent install directory on a remote instance
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper libPath = remoteHomeDir + FILE_SEP + INSTANCE_LIB_DIR_NAME;
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper "MigrateUnconfigureDomainXMLTask." +
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper "getAgentClassPathEntries: Modified libPath = "
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String instanceName = getAgentInstanceName(stateAccess);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String instanceConfigDirPath = sb.toString();
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper entryList.add(libPath + FILE_SEP + STR_AGENT_JAR);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper entryList.add(libPath + FILE_SEP + STR_FM_CLIENT_SDK_JAR);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper entryList.add(libPath + FILE_SEP + STR_AM_CLIENT_SDK_JAR);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper entryList.add(libPath + FILE_SEP + STR_AM_CLIENT_SDK_JAR2);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper Debug.log("MigrateUnconfigureDomainXMLTask." +
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper "getAgentClasspathEntries(): " +
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper return (String[]) entryList.toArray(new String[0]);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * get previous agent's home directory.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper return MigrateFromInstFinderStore.getProductHome();
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * get previous agent's lib directory.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper return MigrateFromInstFinderStore.getProductHome() + FILE_SEP +
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * get previous agent's locale directory.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper return MigrateFromInstFinderStore.getProductHome() + FILE_SEP +
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * get previous agent's config directory.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper return MigrateFromInstFinderStore.getProductHome() + FILE_SEP +
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * get previous agent instance's name.
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper private String getAgentInstanceName(IStateAccess stateAccess) {
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String agentInstanceName = (String) stateAccess.get(
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper // Get the user input for agent instance name only when instance is
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper "MigrateUnconfigureDomainXMLTask.getAgentInstanceName():" +
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper "Using remote agent instance name : "+ agentInstanceName);
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper * If any, get previous agent's install directory for remote appserver
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper private String getRemoteHomeDir(IStateAccess stateAccess) {
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper String remoteHomeDir = (String)stateAccess.get(
80c77071c6700660c39046da32a0d7953620f608Mark de Reeper if (remoteHomeDir == null || remoteHomeDir.length() == 0) {