Example usage for com.liferay.portal.kernel.plugin Version getMajor

List of usage examples for com.liferay.portal.kernel.plugin Version getMajor

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.plugin Version getMajor.

Prototype

public String getMajor() 

Source Link

Usage

From source file:com.liferay.exportimport.internal.portlet.data.handler.helper.PortletDataHandlerHelperImpl.java

License:Open Source License

@Override
public boolean validateSchemaVersion(String schemaVersion, String portletSchemaVersion) {

    // Major version has to be identical

    Version currentVersion = Version.getInstance(portletSchemaVersion);
    Version importedVersion = Version.getInstance(schemaVersion);

    if (!Objects.equals(currentVersion.getMajor(), importedVersion.getMajor())) {

        return false;
    }/*from   ww w.  ja  v  a 2  s .com*/

    // Imported minor version should be less than or equal to the current
    // minor version

    int currentMinorVersion = GetterUtil.getInteger(currentVersion.getMinor(), -1);
    int importedMinorVersion = GetterUtil.getInteger(importedVersion.getMinor(), -1);

    if (((currentMinorVersion == -1) && (importedMinorVersion == -1))
            || (currentMinorVersion < importedMinorVersion)) {

        return false;
    }

    // Import should be compatible with all minor versions if previous
    // validations pass

    return true;
}