Skip to content

Commit b0887fc

Browse files
gosurya-oraclejshum2479
authored andcommitted
do not ask password if useCache set to always
1 parent 6197c2e commit b0887fc

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/main/java/com/oracle/weblogicx/imagebuilder/cli/menu/ImageOperation.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@
3030
import java.util.logging.Level;
3131
import java.util.logging.Logger;
3232
import java.util.logging.SimpleFormatter;
33+
import java.util.regex.Matcher;
34+
import java.util.regex.Pattern;
3335
import java.util.stream.Collectors;
3436
import java.util.stream.Stream;
3537

38+
import static com.oracle.weblogicx.imagebuilder.api.model.CachePolicy.ALWAYS;
3639
import static com.oracle.weblogicx.imagebuilder.util.Constants.BUILD_ARG;
3740
import static com.oracle.weblogicx.imagebuilder.util.Constants.HTTP;
3841
import static com.oracle.weblogicx.imagebuilder.util.Constants.HTTPS;
@@ -57,9 +60,12 @@ public abstract class ImageOperation implements Callable<CommandResponse> {
5760
@Override
5861
public CommandResponse call() throws Exception {
5962
handleProxyUrls();
60-
// check user support credentials if we are applying any patches
61-
if (latestPSU || !patches.isEmpty()) {
62-
password = handlePasswordOptions();
63+
password = handlePasswordOptions();
64+
// check user support credentials if useCache not set to always and we are applying any patches
65+
if (latestPSU || (!patches.isEmpty() && useCache != ALWAYS)) {
66+
if (Utils.isEmptyString(password)) {
67+
return new CommandResponse(-1, "Failed to determine password. use one of the options to input password");
68+
}
6369
if (!ARUUtil.checkCredentials(userId, password)) {
6470
return new CommandResponse(-1, "user Oracle support credentials do not match");
6571
}
@@ -96,11 +102,12 @@ List<String> handlePatchFiles(Path tmpDir, Path tmpPatchesDir) throws Exception
96102
patchLocations.add(psuResolver.resolve(cacheStore));
97103
}
98104
if (patches != null && !patches.isEmpty()) {
105+
Pattern patchIdPattern = Pattern.compile(PATCH_ID_REGEX);
99106
for (String patchId : patches) {
100-
if (patchId.matches(PATCH_ID_REGEX)) {
101-
patchId = patchId.substring(1);
102-
patchLocations.add(new PatchFile(useCache, installerType.toString(), installerVersion, patchId, userId,
103-
password).resolve(cacheStore));
107+
Matcher matcher = patchIdPattern.matcher(patchId);
108+
if (matcher.matches() && matcher.groupCount() > 0) {
109+
patchLocations.add(new PatchFile(useCache, installerType.toString(), installerVersion,
110+
matcher.group(1), userId, password).resolve(cacheStore));
104111
} else {
105112
logger.severe("Ignoring invalid patch id format: " + patchId);
106113
}

src/main/java/com/oracle/weblogicx/imagebuilder/impl/PatchFile.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.io.IOException;
1414
import java.util.Collections;
1515
import java.util.List;
16-
import java.util.Objects;
1716
import java.util.logging.Logger;
1817

1918
import static com.oracle.weblogicx.imagebuilder.api.meta.CacheStore.CACHE_KEY_SEPARATOR;
@@ -28,10 +27,6 @@ public class PatchFile extends AbstractFile {
2827

2928
public PatchFile(CachePolicy cachePolicy, String category, String version, String patchId, String userId, String password) {
3029
super(null, cachePolicy, userId, password);
31-
// if (cachePolicy != ALWAYS) {
32-
// Objects.requireNonNull(userId, "userId cannot be null");
33-
// Objects.requireNonNull(password, "password cannot be null");
34-
// }
3530
this.category = category;
3631
this.version = version;
3732
this.patchId = patchId;

src/main/java/com/oracle/weblogicx/imagebuilder/util/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public final class Constants {
4040
public static final String CACHE_STORE_TYPE = "cacheStoreType";
4141
public static final String HTTP = "http";
4242
public static final String HTTPS = "https";
43-
public static final String PATCH_ID_REGEX = "^[pP]\\d+";
43+
public static final String PATCH_ID_REGEX = "^[pP]?(\\d+)";
4444

4545
private Constants() {
4646
//restrict access

src/main/java/com/oracle/weblogicx/imagebuilder/util/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,6 @@ public static String getPasswordFromInputs(String passwordStr, Path passwordFile
531531
} else if (!isEmptyString(passwordEnv) && !isEmptyString(System.getenv(passwordEnv))) {
532532
return System.getenv(passwordEnv);
533533
}
534-
throw new IOException("Failed to determine password. use one of the options to input password");
534+
return null;
535535
}
536536
}

0 commit comments

Comments
 (0)