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.i18n.ConsoleTranslate;
026: import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean;
027: import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
028:
029: /**
030: * This class defines a "update dump path" admin command.
031: *
032: * @author <a href="mailto:jeff.mesnil@emicnetworks.com">Jeff Mesnil</a>
033: */
034: public class UpdateDumpPath extends AbstractAdminCommand {
035:
036: /**
037: * Creates an "update backup path" command.
038: *
039: * @param module the command is attached to
040: */
041: public UpdateDumpPath(VirtualDatabaseAdmin module) {
042: super (module);
043: }
044:
045: /**
046: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
047: */
048: public void parse(String commandText) throws Exception {
049: String dumpName = null;
050: String newPath = null;
051: StringTokenizer st = new StringTokenizer(commandText.trim());
052:
053: if (st.countTokens() != 2) {
054: console.printError(getUsage());
055: return;
056: }
057: try {
058: dumpName = st.nextToken();
059: newPath = st.nextToken();
060: if (dumpName == null || newPath == null) {
061: console.printError(getUsage());
062: return;
063: }
064:
065: console.printInfo(ConsoleTranslate.get(
066: "admin.command.update.dump.path.echo", //$NON-NLS-1$
067: new String[] { dumpName, newPath }));
068: VirtualDatabaseMBean vdjc = jmxClient
069: .getVirtualDatabaseProxy(dbName, user, password);
070: vdjc.updateDumpPath(dumpName, newPath);
071: console.printInfo(ConsoleTranslate.get(
072: "admin.command.update.dump.path.done", //$NON-NLS-1$
073: new String[] { dumpName, newPath }));
074: } catch (Exception e) {
075: console.printError("problem while updating path", e);
076: }
077: }
078:
079: /**
080: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
081: */
082: public String getCommandName() {
083: return "force path"; //$NON-NLS-1$
084: }
085:
086: /**
087: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
088: */
089: public String getCommandDescription() {
090: return ConsoleTranslate
091: .get("admin.command.update.dump.path.description"); //$NON-NLS-1$
092: }
093:
094: /**
095: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
096: */
097: public String getCommandParameters() {
098: return ConsoleTranslate
099: .get("admin.command.update.dump.path.parameters"); //$NON-NLS-1$
100: }
101: }
|