Removed dependency on commons StringUtils and cleaned up the warning message

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42716 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gethin James
2012-10-17 11:47:02 +00:00
parent 12dfc4785d
commit 5c6e93521c
2 changed files with 33 additions and 8 deletions

View File

@@ -13,7 +13,6 @@ import org.alfresco.repo.module.ModuleDetailsImpl;
import org.alfresco.service.cmr.module.ModuleDependency;
import org.alfresco.service.cmr.module.ModuleDetails;
import org.alfresco.util.VersionNumber;
import org.apache.commons.lang.StringUtils;
import de.schlichtherle.truezip.file.TFile;
import de.schlichtherle.truezip.file.TFileInputStream;
@@ -36,6 +35,7 @@ public class WarHelperImpl implements WarHelper
public static final String MANIFEST_SHARE = "Alfresco Share";
public static final String MANIFEST_COMMUNITY = "Community";
protected static final String REGEX_NUMBER_OR_DOT = "[0-9\\.]*";
private LogOutput log = null;
@@ -72,9 +72,9 @@ public class WarHelperImpl implements WarHelper
protected void checkCompatibleVersionUsingManifest(TFile war, ModuleDetails installingModuleDetails)
{
String version = findManifestArtibute(war, MANIFEST_SPECIFICATION_VERSION);
if (StringUtils.isNotBlank(version))
{
if (StringUtils.containsOnly(version, "0123456789.")) {
if (version != null && version.length() > 0)
{
if (version.matches(REGEX_NUMBER_OR_DOT)) {
VersionNumber warVersion = new VersionNumber(version);
checkVersions(warVersion, installingModuleDetails);
}
@@ -93,7 +93,11 @@ public class WarHelperImpl implements WarHelper
}
}
}
}
else
{
log.info("WARNING: No version information detected in war, therefore version validation is disabled, continuing anyway. Is this war prior to 3.4.11, 4.1.1 and Community 4.2 ?");
}
}
/**
@@ -158,7 +162,7 @@ public class WarHelperImpl implements WarHelper
throw new ModuleManagementToolException("The module ("+installingModuleDetails.getTitle()
+") can only be installed in one of the following editions"+installableEditions);
} else {
log.info("No valid editions found, is this a share war?");
checkCompatibleEditionUsingManifest(war,installingModuleDetails);
}
}
}
@@ -177,7 +181,7 @@ public class WarHelperImpl implements WarHelper
if (installableEditions != null && installableEditions.size() > 0) {
String warEdition = findManifestArtibute(war, MANIFEST_IMPLEMENTATION_TITLE);
if (StringUtils.isNotBlank(warEdition))
if (warEdition != null && warEdition.length() > 0)
{
warEdition = warEdition.toLowerCase();
for (String edition : installableEditions)
@@ -190,7 +194,7 @@ public class WarHelperImpl implements WarHelper
throw new ModuleManagementToolException("The module ("+installingModuleDetails.getTitle()
+") can only be installed in one of the following editions"+installableEditions);
} else {
log.info("No valid editions found in the manifest. Is this war prior to 3.4.11, 4.1.1 and Community 4.2 ?");
log.info("WARNING: No edition information detected in war, edition validation is disabled, continuing anyway. Is this war prior to 3.4.11, 4.1.1 and Community 4.2 ?");
}
}
}

View File

@@ -37,6 +37,27 @@ public class WarHelperImplTest extends WarHelperImpl
});
}
@Test
public void testRegEx()
{
String x = "1";
assertTrue(x.matches(REGEX_NUMBER_OR_DOT));
x = "king";
assertFalse(x.matches(REGEX_NUMBER_OR_DOT));
x = "2.5.a";
assertFalse(x.matches(REGEX_NUMBER_OR_DOT));
x = "1.2.5";
assertTrue(x.matches(REGEX_NUMBER_OR_DOT));
x = "123";
assertTrue(x.matches(REGEX_NUMBER_OR_DOT));
x = "3.4.11";
assertTrue(x.matches(REGEX_NUMBER_OR_DOT));
x = "4.1.1";
assertTrue(x.matches(REGEX_NUMBER_OR_DOT));
x = "4.2.b";
assertFalse(x.matches(REGEX_NUMBER_OR_DOT));
}
@Test
public void testCheckCompatibleVersion()
{