From e35382180d75ed9a2c9a9d18014d29dd1b671c22 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Tue, 11 May 2010 13:33:47 +0000 Subject: [PATCH] [312415] [dstore] shell service interprets < and > sequences - handle old client/new server case --- .../rse/dstore/universal/miners/CommandMiner.java | 14 ++++++++++++-- .../miners/command/CommandMinerThread.java | 7 ++++++- .../universal/miners/command/OutputHandler.java | 9 +++++++-- .../services/dstore/shells/DStoreShellThread.java | 10 +++++++++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/CommandMiner.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/CommandMiner.java index e4b9ed1b394..8d30ef4abf7 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/CommandMiner.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/CommandMiner.java @@ -19,6 +19,7 @@ * Noriaki Takatsu (IBM) - [230399] [multithread] changes to stop CommandMiner threads when clients disconnect * David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed * David McKnight (IBM) - [286671] Dstore shell service interprets < and > sequences - cmd descriptor to identify ability + * David McKnight (IBM) [312415] [dstore] shell service interprets < and > sequences - handle old client/new server case *******************************************************************************/ package org.eclipse.rse.dstore.universal.miners; @@ -146,7 +147,7 @@ public class CommandMiner extends Miner _dataStore.createReference(cancellable, shellD, "abstracts", "abstracted by"); //$NON-NLS-1$ //$NON-NLS-2$ // indicates support for char conversion in version 3.2 - createCommandDescriptor(fsD, "CharConversion", "C_CHAR_CONVERSION", false); + createCommandDescriptor(fsD, "CharConversion", "C_CHAR_CONVERSION", false); //$NON-NLS-1$ //$NON-NLS-2$ // DataElement inputD = _dataStore.createObject(cmdD, "input", "Enter command"); @@ -230,7 +231,16 @@ public class CommandMiner extends Miner getPossibleCommands(status); return status; } - + else if (name.equals("C_CHAR_CONVERSION")) //$NON-NLS-1$ + { + DataElement cmdStatus = getCommandStatus(subject); + CommandMinerThread theThread = (CommandMinerThread) _threads.get(cmdStatus.getAttribute(DE.A_ID)); + if (theThread != null) + { + theThread._supportsCharConversion = true; + } + } + return status; } diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java index 129ba18f71e..7d3fb866df0 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java @@ -29,6 +29,7 @@ * David McKnight (IBM) [302724] problems with environment variable substitution * David McKnight (IBM) [302996] [dstore] null checks and performance issue with shell output * David McKnight (IBM) [308246] [dstore] fix for Bug 287305 breaks on z/OS due to "su" usage + * David McKnight (IBM) [312415] [dstore] shell service interprets < and > sequences - handle old client/new server case *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.command; @@ -127,6 +128,8 @@ public class CommandMinerThread extends MinerThread private DataElement _lastPrompt; private InitRunnable _initRunnable; private Thread _cdThread; + + public boolean _supportsCharConversion = false; public CommandMinerThread(DataElement theElement, String invocation, DataElement status, Patterns thePatterns, CommandMiner.CommandMinerDescriptors descriptors) { @@ -653,7 +656,9 @@ public class CommandMinerThread extends MinerThread String origInput = input; - input = convertSpecialCharacters(input); + if (_supportsCharConversion){ + input = convertSpecialCharacters(input); + } input.getBytes(); try diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java index cb78e962b1f..1f18e2b952b 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java @@ -21,6 +21,7 @@ * Peter Wang (IBM) [299422] [dstore] OutputHandler.readLines() not compatible with servers that return max 1024bytes available to be read * David McKnight (IBM) [302996] [dstore] null checks and performance issue with shell output * David McKnight (IBM) [309338] [dstore] z/OS USS - invocation of 'env' shell command returns inconsistently organized output + * David McKnight (IBM) [312415] [dstore] shell service interprets < and > sequences - handle old client/new server case *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.command; @@ -129,8 +130,8 @@ public class OutputHandler extends Handler { } private String convertSpecialCharacters(String input){ - // needed to ensure xml characters aren't converted in xml layer - + if (_commandThread._supportsCharConversion){ + // needed to ensure xml characters aren't converted in xml layer StringBuffer output = new StringBuffer(); for (int idx = 0; idx < input.length(); idx++) @@ -151,6 +152,10 @@ public class OutputHandler extends Handler { } return output.toString(); } + else { + return input; + } + } private void doPrompt() { try { diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellThread.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellThread.java index 0f3c28518a2..b52e51a164b 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellThread.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellThread.java @@ -15,6 +15,7 @@ * {Name} (company) - description of contribution. * David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup * David McKnight (IBM) - [286671] Dstore shell service interprets < and > sequences + * David McKnight (IBM) [312415] [dstore] shell service interprets < and > sequences - handle old client/new server case *******************************************************************************/ package org.eclipse.rse.internal.services.dstore.shells; @@ -46,6 +47,8 @@ public class DStoreShellThread private DataElement _status; private String _invocation; + private boolean _sentCharConversionCommand = false; + /** * @param cwd initial working directory * @param invocation launch shell command @@ -267,7 +270,12 @@ public class DStoreShellThread // first, find out if the server support conversion DataElement fsD= dataStore.findObjectDescriptor(DataStoreResources.model_directory); DataElement convDes = dataStore.localDescriptorQuery(fsD, "C_CHAR_CONVERSION", 1); //$NON-NLS-1$ - if (convDes != null){ + if (convDes != null){ + if (!_sentCharConversionCommand){ + dataStore.command(convDes, _status); + _sentCharConversionCommand = true; + } + cmd = convertSpecialCharacters(cmd); }