XPath in Entitlement Aggregation

Hello guys!

trying to aggregate entitlements but unable to get the correct response. i configured this way

image



the aggregation aways returns 0 entitlements

Hi @rogerio_netbr, not sure if it’s going to work, but I think you should use the following “Root Path”: /DATA_DS/GL_USER and remove GL_USER from the attribute path.

Notice I didn’t use double / in the expression for Root Path.

I hope it helps!

Elisa.

1 Like

Hi @rogerio_netbr ,

Welcome to SailPoint Developer Community

Have you marked the entitlement attribute as entitlement type in Schema?
If not, please mark the attribute as entitlement and try to do the aggregation

Thanks

1 Like

Hi @mohammedfavazhrb !!

Hello Mohamed, I managed to configure it, but it still hasn’t worked. I’m also trying the solution Elisa suggested.

regards

Hello Elisa, thanks for the suggestion, but it still didn’t work this way… I’m not sure if this is common behavior, but I think it might be related to the way the endpoint responds to the requests. Notice that this XML response doesn’t have xml namespaces or even <?xml …> at the beginning of the document.

Have you seen anything like this before?

Hi Rogerio, no, I haven’t.

Another thing you can try (just trying to help, but not sure if it will work!)

Try adding a dot at the beginning of the Root Path expression: ./DATA_DS/GL_USER

Background: In my old days as web-tester, I worked with Xpath locators using Firebug (pre-DevTools days). For some reason I couldn’t understand, my tests needed the XPath selectors to be prepended with a “dot” because otherwise they weren’t found.

I hope that helps!

Elisa.

1 Like

Hi @rogerio_netbr,

Replace your root path with below:

.//DATA_DS/GL_USER

Thank you.

Thanks for the responses, everyone, but I gave up on doing it the conventional way and created this after rule instead haha

import java.util.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import java.io.StringReader;
import org.w3c.dom.NodeList;

if (!rawResponseObject.equals("")) {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(new InputSource(new StringReader(rawResponseObject)));

    XPathFactory xPathFactory = XPathFactory.newInstance();
    XPath xpath = xPathFactory.newXPath();

    String expression = "/DATA_DS/GL_USER";

    XPathExpression xPathExpression = xpath.compile(expression);

    NodeList entitlements = (NodeList) xPathExpression.evaluate(doc,javax.xml.xpath.XPathConstants.NODESET);

    Map processedResponse = new HashMap();
    String USER_ROLE_XID;
    String IS_RESERVED;
    String GL_LEVEL;
    String USER_ROLE_GID;
    String DATA_SOURCE_PROFILE_GID;
    String VPD_PROFILE_GID;
    String VPD_DOMAIN_NAME;
    String DOMAIN_NAME;
    for (int i = 1; i <= entitlements.getLength(); i++) {

        USER_ROLE_XID = xpath.compile("/DATA_DS/GL_USER["+i+"]/USER_ROLE_XID").evaluate(doc);
        IS_RESERVED = xpath.compile("/DATA_DS/GL_USER["+i+"]/IS_RESERVED").evaluate(doc);
        GL_LEVEL = xpath.compile("/DATA_DS/GL_USER["+i+"]/GL_LEVEL").evaluate(doc);
        USER_ROLE_GID = xpath.compile("/DATA_DS/GL_USER["+i+"]/USER_ROLE_GID").evaluate(doc);
        DATA_SOURCE_PROFILE_GID = xpath.compile("/DATA_DS/GL_USER["+i+"]/DATA_SOURCE_PROFILE_GID").evaluate(doc);
        VPD_PROFILE_GID = xpath.compile("/DATA_DS/GL_USER["+i+"]/VPD_PROFILE_GID").evaluate(doc);
        VPD_DOMAIN_NAME = xpath.compile("/DATA_DS/GL_USER["+i+"]/VPD_DOMAIN_NAME").evaluate(doc);
        DOMAIN_NAME = xpath.compile("/DATA_DS/GL_USER["+i+"]/DOMAIN_NAME").evaluate(doc);


        processedResponse.put("Role", USER_ROLE_XID);
        processedResponse.put("IS_RESERVED", IS_RESERVED);
        processedResponse.put("GL_LEVEL", GL_LEVEL);
        processedResponse.put("USER_ROLE_GID", USER_ROLE_GID);
        processedResponse.put("DATA_SOURCE_PROFILE_GID", DATA_SOURCE_PROFILE_GID);
        processedResponse.put("VPD_PROFILE_GID", VPD_PROFILE_GID);
        processedResponse.put("VPD_DOMAIN_NAME", VPD_DOMAIN_NAME);
        processedResponse.put("DOMAIN_NAME", DOMAIN_NAME);

        processedResponseObject.add(processedResponse);

        processedResponse = new HashMap();
    }
}

Map updatedMapInfo = new HashMap();
updatedMapInfo.put("data", processedResponseObject);

return updatedMapInfo;

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.