com.akaxin.proto.site.ApiDeviceProfileProto Java Examples

The following examples show how to use com.akaxin.proto.site.ApiDeviceProfileProto. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApiDeviceService.java    From wind-im with Apache License 2.0 5 votes vote down vote up
public CommandResponse profile(Command command) {
	CommandResponse commandResponse = new CommandResponse();
	ErrorCode2 errCode = ErrorCode2.ERROR;
	try {
		ApiDeviceProfileProto.ApiDeviceProfileRequest request = ApiDeviceProfileProto.ApiDeviceProfileRequest
				.parseFrom(command.getParams());
		String siteUserId = command.getSiteUserId();
		String deviceId = request.getDeviceId();
		LogUtils.requestDebugLog(logger, command, request.toString());

		if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(deviceId)) {
			UserDeviceBean deviceBean = UserDeviceDao.getInstance().getDeviceDetails(siteUserId, deviceId);
			DeviceProto.SimpleDeviceProfile deviceProfile = DeviceProto.SimpleDeviceProfile.newBuilder()
					.setDeviceId(String.valueOf(deviceBean.getDeviceId()))
					.setDeviceName(String.valueOf(deviceBean.getDeviceName()))
					.setLastLoginTime(deviceBean.getLoginTime()).build();
			ApiDeviceProfileProto.ApiDeviceProfileResponse response = ApiDeviceProfileProto.ApiDeviceProfileResponse
					.newBuilder().setDeviceProfile(deviceProfile)
					.setLoginIp(String.valueOf(deviceBean.getDeviceIp()))
					.setLastActiveTime(deviceBean.getActiveTime()).build();
			commandResponse.setParams(response.toByteArray());
			errCode = ErrorCode2.SUCCESS;
		} else {
			errCode = ErrorCode2.ERROR_PARAMETER;
		}
	} catch (Exception e) {
		errCode = ErrorCode2.ERROR_SYSTEMERROR;
		LogUtils.requestErrorLog(logger, command, e);
	}
	return commandResponse.setErrCode2(errCode);
}
 
Example #2
Source File: ApiDeviceService.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public CommandResponse profile(Command command) {
	CommandResponse commandResponse = new CommandResponse();
	ErrorCode2 errCode = ErrorCode2.ERROR;
	try {
		ApiDeviceProfileProto.ApiDeviceProfileRequest request = ApiDeviceProfileProto.ApiDeviceProfileRequest
				.parseFrom(command.getParams());
		String siteUserId = command.getSiteUserId();
		String deviceId = request.getDeviceId();
		LogUtils.requestDebugLog(logger, command, request.toString());

		if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(deviceId)) {
			UserDeviceBean deviceBean = UserDeviceDao.getInstance().getDeviceDetails(siteUserId, deviceId);
			DeviceProto.SimpleDeviceProfile deviceProfile = DeviceProto.SimpleDeviceProfile.newBuilder()
					.setDeviceId(String.valueOf(deviceBean.getDeviceId()))
					.setDeviceName(String.valueOf(deviceBean.getDeviceName()))
					.setLastLoginTime(deviceBean.getLoginTime()).build();
			ApiDeviceProfileProto.ApiDeviceProfileResponse response = ApiDeviceProfileProto.ApiDeviceProfileResponse
					.newBuilder().setDeviceProfile(deviceProfile)
					.setLoginIp(String.valueOf(deviceBean.getDeviceIp()))
					.setLastActiveTime(deviceBean.getActiveTime()).build();
			commandResponse.setParams(response.toByteArray());
			errCode = ErrorCode2.SUCCESS;
		} else {
			errCode = ErrorCode2.ERROR_PARAMETER;
		}
	} catch (Exception e) {
		errCode = ErrorCode2.ERROR_SYSTEMERROR;
		LogUtils.requestErrorLog(logger, command, e);
	}
	return commandResponse.setErrCode2(errCode);
}
 
Example #3
Source File: ApiDeviceService.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public CommandResponse profile(Command command) {
	CommandResponse commandResponse = new CommandResponse();
	ErrorCode2 errCode = ErrorCode2.ERROR;
	try {
		ApiDeviceProfileProto.ApiDeviceProfileRequest request = ApiDeviceProfileProto.ApiDeviceProfileRequest
				.parseFrom(command.getParams());
		String siteUserId = command.getSiteUserId();
		String deviceId = request.getDeviceId();
		LogUtils.requestDebugLog(logger, command, request.toString());

		if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(deviceId)) {
			UserDeviceBean deviceBean = UserDeviceDao.getInstance().getDeviceDetails(siteUserId, deviceId);
			DeviceProto.SimpleDeviceProfile deviceProfile = DeviceProto.SimpleDeviceProfile.newBuilder()
					.setDeviceId(String.valueOf(deviceBean.getDeviceId()))
					.setDeviceName(String.valueOf(deviceBean.getDeviceName()))
					.setLastLoginTime(deviceBean.getLoginTime()).build();
			ApiDeviceProfileProto.ApiDeviceProfileResponse response = ApiDeviceProfileProto.ApiDeviceProfileResponse
					.newBuilder().setDeviceProfile(deviceProfile)
					.setLoginIp(String.valueOf(deviceBean.getDeviceIp()))
					.setLastActiveTime(deviceBean.getActiveTime()).build();
			commandResponse.setParams(response.toByteArray());
			errCode = ErrorCode2.SUCCESS;
		} else {
			errCode = ErrorCode2.ERROR_PARAMETER;
		}
	} catch (Exception e) {
		errCode = ErrorCode2.ERROR_SYSTEMERROR;
		LogUtils.requestErrorLog(logger, command, e);
	}
	return commandResponse.setErrCode2(errCode);
}