本文整理汇总了Java中org.wso2.carbon.device.mgt.common.EnrolmentInfo类的典型用法代码示例。如果您正苦于以下问题:Java EnrolmentInfo类的具体用法?Java EnrolmentInfo怎么用?Java EnrolmentInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EnrolmentInfo类属于org.wso2.carbon.device.mgt.common包,在下文中一共展示了EnrolmentInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeDeviceStatus
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
/**
* Change device status.
*
* @param type Device type
* @param id Device id
* @param newsStatus Device new status
* @return {@link Response} object
*/
@PUT
@Path("/{type}/{id}/changestatus")
public Response changeDeviceStatus(@PathParam("type") @Size(max = 45) String type,
@PathParam("id") @Size(max = 45) String id,
@QueryParam("newStatus") EnrolmentInfo.Status newsStatus) {
RequestValidationUtil.validateDeviceIdentifier(type, id);
DeviceManagementProviderService deviceManagementProviderService =
DeviceMgtAPIUtils.getDeviceManagementService();
try {
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(id, type);
Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, false);
if (persistedDevice == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
boolean response = deviceManagementProviderService.changeDeviceStatus(deviceIdentifier, newsStatus);
return Response.status(Response.Status.OK).entity(response).build();
} catch (DeviceManagementException e) {
String msg = "Error occurred while changing device status of type : " + type + " and " +
"device id : " + id;
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}
示例2: testEnrollDeviceSuccess
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
@Test(description = "Test the device enrollment success scenario.")
public void testEnrollDeviceSuccess() throws DeviceManagementException {
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
.toReturn(this.deviceManagementProviderService);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getAuthenticatedUser"))
.toReturn(AUTHENTICATED_USER);
EnrolmentInfo enrolmentInfo = demoDevice.getEnrolmentInfo();
enrolmentInfo.setStatus(EnrolmentInfo.Status.INACTIVE);
demoDevice.setEnrolmentInfo(enrolmentInfo);
Mockito.when(this.deviceManagementProviderService.getDevice(Mockito.any())).thenReturn(demoDevice);
Response response = this.deviceAgentService.enrollDevice(demoDevice);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
"The response status should be 200");
Mockito.reset(this.deviceManagementProviderService);
}
示例3: determineDeviceStatus
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
private EnrolmentInfo.Status determineDeviceStatus(OperationEnrolmentMapping opMapping, long lastActivityTime) {
long lastPendingOpBefore = (System.currentTimeMillis()/1000) - opMapping.getCreatedTime();
EnrolmentInfo.Status newStatus = null;
if (lastPendingOpBefore >= this.deviceStatusTaskPluginConfig.getIdleTimeToMarkInactive()) {
newStatus = EnrolmentInfo.Status.INACTIVE;
} else if (lastPendingOpBefore >= this.deviceStatusTaskPluginConfig.getIdleTimeToMarkUnreachable()) {
newStatus = EnrolmentInfo.Status.UNREACHABLE;
}
if (lastActivityTime != -1) {
long lastActivityBefore = (System.currentTimeMillis()/1000) - lastActivityTime;
if (lastActivityBefore < lastPendingOpBefore) {
return opMapping.getDeviceStatus();
}
}
return newStatus;
}
示例4: updateEnrollment
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
@Override
public int updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo,
int tenantId) throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.getConnection();
String sql = "UPDATE DM_ENROLMENT SET OWNERSHIP = ?, STATUS = ?, DATE_OF_LAST_UPDATE = ? WHERE DEVICE_ID = ?" +
" AND OWNER = ? AND TENANT_ID = ? AND ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, enrolmentInfo.getOwnership().toString());
stmt.setString(2, enrolmentInfo.getStatus().toString());
stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
stmt.setInt(4, deviceId);
stmt.setString(5, enrolmentInfo.getOwner());
stmt.setInt(6, tenantId);
stmt.setInt(7, enrolmentInfo.getId());
int status = stmt.executeUpdate();
return status;
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
}
示例5: setStatus
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
@Override
public boolean setStatus(int enrolmentID, String currentOwner, EnrolmentInfo.Status status,
int tenantId) throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String sql = "UPDATE DM_ENROLMENT SET STATUS = ? WHERE ID = ? AND OWNER = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, status.toString());
stmt.setInt(2, enrolmentID);
stmt.setString(3, currentOwner);
stmt.setInt(4, tenantId);
stmt.executeUpdate();
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
}
return true;
}
示例6: getStatus
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
@Override
public EnrolmentInfo.Status getStatus(int deviceId, String currentOwner,
int tenantId) throws DeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
EnrolmentInfo.Status status = null;
try {
conn = this.getConnection();
String sql = "SELECT STATUS FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId);
stmt.setString(2, currentOwner);
stmt.setInt(3, tenantId);
rs = stmt.executeQuery();
if (rs.next()) {
status = EnrolmentInfo.Status.valueOf(rs.getString("STATUS"));
}
return status;
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
}
示例7: testReEnrollmentofSameDeviceWithOtherUser
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
@Test(dependsOnMethods = {"testReEnrollmentofSameDeviceUnderSameUser"})
public void testReEnrollmentofSameDeviceWithOtherUser() throws DeviceManagementException {
if (!isMock()) {
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setDateOfEnrolment(new Date().getTime());
enrolmentInfo.setDateOfLastUpdate(new Date().getTime());
enrolmentInfo.setOwner("user1");
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
enrolmentInfo.setStatus(EnrolmentInfo.Status.CREATED);
Device alternateDevice = TestDataHolder.generateDummyDeviceData(DEVICE_ID, DEVICE_TYPE,
enrolmentInfo);
Device retrievedDevice1 = deviceMgtService.getDevice(new DeviceIdentifier(DEVICE_ID,
DEVICE_TYPE));
deviceMgtService.enrollDevice(alternateDevice);
Device retrievedDevice2 = deviceMgtService.getDevice(new DeviceIdentifier(alternateDevice
.getDeviceIdentifier(), alternateDevice.getType()));
Assert.assertFalse(retrievedDevice1.getEnrolmentInfo().getOwner().equalsIgnoreCase
(retrievedDevice2.getEnrolmentInfo().getOwner()));
}
}
示例8: generateDummyDeviceData
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
public static List<Device> generateDummyDeviceData(List<DeviceIdentifier> deviceIds) {
List<Device> devices = new ArrayList<>();
for (DeviceIdentifier deviceId : deviceIds) {
Device device = new Device();
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setDateOfEnrolment(new Date().getTime());
enrolmentInfo.setDateOfLastUpdate(new Date().getTime());
enrolmentInfo.setOwner(OWNER);
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
enrolmentInfo.setStatus(EnrolmentInfo.Status.CREATED);
device.setEnrolmentInfo(enrolmentInfo);
device.setDescription("Test Description");
device.setDeviceIdentifier(deviceId.getId());
device.setType(deviceId.getType());
devices.add(device);
}
return devices;
}
示例9: testEnrollDeviceWithDeviceManagementException
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
@Test(description = "Test the device enrollment with device management exception.")
public void testEnrollDeviceWithDeviceManagementException() throws DeviceManagementException {
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
.toReturn(this.deviceManagementProviderService);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getAuthenticatedUser"))
.toReturn(AUTHENTICATED_USER);
Device device = DeviceMgtAPITestHelper.generateDummyDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo();
enrolmentInfo.setStatus(EnrolmentInfo.Status.INACTIVE);
device.setEnrolmentInfo(enrolmentInfo);
Mockito.when(this.deviceManagementProviderService.getDevice(Mockito.any())).thenReturn(device);
Mockito.when(this.deviceManagementProviderService.enrollDevice(Mockito.any()))
.thenThrow(new DeviceManagementException());
Response response = this.deviceAgentService.enrollDevice(device);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
Mockito.reset(this.deviceManagementProviderService);
}
示例10: getDeviceList3
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
public static List<Device> getDeviceList3 (DeviceType deviceType) {
List<Device> deviceList = new ArrayList<Device>();
Device device = new Device();
device.setId(3);
device.setType(deviceType.getName());
device.setName("Apple 6 Large");
device.setDeviceIdentifier("xxxx123");
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setOwner("Harshan");
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
device.setEnrolmentInfo(enrolmentInfo);
deviceList.add(device);
return deviceList;
}
示例11: getDeviceList4
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
public static List<Device> getDeviceList4 (DeviceType deviceType) {
List<Device> deviceList = new ArrayList<Device>();
Device device = new Device();
device.setId(4);
device.setType(deviceType.getName());
device.setName("HTC M");
device.setDeviceIdentifier("ppp456");
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setOwner("Dilan");
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
device.setEnrolmentInfo(enrolmentInfo);
deviceList.add(device);
return deviceList;
}
示例12: getDeviceList5
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
public static List<Device> getDeviceList5 (DeviceType deviceType) {
List<Device> deviceList = new ArrayList<Device>();
Device device = new Device();
device.setId(5);
device.setType(deviceType.getName());
device.setName("Sony Experia L");
device.setDeviceIdentifier("ssss123");
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setOwner("Milan");
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
device.setEnrolmentInfo(enrolmentInfo);
deviceList.add(device);
return deviceList;
}
示例13: getDeviceList6
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
public static List<Device> getDeviceList6 (DeviceType deviceType) {
List<Device> deviceList = new ArrayList<Device>();
Device device = new Device();
device.setId(6);
device.setType(deviceType.getName());
device.setName("Alcatel RTS");
device.setDeviceIdentifier("ttt123");
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setOwner("Dileesha");
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
device.setEnrolmentInfo(enrolmentInfo);
deviceList.add(device);
return deviceList;
}
示例14: getSingleDevice
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
public static Device getSingleDevice() {
Device device = new Device();
device.setId(1);
device.setType("android");
device.setName("Galaxy S6");
device.setDeviceIdentifier("abc123");
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setOwner("Geeth");
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
device.setEnrolmentInfo(enrolmentInfo);
return device;
}
示例15: removeUser
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; //导入依赖的package包/类
@DELETE
@Path("/{username}")
@Override
public Response removeUser(@PathParam("username") String username, @QueryParam("domain") String domain) {
if (domain != null && !domain.isEmpty()) {
username = domain + '/' + username;
}
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (!userStoreManager.isExistingUser(username)) {
if (log.isDebugEnabled()) {
log.debug("User by username: " + username + " does not exist for removal.");
}
return Response.status(Response.Status.NOT_FOUND).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("User '" +
username + "' does not exist for removal.").build()).build();
}
// Un-enroll all devices for the user
DeviceManagementProviderService deviceManagementService = DeviceMgtAPIUtils.getDeviceManagementService();
deviceManagementService.setStatus(username, EnrolmentInfo.Status.REMOVED);
userStoreManager.deleteUser(username);
if (log.isDebugEnabled()) {
log.debug("User '" + username + "' was successfully removed.");
}
return Response.status(Response.Status.OK).build();
} catch (DeviceManagementException | UserStoreException e) {
String msg = "Exception in trying to remove user by username: " + username;
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}