Skip to content

Commit 2f99236

Browse files
authored
Use versioned names for apps and libraries when planning and deploying (#742)
* JIRA WDT-482 - Examine manifest within archive zip for deploy strategy * JIRA WDT-482 - Use versioned names for apps and libraries when building strategies and deploying
1 parent a4c7585 commit 2f99236

File tree

5 files changed

+275
-170
lines changed

5 files changed

+275
-170
lines changed

core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
import java.security.NoSuchAlgorithmException;
1515
import java.util.List;
1616
import java.util.Map;
17+
import java.util.jar.JarFile;
18+
import java.util.jar.Manifest;
19+
import java.util.zip.ZipEntry;
20+
import java.util.zip.ZipInputStream;
1721

1822
import oracle.weblogic.deploy.exception.ExceptionHelper;
1923
import oracle.weblogic.deploy.logging.PlatformLogger;
@@ -1083,6 +1087,48 @@ public String addNodeManagerKeyStoreFile(File keystoreFile) throws WLSDeployArch
10831087
return newName;
10841088
}
10851089

1090+
/**
1091+
* Return the manifest for the specified path in the archive, if present.
1092+
* The path may refer to a packaged EAR/JAR/WAR, or an exploded entry.
1093+
* @param sourcePath the path to be checked
1094+
* @return the Manifest object, or null
1095+
* @throws WLSDeployArchiveIOException if there is a problem reading the archive, or the manifest
1096+
*/
1097+
public Manifest getManifest(String sourcePath) throws WLSDeployArchiveIOException {
1098+
try {
1099+
if(containsFile(sourcePath)) {
1100+
// a jarred app or library in the archive.
1101+
try(ZipInputStream zipStream = new ZipInputStream(getZipFile().getZipEntry(sourcePath))) {
1102+
// JarInputStream.getManifest() has problems if MANIFEST.MF is not the first entry,
1103+
// so use ZipInputStream and search for the specific entry.
1104+
ZipEntry zipEntry;
1105+
while((zipEntry = zipStream.getNextEntry()) != null) {
1106+
if(JarFile.MANIFEST_NAME.equals(zipEntry.getName())) {
1107+
Manifest manifest = new Manifest(zipStream);
1108+
zipStream.closeEntry();
1109+
return manifest;
1110+
}
1111+
zipStream.closeEntry();
1112+
}
1113+
}
1114+
} else if(containsPath(sourcePath)) {
1115+
// an exploded app or library in the archive.
1116+
String manifestPath = sourcePath + "/" + JarFile.MANIFEST_NAME;
1117+
if (containsFile(manifestPath)) {
1118+
try (InputStream inStream = getZipFile().getZipEntry(manifestPath)) {
1119+
return new Manifest(inStream);
1120+
}
1121+
}
1122+
}
1123+
} catch(IOException e) {
1124+
WLSDeployArchiveIOException aioe = new WLSDeployArchiveIOException("WLSDPLY-01426", sourcePath,
1125+
getArchiveFileName(), e.getLocalizedMessage());
1126+
LOGGER.throwing(aioe);
1127+
throw aioe;
1128+
}
1129+
return null;
1130+
}
1131+
10861132
/**
10871133
* This method removes all binaries from the archive. This method is intended to
10881134
* be invoked by discovery to remove binaries from a previous run that might

0 commit comments

Comments
 (0)