@@ -125,6 +125,12 @@ public class WLSDeployArchive {
125
125
*/
126
126
public static final String ARCHIVE_SHLIBS_TARGET_DIR = WLSDPLY_ARCHIVE_BINARY_DIR + ZIP_SEP + "sharedLibraries" ;
127
127
128
+ /**
129
+ * Top-level archive subdirectory where the plugins are stored and the subdirectory to
130
+ * which they will be extracted.
131
+ */
132
+ public static final String ARCHIVE_PLUGINS_TARGET_DIR = WLSDPLY_ARCHIVE_BINARY_DIR + ZIP_SEP + "pluginDeployments" ;
133
+
128
134
/**
129
135
* Top-level archive subdirectory where the $DOMAIN_HOME/lib are stored.
130
136
*/
@@ -212,6 +218,7 @@ public enum ArchiveEntryType {
212
218
MIME_MAPPING ,
213
219
NODE_MANAGER_KEY_STORE ,
214
220
OPSS_WALLET ,
221
+ PLUGIN_DEPLOYMENT ,
215
222
RCU_WALLET ,
216
223
SAML2_DATA ,
217
224
SCRIPT ,
@@ -340,6 +347,10 @@ public static String getPathForType(ArchiveEntryType type) {
340
347
pathPrefix = ARCHIVE_SHLIBS_TARGET_DIR + ZIP_SEP ;
341
348
break ;
342
349
350
+ case PLUGIN_DEPLOYMENT :
351
+ pathPrefix = ARCHIVE_PLUGINS_TARGET_DIR + ZIP_SEP ;
352
+ break ;
353
+
343
354
case STRUCTURED_APPLICATION :
344
355
pathPrefix = ARCHIVE_STRUCT_APPS_TARGET_DIR + ZIP_SEP ;
345
356
break ;
@@ -1052,6 +1063,152 @@ public void close() {
1052
1063
// methods using archiveType //
1053
1064
///////////////////////////////////////////////////////////////////////////////////////////////
1054
1065
1066
+ /**
1067
+ * Get the path of the archive entry as if it is in the archive file.
1068
+ * This does not reconcile duplicate names and other items that require the archive file
1069
+ * and is only used with discoverDomain -remote to give the user an archive path.
1070
+ * @param archiveType the type of the entry
1071
+ * @param path the original path of the entry
1072
+ * @return name for model archive file name
1073
+ */
1074
+ public static String getArchivePath (ArchiveEntryType archiveType , String path ) {
1075
+ String pathPrefix = getPathForType (archiveType );
1076
+ return getArchiveName (pathPrefix , path );
1077
+ }
1078
+
1079
+ public String addItem (ArchiveEntryType archiveType , String sourcePath ) throws WLSDeployArchiveIOException {
1080
+ final String METHOD = "addItem" ;
1081
+ LOGGER .entering (CLASS , METHOD , archiveType , sourcePath );
1082
+
1083
+ File filePath = FileUtils .getCanonicalFile (sourcePath );
1084
+ validateExistingFile (filePath , "path" , getArchiveFileName (), METHOD , true );
1085
+
1086
+ String pathPrefix = getPathForType (archiveType );
1087
+ String newName = addItemToZip (pathPrefix , filePath );
1088
+
1089
+ LOGGER .exiting (CLASS , METHOD , newName );
1090
+ return newName ;
1091
+ }
1092
+
1093
+ public String replaceItem (ArchiveEntryType archiveType , String archiveName , String sourcePath )
1094
+ throws WLSDeployArchiveIOException {
1095
+
1096
+ final String METHOD = "replaceItem" ;
1097
+ LOGGER .entering (CLASS , METHOD , archiveType , archiveName , sourcePath );
1098
+
1099
+ String pathPrefix = getPathForType (archiveType );
1100
+ String archivePath ;
1101
+ if (archiveName .startsWith (pathPrefix )) {
1102
+ archivePath = archiveName ;
1103
+ } else {
1104
+ archivePath = pathPrefix + archiveName ;
1105
+ }
1106
+
1107
+ getZipFile ().removeZipEntries (archivePath );
1108
+ String newName = addItem (archiveType , sourcePath );
1109
+
1110
+ LOGGER .exiting (CLASS , METHOD , newName );
1111
+ return newName ;
1112
+ }
1113
+
1114
+ /**
1115
+ * Extracts the named file or directory from the archive into the specified directory,
1116
+ * preserving any archive directory structure.
1117
+ *
1118
+ * @param archiveType the type of the entry
1119
+ * @param path the path of the file or directory in the archive
1120
+ * @param directory the existing target directory (usually domain home)
1121
+ * @throws WLSDeployArchiveIOException if an IOException occurred while reading the archive or writing the file
1122
+ * @throws IllegalArgumentException if the directory does not exist or the path is empty
1123
+ */
1124
+ public void extractItem (ArchiveEntryType archiveType , String path , File directory )
1125
+ throws WLSDeployArchiveIOException {
1126
+
1127
+ final String METHOD = "extractItem" ;
1128
+ LOGGER .entering (CLASS , METHOD , archiveType , path );
1129
+
1130
+ validateNonEmptyString (path , "path" , METHOD );
1131
+ validateExistingDirectory (directory , "directory" , getArchiveFileName (), METHOD );
1132
+
1133
+ String pathPrefix = getPathForType (archiveType );
1134
+ String archivePath = path ;
1135
+ if (!path .startsWith (pathPrefix )) {
1136
+ archivePath = pathPrefix + path ;
1137
+ }
1138
+
1139
+ archivePath = fixupPathForDirectories (archivePath );
1140
+ if (archivePath .endsWith (ZIP_SEP )) {
1141
+ extractDirectoryFromZip (archivePath , directory );
1142
+ } else {
1143
+ extractFileFromZip (archivePath , directory );
1144
+ }
1145
+
1146
+ LOGGER .exiting (CLASS , METHOD );
1147
+ }
1148
+
1149
+ /**
1150
+ * Remove the named item from the archive file. If this is the only entry
1151
+ * in the archive file directory, the directory entry will also be removed, if present.
1152
+ *
1153
+ * @param path The item name (e.g., foo.jar) or the archive path
1154
+ * to it (e.g., wlsdeploy/domainLibraries/foo.jar)
1155
+ * @return the number of zip entries removed from the archive
1156
+ * @throws WLSDeployArchiveIOException if the item is not present or an IOException occurred while
1157
+ * reading the archive or writing the file
1158
+ * @throws IllegalArgumentException if the path is null or empty
1159
+ */
1160
+ public int removeItem (ArchiveEntryType archiveType , String path ) throws WLSDeployArchiveIOException {
1161
+ return removeItem (archiveType , path , false );
1162
+ }
1163
+
1164
+ /**
1165
+ * Remove the named item from the archive file. If this is the only entry
1166
+ * in the archive file directory, the directory entry will also be removed, if present.
1167
+ *
1168
+ * @param path The item name (e.g., foo.jar) or the archive path
1169
+ * to it (e.g., wlsdeploy/domainLibraries/foo.jar)
1170
+ * @param silent If false, a WLSDeployArchiveIOException is thrown if the named item does not exist
1171
+ * @return the number of zip entries removed from the archive
1172
+ * @throws WLSDeployArchiveIOException if the item is not present (and silent = false) or an IOException
1173
+ * occurred while reading the archive or writing the file
1174
+ * @throws IllegalArgumentException if the path is null or empty
1175
+ */
1176
+ public int removeItem (ArchiveEntryType archiveType , String path , boolean silent ) throws WLSDeployArchiveIOException {
1177
+ final String METHOD = "removeItem" ;
1178
+ LOGGER .entering (CLASS , METHOD , path , silent );
1179
+
1180
+ validateNonEmptyString (path , "path" , METHOD );
1181
+
1182
+ String pathPrefix = getPathForType (archiveType );
1183
+ String archivePath ;
1184
+ String itemName ;
1185
+ if (path .startsWith (pathPrefix )) {
1186
+ archivePath = path ;
1187
+ itemName = getNameFromPath (archivePath , pathPrefix .length () + 1 );
1188
+ } else {
1189
+ archivePath = pathPrefix + path ;
1190
+ itemName = path ;
1191
+ }
1192
+
1193
+ List <String > zipEntries = getArchiveEntries (archiveType , itemName );
1194
+
1195
+ if (!silent && zipEntries .isEmpty ()) {
1196
+ WLSDeployArchiveIOException ex =
1197
+ new WLSDeployArchiveIOException ("WLSDPLY-01480" , archiveType , itemName , getArchiveFileName (), archivePath );
1198
+ LOGGER .throwing (CLASS , METHOD , ex );
1199
+ throw ex ;
1200
+ }
1201
+
1202
+ int result = zipEntries .size ();
1203
+ for (String zipEntry : zipEntries ) {
1204
+ getZipFile ().removeZipEntry (zipEntry );
1205
+ }
1206
+ result += removeEmptyTypeDir (archiveType , pathPrefix );
1207
+
1208
+ LOGGER .exiting (CLASS , METHOD , result );
1209
+ return result ;
1210
+ }
1211
+
1055
1212
/**
1056
1213
* Add a source file for the specified archive type, including an entry name.
1057
1214
* Example: config/wlsdeploy/servers/myServer/identity.jks
0 commit comments