mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
commit
f3666ac175
@ -57,7 +57,7 @@ public class FCMNotificationStrategy implements NotificationStrategy {
|
||||
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
|
||||
try {
|
||||
Device device =
|
||||
FCMDataHolder.getInstance().getDeviceManagementProviderService().getDevice(ctx.getDeviceId());
|
||||
FCMDataHolder.getInstance().getDeviceManagementProviderService().getDeviceWithTypeProperties(ctx.getDeviceId());
|
||||
this.sendWakeUpCall(ctx.getOperation().getCode(), device);
|
||||
} catch (DeviceManagementException e) {
|
||||
throw new PushNotificationExecutionFailedException("Error occurred while retrieving device information", e);
|
||||
|
||||
@ -267,6 +267,13 @@ public interface DeviceManagementService {
|
||||
required = false)
|
||||
@HeaderParam("If-Modified-Since")
|
||||
String timestamp,
|
||||
@ApiParam(
|
||||
name = "requireDeviceInfo",
|
||||
value = "Boolean flag indicating whether to include device-info (location, application list etc) \n" +
|
||||
" to the device object.",
|
||||
required = false)
|
||||
@QueryParam("requireDeviceInfo")
|
||||
boolean requireDeviceInfo,
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
value = "The starting pagination index for the complete list of qualified items.",
|
||||
@ -333,6 +340,13 @@ public interface DeviceManagementService {
|
||||
})
|
||||
@Path("/user-devices")
|
||||
Response getDeviceByUser(
|
||||
@ApiParam(
|
||||
name = "requireDeviceInfo",
|
||||
value = "Boolean flag indicating whether to include device-info (location, application list etc) \n" +
|
||||
" to the device object.",
|
||||
required = false)
|
||||
@QueryParam("requireDeviceInfo")
|
||||
boolean requireDeviceInfo,
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
value = "The starting pagination index for the complete list of qualified items.",
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
||||
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@ -97,6 +96,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
@QueryParam("groupId") int groupId,
|
||||
@QueryParam("since") String since,
|
||||
@HeaderParam("If-Modified-Since") String ifModifiedSince,
|
||||
@QueryParam("requireDeviceInfo") boolean requireDeviceInfo,
|
||||
@QueryParam("offset") int offset,
|
||||
@QueryParam("limit") int limit) {
|
||||
try {
|
||||
@ -180,7 +180,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
"string is provided in 'If-Modified-Since' header").build()).build();
|
||||
}
|
||||
request.setSince(sinceDate);
|
||||
if (requireDeviceInfo) {
|
||||
result = dms.getAllDevices(request);
|
||||
} else {
|
||||
result = dms.getAllDevices(request, false);
|
||||
}
|
||||
|
||||
if (result == null || result.getData() == null || result.getData().size() <= 0) {
|
||||
return Response.status(Response.Status.NOT_MODIFIED).entity("No device is modified " +
|
||||
"after the timestamp provided in 'If-Modified-Since' header").build();
|
||||
@ -196,14 +201,22 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
"string is provided in 'since' filter").build()).build();
|
||||
}
|
||||
request.setSince(sinceDate);
|
||||
if (requireDeviceInfo) {
|
||||
result = dms.getAllDevices(request);
|
||||
} else {
|
||||
result = dms.getAllDevices(request, false);
|
||||
}
|
||||
if (result == null || result.getData() == null || result.getData().size() <= 0) {
|
||||
devices.setList(new ArrayList<Device>());
|
||||
devices.setCount(0);
|
||||
return Response.status(Response.Status.OK).entity(devices).build();
|
||||
}
|
||||
} else {
|
||||
if (requireDeviceInfo) {
|
||||
result = dms.getAllDevices(request);
|
||||
} else {
|
||||
result = dms.getAllDevices(request, false);
|
||||
}
|
||||
int resultCount = result.getRecordsTotal();
|
||||
if (resultCount == 0) {
|
||||
Response.status(Response.Status.OK).entity(devices).build();
|
||||
@ -229,7 +242,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
@GET
|
||||
@Override
|
||||
@Path("/user-devices")
|
||||
public Response getDeviceByUser(@QueryParam("offset") int offset,
|
||||
public Response getDeviceByUser(@QueryParam("requireDeviceInfo") boolean requireDeviceInfo,
|
||||
@QueryParam("offset") int offset,
|
||||
@QueryParam("limit") int limit) {
|
||||
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
@ -241,7 +255,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
request.setOwner(currentUser);
|
||||
|
||||
try {
|
||||
if (requireDeviceInfo) {
|
||||
result = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesOfUser(request);
|
||||
} else {
|
||||
result = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesOfUser(request, false);
|
||||
}
|
||||
devices.setList((List<Device>) result.getData());
|
||||
devices.setCount(result.getRecordsTotal());
|
||||
return Response.status(Response.Status.OK).entity(devices).build();
|
||||
@ -261,7 +279,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
DeviceMgtAPIUtils.getDeviceManagementService();
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType);
|
||||
Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier);
|
||||
Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true);
|
||||
if (persistedDevice == null) {
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
@ -287,7 +305,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
DeviceManagementProviderService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||
try {
|
||||
Device persistedDevice = deviceManagementProviderService.getDevice(new DeviceIdentifier
|
||||
(deviceId, deviceType));
|
||||
(deviceId, deviceType), true);
|
||||
persistedDevice.setName(device.getName());
|
||||
boolean response = deviceManagementProviderService.modifyEnrollment(persistedDevice);
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
@ -586,7 +604,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
DeviceMgtAPIUtils.getDeviceManagementService();
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(id, type);
|
||||
Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier);
|
||||
Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, false);
|
||||
if (persistedDevice == null) {
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
||||
List<DeviceIdentifier> deviceIdentifiers = policyWrapper.getDeviceIdentifiers();
|
||||
if (deviceIdentifiers != null) {
|
||||
for (DeviceIdentifier id : deviceIdentifiers) {
|
||||
devices.add(DeviceMgtAPIUtils.getDeviceManagementService().getDevice(id));
|
||||
devices.add(DeviceMgtAPIUtils.getDeviceManagementService().getDevice(id, false));
|
||||
}
|
||||
}
|
||||
policy.setDevices(devices);
|
||||
|
||||
@ -25,6 +25,7 @@ import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceManagementAdminService;
|
||||
@ -64,8 +65,11 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(DeviceMgtAPIUtils.getTenantId(tenantDomain));
|
||||
|
||||
PaginationRequest request = new PaginationRequest(offset, limit);
|
||||
request.setDeviceType(type);
|
||||
request.setDeviceName(name);
|
||||
List<Device> devices = DeviceMgtAPIUtils.getDeviceManagementService().
|
||||
getDevicesByNameAndType(name, type, offset, limit);
|
||||
getDevicesByNameAndType(request, false);
|
||||
|
||||
// setting up paginated result
|
||||
DeviceList deviceList = new DeviceList();
|
||||
|
||||
@ -114,7 +114,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
||||
for (String user : userNameList) {
|
||||
userName = user;
|
||||
deviceList = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevicesOfUser
|
||||
(user);
|
||||
(user, false);
|
||||
for (Device device : deviceList) {
|
||||
deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(Integer.toString(device.getId()));
|
||||
@ -156,7 +156,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
||||
for (String role : userRoleList) {
|
||||
userRole = role;
|
||||
deviceList = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
|
||||
.getAllDevicesOfRole(userRole);
|
||||
.getAllDevicesOfRole(userRole, false);
|
||||
for (Device device : deviceList) {
|
||||
deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(Integer.toString(device.getId()));
|
||||
|
||||
@ -55,7 +55,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
public void addDeviceInfo(DeviceIdentifier deviceId, DeviceInfo deviceInfo) throws DeviceDetailsMgtException {
|
||||
try {
|
||||
Device device = DeviceManagementDataHolder.getInstance().
|
||||
getDeviceManagementProvider().getDevice(deviceId);
|
||||
getDeviceManagementProvider().getDevice(deviceId, false);
|
||||
|
||||
DeviceManagementDAOFactory.beginTransaction();
|
||||
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
||||
@ -87,7 +87,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
Device device;
|
||||
try {
|
||||
device = DeviceManagementDataHolder.getInstance().
|
||||
getDeviceManagementProvider().getDevice(deviceId);
|
||||
getDeviceManagementProvider().getDevice(deviceId, false);
|
||||
if (device == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("No device is found upon the device identifier '" + deviceId.getId() +
|
||||
@ -123,8 +123,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
}
|
||||
try {
|
||||
List<Integer> deviceIds = new ArrayList<>();
|
||||
List<Device> devices = DeviceManagementDataHolder.getInstance().
|
||||
getDeviceManagementProvider().getAllDevices();
|
||||
List<Device> devices = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().
|
||||
getAllDevices(false);
|
||||
for (Device device : devices) {
|
||||
if (identifierMap.containsKey(device.getDeviceIdentifier()) &&
|
||||
device.getType().equals(identifierMap.get(device.getDeviceIdentifier()).getType())) {
|
||||
@ -154,7 +154,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
|
||||
try {
|
||||
Device device = DeviceManagementDataHolder.getInstance().
|
||||
getDeviceManagementProvider().getDevice(deviceLocation.getDeviceIdentifier());
|
||||
getDeviceManagementProvider().getDevice(deviceLocation.getDeviceIdentifier(), false);
|
||||
deviceLocation.setDeviceId(device.getId());
|
||||
DeviceManagementDAOFactory.beginTransaction();
|
||||
deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
||||
@ -183,7 +183,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
public DeviceLocation getDeviceLocation(DeviceIdentifier deviceId) throws DeviceDetailsMgtException {
|
||||
Device device;
|
||||
try {
|
||||
device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId);
|
||||
device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId, false);
|
||||
if (device == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("No device is found upon the device identifier '" + deviceId.getId() +
|
||||
@ -212,7 +212,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
|
||||
try {
|
||||
List<Device> devices = DeviceManagementDataHolder.getInstance().
|
||||
getDeviceManagementProvider().getAllDevices(deviceIdentifiers.get(0).getType());
|
||||
getDeviceManagementProvider().getAllDevices(deviceIdentifiers.get(0).getType(), false);
|
||||
List<DeviceLocation> deviceLocations = new ArrayList<>();
|
||||
DeviceManagementDAOFactory.openConnection();
|
||||
for (Device device : devices) {
|
||||
|
||||
@ -54,6 +54,18 @@ public interface DeviceManagementProviderService {
|
||||
*/
|
||||
List<Device> getAllDevices(String deviceType) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to retrieve all the devices of a given device type.
|
||||
*
|
||||
* @param deviceType Device-type of the required devices
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of devices of given device-type.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* devices.
|
||||
*/
|
||||
List<Device> getAllDevices(String deviceType, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to retrieve all the devices registered in the system.
|
||||
*
|
||||
@ -63,6 +75,38 @@ public interface DeviceManagementProviderService {
|
||||
*/
|
||||
List<Device> getAllDevices() throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to retrieve all the devices registered in the system.
|
||||
*
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of registered devices.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* devices.
|
||||
*/
|
||||
List<Device> getAllDevices(boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to retrieve all the devices registered in the system.
|
||||
*
|
||||
* @param since - Date value where the resource was last modified
|
||||
* @return List of registered devices.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* devices.
|
||||
*/
|
||||
List<Device> getDevices(Date since) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to retrieve all the devices registered in the system.
|
||||
*
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of registered devices.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* devices.
|
||||
*/
|
||||
List<Device> getDevices(Date since, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to retrieve all the devices with pagination support.
|
||||
*
|
||||
@ -73,6 +117,18 @@ public interface DeviceManagementProviderService {
|
||||
*/
|
||||
PaginationResult getDevicesByType(PaginationRequest request) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to retrieve all the devices with pagination support.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return PaginationResult - Result including the required parameters necessary to do pagination.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* devices.
|
||||
*/
|
||||
PaginationResult getDevicesByType(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to retrieve all the devices with pagination support.
|
||||
*
|
||||
@ -83,21 +139,91 @@ public interface DeviceManagementProviderService {
|
||||
*/
|
||||
PaginationResult getAllDevices(PaginationRequest request) throws DeviceManagementException;
|
||||
|
||||
void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException;
|
||||
|
||||
void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException;
|
||||
|
||||
FeatureManager getFeatureManager(String deviceType) throws DeviceManagementException;
|
||||
/**
|
||||
* Method to retrieve all the devices with pagination support.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return PaginationResult - Result including the required parameters necessary to do pagination.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* devices.
|
||||
*/
|
||||
PaginationResult getAllDevices(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Proxy method to get the tenant configuration of a given platform.
|
||||
* Returns the device of specified id.
|
||||
*
|
||||
* @param deviceType Device platform
|
||||
* @return Tenant configuration settings of the particular tenant and platform.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* configuration.
|
||||
* @param deviceId device Id
|
||||
* @return Device returns null when device is not available.
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
PlatformConfiguration getConfiguration(String deviceType) throws DeviceManagementException;
|
||||
Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Returns the device of specified id.
|
||||
*
|
||||
* @param deviceId device Id
|
||||
* @return Device returns null when device is not available.
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
Device getDeviceWithTypeProperties(DeviceIdentifier deviceId) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Returns the device of specified id.
|
||||
*
|
||||
* @param deviceId device Id
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return Device returns null when device is not available.
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
Device getDevice(DeviceIdentifier deviceId, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Returns the device of specified id.
|
||||
*
|
||||
* @param deviceId device Id
|
||||
* @param since - Date value where the resource was last modified
|
||||
* @return Device returns null when device is not available.
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
Device getDevice(DeviceIdentifier deviceId, Date since) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Returns the device of specified id.
|
||||
*
|
||||
* @param deviceId device Id
|
||||
* @param since - Date value where the resource was last modified
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return Device returns null when device is not available.
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
Device getDevice(DeviceIdentifier deviceId, Date since, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Returns the device of specified id with the given status.
|
||||
*
|
||||
* @param deviceId device Id
|
||||
* @param status - Status of the device
|
||||
*
|
||||
* @return Device returns null when device is not available.
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Returns the device of specified id with the given status.
|
||||
*
|
||||
* @param deviceId device Id
|
||||
* @param status - Status of the device
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return Device returns null when device is not available.
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices owned by an user with paging information.
|
||||
@ -109,6 +235,18 @@ public interface DeviceManagementProviderService {
|
||||
*/
|
||||
PaginationResult getDevicesOfUser(PaginationRequest request) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices owned by an user with paging information.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of devices owned by a particular user along with the required parameters necessary to do pagination.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
PaginationResult getDevicesOfUser(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices filtered by the ownership with paging information.
|
||||
*
|
||||
@ -119,6 +257,18 @@ public interface DeviceManagementProviderService {
|
||||
*/
|
||||
PaginationResult getDevicesByOwnership(PaginationRequest request) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices filtered by the ownership with paging information.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of devices owned by a particular user along with the required parameters necessary to do pagination.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
PaginationResult getDevicesByOwnership(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices owned by an user.
|
||||
*
|
||||
@ -129,16 +279,42 @@ public interface DeviceManagementProviderService {
|
||||
*/
|
||||
List<Device> getDevicesOfUser(String userName) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices owned by an user.
|
||||
*
|
||||
* @param userName Username of the user
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of devices owned by a particular user
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
List<Device> getDevicesOfUser(String userName, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method returns the list of device owned by a user of given device type.
|
||||
*
|
||||
* @param userName user name.
|
||||
* @param deviceType device type name
|
||||
* @return
|
||||
* @throws DeviceManagementException
|
||||
* @return List of device owned by the given user and type.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
List<Device> getDevicesOfUser(String userName, String deviceType) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method returns the list of device owned by a user of given device type.
|
||||
*
|
||||
* @param userName user name.
|
||||
* @param deviceType device type name
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of device owned by the given user and type.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
List<Device> getDevicesOfUser(String userName, String deviceType, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices owned by users of a particular user-role.
|
||||
*
|
||||
@ -149,6 +325,94 @@ public interface DeviceManagementProviderService {
|
||||
*/
|
||||
List<Device> getAllDevicesOfRole(String roleName) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices owned by users of a particular user-role.
|
||||
*
|
||||
* @param roleName Role name of the users
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of devices owned by users of a particular role
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
List<Device> getAllDevicesOfRole(String roleName, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to retrieve list of devices based on the device status with paging information.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination and filter info
|
||||
* @return List of devices in given status along with the required parameters necessary to do pagination.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
PaginationResult getDevicesByStatus(PaginationRequest request) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to retrieve list of devices based on the device status with paging information.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination and filter info
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of devices in given status along with the required parameters necessary to do pagination.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
PaginationResult getDevicesByStatus(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices that matches with the given device name.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination and filter info
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of devices that matches with the given device name.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
List<Device> getDevicesByNameAndType(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to retrieve list of devices that matches with the given device name with paging information.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination
|
||||
* @return List of devices in given status along with the required parameters necessary to do pagination.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
PaginationResult getDevicesByName(PaginationRequest request) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to retrieve list of devices that matches with the given device name with paging information.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of devices in given status along with the required parameters necessary to do pagination.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
PaginationResult getDevicesByName(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to retrieve list of devices based on the device status.
|
||||
*
|
||||
* @param status Device status
|
||||
* @return List of devices
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
List<Device> getDevicesByStatus(EnrolmentInfo.Status status) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to retrieve list of devices based on the device status.
|
||||
*
|
||||
* @param status Device status
|
||||
* @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required
|
||||
* along with the device data.
|
||||
* @return List of devices
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
List<Device> getDevicesByStatus(EnrolmentInfo.Status status, boolean requireDeviceInfo) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the device count of user.
|
||||
*
|
||||
@ -167,47 +431,26 @@ public interface DeviceManagementProviderService {
|
||||
*/
|
||||
int getDeviceCount() throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Method to get the list of devices that matches with the given device name.
|
||||
*
|
||||
* @param deviceName name of the device
|
||||
* @return List of devices that matches with the given device name.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
List<Device> getDevicesByNameAndType(String deviceName, String type, int offset, int limit) throws DeviceManagementException;
|
||||
HashMap<Integer, Device> getTenantedDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException;
|
||||
|
||||
void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException;
|
||||
|
||||
void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException;
|
||||
|
||||
FeatureManager getFeatureManager(String deviceType) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to retrieve list of devices that matches with the given device name with paging information.
|
||||
* Proxy method to get the tenant configuration of a given platform.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination
|
||||
* @return List of devices in given status along with the required parameters necessary to do pagination.
|
||||
* @param deviceType Device platform
|
||||
* @return Tenant configuration settings of the particular tenant and platform.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
* configuration.
|
||||
*/
|
||||
PaginationResult getDevicesByName(PaginationRequest request) throws DeviceManagementException;
|
||||
PlatformConfiguration getConfiguration(String deviceType) throws DeviceManagementException;
|
||||
|
||||
void updateDeviceEnrolmentInfo(Device device, EnrolmentInfo.Status active) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to retrieve list of devices based on the device status.
|
||||
*
|
||||
* @param status Device status
|
||||
* @return List of devices
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
List<Device> getDevicesByStatus(EnrolmentInfo.Status status) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to retrieve list of devices based on the device status with paging information.
|
||||
*
|
||||
* @param request PaginationRequest object holding the data for pagination
|
||||
* @return List of devices in given status along with the required parameters necessary to do pagination.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the
|
||||
* device list
|
||||
*/
|
||||
PaginationResult getDevicesByStatus(PaginationRequest request) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* This method is used to check whether the device is enrolled with the give user.
|
||||
*
|
||||
@ -247,21 +490,6 @@ public interface DeviceManagementProviderService {
|
||||
|
||||
boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException;
|
||||
|
||||
/**
|
||||
* Returns the device of specified id.
|
||||
*
|
||||
* @param deviceId device Id
|
||||
* @return Device returns null when device is not avaialble.
|
||||
* @throws DeviceManagementException
|
||||
*/
|
||||
Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
|
||||
|
||||
Device getDevice(DeviceIdentifier deviceId, Date since) throws DeviceManagementException;
|
||||
|
||||
HashMap<Integer, Device> getTenantedDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException;
|
||||
|
||||
Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status) throws DeviceManagementException;
|
||||
|
||||
List<String> getAvailableDeviceTypes() throws DeviceManagementException;
|
||||
|
||||
boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -472,7 +472,8 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
GroupManagementDAOFactory.beginTransaction();
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
||||
device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceIdentifier);
|
||||
device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().
|
||||
getDevice(deviceIdentifier, false);
|
||||
if (device == null) {
|
||||
throw new DeviceNotFoundException("Device not found for id '" + deviceIdentifier.getId() + "'");
|
||||
}
|
||||
@ -504,7 +505,8 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
GroupManagementDAOFactory.beginTransaction();
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
||||
device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceIdentifier);
|
||||
device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().
|
||||
getDevice(deviceIdentifier, false);
|
||||
if (device == null) {
|
||||
throw new DeviceNotFoundException("Device not found for id '" + deviceIdentifier.getId() + "'");
|
||||
}
|
||||
@ -553,7 +555,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
||||
public List<DeviceGroup> getGroups(DeviceIdentifier deviceIdentifier) throws GroupManagementException {
|
||||
DeviceManagementProviderService managementProviderService = new DeviceManagementProviderServiceImpl();
|
||||
try {
|
||||
Device device = managementProviderService.getDevice(deviceIdentifier);
|
||||
Device device = managementProviderService.getDevice(deviceIdentifier, false);
|
||||
GroupManagementDAOFactory.openConnection();
|
||||
return groupDAO.getGroups(device.getId(),
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
|
||||
|
||||
@ -90,7 +90,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||
List<String> operations;
|
||||
|
||||
operations = this.getValidOperationNames(); //list operations for each device type
|
||||
devices = deviceManagementProviderService.getAllDevices(deviceType);//list devices for each type
|
||||
devices = deviceManagementProviderService.getAllDevices(deviceType, false);//list devices for each type
|
||||
if (!devices.isEmpty()) {
|
||||
for (String str : operations) {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
|
||||
@ -431,7 +431,8 @@ public final class DeviceManagerUtil {
|
||||
}
|
||||
|
||||
public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
Device device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceIdentifier);
|
||||
Device device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceIdentifier,
|
||||
false);
|
||||
if (device == null || device.getDeviceIdentifier() == null ||
|
||||
device.getDeviceIdentifier().isEmpty() || device.getEnrolmentInfo() == null) {
|
||||
return false;
|
||||
|
||||
@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.ntask.core.Task;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||
@ -64,15 +63,15 @@ public class DelegationTask implements Task {
|
||||
log.debug("Number of device types which policies are changed .......... : " + deviceTypes.size());
|
||||
}
|
||||
if (!deviceTypes.isEmpty()) {
|
||||
DeviceManagementProviderService service = PolicyManagementDataHolder.getInstance()
|
||||
.getDeviceManagementService();
|
||||
DeviceManagementProviderService service = PolicyManagementDataHolder.getInstance().
|
||||
getDeviceManagementService();
|
||||
List<Device> devices;
|
||||
List<Device> toBeNotified;
|
||||
for (String deviceType : deviceTypes) {
|
||||
try {
|
||||
devices = new ArrayList<>();
|
||||
toBeNotified = new ArrayList<>();
|
||||
devices.addAll(service.getAllDevices(deviceType));
|
||||
devices.addAll(service.getAllDevices(deviceType, false));
|
||||
//HashMap<Integer, Integer> deviceIdPolicy = policyManager.getAppliedPolicyIdsDeviceIds();
|
||||
for (Device device : devices) {
|
||||
// if (deviceIdPolicy.containsKey(device.getId())) {
|
||||
|
||||
@ -54,7 +54,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
|
||||
try {
|
||||
DeviceManagementProviderService service = this.getDeviceManagementProviderService();
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
service.setStatus(deviceIdentifier, device.getEnrolmentInfo().getOwner(),
|
||||
EnrolmentInfo.Status.UNREACHABLE);
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
|
||||
try {
|
||||
DeviceManagementProviderService service = this.getDeviceManagementProviderService();
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
service.setStatus(deviceIdentifier, device.getEnrolmentInfo().getOwner(),
|
||||
EnrolmentInfo.Status.INACTIVE);
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
|
||||
try {
|
||||
|
||||
DeviceManagementProviderService service = this.getDeviceManagementProviderService();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
service.setStatus(deviceIdentifier, device.getEnrolmentInfo().getOwner(),
|
||||
EnrolmentInfo.Status.ACTIVE);
|
||||
|
||||
@ -213,7 +213,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
|
||||
|
||||
try {
|
||||
DeviceManagementProviderService service = this.getDeviceManagementProviderService();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
service.setStatus(deviceIdentifier, device.getEnrolmentInfo().getOwner(),
|
||||
EnrolmentInfo.Status.ACTIVE);
|
||||
|
||||
@ -231,7 +231,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
|
||||
try {
|
||||
|
||||
DeviceManagementProviderService service = this.getDeviceManagementProviderService();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
service.setStatus(deviceIdentifier, device.getEnrolmentInfo().getOwner(),
|
||||
EnrolmentInfo.Status.INACTIVE);
|
||||
|
||||
@ -248,7 +248,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
|
||||
|
||||
try {
|
||||
DeviceManagementProviderService service = this.getDeviceManagementProviderService();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
service.setStatus(deviceIdentifier, device.getEnrolmentInfo().getOwner(),
|
||||
EnrolmentInfo.Status.ACTIVE);
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
||||
DeviceManagementProviderService service =
|
||||
PolicyManagementDataHolder.getInstance().getDeviceManagementService();
|
||||
PolicyManager manager = PolicyManagementDataHolder.getInstance().getPolicyManager();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
Policy policy = manager.getAppliedPolicyToDevice(deviceIdentifier);
|
||||
if (policy != null) {
|
||||
PolicyMonitoringManager monitoringService = PolicyManagementDataHolder.getInstance().
|
||||
@ -177,7 +177,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
||||
try {
|
||||
DeviceManagementProviderService service =
|
||||
PolicyManagementDataHolder.getInstance().getDeviceManagementService();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
PolicyManagementDAOFactory.openConnection();
|
||||
NonComplianceData complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo()
|
||||
.getId());
|
||||
@ -207,7 +207,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
||||
PolicyManagementDAOFactory.openConnection();
|
||||
DeviceManagementProviderService service =
|
||||
PolicyManagementDataHolder.getInstance().getDeviceManagementService();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo().getId());
|
||||
List<ComplianceFeature> complianceFeatures =
|
||||
monitoringDAO.getNoneComplianceFeatures(complianceData.getId());
|
||||
|
||||
@ -392,7 +392,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIdentifierList) {
|
||||
try {
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
deviceList.add(device);
|
||||
} catch (DeviceManagementException e) {
|
||||
throw new PolicyManagementException("Error occurred while retrieving device information", e);
|
||||
@ -641,7 +641,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
||||
try {
|
||||
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
|
||||
PolicyManagementDAOFactory.openConnection();
|
||||
policyIdList = policyDAO.getPolicyIdsOfDevice(device);
|
||||
@ -807,7 +807,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
||||
int deviceId = -1;
|
||||
try {
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
deviceId = device.getId();
|
||||
|
||||
PolicyManagementDAOFactory.beginTransaction();
|
||||
@ -879,7 +879,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
||||
int deviceId = -1;
|
||||
try {
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
deviceId = device.getId();
|
||||
PolicyManagementDAOFactory.beginTransaction();
|
||||
|
||||
@ -909,7 +909,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
||||
int deviceId = -1;
|
||||
try {
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
deviceId = device.getId();
|
||||
PolicyManagementDAOFactory.beginTransaction();
|
||||
|
||||
@ -937,7 +937,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
||||
boolean exist;
|
||||
try {
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
PolicyManagementDAOFactory.openConnection();
|
||||
exist = policyDAO.checkPolicyAvailable(device.getId(), device.getEnrolmentInfo().getId());
|
||||
} catch (PolicyManagerDAOException e) {
|
||||
@ -958,7 +958,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
||||
public boolean setPolicyApplied(DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
|
||||
try {
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
Device device = service.getDevice(deviceIdentifier);
|
||||
Device device = service.getDevice(deviceIdentifier, false);
|
||||
|
||||
PolicyManagementDAOFactory.openConnection();
|
||||
policyDAO.setPolicyApplied(device.getId(), device.getEnrolmentInfo().getId());
|
||||
@ -996,7 +996,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
Device device;
|
||||
try {
|
||||
device = service.getDevice(deviceId);
|
||||
device = service.getDevice(deviceId, false);
|
||||
if (device == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("No device is found upon the device identifier '" + deviceId.getId() +
|
||||
|
||||
@ -24,11 +24,9 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
|
||||
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
||||
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.ntask.core.Task;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
||||
import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager;
|
||||
|
||||
@ -83,7 +81,7 @@ public class MonitoringTask implements Task {
|
||||
PolicyMonitoringManager monitoringService =
|
||||
PolicyManagementDataHolder.getInstance().getDeviceManagementService()
|
||||
.getPolicyMonitoringManager(deviceType);
|
||||
List<Device> devices = deviceManagementProviderService.getAllDevices(deviceType);
|
||||
List<Device> devices = deviceManagementProviderService.getAllDevices(deviceType, false);
|
||||
if (monitoringService != null && !devices.isEmpty()) {
|
||||
List<Device> notifiableDevices = new ArrayList<>();
|
||||
if (log.isDebugEnabled()) {
|
||||
|
||||
@ -140,7 +140,7 @@ public class MonitoringTestCase extends BasePolicyManagementDAOTest {
|
||||
MonitoringManager monitoringManager = new MonitoringManagerImpl();
|
||||
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
List<Device> devices = service.getAllDevices(ANDROID);
|
||||
List<Device> devices = service.getAllDevices(ANDROID, false);
|
||||
|
||||
// monitoringManager.addMonitoringOperation(devices);
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Printing device taken by calling the service layer with device type.");
|
||||
}
|
||||
List<Device> devices3 = service.getAllDevices("android");
|
||||
List<Device> devices3 = service.getAllDevices("android", false);
|
||||
|
||||
log.debug("Device list size ...! " + devices3.size());
|
||||
for (Device device : devices3) {
|
||||
@ -437,7 +437,7 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest {
|
||||
PolicyManagerService policyManagerService = new PolicyManagerServiceImpl();
|
||||
|
||||
List<Policy> policies = policyManagerService.getPolicies("android");
|
||||
List<Device> devices = service.getAllDevices("android");
|
||||
List<Device> devices = service.getAllDevices("android", false);
|
||||
|
||||
for (Policy policy : policies) {
|
||||
log.debug("Policy Name : " + policy.getPolicyName());
|
||||
|
||||
@ -95,7 +95,7 @@ public class PolicyEvaluationTestCase extends BasePolicyManagementDAOTest {
|
||||
log.debug("Getting effective policy for device started ..........");
|
||||
|
||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||
List<Device> devices = service.getAllDevices(ANDROID);
|
||||
List<Device> devices = service.getAllDevices(ANDROID, false);
|
||||
|
||||
PolicyEvaluationPoint evaluationPoint = PolicyManagementDataHolder.getInstance().getPolicyEvaluationPoint();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user