{"action":"closed","issue":{"url":"https://api.github.com/repos/USM-RCG/openhds-server/issues/44","labels_url":"https://api.github.com/repos/USM-RCG/openhds-server/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/USM-RCG/openhds-server/issues/44/comments","events_url":"https://api.github.com/repos/USM-RCG/openhds-server/issues/44/events","html_url":"https://github.com/USM-RCG/openhds-server/issues/44","id":37179763,"number":44,"title":"Implement a generic REST resource supertype?","user":{"login":"benjamin-heasly","id":1950775,"avatar_url":"https://avatars.githubusercontent.com/u/1950775?v=3","gravatar_id":"","url":"https://api.github.com/users/benjamin-heasly","html_url":"https://github.com/benjamin-heasly","followers_url":"https://api.github.com/users/benjamin-heasly/followers","following_url":"https://api.github.com/users/benjamin-heasly/following{/other_user}","gists_url":"https://api.github.com/users/benjamin-heasly/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamin-heasly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamin-heasly/subscriptions","organizations_url":"https://api.github.com/users/benjamin-heasly/orgs","repos_url":"https://api.github.com/users/benjamin-heasly/repos","events_url":"https://api.github.com/users/benjamin-heasly/events{/privacy}","received_events_url":"https://api.github.com/users/benjamin-heasly/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/USM-RCG/openhds-server/labels/internal%20/%20refactoring","name":"internal / refactoring","color":"5319e7"},{"url":"https://api.github.com/repos/USM-RCG/openhds-server/labels/low%20priority","name":"low priority","color":"fef2c0"},{"url":"https://api.github.com/repos/USM-RCG/openhds-server/labels/question","name":"question","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/USM-RCG/openhds-server/milestones/4","html_url":"https://github.com/USM-RCG/openhds-server/milestones/Re-factor%20around%20service%20uniformity%20and%20web%20error%20reporting%20","labels_url":"https://api.github.com/repos/USM-RCG/openhds-server/milestones/4/labels","id":680997,"number":4,"title":"Re-factor around service uniformity and web error reporting ","description":"We will re-factor service and web REST resources for uniformity of API and consistent, informative error reporting.\r\n\r\n---\r\n\r\nAt the service layer, we will implement a \"Layer Supertype\" pattern.  This will bring generic CRUD operations into each service implementation.  Currently, some crud operations are implemented in a distinct EntityService, and some are implemented in the services for specific entities.  This is confusing and complicates client code.\r\n\r\nAlso at the service layer we will implement a consistent method of error reporting: domain constraint violations and general errors should be \"bubbled up\" to the caller, not consumed but the services or coerced into new forms.  Services should return expected entities or other data, and throw exceptions when they encounter errors.  They should not try to report errors by returning null, or by modifying inputs like constraint violations objects.  All of this will support better error reporting from client code, like web services.\r\n\r\n---\r\n\r\nWe will revisit the web REST resources and re-implement them in the style of recent changes by Russell Gillen:\r\nhttps://github.com/USM-RCG/openhds-server/commit/23d21f54e9814daeb3edd0ab62c7135c8db3027f\r\n\r\nFor each REST resource, we will add support for four REST verbs: GET, POST, PUT, and DELETE.\r\n\r\nWe will also add support for XML and JSON inputs and outputs.  XML and JSON outputs should be based on the new WebserviceResult, with useful status codes, messages, and data payload.\r\n\r\nWe will also add integration tests for each REST resource to verify that correct CRUD operations from the resource methods.  Integration tests should use the re-factored services to verify CRUD results.\r\n\r\n---\r\n\r\nWe will also make miscellaneous improvements, such renaming misnamed database columns, which in turn affect domain class field names and may rise to the service API.","creator":{"login":"benjamin-heasly","id":1950775,"avatar_url":"https://avatars.githubusercontent.com/u/1950775?v=3","gravatar_id":"","url":"https://api.github.com/users/benjamin-heasly","html_url":"https://github.com/benjamin-heasly","followers_url":"https://api.github.com/users/benjamin-heasly/followers","following_url":"https://api.github.com/users/benjamin-heasly/following{/other_user}","gists_url":"https://api.github.com/users/benjamin-heasly/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamin-heasly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamin-heasly/subscriptions","organizations_url":"https://api.github.com/users/benjamin-heasly/orgs","repos_url":"https://api.github.com/users/benjamin-heasly/repos","events_url":"https://api.github.com/users/benjamin-heasly/events{/privacy}","received_events_url":"https://api.github.com/users/benjamin-heasly/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":25,"state":"open","created_at":"2014-06-04T19:35:28Z","updated_at":"2015-05-18T17:53:43Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2014-07-04T17:09:39Z","updated_at":"2015-05-18T17:53:43Z","closed_at":"2015-05-18T17:53:43Z","body":"Creating a separate REST resources for each service might require a lot of code duplication, especially if we want to support multiple HTTP verbs, XML, and JSON, for each resource.\r\n\r\nExample 11.3 of Spring in Practice suggests that we could factor out a lot of common code into a resource supertype:\r\nhttps://github.com/springinpractice/sip11/blob/master/service/src/main/java/com/springinpractice/ch11/web/controller/AbstractCrudController.java\r\n\r\nThis should conveniently support XML and JSON, as of Spring 3.2:\r\nhttps://jira.spring.io/browse/SPR-9153\r\n"}}