Skip to content

Commit e980019

Browse files
authored
Allow FMW installers (#114)
1 parent b4536b6 commit e980019

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+733
-587
lines changed

build-tools/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.oracle.weblogic.lifecycle</groupId>
88
<artifactId>build-tools</artifactId>
9-
<version>1.1</version>
9+
<version>1.2</version>
1010
<name>Build Tools</name>
1111

1212
</project>

build-tools/src/main/resources/weblogic-image-tool/checkstyle/customized_google_checks.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
5252
</module>
5353
<module name="AvoidStarImport"/>
54+
<module name="UnusedImports"/>
5455
<module name="OneTopLevelClass"/>
5556
<module name="NoLineWrap"/>
5657
<module name="EmptyBlock">

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/FileResolver.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/model/AbstractFile.java

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package com.oracle.weblogic.imagetool.api.model;
5+
6+
import java.io.File;
7+
import java.io.FileNotFoundException;
8+
import java.io.IOException;
9+
import java.nio.file.Files;
10+
import java.nio.file.Path;
11+
import java.nio.file.Paths;
12+
13+
import com.oracle.weblogic.imagetool.cachestore.CacheStore;
14+
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
15+
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
16+
import com.oracle.weblogic.imagetool.util.Utils;
17+
18+
/**
19+
* Base class to represent either an installer or a patch file.
20+
*/
21+
public class CachedFile {
22+
23+
private static final LoggingFacade logger = LoggingFactory.getLogger(CachedFile.class);
24+
25+
private String key;
26+
27+
/**
28+
* Represents a locally cached file.
29+
*
30+
* @param id cache ID (like installer type or patchId)
31+
* @param version version number for the patch or installer.
32+
*/
33+
public CachedFile(String id, String version) {
34+
key = generateKey(id, version);
35+
}
36+
37+
/**
38+
* Represents a locally cached file.
39+
*
40+
* @param id cache ID (like installer type)
41+
* @param version version number for the patch or installer.
42+
*/
43+
public CachedFile(InstallerType id, String version) {
44+
this(id.toString(), version);
45+
}
46+
47+
public static boolean isFileOnDisk(String filePath) {
48+
return filePath != null && Files.isRegularFile(Paths.get(filePath));
49+
}
50+
51+
private String generateKey(String id, String version) {
52+
53+
logger.entering(id, version);
54+
String mykey = id;
55+
if (id == null) { // should never happens
56+
mykey = id + CacheStore.CACHE_KEY_SEPARATOR + version;
57+
} else if (id.indexOf('_') < 0) {
58+
if (version != null) {
59+
mykey = mykey + CacheStore.CACHE_KEY_SEPARATOR + version;
60+
}
61+
}
62+
63+
logger.exiting(mykey);
64+
return mykey;
65+
}
66+
67+
public String getKey() {
68+
return key;
69+
}
70+
71+
/**
72+
* Get the path of the file stored locally in the cache.
73+
* @param cacheStore the cache store to search
74+
* @return the Path of the file, if found
75+
* @throws IOException throws FileNotFoundException, if this cached file (key) could not be located in the cache
76+
*/
77+
public String resolve(CacheStore cacheStore) throws IOException {
78+
// check entry exists in cache
79+
String key = getKey();
80+
logger.entering(key);
81+
String filePath = cacheStore.getValueFromCache(key);
82+
if (!isFileOnDisk(filePath)) {
83+
throw new FileNotFoundException(Utils.getMessage("IMG-0011", key));
84+
}
85+
86+
logger.exiting(filePath);
87+
return filePath;
88+
}
89+
90+
/**
91+
* Copy file from cacheStore to Docker build context directory.
92+
* @param cacheStore cache to copy file from
93+
* @param buildContextDir directory to copy file to
94+
* @return the path of the file copied to the Docker build context directory
95+
*/
96+
public Path copyFile(CacheStore cacheStore, String buildContextDir) throws IOException {
97+
logger.entering();
98+
Path result = null;
99+
String sourceFile = resolve(cacheStore);
100+
logger.info("copying {0} to build context folder.", sourceFile);
101+
String targetFilename = new File(sourceFile).getName();
102+
try {
103+
result = Files.copy(Paths.get(sourceFile), Paths.get(buildContextDir, targetFilename));
104+
} catch (Exception ee) {
105+
ee.printStackTrace();
106+
}
107+
logger.exiting(result);
108+
return result;
109+
}
110+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package com.oracle.weblogic.imagetool.api.model;
5+
6+
import java.util.Arrays;
7+
import java.util.List;
8+
9+
/**
10+
* Supported Fusion Middleware installer sets.
11+
*/
12+
public enum FmwInstallerType {
13+
WLS(InstallerType.WLS), //WebLogic Server
14+
FMW(InstallerType.FMW), //WebLogic Server Infrastructure (JRF)
15+
OSB(InstallerType.FMW, InstallerType.OSB), //Service Bus
16+
SOA(InstallerType.FMW, InstallerType.SOA), //SOA Suite
17+
SOAOSB(InstallerType.FMW, InstallerType.SOA, InstallerType.OSB),
18+
OAM(InstallerType.FMW, InstallerType.IDM),
19+
BI(InstallerType.FMW, InstallerType.BI),
20+
ODI(InstallerType.FMW, InstallerType.ODI),
21+
EDQ(InstallerType.FMW, InstallerType.EDQ),
22+
OHSSA(InstallerType.OHS),
23+
OHS(InstallerType.FMW, InstallerType.OHS),
24+
OIG(InstallerType.FMW, InstallerType.SOA, InstallerType.OSB, InstallerType.IDM),
25+
OUD(InstallerType.OUD),
26+
OUDSM(InstallerType.FMW, InstallerType.OUD),
27+
WCC(InstallerType.FMW, InstallerType.WCC), //Web Center Content
28+
WCP(InstallerType.FMW, InstallerType.WCP), //Web Center Portal
29+
WCS(InstallerType.FMW, InstallerType.WCS) //Web Center Sites
30+
;
31+
32+
private InstallerType[] installers;
33+
FmwInstallerType(InstallerType... installers) {
34+
this.installers = installers;
35+
}
36+
37+
public List<InstallerType> getInstallerList() {
38+
return Arrays.asList(installers);
39+
}
40+
}

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/model/InstallerType.java

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
1-
// Copyright (c) 2019, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package com.oracle.weblogic.imagetool.api.model;
55

6-
import java.util.ArrayList;
7-
import java.util.List;
8-
9-
import com.oracle.weblogic.imagetool.util.Constants;
10-
116
/**
12-
* An enum to represent installer type.
7+
* Supported installer types in the local cache.
8+
* Provides list of types to the CLI for the addInstaller type flag.
139
*/
1410
public enum InstallerType {
1511

16-
FMW(WLSInstallerType.FMW.toString()),
12+
//Values are used to resolve response files and lookup installers in the cache
13+
//There must be a matching (default) response file in {resources}/response-files/
14+
WLS("wls"),
15+
FMW("fmw"),
16+
SOA("soa"),
17+
OSB("osb"),
18+
IDM("idm"),
19+
ODI("odi"),
20+
BI("bi"),
21+
OHS("ohs"),
22+
OUD("oud"),
23+
EDQ("edq"),
24+
WCC("wcc"),
25+
WCP("wcp"),
26+
WCS("wcs"),
1727
JDK("jdk"),
18-
WDT("wdt"),
19-
WLS(WLSInstallerType.WLS.toString());
28+
WDT("wdt");
2029

2130
private String value;
2231

@@ -29,24 +38,6 @@ public String toString() {
2938
return value;
3039
}
3140

32-
/**
33-
* Get the Dockerfile build argument for this installer type.
34-
* @param location the location of the installer.
35-
* @return --build-arg and this installer type argument and location.
36-
*/
37-
public List<String> getBuildArg(String location) {
38-
List<String> retVal = new ArrayList<>(2);
39-
retVal.add(Constants.BUILD_ARG);
40-
if (this == WLS || this == FMW) {
41-
retVal.add("WLS_PKG=" + location);
42-
} else if (this == JDK) {
43-
retVal.add("JAVA_PKG=" + location);
44-
} else {
45-
retVal.add("WDT_PKG=" + location);
46-
}
47-
return retVal;
48-
}
49-
5041
/**
5142
* Create the installer type Enum from the String value.
5243
* @param value the installer type string, ignoring case.

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/model/WLSInstallerType.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/model/WLSVersionValues.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/meta/CacheStore.java renamed to imagetool/src/main/java/com/oracle/weblogic/imagetool/cachestore/CacheStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Copyright (c) 2019, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

4-
package com.oracle.weblogic.imagetool.api.meta;
4+
package com.oracle.weblogic.imagetool.cachestore;
55

66
import java.util.Map;
77

0 commit comments

Comments
 (0)