|
|
@@ -261,15 +261,13 @@ public class ManagementService extends DBServlet {
|
|
|
|
|
|
private JSON deleteUnit(JSONObject unitJson) throws SQLException, NoItemFoundException {
|
|
|
Long deletedUnit = db.manUtil.deleteUnit(unitJson);
|
|
|
- String message;
|
|
|
if (deletedUnit != null) {
|
|
|
- message = String.format("Unit '%s' was successfully deleted.", deletedUnit);
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ resultJson.put("message", String.format("Unit '%s' was successfully deleted.", deletedUnit));
|
|
|
+ return resultJson;
|
|
|
} else {
|
|
|
- message = "Unit can not be deleted.";
|
|
|
+ throw new SQLException("Unit can not be deleted.");
|
|
|
}
|
|
|
- JSONObject resultJson = new JSONObject();
|
|
|
- resultJson.put("message", message);
|
|
|
- return resultJson;
|
|
|
}
|
|
|
|
|
|
private JSON deleteSensor(JSONObject unitJson) throws SQLException, NoItemFoundException {
|