@@ -2993,7 +2993,7 @@ public int removeScript(String scriptPath, boolean silent) throws WLSDeployArchi
2993
2993
* @param keystoreFile the file to add
2994
2994
* @return the new location of the file to use in the model
2995
2995
* @throws WLSDeployArchiveIOException if an error occurs while archiving the file
2996
- * @throws IllegalArgumentException if the file does not exist or the clusterName is empty or null
2996
+ * @throws IllegalArgumentException if the file does not exist or the serverTemplateName is empty or null
2997
2997
*/
2998
2998
public String addServerKeyStoreFile (String serverName , String keystoreFile ) throws WLSDeployArchiveIOException {
2999
2999
final String METHOD = "addServerKeyStoreFile" ;
@@ -3147,6 +3147,175 @@ public int removeServerKeystore(String serverName, String keystoreName, boolean
3147
3147
return result ;
3148
3148
}
3149
3149
3150
+ ///////////////////////////////////////////////////////////////////////////////////////////////
3151
+ // server template keystore methods //
3152
+ ///////////////////////////////////////////////////////////////////////////////////////////////
3153
+
3154
+ /**
3155
+ * Add a Server template keystore file to the server's directory in the archive.
3156
+ *
3157
+ * @param serverTemplateName the Server name used to segregate the directories
3158
+ * @param keystoreFile the file to add
3159
+ * @return the new location of the file to use in the model
3160
+ * @throws WLSDeployArchiveIOException if an error occurs while archiving the file
3161
+ * @throws IllegalArgumentException if the file does not exist or the serverTemplateName
3162
+ * is empty or null
3163
+ */
3164
+ public String addServerTemplateKeyStoreFile (String serverTemplateName , String keystoreFile )
3165
+ throws WLSDeployArchiveIOException {
3166
+ final String METHOD = "addServerTemplateKeyStoreFile" ;
3167
+ LOGGER .entering (CLASS , METHOD , serverTemplateName , keystoreFile );
3168
+
3169
+ File filePath = new File (keystoreFile );
3170
+ validateNonEmptyString (serverTemplateName , "serverTemplateName" , METHOD );
3171
+ validateExistingFile (filePath , "keyStoreFile" , getArchiveFileName (), METHOD );
3172
+
3173
+ String newName =
3174
+ addItemToZip (ARCHIVE_SERVER_TEMPLATE_TARGET_DIR + ZIP_SEP + serverTemplateName , filePath );
3175
+
3176
+ LOGGER .exiting (CLASS , METHOD , newName );
3177
+ return newName ;
3178
+ }
3179
+
3180
+ /**
3181
+ * Replace a Server template keystore in the archive.
3182
+ *
3183
+ * @param serverTemplateName the server template name used to segregate directories, or null if the keystorePath
3184
+ * is includes the server name already (e.g., myserver/keystore.jks or
3185
+ * wlsdeploy/servers/myserver/keystore.jks)
3186
+ * @param keystorePath the keystore name (e.g., keystore.jks) or an archive path
3187
+ * (e.g., mytemplate/keystore.jks or wlsdeploy/serverTemplates/mytemplate/keystore.jks)
3188
+ * @param sourceLocation the file system location of the new keystore file to replace the existing one
3189
+ * @return the archive path of the new server template keystore file
3190
+ * @throws WLSDeployArchiveIOException if an IOException occurred while reading or writing changes
3191
+ * @throws IllegalArgumentException if the file or directory passed in does not exist
3192
+ */
3193
+ public String replaceServerTemplateKeyStoreFile (String serverTemplateName , String keystorePath , String sourceLocation )
3194
+ throws WLSDeployArchiveIOException {
3195
+ final String METHOD = "replaceServerTemplateKeyStoreFile" ;
3196
+ LOGGER .entering (CLASS , METHOD , serverTemplateName , keystorePath , sourceLocation );
3197
+
3198
+ String archivePath = null ;
3199
+ String computedTemplateName = serverTemplateName ;
3200
+ if (keystorePath .startsWith (ARCHIVE_SERVER_TEMPLATE_TARGET_DIR + ZIP_SEP )) {
3201
+ archivePath = keystorePath ;
3202
+ computedTemplateName = getSegregationNameFromSegregatedArchivePath (serverTemplateName , keystorePath );
3203
+ } else if (!StringUtils .isEmpty (serverTemplateName )) {
3204
+ if (keystorePath .startsWith (serverTemplateName + ZIP_SEP )) {
3205
+ archivePath = ARCHIVE_SERVER_TEMPLATE_TARGET_DIR + ZIP_SEP + keystorePath ;
3206
+ } else {
3207
+ archivePath = ARCHIVE_SERVER_TEMPLATE_TARGET_DIR + ZIP_SEP + serverTemplateName + ZIP_SEP + keystorePath ;
3208
+ }
3209
+ }
3210
+
3211
+ if (StringUtils .isEmpty (computedTemplateName )) {
3212
+ WLSDeployArchiveIOException ex =
3213
+ new WLSDeployArchiveIOException ("WLSDPLY-01478" , keystorePath , sourceLocation );
3214
+ LOGGER .throwing (CLASS , METHOD , ex );
3215
+ throw ex ;
3216
+ }
3217
+
3218
+ // If we get here, archivePath should never be null!
3219
+ //
3220
+ getZipFile ().removeZipEntry (archivePath );
3221
+ String newName = addServerTemplateKeyStoreFile (computedTemplateName , sourceLocation );
3222
+
3223
+ LOGGER .exiting (CLASS , METHOD , newName );
3224
+ return newName ;
3225
+ }
3226
+
3227
+ /**
3228
+ * Extract the named server template's keystore file to the domain home location.
3229
+ *
3230
+ * @param serverTemplateName the name of the server template used to segregate the keystore
3231
+ * @param keystoreName the name of the keystore file
3232
+ * @param domainHome the existing directory location to write the file
3233
+ * @throws WLSDeployArchiveIOException if an IOException occurred while reading the archive or writing the file
3234
+ * @throws IllegalArgumentException if the domainHome directory does not exist or
3235
+ * the serverTemplateName or keystoreName is empty
3236
+ */
3237
+ public void extractServerTemplateKeystore (String serverTemplateName , String keystoreName , File domainHome )
3238
+ throws WLSDeployArchiveIOException {
3239
+ final String METHOD = "extractServerTemplateKeystore" ;
3240
+ LOGGER .entering (CLASS , METHOD , serverTemplateName , keystoreName , domainHome );
3241
+
3242
+ validateNonEmptyString (serverTemplateName , "serverTemplateName" , METHOD );
3243
+ validateNonEmptyString (keystoreName , "keystoreName" , METHOD );
3244
+ validateExistingDirectory (domainHome , "domainHome" , getArchiveFileName (), METHOD );
3245
+
3246
+ String archivePath ;
3247
+ if (keystoreName .startsWith (ARCHIVE_SERVER_TEMPLATE_TARGET_DIR + ZIP_SEP )) {
3248
+ archivePath = keystoreName ;
3249
+ } else if (keystoreName .startsWith (serverTemplateName + ZIP_SEP )) {
3250
+ archivePath = ARCHIVE_SERVER_TEMPLATE_TARGET_DIR + ZIP_SEP + keystoreName ;
3251
+ } else {
3252
+ archivePath = ARCHIVE_SERVER_TEMPLATE_TARGET_DIR + ZIP_SEP + serverTemplateName + ZIP_SEP + keystoreName ;
3253
+ }
3254
+
3255
+ extractFileFromZip (archivePath , domainHome );
3256
+
3257
+ LOGGER .exiting (CLASS , METHOD );
3258
+ }
3259
+
3260
+ /**
3261
+ * Remove the named server template's keystore file from the archive file. If this is the only entry
3262
+ * in the archive file directory, the directory entry will also be removed, if present.
3263
+ *
3264
+ * @param serverTemplateName the name of the server used to segregate the keystore
3265
+ * @param keystoreName the name of the keystore file
3266
+ * @return the number of zip entries removed from the archive
3267
+ * @throws WLSDeployArchiveIOException if the server's keystore file is not present or an IOException
3268
+ * occurred while reading the archive or writing the file
3269
+ * @throws IllegalArgumentException if the serverTemplateName or keystoreName is null or empty
3270
+ */
3271
+ public int removeServerTemplateKeystore (String serverTemplateName , String keystoreName )
3272
+ throws WLSDeployArchiveIOException {
3273
+ return removeServerTemplateKeystore (serverTemplateName , keystoreName , false );
3274
+ }
3275
+
3276
+ /**
3277
+ * Remove the named server template's keystore file from the archive file. If this is the only entry
3278
+ * in the archive file directory, the directory entry will also be removed, if present.
3279
+ *
3280
+ * @param serverTemplateName the name of the server used to segregate the keystore
3281
+ * @param keystoreName the name of the keystore file
3282
+ * @param silent If false, a WLSDeployArchiveIOException is thrown is the named item does not exist
3283
+ * @return the number of zip entries removed from the archive
3284
+ * @throws WLSDeployArchiveIOException if the server's keystore file is not present (and silent = false) or
3285
+ * an IOException occurred while reading the archive or writing the file
3286
+ * @throws IllegalArgumentException if the serverTemplateName or keystoreName is null or empty
3287
+ */
3288
+ public int removeServerTemplateKeystore (String serverTemplateName , String keystoreName , boolean silent )
3289
+ throws WLSDeployArchiveIOException {
3290
+ final String METHOD = "removeServerTemplateKeystore" ;
3291
+ LOGGER .entering (CLASS , METHOD , serverTemplateName , keystoreName , silent );
3292
+
3293
+ validateNonEmptyString (serverTemplateName , "serverTemplateName" , METHOD );
3294
+ validateNonEmptyString (keystoreName , "keystoreName" , METHOD );
3295
+
3296
+ String parentDir = ARCHIVE_SERVER_TEMPLATE_TARGET_DIR + ZIP_SEP + serverTemplateName ;
3297
+ String archivePath = parentDir + ZIP_SEP + keystoreName ;
3298
+
3299
+ List <String > zipEntries =
3300
+ getSegregatedArchiveEntries (ArchiveEntryType .SERVER_TEMPLATE_KEYSTORE , serverTemplateName , keystoreName );
3301
+
3302
+ if (!silent && zipEntries .isEmpty ()) {
3303
+ WLSDeployArchiveIOException ex = new WLSDeployArchiveIOException ("WLSDPLY-01479" , serverTemplateName ,
3304
+ keystoreName , getArchiveFileName (), archivePath );
3305
+ LOGGER .throwing (CLASS , METHOD , ex );
3306
+ throw ex ;
3307
+ }
3308
+
3309
+ int result = zipEntries .size ();
3310
+ for (String zipEntry : zipEntries ) {
3311
+ getZipFile ().removeZipEntry (zipEntry );
3312
+ }
3313
+ result += removeEmptyDirs (parentDir );
3314
+
3315
+ LOGGER .exiting (CLASS , METHOD , result );
3316
+ return result ;
3317
+ }
3318
+
3150
3319
///////////////////////////////////////////////////////////////////////////////////////////////
3151
3320
// node manager keystore methods //
3152
3321
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -3400,16 +3569,16 @@ public int removeMimeMappingFile(String mimeMappingPath, boolean silent)
3400
3569
validateNonEmptyString (mimeMappingPath , "mimeMappingPath" , METHOD );
3401
3570
3402
3571
String archivePath ;
3403
- String keystoreName ;
3572
+ String mimeFileName ;
3404
3573
if (mimeMappingPath .startsWith (ARCHIVE_CONFIG_TARGET_DIR + ZIP_SEP )) {
3405
3574
archivePath = mimeMappingPath ;
3406
- keystoreName = getNameFromPath (mimeMappingPath , ARCHIVE_CONFIG_TARGET_DIR .length () + 2 );
3575
+ mimeFileName = getNameFromPath (mimeMappingPath , ARCHIVE_CONFIG_TARGET_DIR .length () + 2 );
3407
3576
} else {
3408
3577
archivePath = ARCHIVE_CONFIG_TARGET_DIR + ZIP_SEP + mimeMappingPath ;
3409
- keystoreName = mimeMappingPath ;
3578
+ mimeFileName = mimeMappingPath ;
3410
3579
}
3411
3580
3412
- List <String > zipEntries = getArchiveEntries (ArchiveEntryType .MIME_MAPPING , keystoreName );
3581
+ List <String > zipEntries = getArchiveEntries (ArchiveEntryType .MIME_MAPPING , mimeFileName );
3413
3582
3414
3583
if (!silent && zipEntries .isEmpty ()) {
3415
3584
WLSDeployArchiveIOException ex = new WLSDeployArchiveIOException ("WLSDPLY-01452" , mimeMappingPath ,
@@ -5572,7 +5741,7 @@ protected static FileOrDirectoryType getFileType(ArchiveEntryType type) {
5572
5741
LOGGER .entering (CLASS , METHOD , type );
5573
5742
5574
5743
FileOrDirectoryType result ;
5575
- switch (type ) {
5744
+ switch (type ) {
5576
5745
case COHERENCE :
5577
5746
case COHERENCE_PERSISTENCE_DIR :
5578
5747
case DB_WALLET :
0 commit comments