Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Correction #245

Open
wants to merge 3 commits into
base: mig-release-2.2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.wso2telco.gsma.authenticators.model.ReceiptRequest;
import com.wso2telco.gsma.authenticators.sms.message.OutboundSMSTextMessage;
import com.wso2telco.gsma.authenticators.sms.message.v1.OutboundSMSMessageRequest;
import com.wso2telco.gsma.authenticators.sms.message.v1.SendSMSRequest;
import com.wso2telco.gsma.authenticators.sms.message.v2.SenderAddress;
import com.wso2telco.gsma.authenticators.util.BasicFutureCallback;
import org.apache.http.client.HttpClient;
Expand Down Expand Up @@ -85,10 +86,10 @@ public String sendSMS(String msisdn, String message, String operator, BasicFutur
receipt.setCallbackData("");
receipt.setNotifyURL("");

OutboundSMSMessageRequest outbound = new OutboundSMSMessageRequest();
String smsversion=smsConfig.getSMSMessageVersion();
if(smsversion!=null && smsversion.equalsIgnoreCase("V2")){
com.wso2telco.gsma.authenticators.sms.message.v2.OutboundSMSMessageRequest outboundv2 = new com.wso2telco.gsma.authenticators.sms.message.v2.OutboundSMSMessageRequest();

String smsVersion=smsConfig.getSMSMessageVersion();
if(smsVersion!=null && smsVersion.equalsIgnoreCase("V2")){
com.wso2telco.gsma.authenticators.sms.message.v2.OutboundSMSMessageRequest outbound = new com.wso2telco.gsma.authenticators.sms.message.v2.OutboundSMSMessageRequest();

List<SenderAddress> senderAddresses = new ArrayList<>();
List<OperatorMapping> operators = smsConfig.getOperatorMappings();
Expand All @@ -105,29 +106,29 @@ public String sendSMS(String msisdn, String message, String operator, BasicFutur
}
}
if(!senderAddresses.isEmpty()) {
outboundv2.setSenderAddresses(senderAddresses);
outbound = outboundv2;
outbound.setSenderAddresses(senderAddresses);
outbound.setReceiptRequest(receipt);
outbound.setOutboundTextMessage(messageObj);
outbound.setAddress(address);
com.wso2telco.gsma.authenticators.sms.message.v2.SendSMSRequest req = new com.wso2telco.gsma.authenticators.sms.message.v2.SendSMSRequest();
req.setOutboundSMSMessageRequest(outbound);
returnString = new GsonBuilder().serializeNulls().create().toJson(req);
}else{
throw new AuthenticationFailedException("SMS Authentication failed, operator mapping invalid to send SMS");
}
}else{
String senderAddress = smsConfig.getSenderAddress();
senderAddress = senderAddress.trim() == null ? "26451" : senderAddress.trim();
OutboundSMSMessageRequest outbound = new OutboundSMSMessageRequest();
outbound.setSenderAddress(senderAddress);
outbound.setReceiptRequest(receipt);
outbound.setOutboundTextMessage(messageObj);
outbound.setAddress(address);
SendSMSRequest req = new SendSMSRequest();
req.setOutboundSMSMessageRequest(outbound);
returnString = new GsonBuilder().serializeNulls().create().toJson(req);
}

outbound.setReceiptRequest(receipt);
outbound.setOutboundTextMessage(messageObj);
outbound.setAddress(address);

SendSMSRequest req = new SendSMSRequest();

req.setOutboundSMSMessageRequest(outbound);

Gson gson = new GsonBuilder().serializeNulls().create();

returnString = gson.toJson(req);

postRequest(smsConfig.getEndpoint(), returnString, operator, futureCallback);

return returnString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.wso2telco.gsma.authenticators.sms;
package com.wso2telco.gsma.authenticators.sms.message.v1;

import com.wso2telco.gsma.authenticators.sms.message.v1.OutboundSMSMessageRequest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
package com.wso2telco.gsma.authenticators.sms.message.v2;


import com.wso2telco.gsma.authenticators.model.ReceiptRequest;
import com.wso2telco.gsma.authenticators.sms.message.OutboundSMSTextMessage;

import java.util.ArrayList;
import java.util.List;

/**
* The Class OutboundSMSMessageRequest.
*/
public class OutboundSMSMessageRequest extends
com.wso2telco.gsma.authenticators.sms.message.v1.OutboundSMSMessageRequest {
public class OutboundSMSMessageRequest {


/**
Expand Down Expand Up @@ -56,4 +58,103 @@ public List<SenderAddress> getSenderAddresses() {
public void setSenderAddresses(List<SenderAddress> senderAddresses) {
this.senderAddresses = senderAddresses;
}

/**
* The client correlator.
*/
protected String clientCorrelator = new String();

/**
* The address.
*/
// private String callbackData = new String();
protected List<String> address;

/**
* The outbound sms text message.
*/
protected OutboundSMSTextMessage outboundSMSTextMessage;

/**
* The receipt request.
*/
protected ReceiptRequest receiptRequest;


/**
* Gets the client correlator.
*
* @return the client correlator
*/
public String getClientCorrelator() {
return clientCorrelator;
}

/**
* Sets the client correlator.
*
* @param clientCorrelator the new client correlator
*/
public void setClientCorrelator(String clientCorrelator) {
this.clientCorrelator = clientCorrelator;
}


/**
* Gets the address.
*
* @return the address
*/
public List<String> getAddress() {
return address;
}

/**
* Sets the address.
*
* @param address the new address
*/
public void setAddress(List<String> address) {
this.address = address;
}

/**
* Gets the outbound text message.
*
* @return the outbound text message
*/
public OutboundSMSTextMessage getOutboundTextMessage() {
return outboundSMSTextMessage;
}

/**
* Sets the outbound text message.
*
* @param outboundSMSTextMessage the new outbound text message
*/
public void setOutboundTextMessage(OutboundSMSTextMessage outboundSMSTextMessage) {
this.outboundSMSTextMessage = outboundSMSTextMessage;
}

/**
* Gets the receipt request.
*
* @return the receipt request
*/
public ReceiptRequest getReceiptRequest() {
return receiptRequest;
}

/**
* Sets the receipt request.
*
* @param receiptRequest the new receipt request
*/
public void setReceiptRequest(ReceiptRequest receiptRequest) {
this.receiptRequest = receiptRequest;
}




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*******************************************************************************
* Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com)
*
* All Rights Reserved. WSO2.Telco Inc. licences this file to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.wso2telco.gsma.authenticators.sms.message.v2;

import com.wso2telco.gsma.authenticators.sms.message.v2.OutboundSMSMessageRequest;

import javax.xml.bind.annotation.XmlRootElement;

// TODO: Auto-generated Javadoc

/**
* The Class SendSMSRequest.
*/
@XmlRootElement(name = "outboundSMSMessageRequest")
public class SendSMSRequest {
/**
* The outbound sms message request.
*/
//implements ISMSresponse {
private OutboundSMSMessageRequest outboundSMSMessageRequest;

/**
* Instantiates a new send sms request.
*/
public SendSMSRequest() {
}


/**
* Gets the outbound sms message request.
*
* @return the outbound sms message request
*/
public OutboundSMSMessageRequest getOutboundSMSMessageRequest() {
return outboundSMSMessageRequest;
}


/**
* Sets the outbound sms message request.
*
* @param receiptRequest the new outbound sms message request
*/
public void setOutboundSMSMessageRequest(OutboundSMSMessageRequest receiptRequest) {
this.outboundSMSMessageRequest = receiptRequest;
}

}