use of com.qaprosoft.zafira.models.stf.STFDevice in project carina by qaprosoft.
the class DeviceInfo method process.
protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.setStatus(HttpStatus.SC_NOT_FOUND);
String id = request.getParameter("session");
if (id != null) {
TestSession session = this.getRegistry().getExistingSession(ExternalSessionKey.fromString(id));
if (session != null) {
Map<String, Object> cap = session.getSlot().getCapabilities();
if (cap.containsKey("udid")) {
RemoteDevice device = new RemoteDevice();
device.setName((String) cap.get("deviceName"));
device.setOs((String) cap.get("platformName"));
device.setOsVersion((String) cap.get("platformVersion"));
device.setType((String) cap.get("deviceType"));
device.setUdid((String) cap.get("udid"));
STFDevice stfDevice = STF.getDevice(device.getUdid());
if (stfDevice != null) {
device.setRemoteURL((String) stfDevice.getRemoteConnectUrl());
}
response.setStatus(HttpStatus.SC_OK);
response.getWriter().print(new ObjectMapper().writeValueAsString(device));
response.getWriter().close();
}
}
}
}
Aggregations