Skip to content

Commit a18beb6

Browse files
authored
Revert "adding block so windows doesn't run retrieveUninstallFileList twice"
1 parent 719e3e6 commit a18beb6

File tree

1 file changed

+14
-93
lines changed

1 file changed

+14
-93
lines changed

dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/UninstallDirector.java

Lines changed: 14 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,16 @@
1212

1313
import java.io.File;
1414
import java.io.IOException;
15-
import java.nio.file.Files;
16-
import java.nio.file.Path;
1715
import java.util.ArrayList;
18-
import java.util.Arrays;
1916
import java.util.Collection;
2017
import java.util.HashMap;
21-
import java.util.HashSet;
2218
import java.util.LinkedHashMap;
2319
import java.util.List;
2420
import java.util.Map;
2521
import java.util.Map.Entry;
2622
import java.util.Set;
2723
import java.util.logging.Level;
2824
import java.util.logging.Logger;
29-
import java.util.stream.Collectors;
3025

3126
import com.ibm.ws.install.InstallException;
3227
import com.ibm.ws.install.InstallProgressEvent;
@@ -67,8 +62,8 @@ void cleanUp() {
6762
* Creates array and calls method below
6863
*
6964
* @param checkDependency if uninstall should check for dependencies
70-
* @param productId product id to uninstall
71-
* @param toBeDeleted Collection of files to uninstall
65+
* @param productId product id to uninstall
66+
* @param toBeDeleted Collection of files to uninstall
7267
* @throws InstallException
7368
*/
7469
void uninstall(boolean checkDependency, String productId, Collection<File> toBeDeleted) throws InstallException {
@@ -93,32 +88,27 @@ void retrieveUninstallFileList(UninstallAsset uninstallAsset, boolean checkDepen
9388
* Uninstalls product depending on dependencies
9489
*
9590
* @param checkDependency if uninstall should check for dependencies
96-
* @param productIds product ids to uninstall
97-
* @param toBeDeleted Collection of files to uninstall
91+
* @param productIds product ids to uninstall
92+
* @param toBeDeleted Collection of files to uninstall
9893
* @throws InstallException
9994
*/
10095
void uninstall(boolean checkDependency, String[] productIds, Collection<File> toBeDeleted) throws InstallException {
10196
if (uninstallAssets.isEmpty())
10297
return;
10398

104-
// On Windows specifically, we need to do a file lock check before attempting to uninstall assets.
99+
// Run file checking only on Windows
105100
if (InstallUtils.isWindows) {
106101
// check any file is locked
107102
fireProgressEvent(InstallProgressEvent.CHECK, 10, Messages.INSTALL_KERNEL_MESSAGES.getLogMessage("STATE_CHECKING"));
108-
Set<File> baseDirs = new HashSet<>();
109103
for (UninstallAsset uninstallAsset : uninstallAssets) {
110-
baseDirs.addAll(getAssetBaseDirectories(uninstallAsset));
104+
retrieveUninstallFileList(uninstallAsset, checkDependency);
105+
engine.preCheck(uninstallAsset);
111106
}
112-
113-
// For each uninstall asset's base directory, validate no files are locked recursively.
114-
for (File baseDir : baseDirs) {
115-
try {
116-
List<Path> allPathsFromBaseDir = Files.walk(baseDir.toPath()).collect(Collectors.toList());
117-
for (Path path : allPathsFromBaseDir) {
118-
InstallUtils.isFileLocked("ERROR_UNINSTALL_FEATURE_FILE_LOCKED", path.toString(), path.toFile());
107+
if (toBeDeleted != null) {
108+
for (File f : toBeDeleted) {
109+
for (String productId : productIds) {
110+
InstallUtils.isFileLocked("ERROR_UNINSTALL_PRODUCT_FILE_LOCKED", productId, f);
119111
}
120-
} catch (IOException e) {
121-
throw ExceptionUtils.create(e);
122112
}
123113
}
124114
}
@@ -154,75 +144,6 @@ else if (f.isDirectory())
154144
}
155145
}
156146

157-
/**
158-
*
159-
* @param uninstallAsset the uninstall asset to derive a base directory from
160-
* @return the uninstallAsset's base directories derived from uninstallAsset. For example, if the uninstallAsset location is dev/spi/ibm and baseDir is
161-
* /opt/IBM/WebSphere/AppServer, this will return 'Set[/opt/IBM/WebSphere/AppServer/dev]' iff the path exists, an empty Set otherwise.
162-
* @throws InstallException
163-
*/
164-
private Set<File> getAssetBaseDirectories(UninstallAsset uninstallAsset) throws InstallException {
165-
166-
Set<File> baseDirs = new HashSet<>();
167-
File baseDir = engine.getBaseDir(uninstallAsset.getProvisioningFeatureDefinition());
168-
Set<String> assetLocations = getAssetLocations(uninstallAsset);
169-
170-
// For each asset location, construct a list of locations containing the first child directory appended
171-
// to the base directory iff that directory exists.
172-
for (String assetLocation : assetLocations) {
173-
List<String> subDirs = getFirstChildSubdirectoryFromLocations(assetLocation);
174-
for (String subDir : subDirs) {
175-
File base = new File(baseDir + File.separator + subDir);
176-
if (base.exists()) {
177-
baseDirs.add(base);
178-
}
179-
}
180-
}
181-
return baseDirs;
182-
}
183-
184-
/**
185-
* @param uninstallAsset the asset to process for relevant location data
186-
* @return a set of strings that are the location data derived from uninstallAsset. This set my be empty if the asset is not BUNDLE_TYPE, JAR_TYPE, BOOT_JAR_TYPE or FILE_TYPE.
187-
* It could also be empty if the getLocation() call returns null or an empty string.
188-
*/
189-
private Set<String> getAssetLocations(UninstallAsset uninstallAsset) {
190-
// Only process BUNDLE, JAR, BOOT and FILE subsystem types.
191-
final List<SubsystemContentType> resourceFilter = Arrays.asList(SubsystemContentType.BUNDLE_TYPE, SubsystemContentType.JAR_TYPE, SubsystemContentType.BOOT_JAR_TYPE,
192-
SubsystemContentType.FILE_TYPE);
193-
// From the collection of FeatureResources, filter out types we don't wish to process and then collect all location strings from them.
194-
return uninstallAsset.getProvisioningFeatureDefinition().getConstituents(null).stream().filter(s -> resourceFilter.contains(s.getType())
195-
&& s.getLocation() != null).map(s -> s.getLocation()).collect(Collectors.toSet());
196-
}
197-
198-
/**
199-
*
200-
* @param locString the location string to parse, may be null and may contain more than one location separated by `,`.
201-
* @return A list of the parent directories specified in the locString. For example, if the locString is "bin/tools/tools.zip", this method will return ["bin"].
202-
* if locString contains "bin/tools/tools.zip,etc/files/files.zip" this method would return ["bin","etc"]
203-
*
204-
*/
205-
private List<String> getFirstChildSubdirectoryFromLocations(String locString) {
206-
List<String> subdirectories = new ArrayList<>();
207-
if (locString != null) {
208-
String[] locs = locString.contains(",") ? locString.split(",") : new String[] { locString };
209-
for (String loc : locs) {
210-
File fle = new File(loc);
211-
String fileStr = fle.toString();
212-
// skip a leading separator
213-
if (fileStr.charAt(0) == File.separatorChar) {
214-
fileStr = fileStr.substring(1);
215-
}
216-
int index = fileStr.indexOf(File.separator);
217-
if (index > 0) {
218-
fileStr = fileStr.substring(0, fileStr.indexOf(File.separator));
219-
}
220-
subdirectories.add(fileStr);
221-
}
222-
}
223-
return subdirectories;
224-
}
225-
226147
void uninstall(Collection<String> ids, boolean force) throws InstallException {
227148
Collection<ProvisioningFeatureDefinition> installedFeatureDefinitions = product.getAllFeatureDefinitions().values();
228149
Collection<String> featureNames = new ArrayList<String>();
@@ -251,7 +172,7 @@ void uninstall(Collection<String> ids, boolean force) throws InstallException {
251172
*
252173
* @param featureNames a list of the feature names and feature symbolic names to uninstall
253174
* @throws InstallException if there is a feature not installed or
254-
* there is another feature still requires the uninstalling features.
175+
* there is another feature still requires the uninstalling features.
255176
*/
256177
void uninstallFeatures(Collection<String> featureNames, Collection<String> uninstallInstallFeatures, boolean force) {
257178
product.refresh();
@@ -288,7 +209,7 @@ boolean contains(ProvisioningFeatureDefinition pfd) {
288209
/**
289210
* Creates array and calls method below
290211
*
291-
* @param productId product id to uninstall
212+
* @param productId product id to uninstall
292213
* @param exceptPlatfromFeatuers If platform features should be ignored
293214
* @throws InstallException
294215
*/
@@ -301,7 +222,7 @@ void uninstallFeaturesByProductId(String productId, boolean exceptPlatfromFeatue
301222
/**
302223
* Uninstalls features by product id
303224
*
304-
* @param productIds product ids to uninstall
225+
* @param productIds product ids to uninstall
305226
* @param exceptPlatfromFeatuers If platform features should be ignored
306227
* @throws InstallException
307228
*/

0 commit comments

Comments
 (0)