Scope authoring resource lookups to the action weblog - #162
Open
snoopdave wants to merge 1 commit into
Open
Conversation
Authoring actions resolve the resource named by a request parameter by id alone, independently of the weblog the action is operating on. Add weblog-scoped lookups beside the existing unscoped ones, modelled on getTemplateByLink(Weblog, String), and point the authoring actions at them: WeblogManager getTemplate(Weblog, String) WeblogEntryManager getWeblogEntry / getWeblogCategory / getComment BookmarkManager getBookmark, getFolderById MediaFileManager getMediaFile, getMediaFileDirectory Each is backed by a named query filtering on the owning weblog, and returns null when the id does not belong to that weblog, the same as for an id that does not exist. The bookmark folder lookup is named getFolderById because getFolder(Weblog, String) already exists as the by-name lookup and the two would otherwise share an erasure. Call sites updated across templates, entries, categories, comments, bookmarks, folders and media files. The two comment loops in Comments already compared the weblog after loading; they now use the scoped lookup instead, which also removes an NPE on ids that do not exist. Left unchanged, having been verified to resolve correctly by other means: EntryBean, StylesheetEdit, CommentDataServlet, and the XML-RPC and Atom handlers, which derive the weblog from the entity itself. Tests: WeblogScopedLookupTest (manager layer), TemplateEditScopingTest and AuthoringActionScopingTest (action layer). Full suite 182 run, 0 failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Roller's manager APIs expose two styles of lookup: by id, and by a weblog plus
some other key —
getTemplateByLink(Weblog, String),getTemplateByName(Weblog, String)and friends. The authoring UI operates inthe context of a single weblog throughout, but has only the id-based form
available for several resource types, so the two styles are mixed within the
same action.
This adds weblog-scoped overloads beside the existing id-based lookups and
points the authoring actions at them, so the lookups an action performs are
consistently expressed in terms of the weblog it is working on. The new
methods follow the shape of the existing
getTemplateByLink(Weblog, String)rather than introducing a different convention.
Manager methods added
WeblogManagergetTemplate(Weblog, String)WeblogTemplate.getByWeblog&IdWeblogEntryManagergetWeblogEntry(Weblog, String)WeblogEntry.getByWebsite&IdWeblogEntryManagergetWeblogCategory(Weblog, String)WeblogCategory.getByWeblog&IdWeblogEntryManagergetComment(Weblog, String)WeblogEntryComment.getByWebsite&IdBookmarkManagergetBookmark(Weblog, String)WeblogBookmark.getByWebsite&IdBookmarkManagergetFolderById(Weblog, String)WeblogBookmarkFolder.getByWebsite&IdMediaFileManagergetMediaFile(Weblog, String)MediaFile.getByWeblogAndIdMediaFileManagergetMediaFileDirectory(Weblog, String)MediaFileDirectory.getByWeblogAndIdEach is backed by a named query filtering on the owning weblog, and returns
null when there is no match.
The folder lookup is named
getFolderByIdrather than being an overload:getFolder(Weblog, String)already exists as the by-name lookup, and the twowould otherwise share an erasure.
Call sites
Updated across templates, entries, categories, comments, bookmarks, folders
and media files in
ui/struts2/editor/. The action weblog is resolved by theinterceptor stack (
params->UIActionInterceptor->UISecurityInterceptor->
UIActionPrepareInterceptor) beforemyPrepare()runs, sogetActionWeblog()is available at each of these call sites withoutreordering anything.
The two comment loops in
Commentspreviously compared the weblog afterloading; they now use the scoped lookup instead, which also removes an NPE on
ids with no match.
Not changed
RollerResourceLoaderandGlobalCommentManagementhave no single weblog incontext by design and keep the id-based lookups.
EntryBean,StylesheetEdit,CommentDataServletand the XML-RPC and Atom handlers reachtheir weblog by other means and were left alone.
Tests
business/WeblogScopedLookupTest— manager layer, covering each new overloadui/struts2/editor/TemplateEditScopingTest— action layerui/struts2/editor/AuthoringActionScopingTest— action layer, coveringEntryRemove,EntryEdit,CategoryRemoveandBookmarkEditFull suite on JDK 11: 182 run, 0 failures, 0 errors, 1 skipped.