Skip to content

Commit 56b74f4

Browse files
committed
Merge branch 'jira-wdt-939-archive-helper' into 'main'
Archive helper changes for plugin deployment See merge request weblogic-cloud/weblogic-deploy-tooling!1821
2 parents 59cc9ff + c485422 commit 56b74f4

17 files changed

+896
-108
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
AddMIMEMappingCommand.class,
2828
AddNodeManagerKeystoreCommand.class,
2929
AddOPSSWalletCommand.class,
30+
AddPluginDeploymentCommand.class,
3031
AddRCUWalletCommand.class,
3132
AddSaml2InitializationDataCommand.class,
3233
AddScriptCommand.class,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.tool.archive_helper.add;
6+
7+
import oracle.weblogic.deploy.logging.PlatformLogger;
8+
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
9+
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
10+
import picocli.CommandLine.Command;
11+
import picocli.CommandLine.Option;
12+
13+
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
14+
import static oracle.weblogic.deploy.util.WLSDeployArchive.ArchiveEntryType.PLUGIN_DEPLOYMENT;
15+
16+
@Command(
17+
name = "pluginDeployment",
18+
header = "Add plugin deployment to the archive file.",
19+
description = "%nCommand-line options:"
20+
)
21+
public class AddPluginDeploymentCommand extends AddTypeCommandBase {
22+
private static final String CLASS = AddPluginDeploymentCommand.class.getName();
23+
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger(LOGGER_NAME);
24+
private static final String TYPE = "plugin deployment";
25+
26+
@Option(
27+
names = {"-source"},
28+
paramLabel = "<path>",
29+
description = "File system path to the plugin deployment to add",
30+
required = true
31+
)
32+
private String sourcePath;
33+
34+
@Override
35+
public CommandResponse call() throws Exception {
36+
final String METHOD = "call";
37+
LOGGER.entering(CLASS, METHOD);
38+
39+
CommandResponse response = addType(PLUGIN_DEPLOYMENT, TYPE, this.sourcePath);
40+
41+
LOGGER.exiting(CLASS, METHOD, response);
42+
return response;
43+
}
44+
}

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.tool.archive_helper.add;
@@ -13,8 +13,11 @@
1313
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
1414
import oracle.weblogic.deploy.util.ExitCode;
1515
import oracle.weblogic.deploy.util.FileUtils;
16+
import oracle.weblogic.deploy.util.WLSDeployArchive.ArchiveEntryType;
17+
import oracle.weblogic.deploy.util.WLSDeployArchiveIOException;
1618

1719
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
20+
import static oracle.weblogic.deploy.util.WLSDeployArchive.ArchiveEntryType.PLUGIN_DEPLOYMENT;
1821

1922
public abstract class AddTypeCommandBase extends AddOptions implements Callable<CommandResponse> {
2023
private static final String CLASS = AddTypeCommandBase.class.getName();
@@ -31,6 +34,45 @@ protected File initializeOptions(String sourcePath) throws ArchiveHelperExceptio
3134
return result;
3235
}
3336

