Skip to content

Commit efb6fd6

Browse files
committed
Merge branch 'archive-custom-location' into 'main'
adding support for the non-replicated custom location to the archiveHelper tool See merge request weblogic-cloud/weblogic-deploy-tooling!1665
2 parents a5d1844 + 982c8e3 commit efb6fd6

File tree

9 files changed

+200
-45
lines changed

9 files changed

+200
-45
lines changed

core/src/main/java/oracle/weblogic/deploy/tool/archive_helper/add/AddCustomCommand.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@ public class AddCustomCommand extends AddTypeCommandBase {
3737
)
3838
private String sourcePath;
3939

40+
@Option(
41+
names = {"-use_non_replicable_location"},
42+
description = "Place the content into the wlsdeploy/custom location instead of the default config/wlsdeploy/custom location"
43+
)
44+
private boolean useNonReplicableLocation;
45+
4046
@Option(
4147
names = {"-path"},
4248
paramLabel = "<archive-path>",
4349
description = "Relative archive path from custom to the parent directory to use to add the file or directory, if any"
4450
)
45-
private String archivePath = null;
51+
private String archivePath;
4652

4753
@Override
4854
public CommandResponse call() throws Exception {
@@ -57,16 +63,18 @@ public CommandResponse call() throws Exception {
5763
String resultName;
5864
if (this.overwrite) {
5965
String archiveReplacementPath = "";
60-
if (!StringUtils.isEmpty(archivePath)) {
66+
if (!StringUtils.isEmpty(this.archivePath)) {
6167
archiveReplacementPath = this.archivePath;
6268
if (!archiveReplacementPath.endsWith(ZIP_SEP)) {
6369
archiveReplacementPath += ZIP_SEP;
6470
}
6571
}
6672
archiveReplacementPath += sourceFile.getName();
67-
resultName = this.archive.replaceCustomEntry(archiveReplacementPath, sourceFile.getPath());
73+
resultName = this.archive.replaceCustomEntry(archiveReplacementPath, sourceFile.getPath(),
74+
this.useNonReplicableLocation);
6875
} else {
69-
resultName = this.archive.addCustomEntry(sourceFile.getPath(), this.archivePath);
76+
resultName =
77+
this.archive.addCustomEntry(sourceFile.getPath(), this.archivePath, this.useNonReplicableLocation);
7078
}
7179
response = new CommandResponse(ExitCode.OK, resultName);
7280
} catch (ArchiveHelperException ex) {

core/src/main/java/oracle/weblogic/deploy/tool/archive_helper/extract/ExtractCustomCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public class ExtractCustomCommand extends ExtractTypeCommandBase {
3333
)
3434
private String name;
3535

36+
@Option(
37+
names = {"-use_non_replicable_location"},
38+
description = "Extract the contents from the wlsdeploy/custom location instead of the default config/wlsdeploy/custom location"
39+
)
40+
private boolean useNonReplicableLocation;
3641

3742
@Override
3843
public CommandResponse call() throws Exception {
@@ -43,7 +48,7 @@ public CommandResponse call() throws Exception {
4348
try {
4449
initializeOptions();
4550

46-
this.archive.extractCustomEntry(this.name, this.targetDirectory);
51+
this.archive.extractCustomEntry(this.name, this.targetDirectory, useNonReplicableLocation);
4752
response = new CommandResponse(ExitCode.OK, "WLSDPLY-30046", TYPE, this.name,
4853
this.archiveFilePath, this.targetDirectory.getPath());
4954
} catch (ArchiveHelperException ex) {

core/src/main/java/oracle/weblogic/deploy/tool/archive_helper/list/ListCustomCommand.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
*/
55
package oracle.weblogic.deploy.tool.archive_helper.list;
66

7+
import java.util.List;
8+
79
import oracle.weblogic.deploy.logging.PlatformLogger;
810
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
11+
import oracle.weblogic.deploy.tool.archive_helper.ArchiveHelperException;
912
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
13+
import oracle.weblogic.deploy.util.ExitCode;
14+
import oracle.weblogic.deploy.util.StringUtils;
15+
import oracle.weblogic.deploy.util.WLSDeployArchiveIOException;
1016
import picocli.CommandLine.Command;
1117
import picocli.CommandLine.Option;
1218

@@ -29,12 +35,44 @@ public class ListCustomCommand extends ListTypeCommandBase {
2935
)
3036
private String name;
3137

38+
@Option(
39+
names = {"-use_non_replicable_location"},
40+
description = "List the contents of the wlsdeploy/custom location instead of the default config/wlsdeploy/custom location"
41+
)
42+
private boolean useNonReplicableLocation;
43+
3244
@Override
3345
public CommandResponse call() throws Exception {
3446
final String METHOD = "call";
3547
LOGGER.entering(CLASS, METHOD);
3648

37-
CommandResponse response = listType(CUSTOM, "custom file or directory", name);
49+
CommandResponse response;
50+
boolean hasName = !StringUtils.isEmpty(this.name);
51+
try {
52+
initializeOptions(true);
53+
54+
List<String> archiveEntries;
55+
if (hasName) {
56+
archiveEntries = this.archive.listCustomEntries(name, useNonReplicableLocation);
57+
} else {
58+
archiveEntries = this.archive.listCustomEntries(useNonReplicableLocation);
59+
}
60+
response = new CommandResponse(ExitCode.OK);
61+
response.addMessages(archiveEntries);
62+
} catch (ArchiveHelperException ex) {
63+
LOGGER.severe(ex.getLocalizedMessage(), ex);
64+
response = new CommandResponse(ex.getExitCode(), ex.getLocalizedMessage());
65+
} catch (WLSDeployArchiveIOException | IllegalArgumentException ex) {
66+
if (hasName) {
67+
LOGGER.severe("WLSDPLY-30005", ex, CUSTOM, name, archiveFilePath, ex.getLocalizedMessage());
68+
response = new CommandResponse(ExitCode.ERROR, "WLSDPLY-30005", CUSTOM, name,
69+
this.archiveFilePath, ex.getLocalizedMessage());
70+
} else {
71+
LOGGER.severe("WLSDPLY-30006", ex, CUSTOM, this.archiveFilePath, ex.getLocalizedMessage());
72+
response = new CommandResponse(ExitCode.ERROR, "WLSDPLY-30006", CUSTOM, this.archiveFilePath,
73+
ex.getLocalizedMessage());
74+
}
75+
}
3876

3977
LOGGER.exiting(CLASS, METHOD, response);
4078
return response;

core/src/main/java/oracle/weblogic/deploy/tool/archive_helper/remove/RemoveCustomCommand.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public class RemoveCustomCommand extends RemoveTypeCommandBase {
3232
)
3333
private String name;
3434

35+
@Option(
36+
names = {"-use_non_replicable_location"},
37+
description = "List the contents of the wlsdeploy/custom location instead of the default config/wlsdeploy/custom location"
38+
)
39+
private boolean useNonReplicableLocation;
40+
3541
@Override
3642
public CommandResponse call() throws Exception {
3743
final String METHOD = "call";
@@ -43,9 +49,9 @@ public CommandResponse call() throws Exception {
4349

4450
int entriesRemoved;
4551
if (this.force) {
46-
entriesRemoved = this.archive.removeCustomEntry(name, true);
52+
entriesRemoved = this.archive.removeCustomEntry(name, useNonReplicableLocation, true);
4753
} else {
48-
entriesRemoved = this.archive.removeCustomEntry(name);
54+
entriesRemoved = this.archive.removeCustomEntry(name, useNonReplicableLocation);
4955
}
5056
response = new CommandResponse(ExitCode.OK, "WLSDPLY-30026", TYPE, this.name,
5157
entriesRemoved, this.archiveFilePath);

0 commit comments

Comments
 (0)