diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
index 7b0ddcda4f..493dfa5f66 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
@@ -158,6 +158,10 @@
org.wso2.carbon.identity.framework
org.wso2.carbon.user.mgt
+
+ commons-lang
+ commons-lang
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
index af07800f3d..38d5795626 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
@@ -87,6 +87,7 @@ public final class DeviceManagementConstants {
public static final class OperationAttributes {
private OperationAttributes() {throw new AssertionError(); }
public static final String ACTIVITY = "ACTIVITY_";
+ public static final int APPLIST_VERSION_MAX_LENGTH = 50;
}
public static final class PushNotifications {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java
index bf078a7b56..37ee12f054 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java
@@ -18,6 +18,7 @@
package org.wso2.carbon.device.mgt.core.app.mgt;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
@@ -31,6 +32,7 @@ import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
+import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.dao.ApplicationDAO;
import org.wso2.carbon.device.mgt.core.dao.ApplicationMappingDAO;
@@ -225,6 +227,14 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
List applicationIds = new ArrayList<>();
for (Application application : applications) {
+ /*
+ Truncating the application version if length of the version is greater than maximum allowed length.
+ */
+ if (application.getVersion().length() >
+ DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH) {
+ application.setVersion(StringUtils.abbreviate(application.getVersion(),
+ DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH));
+ }
if (!installedAppList.contains(application)) {
installedApp = applicationDAO.getApplication(application.getApplicationIdentifier(),
application.getVersion(), tenantId);