KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > cli > commands > DeleteDomainCommand


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * $Id: DeleteDomainCommand.java,v 1.4 2006/02/02 00:21:45 pa100654 Exp $
26  */

27
28 package com.sun.enterprise.cli.commands;
29
30 import com.sun.enterprise.cli.framework.*;
31 import com.sun.enterprise.admin.servermgmt.DomainsManager;
32 import com.sun.enterprise.admin.servermgmt.DomainConfig;
33
34 /**
35  * Deletes a domain of the Application server
36  */

37 public class DeleteDomainCommand extends BaseLifeCycleCommand
38 {
39
40
41     /** Creates new DeleteDomainCommand */
42     public DeleteDomainCommand()
43     {
44     }
45
46     /**
47      * Validates the Options for correctness
48      * @return boolean returns true if validation is succesful else false
49      */

50     public boolean validateOptions() throws CommandValidationException
51     {
52         return super.validateOptions();
53     }
54     
55     /**
56      * Executes the command
57      * @throws CommandException
58      */

59     public void runCommand() throws CommandException, CommandValidationException
60     {
61         validateOptions();
62     
63     String JavaDoc domainName = null;
64         try
65         {
66         domainName = (String JavaDoc)operands.firstElement();
67             DomainConfig domainConfig = getDomainConfig(domainName);
68             DomainsManager manager = getFeatureFactory().getDomainsManager();
69             manager.deleteDomain(domainConfig);
70             deleteLoginInfo();
71         }
72         catch (Exception JavaDoc e)
73         {
74         CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
75         throw new CommandException(getLocalizedString("CouldNotDeleteDomain",
76                               new Object JavaDoc[] {domainName}));
77         }
78
79     CLILogger.getInstance().printDetailMessage(getLocalizedString("DomainDeleted",
80                                              new Object JavaDoc[] {domainName}));
81     }
82
83
84     /**
85      * This method will delete the entry in the .asadminpass file if exists
86      */

87     private void deleteLoginInfo() throws CommandValidationException
88     {
89         return;
90     }
91     
92 }
93
Popular Tags