
com.adobe.aemds.guide.utils.GuideModelUtils Maven / Gradle / Ivy
/*
* **********************************************************************
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2015 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
* **********************************************************************
*/
package com.adobe.aemds.guide.utils;
import com.adobe.aemds.guide.common.GuideContainer;
import com.adobe.aemds.guide.service.GuideSchemaType;
import org.apache.commons.lang.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.util.Iterator;
import java.util.Objects;
/**
* @pad.exclude Exclude from Published API.
*/
public class GuideModelUtils {
public static String getDataForDORMerge(Document dorDoc, Document dataDocument, JSONObject guideContainerJson)throws JSONException {
String xdpRef = guideContainerJson.has(GuideConstants.XDP_REF) ? guideContainerJson.getString(GuideConstants.XDP_REF) : null;
String xsdRef = guideContainerJson.has(GuideConstants.XSD_REF) ? guideContainerJson.getString(GuideConstants.XSD_REF) : null;
// get the excludeFromDorIfHidden flag from guide container, since we need it in the DOR Data XML
// If this is set, then the template id's are red from excludeFromDoR tag
String excludeFromDorIfHidden = guideContainerJson.has(GuideConstants.EXCLUDE_FROM_DOR_IF_HIDDEN) ? guideContainerJson.getString(GuideConstants.EXCLUDE_FROM_DOR_IF_HIDDEN) : null;
return getDataForDORMerge(dorDoc, dataDocument, xdpRef, xsdRef, excludeFromDorIfHidden, guideContainerJson);
}
@Deprecated
public static String getDataForDORMerge(Document dorDoc, Document dataDocument, Resource guideContainerResource) {
GuideContainer guideContainerBean = GuideContainer.from(guideContainerResource);
ValueMap guideContainerProps = guideContainerBean.getResource().adaptTo(ValueMap.class);
String schemaRef = guideContainerBean.getSchemaRef();
GuideSchemaType schemaType = guideContainerBean.getSchema();
String xdpRef = GuideSchemaType.XDP.equals(schemaType) ? schemaRef : null;
String xsdRef = GuideSchemaType.XSD.equals(schemaType) ? schemaRef : null;
String excludeFromDorIfHidden = guideContainerProps.get(GuideConstants.EXCLUDE_FROM_DOR_IF_HIDDEN, String.class);
return getDataForDORMerge(dorDoc, dataDocument, xdpRef, xsdRef, excludeFromDorIfHidden, new JSONObject());
}
private static String getDataForDORMerge(Document dorDoc, Document dataDocument, String xdpRef, String xsdRef, String excludeFromDorIfHidden, JSONObject guideJson) {
// Irrespective of type of AF(XSD, XFA, none), always invoke the getDataDorXML Part
// Even in case of XDP Based AF, the dor data xml would contain the unbound data if any
return XMLUtils.getDorDataXmlPart(dorDoc, dataDocument, excludeFromDorIfHidden, StringUtils.isEmpty(xdpRef), guideJson);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy