001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Contact: sequoia@continuent.org
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: *
019: * Initial developer(s): Emmanuel Cecchet.
020: * Contributor(s): ______________________.
021: */package org.continuent.sequoia.console.text.commands.dbadmin;
022:
023: import java.util.StringTokenizer;
024:
025: import org.continuent.sequoia.common.exceptions.VirtualDatabaseException;
026: import org.continuent.sequoia.common.i18n.ConsoleTranslate;
027: import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean;
028: import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
029:
030: /**
031: * This class defines a RemoveDump
032: *
033: * @author <a href="mailto:jeff.mesnil@emicnetworks.com">Jeff Mesnil</a>
034: * @version 1.0
035: */
036: public class RemoveDump extends AbstractAdminCommand {
037:
038: /**
039: * Create a "remove dump" admin command.
040: *
041: * @param module the command is attached to
042: */
043: public RemoveDump(VirtualDatabaseAdmin module) {
044: super (module);
045: }
046:
047: /**
048: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
049: */
050: public void parse(String commandText) throws Exception {
051: StringTokenizer tokenizer = new StringTokenizer(commandText
052: .trim());
053:
054: if (tokenizer.countTokens() < 1) {
055: console.printError(getUsage());
056: return;
057: }
058:
059: String dumpName = tokenizer.nextToken();
060: boolean keepsFile = false;
061:
062: if (tokenizer.countTokens() == 1) {
063: String keepsFileStr = tokenizer.nextToken();
064: keepsFile = "keepfile".equals(keepsFileStr); //$NON-NLS-1$
065: }
066:
067: if ("".equals(dumpName)) //$NON-NLS-1$
068: {
069: console.printError(getUsage());
070: return;
071: }
072:
073: VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(
074: dbName, user, password);
075: try {
076: vdjc.deleteDump(dumpName, keepsFile);
077: console.printInfo(ConsoleTranslate
078: .get("admin.command.remove.dump.done")); //$NON-NLS-1$
079: } catch (VirtualDatabaseException e) {
080: console.printError(e.getMessage(), e); //$NON-NLS-1$
081: }
082: }
083:
084: /**
085: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
086: */
087: public String getCommandName() {
088: return "delete dump"; //$NON-NLS-1$
089: }
090:
091: /**
092: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
093: */
094: public String getCommandDescription() {
095: return ConsoleTranslate
096: .get("admin.command.remove.dump.description"); //$NON-NLS-1$
097: }
098:
099: /**
100: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
101: */
102: public String getCommandParameters() {
103: return ConsoleTranslate
104: .get("admin.command.remove.dump.parameters"); //$NON-NLS-1$
105: }
106: }
|