Add app details for UNMANAGED_APP_UNINSTALL

Bug#10236#issue36
osh 1 year ago
parent 5f5ac9d5ab
commit 1fed47e8fd

@ -41,6 +41,14 @@ public class ApplicationUninstallation {
@Pattern(regexp = "^[A-Za-z]*$") @Pattern(regexp = "^[A-Za-z]*$")
String type; String type;
String name;
String platform;
String version;
String user;
public ApplicationUninstallation() { public ApplicationUninstallation() {
} }
@ -49,6 +57,47 @@ public class ApplicationUninstallation {
this.type = type; this.type = type;
} }
public ApplicationUninstallation(String appIdentifier, String type, String name, String platform, String version, String user) {
this.appIdentifier = appIdentifier;
this.type = type;
this.name = name;
this.platform = platform;
this.version = version;
this.user = user;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getAppIdentifier() { public String getAppIdentifier() {
return appIdentifier; return appIdentifier;
} }

@ -1657,7 +1657,31 @@ public interface DeviceManagementService {
value = "The package name of the app user want to uninstall", value = "The package name of the app user want to uninstall",
required = true) required = true)
@QueryParam("packageName") @QueryParam("packageName")
String packageName); String packageName,
@ApiParam(
name = "platform",
value = "The platform of the app user want to uninstall",
required = false)
@QueryParam("platform")
String platform,
@ApiParam(
name = "name",
value = "The name of the app user want to uninstall",
required = false)
@QueryParam("name")
String name,
@ApiParam(
name = "version",
value = "The version of the app user want to uninstall",
required = false)
@QueryParam("version")
String version,
@ApiParam(
name = "user",
value = "The user who triggered the app uninstall",
required = false)
@QueryParam("user")
String user);
@GET @GET
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)

