Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. package com.latam.pax.cancloyred.ejb.clients;
  2.  
  3. import java.net.MalformedURLException;
  4. import java.net.URL;
  5. import java.util.Properties;
  6. import javax.xml.ws.BindingProvider;
  7. import javax.xml.ws.Holder;
  8. import javax.xml.ws.WebServiceException;
  9. import javax.xml.ws.soap.SOAPFaultException;
  10.  
  11. import com.latam.arq.commons.appconfig.properties.AppConfigException;
  12. import com.latam.arq.commons.appconfig.properties.AppConfigUtil;
  13. import com.latam.arq.commons.exceptions.LATAMException;
  14. import com.latam.pax.cancloyred.domain.CancelLoyaltyRedemptionRQDTO;
  15. import com.latam.pax.cancloyred.ejb.exceptions.CancelLoyaltyRedemptionException;
  16. import com.latam.pax.cancloyred.utils.Constants;
  17. import com.latam.pax.cancloyred.utils.LATAMPASSError;
  18. import com.siebel.customui.LOY37OCSLANQueryMemberLight;
  19. import com.siebel.customui.OCSLANQueryMemberLightInput;
  20. import com.siebel.customui.OCSLANQueryMemberLightOutput;
  21. import com.siebel.customui.OCSSpcQuerySpcMemberSpcLightSpcWF;
  22. import com.siebel.customui.SiebelFault;
  23. import com.siebel.webservices.SiebelSessionType;
  24. import com.siebel.xml.ocs_querymemberlight_input.ListOfLanInputQueryMemberLight;
  25. import com.siebel.xml.ocs_querymemberlight_input.LoyMember;
  26. import lombok.extern.slf4j.Slf4j;
  27.  
  28.  
  29. /**
  30. * Class customer service calls LOY37-OCSLANQueryMemberLight
  31. * @author
  32. *
  33. */
  34. @Slf4j
  35. public class WSQueryMemberLightClient {
  36. private String wsdl;
  37. private String endpoint;
  38. private String user;
  39. private String pass;
  40.  
  41.  
  42. private static LOY37OCSLANQueryMemberLight service;
  43.  
  44. /**
  45. * INIT default values
  46. *
  47. * @param appConfig
  48. * @throws AppConfigException
  49. * @throws MalformedURLException
  50. */
  51. public WSQueryMemberLightClient(Properties appConfig){
  52. setEndpoint(appConfig.getProperty(Constants.QUERY_MEMBER_LIGHT_ENDPOINT));
  53. setWsdl(appConfig.getProperty(Constants.QUERY_MEMBER_LIGHT_WSDL));
  54. setUser(appConfig.getProperty(Constants.QUERY_MEMBER_LIGHT_USER));
  55. setPass(appConfig.getProperty(Constants.QUERY_MEMBER_LIGHT_PASS));
  56. }
  57.  
  58. /**
  59. * method for completing the quest to send the Loyalty service
  60. *
  61. * @param input
  62. */
  63. private void completeRequestObject(OCSLANQueryMemberLightInput input, CancelLoyaltyRedemptionRQDTO businessData) {
  64.  
  65. LoyMember loyaltymember = new LoyMember();
  66. loyaltymember.setMemberNumber(businessData.getLoyaltyMember().getFfNumber());
  67. /**
  68. * Al realizar la consulta al servicio de la cartola light, el programa (aunque se desconozca) debe ser '*'
  69. */
  70. loyaltymember.setProgramName("*");
  71. input.setListOfLanInputQueryMemberLight(new ListOfLanInputQueryMemberLight());
  72. input.getListOfLanInputQueryMemberLight().getLoyMember().add(loyaltymember);
  73.  
  74. input.setPageSize("1");
  75. input.setStartRowNum("0");
  76.  
  77. }
  78.  
  79. /**
  80. * method to deliver the service Loyalty Service
  81. *
  82. * @param wsdl
  83. * @return
  84. * @throws WebServiceException
  85. */
  86. private static LOY37OCSLANQueryMemberLight getService(String wsdl)
  87. throws WebServiceException{
  88. if (service == null) {
  89. URL url;
  90. try {
  91. url = AppConfigUtil.getResourceFromAppConfig(wsdl).toURI().toURL();
  92. service = new LOY37OCSLANQueryMemberLight(url);
  93. } catch (MalformedURLException e) {
  94. logger.error("Excecption in MalformedURLException", e);
  95. } catch (AppConfigException e) {
  96. logger.error("Excecption in AppConfigException", e);
  97.  
  98. }
  99. }
  100. return service;
  101. }
  102.  
  103. /**
  104. * method to call the service SIEBEL Display Loyalty Transactions
  105. *
  106. * @param businessData
  107. * @return
  108. * @throws LATAMException
  109. * @throws SiebelFault
  110. */
  111. public OCSLANQueryMemberLightOutput execute(CancelLoyaltyRedemptionRQDTO businessData,Holder<String> securityHolder) throws CancelLoyaltyRedemptionException{
  112.  
  113. OCSSpcQuerySpcMemberSpcLightSpcWF port = getService(this.wsdl).getOCSSpcQuerySpcMemberSpcLightSpcWF();
  114. ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
  115.  
  116. OCSLANQueryMemberLightInput input = new OCSLANQueryMemberLightInput();
  117.  
  118. completeRequestObject(input, businessData);
  119.  
  120. OCSLANQueryMemberLightOutput response = null;
  121.  
  122. try{
  123. response = port.ocslanQueryMemberLight(this.user, this.pass, SiebelSessionType.NONE, securityHolder, input);
  124. }
  125. catch (SOAPFaultException ex){
  126. logger.error(ex.getMessage(),ex);
  127.  
  128. throw new CancelLoyaltyRedemptionException(Constants.LATAM_LOY37_QUERY_MEMBER_LIGHT_ID, Constants.LATAM_LOY37_QUERY_MEMBER_LIGHT, ex.getMessage());
  129.  
  130. }catch (WebServiceException e) {
  131. logger.error(e.getMessage(),e);
  132. throw new CancelLoyaltyRedemptionException(Constants.LATAM_LOY37_QUERY_MEMBER_LIGHT_ID, Constants.LATAM_LOY37_QUERY_MEMBER_LIGHT, e.getMessage());
  133.  
  134. }
  135. catch (SiebelFault ex){
  136. logger.error(ex.getMessage(),ex);
  137. LATAMPASSError error = new LATAMPASSError();
  138.  
  139. throw error.getException(ex);
  140. }
  141. return response;
  142. }
  143.  
  144. public void setWsdl(String wsdl) {
  145. this.wsdl = wsdl;
  146. }
  147.  
  148. public void setEndpoint(String endpoint) {
  149. this.endpoint = endpoint;
  150. }
  151.  
  152. public void setUser(String user) {
  153. this.user = user;
  154. }
  155.  
  156. public void setPass(String pass) {
  157. this.pass = pass;
  158. }
  159.  
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement