Merge "Omaha #4541 - Fixed NPE for protected files." into omaha_16.1.1

Former-commit-id: c6eecf39975fc9500a7fc61e7da6f7784a42861f
This commit is contained in:
Lee Venable 2015-06-11 14:13:36 -05:00 committed by Gerrit Code Review
commit 741ee5f1e7

View file

@ -52,6 +52,7 @@ import com.raytheon.viz.ui.VizWorkbenchManager;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 1, 2011 mschenke Initial creation
* Jun 11, 2015 4541 skorolev Added NULL test for lf.
*
* </pre>
*
@ -69,9 +70,9 @@ public class ImportFileAction extends Action {
private static final String ASTERISK = "*";
private String directoryPath;
private final String directoryPath;
private LocalizationType contextType;
private final LocalizationType contextType;
private String[] fileExtensionFilterArr;
@ -81,7 +82,8 @@ public class ImportFileAction extends Action {
this.directoryPath = directoryPath;
}
public ImportFileAction(LocalizationType contextType, String directoryPath, String[] filter) {
public ImportFileAction(LocalizationType contextType, String directoryPath,
String[] filter) {
this(contextType, directoryPath);
if (filter != null) {
this.fileExtensionFilterArr = new String[filter.length];
@ -137,10 +139,17 @@ public class ImportFileAction extends Action {
LocalizationFile lf = pm.getLocalizationFile(
pm.getContext(contextType, LocalizationLevel.USER),
newFilePath);
if ((lf != null) && !lf.isProtected()) {
localizationFiles.add(lf);
if (lf.exists()) {
existing.add(lf);
}
} else {
statusHandler
.handle(Priority.WARN,
newFilePath
+ " is protected. A user level version of this file is not allowed to be created.");
}
}
List<LocalizationFile> skip = new ArrayList<LocalizationFile>();
@ -164,6 +173,7 @@ public class ImportFileAction extends Action {
int addCount = 0;
for (int i = 0; i < applicable.size(); ++i) {
File importFile = applicable.get(i);
if (!localizationFiles.isEmpty()) {
LocalizationFile lf = localizationFiles.get(i);
if (skip.contains(lf) == false) {
try {
@ -175,14 +185,15 @@ public class ImportFileAction extends Action {
}
}
}
}
return addCount > 0;
}
private static class MultiConfirmDialog extends MessageDialog {
private List<LocalizationFile> confirmedFiles;
private final List<LocalizationFile> confirmedFiles;
private List<LocalizationFile> existingFiles;
private final List<LocalizationFile> existingFiles;
private int curIdx = 0;