@ -981,7 +981,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
public Response uninstallation( public Response uninstallation(
@PathParam("type") @Size(max = 45) String type, @PathParam("type") @Size(max = 45) String type,
@PathParam("id") @Size(max = 45) String id, @PathParam("id") @Size(max = 45) String id,
@QueryParam("packageName") String packageName) { @QueryParam("packageName") String packageName,
@QueryParam("platform") String platform,
@QueryParam("name") String name,
@QueryParam("version") String version,
@QueryParam("user") String user) {
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>(); List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
Operation operation = new Operation(); Operation operation = new Operation();
try { try {
@ -1004,7 +1008,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
//if the applications not installed via entgra store //if the applications not installed via entgra store
} else { } else {
if (Constants.ANDROID.equals(type)) { if (Constants.ANDROID.equals(type)) {
ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation(packageName, "PUBLIC"); ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation(packageName, "PUBLIC", name, platform, version, user);
Gson gson = new Gson(); Gson gson = new Gson();
operation.setCode(MDMAppConstants.AndroidConstants.UNMANAGED_APP_UNINSTALL); operation.setCode(MDMAppConstants.AndroidConstants.UNMANAGED_APP_UNINSTALL);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);

@ -17,6 +17,8 @@
*/ */
package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl;
import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants;
import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ProfileOperation;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
@ -41,6 +43,8 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util.Operatio
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.ByteArrayInputStream;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -1353,6 +1357,9 @@ public class GenericOperationDAOImpl implements OperationDAO {
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
String createdTo = null; String createdTo = null;
String createdFrom = null; String createdFrom = null;
ByteArrayInputStream bais;
ObjectInputStream ois;
ProfileOperation profileOperation = null;
DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
boolean isCreatedDayProvided = false; boolean isCreatedDayProvided = false;
boolean isUpdatedDayProvided = false; //updated day = received day boolean isUpdatedDayProvided = false; //updated day = received day
@ -1375,6 +1382,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
"o.RECEIVED_TIMESTAMP, " + "o.RECEIVED_TIMESTAMP, " +
"o.OPERATION_CODE, " + "o.OPERATION_CODE, " +
"o.INITIATED_BY, " + "o.INITIATED_BY, " +
"o.OPERATION_DETAILS, " +
"om.STATUS, " + "om.STATUS, " +
"om.ID AS OM_MAPPING_ID, " + "om.ID AS OM_MAPPING_ID, " +
"om.UPDATED_TIMESTAMP " + "om.UPDATED_TIMESTAMP " +
@ -1473,10 +1481,21 @@ public class GenericOperationDAOImpl implements OperationDAO {
} }
operation.setCode(rs.getString("OPERATION_CODE")); operation.setCode(rs.getString("OPERATION_CODE"));
operation.setInitiatedBy(rs.getString("INITIATED_BY")); operation.setInitiatedBy(rs.getString("INITIATED_BY"));
if (MDMAppConstants.AndroidConstants.UNMANAGED_APP_UNINSTALL.equals(operation.getCode())) {
byte[] operationDetails = rs.getBytes("OPERATION_DETAILS");
bais = new ByteArrayInputStream(operationDetails);
ois = new ObjectInputStream(bais);
profileOperation = (ProfileOperation) ois.readObject();
operation.setPayLoad(profileOperation.getPayLoad());
}
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
OperationDAOUtil.setActivityId(operation, rs.getInt("ID")); OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
operations.add(operation); operations.add(operation);
} }
} catch (IOException e) {
throw new OperationManagementDAOException("IO Error occurred while retrieving app data of operation ", e);
} catch (ClassNotFoundException e) {
throw new OperationManagementDAOException("Class not found error occurred while retrieving app data of operation ", e);
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -1493,6 +1512,9 @@ public class GenericOperationDAOImpl implements OperationDAO {
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
String createdTo = null; String createdTo = null;
String createdFrom = null; String createdFrom = null;
ByteArrayInputStream bais;
ObjectInputStream ois;
ProfileOperation profileOperation = null;
DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
boolean isCreatedDayProvided = false; boolean isCreatedDayProvided = false;
boolean isUpdatedDayProvided = false; //updated day = received day boolean isUpdatedDayProvided = false; //updated day = received day
@ -1515,6 +1537,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
"o.RECEIVED_TIMESTAMP, " + "o.RECEIVED_TIMESTAMP, " +
"o.OPERATION_CODE, " + "o.OPERATION_CODE, " +
"o.INITIATED_BY, " + "o.INITIATED_BY, " +
"o.OPERATION_DETAILS, " +
"om.STATUS, " + "om.STATUS, " +
"om.ID AS OM_MAPPING_ID, " + "om.ID AS OM_MAPPING_ID, " +
"om.UPDATED_TIMESTAMP " + "om.UPDATED_TIMESTAMP " +
@ -1613,10 +1636,21 @@ public class GenericOperationDAOImpl implements OperationDAO {
} }
operation.setCode(rs.getString("OPERATION_CODE")); operation.setCode(rs.getString("OPERATION_CODE"));
operation.setInitiatedBy(rs.getString("INITIATED_BY")); operation.setInitiatedBy(rs.getString("INITIATED_BY"));
if (MDMAppConstants.AndroidConstants.UNMANAGED_APP_UNINSTALL.equals(operation.getCode())) {
byte[] operationDetails = rs.getBytes("OPERATION_DETAILS");
bais = new ByteArrayInputStream(operationDetails);
ois = new ObjectInputStream(bais);
profileOperation = (ProfileOperation) ois.readObject();
operation.setPayLoad(profileOperation.getPayLoad());
}
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
OperationDAOUtil.setActivityId(operation, rs.getInt("ID")); OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
operations.add(operation); operations.add(operation);
} }
} catch (IOException e) {
throw new OperationManagementDAOException("IO Error occurred while retrieving app data of operation " , e);
} catch (ClassNotFoundException e) {
throw new OperationManagementDAOException("Class not found error occurred while retrieving app data of operation ", e);
} }
} }
} catch (SQLException e) { } catch (SQLException e) {

Loading…
Cancel
Save