Skip to content
Snippets Groups Projects
Commit e59c98b0 authored by Felix Sidokhine's avatar Felix Sidokhine
Browse files

added update of device name

parent 5cb5b7bc
No related branches found
No related tags found
No related merge requests found
......@@ -36,10 +36,17 @@ public class DeviceServlet extends HttpServlet {
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String username = req.getParameter("username");
String deviceId = req.getParameter("deviceId");
StatementList statementList = new StatementList();
StatementElement st0 = new StatementElement()
String deviceName = req.getParameter("deviceName");
StatementList update = new StatementList();
StatementElement st0 = new StatementElement("deviceName","=",deviceName,"");
update.addStatement(st0);
StatementList constraint = new StatementList();
StatementElement st1 = new StatementElement("owner","=",username,"AND");
StatementElement st2 = new StatementElement("deviceId","=",deviceId,"");
update.addStatement(st1);
update.addStatement(st2);
if(dataStore.getDeviceDao().updateObject(update,constraint)) resp.setStatus(200);
else resp.sendError(500,"could not update the device's information!");
}
//Revoke/delete a device.
......
......@@ -47,7 +47,19 @@ public class DeviceServlet extends HttpServlet {
@Override
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doPut(req, resp);
String username = req.getAttribute("username").toString();
String deviceId = req.getParameter("deviceId");
String deviceName = req.getParameter("deviceName");
StatementList update = new StatementList();
StatementElement st0 = new StatementElement("deviceName","=",deviceName,"");
update.addStatement(st0);
StatementList constraint = new StatementList();
StatementElement st1 = new StatementElement("owner","=",username,"AND");
StatementElement st2 = new StatementElement("deviceId","=",deviceId,"");
update.addStatement(st1);
update.addStatement(st2);
if(dataStore.getDeviceDao().updateObject(update,constraint)) resp.setStatus(200);
else resp.sendError(500,"could not update the device's information!");
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment