crashanalysis/crashanalyser/com.nokia.s60tools.crashanalyser/src/com/nokia/s60tools/crashanalyser/model/DecoderEngine.java
changeset 16 72f198be1c1d
parent 4 615035072f7e
equal deleted inserted replaced
15:0367d2db2c06 16:72f198be1c1d
    75 	 * 
    75 	 * 
    76 	 * @param file
    76 	 * @param file
    77 	 *            crash file
    77 	 *            crash file
    78 	 * @return true if file seems to be a known crash file, false if not
    78 	 * @return true if file seems to be a known crash file, false if not
    79 	 */
    79 	 */
    80 	public static boolean isFileValidCrashFile(String file) {
    80 	public static boolean isFileValidCrashFile(final String file) {
    81 		return isFileValidCrashFile(new File(file));
    81 		return isFileValidCrashFile(new File(file));
    82 	}
    82 	}
    83 
    83 
    84 	/**
    84 	/**
    85 	 * Checks whether given file is a known crash file
    85 	 * Checks whether given file is a known crash file
    86 	 * 
    86 	 * 
    87 	 * @param file
    87 	 * @param file
    88 	 *            crash file
    88 	 *            crash file
    89 	 * @return true if file seems to be a known crash file, false if not
    89 	 * @return true if file seems to be a known crash file, false if not
    90 	 */
    90 	 */
    91 	public static boolean isFileValidCrashFile(File file) {
    91 	public static boolean isFileValidCrashFile(final File file) {
    92 		try {
    92 		try {
    93 			// file must be a file and it must exist
    93 			// file must be a file and it must exist
    94 			if (file.isFile() && file.exists()) {
    94 			if (file.isFile() && file.exists()) {
    95 				String fileName = file.getName();
    95 				final String fileName = file.getName();
    96 				// file extension must match known extension types
    96 				// file extension must match known extension types
    97 				if (fileName
    97 				if (fileName
    98 						.endsWith(CrashAnalyserFile.MOBILECRASH_FILE_EXTENSION)
    98 						.endsWith(CrashAnalyserFile.MOBILECRASH_FILE_EXTENSION)
    99 						|| fileName
    99 						|| fileName
   100 								.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION)
   100 								.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION)
   115 	 * 
   115 	 * 
   116 	 * @param path
   116 	 * @param path
   117 	 *            from where Crash files should be found
   117 	 *            from where Crash files should be found
   118 	 * @return true if given path contains Crash files, false if not
   118 	 * @return true if given path contains Crash files, false if not
   119 	 */
   119 	 */
   120 	protected boolean isCrashPathValid(String path) {
   120 	protected boolean isCrashPathValid(final String path) {
   121 		try {
   121 		try {
   122 			File file = new File(path);
   122 			final File file = new File(path);
   123 			if (!file.isDirectory())
   123 			if (!file.isDirectory())
   124 				return false;
   124 				return false;
   125 
   125 
   126 			// We are looking for files *.bin, or *.txt or *.crashxml
   126 			// We are looking for files *.bin, or *.txt or *.crashxml
   127 			FilenameFilter filter = new FilenameFilter() {
   127 			final FilenameFilter filter = new FilenameFilter() {
   128 				public boolean accept(File dir, String name) {
   128 				public boolean accept(File dir, String name) {
   129 					return (name
   129 					return (name
   130 							.endsWith(CrashAnalyserFile.MOBILECRASH_FILE_EXTENSION)
   130 							.endsWith(CrashAnalyserFile.MOBILECRASH_FILE_EXTENSION)
   131 							|| name
   131 							|| name
   132 									.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION)
   132 									.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION)
   134 									.endsWith(CrashAnalyserFile.D_EXC_FILE_EXTENSION)
   134 									.endsWith(CrashAnalyserFile.D_EXC_FILE_EXTENSION)
   135 							|| name
   135 							|| name
   136 									.endsWith(CrashAnalyserFile.ELF_CORE_DUMP_FILE_EXTENSION));
   136 									.endsWith(CrashAnalyserFile.ELF_CORE_DUMP_FILE_EXTENSION));
   137 				}
   137 				}
   138 			};
   138 			};
   139 			File[] files = file.listFiles(filter);
   139 			final File[] files = file.listFiles(filter);
   140 			if (files != null && files.length > 0)
   140 			if (files != null && files.length > 0)
   141 				return true;
   141 				return true;
   142 
   142 
   143 			return false;
   143 			return false;
   144 		} catch (Exception e) {
   144 		} catch (Exception e) {
   153 	 *            defines whether the folder should be cleared
   153 	 *            defines whether the folder should be cleared
   154 	 * @return E.g.
   154 	 * @return E.g.
   155 	 *         C:\My_Workspace\.metadata\.plugins\com.nokia.s60tools.crashanalyser
   155 	 *         C:\My_Workspace\.metadata\.plugins\com.nokia.s60tools.crashanalyser
   156 	 *         \work\
   156 	 *         \work\
   157 	 */
   157 	 */
   158 	public static String getWorkingFolder(boolean clean) {
   158 	public static String getWorkingFolder(final boolean clean) {
   159 		String workingFolder = FileOperations
   159 		String workingFolder = FileOperations
   160 				.addSlashToEnd(getPluginWorkingLocation());
   160 				.addSlashToEnd(getPluginWorkingLocation());
   161 		workingFolder += FileOperations.addSlashToEnd(WORK_FOLDER);
   161 		workingFolder += FileOperations.addSlashToEnd(WORK_FOLDER);
   162 		// creates the folder. if the folder already exists, deletes its content
   162 		// creates the folder. if the folder already exists, deletes its content
   163 		FileOperations.createFolder(workingFolder, clean);
   163 		FileOperations.createFolder(workingFolder, clean);
   170 	 * \com.nokia.s60tools.crashanalyser\CrashFiles\5\
   170 	 * \com.nokia.s60tools.crashanalyser\CrashFiles\5\
   171 	 * 
   171 	 * 
   172 	 * @return created folder, or null if failed
   172 	 * @return created folder, or null if failed
   173 	 */
   173 	 */
   174 	public static String getNewCrashFolder() {
   174 	public static String getNewCrashFolder() {
   175 		String crashFilesFolder = FileOperations
   175 		final String crashFilesFolder = FileOperations
   176 				.addSlashToEnd(getCrashFilesFolder());
   176 				.addSlashToEnd(getCrashFilesFolder());
   177 		for (int i = 1; i < MAX_FILE_COUNT; i++) {
   177 		for (int i = 1; i < MAX_FILE_COUNT; i++) {
   178 			File freeFolder = new File(crashFilesFolder + Integer.toString(i));
   178 			final File freeFolder = new File(crashFilesFolder + Integer.toString(i));
   179 			if (!freeFolder.exists()) {
   179 			if (!freeFolder.exists()) {
   180 				FileOperations.createFolder(freeFolder.getAbsolutePath());
   180 				FileOperations.createFolder(freeFolder.getAbsolutePath());
   181 				return freeFolder.getAbsolutePath();
   181 				return freeFolder.getAbsolutePath();
   182 			}
   182 			}
   183 		}
   183 		}
   193 	 *            defines whether the folder should be cleared
   193 	 *            defines whether the folder should be cleared
   194 	 * @return E.g.
   194 	 * @return E.g.
   195 	 *         C:\My_Workspace\.metadata\.plugins\com.nokia.s60tools.crashanalyser
   195 	 *         C:\My_Workspace\.metadata\.plugins\com.nokia.s60tools.crashanalyser
   196 	 *         \temp
   196 	 *         \temp
   197 	 */
   197 	 */
   198 	public static String getTemporaryCrashFileFolder(boolean clean) {
   198 	public static String getTemporaryCrashFileFolder(final boolean clean) {
   199 		String tempFolder = FileOperations
   199 		String tempFolder = FileOperations
   200 				.addSlashToEnd(getPluginWorkingLocation());
   200 				.addSlashToEnd(getPluginWorkingLocation());
   201 		tempFolder += TEMPORARY_FOLDER;
   201 		tempFolder += TEMPORARY_FOLDER;
   202 		// creates the folder. if the folder already exists, deletes its content
   202 		// creates the folder. if the folder already exists, deletes its content
   203 		FileOperations.createFolder(tempFolder, clean);
   203 		FileOperations.createFolder(tempFolder, clean);
   211 	 *            path to be checked
   211 	 *            path to be checked
   212 	 * @param pathType
   212 	 * @param pathType
   213 	 *            defines "how" the path is validated
   213 	 *            defines "how" the path is validated
   214 	 * @return true if path is valid, false if not
   214 	 * @return true if path is valid, false if not
   215 	 */
   215 	 */
   216 	public boolean isPathValid(String path, PathTypes pathType) {
   216 	public boolean isPathValid(final String path, final PathTypes pathType) {
   217 
   217 
   218 		boolean retVal = false;
   218 		boolean retVal = false;
   219 
   219 
   220 		if (PathTypes.CRASH.equals(pathType))
   220 		if (PathTypes.CRASH.equals(pathType))
   221 			retVal = isCrashPathValid(path);
   221 			retVal = isCrashPathValid(path);
   238 	 * method is used when user has selected files to be re-decoded.
   238 	 * method is used when user has selected files to be re-decoded.
   239 	 * 
   239 	 * 
   240 	 * @param files
   240 	 * @param files
   241 	 *            files to be decoded
   241 	 *            files to be decoded
   242 	 */
   242 	 */
   243 	public void setCrashFiles(List<CrashFileBundle> files) {
   243 	public void setCrashFiles(final List<CrashFileBundle> files) {
   244 		crashFiles = files;
   244 		crashFiles = files;
   245 	}
   245 	}
   246 
   246 
   247 	/**
   247 	/**
   248 	 * This method executes CrashAnalyser.exe for summary information for given
   248 	 * This method executes CrashAnalyser.exe for summary information for given
   254 	 *            Error Library
   254 	 *            Error Library
   255 	 * @param progress
   255 	 * @param progress
   256 	 *            progress monitor
   256 	 *            progress monitor
   257 	 * @return true if any files were found for summary info, false if not
   257 	 * @return true if any files were found for summary info, false if not
   258 	 */
   258 	 */
   259 	public boolean processSummaryInfoForFiles(String fileOrFolder,
   259 	public boolean processSummaryInfoForFiles(final String fileOrFolder,
   260 			ErrorLibrary errorLibrary, IProgressMonitor progress) {
   260 			ErrorLibrary errorLibrary, final IProgressMonitor progress) {
   261 		if (crashFiles != null)
   261 		if (crashFiles != null)
   262 			crashFiles.clear();
   262 			crashFiles.clear();
   263 		String workingFolder = DecoderEngine.getWorkingFolder(true);
   263 		final String workingFolder = DecoderEngine.getWorkingFolder(true);
   264 		if (!"".equals(fileOrFolder)) {
   264 		if (!"".equals(fileOrFolder)) {
   265 
   265 
   266 			String originatingDirectory = fileOrFolder;
   266 			String originatingDirectory = fileOrFolder;
   267 
   267 
   268 			File f = new File(fileOrFolder);
   268 			final File f = new File(fileOrFolder);
   269 			// if only one .crashxml file is selected, no need to run command
   269 			// if only one .crashxml file is selected, no need to run command
   270 			// line
   270 			// line
   271 			if (f.isFile()
   271 			if (f.isFile()
   272 					&& fileOrFolder
   272 					&& fileOrFolder
   273 							.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION)) {
   273 							.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION)) {
   309 	 * @param workingFolder
   309 	 * @param workingFolder
   310 	 *            folder where crash files are copied to
   310 	 *            folder where crash files are copied to
   311 	 * @return true if fromFolder contained only crash files (.crashxml), false
   311 	 * @return true if fromFolder contained only crash files (.crashxml), false
   312 	 *         if folder contained other files also
   312 	 *         if folder contained other files also
   313 	 */
   313 	 */
   314 	boolean copyCrashFilesToWorkingDirectory(String fromFolder,
   314 	boolean copyCrashFilesToWorkingDirectory(final String fromFolder,
   315 			String workingFolder) {
   315 			final String workingFolder) {
   316 		boolean retval = true;
   316 		boolean retval = true;
   317 		File from = new File(fromFolder);
   317 		final File from = new File(fromFolder);
   318 		// given from folder needs to be an existing directory
   318 		// given from folder needs to be an existing directory
   319 		if (from.isDirectory() && from.exists()) {
   319 		if (from.isDirectory() && from.exists()) {
   320 			String[] files = from.list(); // get all files
   320 			final String[] files = from.list(); // get all files
   321 			// if files were found
   321 			// if files were found
   322 			if (files != null && files.length > 0) {
   322 			if (files != null && files.length > 0) {
   323 				// go through all files in fromFolder
   323 				// go through all files in fromFolder
   324 				for (int i = 0; i < files.length; i++) {
   324 				for (int i = 0; i < files.length; i++) {
   325 					String file = files[i];
   325 					final String file = files[i];
   326 					// files is .crashxml
   326 					// files is .crashxml
   327 					if (file.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION)) {
   327 					if (file.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION)) {
   328 						FileOperations.copyFile(new File(FileOperations
   328 						FileOperations.copyFile(new File(FileOperations
   329 								.addSlashToEnd(fromFolder)
   329 								.addSlashToEnd(fromFolder)
   330 								+ file), workingFolder, true);
   330 								+ file), workingFolder, true);
   349 	 * @param originatingDirectory
   349 	 * @param originatingDirectory
   350 	 *            directory from where the original files are being imported
   350 	 *            directory from where the original files are being imported
   351 	 * @param errorLibrary
   351 	 * @param errorLibrary
   352 	 *            Error Library
   352 	 *            Error Library
   353 	 */
   353 	 */
   354 	void readSummaryFiles(String summaryFileDirectory,
   354 	void readSummaryFiles(final String summaryFileDirectory,
   355 			String originatingDirectory, ErrorLibrary errorLibrary) {
   355 			final String originatingDirectory, final ErrorLibrary errorLibrary) {
   356 		File file = new File(summaryFileDirectory);
   356 		final File file = new File(summaryFileDirectory);
   357 		crashFiles = new ArrayList<CrashFileBundle>();
   357 		crashFiles = new ArrayList<CrashFileBundle>();
   358 
   358 
   359 		// read all files from the directory
   359 		// read all files from the directory
   360 		if (file.isDirectory()) {
   360 		if (file.isDirectory()) {
   361 
   361 
   362 			// accept summary and output files (.xml & .crashxml)
   362 			// accept summary and output files (.xml & .crashxml)
   363 			FilenameFilter filter = new FilenameFilter() {
   363 			final FilenameFilter filter = new FilenameFilter() {
   364 				public boolean accept(File dir, String name) {
   364 				public boolean accept(final File dir, final String name) {
   365 					return (name
   365 					return ((name
   366 							.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION) || name
   366 							.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION) || name
   367 							.endsWith("."
   367 							.endsWith("."
   368 									+ CrashAnalyserFile.SUMMARY_FILE_EXTENSION));
   368 									+ CrashAnalyserFile.SUMMARY_FILE_EXTENSION)) && 
       
   369 									! name.equals(CommandLineManager.PARAMETERS_XML));
   369 				}
   370 				}
   370 			};
   371 			};
   371 
   372 
   372 			File[] files = file.listFiles(filter);
   373 			final File[] files = file.listFiles(filter);
   373 
   374 
   374 			// go through all found files
   375 			// go through all found files
   375 			for (int i = 0; i < files.length; i++) {
   376 			for (int i = 0; i < files.length; i++) {
   376 				File crashFile = files[i];
   377 				final File crashFile = files[i];
   377 
   378 
   378 				// file is output.crashxml type
   379 				// file is output.crashxml type
   379 				if (crashFile.getName().endsWith(
   380 				if (crashFile.getName().endsWith(
   380 						CrashAnalyserFile.OUTPUT_FILE_EXTENSION)) {
   381 						CrashAnalyserFile.OUTPUT_FILE_EXTENSION)) {
   381 					CrashFile crashxml = CrashFile
   382 					CrashFile crashxml = CrashFile
   383 					if (crashxml != null)
   384 					if (crashxml != null)
   384 						crashFiles.add(new CrashFileBundle(crashxml,
   385 						crashFiles.add(new CrashFileBundle(crashxml,
   385 								originatingDirectory));
   386 								originatingDirectory));
   386 					// file is summary file
   387 					// file is summary file
   387 				} else {
   388 				} else {
   388 					SummaryFile summaryXml = SummaryFile.read(crashFile,
   389 					final SummaryFile summaryXml = SummaryFile.read(crashFile,
   389 							errorLibrary);
   390 							errorLibrary);
   390 					if (summaryXml != null)
   391 					if (summaryXml != null)
   391 						crashFiles.add(new CrashFileBundle(summaryXml,
   392 						crashFiles.add(new CrashFileBundle(summaryXml,
   392 								originatingDirectory));
   393 								originatingDirectory));
   393 				}
   394 				}
   399 	 * Used for passing decoding parameters
   400 	 * Used for passing decoding parameters
   400 	 * 
   401 	 * 
   401 	 * @param data
   402 	 * @param data
   402 	 *            decoding parameters
   403 	 *            decoding parameters
   403 	 */
   404 	 */
   404 	public void setDecodingData(DecodingData data) {
   405 	public void setDecodingData(final DecodingData data) {
   405 		decodingData = data;
   406 		decodingData = data;
   406 	}
   407 	}
   407 
   408 
   408 	/**
   409 	/**
   409 	 * Returns a path where Crash Analyser plugin can do various tasks (located
   410 	 * Returns a path where Crash Analyser plugin can do various tasks (located
   412 	 * @return E.g.
   413 	 * @return E.g.
   413 	 *         C:\My_Workspace\.metadata\.plugins\com.nokia.s60tools.crashanalyser
   414 	 *         C:\My_Workspace\.metadata\.plugins\com.nokia.s60tools.crashanalyser
   414 	 *         \
   415 	 *         \
   415 	 */
   416 	 */
   416 	protected static String getPluginWorkingLocation() {
   417 	protected static String getPluginWorkingLocation() {
   417 		IPath location = Platform.getStateLocation(CrashAnalyserPlugin
   418 		final IPath location = Platform.getStateLocation(CrashAnalyserPlugin
   418 				.getDefault().getBundle());
   419 				.getDefault().getBundle());
   419 		return location.toOSString();
   420 		return location.toOSString();
   420 	}
   421 	}
   421 
   422 
   422 	/**
   423 	/**
   425 	 * @return E.g.
   426 	 * @return E.g.
   426 	 *         C:\My_Workspace\.metadata\.plugins\com.nokia.s60tools.crashanalyser
   427 	 *         C:\My_Workspace\.metadata\.plugins\com.nokia.s60tools.crashanalyser
   427 	 *         \CrashFiles
   428 	 *         \CrashFiles
   428 	 */
   429 	 */
   429 	public static String getCrashFilesFolder() {
   430 	public static String getCrashFilesFolder() {
   430 		String crashFilesFolder = FileOperations
   431 		final String crashFilesFolder = FileOperations
   431 				.addSlashToEnd(getPluginWorkingLocation())
   432 				.addSlashToEnd(getPluginWorkingLocation())
   432 				+ CRASH_FILES_FOLDER;
   433 				+ CRASH_FILES_FOLDER;
   433 		FileOperations.createFolder(crashFilesFolder);
   434 		FileOperations.createFolder(crashFilesFolder);
   434 		return crashFilesFolder;
   435 		return crashFilesFolder;
   435 	}
   436 	}
   438 	 * Start the decoding process
   439 	 * Start the decoding process
   439 	 * 
   440 	 * 
   440 	 * @param observer
   441 	 * @param observer
   441 	 *            observer for the decoding process
   442 	 *            observer for the decoding process
   442 	 */
   443 	 */
   443 	public void decode(IDecodingObserver observer) {
   444 	public void decode(final IDecodingObserver observer) {
   444 		decodingObserver = observer;
   445 		decodingObserver = observer;
   445 		setPriority(Job.SHORT);
   446 		setPriority(Job.SHORT);
   446 		setUser(true);
   447 		setUser(true);
   447 		schedule();
   448 		schedule();
   448 	}
   449 	}
   456 	 * @param workingFolder
   457 	 * @param workingFolder
   457 	 *            where files are to be decoded
   458 	 *            where files are to be decoded
   458 	 * @param monitor
   459 	 * @param monitor
   459 	 *            for progress bar
   460 	 *            for progress bar
   460 	 */
   461 	 */
   461 	void importCrashFiles(String workingFolder, IProgressMonitor monitor) {
   462 	void importCrashFiles(final String workingFolder, final IProgressMonitor monitor) {
   462 		if (crashFiles != null) {
   463 		if (crashFiles != null) {
   463 			List<String> filesToBeDecoded = new ArrayList<String>();
   464 			final List<String> filesToBeDecoded = new ArrayList<String>();
   464 			// go through all crash files
   465 			// go through all crash files
   465 			for (int i = 0; i < crashFiles.size(); i++) {
   466 			for (int i = 0; i < crashFiles.size(); i++) {
   466 				CrashFileBundle crashFile = crashFiles.get(i);
   467 				final CrashFileBundle crashFile = crashFiles.get(i);
   467 
   468 
   468 				// we are importing already decoded file (.crashxml)
   469 				// we are importing already decoded file (.crashxml)
   469 				if (crashFile.isFullyDecoded()) {
   470 				if (crashFile.isFullyDecoded()) {
   470 					CrashFile f = crashFile.getCrashFile();
   471 					final CrashFile f = crashFile.getCrashFile();
   471 					// this index was not chosen by user to be imported, delete
   472 					// this index was not chosen by user to be imported, delete
   472 					// this .crash from working folder
   473 					// this .crash from working folder
   473 					if (f != null && !decodingData.crashFileIndexes.contains(i)) {
   474 					if (f != null && !decodingData.crashFileIndexes.contains(i)) {
   474 						FileOperations.deleteFile(f.getFilePath());
   475 						FileOperations.deleteFile(f.getFilePath());
   475 					}
   476 					}
   478 					// this index was not chosen by user to be imported, skip
   479 					// this index was not chosen by user to be imported, skip
   479 					// this crash file
   480 					// this crash file
   480 					if (!decodingData.crashFileIndexes.contains(i))
   481 					if (!decodingData.crashFileIndexes.contains(i))
   481 						continue;
   482 						continue;
   482 
   483 
   483 					SummaryFile f = crashFile.getSummaryFile();
   484 					final SummaryFile f = crashFile.getSummaryFile();
   484 					filesToBeDecoded.add(f.getSourceFilePath());
   485 					filesToBeDecoded.add(f.getSourceFilePath());
   485 				}
   486 				}
   486 			}
   487 			}
   487 
   488 
   488 			if (!filesToBeDecoded.isEmpty()) {
   489 			if (!filesToBeDecoded.isEmpty()) {
   490 
   491 
   491 				// if MapFiles.zip is provided
   492 				// if MapFiles.zip is provided
   492 				if (mapFilesFolder != null && "".equals(mapFilesFolder)
   493 				if (mapFilesFolder != null && "".equals(mapFilesFolder)
   493 						&& decodingData.mapFilesZip != null
   494 						&& decodingData.mapFilesZip != null
   494 						&& !"".equals(decodingData.mapFilesZip)) {
   495 						&& !"".equals(decodingData.mapFilesZip)) {
   495 					String zipFolder = FileOperations
   496 					final String zipFolder = FileOperations
   496 							.addSlashToEnd(workingFolder)
   497 							.addSlashToEnd(workingFolder)
   497 							+ FileOperations
   498 							+ FileOperations
   498 									.addSlashToEnd(MAP_FILES_ZIP_FOLDER);
   499 									.addSlashToEnd(MAP_FILES_ZIP_FOLDER);
   499 					FileOperations.createFolder(zipFolder, true);
   500 					FileOperations.createFolder(zipFolder, true);
   500 					FileOperations.unZipFiles(
   501 					FileOperations.unZipFiles(
   518 	 * 
   519 	 * 
   519 	 * @param crashFile
   520 	 * @param crashFile
   520 	 *            .xml or .crashxml file
   521 	 *            .xml or .crashxml file
   521 	 * @return CrashFileBundle for given file if found, null if not found
   522 	 * @return CrashFileBundle for given file if found, null if not found
   522 	 */
   523 	 */
   523 	CrashFileBundle getCrashFileBundle(File crashFile) {
   524 	CrashFileBundle getCrashFileBundle(final File crashFile) {
   524 		if (crashFiles != null) {
   525 		if (crashFiles != null) {
   525 			for (int i = 0; i < crashFiles.size(); i++) {
   526 			for (int i = 0; i < crashFiles.size(); i++) {
   526 				CrashFileBundle cfb = crashFiles.get(i);
   527 				final CrashFileBundle cfb = crashFiles.get(i);
   527 				String fileName = "";
   528 				String fileName = "";
   528 				SummaryFile sf = cfb.getSummaryFile();
   529 				final SummaryFile sf = cfb.getSummaryFile();
   529 				if (sf != null) {
   530 				if (sf != null) {
   530 					fileName = FileOperations.getFileNameWithoutExtension(sf
   531 					fileName = FileOperations.getFileNameWithoutExtension(sf
   531 							.getFileName());
   532 							.getFileName());
   532 				}
   533 				}
   533 				CrashFile cf = cfb.getCrashFile();
   534 				final CrashFile cf = cfb.getCrashFile();
   534 				if (cf != null) {
   535 				if (cf != null) {
   535 					fileName = FileOperations.getFileNameWithoutExtension(cf
   536 					fileName = FileOperations.getFileNameWithoutExtension(cf
   536 							.getFileName());
   537 							.getFileName());
   537 				}
   538 				}
   538 
   539 
   539 				if ("".equals(fileName)) {
   540 				if ("".equals(fileName)) {
   540 					UndecodedFile uf = cfb.getUndecodedFile();
   541 					final UndecodedFile uf = cfb.getUndecodedFile();
   541 					if (uf != null
   542 					if (uf != null
   542 							&& uf
   543 							&& uf
   543 									.getFileName()
   544 									.getFileName()
   544 									.equals(
   545 									.equals(
   545 											FileOperations
   546 											FileOperations
   561 	 * CrashFiles folder
   562 	 * CrashFiles folder
   562 	 * 
   563 	 * 
   563 	 * @param workingFolder
   564 	 * @param workingFolder
   564 	 *            from where decoded files are moved from
   565 	 *            from where decoded files are moved from
   565 	 */
   566 	 */
   566 	CrashAnalyserFile moveDecodedFiles(String workingFolder) {
   567 	CrashAnalyserFile moveDecodedFiles(final String workingFolder) {
   567 		CrashAnalyserFile cafile = null;
   568 		CrashAnalyserFile cafile = null;
   568 		File folder = new File(workingFolder);
   569 		final File folder = new File(workingFolder);
   569 
   570 
   570 		// accept output files (.crashxml)
   571 		// accept output files (.crashxml)
   571 		FilenameFilter filter = new FilenameFilter() {
   572 		final FilenameFilter filter = new FilenameFilter() {
   572 			public boolean accept(File dir, String name) {
   573 			public boolean accept(final File dir, final String name) {
   573 				return (name.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION));
   574 				return (name.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION));
   574 			}
   575 			}
   575 		};
   576 		};
   576 
   577 
   577 		File[] files = folder.listFiles(filter);
   578 		final File[] files = folder.listFiles(filter);
   578 
   579 
   579 		// go through all found files
   580 		// go through all found files
   580 		for (int i = 0; i < files.length; i++) {
   581 		for (int i = 0; i < files.length; i++) {
   581 			try {
   582 			try {
   582 				File crashFile = files[i];
   583 				final File crashFile = files[i];
   583 
   584 
   584 				String crashFolder = getNewCrashFolder();
   585 				final String crashFolder = getNewCrashFolder();
   585 
   586 
   586 				// copy crash file (.crashxml) to crash folder
   587 				// copy crash file (.crashxml) to crash folder
   587 				FileOperations.copyFile(crashFile, crashFolder, true);
   588 				FileOperations.copyFile(crashFile, crashFolder, true);
   588 
   589 
   589 				// try to copy the original binary file also to crash folder
   590 				// try to copy the original binary file also to crash folder
   590 				// (only mobilecrash, not D_EXC)
   591 				// (only mobilecrash, not D_EXC)
   591 				String binaryFile = SummaryFile.getSourceFilePath(crashFile
   592 				final String binaryFile = SummaryFile.getSourceFilePath(crashFile
   592 						.getAbsolutePath());
   593 						.getAbsolutePath());
   593 				if (!"".equals(binaryFile)
   594 				if (!"".equals(binaryFile)
   594 						&& binaryFile
   595 						&& binaryFile
   595 								.toLowerCase()
   596 								.toLowerCase()
   596 								.endsWith(
   597 								.endsWith(
   608 				}
   609 				}
   609 
   610 
   610 				// html and/or text page needs to be generated
   611 				// html and/or text page needs to be generated
   611 				if ((decodingData.html || decodingData.text)
   612 				if ((decodingData.html || decodingData.text)
   612 						&& decodingData.htmlTextOutputFolder != null) {
   613 						&& decodingData.htmlTextOutputFolder != null) {
   613 					CrashFile crashxml = CrashFile.read(crashFile,
   614 					final CrashFile crashxml = CrashFile.read(crashFile,
   614 							decodingData.errorLibrary);
   615 							decodingData.errorLibrary);
   615 					if (crashxml != null) {
   616 					if (crashxml != null) {
   616 						// create html/text file to the original folder where
   617 						// create html/text file to the original folder where
   617 						// file came from
   618 						// file came from
   618 						if ("".equals(decodingData.htmlTextOutputFolder)) {
   619 						if ("".equals(decodingData.htmlTextOutputFolder)) {
   619 							CrashFileBundle cfb = getCrashFileBundle(crashFile);
   620 							final CrashFileBundle cfb = getCrashFileBundle(crashFile);
   620 							if (cfb != null) {
   621 							if (cfb != null) {
   621 								if (decodingData.html)
   622 								if (decodingData.html)
   622 									crashxml.writeTo(cfb
   623 									crashxml.writeTo(cfb
   623 											.getOriginatingDirectory(), true);
   624 											.getOriginatingDirectory(), true);
   624 								if (decodingData.text)
   625 								if (decodingData.text)
   654 	 * 
   655 	 * 
   655 	 * @param workingFolder
   656 	 * @param workingFolder
   656 	 *            where files are to be decoded
   657 	 *            where files are to be decoded
   657 	 * @param monitor
   658 	 * @param monitor
   658 	 */
   659 	 */
   659 	void reDecodeCrashFiles(String workingFolder, IProgressMonitor monitor) {
   660 	void reDecodeCrashFiles(final String workingFolder, final IProgressMonitor monitor) {
   660 		if (crashFiles != null) {
   661 		if (crashFiles != null) {
   661 			List<String> filesToBeDecoded = new ArrayList<String>();
   662 			final List<String> filesToBeDecoded = new ArrayList<String>();
   662 			// collect all binary file paths
   663 			// collect all binary file paths
   663 			for (int i = 0; i < crashFiles.size(); i++) {
   664 			for (int i = 0; i < crashFiles.size(); i++) {
   664 				CrashFileBundle crashFile = crashFiles.get(i);
   665 				final CrashFileBundle crashFile = crashFiles.get(i);
   665 				UndecodedFile udf = crashFile.getUndecodedFile();
   666 				final UndecodedFile udf = crashFile.getUndecodedFile();
   666 				filesToBeDecoded.add(udf.getFilePath());
   667 				filesToBeDecoded.add(udf.getFilePath());
   667 			}
   668 			}
   668 
   669 
   669 			if (!filesToBeDecoded.isEmpty()) {
   670 			if (!filesToBeDecoded.isEmpty()) {
   670 				String mapFilesFolder = decodingData.mapFilesFolder;
   671 				String mapFilesFolder = decodingData.mapFilesFolder;
   671 
   672 
   672 				// if MapFiles.zip is provided
   673 				// if MapFiles.zip is provided
   673 				if (mapFilesFolder != null && "".equals(mapFilesFolder)
   674 				if (mapFilesFolder != null && "".equals(mapFilesFolder)
   674 						&& decodingData.mapFilesZip != null
   675 						&& decodingData.mapFilesZip != null
   675 						&& !"".equals(decodingData.mapFilesZip)) {
   676 						&& !"".equals(decodingData.mapFilesZip)) {
   676 					String zipFolder = FileOperations
   677 					final String zipFolder = FileOperations
   677 							.addSlashToEnd(workingFolder)
   678 							.addSlashToEnd(workingFolder)
   678 							+ FileOperations
   679 							+ FileOperations
   679 									.addSlashToEnd(MAP_FILES_ZIP_FOLDER);
   680 									.addSlashToEnd(MAP_FILES_ZIP_FOLDER);
   680 					FileOperations.createFolder(zipFolder, true);
   681 					FileOperations.createFolder(zipFolder, true);
   681 					FileOperations.unZipFiles(
   682 					FileOperations.unZipFiles(
   698 	 * under CrashFiles folder
   699 	 * under CrashFiles folder
   699 	 * 
   700 	 * 
   700 	 * @param workingFolder
   701 	 * @param workingFolder
   701 	 *            from where decoded files are moved from
   702 	 *            from where decoded files are moved from
   702 	 */
   703 	 */
   703 	CrashFile moveReDecodedFiles(String workingFolder) {
   704 	CrashFile moveReDecodedFiles(final String workingFolder) {
   704 		CrashFile cafile = null;
   705 		CrashFile cafile = null;
   705 		File folder = new File(workingFolder);
   706 		final File folder = new File(workingFolder);
   706 
   707 
   707 		// accept output files (.crashxml)
   708 		// accept output files (.crashxml)
   708 		FilenameFilter filter = new FilenameFilter() {
   709 		final FilenameFilter filter = new FilenameFilter() {
   709 			public boolean accept(File dir, String name) {
   710 			public boolean accept(final File dir, final String name) {
   710 				return (name.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION));
   711 				return (name.endsWith(CrashAnalyserFile.OUTPUT_FILE_EXTENSION));
   711 			}
   712 			}
   712 		};
   713 		};
   713 
   714 
   714 		File[] files = folder.listFiles(filter);
   715 		final File[] files = folder.listFiles(filter);
   715 
   716 
   716 		// go through all found files
   717 		// go through all found files
   717 		for (int i = 0; i < files.length; i++) {
   718 		for (int i = 0; i < files.length; i++) {
   718 			try {
   719 			try {
   719 				File crashFile = files[i];
   720 				final File crashFile = files[i];
   720 
   721 
   721 				CrashFileBundle cfb = getCrashFileBundle(crashFile);
   722 				final CrashFileBundle cfb = getCrashFileBundle(crashFile);
   722 				if (cfb == null)
   723 				if (cfb == null)
   723 					continue;
   724 					continue;
   724 
   725 
   725 				String crashFolder = FileOperations.addSlashToEnd(cfb
   726 				final String crashFolder = FileOperations.addSlashToEnd(cfb
   726 						.getOriginatingDirectory());
   727 						.getOriginatingDirectory());
   727 				File fCrashFolder = new File(crashFolder);
   728 				final File fCrashFolder = new File(crashFolder);
   728 
   729 
   729 				// folder should exist
   730 				// folder should exist
   730 				if (!fCrashFolder.exists())
   731 				if (!fCrashFolder.exists())
   731 					continue;
   732 					continue;
   732 
   733 
   733 				// copy crash file (.crashxml) to crash folder
   734 				// copy crash file (.crashxml) to crash folder
   734 				if (FileOperations.copyFile(crashFile, crashFolder, true)) {
   735 				if (FileOperations.copyFile(crashFile, crashFolder, true)) {
   735 					String[] crashFolderFiles = fCrashFolder.list();
   736 					final String[] crashFolderFiles = fCrashFolder.list();
   736 
   737 
   737 					// if only one file was decoded, pass this file eventually
   738 					// if only one file was decoded, pass this file eventually
   738 					// to MainView so that this file can be opened up after decoding.
   739 					// to MainView so that this file can be opened up after decoding.
   739 					if (files.length == 1) {
   740 					if (files.length == 1) {
   740 						cafile = CrashFile.read(crashFolder,
   741 						cafile = CrashFile.read(crashFolder,
   743 
   744 
   744 					// remove .html and .xml files from crash folder if they
   745 					// remove .html and .xml files from crash folder if they
   745 					// exist
   746 					// exist
   746 					if (crashFolderFiles != null && crashFolderFiles.length > 0) {
   747 					if (crashFolderFiles != null && crashFolderFiles.length > 0) {
   747 						for (int j = 0; j < crashFolderFiles.length; j++) {
   748 						for (int j = 0; j < crashFolderFiles.length; j++) {
   748 							String crashFolderFile = crashFolderFiles[j];
   749 							final String crashFolderFile = crashFolderFiles[j];
   749 							if (crashFolderFile.toLowerCase().endsWith(
   750 							if (crashFolderFile.toLowerCase().endsWith(
   750 									CrashFileBundle.EXTENSION_HTML)
   751 									CrashFileBundle.EXTENSION_HTML)
   751 									|| crashFolderFile
   752 									|| crashFolderFile
   752 											.toLowerCase()
   753 											.toLowerCase()
   753 											.endsWith(
   754 											.endsWith(
   774 		toolsPath += TOOLS_FOLDER + File.separator;
   775 		toolsPath += TOOLS_FOLDER + File.separator;
   775 		return toolsPath;
   776 		return toolsPath;
   776 	}
   777 	}
   777 
   778 
   778 	@Override
   779 	@Override
   779 	protected IStatus run(IProgressMonitor monitor) {
   780 	protected IStatus run(final IProgressMonitor monitor) {
   780 		String workingFolder = "";
   781 		String workingFolder = "";
   781 		CrashAnalyserFile caFile = null;
   782 		CrashAnalyserFile caFile = null;
   782 		try {
   783 		try {
   783 			// we are importing files
   784 			// we are importing files
   784 			if (decodingData.importingFiles) {
   785 			if (decodingData.importingFiles) {