Skip to content

Commit 3334bce

Browse files
Merge pull request #427 from zowe/refactorconsole
Refactor zosconsole package
2 parents c69af8c + f34e1de commit 3334bce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+956
-709
lines changed

src/main/java/zowe/client/sdk/parse/JsonParseFactory.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ public static JsonParse buildParser(final ParseType type) {
5353
case MEMBER:
5454
parseResponse = MemberJsonParse.getInstance();
5555
break;
56-
case MVS_CONSOLE:
57-
parseResponse = MvsConsoleJsonParse.getInstance();
58-
break;
5956
case PROPS:
6057
parseResponse = PropsJsonParse.getInstance();
6158
break;

src/main/java/zowe/client/sdk/parse/MvsConsoleJsonParse.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/main/java/zowe/client/sdk/parse/type/ParseType.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ public enum ParseType {
3333
* member type
3434
*/
3535
MEMBER,
36-
/**
37-
* mvs console type
38-
*/
39-
MVS_CONSOLE,
4036
/**
4137
* property type
4238
*/
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* This program and the accompanying materials are made available under the terms of the
3+
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
4+
* https://www.eclipse.org/legal/epl-v20.html
5+
*
6+
* SPDX-License-Identifier: EPL-2.0
7+
*
8+
* Copyright Contributors to the Zowe Project.
9+
*/
10+
package zowe.client.sdk.utility;
11+
12+
/**
13+
* Utility class contains helper methods for console processing.
14+
*
15+
* @author Frank Giordano
16+
* @version 5.0
17+
*/
18+
public final class ConsoleUtils {
19+
20+
/**
21+
* Private constructor defined to avoid instantiation of class
22+
*/
23+
private ConsoleUtils() {
24+
throw new IllegalStateException("Utility class");
25+
}
26+
27+
/**
28+
* Process response from console command. Add a line break if needed.
29+
*
30+
* @param response string value of response from console command
31+
* @return string value of response with line break added if needed
32+
*/
33+
public static String processCmdResponse(String response) {
34+
response = response.replace('\r', '\n');
35+
if (!response.isBlank() && response.charAt(response.length() - 1) != '\n') {
36+
response = response + "\n";
37+
}
38+
return response;
39+
}
40+
41+
}

src/main/java/zowe/client/sdk/utility/EncodeUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.Base64;
1717

1818
/**
19-
* Utility class contains helper methods for encoding processing
19+
* Utility class contains helper methods for encoding processing.
2020
*
2121
* @author Frank Giordano
2222
* @version 5.0

src/main/java/zowe/client/sdk/utility/JsonParserUtil.java renamed to src/main/java/zowe/client/sdk/utility/JsonParserUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
import zowe.client.sdk.rest.exception.ZosmfRequestException;
1919

2020
/**
21-
* Utility class contains helper methods for JSON parse processing
21+
* Utility class contains helper methods for JSON parse processing.
2222
*
2323
* @author Frank Giordano
2424
* @version 5.0
2525
*/
26-
public final class JsonParserUtil {
26+
public final class JsonParserUtils {
2727

28-
private static final Logger LOG = LoggerFactory.getLogger(JsonParserUtil.class);
28+
private static final Logger LOG = LoggerFactory.getLogger(JsonParserUtils.class);
2929

3030
private static final String PARSE_ERROR_MSG = "json response parse error";
3131

3232
/**
3333
* Private constructor defined to avoid instantiation of class
3434
*/
35-
private JsonParserUtil() {
35+
private JsonParserUtils() {
3636
throw new IllegalStateException("Utility class");
3737
}
3838

src/main/java/zowe/client/sdk/utility/TsoUtil.java renamed to src/main/java/zowe/client/sdk/utility/TsoUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
import java.util.concurrent.atomic.AtomicInteger;
2020

2121
/**
22-
* Utility class contains helper methods for response processing
22+
* Utility class contains helper methods for TSO response processing.
2323
*
2424
* @author Frank Giordano
2525
* @version 5.0
2626
*/
27-
public class TsoUtil {
27+
public final class TsoUtils {
2828

2929
/**
3030
* Private constructor defined to avoid instantiation of class
3131
*/
32-
private TsoUtil() {
32+
private TsoUtils() {
3333
throw new IllegalStateException("Utility class");
3434
}
3535

src/main/java/zowe/client/sdk/utility/ValidateUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import java.util.Optional;
1515

1616
/**
17-
* Utility class contains helper methods for validation processing
17+
* Utility class contains helper methods for validation processing.
1818
*
1919
* @author Frank Giordano
2020
* @version 5.0

src/main/java/zowe/client/sdk/zosconsole/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import zowe.client.sdk.core.ZosConnectionFactory;
1616
import zowe.client.sdk.examples.TstZosConnection;
1717
import zowe.client.sdk.rest.exception.ZosmfRequestException;
1818
import zowe.client.sdk.zosconsole.ConsoleConstants;
19-
import zowe.client.sdk.zosconsole.input.IssueConsoleInputData;
20-
import zowe.client.sdk.zosconsole.method.IssueConsole;
19+
import zowe.client.sdk.zosconsole.input.ConsoleCmdInputData;
20+
import zowe.client.sdk.zosconsole.method.ConsoleCmd;
21+
import zowe.client.sdk.zosconsole.response.ConsoleGetResponse;
2122
import zowe.client.sdk.zosconsole.response.ConsoleResponse;
2223

2324
/**
@@ -50,10 +51,10 @@ public class IssueConsoleExp extends TstZosConnection {
5051
* @author Frank Giordano
5152
*/
5253
public static void issueCommand(ZosConnection connection, String cmd) {
53-
ConsoleResponse response;
54+
ConsoleGetResponse response;
5455
try {
55-
IssueConsole issueConsole = new IssueConsole(connection);
56-
response = issueConsole.issueCommand(cmd);
56+
ConsoleCmd consoleCmd = new ConsoleCmd(connection);
57+
response = consoleCmd.issueCommand(cmd);
5758
} catch (ZosmfRequestException e) {
5859
String errMsg = (String) e.getResponse().getResponsePhrase().orElse(e.getMessage());
5960
throw new RuntimeException(errMsg);
@@ -70,12 +71,12 @@ public class IssueConsoleExp extends TstZosConnection {
7071
* @author Frank Giordano
7172
*/
7273
public static void issueCommandCommon(ZosConnection connection, String cmd) {
73-
ConsoleResponse response;
74+
ConsoleGetResponse response;
7475
try {
75-
IssueConsole issueConsole = new IssueConsole(connection);
76-
IssueConsoleInputData consoleInputData = new IssueConsoleInputData(cmd);
76+
ConsoleCmd consoleCmd = new ConsoleCmd(connection);
77+
ConsoleCmdInputData consoleInputData = new ConsoleCmdInputData(cmd);
7778
consoleInputData.setProcessResponse();
78-
response = issueConsole.issueCommandCommon(ConsoleConstants.RES_DEF_CN, consoleInputData);
79+
response = consoleCmd.issueCommandCommon(ConsoleConstants.RES_DEF_CN, consoleInputData);
7980
} catch (ZosmfRequestException e) {
8081
String errMsg = (String) e.getResponse().getResponsePhrase().orElse(e.getMessage());
8182
throw new RuntimeException(errMsg);

src/main/java/zowe/client/sdk/zosconsole/input/IssueConsoleInputData.java renamed to src/main/java/zowe/client/sdk/zosconsole/input/ConsoleCmdInputData.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
import java.util.Optional;
1515

1616
/**
17-
* The z/OSMF console API parameters. See the z/OSMF REST API documentation for full details.
17+
* The z/OSMF console command API parameters. See the z/OSMF REST API documentation for full details.
1818
*
1919
* @author Frank Giordano
2020
* @version 5.0
2121
*/
22-
public class IssueConsoleInputData {
22+
public class ConsoleCmdInputData {
2323

2424
/**
2525
* The z/OS console command to issue.
@@ -28,7 +28,7 @@ public class IssueConsoleInputData {
2828

2929
/**
3030
* The solicited keyword to check for in the response. Causes the API to return immediately when the keyword
31-
* is found, however, it may include solicited command response messages beyond the keyword itself.
31+
* is found; however, it may include solicited command response messages beyond the keyword itself.
3232
*/
3333
private String solKey;
3434

@@ -38,8 +38,10 @@ public class IssueConsoleInputData {
3838
private String system;
3939

4040
/**
41-
* The z/OSMF Console API returns '\r' or '\r\n' where line-breaks. Can attempt to replace these
42-
* sequences with '\n', but there may be cases where that are not preferable. Specify false to prevent processing.
41+
* The z/OSMF Console API returns '\r' or '\r\n' where line-breaks.
42+
* You can use the following flag variable to replace these sequences with '\n'.
43+
* But there may be cases where this may not be preferable.
44+
* Specify false to prevent processing.
4345
*/
4446
private boolean processResponse = false;
4547

@@ -49,7 +51,7 @@ public class IssueConsoleInputData {
4951
* @param command console command to issue
5052
* @author Frank Giordano
5153
*/
52-
public IssueConsoleInputData(final String command) {
54+
public ConsoleCmdInputData(final String command) {
5355
ValidateUtils.checkIllegalParameter(command, "command");
5456
this.cmd = command;
5557
}

0 commit comments

Comments
 (0)