E9.2 Orchestration - Use current session instead of com.oracle.e1.aisclient.LoginEnvironment

plgbpedro2

Member
I'm creating a Custom Script (Groovy) and I need to call a BSFN inside that script. I was able to do that thanks to another post from here, the problem is that the way it's done now requires me to create a new LoginEnvironment instance, passing the serverURL, the username and user password as parameters. Instead of creating a new conenction, I want to use the current one, since the user is already connected to the AIS Server. Is there any way to use the current session to call the BSFN?
There is a token stored inside orchAttr and I can get it by using the method orchAttr.getToken(), but I can't find a way to use it to retrieve the session.

That's how it's doing now:
Java:
import com.oracle.e1.common.OrchestrationAttributes;
import com.oracle.e1.aisclient.*;
import com.oracle.e1.aisclient.runbsfn.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;

HashMap < String, Object > main(OrchestrationAttributes orchAttr, HashMap inputMap) {
  HashMap < String, Object > returnMap = new HashMap < String, Object > ();

  String ais_url = (String) inputMap.get("ais_url");

  LoginEnvironment loginEnv = new LoginEnvironment(ais_url, "user", "pass", null);

  if (loginEnv != null) {

    try {

      String abNo = (String) inputMap.get("abNo");

      BSFNRequest bsfnRequest = new BSFNRequest(loginEnv);
      bsfnRequest.setName("F0101GetAddressInformation");
      bsfnRequest.setIsAsynch(false);

      // Set Input Values
      bsfnRequest.getInParams().add(new DSTRInputValue(1, abNo));

      // Set Return Ids
      bsfnRequest.getOutputIds().add(new Long(3));
      bsfnRequest.getOutputIds().add(new Long(4));

      BSFNResponse responseObject = bsfnRequest.execute();

    
        returnMap.put("outValue2", outValue2);
      }
    } catch (Exception e) {
      String error = e.getMessage();
      returnMap.put("error", error);

    } finally {

      AISClientUtilities.logout(loginEnv);
    }
  }

  return returnMap;
}
 
Back
Top