Skip to content

Commit 6ce05e1

Browse files
authored
Revert "FORMS-18986 XFA to AF (#1532)" (#1648)
This reverts commit 9b1eb2a.
1 parent 6e11b76 commit 6ce05e1

File tree

53 files changed

+305
-1129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+305
-1129
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
# auto-generated clientlib
1111
ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-base/**
12-
ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-base-xfa/**
1312

1413
# xfa not supported in 650 yet
1514
ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-base-xfa/**

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/ReservedProperties.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ private ReservedProperties() {
165165
public static final String FD_AUTO_SAVE_INTERVAL = "fd:autoSaveInterval";
166166
public static final String FD_EXCLUDE_FROM_DOR_IF_HIDDEN = "excludeFromDoRIfHidden";
167167

168-
public static final String FD_XFA_SCRIPTS = "fd:xfaScripts";
169-
170168
public static final String FD_DRAFT_ID = "fd:draftId";
171169

172170
// Begin: Form submission related properties

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractFormComponentImpl.java

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,17 @@
1717

1818
import java.io.IOException;
1919
import java.math.BigDecimal;
20-
import java.util.*;
20+
import java.util.AbstractMap;
21+
import java.util.Arrays;
22+
import java.util.Calendar;
23+
import java.util.Collections;
24+
import java.util.HashMap;
25+
import java.util.HashSet;
26+
import java.util.LinkedHashMap;
27+
import java.util.List;
28+
import java.util.Map;
29+
import java.util.Optional;
30+
import java.util.Set;
2131
import java.util.function.Predicate;
2232
import java.util.regex.Pattern;
2333
import java.util.stream.Collectors;
@@ -58,12 +68,9 @@
5868
import com.fasterxml.jackson.annotation.JsonInclude;
5969
import com.fasterxml.jackson.annotation.JsonProperty;
6070
import com.fasterxml.jackson.core.JsonGenerator;
61-
import com.fasterxml.jackson.databind.JsonNode;
6271
import com.fasterxml.jackson.databind.JsonSerializer;
63-
import com.fasterxml.jackson.databind.ObjectMapper;
6472
import com.fasterxml.jackson.databind.SerializerProvider;
6573
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
66-
import com.fasterxml.jackson.databind.node.ArrayNode;
6774

6875
public class AbstractFormComponentImpl extends AbstractComponentImpl implements FormComponent {
6976
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = ReservedProperties.PN_DATAREF)
@@ -291,10 +298,6 @@ protected boolean getEditMode() {
291298
if (rulesProperties.size() > 0) {
292299
properties.put(CUSTOM_RULE_PROPERTY_WRAPPER, rulesProperties);
293300
}
294-
List<String> disabledScripts = getDisabledXFAScripts();
295-
if (!disabledScripts.isEmpty()) {
296-
properties.put("fd:disabledXfaScripts", disabledScripts);
297-
}
298301
return properties;
299302
}
300303

@@ -547,24 +550,4 @@ public Map<String, Object> getDorProperties() {
547550
return customDorProperties;
548551
}
549552

550-
private List<String> getDisabledXFAScripts() {
551-
Set<String> disabledScripts = new HashSet<>();
552-
String xfaScripts = resource.getValueMap().get(ReservedProperties.FD_XFA_SCRIPTS, "");
553-
if (StringUtils.isNotEmpty(xfaScripts)) {
554-
// read string xfaScripts to jsonNode
555-
ObjectMapper mapper = new ObjectMapper();
556-
try {
557-
ArrayNode node = (ArrayNode) mapper.readTree(xfaScripts);
558-
// iterate through the array node and add the elements which have disabled property set to true
559-
for (JsonNode jsonNode : node) {
560-
if (jsonNode.has("disabled") && jsonNode.get("disabled").asBoolean()) {
561-
disabledScripts.add(jsonNode.get("activity").asText());
562-
}
563-
}
564-
} catch (IOException e) {
565-
logger.error("Error while parsing xfaScripts {} {}", e, resource.getPath());
566-
}
567-
}
568-
return new ArrayList<>(disabledScripts);
569-
}
570553
}

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.Arrays;
1919
import java.util.LinkedHashMap;
2020
import java.util.Map;
21-
import java.util.Optional;
2221
import java.util.stream.IntStream;
2322

2423
import org.apache.sling.models.annotations.Default;
@@ -116,7 +115,9 @@ public String[] getEnumNames() {
116115
Map<Object, String> map = getEnumPairs();
117116
String[] enumName = map.values().toArray(new String[0]);
118117
return Arrays.stream(enumName)
119-
.map(p -> Optional.ofNullable(translate(ReservedProperties.PN_ENUM_NAMES, p)).orElse(""))
118+
.map(p -> {
119+
return this.translate(ReservedProperties.PN_ENUM_NAMES, p);
120+
})
120121
.toArray(String[]::new);
121122
}
122123
return null;

bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v1/form/CheckBoxGroupImplTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public class CheckBoxGroupImplTest {
5757
private static final String PATH_CHECKBOX_GROUP_FOR_INSERTION_ORDER = CONTENT_ROOT + "/checkboxgroup-insertion-order";
5858
private static final String PATH_CHECKBOX_GROUP_FOR_BOOLEAN = CONTENT_ROOT + "/checkboxgroup-boolean";
5959
private static final String PATH_CHECKBOX_GROUP_NO_FIELDTYPE = CONTENT_ROOT + "/checkboxgroup-without-fieldtype";
60-
private static final String PATH_CHECKBOX_GROUP_WITH_NULL_VALUES = CONTENT_ROOT + "/checkboxgroup-with-null-values";
6160

6261
private final AemContext context = FormsCoreComponentTestContext.newAemContext();
6362

@@ -299,18 +298,6 @@ void testGetEnumNames() {
299298
assertArrayEquals(new String[] { "m", "f", "o" }, checkboxGroup.getEnumNames());
300299
}
301300

302-
@Test
303-
void testGetEnumNamesWithNullValues() throws Exception {
304-
// Get the checkbox group under test
305-
CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP);
306-
String[] modifiedEnumNames = new String[] { null, "", "value3" };
307-
FieldUtils.writeField(checkboxGroup, "enumNames", modifiedEnumNames, true);
308-
// Now call getEnumNames() which should handle the null value by converting it to an empty string
309-
String[] result = checkboxGroup.getEnumNames();
310-
// Verify that nulls are converted to empty strings
311-
assertArrayEquals(new String[] { "", "", "value3" }, result);
312-
}
313-
314301
@Test
315302
void testGetEnumNamesWithDuplicateEnumValues() {
316303
CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP_WITH_DUPLICATE_ENUMS);

bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/util/AbstractFormComponentImplTest.java

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.adobe.cq.forms.core.components.util;
1818

1919
import java.lang.reflect.Method;
20-
import java.util.List;
2120
import java.util.Map;
2221

2322
import org.apache.sling.api.resource.Resource;
@@ -49,9 +48,6 @@ public class AbstractFormComponentImplTest {
4948
private static final String PATH_COMPONENT_WITH_NO_VALIDATION_STATUS = CONTENT_ROOT + "/datepicker2";
5049
private static final String PATH_COMPONENT_WITH_INVALID_VALIDATION_STATUS = CONTENT_ROOT + "/datepicker3";
5150
private static final String PATH_COMPONENT_WITH_NO_RULE = CONTENT_ROOT + "/numberinput";
52-
private static final String PATH_COMPONENT_WITH_DISABLED_XFA_SCRIPTS = CONTENT_ROOT + "/xfacomponent";
53-
private static final String PATH_COMPONENT_WITH_INVALID_XFA_SCRIPTS = CONTENT_ROOT + "/xfacomponentinvalid";
54-
private static final String PATH_COMPONENT_WITH_NO_XFA_SCRIPTS = CONTENT_ROOT + "/xfacomponentnone";
5551
private static final String AF_PATH = "/content/forms/af/testAf";
5652
private static final String PAGE_PATH = "/content/testPage";
5753

@@ -105,34 +101,6 @@ public void testInvalidValidationStatusRule() {
105101
assertEquals("invalid", rulesProperties.get("validationStatus"));
106102
}
107103

108-
@Test
109-
public void testDisabledXFAScripts() {
110-
AbstractFormComponentImpl abstractFormComponentImpl = prepareTestClass(PATH_COMPONENT_WITH_DISABLED_XFA_SCRIPTS);
111-
Map<String, Object> properties = abstractFormComponentImpl.getProperties();
112-
List<String> disabledScripts = (List<String>) properties.get("fd:disabledXfaScripts");
113-
assertNotNull(disabledScripts);
114-
assertEquals(2, disabledScripts.size());
115-
assertTrue(disabledScripts.contains("click"));
116-
assertTrue(disabledScripts.contains("change"));
117-
}
118-
119-
@Test
120-
public void testInvalidXFAScripts() {
121-
AbstractFormComponentImpl abstractFormComponentImpl = prepareTestClass(PATH_COMPONENT_WITH_INVALID_XFA_SCRIPTS);
122-
Map<String, Object> properties = abstractFormComponentImpl.getProperties();
123-
Object disabledScripts = properties.get("fd:disabledXfaScripts");
124-
// Even with invalid JSON, we should get an empty list, not null
125-
assertNull(disabledScripts);
126-
}
127-
128-
@Test
129-
public void testNoXFAScripts() {
130-
AbstractFormComponentImpl abstractFormComponentImpl = prepareTestClass(PATH_COMPONENT_WITH_NO_XFA_SCRIPTS);
131-
Map<String, Object> properties = abstractFormComponentImpl.getProperties();
132-
Object disabledScripts = properties.get("fd:disabledXfaScripts");
133-
assertNull(disabledScripts);
134-
}
135-
136104
@Test
137105
public void testEmbedWithIframe() {
138106
Resource resource = Mockito.mock(Resource.class);
@@ -179,6 +147,7 @@ public Page getCurrentPageToTest() {
179147
}
180148
}
181149

150+
@Test
182151
private AbstractFormComponentImpl prepareTestClass(String path) {
183152
Resource resource = context.resourceResolver().getResource(path);
184153
AbstractFormComponentImpl abstractFormComponentImpl = new AbstractFormComponentImpl();

bundles/af-core/src/test/resources/form/checkboxgroup/test-content.json

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -269,25 +269,5 @@
269269
],
270270
"jcr:lastModified": "Tue Jul 30 2024 15:16:00 GMT+0530",
271271
"sling:resourceType": "forms-components-examples/components/form/checkboxgroup"
272-
},
273-
"checkboxgroup-with-null-values": {
274-
"id": "checkboxgroup-with-null-values",
275-
"jcr:primaryType": "nt:unstructured",
276-
"sling:resourceType": "core/fd/components/form/checkboxgroup/v1/checkboxgroup",
277-
"name": "nullValues",
278-
"jcr:title": "Null Values Test",
279-
"fieldType": "checkbox-group",
280-
"type": "number[]",
281-
"enum": [
282-
0,
283-
1,
284-
2
285-
],
286-
"enforceEnum": true,
287-
"enumNames": [
288-
"",
289-
"",
290-
"value3"
291-
]
292272
}
293273
}

bundles/af-core/src/test/resources/form/componentswithrule/test-content.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,5 @@
4343
"jcr:primaryType": "nt:unstructured",
4444
"validationStatus" : "someInvalidStatus"
4545
}
46-
},
47-
"xfacomponent": {
48-
"jcr:primaryType": "nt:unstructured",
49-
"fd:xfaScripts": "[{\"activity\":\"click\",\"disabled\":true},{\"activity\":\"change\",\"disabled\":true},{\"activity\":\"initialize\",\"disabled\":false}]"
50-
},
51-
"xfacomponentinvalid": {
52-
"jcr:primaryType": "nt:unstructured",
53-
"fd:xfaScripts": "invalid json"
54-
},
55-
"xfacomponentnone": {
56-
"jcr:primaryType": "nt:unstructured"
5746
}
5847
}

it/content/src/main/content/jcr_root/content/dam/formsanddocuments/core-components-it/samples/showHideRule.xdp/.content.xml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)