1 7 package org.jahia.security.license; 8 9 import org.jahia.utils.Version; 10 import org.jahia.resourcebundle.ResourceMessage; 11 12 18 public class VersionValidator extends AbstractValidator { 19 20 protected Version internalVersion = new Version("1.0"); 21 22 public VersionValidator(String name, String value, License license) { 23 super(name, value, license); 24 } 25 26 public boolean assertEquals(String value) { 27 Version licenseVersion = new Version(value); 28 if (licenseVersion.equals(internalVersion)) { 29 return true; 30 } else { 31 errorMessage = new ResourceMessage("org.jahia.security.license.VersionValidator.invalidVersion.label", internalVersion, value); 32 return false; 33 } 34 } 35 36 public boolean assertInRange(String fromValue, String toValue) { 37 Version fromVersion = new Version(fromValue); 38 Version toVersion = new Version(toValue); 39 if ((fromVersion.compareTo(internalVersion) <= 0) && 40 (toVersion.compareTo(internalVersion) > 0)) { 41 return true; 42 } 43 errorMessage = new ResourceMessage("org.jahia.security.license.VersionValidator.versionNotInRange.label", internalVersion, fromValue, toValue); 44 return false; 45 } 46 47 } 48 | Popular Tags |