GT-2865: ApplicationIdentifer now removes spaces from application name

and release name.
This commit is contained in:
Ryan Kurtz 2019-05-23 12:22:09 -04:00
parent f9a1652974
commit c5fdf6f9ec
3 changed files with 11 additions and 8 deletions

View File

@ -59,7 +59,7 @@ public class ApplicationIdentifierTest extends AbstractGenericTest {
@Test
public void testApplicationIdentifierEquals() {
ApplicationIdentifier id1 = new ApplicationIdentifier("ghidra_9.0_public");
ApplicationIdentifier id1 = new ApplicationIdentifier("ghi dra_9.0_pub lic");
ApplicationIdentifier id2 = new ApplicationIdentifier("Ghidra_9.0.0_PUBLIC");
assertEquals(id1, id2);

View File

@ -23,7 +23,7 @@ package ghidra.framework;
* name version release name
* </pre>
* Application names will be converted to all lowercase and application release names will be
* converted to all uppercase.
* converted to all uppercase. Both will have spaces removed from their names.
* <p>
* Examples:
* <li>ghidra-7.4_DEV
@ -44,14 +44,16 @@ public class ApplicationIdentifier {
*/
public ApplicationIdentifier(ApplicationProperties applicationProperties)
throws IllegalArgumentException {
applicationName = applicationProperties.getApplicationName().toLowerCase();
applicationName =
applicationProperties.getApplicationName().replaceAll("\\s", "").toLowerCase();
if (applicationName.isEmpty()) {
throw new IllegalArgumentException("Application name is undefined.");
}
applicationVersion = new ApplicationVersion(applicationProperties.getApplicationVersion());
applicationReleaseName = applicationProperties.getApplicationReleaseName().toUpperCase();
applicationReleaseName =
applicationProperties.getApplicationReleaseName().replaceAll("\\s", "").toUpperCase();
if (applicationReleaseName.isEmpty()) {
throw new IllegalArgumentException("Application release name is undefined.");
}
@ -144,9 +146,9 @@ public class ApplicationIdentifier {
String[] identifierParts = identifier.split("_");
if (identifierParts.length >= 3) {
applicationName = identifierParts[0].toLowerCase();
applicationName = identifierParts[0].replaceAll("\\s", "").toLowerCase();
applicationVersion = new ApplicationVersion(identifierParts[1]);
applicationReleaseName = identifierParts[2].toUpperCase();
applicationReleaseName = identifierParts[2].replaceAll("\\s", "").toUpperCase();
// Ignore any parts after the release name...they are not part of the identifier
}
else {

View File

@ -352,10 +352,11 @@ public class JavaConfig {
}
// Get the java home save file from user home directory (it might not exist yet).
File userSettingsParentDir = new File(userHomeDir, "." + applicationName.toLowerCase());
File userSettingsParentDir =
new File(userHomeDir, "." + applicationName.replaceAll("\\s", "").toLowerCase());
String userSettingsDirName = userSettingsParentDir.getName() + "_" + applicationVersion +
"_" + applicationReleaseName.toUpperCase();
"_" + applicationReleaseName.replaceAll("\\s", "").toUpperCase();
if (isDev) {
userSettingsDirName += "_location_" + installDir.getParentFile().getName();