From f4ffabf9abc6c1049a74f0fde006e706378ad70c Mon Sep 17 00:00:00 2001 From: Wikum Weerakutti Date: Mon, 29 Jan 2024 22:50:58 +0530 Subject: [PATCH] LU-181: Include suffix in controller urls (#67) --- .../web/controller/ExportController.java | 28 +++++++-------- .../web/controller/ImportController.java | 36 +++++++++---------- .../web/controller/TaskController.java | 4 +-- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/ExportController.java b/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/ExportController.java index 98eb4354..2fa9bc38 100644 --- a/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/ExportController.java +++ b/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/ExportController.java @@ -111,7 +111,7 @@ public class ExportController { @Autowired private JsonObjectView jsonView; - @RequestMapping(LIST_PATH) + @RequestMapping(LIST_PATH + ".form") public void list(Model model) { List packages = getService().getAllExportedPackageSummaries(); Map latestVersion = new HashMap(); @@ -153,7 +153,7 @@ public void list(Model model) { * Gets all packages with the given group and passes to the model (they will be rendered in .jsp * page) */ - @RequestMapping(DETAILS_PATH) + @RequestMapping(DETAILS_PATH + ".form") public String details(String group, Model model) { List packages = new ArrayList(); for (ExportedPackageSummary summary : getService().getAllExportedPackageSummaries()) { @@ -174,7 +174,7 @@ public String details(String group, Model model) { } } - @RequestMapping(DELETE_PATH) + @RequestMapping(DELETE_PATH + ".form") public String delete(Integer id, Model model) { ExportedPackage pack = MetadataSharing.getService().getExportedPackageById(id); if (pack != null) { @@ -206,14 +206,14 @@ public String togglePublished(Integer id, Model model) { } } - @RequestMapping(DOWNLOAD_PATH) + @RequestMapping(DOWNLOAD_PATH + ".form") public ModelAndView download(Integer id, Model model) { ExportedPackage pack = MetadataSharing.getService().getExportedPackageById(id); model.addAttribute("package", pack); return new ModelAndView(downloadPackageView); } - @RequestMapping(value = CREATE_PATH, method = RequestMethod.GET) + @RequestMapping(value = CREATE_PATH + ".form", method = RequestMethod.GET) public void create(Model model) { if (!model.containsAttribute(EXPORTER)) { model.addAttribute(EXPORTER, MetadataSharing.getInstance().newPackageExporter()); @@ -221,7 +221,7 @@ public void create(Model model) { model.addAttribute("publishConfigured", MetadataSharing.getInstance().isPublishConfigured()); } - @RequestMapping(value = UPGRADE_PATH) + @RequestMapping(value = UPGRADE_PATH + ".form") public String upgrade(Integer id, Boolean empty, Model model) throws SerializationException, IOException { ExportedPackage exportedPackage = MetadataSharing.getService().getExportedPackageById(id); PackageVersioner versioner = null; @@ -257,7 +257,7 @@ public String upgrade(Integer id, Boolean empty, Model model) throws Serializati return WebUtils.redirect(CREATE_PATH); } - @RequestMapping(value = CREATE_PATH, method = RequestMethod.POST) + @RequestMapping(value = CREATE_PATH + ".form", method = RequestMethod.POST) public String create(@ModelAttribute(EXPORTER) PackageExporter exporter, Errors errors, Model model) { model.addAttribute("publishConfigured", MetadataSharing.getInstance().isPublishConfigured()); @@ -279,11 +279,11 @@ public String create(@ModelAttribute(EXPORTER) } } - @RequestMapping(value = EDIT_PATH) + @RequestMapping(value = EDIT_PATH + ".form") public void edit() { } - @RequestMapping(value = ADD_ALL_ITEMS_PATH) + @RequestMapping(value = ADD_ALL_ITEMS_PATH + ".form") public String addAllItems(@ModelAttribute(PACKAGE_ITEMS) PackageItems packageItems, String type, Boolean includeRetired) { if (includeRetired) { @@ -302,7 +302,7 @@ public String addAllItems(@ModelAttribute(PACKAGE_ITEMS) return WebUtils.redirect(EDIT_PATH); } - @RequestMapping(value = REMOVE_ALL_ITEMS_PATH) + @RequestMapping(value = REMOVE_ALL_ITEMS_PATH + ".form") public String removeAllItems(@ModelAttribute(PACKAGE_ITEMS) PackageItems packageItems, String type) { packageItems.getCompleteTypes().remove(type); @@ -310,7 +310,7 @@ public String removeAllItems(@ModelAttribute(PACKAGE_ITEMS) return WebUtils.redirect(EDIT_PATH); } - @RequestMapping(value = SELECT_ITEMS_PATH, method = RequestMethod.GET) + @RequestMapping(value = SELECT_ITEMS_PATH + ".form", method = RequestMethod.GET) public void selectItems(@RequestParam(required = false) String type, Model model) { if (type == null) { @@ -322,7 +322,7 @@ public void selectItems(@RequestParam(required = false) // Items will be fetched with JSON. } - @RequestMapping(value = SELECT_ITEMS_PATH, method = RequestMethod.POST) + @RequestMapping(value = SELECT_ITEMS_PATH + ".form", method = RequestMethod.POST) public String selectItems(@ModelAttribute(PACKAGE_ITEMS) PackageItems packageItems, String type, HttpServletRequest request) { String[] addUuids = request.getParameterValues("addUuids"); @@ -372,7 +372,7 @@ public String selectItems(@ModelAttribute(PACKAGE_ITEMS) return WebUtils.redirect(EDIT_PATH); } - @RequestMapping(JSON_ITEMS_PATH) + @RequestMapping(JSON_ITEMS_PATH + ".form`") public ModelAndView jsonItems(@ModelAttribute(PACKAGE_ITEMS) PackageItems packageItems, String type, HttpServletRequest httpRequest, Model model) throws IOException { DatatablesRequest request = DatatablesRequest.parseRequest(httpRequest); @@ -421,7 +421,7 @@ public ModelAndView jsonItems(@ModelAttribute(PACKAGE_ITEMS) return new ModelAndView(jsonView); } - @RequestMapping(value = COMPLETE_PATH, method = RequestMethod.POST) + @RequestMapping(value = COMPLETE_PATH + ".form", method = RequestMethod.POST) public String complete(@ModelAttribute(EXPORTER) PackageExporter exporter, Errors errors, @ModelAttribute(PACKAGE_ITEMS) PackageItems packageItems, Model model, SessionStatus session) { diff --git a/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/ImportController.java b/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/ImportController.java index 41d26523..a2fc9dde 100644 --- a/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/ImportController.java +++ b/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/ImportController.java @@ -153,12 +153,12 @@ public class ImportController { @Autowired private SubscriptionUpdater updater; - @RequestMapping(LIST_PATH) + @RequestMapping(LIST_PATH + ".form") public void list(Model model) { model.addAttribute("subscriptions", MetadataSharing.getService().getAllImportedPackages()); } - @RequestMapping(value = TOGGLE_SUBSCRIBE_PATH, method = RequestMethod.GET) + @RequestMapping(value = TOGGLE_SUBSCRIBE_PATH + ".form", method = RequestMethod.GET) public String toggleSubscribe(Integer id) { ImportedPackage importedPackage = MetadataSharing.getService().getImportedPackageById(id); if (importedPackage != null) { @@ -172,7 +172,7 @@ public String toggleSubscribe(Integer id) { return WebUtils.redirect(LIST_PATH); } - @RequestMapping(value = DELETE_SUBSCRIBE_PATH, method = RequestMethod.GET) + @RequestMapping(value = DELETE_SUBSCRIBE_PATH + ".form", method = RequestMethod.GET) public String purgeSubscribe(Integer id) { ImportedPackage importedPackage = MetadataSharing.getService().getImportedPackageById(id); if (importedPackage != null) { @@ -182,7 +182,7 @@ public String purgeSubscribe(Integer id) { } - @RequestMapping(value = JSON_CHECK_UPDATES_PATH, method = RequestMethod.GET) + @RequestMapping(value = JSON_CHECK_UPDATES_PATH + ".form", method = RequestMethod.GET) public ModelAndView jsonCheckUpdates(Integer id, ModelMap model) { ImportedPackage importedPackage = MetadataSharing.getService().getImportedPackageById(id); if (importedPackage != null && importedPackage.isSubscribed()) { @@ -263,12 +263,12 @@ public ModelAndView jsonPerformDownload(@ModelAttribute(DOWNLOADER) return new ModelAndView(jsonObjectView); } - @RequestMapping(value = UPLOAD_PATH, method = RequestMethod.GET) + @RequestMapping(value = UPLOAD_PATH + ".form", method = RequestMethod.GET) public void upload(SessionStatus status) { status.setComplete(); } - @RequestMapping(value = UPLOAD_PATH, method = RequestMethod.POST) + @RequestMapping(value = UPLOAD_PATH + ".form", method = RequestMethod.POST) public String uploadPOST(UploadForm uploadForm, Errors errors, Model model) throws IOException { uploadFormValidator.validate(uploadForm, errors); if (errors.hasErrors()) { @@ -315,13 +315,13 @@ public String uploadPOST(UploadForm uploadForm, Errors errors, Model model) thro } } - @RequestMapping(value = VALIDATE_PATH, method = RequestMethod.GET) + @RequestMapping(value = VALIDATE_PATH + ".form", method = RequestMethod.GET) public void validate(@ModelAttribute(IMPORTER) PackageImporter importer, Errors errors) throws SerializationException { packageContainerValidator.validateForErrorsAndWarnings(importer, errors); } - @RequestMapping(value = VALIDATE_PATH, method = RequestMethod.POST) + @RequestMapping(value = VALIDATE_PATH + ".form", method = RequestMethod.POST) public String validatePOST(@ModelAttribute(IMPORTER) PackageImporter importer, Errors errors) { packageContainerValidator.validate(importer, errors); @@ -333,11 +333,11 @@ public String validatePOST(@ModelAttribute(IMPORTER) } } - @RequestMapping(value = MODE_PATH, method = RequestMethod.GET) + @RequestMapping(value = MODE_PATH + ".form", method = RequestMethod.GET) public void mode() { } - @RequestMapping(value = MODE_PATH, method = RequestMethod.POST) + @RequestMapping(value = MODE_PATH + ".form", method = RequestMethod.POST) public String modePOST(@ModelAttribute(IMPORTER) PackageImporter importer, String importMode) { ImportMode mode = ImportMode.valueOf(importMode); @@ -354,12 +354,12 @@ public String modePOST(@ModelAttribute(IMPORTER) return WebUtils.redirect(CONFIG_PATH); } - @RequestMapping(value = CONFIG_PATH, method = RequestMethod.GET) + @RequestMapping(value = CONFIG_PATH + ".form", method = RequestMethod.GET) public void config(@ModelAttribute(IMPORTER) PackageImporter importer) { } - @RequestMapping(value = CONFIG_PATH, method = RequestMethod.POST) + @RequestMapping(value = CONFIG_PATH + ".form", method = RequestMethod.POST) public String configPOST(@ModelAttribute(IMPORTER) PackageImporter importer, Model model) throws IOException { ImportedPackage importedPackage = MetadataSharing.getService().getImportedPackageByGroup( @@ -380,7 +380,7 @@ public String configPOST(@ModelAttribute(IMPORTER) return WebUtils.redirect(LOAD_PATH); } - @RequestMapping(value = LOAD_PATH, params = "part") + @RequestMapping(value = LOAD_PATH + ".form", params = "part") public String load(@ModelAttribute(IMPORTER) PackageImporter importer, @ModelAttribute(PARTS) Map parts, Integer part, Model model) { @@ -412,7 +412,7 @@ public String load(@ModelAttribute(IMPORTER) } } - @RequestMapping(LOAD_PATH) + @RequestMapping(LOAD_PATH + ".form") public String load(@ModelAttribute(IMPORTER) PackageImporter importer, @ModelAttribute(ITEMS_STATS) ImportedItemsStats stats, @ModelAttribute(PARTS) @@ -429,7 +429,7 @@ public String load(@ModelAttribute(IMPORTER) return VIEW_PATH; } - @RequestMapping(VIEW_PATH) + @RequestMapping(VIEW_PATH + ".form") public void view(@ModelAttribute(IMPORTER) PackageImporter importer, @ModelAttribute(ITEMS_STATS) ImportedItemsStats stats, @ModelAttribute(PARTS) @@ -444,7 +444,7 @@ public void view(@ModelAttribute(IMPORTER) model.addAttribute(ITEMS_STATS, itemsStats); } - @RequestMapping(value = COMPLETE_PATH) + @RequestMapping(value = COMPLETE_PATH + ".form") public String complete(@ModelAttribute(IMPORTER) PackageImporter importer, Errors errors, Model model, SessionStatus session) { Task task = importer.schedulePackageImport(); @@ -573,7 +573,7 @@ public void assessItem(@ModelAttribute(ITEMS) model.addAttribute(assessItemForm); } - @RequestMapping(value = ITEM_PATH, method = RequestMethod.GET, params = "uuid") + @RequestMapping(value = ITEM_PATH + ".form", method = RequestMethod.GET, params = "uuid") public void assessItem(@ModelAttribute(ITEMS) List items, Integer index, String uuid, Model model) { ImportedItem importedItem = items.get(index); @@ -589,7 +589,7 @@ public void assessItem(@ModelAttribute(ITEMS) assessItem(items, index, model); } - @RequestMapping(value = ITEM_PATH, method = RequestMethod.POST) + @RequestMapping(value = ITEM_PATH + ".form", method = RequestMethod.POST) public String assessItemPOST(@ModelAttribute(ITEMS) List items, AssessItemForm assessItemForm, Model model) { ImportedItem importedItem = items.get(assessItemForm.getIndex()); diff --git a/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/TaskController.java b/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/TaskController.java index 9ab65467..262fc534 100644 --- a/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/TaskController.java +++ b/omod/src/main/java/org/openmrs/module/metadatasharing/web/controller/TaskController.java @@ -45,7 +45,7 @@ public class TaskController { @Autowired private TaskEngine taskEngine; - @RequestMapping(value = LIST_PATH) + @RequestMapping(value = LIST_PATH + ".form") public void list(Model model) { model.addAttribute(TASKS, taskEngine.getTasks()); } @@ -56,7 +56,7 @@ public String remove(String uuid, HttpSession session) { return WebUtils.redirect(LIST_PATH); } - @RequestMapping(value = DETAILS_PATH) + @RequestMapping(value = DETAILS_PATH + ".form") public void details(String uuid, Model model) { Task task = taskEngine.getTask(uuid); model.addAttribute(TASK, task);