-
Notifications
You must be signed in to change notification settings - Fork 61
feat: FORMS-25252 add server-side validation (SSV) #1902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,8 @@ public enum FormMetaDataType { | |
| SUBMIT_ACTION("submitAction"), | ||
| PREFILL_ACTION("prefillServiceProvider"), | ||
| LANG("lang"), | ||
| FORMATTERS("formatters"); | ||
| FORMATTERS("formatters"), | ||
| SSV_CLOUD_CONFIG("ssvCloudServiceConfiguration"); | ||
|
|
||
| private String value; | ||
|
|
||
|
|
@@ -174,6 +175,9 @@ private Boolean isLangPolicy(FormMetaDataType type, Map.Entry<String, Object> en | |
| private List<Resource> getDataSourceResources(SlingHttpServletRequest request, ResourceResolver resourceResolver, FormMetaDataType type, | ||
| String dataModel, Config config) { | ||
| List<Resource> resources = new ArrayList<>(); | ||
| if (type == FormMetaDataType.SSV_CLOUD_CONFIG) { | ||
| return getCloudConfigsByGroup(request, resourceResolver); | ||
| } | ||
| FormMetaData formMetaData = resourceResolver.adaptTo(FormMetaData.class); | ||
| if (formMetaData != null) { | ||
| Iterator<FormsManager.ComponentDescription> metaDataList = null; | ||
|
|
@@ -223,6 +227,64 @@ private List<Resource> getDataSourceResources(SlingHttpServletRequest request, R | |
| resources.add(getResourceForDropdownDisplay(resourceResolver, i18n.get("None"), "")); | ||
| resources.addAll(this.getResourceListFromComponentDescription(metaDataList, resourceResolver)); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| return resources; | ||
| } | ||
|
|
||
| private List<Resource> getCloudConfigsByGroup(SlingHttpServletRequest request, ResourceResolver resourceResolver) { | ||
| List<Resource> resources = new ArrayList<>(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is incorrect, we have helpers in cq-guides (addon) for such use-cases, you should re-use that |
||
| resources.add(getResourceForDropdownDisplay(resourceResolver, "None", "")); | ||
| String contentPath = (String) request.getAttribute(Value.CONTENTPATH_ATTRIBUTE); | ||
| Resource formResource = null; | ||
| if (StringUtils.isNotBlank(contentPath)) { | ||
| formResource = resourceResolver.getResource(contentPath); | ||
| } | ||
| if (formResource == null) { | ||
| formResource = request.getRequestPathInfo().getSuffixResource(); | ||
| } | ||
| String resolvedConfPath = null; | ||
| if (formResource != null) { | ||
| Resource r = formResource; | ||
| while (r != null) { | ||
| String confPath = r.getValueMap().get("cq:conf", String.class); | ||
| if (StringUtils.isNotBlank(confPath)) { | ||
| resolvedConfPath = confPath; | ||
| break; | ||
| } | ||
| // cq:conf lives on jcr:content for cq:Page and folder nodes | ||
| Resource pageContent = r.getChild(JcrConstants.JCR_CONTENT); | ||
| if (pageContent != null) { | ||
| confPath = pageContent.getValueMap().get("cq:conf", String.class); | ||
| if (StringUtils.isNotBlank(confPath)) { | ||
| resolvedConfPath = confPath; | ||
| break; | ||
| } | ||
| } | ||
| r = r.getParent(); | ||
| } | ||
| } | ||
| // Fall back to /conf/global when no cq:conf is found in the hierarchy — | ||
| // this mirrors AEM's own context-aware configuration resolution behaviour. | ||
| if (resolvedConfPath == null) { | ||
| resolvedConfPath = "/conf/global"; | ||
| } | ||
| // Query for any jcr:content node under cloudconfigs/ that carries serviceEndPoint, | ||
| // regardless of nesting depth (handles both flat and service-type-subfolder layouts). | ||
| String cloudConfigsBase = resolvedConfPath + "/settings/cloudconfigs"; | ||
| String query = "SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE(s, '" | ||
| + cloudConfigsBase + "') AND s.[serviceEndPoint] IS NOT NULL"; | ||
| Iterator<Resource> results = resourceResolver.findResources(query, "JCR-SQL2"); | ||
| while (results.hasNext()) { | ||
| Resource configContent = results.next(); | ||
| // configContent is the node with serviceEndPoint — its parent is the config root node | ||
| Resource configNode = configContent.getParent(); | ||
| if (configNode != null) { | ||
| String title = configContent.getValueMap().get("jcr:title", | ||
| configNode.getValueMap().get("jcr:title", configNode.getName())); | ||
| resources.add(getResourceForDropdownDisplay(resourceResolver, title, configNode.getPath())); | ||
| } | ||
| } | ||
| return resources; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ | |
| let defaultSubmissionError = FormView.LanguageUtils.getTranslatedString(self.getLang(), "InternalFormSubmissionError"); | ||
| const globals = { | ||
| form: self.getModel().getRuleNode(), | ||
| formModel: self.getModel(), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this required ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its not required. Removed it. |
||
| event: { | ||
| type: action.type, | ||
| payload: action.payload, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: comment not required here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.