37+
/**
38+
* Add a non-segregated file or directory to the archive.
39+
* @param archiveType the archive entry type
40+
* @param typeName readable type name for logging
41+
* @param sourcePath location of the file or directory to be added
42+
* @return command response
43+
*/
44+
protected CommandResponse addType(ArchiveEntryType archiveType, String typeName, String sourcePath) {
45+
final String METHOD = "addType";
46+
LOGGER.entering(CLASS, archiveType);
47+
48+
CommandResponse response;
49+
File sourceFile;
50+
try {
51+
sourceFile = initializeOptions(sourcePath);
52+
53+
String resultName;
54+
if (this.overwrite) {
55+
resultName = this.archive.replaceItem(PLUGIN_DEPLOYMENT, sourceFile.getName(), sourceFile.getPath());
56+
} else {
57+
resultName = this.archive.addItem(PLUGIN_DEPLOYMENT, sourceFile.getPath());
58+
}
59+
response = new CommandResponse(ExitCode.OK, resultName);
60+
} catch (ArchiveHelperException ex) {
61+
LOGGER.severe("WLSDPLY-30010", ex, typeName, sourcePath,
62+
this.archiveFilePath, ex.getLocalizedMessage());
63+
response = new CommandResponse(ex.getExitCode(), "WLSDPLY-30010", typeName,
64+
sourcePath, this.archiveFilePath, ex.getLocalizedMessage());
65+
} catch (WLSDeployArchiveIOException | IllegalArgumentException ex) {
66+
LOGGER.severe("WLSDPLY-30011", ex, typeName, sourcePath,
67+
this.overwrite, this.archiveFilePath, ex.getLocalizedMessage());
68+
response = new CommandResponse(ExitCode.ERROR, "WLSDPLY-30011", typeName,
69+
sourcePath, this.overwrite, this.archiveFilePath, ex.getLocalizedMessage());
70+
}
71+
72+
LOGGER.exiting(CLASS, METHOD, response);
73+
return response;
74+
}
75+
3476
private File getSourceLocationFile(String path) throws ArchiveHelperException {
3577
final String METHOD = "getSourceLocationFile";
3678
LOGGER.entering(CLASS, METHOD, path);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
ExtractMIMEMappingCommand.class,
2929
ExtractNodeManagerKeystoreCommand.class,
3030
ExtractOPSSWalletCommand.class,
31+
ExtractPluginDeploymentCommand.class,
3132
ExtractRCUWalletCommand.class,
3233
ExtractSaml2InitializationDataCommand.class,
3334
ExtractScriptCommand.class,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.tool.archive_helper.extract;
6+
7+
import oracle.weblogic.deploy.logging.PlatformLogger;
8+
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
9+
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
10+
import picocli.CommandLine.Command;
11+
import picocli.CommandLine.Option;
12+
13+
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
14+
import static oracle.weblogic.deploy.util.WLSDeployArchive.ArchiveEntryType.PLUGIN_DEPLOYMENT;
15+
16+
@Command(
17+
name = "pluginDeployment",
18+
header = "Extract plugin deployment from the archive file.",
19+
description = "%nCommand-line options:"
20+
)
21+
public class ExtractPluginDeploymentCommand extends ExtractTypeCommandBase {
22+
private static final String CLASS = ExtractPluginDeploymentCommand.class.getName();
23+
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger(LOGGER_NAME);
24+
private static final String TYPE = "plugin deployment";
25+
26+
@Option(
27+
names = {"-name"},
28+
description = "Name of the plugin deployment to be extracted from the archive file",
29+
required = true
30+
)
31+
private String name;
32+
33+
34+
@Override
35+
public CommandResponse call() throws Exception {
36+
final String METHOD = "call";
37+
LOGGER.entering(CLASS, METHOD);
38+
39+
CommandResponse response = extractType(PLUGIN_DEPLOYMENT, TYPE, name);
40+
41+
LOGGER.exiting(CLASS, METHOD, response);
42+
return response;
43+
}
44+
}
Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,57 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.tool.archive_helper.extract;
66

77
import java.util.concurrent.Callable;
88

9+
import oracle.weblogic.deploy.logging.PlatformLogger;
10+
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.WLSDeployArchive;
15+
import oracle.weblogic.deploy.util.WLSDeployArchiveIOException;
16+
17+
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
1018

1119
public abstract class ExtractTypeCommandBase extends ExtractOptions implements Callable<CommandResponse> {
20+
private static final String CLASS = ExtractTypeCommandBase.class.getName();
21+
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger(LOGGER_NAME);
22+
private static final String ERROR_KEY = "WLSDPLY-30047";
23+
24+
/**
25+
* Extract a non-segregated file or directory from the archive.
26+
* @param archiveType the archive entry type
27+
* @param typeName readable type name for logging
28+
* @param name the name or archive path of entry to be extracted
29+
* @return command response
30+
*/
31+
public CommandResponse extractType(WLSDeployArchive.ArchiveEntryType archiveType, String typeName, String name) {
32+
final String METHOD = "extractType";
33+
LOGGER.entering(CLASS, METHOD, archiveType, typeName, name);
34+
35+
CommandResponse response;
36+
try {
37+
initializeOptions();
38+
39+
this.archive.extractItem(archiveType, name, this.targetDirectory);
40+
response = new CommandResponse(ExitCode.OK, "WLSDPLY-30046", typeName, name,
41+
this.archiveFilePath, this.targetDirectory.getPath());
42+
} catch (ArchiveHelperException ex) {
43+
LOGGER.severe(ERROR_KEY, ex, typeName, name, this.archiveFilePath,
44+
this.targetDirectory.getPath(), ex.getLocalizedMessage());
45+
response = new CommandResponse(ex.getExitCode(), ERROR_KEY, typeName, name,
46+
this.archiveFilePath, this.targetDirectory.getPath(), ex.getLocalizedMessage());
47+
} catch (WLSDeployArchiveIOException | IllegalArgumentException ex) {
48+
LOGGER.severe(ERROR_KEY, ex, typeName, name, this.archiveFilePath,
49+
this.targetDirectory.getPath(), ex.getLocalizedMessage());
50+
response = new CommandResponse(ExitCode.ERROR, ERROR_KEY, typeName, name,
51+
this.archiveFilePath, this.targetDirectory.getPath(), ex.getLocalizedMessage());
52+
}
53+
54+
LOGGER.exiting(CLASS, METHOD, response);
55+
return response;
56+
}
1257
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
ListMIMEMappingCommand.class,
2727
ListNodeManagerKeystoreCommand.class,
2828
ListOPSSWalletCommand.class,
29+
ListPluginDeploymentCommand.class,
2930
ListRCUWalletCommand.class,
3031
ListSaml2InitializationDataCommand.class,
3132
ListScriptCommand.class,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.tool.archive_helper.list;
6+
7+
import oracle.weblogic.deploy.logging.PlatformLogger;
8+
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
9+
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
10+
import picocli.CommandLine.Command;
11+
import picocli.CommandLine.Option;
12+
13+
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
14+
import static oracle.weblogic.deploy.util.WLSDeployArchive.ArchiveEntryType.PLUGIN_DEPLOYMENT;
15+
16+
@Command(
17+
name = "pluginDeployment",
18+
header = "List plugin deployment entries in the archive file.",
19+
description = "%nCommand-line options:"
20+
)
21+
public class ListPluginDeploymentCommand extends ListTypeCommandBase {
22+
private static final String CLASS = ListPluginDeploymentCommand.class.getName();
23+
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger(LOGGER_NAME);
24+
25+
@Option(
26+
names = { "-name" },
27+
paramLabel = "<name>",
28+
description = "Name of the plugin deployment to list"
29+
)
30+
private String name;
31+
32+
@Override
33+
public CommandResponse call() throws Exception {
34+
final String METHOD = "call";
35+
LOGGER.entering(CLASS, METHOD);
36+
37+
CommandResponse response = listType(PLUGIN_DEPLOYMENT, "plugin deployment", name);
38+
39+
LOGGER.exiting(CLASS, METHOD, response);
40+
return response;
41+
}
42+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
RemoveMIMEMappingCommand.class,
2828
RemoveNodeManagerKeystoreCommand.class,
2929
RemoveOPSSWalletCommand.class,
30+
RemovePluginDeploymentCommand.class,
3031
RemoveRCUWalletCommand.class,
3132
RemoveSaml2InitializationDataCommand.class,
3233
RemoveScriptCommand.class,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.tool.archive_helper.remove;
6+
7+
import oracle.weblogic.deploy.logging.PlatformLogger;
8+
import oracle.weblogic.deploy.logging.WLSDeployLogFactory;
9+
import oracle.weblogic.deploy.tool.archive_helper.CommandResponse;
10+
import picocli.CommandLine.Command;
11+
import picocli.CommandLine.Option;
12+
13+
import static oracle.weblogic.deploy.tool.ArchiveHelper.LOGGER_NAME;
14+
import static oracle.weblogic.deploy.util.WLSDeployArchive.ArchiveEntryType.PLUGIN_DEPLOYMENT;
15+
16+
@Command(
17+
name = "pluginDeployment",
18+
header = "Remove plugin deployment from the archive file.",
19+
description = "%nCommand-line options:"
20+
)
21+
public class RemovePluginDeploymentCommand extends RemoveTypeCommandBase {
22+
private static final String CLASS = RemovePluginDeploymentCommand.class.getName();
23+
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger(LOGGER_NAME);
24+
private static final String TYPE = "plugin deployment";
25+
26+
@Option(
27+
names = {"-name"},
28+
description = "Name of the plugin deployment to be removed from the archive file",
29+
required = true
30+
)
31+
private String name;
32+
33+
@Override
34+
public CommandResponse call() throws Exception {
35+
final String METHOD = "call";
36+
LOGGER.entering(CLASS, METHOD);
37+
38+
CommandResponse response = removeType(PLUGIN_DEPLOYMENT, TYPE, name);
39+
40+
LOGGER.exiting(CLASS, METHOD, response);
41+
return response;
42+
}
43+
}

0 commit comments

Comments
 (0)