|
|
@ -22,6 +22,7 @@ import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestExcept
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.Base64File;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.Base64File;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata;
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
@ -1445,19 +1446,27 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationList getSubscribedAppsOfDevice(int deviceId) throws ApplicationManagementException {
|
|
|
|
public ApplicationList getSubscribedAppsOfDevice(int deviceId, PaginationRequest request) throws ApplicationManagementException {
|
|
|
|
ApplicationList applicationList = new ApplicationList();
|
|
|
|
ApplicationList applicationList = new ApplicationList();
|
|
|
|
List<Application> applications = new ArrayList<>();
|
|
|
|
List<Application> applications = new ArrayList<>();
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
List<ApplicationDTO> applicationDTOS = this.applicationDAO.getSubscribedAppsOfDevice(deviceId, tenantId);
|
|
|
|
List<ApplicationDTO> applicationDTOS = this.applicationDAO.getSubscribedAppsOfDevice(deviceId, tenantId, request);
|
|
|
|
for (ApplicationDTO applicationDTO: applicationDTOS) {
|
|
|
|
for (ApplicationDTO applicationDTO: applicationDTOS) {
|
|
|
|
applicationDTO.setTags(this.applicationDAO.getAppTags(applicationDTO.getId(), tenantId));
|
|
|
|
applicationDTO.setTags(this.applicationDAO.getAppTags(applicationDTO.getId(), tenantId));
|
|
|
|
applicationDTO.setAppCategories(this.applicationDAO.getAppCategories(applicationDTO.getId(), tenantId));
|
|
|
|
applicationDTO.setAppCategories(this.applicationDAO.getAppCategories(applicationDTO.getId(), tenantId));
|
|
|
|
applications.add(APIUtil.appDtoToAppResponse(applicationDTO));
|
|
|
|
applications.add(APIUtil.appDtoToAppResponse(applicationDTO));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ApplicationDTO> totalApplications = this.applicationDAO.getSubscribedAppsOfDevice(deviceId, tenantId, null);
|
|
|
|
|
|
|
|
Pagination pagination = new Pagination();
|
|
|
|
|
|
|
|
pagination.setCount(totalApplications.size());
|
|
|
|
|
|
|
|
pagination.setSize(applications.size());
|
|
|
|
|
|
|
|
pagination.setOffset(request.getStartIndex());
|
|
|
|
|
|
|
|
pagination.setLimit(request.getRowCount());
|
|
|
|
applicationList.setApplications(applications);
|
|
|
|
applicationList.setApplications(applications);
|
|
|
|
|
|
|
|
applicationList.setPagination(pagination);
|
|
|
|
return applicationList;
|
|
|
|
return applicationList;
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
String msg = "Error occurred when getting installed apps of device with device id: "
|
|
|
|
String msg = "Error occurred when getting installed apps of device with device id: "
|
|
|
|