Skip to content

Commit 80657ca

Browse files
Merge pull request #1660 from adobe/FORMS-21058
Updates References to mark them optional as portal code base might no…
1 parent 2f8a692 commit 80657ca

File tree

13 files changed

+553
-144
lines changed

13 files changed

+553
-144
lines changed

.circleci/ci/it-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const { TYPE, BROWSER, AEM, PRERELEASE, FT, CONTEXTPATH, FTCONFIG} = process.env
2828
const latestVersion = ci.fetchLatestArtifactVersion('com.adobe.aemds', 'adobe-aemfd-linux-pkg');
2929
const classicFormAddonVersion = latestVersion !== null ? latestVersion : '6.0.1328'; // Use the latest version if available, otherwise default to '6.0.1256'
3030
// this value is for 6.5.21.0 version as per, https://experienceleague.adobe.com/en/docs/experience-manager-release-information/aem-release-updates/forms-updates/aem-forms-releases
31-
const classicFormReleasedAddonVersion = '6.0.1328';
31+
const classicFormReleasedAddonVersion = '6.0.1360';
3232

3333
try {
3434
ci.stage("Integration Tests");

bundles/core/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
<Import-Package>
8989
<!-- https://github.com/jhy/jsoup/issues/1616 -->
9090
javax.annotation;version=!;resolution:=optional,javax.annotation.meta;version=!;resolution:=optional,
91+
com.adobe.fd.fp.api.exception;resolution:=optional,
92+
com.adobe.fd.fp.api.models;resolution:=optional,
93+
com.adobe.fd.fp.api.service;resolution:=optional,
94+
com.adobe.forms.foundation.usc.model;resolution:=optional,
9195
<!-- com.adobe.cq.wcm.core.components.models;version="[12.0.0,13.0.0)", -->
9296
*
9397
</Import-Package>

bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/formsportal/DraftsAndSubmissionsImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ protected List<PortalLister.Item> getItemList() {
154154
switch (typeEnum) {
155155
case DRAFT:
156156
try {
157+
if (draftService == null) {
158+
LOGGER.info("DraftService is not available, please ensure AEM 6.5 Forms Service Pack 24 or later is installed.");
159+
return itemList;
160+
}
157161
List<DraftModel> list = draftService.getAllDraft(query);
158162
for (DraftModel draftModel : list) {
159163
PortalLister.Item item = getItem(draftModel.getFormPath(), typeEnum, draftModel.getId(),
@@ -166,6 +170,10 @@ protected List<PortalLister.Item> getItemList() {
166170
break;
167171
case SUBMISSION:
168172
try {
173+
if (submitService == null) {
174+
LOGGER.info("SubmitService is not available. Please ensure AEM 6.5 Forms Service Pack 24 or later is installed.");
175+
return itemList;
176+
}
169177
List<SubmitModel> list = submitService.getAllSubmission(query);
170178
for (SubmitModel submitModel : list) {
171179
PortalLister.Item item = getItem(submitModel.getFormPath(), typeEnum, submitModel.getId(),

bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/services/formsportal/DiscardDraftOperation.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
import org.osgi.service.component.annotations.Component;
2626
import org.osgi.service.component.annotations.Reference;
27+
import org.osgi.service.component.annotations.ReferenceCardinality;
28+
import org.osgi.service.component.annotations.ReferencePolicy;
2729
import org.slf4j.Logger;
2830
import org.slf4j.LoggerFactory;
2931

@@ -35,8 +37,7 @@
3537
import com.fasterxml.jackson.annotation.JsonIgnore;
3638

3739
@Component(
38-
service = Operation.class,
39-
immediate = true)
40+
service = Operation.class)
4041
public class DiscardDraftOperation implements Operation {
4142
private static final String OPERATION_NAME = "discardDraft";
4243
private static final String OPERATION_TITLE = "Discard";
@@ -45,8 +46,8 @@ public class DiscardDraftOperation implements Operation {
4546

4647
private String actionURL;
4748

48-
@Reference
49-
private DraftService draftService;
49+
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.OPTIONAL)
50+
private transient volatile DraftService draftService;
5051

5152
@Override
5253
public String getName() {
@@ -77,8 +78,13 @@ public OperationResult execute(Map<String, Object> parameterMap) {
7778
.collect(Collectors.toMap(Map.Entry::getKey, value -> (String[]) value.getValue()));
7879
String modelID = Arrays.stream(Objects.requireNonNull(map.get(Operation.OPERATION_MODEL_ID))).findFirst().orElse(null);
7980
try {
80-
draftService.deleteDraft(modelID);
81-
result.put("status", "success");
81+
if (draftService != null) {
82+
draftService.deleteDraft(modelID);
83+
result.put("status", "success");
84+
} else {
85+
LOGGER.info("Failed to fetch draft with ID {}. Ensure AEM 6.5 Forms Service Pack 24 or later is installed.", modelID);
86+
result.put("status", "fail");
87+
}
8288
} catch (FormsPortalException e) {
8389
LOGGER.error("Failed to delete draft with id " + modelID, e);
8490
result.put("status", "fail");

bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/services/formsportal/OpenDraftOperation.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.apache.sling.settings.SlingSettingsService;
2727
import org.osgi.service.component.annotations.Component;
2828
import org.osgi.service.component.annotations.Reference;
29+
import org.osgi.service.component.annotations.ReferenceCardinality;
30+
import org.osgi.service.component.annotations.ReferencePolicy;
2931
import org.slf4j.Logger;
3032
import org.slf4j.LoggerFactory;
3133

@@ -40,8 +42,7 @@
4042
import com.fasterxml.jackson.annotation.JsonIgnore;
4143

4244
@Component(
43-
service = Operation.class,
44-
immediate = true)
45+
service = Operation.class)
4546
public class OpenDraftOperation implements Operation {
4647
private static final String OPERATION_NAME = "openDraft";
4748
private static final String OPERATION_TITLE = "Open";
@@ -52,8 +53,8 @@ public class OpenDraftOperation implements Operation {
5253

5354
private String actionURL;
5455

55-
@Reference
56-
private DraftService draftService;
56+
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.OPTIONAL)
57+
private transient volatile DraftService draftService;
5758

5859
@Reference
5960
private SlingSettingsService slingSettings;
@@ -89,12 +90,17 @@ public OperationResult execute(Map<String, Object> parameterMap) {
8990
.collect(Collectors.toMap(Map.Entry::getKey, v -> (String[]) v.getValue()));
9091
String modelID = Arrays.stream(Objects.requireNonNull(map.get(OPERATION_MODEL_ID))).findFirst().orElse(null);
9192
try {
92-
DraftModel dm = draftService.getDraft(modelID);
93-
String formPath = GuideUtils.convertFMAssetPathToFormPagePath(GuideUtils.convertGuideContainerPathToFMAssetPath(dm
94-
.getFormPath()));
95-
String formLink = String.format(DRAFT_LINK, formPath, modelID, suffix);
96-
result.put("formLink", formLink);
97-
result.put("status", "success");
93+
if (draftService != null) {
94+
DraftModel dm = draftService.getDraft(modelID);
95+
String formPath = GuideUtils.convertFMAssetPathToFormPagePath(GuideUtils.convertGuideContainerPathToFMAssetPath(dm
96+
.getFormPath()));
97+
String formLink = String.format(DRAFT_LINK, formPath, modelID, suffix);
98+
result.put("formLink", formLink);
99+
result.put("status", "success");
100+
} else {
101+
LOGGER.info("Failed to fetch draft with ID {}. Ensure AEM 6.5 Forms Service Pack 24 or later is installed.", modelID);
102+
result.put("status", "fail");
103+
}
98104
} catch (FormsPortalException e) {
99105
LOGGER.error("Failed to fetch link for draft with id " + modelID, e);
100106
result.put("status", "fail");
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
3+
jcr:description="Search and Lister Component for the Core Components Library"
4+
jcr:primaryType="cq:Component"
5+
jcr:title="Search and Lister"
6+
sling:resourceSuperType="core/fd/components/formsportal/searchlister/v1/searchlister"
7+
componentGroup="Core Components Examples - Forms And Communications Portal"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
3+
jcr:primaryType="cq:Page">
4+
<jcr:content
5+
cq:allowedTemplates="[/conf/core-components-examples/settings/wcm/templates/.*]"
6+
cq:deviceGroups="[/etc/mobile/groups/responsive]"
7+
cq:lastModified="{Date}2020-04-13T12:48:41.174+03:00"
8+
cq:lastModifiedBy="admin"
9+
cq:template="/conf/core-components-examples/settings/wcm/templates/content-page"
10+
jcr:primaryType="nt:unstructured"
11+
jcr:title="Forms And Communications Portal"
12+
sling:redirect="{Boolean}true"
13+
sling:redirectStatus="{Long}302"
14+
sling:resourceType="foundation/components/redirect"
15+
hideInNav="true"
16+
redirectTarget="/content/core-components-examples/library"/>
17+
<link/>
18+
<searchlister/>
19+
</jcr:root>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
3+
jcr:primaryType="cq:Page">
4+
<jcr:content
5+
cq:lastModified="{Date}2020-07-15T13:25:39.732+02:00"
6+
cq:lastModifiedBy="admin"
7+
cq:tags="[]"
8+
cq:template="/conf/core-components-examples/settings/wcm/templates/content-page"
9+
jcr:description="Draft and submission of forms"
10+
jcr:primaryType="cq:PageContent"
11+
jcr:title="Drafts and Submissions"
12+
sling:resourceType="forms-components-examples/components/page">
13+
<root
14+
jcr:primaryType="nt:unstructured"
15+
sling:resourceType="wcm/foundation/components/responsivegrid">
16+
<responsivegrid
17+
jcr:primaryType="nt:unstructured"
18+
sling:resourceType="wcm/foundation/components/responsivegrid">
19+
<text_1740702241
20+
cq:styleIds="[1644862132301]"
21+
jcr:created="{Date}2019-02-15T19:05:53.032+01:00"
22+
jcr:createdBy="admin"
23+
jcr:lastModified="{Date}2019-02-15T19:09:39.787+01:00"
24+
jcr:lastModifiedBy="admin"
25+
jcr:primaryType="nt:unstructured"
26+
sling:resourceType="core-components-examples/components/text"
27+
text="&lt;h1>Drafts and Submissions Component&lt;sub>v1&lt;/sub>&lt;/h1>"
28+
textIsRich="true"/>
29+
<text
30+
cq:styleIds="[1544762734201]"
31+
jcr:created="{Date}2018-12-06T19:11:23.947+01:00"
32+
jcr:createdBy="admin"
33+
jcr:lastModified="{Date}2020-07-15T13:25:39.729+02:00"
34+
jcr:lastModifiedBy="admin"
35+
jcr:primaryType="nt:unstructured"
36+
sling:resourceType="core/wcm/components/text/v2/text"
37+
text="&lt;p>The drafts and submissions component is a server side component written in HTL, allowing to list all draft and submitted aem forms in a sites page."
38+
textIsRich="true"/>
39+
<teaser
40+
cq:styleIds="[1550165685463]"
41+
jcr:created="{Date}2019-02-14T16:41:54.952+01:00"
42+
jcr:createdBy="admin"
43+
jcr:description="&lt;p>GitHub&lt;/p>&#xd;&#xa;"
44+
jcr:lastModified="{Date}2019-02-14T16:49:57.290+01:00"
45+
jcr:lastModifiedBy="admin"
46+
jcr:primaryType="nt:unstructured"
47+
jcr:title="Technical Documentation"
48+
sling:resourceType="core-components-examples/components/teaser"
49+
actionsEnabled="false"
50+
descriptionFromPage="false"
51+
linkURL="https://github.com/adobe/aem-core-forms-components/tree/master/ui.apps/src/main/content/jcr_root/apps/core/fd/components/formsportal/draftsandsubmissions/v1/draftsandsubmissions"
52+
textIsRich="true"
53+
titleFromPage="false"/>
54+
<title_865328580
55+
cq:styleIds="[1544759664489]"
56+
jcr:created="{Date}2018-12-06T19:22:23.729+01:00"
57+
jcr:createdBy="admin"
58+
jcr:lastModified="{Date}2018-12-06T19:23:25.116+01:00"
59+
jcr:lastModifiedBy="admin"
60+
jcr:primaryType="nt:unstructured"
61+
jcr:title="Examples"
62+
sling:resourceType="core/wcm/components/title/v2/title"
63+
type="h2"/>
64+
<title_draft_title
65+
cq:styleIds="[1544759676459]"
66+
jcr:created="{Date}2018-12-06T19:22:48.620+01:00"
67+
jcr:createdBy="admin"
68+
jcr:lastModified="{Date}2019-05-22T11:01:40.926+03:00"
69+
jcr:lastModifiedBy="admin"
70+
jcr:primaryType="nt:unstructured"
71+
jcr:title="Drafts"
72+
sling:resourceType="core/wcm/components/title/v2/title"
73+
type="h3"/>
74+
<text_draft
75+
jcr:created="{Date}2018-12-06T19:23:41.968+01:00"
76+
jcr:createdBy="admin"
77+
jcr:lastModified="{Date}2019-05-22T11:26:32.604+03:00"
78+
jcr:lastModifiedBy="admin"
79+
jcr:primaryType="nt:unstructured"
80+
sling:resourceType="core/wcm/components/text/v2/text"
81+
text="&lt;p>Drafts selected in the component in card layout.&lt;/p>"
82+
textIsRich="true"/>
83+
<demo_draft
84+
jcr:created="{Date}2018-12-07T12:55:03.496+01:00"
85+
jcr:createdBy="admin"
86+
jcr:lastModified="{Date}2018-12-07T12:55:03.496+01:00"
87+
jcr:lastModifiedBy="admin"
88+
jcr:primaryType="nt:unstructured"
89+
sling:resourceType="forms-components-examples/components/demo">
90+
<component
91+
jcr:primaryType="nt:unstructured"
92+
sling:resourceType="core-components-examples/components/demo/component">
93+
<draftsandsubmissions
94+
jcr:created="{Date}2019-03-06T14:11:01.819+01:00"
95+
jcr:createdBy="admin"
96+
jcr:lastModified="{Date}2019-05-21T18:59:35.605+03:00"
97+
jcr:lastModifiedBy="admin"
98+
jcr:primaryType="nt:unstructured"
99+
title="Drafts"
100+
type="DRAFT"
101+
layout="card"
102+
sling:resourceType="forms-components-examples/components/draftsandsubmissions"/>
103+
</component>
104+
<info
105+
jcr:primaryType="nt:unstructured"
106+
sling:resourceType="core-components-examples/components/tabs">
107+
<properties
108+
cq:panelTitle="Properties"
109+
jcr:primaryType="nt:unstructured"
110+
sling:resourceType="core-components-examples/components/demo/properties"
111+
reference="../../component"/>
112+
<markup
113+
cq:panelTitle="Markup"
114+
jcr:primaryType="nt:unstructured"
115+
sling:resourceType="core-components-examples/components/demo/markup"
116+
reference="../../component"/>
117+
<json
118+
cq:panelTitle="JSON"
119+
jcr:primaryType="nt:unstructured"
120+
sling:resourceType="core-components-examples/components/demo/json"
121+
reference="../../component"/>
122+
</info>
123+
</demo_draft>
124+
<title_submission_title
125+
cq:styleIds="[1544759676459]"
126+
jcr:created="{Date}2018-12-06T19:22:48.620+01:00"
127+
jcr:createdBy="admin"
128+
jcr:lastModified="{Date}2019-05-22T11:01:40.926+03:00"
129+
jcr:lastModifiedBy="admin"
130+
jcr:primaryType="nt:unstructured"
131+
jcr:title="Submissions"
132+
sling:resourceType="core/wcm/components/title/v2/title"
133+
type="h3"/>
134+
<text_submission
135+
jcr:created="{Date}2018-12-06T19:23:41.968+01:00"
136+
jcr:createdBy="admin"
137+
jcr:lastModified="{Date}2019-05-22T11:26:32.604+03:00"
138+
jcr:lastModifiedBy="admin"
139+
jcr:primaryType="nt:unstructured"
140+
sling:resourceType="core/wcm/components/text/v2/text"
141+
text="&lt;p>Submissions selected in the component in list layout.&lt;/p>"
142+
textIsRich="true"/>
143+
<demo_submission
144+
jcr:created="{Date}2018-12-07T12:55:03.496+01:00"
145+
jcr:createdBy="admin"
146+
jcr:lastModified="{Date}2018-12-07T12:55:03.496+01:00"
147+
jcr:lastModifiedBy="admin"
148+
jcr:primaryType="nt:unstructured"
149+
sling:resourceType="forms-components-examples/components/demo">
150+
<component
151+
jcr:primaryType="nt:unstructured"
152+
sling:resourceType="core-components-examples/components/demo/component">
153+
<draftsandsubmissions
154+
jcr:created="{Date}2019-03-06T14:11:01.819+01:00"
155+
jcr:createdBy="admin"
156+
jcr:lastModified="{Date}2019-05-21T18:59:35.605+03:00"
157+
jcr:lastModifiedBy="admin"
158+
jcr:primaryType="nt:unstructured"
159+
title="Submissions"
160+
type="SUBMISSION"
161+
layout="list"
162+
sling:resourceType="forms-components-examples/components/draftsandsubmissions"/>
163+
</component>
164+
<info
165+
jcr:primaryType="nt:unstructured"
166+
sling:resourceType="core-components-examples/components/tabs">
167+
<properties
168+
cq:panelTitle="Properties"
169+
jcr:primaryType="nt:unstructured"
170+
sling:resourceType="core-components-examples/components/demo/properties"
171+
reference="../../component"/>
172+
<markup
173+
cq:panelTitle="Markup"
174+
jcr:primaryType="nt:unstructured"
175+
sling:resourceType="core-components-examples/components/demo/markup"
176+
reference="../../component"/>
177+
<json
178+
cq:panelTitle="JSON"
179+
jcr:primaryType="nt:unstructured"
180+
sling:resourceType="core-components-examples/components/demo/json"
181+
reference="../../component"/>
182+
</info>
183+
</demo_submission>
184+
</responsivegrid>
185+
</root>
186+
</jcr:content>
187+
</jcr:root>

0 commit comments

Comments
 (0)