store.setReadOnlyMode(TRANSIENT_STATE);
int serviceResponseType = Integer.parseInt(req
.getParameter("responseType"));
for (Iterator<Service> iterator = services.iterator(); iterator
.hasNext();) {
Service service = iterator.next();
service.setServiceResponseType(serviceResponseType);
store.saveOrUpdateService(service);
}
} catch (Exception e) {
logger.error("Unable to update service(s", e);
}
// #3 Return store back to original setting.
store.setReadOnlyMode(origReadOnlyMode);
resp.setContentType("application/json");
PrintWriter out = resp.getWriter();
Map<String, String> successMessage = new HashMap<String, String>();
successMessage.put("success", "updated");
String resultingJSON = Util.getJSON(successMessage);
out.println(resultingJSON);
out.flush();
out.close();
return;
}
Long serviceId = null;
try {
serviceId = new Long(req.getParameter("serviceId"));
} catch (Exception e) {
// Do nothing
}
if (req.getParameter("deleteService") != null && serviceId != null) {
Service service = store.getServiceById(serviceId);
store.deleteService(service);
store.deleteFulfilledClientRequestsForService(serviceId);
Util.saveSuccessMessage("Service '" + service.getServiceName()
+ "' was deleted.", req);
// Check to see if any plans need an update.
String errorMessage = null;
if (service.isReferencedInAServicePlan()) {
errorMessage = "Warning: the deleted service is referenced in service plans.";
}
if (errorMessage != null) {
Util.saveErrorMessage(errorMessage, req);
}
String contextRoot = req.getContextPath();
resp.sendRedirect(Url.getContextAwarePath("home", contextRoot));
return;
} else if (req.getParameter("duplicateService") != null
&& serviceId != null) {
Service service = store.getServiceById(serviceId);
Service duplicateService = store.duplicateService(service);
String contextRoot = req.getContextPath();
resp.sendRedirect(Url.getContextAwarePath("setup?serviceId="
+ duplicateService.getId(), contextRoot));
return;
}
super.service(req, resp);
}