org.alfresco.util.VersionNumber Java Examples
The following examples show how to use
org.alfresco.util.VersionNumber.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModuleComponentHelperTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testgetModuleVersionNumber() { ModuleVersionNumber moduleVersion = new ModuleVersionNumber("3.5"); VersionNumber versNumber = new VersionNumber("3.5"); assertEquals(moduleVersion, helper.getModuleVersionNumber(moduleVersion)); assertEquals(moduleVersion, helper.getModuleVersionNumber(versNumber)); try { helper.getModuleVersionNumber(null); assertTrue(false); //should never get here } catch (ModuleManagementToolException e) { //should get here } // try { // helper.getModuleVersionNumber("any object"); // assertTrue(false); //should never get here // } catch (ModuleManagementToolException e) { // //should get here // } // assertTrue(true); }
Example #2
Source File: ModuleDetailsImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public VersionNumber getVersion() { // lossy translation between maven version and old VersionNumber String mavenVersion = version.toString(); StringBuffer b = new StringBuffer(); for(int i = 0; i < mavenVersion.length(); i++) { char c = mavenVersion.charAt(i); if(Character.isDigit(c) || c == '.') { b.append(c); } } return new VersionNumber(b.toString()); }
Example #3
Source File: WarHelperImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void checkCompatibleVersion(TFile war, ModuleDetails installingModuleDetails) { //Version check TFile propsFile = new TFile(war+VERSION_PROPERTIES); if (propsFile != null && propsFile.exists()) { log.info("INFO: Checking the war version using "+VERSION_PROPERTIES); Properties warVers = loadProperties(propsFile); VersionNumber warVersion = new VersionNumber(warVers.getProperty("version.major")+"."+warVers.getProperty("version.minor")+"."+warVers.getProperty("version.revision")); checkVersions(warVersion, installingModuleDetails); } else { log.info("INFO: Checking the war version using the manifest."); checkCompatibleVersionUsingManifest(war,installingModuleDetails); } }
Example #4
Source File: ImageMagickContentTransformerWorker.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private static boolean isAlphaOptionSupported(String versionString) { // the "-alpha" option was only introduced in ImageMagick v6.7.5 and will fail in older versions. String ALPHA_PROP_SUPPORTED_VERSION = "6.7.5"; try { VersionNumber supportedVersion = new VersionNumber(ALPHA_PROP_SUPPORTED_VERSION); VersionNumber checkedVersion = new VersionNumber(getImageMagickVersionNumber(versionString)); return supportedVersion.compareTo(checkedVersion) > 0 ? false : true; } catch (Exception e) { logger.warn("Could not extract version of ImageMagick. Alpha-compatibility will be disabled: " + e.getMessage()); } return false; }
Example #5
Source File: DescriptorServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public VersionNumber getVersionNumber() { if (this.versionNumber == null) { StringBuilder version = new StringBuilder(); version.append(getVersionMajor()); version.append("."); version.append(getVersionMinor()); version.append("."); version.append(getVersionRevision()); this.versionNumber = new VersionNumber(version.toString()); } return this.versionNumber; }
Example #6
Source File: ModuleComponentHelperTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private DummyModuleComponent(String moduleId, String name, VersionNumber from, VersionNumber to) { super.setServiceRegistry(serviceRegistry); super.setAuthenticationComponent(authenticationComponent); super.setModuleService(moduleService); super.setTenantAdminService(tenantAdminService); super.setModuleId(moduleId); super.setName(name); super.setAppliesFromVersion(from.toString()); super.setAppliesToVersion(to.toString()); super.setSinceVersion("10.1.2"); super.setDescription("A dummy module component"); }
Example #7
Source File: WarHelperImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Checks if the module is compatible using the entry in the manifest. This is more accurate and works for both alfresco.war and share.war, however * valid manifest entries weren't added until 3.4.11, 4.1.1 and Community 4.2 * @param war TFile * @param installingModuleDetails ModuleDetails */ protected void checkCompatibleVersionUsingManifest(TFile war, ModuleDetails installingModuleDetails) { String version = findManifestArtibute(war, MANIFEST_SPECIFICATION_VERSION); if (version != null && version.length() > 0) { if (version.matches(REGEX_NUMBER_OR_DOT)) { VersionNumber warVersion = new VersionNumber(version); checkVersions(warVersion, installingModuleDetails); } else { //A non-numeric version number. Currently our VersionNumber class doesn't support Strings in the version String edition = findManifestArtibute(war, MANIFEST_IMPLEMENTATION_TITLE); if (edition.endsWith(MANIFEST_COMMUNITY)) { //If it's a community version, so don't worry about it log.info("WARNING: Community edition war detected, the version number is non-numeric so we will not validate it."); } else { throw new ModuleManagementToolException("Invalid version number specified: "+ version); } } } 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 ?"); } }
Example #8
Source File: WarHelperImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Compares the version information with the module details to see if their valid. If they are invalid then it throws an exception. * @param warVersion VersionNumber * @param installingModuleDetails ModuleDetails * @throws ModuleManagementToolException */ private void checkVersions(VersionNumber warVersion, ModuleDetails installingModuleDetails) throws ModuleManagementToolException { if(warVersion.compareTo(installingModuleDetails.getRepoVersionMin())==-1) { throw new ModuleManagementToolException("The module ("+installingModuleDetails.getTitle()+") must be installed on a war version equal to or greater than " +installingModuleDetails.getRepoVersionMin()+". This war is version: "+warVersion+"."); } if(warVersion.compareTo(installingModuleDetails.getRepoVersionMax())==1) { throw new ModuleManagementToolException("The module ("+installingModuleDetails.getTitle()+") cannot be installed on a war version greater than " +installingModuleDetails.getRepoVersionMax()+". This war is version: "+warVersion+"."); } }
Example #9
Source File: WarHelperImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testNoVersionProperties() { TFile theWar = getFile(".war", "module/empty.war"); ModuleDetails installingModuleDetails = new ModuleDetailsImpl("test_it", new ModuleVersionNumber("9999"), "Test Mod", "Testing module"); installingModuleDetails.setRepoVersionMin(new VersionNumber("10.1")); this.checkCompatibleVersion(theWar, installingModuleDetails); //does not throw exception this.checkCompatibleEdition(theWar, installingModuleDetails); //does not throw exception }
Example #10
Source File: ModuleComponentHelper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
protected ModuleVersionNumber getModuleVersionNumber(Serializable moduleVersion) { if (moduleVersion instanceof ModuleVersionNumber) return (ModuleVersionNumber) moduleVersion; if (moduleVersion instanceof VersionNumber) return new ModuleVersionNumber((VersionNumber)moduleVersion); if (moduleVersion instanceof String) return new ModuleVersionNumber((String)moduleVersion); throw new ModuleManagementToolException("Invalid moduleVersion"); }
Example #11
Source File: SerialVersionLabelPolicy.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Constructor * * @param versionLabel the vesion label to take the version from */ public SerialVersionLabel(String versionLabel) { if (versionLabel != null && versionLabel.length() != 0) { VersionNumber versionNumber = new VersionNumber(versionLabel); majorRevisionNumber = versionNumber.getPart(0); minorRevisionNumber = versionNumber.getPart(1); } else { majorRevisionNumber = 0; minorRevisionNumber = 0; } }
Example #12
Source File: VersionLabelComparator.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public int compare(Version version1, Version version2) { String labelV1 = version1.getVersionLabel(); String labelV2 = version2.getVersionLabel(); // sort the list descending (ie. most recent first) return new VersionNumber(labelV2).compareTo(new VersionNumber(labelV1)); }
Example #13
Source File: ModuleDetailsImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Private constructor to set default values. */ private ModuleDetailsImpl() { aliases = new ArrayList<String>(0); repoVersionMin = VersionNumber.VERSION_ZERO; repoVersionMax = VersionNumber.VERSION_BIG; dependencies = new ArrayList<ModuleDependency>(0); this.installState = ModuleInstallState.UNKNOWN; }
Example #14
Source File: NodePropertyValue.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Determine the actual value type to aid in more concise persistence. * * @param value the value that is to be persisted * @return Returns the value type equivalent of the */ private static ValueType getActualType(Serializable value) { if (value == null) { return ValueType.NULL; } else if (value instanceof Boolean) { return ValueType.BOOLEAN; } else if (value instanceof Integer) { return ValueType.INTEGER; } else if (value instanceof Long) { return ValueType.LONG; } else if (value instanceof Float) { return ValueType.FLOAT; } else if (value instanceof Double) { return ValueType.DOUBLE; } else if (value instanceof String) { return ValueType.STRING; } else if (value instanceof Date) { return ValueType.DATE; } else if (value instanceof NodeRef) { return ValueType.NODEREF; } else if (value instanceof ChildAssociationRef) { return ValueType.CHILD_ASSOC_REF; } else if (value instanceof AssociationRef) { return ValueType.ASSOC_REF; } else if (value instanceof QName) { return ValueType.QNAME; } else if (value instanceof Path) { return ValueType.PATH; } else if (value instanceof Locale) { return ValueType.LOCALE; } else if (value instanceof VersionNumber) { return ValueType.VERSION_NUMBER; } else if (value instanceof Period) { return ValueType.PERIOD; } else if (value instanceof ContentDataId) { return ValueType.CONTENT_DATA_ID; } else if (value instanceof ContentDataWithId) { return ValueType.CONTENT_DATA_ID; } else if (value instanceof ContentData) { return ValueType.CONTENT; } else if (value instanceof SealedObject) { return ValueType.SEALED_OBJECT; } else { // type is not recognised as belonging to any particular slot return ValueType.SERIALIZABLE; } }
Example #15
Source File: DescriptorServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @return <b>0.0.0</b> always */ public VersionNumber getVersionNumber() { return new VersionNumber("0.0.0"); }
Example #16
Source File: DefaultTypeConverterTest.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 4 votes |
public void testToString() { assertEquals("true", DefaultTypeConverter.INSTANCE.convert(String.class, new Boolean(true))); assertEquals("false", DefaultTypeConverter.INSTANCE.convert(String.class, new Boolean(false))); assertEquals("v", DefaultTypeConverter.INSTANCE.convert(String.class, Character.valueOf('v'))); assertEquals("3", DefaultTypeConverter.INSTANCE.convert(String.class, Byte.valueOf("3"))); assertEquals("4", DefaultTypeConverter.INSTANCE.convert(String.class, Short.valueOf("4"))); assertEquals("5", DefaultTypeConverter.INSTANCE.convert(String.class, Integer.valueOf("5"))); assertEquals("6", DefaultTypeConverter.INSTANCE.convert(String.class, Long.valueOf("6"))); assertEquals("7.1", DefaultTypeConverter.INSTANCE.convert(String.class, Float.valueOf("7.1"))); assertEquals("NaN", DefaultTypeConverter.INSTANCE.convert(String.class, Float.NaN)); assertEquals("-Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Float.NEGATIVE_INFINITY)); assertEquals("Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Float.POSITIVE_INFINITY)); assertEquals("123.123", DefaultTypeConverter.INSTANCE.convert(String.class, Double.valueOf("123.123"))); assertEquals("NaN", DefaultTypeConverter.INSTANCE.convert(String.class, Double.NaN)); assertEquals("-Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Double.NEGATIVE_INFINITY)); assertEquals("Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Double.POSITIVE_INFINITY)); assertEquals("1234567890123456789", DefaultTypeConverter.INSTANCE.convert(String.class, new BigInteger("1234567890123456789"))); assertEquals("12345678901234567890.12345678901234567890", DefaultTypeConverter.INSTANCE.convert(String.class, new BigDecimal("12345678901234567890.12345678901234567890"))); Date date = new Date(); assertEquals(ISO8601DateFormat.format(date), DefaultTypeConverter.INSTANCE.convert(String.class, date)); assertEquals("P0Y25D", DefaultTypeConverter.INSTANCE.convert(String.class, new Duration("P0Y25D"))); assertEquals("woof", DefaultTypeConverter.INSTANCE.convert(String.class, "woof")); // MLText MLText mlText = new MLText("woof"); mlText.addValue(Locale.SIMPLIFIED_CHINESE, "缂"); assertEquals("woof", DefaultTypeConverter.INSTANCE.convert(String.class, mlText)); // Locale assertEquals("fr_FR_", DefaultTypeConverter.INSTANCE.convert(String.class, Locale.FRANCE)); // VersionNumber assertEquals("1.2.3", DefaultTypeConverter.INSTANCE.convert(String.class, new VersionNumber("1.2.3"))); // Period assertEquals("period", DefaultTypeConverter.INSTANCE.convert(String.class, new Period("period"))); assertEquals("period|12", DefaultTypeConverter.INSTANCE.convert(String.class, new Period("period|12"))); Map<String,String> periodMap = new HashMap<>(); periodMap.put("periodType","month"); periodMap.put("expression","1"); assertEquals(new Period("month|1"), DefaultTypeConverter.INSTANCE.convert(Period.class, new Period(periodMap))); // Java Class assertEquals(this.getClass(), DefaultTypeConverter.INSTANCE.convert(Class.class, this.getClass().getName())); }
Example #17
Source File: DefaultTypeConverterTest.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 4 votes |
public void testFromString() { assertEquals(Boolean.valueOf(true), DefaultTypeConverter.INSTANCE.convert(Boolean.class, "True")); assertEquals(Boolean.valueOf(false), DefaultTypeConverter.INSTANCE.convert(Boolean.class, "woof")); assertEquals(Character.valueOf('w'), DefaultTypeConverter.INSTANCE.convert(Character.class, "w")); assertEquals(Byte.valueOf("3"), DefaultTypeConverter.INSTANCE.convert(Byte.class, "3")); assertEquals(Short.valueOf("4"), DefaultTypeConverter.INSTANCE.convert(Short.class, "4")); assertEquals(Integer.valueOf("5"), DefaultTypeConverter.INSTANCE.convert(Integer.class, "5")); assertEquals(Long.valueOf("6"), DefaultTypeConverter.INSTANCE.convert(Long.class, "6")); assertEquals(Float.valueOf("7.1"), DefaultTypeConverter.INSTANCE.convert(Float.class, "7.1")); assertEquals(Float.NaN, DefaultTypeConverter.INSTANCE.convert(Float.class, "NaN")); assertEquals(Float.NEGATIVE_INFINITY, DefaultTypeConverter.INSTANCE.convert(Float.class, "-Infinity")); assertEquals(Float.POSITIVE_INFINITY, DefaultTypeConverter.INSTANCE.convert(Float.class, "Infinity")); assertEquals(Double.valueOf("123.123"), DefaultTypeConverter.INSTANCE.convert(Double.class, "123.123")); assertEquals(Double.NaN, DefaultTypeConverter.INSTANCE.convert(Double.class, "NaN")); assertEquals(Double.NEGATIVE_INFINITY, DefaultTypeConverter.INSTANCE.convert(Double.class, "-Infinity")); assertEquals(Double.POSITIVE_INFINITY, DefaultTypeConverter.INSTANCE.convert(Double.class, "Infinity")); assertEquals(new BigInteger("1234567890123456789"), DefaultTypeConverter.INSTANCE.convert(BigInteger.class, "1234567890123456789")); assertEquals(new BigDecimal("12345678901234567890.12345678901234567890"), DefaultTypeConverter.INSTANCE.convert(BigDecimal.class, "12345678901234567890.12345678901234567890")); GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, 3); cal.set(Calendar.DAY_OF_MONTH, 12); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); String isoDate = ISO8601DateFormat.format(cal.getTime()); assertEquals(isoDate, ISO8601DateFormat.format(DefaultTypeConverter.INSTANCE.convert(Date.class, isoDate))); assertEquals(new Duration("P25D"), DefaultTypeConverter.INSTANCE.convert(Duration.class, "P25D")); assertEquals("woof", DefaultTypeConverter.INSTANCE.convert(String.class, "woof")); MLText converted = DefaultTypeConverter.INSTANCE.convert(MLText.class, "woof"); assertEquals("woof", converted.getValue(Locale.getDefault())); assertEquals(Locale.FRANCE, DefaultTypeConverter.INSTANCE.convert(Locale.class, "fr_FR")); assertEquals(Locale.FRANCE, DefaultTypeConverter.INSTANCE.convert(Locale.class, "fr_FR_")); assertEquals(new VersionNumber("1.2.3"), DefaultTypeConverter.INSTANCE.convert(VersionNumber.class, "1.2.3")); assertEquals(new Period("period"), DefaultTypeConverter.INSTANCE.convert(Period.class, "period")); assertEquals(new Period("period|12"), DefaultTypeConverter.INSTANCE.convert(Period.class, "period|12")); Map<String,String> periodMap = new HashMap<String, String>(); periodMap.put("periodType","month"); periodMap.put("expression","1"); assertEquals(new Period(periodMap), DefaultTypeConverter.INSTANCE.convert(Period.class, periodMap)); // Java Class assertEquals(this.getClass().getName(), DefaultTypeConverter.INSTANCE.convert(String.class, this.getClass())); }
Example #18
Source File: NodePropertyValue.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override Serializable convert(Serializable value) { return DefaultTypeConverter.INSTANCE.convert(VersionNumber.class, value); }
Example #19
Source File: ModuleVersionNumber.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public ModuleVersionNumber(VersionNumber versionCurrent) { this(versionCurrent.toString()); }
Example #20
Source File: ModuleDetailsImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void setRepoVersionMax(VersionNumber repoVersionMax) { this.repoVersionMax = repoVersionMax; }
Example #21
Source File: ModuleDetailsImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public VersionNumber getRepoVersionMax() { return repoVersionMax; }
Example #22
Source File: ModuleDetailsImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void setRepoVersionMin(VersionNumber repoVersionMin) { this.repoVersionMin = repoVersionMin; }
Example #23
Source File: ModuleDetailsImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public VersionNumber getRepoVersionMin() { return repoVersionMin; }
Example #24
Source File: ModuleDetails.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * Get the version number of the module * * @return module version number * @deprecated use getModuleVersionNumber which knows about maven style version numbers */ VersionNumber getVersion();
Example #25
Source File: ModuleDetails.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * @return Returns the minimum version of the repository in which the module may be active */ VersionNumber getRepoVersionMin();
Example #26
Source File: ModuleDetails.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * @param repoVersionMin the minimum version of the repository in which the module may be acitve */ void setRepoVersionMin(VersionNumber repoVersionMin);
Example #27
Source File: ModuleDetails.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * @return Returns the maximum version of the repository in which the module may be active */ VersionNumber getRepoVersionMax();
Example #28
Source File: ModuleDetails.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * @param repoVersionMax the maximum version of the repository in which the module may be acitve */ void setRepoVersionMax(VersionNumber repoVersionMax);
Example #29
Source File: Descriptor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 2 votes |
/** * @return Returns the object representing the major-minor-revision numbers */ public VersionNumber getVersionNumber();