DefaultFDMSubmitServiceImpl.java
2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aem.dermis.slingmodel.Entity
* com.adobe.aem.dermis.slingmodel.FormDataModel
* com.adobe.aemds.guide.addon.fdm.submit.AbstractFDMSubmitService
* com.adobe.aemds.guide.model.FormSubmitInfo
* com.adobe.aemds.guide.service.FormSubmitActionService
* org.apache.commons.lang3.StringUtils
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.Resource
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.addon.service.impl.fdm;
import com.adobe.aem.dermis.slingmodel.Entity;
import com.adobe.aem.dermis.slingmodel.FormDataModel;
import com.adobe.aemds.guide.addon.fdm.submit.AbstractFDMSubmitService;
import com.adobe.aemds.guide.model.FormSubmitInfo;
import com.adobe.aemds.guide.service.FormSubmitActionService;
import org.apache.commons.lang3.StringUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=0, immediate=0)
@Service(value={FormSubmitActionService.class})
public class DefaultFDMSubmitServiceImpl
extends AbstractFDMSubmitService {
private static final String serviceName = "Submit using Form Data Model";
protected static Logger logger = LoggerFactory.getLogger(DefaultFDMSubmitServiceImpl.class);
public String getServiceName() {
return "Submit using Form Data Model";
}
public String getOperationName(FormSubmitInfo formSubmitInfo) throws Exception {
String operationName = null;
Resource guideContainerResource = this.getAdaptiveFormContainerResource(formSubmitInfo);
if (guideContainerResource == null) {
throw new Exception("Guide Container resource cannot be null");
}
String entityId = this.getEntityId(guideContainerResource);
if (StringUtils.isBlank((CharSequence)entityId)) {
throw new Exception("Missing entity name");
}
String formDataModelPath = this.getFormDataModelPath(guideContainerResource);
FormDataModel formDataModel = this.getFormDataModel(guideContainerResource);
if (formDataModel == null) {
throw new Exception("Incorrect form data model path configured for Adaptive Form -" + formDataModelPath);
}
if (formDataModel.getEntityById(entityId) == null) {
throw new Exception("Unable to find the entity with name " + entityId);
}
operationName = formDataModel.getEntityById(entityId).getDefaultWriteOperation();
return operationName;
}
}