Fix stream corrupted exception for profile type operations

remotes/1727692234363924000/master
Lasantha Dharmakeerthi 4 months ago
commit ac9c7b1a38

@ -18,6 +18,7 @@
package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans;
import com.google.gson.Gson;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -113,4 +114,8 @@ public class ApplicationUninstallation {
public void setType(String type) {
this.type = type;
}
public String toJson() {
return new Gson().toJson(this);
}
}

@ -19,7 +19,6 @@
package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse;
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType;
import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException;
@ -44,6 +43,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
import io.entgra.device.mgt.core.device.mgt.common.*;
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application;
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException;
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.MobileAppTypes;
import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceData;
@ -1112,7 +1112,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@QueryParam("version") String version,
@QueryParam("user") String user) {
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
Operation operation = new Operation();
try {
RequestValidationUtil.validateDeviceIdentifier(type, id);
Device device = DeviceMgtAPIUtils.getDeviceManagementService().getDevice(id, false);
@ -1133,11 +1132,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
//if the applications not installed via entgra store
} else {
if (Constants.ANDROID.equals(type)) {
ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation(packageName, "PUBLIC", name, platform, version, user);
Gson gson = new Gson();
ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation(packageName,
MobileAppTypes.PUBLIC.toString(), name, platform, version, user);
ProfileOperation operation = new ProfileOperation();
operation.setCode(MDMAppConstants.AndroidConstants.UNMANAGED_APP_UNINSTALL);
operation.setType(Operation.Type.PROFILE);
operation.setPayLoad(gson.toJson(applicationUninstallation));
operation.setPayLoad(applicationUninstallation.toJson());
DeviceManagementProviderService deviceManagementProviderService = HelperUtil
.getDeviceManagementProviderService();
Activity activity = deviceManagementProviderService.addOperation(

Loading…
Cancel
Save