Synchronizing changes from Boeing to open source#137
Synchronizing changes from Boeing to open source#137dlamoris merged 3 commits intoOpen-MBEE:developfrom
Conversation
Branch id input sanitization Add option to disable TWC auth delegation & host parsing cleanup Added TokenService to allow use of tokens in other contexts Allow password setting for admins (user conversion from external to internal) Handle setting of null passwords (user conversion from internal to external)
| public String getSuffix() { | ||
| String refId = ContextHolder.getContext().getBranchId(); | ||
| return refId.equals(ContextObject.MASTER_BRANCH) ? "" : refId.toLowerCase(); | ||
| if(Pattern.matches("^[a-zA-Z0-9-_]*$", refId)) { |
There was a problem hiding this comment.
getSuffix() is used in a number of places multiple times in our DAOs. Recompiling the pattern every time could potentially have an effect on performance, albeit, probably not significantly.
There was a problem hiding this comment.
there's a BRANCH_ID_VALID_PATTERN in the BranchesController - may be better if that gets moved to core Formats?
There was a problem hiding this comment.
updated to use a common Pattern
| } | ||
|
|
||
| private static String stripHost(String url) { | ||
| Pattern pattern = Pattern.compile("(https?://)?([\\w-\\.]*)(:\\d+)?"); |
There was a problem hiding this comment.
Should check this and possibly move it to a static final.
| package org.openmbee.mms.core.objects; | ||
|
|
||
| public class ElementsCommitResponse extends ElementsResponse { | ||
| private String commitId; |
Moved BRANCH_ID_VALID_PATTERN to core Constants & used both places Added @Schema annotation to ElementsCommitResponse
| public String getSuffix() { | ||
| String refId = ContextHolder.getContext().getBranchId(); | ||
| if(Pattern.matches("^[a-zA-Z0-9-_]*$", refId)) { | ||
| if(Pattern.matches(BRANCH_ID_VALID_PATTERN, refId)) { |
There was a problem hiding this comment.
From what I understand Pattern.matches(String, String) is a convenience method that does Pattern.matches(Pattern.compile(String), String) for regex patterns that are used only once. The expensive bit is Pattern.compile, which should instead be defined as static final so that it is only compiled once at initialization.
There was a problem hiding this comment.
Changed to a static Pattern instead
Update ElementsResponse to include commit id when committing changes
Branch id input sanitization
Add option to disable TWC auth delegation & host parsing cleanup
Added TokenService to allow use of tokens in other contexts
Allow password setting for admins (user conversion from external to internal)
Handle setting of null passwords (user conversion from internal to external)