file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
AbstractConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/AbstractConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.math.BigDecimal; import java.net.URI; import java.text.SimpleDateFormat; import java.util.Currency; import java.util.Locale; import org.apache.commons.configuration.Configuration; import org.joda.time.DateTime; import org.restcomm.connect.commons.dao.Sid; import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.thoughtworks.xstream.converters.Converter; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) * @author <a href="mailto:[email protected]">gvagenas</a> * @author <a href="mailto:[email protected]">Jean Deruelle</a> */ public abstract class AbstractConverter implements Converter { protected final Configuration configuration; public AbstractConverter(final Configuration configuration) { super(); this.configuration = configuration; } @SuppressWarnings("rawtypes") @Override public abstract boolean canConvert(Class klass); @Override public abstract void marshal(final Object object, HierarchicalStreamWriter writer, MarshallingContext context); @Override public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) { return null; } protected void writeAccountSid(final Sid accountSid, final HierarchicalStreamWriter writer) { if (accountSid != null) { writer.startNode("AccountSid"); writer.setValue(accountSid.toString()); writer.endNode(); } } protected void writeAccountSid(final Sid accountSid, final JsonObject object) { if (accountSid != null) { object.addProperty("account_sid", accountSid.toString()); } else { object.add("account_sid", JsonNull.INSTANCE); } } protected void writeApiVersion(final String apiVersion, final HierarchicalStreamWriter writer) { writer.startNode("ApiVersion"); writer.setValue(apiVersion); writer.endNode(); } protected void writeApiVersion(final String apiVersion, final JsonObject object) { object.addProperty("api_version", apiVersion); } protected void writeCallSid(final Sid callSid, final HierarchicalStreamWriter writer) { if (callSid != null) { writer.startNode("CallSid"); writer.setValue(callSid.toString()); writer.endNode(); } } protected void writeCallSid(final Sid callSid, final JsonObject object) { if (callSid != null) object.addProperty("call_sid", callSid.toString()); } protected void writeDateCreated(final DateTime dateCreated, final HierarchicalStreamWriter writer) { writer.startNode("DateCreated"); writer.setValue(new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(dateCreated.toDate())); writer.endNode(); } protected void writeDateCreated(final DateTime dateCreated, final JsonObject object) { object.addProperty("date_created", new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(dateCreated.toDate())); } protected void writeDateUpdated(final DateTime dateUpdated, final HierarchicalStreamWriter writer) { writer.startNode("DateUpdated"); writer.setValue(new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(dateUpdated.toDate())); writer.endNode(); } protected void writeDateUpdated(final DateTime dateUpdated, final JsonObject object) { object.addProperty("date_updated", new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(dateUpdated.toDate())); } protected void writeDuration(final double duration, final HierarchicalStreamWriter writer) { writer.startNode("Duration"); writer.setValue(Double.toString(duration)); writer.endNode(); } protected void writeDuration(final double duration, final JsonObject object) { object.addProperty("duration", Double.toString(duration)); } protected void writeFriendlyName(final String friendlyName, final HierarchicalStreamWriter writer) { writer.startNode("FriendlyName"); writer.setValue(friendlyName); writer.endNode(); } protected void writeFriendlyName(final String friendlyName, final JsonObject object) { object.addProperty("friendly_name", friendlyName); } protected void writeFrom(final String from, final HierarchicalStreamWriter writer) { writer.startNode("From"); writer.setValue(from); writer.endNode(); } protected void writeFrom(final String from, final JsonObject object) { object.addProperty("from", from); } protected void writePhoneNumber(final String phoneNumber, final HierarchicalStreamWriter writer) { writer.startNode("PhoneNumber"); writer.setValue(phoneNumber); writer.endNode(); } protected void writePhoneNumber(final String phoneNumber, final JsonObject object) { object.addProperty("phone_number", phoneNumber); } protected void writePrice(final BigDecimal price, final HierarchicalStreamWriter writer) { writer.startNode("Price"); writer.setValue(price.toString()); writer.endNode(); } protected void writePrice(final BigDecimal price, final JsonObject object) { object.addProperty("price", price.toString()); } protected void writePriceUnit(final Currency priceUnit, final HierarchicalStreamWriter writer) { writer.startNode("PriceUnit"); if (priceUnit != null) { writer.setValue(priceUnit.toString()); } writer.endNode(); } protected void writePriceUnit(final Currency priceUnit, final JsonObject object) { if (priceUnit != null) { object.addProperty("price_unit", priceUnit.toString()); } else { object.add("price_unit", JsonNull.INSTANCE); } } protected void writeSid(final Sid sid, final HierarchicalStreamWriter writer) { writer.startNode("Sid"); writer.setValue(sid.toString()); writer.endNode(); } protected void writeSid(final Sid sid, final JsonObject object) { object.addProperty("sid", sid.toString()); } protected void writeDomainName(final String domainName, final HierarchicalStreamWriter writer) { writer.startNode("DomainName"); writer.setValue(domainName); writer.endNode(); } protected void writeDomainName(final String domainName, final JsonObject object) { object.addProperty("domain_name", domainName); } protected void writeSmsFallbackUrl(final URI smsFallbackUrl, final HierarchicalStreamWriter writer) { if (smsFallbackUrl != null) { writer.startNode("SmsFallbackUrl"); writer.setValue(smsFallbackUrl.toString()); writer.endNode(); } } protected void writeSmsFallbackUrl(final URI smsFallbackUrl, final JsonObject object) { if (smsFallbackUrl != null) { object.addProperty("sms_fallback_url", smsFallbackUrl.toString()); } else { object.add("sms_fallback_url", JsonNull.INSTANCE); } } protected void writeSmsFallbackMethod(final String smsFallbackMethod, final HierarchicalStreamWriter writer) { writer.startNode("SmsFallbackMethod"); if (smsFallbackMethod != null) { writer.setValue(smsFallbackMethod); } writer.endNode(); } protected void writeSmsFallbackMethod(final String smsFallbackMethod, final JsonObject object) { if (smsFallbackMethod != null) { object.addProperty("sms_fallback_method", smsFallbackMethod); } else { object.add("sms_fallback_method", JsonNull.INSTANCE); } } protected void writeSmsUrl(final URI smsUrl, final HierarchicalStreamWriter writer) { if (smsUrl != null) { writer.startNode("SmsUrl"); writer.setValue(smsUrl.toString()); writer.endNode(); } } protected void writeSmsUrl(final URI smsUrl, final JsonObject object) { if (smsUrl != null) { object.addProperty("sms_url", smsUrl.toString()); } else { object.add("sms_url", JsonNull.INSTANCE); } } protected void writeSmsMethod(final String smsMethod, final HierarchicalStreamWriter writer) { writer.startNode("SmsMethod"); if (smsMethod != null) { writer.setValue(smsMethod); } writer.endNode(); } protected void writeSmsMethod(final String smsMethod, final JsonObject object) { if (smsMethod != null) { object.addProperty("sms_method", smsMethod); } else { object.add("sms_method", JsonNull.INSTANCE); } } protected void writeUssdFallbackUrl(final URI ussdFallbackUrl, final HierarchicalStreamWriter writer) { if (ussdFallbackUrl != null) { writer.startNode("UssdFallbackUrl"); writer.setValue(ussdFallbackUrl.toString()); writer.endNode(); } } protected void writeUssdFallbackUrl(final URI ussdFallbackUrl, final JsonObject object) { if (ussdFallbackUrl != null) { object.addProperty("ussd_fallback_url", ussdFallbackUrl.toString()); } else { object.add("ussd_fallback_url", JsonNull.INSTANCE); } } protected void writeUssdFallbackMethod(final String ussdFallbackMethod, final HierarchicalStreamWriter writer) { writer.startNode("UssdFallbackMethod"); if (ussdFallbackMethod != null) { writer.setValue(ussdFallbackMethod); } writer.endNode(); } protected void writeUssdFallbackMethod(final String ussdFallbackMethod, final JsonObject object) { if (ussdFallbackMethod != null) { object.addProperty("ussd_fallback_method", ussdFallbackMethod); } else { object.add("ussd_fallback_method", JsonNull.INSTANCE); } } protected void writeUssdUrl(final URI ussdUrl, final HierarchicalStreamWriter writer) { if (ussdUrl != null) { writer.startNode("UssdUrl"); writer.setValue(ussdUrl.toString()); writer.endNode(); } } protected void writeUssdUrl(final URI ussdUrl, final JsonObject object) { if (ussdUrl != null) { object.addProperty("ussd_url", ussdUrl.toString()); } else { object.add("ussd_url", JsonNull.INSTANCE); } } protected void writeUssdMethod(final String ussdMethod, final HierarchicalStreamWriter writer) { writer.startNode("UssdMethod"); if (ussdMethod != null) { writer.setValue(ussdMethod); } writer.endNode(); } protected void writeUssdMethod(final String ussdMethod, final JsonObject object) { if (ussdMethod != null) { object.addProperty("ussd_method", ussdMethod); } else { object.add("ussd_method", JsonNull.INSTANCE); } } protected void writeStatus(final String status, final HierarchicalStreamWriter writer) { writer.startNode("Status"); writer.setValue(status); writer.endNode(); } protected void writeStatus(final String status, final JsonObject object) { object.addProperty("status", status); } protected void writeStatusCallback(final URI statusCallback, final HierarchicalStreamWriter writer) { if (statusCallback != null) { writer.startNode("StatusCallback"); writer.setValue(statusCallback.toString()); writer.endNode(); } } protected void writeStatusCallback(final URI statusCallback, final JsonObject object) { if (statusCallback != null) { object.addProperty("status_callback", statusCallback.toString()); } else { object.add("status_callback", JsonNull.INSTANCE); } } protected void writeStatusCallbackMethod(final String statusCallbackMethod, final HierarchicalStreamWriter writer) { writer.startNode("StatusCallbackMethod"); if (statusCallbackMethod != null) { writer.setValue(statusCallbackMethod); } writer.endNode(); } protected void writeStatusCallbackMethod(final String statusCallbackMethod, final JsonObject object) { if (statusCallbackMethod != null) { object.addProperty("status_callback_method", statusCallbackMethod); } else { object.add("status_callback_method", JsonNull.INSTANCE); } } protected void writeTo(final String to, final HierarchicalStreamWriter writer) { writer.startNode("To"); writer.setValue(to); writer.endNode(); } protected void writeTo(final String to, final JsonObject object) { object.addProperty("to", to); } protected void writeTimeToLive(final int timeToLive, final HierarchicalStreamWriter writer) { writer.startNode("TimeToLive"); writer.setValue(Integer.toString(timeToLive)); writer.endNode(); } protected void writeTimeToLive(final int timeToLive, final JsonObject object) { object.addProperty("time_to_live", timeToLive); } protected void writeType(final String type, final HierarchicalStreamWriter writer) { writer.startNode("Type"); if (type != null) { writer.setValue(type); } else { writer.setValue(null); } writer.endNode(); } protected void writeType(final String type, final JsonObject object) { object.addProperty("type", type); } protected void writeUri(final URI uri, final HierarchicalStreamWriter writer) { writer.startNode("Uri"); writer.setValue(uri.toString()); writer.endNode(); } protected void writeUri(final URI uri, final JsonObject object) { object.addProperty("uri", uri.toString() + ".json"); } protected void writeUserName(final String userName, final HierarchicalStreamWriter writer) { writer.startNode("UserName"); writer.setValue(userName); writer.endNode(); } protected void writeUserName(final String userName, final JsonObject object) { object.addProperty("user_name", userName); } protected void writeVoiceApplicationSid(final Sid voiceApplicationSid, final HierarchicalStreamWriter writer) { if (voiceApplicationSid != null) { writer.startNode("VoiceApplicationSid"); writer.setValue(voiceApplicationSid.toString()); writer.endNode(); } } protected void writeVoiceApplicationSid(final Sid voiceApplicationSid, final JsonObject object) { if (voiceApplicationSid != null) { object.addProperty("voice_application_sid", voiceApplicationSid.toString()); } else { object.add("voice_application_sid", JsonNull.INSTANCE); } } protected void writePushClientIdentity(final String pushClientIdentity, final HierarchicalStreamWriter writer) { if (pushClientIdentity != null) { writer.startNode("PushClientIdentity"); writer.setValue(pushClientIdentity); writer.endNode(); } } protected void writePushClientIdentity(final String pushClientIdentity, final JsonObject object) { if (pushClientIdentity != null) { object.addProperty("push_client_identity", pushClientIdentity); } else { object.add("push_client_identity", JsonNull.INSTANCE); } } protected void writeVoiceCallerIdLookup(final boolean voiceCallerIdLookup, final HierarchicalStreamWriter writer) { writer.startNode("VoiceCallerIdLookup"); writer.setValue(Boolean.toString(voiceCallerIdLookup)); writer.endNode(); } protected void writeVoiceCallerIdLookup(final boolean voiceCallerIdLookup, final JsonObject object) { object.addProperty("voice_caller_id_lookup", voiceCallerIdLookup); } protected void writeVoiceFallbackMethod(final String voiceFallbackMethod, final HierarchicalStreamWriter writer) { writer.startNode("VoiceFallbackMethod"); if (voiceFallbackMethod != null) { writer.setValue(voiceFallbackMethod); } writer.endNode(); } protected void writeVoiceFallbackMethod(final String voiceFallbackMethod, final JsonObject object) { if (voiceFallbackMethod != null) { object.addProperty("voice_fallback_method", voiceFallbackMethod); } else { object.add("voice_fallback_method", JsonNull.INSTANCE); } } protected void writeVoiceFallbackUrl(final URI voiceFallbackUri, final HierarchicalStreamWriter writer) { if (voiceFallbackUri != null) { writer.startNode("VoiceFallbackUrl"); writer.setValue(voiceFallbackUri.toString()); writer.endNode(); } } protected void writeVoiceFallbackUrl(final URI voiceFallbackUri, final JsonObject object) { if (voiceFallbackUri != null) { object.addProperty("voice_fallback_url", voiceFallbackUri.toString()); } else { object.add("voice_fallback_url", JsonNull.INSTANCE); } } protected void writeVoiceMethod(final String voiceMethod, final HierarchicalStreamWriter writer) { writer.startNode("VoiceMethod"); if (voiceMethod != null) { writer.setValue(voiceMethod); } writer.endNode(); } protected void writeVoiceMethod(final String voiceMethod, final JsonObject object) { if (voiceMethod != null) { object.addProperty("voice_method", voiceMethod); } else { object.add("voice_method", JsonNull.INSTANCE); } } protected void writeVoiceUrl(final URI voiceUrl, final HierarchicalStreamWriter writer) { if (voiceUrl != null) { writer.startNode("VoiceUrl"); writer.setValue(voiceUrl.toString()); writer.endNode(); } } protected void writeVoiceUrl(final URI voiceUrl, final JsonObject object) { if (voiceUrl != null) { object.addProperty("voice_url", voiceUrl.toString()); } else { object.add("voice_url", JsonNull.INSTANCE); } } protected void writeReferUrl(final URI referUrl, final HierarchicalStreamWriter writer) { if (referUrl != null) { writer.startNode("ReferUrl"); writer.setValue(referUrl.toString()); writer.endNode(); } } protected void writeReferMethod(final String referMethod, final HierarchicalStreamWriter writer) { writer.startNode("ReferMethod"); if (referMethod != null) { writer.setValue(referMethod); } writer.endNode(); } protected void writeReferUrl(final URI referUrl, final JsonObject object) { if (referUrl != null) { object.addProperty("refer_url", referUrl.toString()); } else { object.add("refer_url", JsonNull.INSTANCE); } } protected void writeReferMethod(final String referMethod, final JsonObject object) { if (referMethod != null) { object.addProperty("refer_method", referMethod); } else { object.add("refer_method", JsonNull.INSTANCE); } } protected void writeCapabilities(final Boolean voiceCapable, final Boolean smsCapable, final Boolean mmsCapable, final Boolean faxCapable, final HierarchicalStreamWriter writer) { writer.startNode("Capabilities"); writeVoiceCapability(voiceCapable, writer); writeSmsCapability(smsCapable, writer); writeMmsCapability(mmsCapable, writer); writeFaxCapability(faxCapable, writer); writer.endNode(); } protected void writeCapabilities(final Boolean voiceCapable, final Boolean smsCapable, final Boolean mmsCapable, final Boolean faxCapable, final JsonObject object) { JsonObject capabilities = new JsonObject(); writeVoiceCapability(voiceCapable, capabilities); writeSmsCapability(smsCapable, capabilities); writeMmsCapability(mmsCapable, capabilities); writeFaxCapability(faxCapable, capabilities); object.add("capabilities", capabilities); } protected void writeVoiceCapability(final Boolean voiceCapable, final HierarchicalStreamWriter writer) { writer.startNode("Voice"); if (voiceCapable == null) { writer.setValue(Boolean.FALSE.toString()); } else { writer.setValue(voiceCapable.toString()); } writer.endNode(); } protected void writeVoiceCapability(final Boolean voiceCapable, final JsonObject object) { if (voiceCapable != null) { object.addProperty("voice_capable", voiceCapable); } else { object.addProperty("voice_capable", Boolean.FALSE); } } protected void writeSmsCapability(final Boolean smsCapable, final HierarchicalStreamWriter writer) { writer.startNode("Sms"); if (smsCapable == null) { writer.setValue(Boolean.FALSE.toString()); } else { writer.setValue(smsCapable.toString()); } writer.endNode(); } protected void writeSmsCapability(final Boolean smsCapable, final JsonObject object) { if (smsCapable != null) { object.addProperty("sms_capable", smsCapable); } else { object.addProperty("sms_capable", Boolean.FALSE); } } protected void writeMmsCapability(final Boolean mmsCapable, final HierarchicalStreamWriter writer) { writer.startNode("Mms"); if (mmsCapable == null) { writer.setValue(Boolean.FALSE.toString()); } else { writer.setValue(mmsCapable.toString()); } writer.endNode(); } protected void writeMmsCapability(final Boolean mmsCapable, final JsonObject object) { if (mmsCapable != null) { object.addProperty("mms_capable", mmsCapable); } else { object.addProperty("mms_capable", Boolean.FALSE); } } protected void writeFaxCapability(final Boolean faxCapable, final HierarchicalStreamWriter writer) { writer.startNode("Fax"); if (faxCapable == null) { writer.setValue(Boolean.FALSE.toString()); } else { writer.setValue(faxCapable.toString()); } writer.endNode(); } protected void writeFaxCapability(final Boolean faxCapable, final JsonObject object) { if (faxCapable != null) { object.addProperty("fax_capable", faxCapable); } else { object.addProperty("fax_capable", Boolean.FALSE); } } }
24,240
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ExtensionConfigurationConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/ExtensionConfigurationConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2016, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package org.restcomm.connect.http.converter; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.commons.util.StringUtils; import org.restcomm.connect.extension.api.ExtensionConfiguration; import java.lang.reflect.Type; /** * @author [email protected] */ @ThreadSafe public final class ExtensionConfigurationConverter extends AbstractConverter implements JsonSerializer<ExtensionConfiguration> { private final String apiVersion; private final String rootUri; public ExtensionConfigurationConverter(final Configuration configuration) { super(configuration); this.apiVersion = configuration.getString("api-version"); rootUri = StringUtils.addSuffixIfNotPresent(configuration.getString("root-uri"), "/"); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return ExtensionConfiguration.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ExtensionConfiguration extensionConfiguration = (ExtensionConfiguration) object; writer.startNode("ExtensionConfiguration"); writeSid(extensionConfiguration.getSid(),writer); writer.startNode("Extension"); writer.setValue(extensionConfiguration.getExtensionName()); writer.endNode(); writer.startNode("Configuration"); writer.setValue(extensionConfiguration.getConfigurationData().toString()); writer.endNode(); writer.startNode("Configuration Type"); writer.setValue(extensionConfiguration.getConfigurationType().name()); writer.endNode(); writeDateCreated(extensionConfiguration.getDateCreated(),writer); writeDateCreated(extensionConfiguration.getDateUpdated(), writer); writer.endNode(); } @Override public JsonElement serialize(final ExtensionConfiguration extensionConfiguration, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(extensionConfiguration.getSid(), object); object.addProperty("extension", extensionConfiguration.getExtensionName()); object.addProperty("configuration", extensionConfiguration.getConfigurationData().toString()); object.addProperty("configuration type", extensionConfiguration.getConfigurationType().name()); writeDateCreated(extensionConfiguration.getDateCreated(), object); writeDateUpdated(extensionConfiguration.getDateUpdated(), object); return object; } }
3,825
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GatewayListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/GatewayListConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Gateway; import org.restcomm.connect.dao.entities.GatewayList; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class GatewayListConverter extends AbstractConverter { public GatewayListConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return GatewayList.class.equals(klass); } @Override public void marshal(final Object object, HierarchicalStreamWriter writer, MarshallingContext context) { final GatewayList list = (GatewayList) object; writer.startNode("Gateways"); for (final Gateway gateway : list.getGateways()) { context.convertAnother(gateway); } writer.endNode(); } }
1,980
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
RecordingListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/RecordingListConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Recording; import org.restcomm.connect.dao.entities.RecordingList; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import java.lang.reflect.Type; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class RecordingListConverter extends AbstractConverter implements JsonSerializer<RecordingList> { Integer page, pageSize, total; String pathUri; public RecordingListConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return RecordingList.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final RecordingList list = (RecordingList) object; writer.startNode("Recordings"); for (final Recording recording : list.getRecordings()) { context.convertAnother(recording); } writer.endNode(); } @Override public JsonObject serialize(RecordingList recList, Type type, JsonSerializationContext context) { JsonObject result = new JsonObject(); JsonArray array = new JsonArray(); for (Recording cdr : recList.getRecordings()) { array.add(context.serialize(cdr)); } if (total != null && pageSize != null && page != null) { result.addProperty("page", page); result.addProperty("num_pages", getTotalPages()); result.addProperty("page_size", pageSize); result.addProperty("total", total); result.addProperty("start", getFirstIndex()); result.addProperty("end", getLastIndex(recList)); result.addProperty("uri", pathUri); result.addProperty("first_page_uri", getFirstPageUri()); result.addProperty("previous_page_uri", getPreviousPageUri()); result.addProperty("next_page_uri", getNextPageUri(recList)); result.addProperty("last_page_uri", getLastPageUri()); } result.add("recordings", array); return result; } private int getTotalPages() { return total / pageSize; } private String getFirstIndex() { return String.valueOf(page * pageSize); } private String getLastIndex(RecordingList list) { return String.valueOf((page == getTotalPages()) ? (page * pageSize) + list.getRecordings().size() : (pageSize - 1) + (page * pageSize)); } private String getFirstPageUri() { return pathUri + "?Page=0&PageSize=" + pageSize; } private String getPreviousPageUri() { return ((page == 0) ? "null" : pathUri + "?Page=" + (page - 1) + "&PageSize=" + pageSize); } private String getNextPageUri(RecordingList list) { String lastSid = (page == getTotalPages()) ? "null" : list.getRecordings().get(pageSize - 1).getSid().toString(); return (page == getTotalPages()) ? "null" : pathUri + "?Page=" + (page + 1) + "&PageSize=" + pageSize + "&AfterSid=" + lastSid; } private String getLastPageUri() { return pathUri + "?Page=" + getTotalPages() + "&PageSize=" + pageSize; } public void setPage(Integer page) { this.page = page; } public void setPageSize(Integer pageSize) { this.pageSize = pageSize; } public void setCount(Integer count) { this.total = count; } public void setPathUri(String pathUri) { this.pathUri = pathUri; } }
4,857
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GatewayConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/GatewayConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Gateway; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class GatewayConverter extends AbstractConverter implements JsonSerializer<Gateway> { public GatewayConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return Gateway.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Gateway gateway = (Gateway) object; writer.startNode("Gateway"); writeSid(gateway.getSid(), writer); writeDateCreated(gateway.getDateCreated(), writer); writeDateUpdated(gateway.getDateUpdated(), writer); writeFriendlyName(gateway.getFriendlyName(), writer); writePassword(gateway.getPassword(), writer); writeProxy(gateway.getProxy(), writer); writeRegister(gateway.register(), writer); writeUserName(gateway.getUserName(), writer); writeTimeToLive(gateway.getTimeToLive(), writer); writeUri(gateway.getUri(), writer); writer.endNode(); } @Override public JsonElement serialize(final Gateway gateway, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(gateway.getSid(), object); writeDateCreated(gateway.getDateCreated(), object); writeDateUpdated(gateway.getDateUpdated(), object); writeFriendlyName(gateway.getFriendlyName(), object); writePassword(gateway.getPassword(), object); writeProxy(gateway.getProxy(), object); writeRegister(gateway.register(), object); writeUserName(gateway.getUserName(), object); writeTimeToLive(gateway.getTimeToLive(), object); writeUri(gateway.getUri(), object); return object; } private void writePassword(final String password, final HierarchicalStreamWriter writer) { writer.startNode("Password"); writer.setValue(password); writer.endNode(); } private void writePassword(final String password, final JsonObject object) { object.addProperty("password", password); } private void writeProxy(final String proxy, final HierarchicalStreamWriter writer) { writer.startNode("Proxy"); writer.setValue(proxy); writer.endNode(); } private void writeProxy(final String proxy, final JsonObject object) { object.addProperty("proxy", proxy); } private void writeRegister(final boolean register, final HierarchicalStreamWriter writer) { writer.startNode("Register"); writer.setValue(Boolean.toString(register)); writer.endNode(); } private void writeRegister(final boolean register, final JsonObject object) { object.addProperty("register", register); } }
4,326
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
AvailableCountriesList.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/AvailableCountriesList.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.util.List; /** * @author [email protected] * */ public class AvailableCountriesList { private List<String> availableCountries; /** * @param availableCountries */ public AvailableCountriesList(List<String> availableCountries) { this.availableCountries = availableCountries; } public List<String> getAvailableCountries() { return availableCountries; } public void setAvailableCountries(List<String> availableCountries) { this.availableCountries = availableCountries; } }
1,420
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
AnnouncementListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/AnnouncementListConverter.java
package org.restcomm.connect.http.converter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Announcement; import org.restcomm.connect.dao.entities.AnnouncementList; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author <a href="mailto:[email protected]">George Vagenas</a> */ @ThreadSafe public class AnnouncementListConverter extends AbstractConverter { public AnnouncementListConverter(Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(Class klass) { return AnnouncementList.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final AnnouncementList list = (AnnouncementList) object; writer.startNode("Announcements"); for (final Announcement anno : list.getAnnouncements()) { context.convertAnother(anno); } writer.endNode(); } }
1,219
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
TranscriptionConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/TranscriptionConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.dao.entities.Transcription; import com.google.gson.JsonElement; import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class TranscriptionConverter extends AbstractConverter implements JsonSerializer<Transcription> { public TranscriptionConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return Transcription.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Transcription transcription = (Transcription) object; writer.startNode("Transcription"); writeSid(transcription.getSid(), writer); writeDateCreated(transcription.getDateCreated(), writer); writeDateUpdated(transcription.getDateUpdated(), writer); writeAccountSid(transcription.getAccountSid(), writer); writeStatus(transcription.getStatus().toString(), writer); writeRecordingSid(transcription.getRecordingSid(), writer); writeDuration(transcription.getDuration(), writer); writeTranscriptionText(transcription.getTranscriptionText(), writer); writePrice(transcription.getPrice(), writer); writePriceUnit(transcription.getPriceUnit(), writer); writeUri(transcription.getUri(), writer); writer.endNode(); } @Override public JsonElement serialize(final Transcription transcription, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(transcription.getSid(), object); writeDateCreated(transcription.getDateCreated(), object); writeDateUpdated(transcription.getDateUpdated(), object); writeAccountSid(transcription.getAccountSid(), object); writeStatus(transcription.getStatus().toString(), object); writeRecordingSid(transcription.getRecordingSid(), object); writeDuration(transcription.getDuration(), object); writeTranscriptionText(transcription.getTranscriptionText(), object); writePrice(transcription.getPrice(), object); writePriceUnit(transcription.getPriceUnit(), object); writeUri(transcription.getUri(), object); return object; } private void writeRecordingSid(final Sid recordingSid, final HierarchicalStreamWriter writer) { writer.startNode("RecordingSid"); writer.setValue(recordingSid.toString()); writer.endNode(); } private void writeRecordingSid(final Sid recordingSid, final JsonObject object) { object.addProperty("recording_sid", recordingSid.toString()); } private void writeTranscriptionText(final String transcriptionText, final HierarchicalStreamWriter writer) { writer.startNode("TranscriptionText"); if (transcriptionText != null) { writer.setValue(transcriptionText); } writer.endNode(); } private void writeTranscriptionText(final String transcriptionText, final JsonObject object) { if (transcriptionText != null) { object.addProperty("transcription_text", transcriptionText); } else { object.add("transcription_text", JsonNull.INSTANCE); } } }
4,749
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ConferenceDetailRecordListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/ConferenceDetailRecordListConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.ConferenceDetailRecord; import org.restcomm.connect.dao.entities.ConferenceDetailRecordList; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author maria */ @ThreadSafe public final class ConferenceDetailRecordListConverter extends AbstractConverter implements JsonSerializer<ConferenceDetailRecordList> { Integer page, pageSize, total; String pathUri; public ConferenceDetailRecordListConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return ConferenceDetailRecordList.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ConferenceDetailRecordList list = (ConferenceDetailRecordList) object; writer.startNode("Conferences"); writer.addAttribute("page", String.valueOf(page)); writer.addAttribute("numpages", String.valueOf(getTotalPages())); writer.addAttribute("pagesize", String.valueOf(pageSize)); writer.addAttribute("total", String.valueOf(getTotalPages())); writer.addAttribute("start", getFirstIndex()); writer.addAttribute("end", getLastIndex(list)); writer.addAttribute("uri", pathUri); writer.addAttribute("firstpageuri", getFirstPageUri()); writer.addAttribute("previouspageuri", getPreviousPageUri()); writer.addAttribute("nextpageuri", getNextPageUri(list)); writer.addAttribute("lastpageuri", getLastPageUri()); for (final ConferenceDetailRecord cdr : list.getConferenceDetailRecords()) { context.convertAnother(cdr); } writer.endNode(); } @Override public JsonObject serialize(ConferenceDetailRecordList cdrList, Type type, JsonSerializationContext context) { JsonObject result = new JsonObject(); JsonArray array = new JsonArray(); for (ConferenceDetailRecord cdr : cdrList.getConferenceDetailRecords()) { array.add(context.serialize(cdr)); } result.addProperty("page", page); result.addProperty("num_pages", getTotalPages()); result.addProperty("page_size", pageSize); result.addProperty("total", total); result.addProperty("start", getFirstIndex()); result.addProperty("end", getLastIndex(cdrList)); result.addProperty("uri", pathUri); result.addProperty("first_page_uri", getFirstPageUri()); result.addProperty("previous_page_uri", getPreviousPageUri()); result.addProperty("next_page_uri", getNextPageUri(cdrList)); result.addProperty("last_page_uri", getLastPageUri()); result.add("conferences", array); return result; } private int getTotalPages() { return total / pageSize; } private String getFirstIndex() { return String.valueOf(page * pageSize); } private String getLastIndex(ConferenceDetailRecordList list) { return String.valueOf((page == getTotalPages()) ? (page * pageSize) + list.getConferenceDetailRecords().size() : (pageSize - 1) + (page * pageSize)); } private String getFirstPageUri() { return pathUri + "?Page=0&PageSize=" + pageSize; } private String getPreviousPageUri() { return ((page == 0) ? "null" : pathUri + "?Page=" + (page - 1) + "&PageSize=" + pageSize); } private String getNextPageUri(ConferenceDetailRecordList list) { String lastSid = (page == getTotalPages()) ? "null" : list.getConferenceDetailRecords().get(pageSize - 1).getSid().toString(); return (page == getTotalPages()) ? "null" : pathUri + "?Page=" + (page + 1) + "&PageSize=" + pageSize + "&AfterSid=" + lastSid; } private String getLastPageUri() { return pathUri + "?Page=" + getTotalPages() + "&PageSize=" + pageSize; } public void setPage(Integer page) { this.page = page; } public void setPageSize(Integer pageSize) { this.pageSize = pageSize; } public void setCount(Integer count) { this.total = count; } public void setPathUri(String pathUri) { this.pathUri = pathUri; } }
5,604
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
SmsMessageConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/SmsMessageConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.joda.time.DateTime; import org.restcomm.connect.dao.entities.SmsMessage; import com.google.gson.JsonElement; import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import org.restcomm.connect.commons.dao.MessageError; /** * @author [email protected] (Thomas Quintana) */ public class SmsMessageConverter extends AbstractConverter implements JsonSerializer<SmsMessage> { public SmsMessageConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return SmsMessage.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final SmsMessage smsMessage = (SmsMessage) object; writer.startNode("SMSMessage"); writeSid(smsMessage.getSid(), writer); writeDateCreated(smsMessage.getDateCreated(), writer); writeDateUpdated(smsMessage.getDateUpdated(), writer); writeDateSent(smsMessage.getDateSent(), writer); writeAccountSid(smsMessage.getAccountSid(), writer); writeFrom(smsMessage.getSender(), writer); writeTo(smsMessage.getRecipient(), writer); writeBody(smsMessage.getBody(), writer); writeStatus(smsMessage.getStatus().toString(), writer); writeDirection(smsMessage.getDirection().toString(), writer); writeError(smsMessage.getError(), writer); writePrice(smsMessage.getPrice(), writer); writePriceUnit(smsMessage.getPriceUnit(), writer); writeApiVersion(smsMessage.getApiVersion(), writer); writeUri(smsMessage.getUri(), writer); writer.endNode(); } @Override public JsonElement serialize(final SmsMessage smsMessage, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(smsMessage.getSid(), object); writeDateCreated(smsMessage.getDateCreated(), object); writeDateUpdated(smsMessage.getDateUpdated(), object); writeDateSent(smsMessage.getDateSent(), object); writeAccountSid(smsMessage.getAccountSid(), object); writeFrom(smsMessage.getSender(), object); writeTo(smsMessage.getRecipient(), object); writeBody(smsMessage.getBody(), object); writeStatus(smsMessage.getStatus().toString(), object); writeDirection(smsMessage.getDirection().toString(), object); writeError(smsMessage.getError(), object); writePrice(smsMessage.getPrice(), object); writePriceUnit(smsMessage.getPriceUnit(), object); writeApiVersion(smsMessage.getApiVersion(), object); writeUri(smsMessage.getUri(), object); return object; } protected void writeError(final MessageError error, final JsonObject object) { if (error != null) { object.addProperty("error_code", error.getErrorCode()); object.addProperty("error_message", error.getErrorMessage()); } else { object.add("error_code", JsonNull.INSTANCE); object.add("error_message", JsonNull.INSTANCE); } } protected void writeError(final MessageError error, final HierarchicalStreamWriter writer) { if (error != null) { writer.startNode("Error"); writeErrorCode(error, writer); writeErrorMessage(error, writer); writer.endNode(); } } private void writeErrorCode(final MessageError error, final HierarchicalStreamWriter writer){ writer.startNode("ErrorCode"); writer.setValue(error.getErrorCode()+""); writer.endNode(); } private void writeErrorMessage(final MessageError error, final HierarchicalStreamWriter writer){ writer.startNode("ErrorMessage"); writer.setValue(error.getErrorMessage()); writer.endNode(); } private void writeBody(final String body, final HierarchicalStreamWriter writer) { writer.startNode("Body"); if (body != null) { writer.setValue(body); } writer.endNode(); } private void writeBody(final String body, final JsonObject object) { if (body != null) { object.addProperty("body", body); } else { object.add("body", JsonNull.INSTANCE); } } private void writeDateSent(final DateTime dateSent, final HierarchicalStreamWriter writer) { writer.startNode("DateSent"); if (dateSent != null) { writer.setValue(dateSent.toString()); } writer.endNode(); } private void writeDateSent(final DateTime dateSent, final JsonObject object) { object.addProperty("date_sent", dateSent != null ? dateSent.toString() : null); } private void writeDirection(final String direction, final HierarchicalStreamWriter writer) { writer.startNode("Direction"); writer.setValue(direction); writer.endNode(); } private void writeDirection(final String direction, final JsonObject object) { object.addProperty("direction", direction); } }
6,392
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
UsageListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/UsageListConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Usage; import org.restcomm.connect.dao.entities.UsageList; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Alexandre Mendonca) */ @ThreadSafe public final class UsageListConverter extends AbstractConverter { public UsageListConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return UsageList.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final UsageList list = (UsageList) object; writer.startNode("UsageRecords"); for (final Usage usage : list.getUsages()) { context.convertAnother(usage); } writer.endNode(); } }
1,919
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CallDetailRecordListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/CallDetailRecordListConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.CallDetailRecord; import org.restcomm.connect.dao.entities.CallDetailRecordList; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) * @author [email protected] (George Vagenas) */ @ThreadSafe public final class CallDetailRecordListConverter extends AbstractConverter implements JsonSerializer<CallDetailRecordList> { Integer page, pageSize, total; String pathUri; public CallDetailRecordListConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return CallDetailRecordList.class.equals(klass); } // Issue 153: https://bitbucket.org/telestax/telscale-restcomm/issue/153 // Issue 110: https://bitbucket.org/telestax/telscale-restcomm/issue/110 @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final CallDetailRecordList list = (CallDetailRecordList) object; writer.startNode("Calls"); writer.addAttribute("page", String.valueOf(page)); writer.addAttribute("numpages", String.valueOf(getTotalPages())); writer.addAttribute("pagesize", String.valueOf(pageSize)); writer.addAttribute("total", String.valueOf(getTotalPages())); writer.addAttribute("start", getFirstIndex()); writer.addAttribute("end", getLastIndex(list)); writer.addAttribute("uri", pathUri); writer.addAttribute("firstpageuri", getFirstPageUri()); writer.addAttribute("previouspageuri", getPreviousPageUri()); writer.addAttribute("nextpageuri", getNextPageUri(list)); writer.addAttribute("lastpageuri", getLastPageUri()); for (final CallDetailRecord cdr : list.getCallDetailRecords()) { context.convertAnother(cdr); } writer.endNode(); } // Issue 153: https://bitbucket.org/telestax/telscale-restcomm/issue/153 // Issue 110: https://bitbucket.org/telestax/telscale-restcomm/issue/110 @Override public JsonObject serialize(CallDetailRecordList cdrList, Type type, JsonSerializationContext context) { JsonObject result = new JsonObject(); JsonArray array = new JsonArray(); for (CallDetailRecord cdr : cdrList.getCallDetailRecords()) { array.add(context.serialize(cdr)); } if (total != null && pageSize != null && page != null) { result.addProperty("page", page); result.addProperty("num_pages", getTotalPages()); result.addProperty("page_size", pageSize); result.addProperty("total", total); result.addProperty("start", getFirstIndex()); result.addProperty("end", getLastIndex(cdrList)); result.addProperty("uri", pathUri); result.addProperty("first_page_uri", getFirstPageUri()); result.addProperty("previous_page_uri", getPreviousPageUri()); result.addProperty("next_page_uri", getNextPageUri(cdrList)); result.addProperty("last_page_uri", getLastPageUri()); } result.add("calls", array); return result; } private int getTotalPages() { return total / pageSize; } private String getFirstIndex() { return String.valueOf(page * pageSize); } private String getLastIndex(CallDetailRecordList list) { return String.valueOf((page == getTotalPages()) ? (page * pageSize) + list.getCallDetailRecords().size() : (pageSize - 1) + (page * pageSize)); } private String getFirstPageUri() { return pathUri + "?Page=0&PageSize=" + pageSize; } private String getPreviousPageUri() { return ((page == 0) ? "null" : pathUri + "?Page=" + (page - 1) + "&PageSize=" + pageSize); } private String getNextPageUri(CallDetailRecordList list) { String lastSid = (page == getTotalPages()) ? "null" : list.getCallDetailRecords().get(pageSize - 1).getSid().toString(); return (page == getTotalPages()) ? "null" : pathUri + "?Page=" + (page + 1) + "&PageSize=" + pageSize + "&AfterSid=" + lastSid; } private String getLastPageUri() { return pathUri + "?Page=" + getTotalPages() + "&PageSize=" + pageSize; } public void setPage(Integer page) { this.page = page; } public void setPageSize(Integer pageSize) { this.pageSize = pageSize; } public void setCount(Integer count) { this.total = count; } public void setPathUri(String pathUri) { this.pathUri = pathUri; } }
6,003
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
AccountConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/AccountConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Account; import javax.ws.rs.core.MediaType; import java.lang.reflect.Type; import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE; import static javax.ws.rs.core.MediaType.APPLICATION_XML_TYPE; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class AccountConverter extends AbstractConverter implements JsonSerializer<Account> { private final String apiVersion; public AccountConverter(final Configuration configuration) { super(configuration); this.apiVersion = configuration.getString("api-version"); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return Account.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Account account = (Account) object; writer.startNode("Account"); writeSid(account.getSid(), writer); writer.startNode("organization"); writer.setValue(account.getOrganizationSid().toString()); writer.endNode(); writeFriendlyName(account.getFriendlyName(), writer); writeEmailAddress(account, writer); writeStatus(account.getStatus().toString(), writer); writeRoleInfo(account.getRole(), writer); writeType(account.getType().toString(), writer); writeDateCreated(account.getDateCreated(), writer); writeDateUpdated(account.getDateUpdated(), writer); writeAuthToken(account, writer); writeUri(account.getUri(), writer); writeSubResourceUris(account, writer); writer.endNode(); } @Override public JsonElement serialize(final Account account, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(account.getSid(), object); object.addProperty("organization", account.getOrganizationSid().toString()); writeFriendlyName(account.getFriendlyName(), object); writeEmailAddress(account, object); writeType(account.getType().toString(), object); writeStatus(account.getStatus().toString(), object); writeRoleInfo(account.getRole(), object); writeDateCreated(account.getDateCreated(), object); writeDateUpdated(account.getDateUpdated(), object); writeAuthToken(account, object); writeUri(account, object); writeSubResourceUris(account, object); return object; } protected void writeUri(final Account account, final JsonObject object) { object.addProperty("uri", prefix(account, APPLICATION_JSON_TYPE)); } private String prefix(final Account account) { return prefix(account, APPLICATION_XML_TYPE); } private String prefix(final Account account, MediaType responseType) { final StringBuilder buffer = new StringBuilder(); buffer.append("/").append(apiVersion).append("/Accounts"); if(responseType == APPLICATION_JSON_TYPE) { buffer.append(".json"); } buffer.append("/"+account.getSid().toString()); return buffer.toString(); } private void writeAuthToken(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("AuthToken"); writer.setValue(account.getAuthToken()); writer.endNode(); } private void writeAuthToken(final Account account, final JsonObject object) { object.addProperty("auth_token", account.getAuthToken()); } private void writeAvailablePhoneNumbers(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("AvailablePhoneNumbers"); writer.setValue(prefix(account) + "/AvailablePhoneNumbers"); writer.endNode(); } private void writeAvailablePhoneNumbers(final Account account, final JsonObject object) { object.addProperty("available_phone_numbers", prefix(account) + "/AvailablePhoneNumbers.json"); } private void writeCalls(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("Calls"); writer.setValue(prefix(account) + "/Calls"); writer.endNode(); } private void writeCalls(final Account account, final JsonObject object) { object.addProperty("calls", prefix(account) + "/Calls.json"); } private void writeConferences(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("Conferences"); writer.setValue(prefix(account) + "/Conferences"); writer.endNode(); } private void writeConferences(final Account account, final JsonObject object) { object.addProperty("conferences", prefix(account) + "/Conferences.json"); } private void writeIncomingPhoneNumbers(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("IncomingPhoneNumbers"); writer.setValue(prefix(account) + "/IncomingPhoneNumbers"); writer.endNode(); } private void writeIncomingPhoneNumbers(final Account account, final JsonObject object) { object.addProperty("incoming_phone_numbers", prefix(account) + "/IncomingPhoneNumbers.json"); } private void writeNotifications(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("Notifications"); writer.setValue(prefix(account) + "/Notifications"); writer.endNode(); } private void writeNotifications(final Account account, final JsonObject object) { object.addProperty("notifications", prefix(account) + "/Notifications.json"); } private void writeOutgoingCallerIds(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("OutgoingCallerIds"); writer.setValue(prefix(account) + "/OutgoingCallerIds"); writer.endNode(); } private void writeOutgoingCallerIds(final Account account, final JsonObject object) { object.addProperty("outgoing_caller_ids", prefix(account) + "/OutgoingCallerIds.json"); } private void writeRecordings(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("Recordings"); writer.setValue(prefix(account) + "/Recordings"); writer.endNode(); } private void writeRecordings(final Account account, final JsonObject object) { object.addProperty("recordings", prefix(account) + "/Recordings.json"); } private void writeSandBox(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("Sandbox"); writer.setValue(prefix(account) + "/Sandbox"); writer.endNode(); } private void writeSandBox(final Account account, final JsonObject object) { object.addProperty("sandbox", prefix(account) + "/Sandbox.json"); } private void writeSmsMessages(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("SMSMessages"); writer.setValue(prefix(account) + "/SMS/Messages"); writer.endNode(); } private void writeSmsMessages(final Account account, final JsonObject object) { object.addProperty("sms_messages", prefix(account) + "/SMS/Messages.json"); } private void writeSubResourceUris(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("SubresourceUris"); writeAvailablePhoneNumbers(account, writer); writeCalls(account, writer); writeConferences(account, writer); writeIncomingPhoneNumbers(account, writer); writeNotifications(account, writer); writeOutgoingCallerIds(account, writer); writeRecordings(account, writer); writeSandBox(account, writer); writeSmsMessages(account, writer); writeTranscriptions(account, writer); writer.endNode(); } private void writeSubResourceUris(final Account account, final JsonObject object) { final JsonObject other = new JsonObject(); writeAvailablePhoneNumbers(account, other); writeCalls(account, other); writeConferences(account, other); writeIncomingPhoneNumbers(account, other); writeNotifications(account, other); writeOutgoingCallerIds(account, other); writeRecordings(account, other); writeSandBox(account, other); writeSmsMessages(account, other); writeTranscriptions(account, other); object.add("subresource_uris", other); } private void writeTranscriptions(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("Transcriptions"); writer.setValue(prefix(account) + "/Transcriptions"); writer.endNode(); } private void writeTranscriptions(final Account account, final JsonObject object) { object.addProperty("transcriptions", prefix(account) + "/Transcriptions.json"); } private void writeEmailAddress(final Account account, final HierarchicalStreamWriter writer) { writer.startNode("EmailAddress"); writer.setValue(account.getEmailAddress()); writer.endNode(); writer.close(); } private void writeEmailAddress(final Account account, final JsonObject object) { object.addProperty("email_address", account.getEmailAddress()); } private void writeRoleInfo(final String role, final HierarchicalStreamWriter writer) { writer.startNode("Role"); writer.setValue(role); writer.endNode(); writer.close(); } private void writeRoleInfo(final String role, final JsonObject object) { object.addProperty("role", role); } }
11,076
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
MonitoringServiceConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/MonitoringServiceConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.http.converter; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import org.apache.commons.configuration.Configuration; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.restcomm.connect.commons.Version; import org.restcomm.connect.core.service.RestcommConnectServiceProvider; import org.restcomm.connect.telephony.api.CallInfo; import org.restcomm.connect.telephony.api.MonitoringServiceResponse; import java.lang.reflect.Type; import java.util.Iterator; import java.util.Map; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class MonitoringServiceConverter extends AbstractConverter implements JsonSerializer<MonitoringServiceResponse>{ private String dateTimeNow; public MonitoringServiceConverter(Configuration configuration) { super(configuration); DateTime now = DateTime.now(); DateTimeFormatter fmt = DateTimeFormat.forPattern("EEE, dd MMM yyyy kk:mm:ss"); dateTimeNow = fmt.print(now); } @Override public boolean canConvert(final Class klass) { return MonitoringServiceResponse.class.equals(klass); } @Override public JsonElement serialize(MonitoringServiceResponse monitoringServiceResponse, Type typeOfSrc, JsonSerializationContext context) { final Map<String, Integer> countersMap = monitoringServiceResponse.getCountersMap(); final Map<String, Double> durationMap = monitoringServiceResponse.getDurationMap(); JsonObject result = new JsonObject(); JsonObject metrics = new JsonObject(); JsonArray callsArray = new JsonArray(); //First add InstanceId and Version details result.addProperty("DateTime", dateTimeNow); result.addProperty("InstanceId", monitoringServiceResponse.getInstanceId().getId().toString()); result.addProperty("Version", Version.getVersion()); result.addProperty("Revision", Version.getRevision()); Iterator<String> counterIterator = countersMap.keySet().iterator(); while (counterIterator.hasNext()) { String counter = counterIterator.next(); metrics.addProperty(counter, countersMap.get(counter)); } Iterator<String> durationIterator = durationMap.keySet().iterator(); while (durationIterator.hasNext()) { String durationKey = durationIterator.next(); metrics.addProperty(durationKey, durationMap.get(durationKey)); } result.add("Metrics", metrics); if (monitoringServiceResponse.isWithCallDetailsList()) { if (monitoringServiceResponse.getCallDetailsList() != null && monitoringServiceResponse.getCallDetailsList().size() > 0) { for (CallInfo callInfo : monitoringServiceResponse.getCallDetailsList()) { callsArray.add(context.serialize(callInfo)); } } result.add("LiveCallDetails", callsArray); } else { result.addProperty("LiveCallDetails", RestcommConnectServiceProvider.getInstance().uriUtils().resolve(monitoringServiceResponse.getCallDetailsUrl(), monitoringServiceResponse.getAccountSid()).toString()); } return result; } @Override public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext context) { final MonitoringServiceResponse monitoringServiceResponse = (MonitoringServiceResponse) object; final Map<String, Double> durationMap = monitoringServiceResponse.getDurationMap(); final Map<String, Integer> countersMap = monitoringServiceResponse.getCountersMap(); Iterator<String> counterIterator = countersMap.keySet().iterator(); Iterator<String> durationIterator = durationMap.keySet().iterator(); writer.startNode("DateTime"); writer.setValue(dateTimeNow); writer.endNode(); writer.startNode("InstanceId"); writer.setValue(monitoringServiceResponse.getInstanceId().getId().toString()); writer.endNode(); writer.startNode("Version"); writer.setValue(Version.getVersion()); writer.endNode(); writer.startNode("Revision"); writer.setValue(Version.getRevision()); writer.endNode(); writer.startNode("Metrics"); while (counterIterator.hasNext()) { String counter = counterIterator.next(); writer.startNode(counter); writer.setValue(String.valueOf(countersMap.get(counter))); writer.endNode(); } while (durationIterator.hasNext()) { String durationKey = durationIterator.next(); writer.startNode(durationKey); writer.setValue(String.valueOf(durationMap.get(durationKey))); writer.endNode(); } writer.endNode(); if (monitoringServiceResponse.isWithCallDetailsList()) { if (monitoringServiceResponse.getCallDetailsList() != null && monitoringServiceResponse.getCallDetailsList().size() > 0) { writer.startNode("LiveCallDetails"); for (final CallInfo callInfo : monitoringServiceResponse.getCallDetailsList()) { context.convertAnother(callInfo); } writer.endNode(); } else { writer.startNode("LiveCallDetails"); writer.setValue(RestcommConnectServiceProvider.getInstance().uriUtils().resolve(monitoringServiceResponse.getCallDetailsUrl(), monitoringServiceResponse.getAccountSid()).toString()); writer.endNode(); } } } }
6,905
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
RegistrationListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/RegistrationListConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Registration; import org.restcomm.connect.dao.entities.RegistrationList; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class RegistrationListConverter extends AbstractConverter { public RegistrationListConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return RegistrationList.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final RegistrationList list = (RegistrationList) object; writer.startNode("Registrations"); for (final Registration registration : list.getRegistrations()) { context.convertAnother(registration); } writer.endNode(); } }
2,052
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ShortCodeListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/ShortCodeListConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.ShortCode; import org.restcomm.connect.dao.entities.ShortCodeList; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class ShortCodeListConverter extends AbstractConverter { public ShortCodeListConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return ShortCodeList.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ShortCodeList list = (ShortCodeList) object; writer.startNode("ShortCodes"); for (final ShortCode shortCode : list.getShortCodes()) { context.convertAnother(shortCode); } writer.endNode(); } }
2,016
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
RegistrationConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/RegistrationConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.joda.time.DateTime; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Registration; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class RegistrationConverter extends AbstractConverter implements JsonSerializer<Registration> { public RegistrationConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return Registration.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Registration registration = (Registration) object; writer.startNode("Registration"); writeSid(registration.getSid(), writer); writeDateCreated(registration.getDateCreated(), writer); writeDateUpdated(registration.getDateUpdated(), writer); writeDateExpires(registration.getDateExpires(), writer); writeAddressOfRecord(registration.getAddressOfRecord(), writer); writeDisplayName(registration.getDisplayName(), writer); writeUserName(registration.getUserName(), writer); writeTimeToLive(registration.getTimeToLive(), writer); writeLocation(registration.getLocation(), writer); writeUserAgent(registration.getUserAgent(), writer); writer.endNode(); } @Override public JsonElement serialize(final Registration registration, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(registration.getSid(), object); writeDateCreated(registration.getDateCreated(), object); writeDateUpdated(registration.getDateUpdated(), object); writeDateExpires(registration.getDateExpires(), object); writeAddressOfRecord(registration.getAddressOfRecord(), object); writeDisplayName(registration.getDisplayName(), object); writeUserName(registration.getUserName(), object); writeTimeToLive(registration.getTimeToLive(), object); writeLocation(registration.getLocation(), object); writeUserAgent(registration.getUserAgent(), object); return object; } private void writeDateExpires(final DateTime dateExpires, final HierarchicalStreamWriter writer) { writer.startNode("DateExpires"); writer.setValue(dateExpires.toString()); writer.endNode(); } private void writeDateExpires(final DateTime dateExpires, final JsonObject object) { object.addProperty("date_expires", dateExpires.toString()); } private void writeAddressOfRecord(final String addressOfRecord, final HierarchicalStreamWriter writer) { writer.startNode("AddressOfRecord"); writer.setValue(addressOfRecord); writer.endNode(); } private void writeAddressOfRecord(final String addressOfRecord, final JsonObject object) { object.addProperty("address_of_record", addressOfRecord.toString()); } private void writeDisplayName(final String displayName, final HierarchicalStreamWriter writer) { writer.startNode("DisplayName"); writer.setValue(displayName); writer.endNode(); } private void writeDisplayName(final String displayName, final JsonObject object) { object.addProperty("display_name", displayName.toString()); } private void writeLocation(final String location, final HierarchicalStreamWriter writer) { writer.startNode("Location"); writer.setValue(location); writer.endNode(); } private void writeLocation(final String location, final JsonObject object) { object.addProperty("location", location.toString()); } private void writeUserAgent(final String userAgent, final HierarchicalStreamWriter writer) { writer.startNode("UserAgent"); writer.setValue(userAgent); writer.endNode(); } private void writeUserAgent(final String userAgent, final JsonObject object) { object.addProperty("user_agent", userAgent.toString()); } }
5,459
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GeolocationListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/GeolocationListConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.http.converter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Geolocation; import org.restcomm.connect.dao.entities.GeolocationList; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author <a href="mailto:[email protected]"> Fernando Mendioroz </a> * */ @ThreadSafe public class GeolocationListConverter extends AbstractConverter { public GeolocationListConverter (final Configuration configuration){ super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return GeolocationList.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final GeolocationList list = (GeolocationList) object; writer.startNode("Geolocations"); for (final Geolocation geolocation : list.getGeolocations()) { context.convertAnother(geolocation); } writer.endNode(); } }
2,178
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
VersionConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/VersionConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.http.converter; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.VersionEntity; import java.lang.reflect.Type; /** * Created by gvagenas on 1/19/16. */ public class VersionConverter extends AbstractConverter implements JsonSerializer<VersionEntity> { public VersionConverter(Configuration configuration) { super(configuration); } @Override public boolean canConvert(Class klass) { return VersionEntity.class.equals(klass); } @Override public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext context) { final VersionEntity versionEntity = (VersionEntity) object; String version = versionEntity.getVersion(); String revision = versionEntity.getRevision(); String name = versionEntity.getName(); String date = versionEntity.getDate(); writer.startNode("Name"); writer.setValue(name+" Restcomm"); writer.endNode(); writer.startNode("Version"); writer.setValue(version); writer.endNode(); writer.startNode("Revision"); writer.setValue(revision); writer.endNode(); writer.startNode("Date"); writer.setValue(date); writer.endNode(); } @Override public JsonElement serialize(VersionEntity versionEntity, Type type, JsonSerializationContext jsonSerializationContext) { JsonObject result = new JsonObject(); result.addProperty("Name", versionEntity.getName()+" Restcomm"); result.addProperty("Version", versionEntity.getVersion()); result.addProperty("Revision", versionEntity.getRevision()); result.addProperty("Date", versionEntity.getDate()); return result; } }
3,016
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
OutgoingCallerIdConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/OutgoingCallerIdConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.OutgoingCallerId; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class OutgoingCallerIdConverter extends AbstractConverter implements JsonSerializer<OutgoingCallerId> { public OutgoingCallerIdConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return OutgoingCallerId.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final OutgoingCallerId outgoingCallerId = (OutgoingCallerId) object; writer.startNode("OutgoingCallerId"); writeSid(outgoingCallerId.getSid(), writer); writeAccountSid(outgoingCallerId.getAccountSid(), writer); writeFriendlyName(outgoingCallerId.getFriendlyName(), writer); writePhoneNumber(outgoingCallerId.getPhoneNumber(), writer); writeDateCreated(outgoingCallerId.getDateCreated(), writer); writeDateUpdated(outgoingCallerId.getDateUpdated(), writer); writeUri(outgoingCallerId.getUri(), writer); writer.endNode(); } @Override public JsonElement serialize(final OutgoingCallerId outgoingCallerId, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(outgoingCallerId.getSid(), object); writeAccountSid(outgoingCallerId.getAccountSid(), object); writeFriendlyName(outgoingCallerId.getFriendlyName(), object); writePhoneNumber(outgoingCallerId.getPhoneNumber(), object); writeDateCreated(outgoingCallerId.getDateCreated(), object); writeDateUpdated(outgoingCallerId.getDateUpdated(), object); writeUri(outgoingCallerId.getUri(), object); return object; } }
3,256
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
EmailMessageConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/EmailMessageConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.joda.time.DateTime; import org.restcomm.connect.email.api.Mail; import org.restcomm.connect.commons.dao.Sid; import com.google.gson.JsonElement; import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Lefteis Banos) */ public class EmailMessageConverter extends AbstractConverter implements JsonSerializer<Mail> { public EmailMessageConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return Mail.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Mail mailMessage = (Mail) object; writer.startNode("EmailMessage"); writeDateSent(mailMessage.dateSent(), writer); writeAccountSid(new Sid(mailMessage.accountSid()), writer); writeFrom(mailMessage.from(), writer); writeTo(mailMessage.to(), writer); writeBody(mailMessage.body(), writer); writeSubject(mailMessage.subject().toString(), writer); writer.endNode(); } @Override public JsonElement serialize(final Mail mailMessage, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeDateSent(mailMessage.dateSent(), object); writeAccountSid(new Sid(mailMessage.accountSid()), object); writeFrom(mailMessage.from(), object); writeTo(mailMessage.to(), object); writeBody(mailMessage.body(), object); writeSubject(mailMessage.subject().toString(), object); return object; } private void writeBody(final String body, final HierarchicalStreamWriter writer) { writer.startNode("Body"); if (body != null) { writer.setValue(body); } writer.endNode(); } private void writeBody(final String body, final JsonObject object) { if (body != null) { object.addProperty("body", body); } else { object.add("body", JsonNull.INSTANCE); } } private void writeDateSent(final DateTime dateSent, final HierarchicalStreamWriter writer) { writer.startNode("DateSent"); if (dateSent != null) { writer.setValue(dateSent.toString()); } writer.endNode(); } private void writeDateSent(final DateTime dateSent, final JsonObject object) { object.addProperty("date_sent", dateSent != null ? dateSent.toString() : null); } private void writeSubject(final String subject, final HierarchicalStreamWriter writer) { writer.startNode("Subject"); writer.setValue(subject); writer.endNode(); } private void writeSubject(final String subject, final JsonObject object) { object.addProperty("subject", subject); } }
4,146
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
RestCommResponseConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/RestCommResponseConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.RestCommResponse; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class RestCommResponseConverter extends AbstractConverter { public RestCommResponseConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return RestCommResponse.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final RestCommResponse response = (RestCommResponse) object; context.convertAnother(response.getObject()); } }
1,852
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ClientListConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/ClientListConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Client; import org.restcomm.connect.dao.entities.ClientList; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class ClientListConverter extends AbstractConverter { public ClientListConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return ClientList.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ClientList list = (ClientList) object; writer.startNode("Clients"); for (final Client client : list.getClients()) { context.convertAnother(client); } writer.endNode(); } }
1,980
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ClientConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/ClientConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.dao.entities.Client; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public class ClientConverter extends AbstractConverter implements JsonSerializer<Client> { public ClientConverter(final Configuration configuration) { super(configuration); } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return Client.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Client client = (Client) object; writer.startNode("Client"); writeSid(client.getSid(), writer); writeDateCreated(client.getDateCreated(), writer); writeDateUpdated(client.getDateUpdated(), writer); writeAccountSid(client.getAccountSid(), writer); writeApiVersion(client.getApiVersion(), writer); writeFriendlyName(client.getFriendlyName(), writer); writeLogin(client.getLogin(), writer); writePassword(client.getPassword(), writer); writePasswordAlgorithm(client.getPasswordAlgorithm(), writer); writeStatus(client.getStatus().toString(), writer); writeVoiceUrl(client.getVoiceUrl(), writer); writeVoiceMethod(client.getVoiceMethod(), writer); writeVoiceFallbackUrl(client.getVoiceFallbackUrl(), writer); writeVoiceFallbackMethod(client.getVoiceFallbackMethod(), writer); writeVoiceApplicationSid(client.getVoiceApplicationSid(), writer); writeUri(client.getUri(), writer); writePushClientIdentity(client.getPushClientIdentity(), writer); writer.endNode(); } @Override public JsonElement serialize(final Client client, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(client.getSid(), object); writeDateCreated(client.getDateCreated(), object); writeDateUpdated(client.getDateUpdated(), object); writeAccountSid(client.getAccountSid(), object); writeApiVersion(client.getApiVersion(), object); writeFriendlyName(client.getFriendlyName(), object); writeLogin(client.getLogin(), object); writePassword(client.getPassword(), object); writePasswordAlgorithm(client.getPasswordAlgorithm(), object); writeStatus(client.getStatus().toString(), object); writeVoiceUrl(client.getVoiceUrl(), object); writeVoiceMethod(client.getVoiceMethod(), object); writeVoiceFallbackUrl(client.getVoiceFallbackUrl(), object); writeVoiceFallbackMethod(client.getVoiceFallbackMethod(), object); writeVoiceApplicationSid(client.getVoiceApplicationSid(), object); writeUri(client.getUri(), object); writePushClientIdentity(client.getPushClientIdentity(), object); return object; } protected void writeLogin(final String login, final HierarchicalStreamWriter writer) { writer.startNode("Login"); writer.setValue(login); writer.endNode(); } protected void writeLogin(final String login, final JsonObject object) { object.addProperty("login", login); } protected void writePassword(final String password, final HierarchicalStreamWriter writer) { writer.startNode("Password"); writer.setValue(password); writer.endNode(); } protected void writePasswordAlgorithm(final String password_algorithm, final HierarchicalStreamWriter writer) { writer.startNode("Password_Algorithm"); writer.setValue(password_algorithm); writer.endNode(); } protected void writePassword(final String password, final JsonObject object) { object.addProperty("password", password); } protected void writePasswordAlgorithm(final String password_algorithm, final JsonObject object) { object.addProperty("password_algorithm", password_algorithm); } }
5,337
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
RecordingConverter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/converter/RecordingConverter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.converter; import java.lang.reflect.Type; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.amazonS3.RecordingSecurityLevel; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.core.service.RestcommConnectServiceProvider; import org.restcomm.connect.dao.entities.Recording; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; /** * @author [email protected] (Thomas Quintana) */ @ThreadSafe public final class RecordingConverter extends AbstractConverter implements JsonSerializer<Recording> { private RecordingSecurityLevel securityLevel = RecordingSecurityLevel.SECURE; public RecordingConverter(final Configuration configuration) { super(configuration); } public void setSecurityLevel(final RecordingSecurityLevel securityLevel) { this.securityLevel = securityLevel; } @SuppressWarnings("rawtypes") @Override public boolean canConvert(final Class klass) { return Recording.class.equals(klass); } @Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Recording recording = (Recording) object; writer.startNode("Recording"); writeSid(recording.getSid(), writer); writeDateCreated(recording.getDateCreated(), writer); writeDateUpdated(recording.getDateUpdated(), writer); writeAccountSid(recording.getAccountSid(), writer); writeCallSid(recording.getCallSid(), writer); writeDuration(recording.getDuration(), writer); writeApiVersion(recording.getApiVersion(), writer); writeUri(recording.getUri(), writer); writer.startNode("FileUri"); //Previously MybatisRecordingsDao used to prepare absolute URL for fileUri. Now we do it in the converter String fileUri = RestcommConnectServiceProvider.getInstance().uriUtils().resolve(recording.getFileUri(), recording.getAccountSid()).toString(); writer.setValue(fileUri); writer.endNode(); if (securityLevel.equals(RecordingSecurityLevel.NONE) && recording.getS3Uri() != null) { writer.startNode("S3Uri"); writer.setValue(recording.getS3Uri().toString()); writer.endNode(); } writer.endNode(); } @Override public JsonElement serialize(final Recording recording, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(recording.getSid(), object); writeDateCreated(recording.getDateCreated(), object); writeDateUpdated(recording.getDateUpdated(), object); writeAccountSid(recording.getAccountSid(), object); writeCallSid(recording.getCallSid(), object); writeDuration(recording.getDuration(), object); writeApiVersion(recording.getApiVersion(), object); writeUri(recording.getUri(), object); if (recording.getFileUri() != null) { //Previously MybatisRecordingsDao used to prepare absolute URL for fileUri. Now we do it in the converter String fileUri = RestcommConnectServiceProvider.getInstance().uriUtils().resolve(recording.getFileUri(), recording.getAccountSid()).toString(); object.addProperty("file_uri", fileUri); } if (securityLevel.equals(RecordingSecurityLevel.NONE) && recording.getS3Uri() != null) { object.addProperty("s3_uri", recording.getS3Uri().toString()); } return object; } }
4,679
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
FileCacheServlet.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/filters/FileCacheServlet.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.filters; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URLDecoder; import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.channels.WritableByteChannel; import java.util.Arrays; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.configuration.Configuration; import org.apache.log4j.Logger; /** * Serves media resources to other third-prty systems like RMS. * * The content is saved in a local FileSystem directory which location is coming * from RC configuration. * * The urlpattern needs to be synced with "cache-uri" conf */ public class FileCacheServlet extends HttpServlet { private Logger logger = Logger.getLogger(FileCacheServlet.class); // Constants ---------------------------------------------------------------------------------- private static final int DEFAULT_BUFFER_SIZE = 10240; // ..bytes = 10KB. private static final long DEFAULT_EXPIRE_TIME = 604800000L; // ..ms = 1 week. /** * Process HEAD request. This returns the same headers as GET request, but * without content. * * @see HttpServlet#doHead(HttpServletRequest, HttpServletResponse). */ protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Process request without content. processRequest(request, response, false); } /** * Process GET request. * * @see HttpServlet#doGet(HttpServletRequest, HttpServletResponse). */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Process request with content. processRequest(request, response, true); } /** * Process the actual request. * * @param request The request to be processed. * @param response The response to be created. * @param content Whether the request body should be written (GET) or not * (HEAD). * @throws IOException If something fails at I/O level. */ private void processRequest(HttpServletRequest request, HttpServletResponse response, boolean content) throws IOException { // Validate the requested file ------------------------------------------------------------ // Get requested file by path info. String requestedFile = request.getPathInfo(); if (logger.isDebugEnabled()) { logger.debug("Requested path:" + requestedFile); } // Check if file is actually supplied to the request URL. if (requestedFile == null) { logger.debug("No file requested, return 404."); // Do your thing if the file is not supplied to the request URL. // Throw an exception, or send 404, or show default/warning page, or just ignore it. response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } Configuration rootConfiguration = (Configuration) request.getServletContext().getAttribute(Configuration.class.getName()); Configuration runtimeConfiguration = rootConfiguration.subset("runtime-settings"); String basePath = runtimeConfiguration.getString("cache-path"); int bufferSize = runtimeConfiguration.getInteger("cache-buffer-size", DEFAULT_BUFFER_SIZE); long expireTime = runtimeConfiguration.getLong("cache-expire-time", DEFAULT_EXPIRE_TIME); // URL-decode the file name (might contain spaces and on) and prepare file object. String fDecodedPath = URLDecoder.decode(requestedFile, "UTF-8"); File file = new File(basePath, fDecodedPath); // Check if file actually exists in filesystem. if (!file.exists()) { logger.debug("Requested file not found, return 404."); // Do your thing if the file appears to be non-existing. // Throw an exception, or send 404, or show default/warning page, or just ignore it. response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } // Prepare some variables. The ETag is an unique identifier of the file. String fileName = file.getName(); long length = file.length(); long lastModified = file.lastModified(); String eTag = fileName + "_" + length + "_" + lastModified; long expires = System.currentTimeMillis() + expireTime; // Validate request headers for caching --------------------------------------------------- // If-None-Match header should contain "*" or ETag. If so, then return 304. String ifNoneMatch = request.getHeader("If-None-Match"); if (ifNoneMatch != null && matches(ifNoneMatch, eTag)) { logger.debug("IfNoneMatch/Etag not matching, return 304."); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader("ETag", eTag); // Required in 304. response.setDateHeader("Expires", expires); // Postpone cache with 1 week. return; } // If-Modified-Since header should be greater than LastModified. If so, then return 304. // This header is ignored if any If-None-Match header is specified. long ifModifiedSince = request.getDateHeader("If-Modified-Since"); if (ifNoneMatch == null && ifModifiedSince != -1 && ifModifiedSince + 1000 > lastModified) { logger.debug("IfModifiedSince not matching, return 304."); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader("ETag", eTag); // Required in 304. response.setDateHeader("Expires", expires); // Postpone cache with 1 week. return; } // Validate request headers for resume ---------------------------------------------------- // If-Match header should contain "*" or ETag. If not, then return 412. String ifMatch = request.getHeader("If-Match"); if (ifMatch != null && !matches(ifMatch, eTag)) { logger.debug("ifMatch not matching, return 412."); response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return; } // If-Unmodified-Since header should be greater than LastModified. If not, then return 412. long ifUnmodifiedSince = request.getDateHeader("If-Unmodified-Since"); if (ifUnmodifiedSince != -1 && ifUnmodifiedSince + 1000 <= lastModified) { logger.debug("ifUnmodifiedSince not matching, return 412."); response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return; } // Prepare and initialize response -------------------------------------------------------- // Get content type by file name and content disposition. String contentType = getServletContext().getMimeType(fileName); String disposition = "inline"; // If content type is unknown, then set the default value. // For all content types, see: http://www.w3schools.com/media/media_mimeref.asp // To add new content types, add new mime-mapping entry in web.xml. if (contentType == null) { contentType = "application/octet-stream"; } // If content type is text, expand content type with the one and right character encoding. if (contentType.startsWith("text")) { contentType += ";charset=UTF-8"; } // Else, expect for images, determine content disposition. If content type is supported by // the browser, then set to inline, else attachment which will pop a 'save as' dialogue. else if (!contentType.startsWith("image")) { String accept = request.getHeader("Accept"); disposition = accept != null && accepts(accept, contentType) ? "inline" : "attachment"; } // Initialize response. response.reset(); response.setBufferSize(bufferSize); response.setHeader("Content-Disposition", disposition + ";filename=\"" + fileName + "\""); response.setHeader("Accept-Ranges", "bytes"); response.setHeader("ETag", eTag); response.setDateHeader("Last-Modified", lastModified); response.setDateHeader("Expires", expires); // Send requested file (part(s)) to client ------------------------------------------------ // Prepare streams. FileInputStream input = null; OutputStream output = null; if (content) { logger.debug("Content requested,streaming."); // Open streams. input = new FileInputStream(file); output = response.getOutputStream(); long streamed = stream(input, output, bufferSize); if (logger.isDebugEnabled()) { logger.debug("Bytes streamed:" + streamed); } } } // Helpers (can be refactored to public utility class) ---------------------------------------- /** * Returns true if the given accept header accepts the given value. * * @param acceptHeader The accept header. * @param toAccept The value to be accepted. * @return True if the given accept header accepts the given value. */ private static boolean accepts(String acceptHeader, String toAccept) { String[] acceptValues = acceptHeader.split("\\s*(,|;)\\s*"); Arrays.sort(acceptValues); return Arrays.binarySearch(acceptValues, toAccept) > -1 || Arrays.binarySearch(acceptValues, toAccept.replaceAll("/.*$", "/*")) > -1 || Arrays.binarySearch(acceptValues, "*/*") > -1; } /** * Returns true if the given match header matches the given value. * * @param matchHeader The match header. * @param toMatch The value to be matched. * @return True if the given match header matches the given value. */ private static boolean matches(String matchHeader, String toMatch) { String[] matchValues = matchHeader.split("\\s*,\\s*"); Arrays.sort(matchValues); return Arrays.binarySearch(matchValues, toMatch) > -1 || Arrays.binarySearch(matchValues, "*") > -1; } /** * Stream the given input to the given output via NIO {@link Channels} and a * directly allocated NIO {@link ByteBuffer}. Both the input and output * streams will implicitly be closed after streaming, regardless of whether * an exception is been thrown or not. * * @param input The input stream. * @param output The output stream. * @param bufferSize * @return The length of the written bytes. * @throws IOException When an I/O error occurs. */ public static long stream(InputStream input, OutputStream output, int bufferSize) throws IOException { try (ReadableByteChannel inputChannel = Channels.newChannel(input); WritableByteChannel outputChannel = Channels.newChannel(output)) { ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize); long size = 0; while (inputChannel.read(buffer) != -1) { buffer.flip(); size += outputChannel.write(buffer); buffer.clear(); } return size; } } }
12,432
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
BodyLengthFilter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/filters/BodyLengthFilter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.filters; import com.sun.jersey.spi.container.ContainerRequest; import com.sun.jersey.spi.container.ContainerRequestFilter; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import static javax.ws.rs.core.Response.status; import javax.ws.rs.ext.Provider; import org.apache.log4j.Logger; import org.restcomm.connect.http.exceptionmappers.CustomReasonPhraseType; @Provider public class BodyLengthFilter implements ContainerRequestFilter { protected Logger logger = Logger.getLogger(ExtensionFilter.class); private static final int MAX_REQ_BODY_SIZE = 10000000; @Override public ContainerRequest filter(ContainerRequest request) { String length = request.getHeaderValue(HttpHeaders.CONTENT_LENGTH); if (length != null) { int bodySize = Integer.parseInt(length); if (bodySize > MAX_REQ_BODY_SIZE) { logger.debug("Request rejected by size"); CustomReasonPhraseType customReasonPhraseType = new CustomReasonPhraseType(Status.Family.CLIENT_ERROR, 413, "Length larger than " + MAX_REQ_BODY_SIZE); Response build = status(customReasonPhraseType).build(); throw new WebApplicationException(build); } } return request; } }
2,222
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
AcceptFilter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/filters/AcceptFilter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.filters; import com.sun.jersey.spi.container.ContainerRequest; import com.sun.jersey.spi.container.ContainerRequestFilter; import com.sun.jersey.spi.container.ContainerResponseFilter; import com.sun.jersey.spi.container.ResourceFilter; import java.net.URI; import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.PathSegment; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.ext.Provider; import org.apache.log4j.Logger; /** * Fixes the accept header taking into accoutn convention on URL (.json). * * ".json" suffix will be removed before matching the actual REST endpoint * * @author */ @Provider public class AcceptFilter implements ResourceFilter, ContainerRequestFilter { protected Logger logger = Logger.getLogger(AcceptFilter.class); private static final String JSON_EXTENSION = ".json"; private static final String ACCEPT_HDR = "Accept"; private URI reworkJSONPath(ContainerRequest cr) { List<PathSegment> pathSegments = cr.getPathSegments(); UriBuilder baseUriBuilder = cr.getBaseUriBuilder(); for (PathSegment seg : pathSegments) { String newSeg = seg.getPath(); if (seg.getPath().endsWith(JSON_EXTENSION)) { int n = newSeg.length(); newSeg = newSeg.substring(0, n - JSON_EXTENSION.length()); } baseUriBuilder.path(newSeg); } MultivaluedMap<String, String> queryParameters = cr.getQueryParameters(); for (String qParam : queryParameters.keySet()) { baseUriBuilder.queryParam(qParam, queryParameters.getFirst(qParam)); } return baseUriBuilder.build(); } @Override public ContainerRequest filter(ContainerRequest cr) { if (cr.getHeaderValue(ACCEPT_HDR) == null) { if (cr.getPath().contains(JSON_EXTENSION)) { cr.getRequestHeaders().add(ACCEPT_HDR, MediaType.APPLICATION_JSON); } else { //by default assume client is expecting XML cr.getRequestHeaders().add(ACCEPT_HDR, MediaType.APPLICATION_XML); } } //Do not apply for Profiles endpoint, as is not following .json convention if (cr.getPath().contains(JSON_EXTENSION) && !cr.getPath().contains("Profiles")) { cr.getRequestHeaders().remove(ACCEPT_HDR); cr.getRequestHeaders().add(ACCEPT_HDR, MediaType.APPLICATION_JSON); URI reworkedUri = reworkJSONPath(cr); cr.setUris(cr.getBaseUri(), reworkedUri); } return cr; } @Override public ContainerRequestFilter getRequestFilter() { return this; } @Override public ContainerResponseFilter getResponseFilter() { return null; } }
3,688
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
SchemeRewriteFilter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/filters/SchemeRewriteFilter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.filters; import com.sun.jersey.spi.container.ContainerRequest; import com.sun.jersey.spi.container.ContainerRequestFilter; import com.sun.jersey.spi.container.ContainerResponseFilter; import com.sun.jersey.spi.container.ResourceFilter; import org.apache.log4j.Logger; import org.restcomm.connect.core.service.RestcommConnectServiceProvider; import javax.ws.rs.ext.Provider; import java.net.URI; /** * Ensures UriInfo builders build proper link scheme depending on container * connector (http/https) * * This will apply to any jaxrs endpoint trying to build uris later. * * UriUtils is used to discover connectors in runtime, and check the scheme. * */ @Provider public class SchemeRewriteFilter implements ResourceFilter, ContainerRequestFilter { protected Logger logger = Logger.getLogger(SchemeRewriteFilter.class); private static final String HTTPS_SCHEME = "https"; @Override public ContainerRequest filter(ContainerRequest cr) { String connectorScheme = RestcommConnectServiceProvider.getInstance().uriUtils().getHttpConnector().getScheme(); if (connectorScheme.equalsIgnoreCase(HTTPS_SCHEME)) { URI newUri = cr.getRequestUriBuilder().scheme(HTTPS_SCHEME).build(); URI baseUri = cr.getBaseUriBuilder().scheme(HTTPS_SCHEME).build(); cr.setUris(baseUri, newUri); if (logger.isDebugEnabled()) { logger.debug("Detected https connector, rewriting URIs:" + newUri + "," + baseUri); } } return cr; } @Override public ContainerRequestFilter getRequestFilter() { return this; } @Override public ContainerResponseFilter getResponseFilter() { return null; } }
2,657
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ExtensionFilter.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/filters/ExtensionFilter.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.http.filters; import com.sun.jersey.spi.container.ContainerRequest; import com.sun.jersey.spi.container.ContainerRequestFilter; import com.sun.jersey.spi.container.ContainerResponse; import com.sun.jersey.spi.container.ContainerResponseFilter; import com.sun.jersey.spi.container.ResourceFilter; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.PathSegment; import javax.ws.rs.core.Response; import static javax.ws.rs.core.Response.Status.FORBIDDEN; import static javax.ws.rs.core.Response.status; import javax.ws.rs.ext.Provider; import org.apache.log4j.Logger; import org.restcomm.connect.extension.api.ApiRequest; import org.restcomm.connect.extension.api.ExtensionType; import org.restcomm.connect.extension.api.RestcommExtensionGeneric; import org.restcomm.connect.extension.controller.ExtensionController; import org.restcomm.connect.http.exceptionmappers.CustomReasonPhraseType; /** * Checks if this REST API request is allowed by Extensions. * * @author */ @Provider public class ExtensionFilter implements ResourceFilter, ContainerRequestFilter, ContainerResponseFilter { protected Logger logger = Logger.getLogger(ExtensionFilter.class); private static final Map<String, ApiRequest.Type> TYPE_MAP = new HashMap(); static { TYPE_MAP.put("AvailablePhoneNumbers", ApiRequest.Type.AVAILABLEPHONENUMBER); TYPE_MAP.put("IncomingPhoneNumbers", ApiRequest.Type.INCOMINGPHONENUMBER); TYPE_MAP.put("AvailablePhoneNumbers.json", ApiRequest.Type.AVAILABLEPHONENUMBER); TYPE_MAP.put("IncomingPhoneNumbers.json", ApiRequest.Type.INCOMINGPHONENUMBER); } private int retrieveAccountPathPosition(ContainerRequest cr) { boolean accountFound = false; int i = 0; List<PathSegment> pathSegments = cr.getPathSegments(); while (i < pathSegments.size() && !accountFound) { if (pathSegments.get(i).getPath().startsWith("Accounts")) { accountFound = true; } } if (accountFound && i + 1 < pathSegments.size()) { //next path to "Accounts" i = i + 1; } else { i = -1; } return i; } private String retrieveAccountSid(ContainerRequest cr) { String accountSid = null; List<PathSegment> pathSegments = cr.getPathSegments(); int accountPos = retrieveAccountPathPosition(cr); if (accountPos >= 0) { accountSid = pathSegments.get(accountPos).getPath(); } return accountSid; } private ApiRequest.Type mapType(ContainerRequest cr) { ApiRequest.Type type = null; List<PathSegment> pathSegments = cr.getPathSegments(); int accountPos = retrieveAccountPathPosition(cr); if (accountPos >= 0 && accountPos + 1 < pathSegments.size()) { String subResPath = pathSegments.get(accountPos + 1).getPath(); type = TYPE_MAP.get(subResPath); } return type; } @Override public ContainerRequest filter(ContainerRequest cr) { final String accountSid = retrieveAccountSid(cr); ApiRequest.Type type = mapType(cr); final MultivaluedMap<String, String> data = cr.getFormParameters(); if (accountSid != null && type != null) { ApiRequest apiRequest = new ApiRequest(accountSid, data, type); if (!executePreApiAction(apiRequest)) { CustomReasonPhraseType customReasonPhraseType = new CustomReasonPhraseType(FORBIDDEN, "Extension blocked access"); Response build = status(customReasonPhraseType).build(); throw new WebApplicationException(build); } } return cr; } @Override public ContainerRequestFilter getRequestFilter() { return this; } @Override public ContainerResponseFilter getResponseFilter() { return this; } private boolean executePreApiAction(final ApiRequest apiRequest) { List<RestcommExtensionGeneric> extensions = ExtensionController.getInstance().getExtensions(ExtensionType.RestApi); ExtensionController ec = ExtensionController.getInstance(); return ec.executePreApiAction(apiRequest, extensions).isAllowed(); } private boolean executePostApiAction(final ApiRequest apiRequest) { List<RestcommExtensionGeneric> extensions = ExtensionController.getInstance().getExtensions(ExtensionType.RestApi); ExtensionController ec = ExtensionController.getInstance(); return ec.executePostApiAction(apiRequest, extensions).isAllowed(); } @Override public ContainerResponse filter(ContainerRequest cr, ContainerResponse response) { final String accountSid = retrieveAccountSid(cr); ApiRequest.Type type = mapType(cr); final MultivaluedMap<String, String> data = cr.getFormParameters(); ApiRequest apiRequest = new ApiRequest(accountSid, data, type); executePostApiAction(apiRequest); return response; } }
6,008
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
PhoneNumberSearchFilters.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.provisioning.number.api/src/main/java/org/restcomm/connect/provisioning/number/api/PhoneNumberSearchFilters.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.provisioning.number.api; import java.util.regex.Pattern; /** * This POJO is holding the different filters that can be applied to Phone Number Search to filter the results * * <p> * The following filters are available for phone numbers search: * </p> * <table> * <thead> * <tr> * <th align="left">Property</th> * <th align="left">Description</th> * </tr> * </thead> <tbody> * <tr> * <td class='notranslate' align="left">AreaCode</td> * <td align="left">The areacode for the phone number</td> * </tr> * <tr> * <td class='notranslate' align="left">FilterPattern</td> * <td align="left">A pattern to match phone numbers on. Valid characters are '*' and [0-9a-zA-Z]. The '*' character will match any single digit.</td> * </tr> * <tr> * <td class='notranslate' align="left">SmsEnabled</td> * <td align="left">This indicates whether the phone numbers can receive text messages. Possible values are true or false..</td> * </tr> * <tr> * <td class='notranslate' align="left">MmsEnabled</td> * <td align="left">This indicates whether the phone numbers can receive MMS messages. Possible values are true or false..</td> * </tr> * <tr> * <td class='notranslate' align="left">VoiceEnabled</td> * <td align="left">This indicates whether the phone numbers can receive calls. Possible values are true or false..</td> * </tr> * <tr> * <td class='notranslate' align="left">FaxEnabled</td> * <td align="left">This indicates whether the phone numbers can receive fax message. Possible values are true or false..</td> * </tr> * <tr> * <td class='notranslate' align="left">UssdEnabled</td> * <td align="left">This indicates whether the phone numbers can receive USSD messages. Possible values are true or false..</td> * </tr> * <tr> * <td class='notranslate' align="left">NearNumber</td> * <td align="left">Given a phone number, find a geographically close number within Distance miles. Distance defaults to 25 miles.</td> * </tr> * <tr> * <td class='notranslate' align="left">NearLatLong</td> * <td align="left">Given a latitude/longitude pair lat,long find geographically close numbers within Distance miles.</td> * </tr> * <tr> * <td class='notranslate' align="left">Distance</td> * <td align="left">Specifies the search radius for a Near- query in miles. If not specified this defaults to 25 miles. Maximum searchable distance is 500 miles.</td> * </tr> * <tr> * <td class='notranslate' align="left">InPostalCode</td> * <td align="left">Limit results to a particular postal code. Given a phone number, search within the same postal code as that number.</td> * </tr> * <tr> * <td class='notranslate' align="left">InRegion</td> * <td align="left">Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number.</td> * </tr> * <tr> * <td class='notranslate' align="left">InRateCenter</td> * <td align="left">Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires InLata to be set as well.</td> * </tr> * <tr> * <td class='notranslate' align="left">InLata</td> * <td align="left">Limit results to a specific Local access and transport area (LATA - http://en.wikipedia.org/wiki/Local_access_and_transport_area). Given a phone number, search within the same LATA as that number.</td> * </tr> * </tbody> * </table> * @author [email protected] */ public class PhoneNumberSearchFilters { String areaCode; Pattern filterPattern; Boolean smsEnabled; Boolean mmsEnabled; Boolean voiceEnabled; Boolean faxEnabled; Boolean ussdEnabled; String nearNumber; String nearLatLong; String distance; String inPostalCode; String inRegion; String inRateCenter; String inLata; int rangeSize; int rangeIndex; PhoneNumberType phoneNumberType; public PhoneNumberSearchFilters() { } public PhoneNumberSearchFilters(String areaCode, Pattern filterPattern, Boolean smsEnabled, Boolean mmsEnabled, Boolean voiceEnabled, Boolean faxEnabled, Boolean ussdEnabled, String nearNumber, String nearLatLong, String distance, String inPostalCode, String inRegion, String inRateCenter, String inLata, int rangeSize, int rangeIndex, PhoneNumberType phoneNumberType) { this.areaCode = areaCode; this.filterPattern = filterPattern; this.smsEnabled = smsEnabled; this.mmsEnabled = mmsEnabled; this.voiceEnabled = voiceEnabled; this.faxEnabled = faxEnabled; this.ussdEnabled = ussdEnabled; this.nearNumber = nearNumber; this.nearLatLong = nearLatLong; this.distance = distance; this.inPostalCode = inPostalCode; this.inRegion = inRegion; this.inRateCenter = inRateCenter; this.inLata = inLata; this.rangeSize = rangeSize; this.rangeIndex = rangeIndex; this.phoneNumberType = phoneNumberType; } /** * @return the areaCode */ public String getAreaCode() { return areaCode; } /** * @param areaCode the areaCode to set */ public void setAreaCode(String areaCode) { this.areaCode = areaCode; } /** * @return the filterPattern */ public Pattern getFilterPattern() { return filterPattern; } /** * @param filterPattern the filterPattern to set */ public void setFilterPattern(Pattern filterPattern) { this.filterPattern = filterPattern; } /** * @return the smsEnabled */ public Boolean getSmsEnabled() { return smsEnabled; } /** * @param smsEnabled the smsEnabled to set */ public void setSmsEnabled(Boolean smsEnabled) { this.smsEnabled = smsEnabled; } /** * @return the mmsEnabled */ public Boolean getMmsEnabled() { return mmsEnabled; } /** * @param mmsEnabled the mmsEnabled to set */ public void setMmsEnabled(Boolean mmsEnabled) { this.mmsEnabled = mmsEnabled; } /** * @return the voiceEnabled */ public Boolean getVoiceEnabled() { return voiceEnabled; } /** * @param voiceEnabled the voiceEnabled to set */ public void setVoiceEnabled(Boolean voiceEnabled) { this.voiceEnabled = voiceEnabled; } /** * @return the faxEnabled */ public Boolean getFaxEnabled() { return faxEnabled; } /** * @param faxEnabled the faxEnabled to set */ public void setFaxEnabled(Boolean faxEnabled) { this.faxEnabled = faxEnabled; } /** * @return the ussdEnabled */ public Boolean getUssdEnabled() { return ussdEnabled; } /** * @param ussdEnabled the ussdEnabled to set */ public void setUssdEnabled(Boolean ussdEnabled) { this.ussdEnabled = ussdEnabled; } /** * @return the nearNumber */ public String getNearNumber() { return nearNumber; } /** * @param nearNumber the nearNumber to set */ public void setNearNumber(String nearNumber) { this.nearNumber = nearNumber; } /** * @return the nearLatLong */ public String getNearLatLong() { return nearLatLong; } /** * @param nearLatLong the nearLatLong to set */ public void setNearLatLong(String nearLatLong) { this.nearLatLong = nearLatLong; } /** * @return the distance */ public String getDistance() { return distance; } /** * @param distance the distance to set */ public void setDistance(String distance) { this.distance = distance; } /** * @return the inPostalCode */ public String getInPostalCode() { return inPostalCode; } /** * @param inPostalCode the inPostalCode to set */ public void setInPostalCode(String inPostalCode) { this.inPostalCode = inPostalCode; } /** * @return the inRegion */ public String getInRegion() { return inRegion; } /** * @param inRegion the inRegion to set */ public void setInRegion(String inRegion) { this.inRegion = inRegion; } /** * @return the inRateCenter */ public String getInRateCenter() { return inRateCenter; } /** * @param inRateCenter the inRateCenter to set */ public void setInRateCenter(String inRateCenter) { this.inRateCenter = inRateCenter; } /** * @return the inLata */ public String getInLata() { return inLata; } /** * @param inLata the inLata to set */ public void setInLata(String inLata) { this.inLata = inLata; } /** * @return the rangeSize */ public int getRangeSize() { return rangeSize; } /** * @param rangeSize the rangeSize to set */ public void setRangeSize(int rangeSize) { this.rangeSize = rangeSize; } /** * @return the rangeIndex */ public int getRangeIndex() { return rangeIndex; } /** * @param rangeIndex the rangeIndex to set */ public void setRangeIndex(int rangeIndex) { this.rangeIndex = rangeIndex; } /** * @return the type of phone number to search for */ public PhoneNumberType getPhoneNumberTypeSearch() { return phoneNumberType; } /** * @param phoneNumberTypeSearch the type of phone number to search for */ public void setPhoneNumberTypeSearch(PhoneNumberType phoneNumberTypeSearch) { this.phoneNumberType = phoneNumberTypeSearch; } }
10,635
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
PhoneNumberProvisioningManager.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.provisioning.number.api/src/main/java/org/restcomm/connect/provisioning/number/api/PhoneNumberProvisioningManager.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.provisioning.number.api; import java.util.List; import org.apache.commons.configuration.Configuration; /** * <p>Interface for plugging Phone Number Provisioning Providers.</p> * * <p>Its init method will be called on startup to initialize and pass the parameters found in restcomm.xml phone-number-provisioning tag as an Apache Commons Configuration Object</p> * <p>the following methods will be called by RestComm during runtime</p> * <ul> * <li>searchForNumbers : when a user is searching for a number to provision</li> * <li>buyNumber : when a user is purchasing a number</li> * <li>updateNumber : when a user is updating the properties/callback URLs of an already purchased number</li> * <li>cancelNumber : when a user is cancelling a number</li> * </ul> * * @author [email protected] */ public interface PhoneNumberProvisioningManager { /** * Initialize the Manager with the RestComm configuration passed in restcomm.xml * * @param phoneNumberProvisioningConfiguration the configuration * @param teleStaxProxyConfiguration the configuration from restcomm.xml contained within <phone-number-provisioning> tags * @param containerConfiguration with container configuration information */ void init(Configuration phoneNumberProvisioningConfiguration, Configuration teleStaxProxyConfiguration, ContainerConfiguration containerConfiguration); /** * Search for a list of numbers matching the various parameters * * @param country 2 letters Country Code as defined per http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2. * @param listFilters contains all the filters that can be applied to restrict the results * @return List of matching numbers */ List<PhoneNumber> searchForNumbers(String country, PhoneNumberSearchFilters listFilters); /** * Purchase a given phone number previously searched through {@link #searchForNumbers(String, PhoneNumberSearchFilters) searchForNumbers} method. * * @param phoneNumber An available phone number - defined as msisdn Ex: 34911067000 returned from * {@link #searchForNumbers(String, PhoneNumberSearchFilters) searchForNumbers} method. * @param phoneNumberParameters parameters set on the phone number purchase so the Provider knows where to route incoming messages (be it voice or SMS, MMS, USSD) * @return true if the number was bought successfully, false otherwise. */ boolean buyNumber(PhoneNumber phoneNumber, PhoneNumberParameters phoneNumberParameters); /** * Update the parameters for an already purchased phone number. * * @param number An available phone number - defined as msisdn Ex: 34911067000 returned from * {@link #searchForNumbers(String, PhoneNumberSearchFilters) searchForNumbers} method. * @param phoneNumberParameters parameters set on the phone number purchase so the Provider knows where to route incoming messages (be it voice or SMS, MMS, USSD). * @return true if the number was updated successfully, false otherwise. */ boolean updateNumber(PhoneNumber number, PhoneNumberParameters phoneNumberParameters); /** * Cancel an already purchased phone number. * * @param number the phonenumber to cancel -defined as msisdn Ex: 34911067000 * @return true if the number was cancelled successfully, false otherwise. */ boolean cancelNumber(PhoneNumber number); /** * Returns the list of supported countries by the phone number provider * * @return a list of 2 letters Country Code as defined per http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2, representing all countries where a number can be bought or searched in. */ List<String> getAvailableCountries(); }
4,623
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
PhoneNumberParameters.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.provisioning.number.api/src/main/java/org/restcomm/connect/provisioning/number/api/PhoneNumberParameters.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.provisioning.number.api; /** * <p> * The following optional parameters for the DID provider to set when a number is bought or updated * </p> * <table> * <thead> * <tr> * <th align="left">Property</th> * <th align="left">Description</th> * </tr> * </thead> * <tbody> * <tr> * <td class='notranslate' align="left">VoiceUrl</td> * <td align="left">The URL in host:port format that the DID provider should request when somebody dials the new phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">VoiceMethod</td> * <td align="left">The method that should be used to request the VoiceUrl. Only SIP or SIPS supported currently. Defaults to SIP.</td> * </tr> * <tr> * <td class='notranslate' align="left">doVoiceCallerIdLookup</td> * <td align="left">Do a lookup of a caller's name from the CNAM database if the service provider support it. Either true or false. Defaults to false..</td> * </tr> * <tr> * <td class='notranslate' align="left">SmsUrl</td> * <td align="left">The URL in host:port format (SIP, SMPP, or SS7 MAP) that the DID provider should request when somebody sends an SMS to the phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">SMSMethod</td> * <td align="left">The method that should be used to request the SmsUrl. SS7, SMPP, SIP or SIPS supported currently. Defaults to SIP. * If SMPP or SS7 are used, the URL of the SMSC will be provided</td> * </tr> * <tr> * <td class='notranslate' align="left">UssdUrl</td> * <td align="left">The URL in host:port format that the DID provider should request when somebody sends a USSD message to the phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">UssdMethod</td> * <td align="left">The method that should be used to request the UssdUrl. SS7, SIP or SIPS supported currently. Defaults to SIP. * If SS7 is used, the URL of the USSD will be provided</td> * </tr> * <tr> * <td class='notranslate' align="left">FaxUrl</td> * <td align="left">The URL in host:port format that the DID provider should request when somebody sends a Fax message to the phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">FaxMethod</td> * <td align="left">The method that should be used to request the FaxUrl. SIP or SIPS supported currently. Defaults to SIP.</td> * </tr> * </tbody> * </table> * * @author [email protected] */ public final class PhoneNumberParameters { private String voiceUrl = null; private String voiceMethod = null; private boolean doVoiceCallerIdLookup = false; private String smsUrl = null; private String smsMethod = null; private String ussdUrl = null; private String ussdMethod = null; private String faxUrl = null; private String faxMethod = null; private PhoneNumberType phoneNumberType = PhoneNumberType.Global; public PhoneNumberParameters() {} /** * @param voiceUrl * @param voiceMethod * @param voiceCallerIdLookup * @param smsUrl * @param smsMethod * @param ussdUrl * @param ussdMethod * @param faxUrl * @param faxMethod */ public PhoneNumberParameters(String voiceUrl, String voiceMethod, boolean doVoiceCallerIdLookup, String smsUrl, String smsMethod, String ussdUrl, String ussdMethod, String faxUrl, String faxMethod) { this.voiceUrl = voiceUrl; this.voiceMethod = voiceMethod; this.doVoiceCallerIdLookup = doVoiceCallerIdLookup; this.smsUrl = smsUrl; this.smsMethod = smsMethod; this.ussdUrl = ussdUrl; this.ussdMethod = ussdMethod; this.faxUrl = faxUrl; this.faxMethod = faxMethod; } /** * @return the voiceUrl */ public String getVoiceUrl() { return voiceUrl; } /** * @param voiceUrl the voiceUrl to set */ public void setVoiceUrl(String voiceUrl) { this.voiceUrl = voiceUrl; } /** * @return the voiceMethod */ public String getVoiceMethod() { return voiceMethod; } /** * @param voiceMethod the voiceMethod to set */ public void setVoiceMethod(String voiceMethod) { this.voiceMethod = voiceMethod; } /** * @return the doVoiceCallerIdLookup */ public boolean isDoVoiceCallerIdLookup() { return doVoiceCallerIdLookup; } /** * @param doVoiceCallerIdLookup the doVoiceCallerIdLookup to set */ public void setDoVoiceCallerIdLookup(boolean doVoiceCallerIdLookup) { this.doVoiceCallerIdLookup = doVoiceCallerIdLookup; } /** * @return the smsUrl */ public String getSmsUrl() { return smsUrl; } /** * @param smsUrl the smsUrl to set */ public void setSmsUrl(String smsUrl) { this.smsUrl = smsUrl; } /** * @return the smsMethod */ public String getSmsMethod() { return smsMethod; } /** * @param smsMethod the smsMethod to set */ public void setSmsMethod(String smsMethod) { this.smsMethod = smsMethod; } /** * @return the ussdUrl */ public String getUssdUrl() { return ussdUrl; } /** * @param ussdUrl the ussdUrl to set */ public void setUssdUrl(String ussdUrl) { this.ussdUrl = ussdUrl; } /** * @return the ussdMethod */ public String getUssdMethod() { return ussdMethod; } /** * @param ussdMethod the ussdMethod to set */ public void setUssdMethod(String ussdMethod) { this.ussdMethod = ussdMethod; } /** * @return the faxUrl */ public String getFaxUrl() { return faxUrl; } /** * @param faxUrl the faxUrl to set */ public void setFaxUrl(String faxUrl) { this.faxUrl = faxUrl; } /** * @return the faxMethod */ public String getFaxMethod() { return faxMethod; } /** * @param faxMethod the faxMethod to set */ public void setFaxMethod(String faxMethod) { this.faxMethod = faxMethod; } /** * @return the phoneNumberType */ public PhoneNumberType getPhoneNumberType() { return phoneNumberType; } /** * @param phoneNumberType the phoneNumberType to set */ public void setPhoneNumberType(PhoneNumberType phoneNumberType) { this.phoneNumberType = phoneNumberType; } @Override public String toString() { return "PhoneNumberParameters [voiceUrl=" + voiceUrl + ", voiceMethod=" + voiceMethod + ", doVoiceCallerIdLookup=" + doVoiceCallerIdLookup + ", smsUrl=" + smsUrl + ", smsMethod=" + smsMethod + ", ussdUrl=" + ussdUrl + ", ussdMethod=" + ussdMethod + ", faxUrl=" + faxUrl + ", faxMethod=" + faxMethod + ", phoneNumberType=" + phoneNumberType + "]"; } }
7,777
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ProvisionProvider.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.provisioning.number.api/src/main/java/org/restcomm/connect/provisioning/number/api/ProvisionProvider.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.provisioning.number.api; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class ProvisionProvider { public static enum PROVIDER {VOIPINNOVATIONS,BANDWIDTH, UNKNOWN}; public static enum REQUEST_TYPE {PING, GETDIDS, ASSIGNDID, QUERYDID, RELEASEDID}; public static String voipinnovationsClass = "org.restcomm.connect.provisioning.number.vi.VoIPInnovationsNumberProvisioningManager"; public static String bandiwidthClass = "org.restcomm.connect.provisioning.number.bandwidth.BandwidthNumberProvisioningManager"; }
1,396
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ContainerConfiguration.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.provisioning.number.api/src/main/java/org/restcomm/connect/provisioning/number/api/ContainerConfiguration.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.provisioning.number.api; import java.util.List; import javax.servlet.sip.SipURI; /** * List of outbound interfaces exposed by RestComm container * * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class ContainerConfiguration { private final List<SipURI> outboundInterfaces; public ContainerConfiguration(final List<SipURI> outboundInterfaces) { this.outboundInterfaces = outboundInterfaces; } public List<SipURI> getOutboundInterfaces() { return outboundInterfaces; } }
1,379
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
PhoneNumber.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.provisioning.number.api/src/main/java/org/restcomm/connect/provisioning/number/api/PhoneNumber.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.provisioning.number.api; /** * <p> * The following properties are available for phone numbers from the US and Canada: * </p> * <table> * <thead> * <tr> * <th align="left">Property</th> * <th align="left">Description</th> * </tr> * </thead> <tbody> * <tr> * <td class='notranslate' align="left">FriendlyName</td> * <td align="left">A nicely-formatted version of the phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">PhoneNumber</td> * <td align="left">The phone number, in <a href="response#phone-numbers">E.164</a> (i.e. "+1") format.</td> * </tr> * <tr> * <td class='notranslate' align="left">Lata</td> * <td align="left">The <a href="http://en.wikipedia.org/wiki/Local_access_and_transport_area">LATA</a> of this phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">RateCenter</td> * <td align="left">The <a href="http://en.wikipedia.org/wiki/Telephone_exchange">rate center</a> of this phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">Latitude</td> * <td align="left">The latitude coordinate of this phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">Longitude</td> * <td align="left">The longitude coordinate of this phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">Region</td> * <td align="left">The two-letter state or province abbreviation of this phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">PostalCode</td> * <td align="left">The postal (zip) code of this phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">IsoCountry</td> * <td align="left">The <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO country code</a> of this phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">Capabilities</td> * <td align="left">This is a set of boolean properties that indicate whether a phone number can receive calls or messages. * Possible capabilities are <code class='notranslate'>Voice</code>, <code class='notranslate'>SMS</code>, and * <code class='notranslate'>MMS</code> with each having a value of either <code class='notranslate'>true</code> or * <code class='notranslate'>false</code>.</td> * </tr> * </tbody> * </table> * * <p> * The following properties are available for phone numbers outside the US and Canada: * </p> * * <table> * <thead> * <tr> * <th align="left">Property</th> * <th align="left">Description</th> * </tr> * </thead> <tbody> * <tr> * <td class='notranslate' align="left">FriendlyName</td> * <td align="left">A nicely-formatted version of the phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">PhoneNumber</td> * <td align="left">The phone number, in <a href="response#phone-numbers">E.164</a> (i.e. "+44") format.</td> * </tr> * <tr> * <td class='notranslate' align="left">IsoCountry</td> * <td align="left">The <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO country code</a> of this phone number.</td> * </tr> * <tr> * <td class='notranslate' align="left">Capabilities</td> * <td align="left">This is a set of boolean properties that indicate whether a phone number can receive calls or messages. * Possible capabilities are <code class='notranslate'>Voice</code>, <code class='notranslate'>SMS</code>, and * <code class='notranslate'>MMS</code> with each having a value of either <code class='notranslate'>true</code> or * <code class='notranslate'>false</code>.</td> * </tr> * </tbody> * </table> * * @author [email protected] */ public final class PhoneNumber { private String friendlyName; private String phoneNumber; private Integer lata; private String rateCenter; private Double latitude; private Double longitude; private String region; private Integer postalCode; private String isoCountry; private String cost; // Capabilities private Boolean voiceCapable; private Boolean smsCapable; private Boolean mmsCapable; private Boolean faxCapable; private Boolean ussdCapable; public PhoneNumber(final String friendlyName, final String phoneNumber, final Integer lata, final String rateCenter, final Double latitude, final Double longitude, final String region, final Integer postalCode, final String isoCountry, final String cost) { this(friendlyName, phoneNumber, lata, rateCenter, latitude, longitude, region, postalCode, isoCountry, cost, null, null, null, null, null); } public PhoneNumber(final String friendlyName, final String phoneNumber, final Integer lata, final String rateCenter, final Double latitude, final Double longitude, final String region, final Integer postalCode, final String isoCountry, final String cost, final Boolean voiceCapable, final Boolean smsCapable, final Boolean mmsCapable, final Boolean faxCapable, final Boolean ussdCapable) { super(); this.friendlyName = friendlyName; this.phoneNumber = phoneNumber; this.lata = lata; this.rateCenter = rateCenter; this.latitude = latitude; this.longitude = longitude; this.region = region; this.postalCode = postalCode; this.isoCountry = isoCountry; this.cost = cost; this.voiceCapable = voiceCapable; this.smsCapable = smsCapable; this.mmsCapable = mmsCapable; this.faxCapable = faxCapable; this.ussdCapable = ussdCapable; } /** * @return the friendlyName */ public String getFriendlyName() { return friendlyName; } /** * @param friendlyName the friendlyName to set */ public void setFriendlyName(String friendlyName) { this.friendlyName = friendlyName; } /** * @return the phoneNumber */ public String getPhoneNumber() { return phoneNumber; } /** * @param phoneNumber the phoneNumber to set */ public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } /** * @return the lata */ public Integer getLata() { return lata; } /** * @param lata the lata to set */ public void setLata(Integer lata) { this.lata = lata; } /** * @return the rateCenter */ public String getRateCenter() { return rateCenter; } /** * @param rateCenter the rateCenter to set */ public void setRateCenter(String rateCenter) { this.rateCenter = rateCenter; } /** * @return the latitude */ public Double getLatitude() { return latitude; } /** * @param latitude the latitude to set */ public void setLatitude(Double latitude) { this.latitude = latitude; } /** * @return the longitude */ public Double getLongitude() { return longitude; } /** * @param longitude the longitude to set */ public void setLongitude(Double longitude) { this.longitude = longitude; } /** * @return the region */ public String getRegion() { return region; } /** * @param region the region to set */ public void setRegion(String region) { this.region = region; } /** * @return the postalCode */ public Integer getPostalCode() { return postalCode; } /** * @param postalCode the postalCode to set */ public void setPostalCode(Integer postalCode) { this.postalCode = postalCode; } /** * @return the isoCountry */ public String getIsoCountry() { return isoCountry; } /** * @param isoCountry the isoCountry to set */ public void setIsoCountry(String isoCountry) { this.isoCountry = isoCountry; } /** * @return the phone number cost */ public String getCost() { return cost; } /** * @param isoCountry the isoCountry to set */ public void setCost(String cost) { this.cost = cost; } /** * @return the voiceCapable */ public Boolean isVoiceCapable() { return voiceCapable; } /** * @param voiceCapable the voiceCapable to set */ public void setVoiceCapable(Boolean voiceCapable) { this.voiceCapable = voiceCapable; } /** * @return the smsCapable */ public Boolean isSmsCapable() { return smsCapable; } /** * @param smsCapable the smsCapable to set */ public void setSmsCapable(Boolean smsCapable) { this.smsCapable = smsCapable; } /** * @return the mmsCapable */ public Boolean isMmsCapable() { return mmsCapable; } /** * @param mmsCapable the mmsCapable to set */ public void setMmsCapable(Boolean mmsCapable) { this.mmsCapable = mmsCapable; } /** * @return the faxCapable */ public Boolean isFaxCapable() { return faxCapable; } /** * @param faxCapable the faxCapable to set */ public void setFaxCapable(Boolean faxCapable) { this.faxCapable = faxCapable; } /** * @return the ussdCapable */ public Boolean isUssdCapable() { return ussdCapable; } /** * @param ussdCapable the ussdCapable to set */ public void setUssdCapable(Boolean ussdCapable) { this.ussdCapable = ussdCapable; } }
10,445
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
PhoneNumberType.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.provisioning.number.api/src/main/java/org/restcomm/connect/provisioning/number/api/PhoneNumberType.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.provisioning.number.api; /** * The differnt types of Phone Numbers : * * <ul> * <li>Global : International numbers</li> * <li>Local : US Local numbers</li> * <li>TollFree : Toll Free numbers</li> * <li>Mobile : mobile numbers</li> * </ul> * * @author [email protected] * */ public enum PhoneNumberType { Global, Local, TollFree, Mobile }
1,209
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
PhoneNumberProvisioningManagerProvider.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.provisioning.number.api/src/main/java/org/restcomm/connect/provisioning/number/api/PhoneNumberProvisioningManagerProvider.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.provisioning.number.api; import org.apache.commons.configuration.Configuration; import org.restcomm.connect.commons.loader.ObjectFactory; import org.restcomm.connect.commons.loader.ObjectInstantiationException; import javax.servlet.ServletContext; import javax.servlet.sip.SipServlet; import javax.servlet.sip.SipURI; import java.util.List; /** * A single place to create the number provisioning manager * * @author [email protected] - Orestis Tsakiridis */ public class PhoneNumberProvisioningManagerProvider { Configuration configuration; ServletContext context; public PhoneNumberProvisioningManagerProvider(Configuration configuration, ServletContext context) { this.configuration = configuration; this.context = context; } private List<SipURI> getOutboundInterfaces() { final List<SipURI> uris = (List<SipURI>) context.getAttribute(SipServlet.OUTBOUND_INTERFACES); return uris; } public PhoneNumberProvisioningManager create() { final String phoneNumberProvisioningManagerClass = configuration.getString("phone-number-provisioning[@class]"); Configuration phoneNumberProvisioningConfiguration = configuration.subset("phone-number-provisioning"); Configuration telestaxProxyConfiguration = configuration.subset("runtime-settings").subset("telestax-proxy"); PhoneNumberProvisioningManager phoneNumberProvisioningManager; try { phoneNumberProvisioningManager = (PhoneNumberProvisioningManager) new ObjectFactory(getClass().getClassLoader()) .getObjectInstance(phoneNumberProvisioningManagerClass); ContainerConfiguration containerConfiguration = new ContainerConfiguration(getOutboundInterfaces()); phoneNumberProvisioningManager.init(phoneNumberProvisioningConfiguration, telestaxProxyConfiguration, containerConfiguration); } catch (ObjectInstantiationException e) { throw new RuntimeException(e); } return phoneNumberProvisioningManager; } /** * Tries to retrieve the manager from the Servlet context. If it's not there it creates is, stores it * in the context and also returns it. * * @param context * @return */ public PhoneNumberProvisioningManager get() { PhoneNumberProvisioningManager manager = (PhoneNumberProvisioningManager) context.getAttribute("PhoneNumberProvisioningManager"); if (manager != null) // ok, it's already in the context. Return it return manager; manager = create(); // put it into the context for next time that is requested context.setAttribute("PhoneNumberProvisioningManager", manager); return manager; } }
3,594
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
UssdStreamEventTest.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/test/java/org/restcomm/connect/telephony/api/events/UssdStreamEventTest.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2018, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it andor modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but OUT ANY WARRANTY; out even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along this program. If not, see <http:www.gnu.orglicenses> */ package org.restcomm.connect.telephony.api.events; import java.util.UUID; import org.junit.Test; import static org.junit.Assert.assertNotNull; /** * @author [email protected] (Laslo Horvat) */ public class UssdStreamEventTest { @Test public void buildUssdStreamEventTest() { UssdStreamEvent expected = UssdStreamEvent.builder() .setTo(UUID.randomUUID().toString()) .setFrom(UUID.randomUUID().toString()) .setStatus(UssdStreamEvent.Status.completed) .setDirection(UssdStreamEvent.Direction.inbound) .build(); assertNotNull(expected); } }
1,427
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
DigestAuthenticationTest.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/test/java/org/restcomm/connect/telephony/api/util/DigestAuthenticationTest.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2018, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package org.restcomm.connect.telephony.api.util; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.XMLConfiguration; import org.apache.log4j.Logger; import org.junit.Test; import org.restcomm.connect.commons.configuration.RestcommConfiguration; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.commons.util.DigestAuthentication; import org.restcomm.connect.dao.AccountsDao; import org.restcomm.connect.dao.ClientsDao; import org.restcomm.connect.dao.DaoManager; import org.restcomm.connect.dao.entities.Account; import org.restcomm.connect.dao.entities.Client; import java.net.URI; import java.net.URL; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class DigestAuthenticationTest { private static Logger logger = Logger.getLogger(DigestAuthenticationTest.class); private String client = "alice0000000"; private String domain = "org0000000.restcomm.com"; private String password = "1234"; //INSERT INTO "restcomm_organizations" VALUES('ORc241349fa4c0442bb8464bce8bb203e3', 'org0000000.restcomm.com', '2017-04-19 00:00:00.000000000','2017-04-19 00:00:00.000000000', 'active'); //INSERT INTO "restcomm_clients" VALUES('CL21d7a04619d84015ab1e1feceaa1893b','2017-04-19 00:00:00.000000000','2017-04-19 00:00:00.000000000','ACca5c323916cb43ec99d0c93eb0b824c4','2012-04-24','alice0000000','alice0000000','9b11a2924d0881aca84f9db97f834d99',1,NULL,'POST',NULL,'POST',NULL,'/2012-04-24/Accounts/ACca5c323916cb43ec99d0c93eb0b824c4/Clients/CL21d7a04619d84015ab1e1feceaa1893b',NULL); private DaoManager daoManager = mock(DaoManager.class); private ClientsDao clientsDao = mock(ClientsDao.class); private AccountsDao accountsDao = mock(AccountsDao.class); private Account account = mock(Account.class); private Sid orgSid = Sid.generate(Sid.Type.ORGANIZATION); private String proxyAuthHeader = "Digest username=\"alice0000000\",realm=\"org0000000.restcomm.com\",cnonce=\"6b8b4567\",nc=00000001,qop=auth,uri=\"sip:192.168.1.204:5080\",nonce=\"34316531323833622d313539352d343\",response=\"9b22e97f4715c937cadf167bb9b02cbf\",algorithm=MD5"; @Test public void testAuth(){ RestcommConfiguration.createOnce(prepareConfiguration()); String hashedPass = DigestAuthentication.HA1(client, domain, password, "MD5"); Sid clientSid = Sid.generate(Sid.Type.CLIENT); Sid accountSid = Sid.generate(Sid.Type.ACCOUNT); Client.Builder builder = Client.builder(); builder.setSid(clientSid); builder.setAccountSid(accountSid); builder.setApiVersion("2012-04-24"); builder.setFriendlyName(client); builder.setLogin(client); builder.setPassword(client, password, domain, "MD5"); builder.setStatus(1); builder.setPasswordAlgorithm("MD5"); builder.setUri(URI.create("/2012-04-24/Accounts/ACca5c323916cb43ec99d0c93eb0b824c4/Clients/CL21d7a04619d84015ab1e1feceaa1893b")); Client aliceClient = builder.build(); when(daoManager.getClientsDao()).thenReturn(clientsDao); when(clientsDao.getClient(client, orgSid)).thenReturn(aliceClient); when(daoManager.getAccountsDao()).thenReturn(accountsDao); when(accountsDao.getAccount(accountSid)).thenReturn(account); when(account.getStatus()).thenReturn(Account.Status.ACTIVE); assertEquals("9b11a2924d0881aca84f9db97f834d99", hashedPass); assertTrue(CallControlHelper.permitted(proxyAuthHeader, "INVITE", daoManager, orgSid)); } private Configuration prepareConfiguration() { Configuration xml = null; try { URL restcommXml = this.getClass().getClassLoader().getResource("restcomm.xml"); XMLConfiguration xmlConfiguration = new XMLConfiguration(); xmlConfiguration.setDelimiterParsingDisabled(true); xmlConfiguration.setAttributeSplittingDisabled(true); xmlConfiguration.load(restcommXml); xml = xmlConfiguration; } catch (Exception e) { logger.error("Exception: "+e); } return xml; } }
5,094
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CallControlHelperTest.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/test/java/org/restcomm/connect/telephony/api/util/CallControlHelperTest.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api.util; import org.junit.Test; import org.mockito.Mockito; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.dao.AccountsDao; import org.restcomm.connect.dao.ClientsDao; import org.restcomm.connect.dao.DaoManager; import org.restcomm.connect.dao.entities.Account; import org.restcomm.connect.dao.entities.Client; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; public class CallControlHelperTest { public CallControlHelperTest() { } @Test public void testPermitted() { String auth = "Digest username=\"alice\",realm=\"127.0.0.1\",nonce=\"64353235316666342d306434392d343\",uri=\"sip:127.0.0.1:5080\",response=\"31927ed6bc4b0c3796fd2240f8315fc7\",cnonce=\"416ba85980000000\",nc=00000001,qop=auth,algorithm=MD5"; String method = "REGISTER"; Sid organization = Sid.generate(Sid.Type.ORGANIZATION); Sid accountSid = Sid.generate(Sid.Type.ACCOUNT); Account.Builder builder = Account.builder(); builder.setSid(accountSid); builder.setStatus(Account.Status.ACTIVE); Account account = builder.build(); Client.Builder builder2 = Client.builder(); builder2.setSid(Sid.generate(Sid.Type.CLIENT)); builder2.setAccountSid(accountSid); //use no algorithm to skip conf mocking builder2.setPassword("alice", "2ea216cdda59f04ef9ba21fead1bca10", "127.0.0.1", ""); builder2.setPasswordAlgorithm("MD5"); builder2.setStatus(Client.ENABLED); Client client = builder2.build(); DaoManager manager = Mockito.mock(DaoManager.class); ClientsDao clients = Mockito.mock(ClientsDao.class); AccountsDao accounts = Mockito.mock(AccountsDao.class); when(manager.getClientsDao()).thenReturn(clients); when(clients.getClient("alice", organization)).thenReturn(client); when(manager.getAccountsDao()).thenReturn(accounts); when(accounts.getAccount(accountSid)).thenReturn(account); boolean permitted = CallControlHelper.permitted(auth, method, manager, organization); assertTrue(permitted); } @Test public void testPermittedNoAlgorithm() { String auth = "Digest username=\"alice\",realm=\"127.0.0.1\",nonce=\"64353235316666342d306434392d343\",uri=\"sip:127.0.0.1:5080\",response=\"31927ed6bc4b0c3796fd2240f8315fc7\",cnonce=\"416ba85980000000\",nc=00000001,qop=auth"; String method = "REGISTER"; Sid organization = Sid.generate(Sid.Type.ORGANIZATION); Sid accountSid = Sid.generate(Sid.Type.ACCOUNT); Account.Builder builder = Account.builder(); builder.setSid(accountSid); builder.setStatus(Account.Status.ACTIVE); Account account = builder.build(); Client.Builder builder2 = Client.builder(); builder2.setSid(Sid.generate(Sid.Type.CLIENT)); builder2.setAccountSid(accountSid); //use no algorithm to skip conf mocking builder2.setPassword("alice", "2ea216cdda59f04ef9ba21fead1bca10", "127.0.0.1", ""); builder2.setPasswordAlgorithm("MD5"); builder2.setStatus(Client.ENABLED); Client client = builder2.build(); DaoManager manager = Mockito.mock(DaoManager.class); ClientsDao clients = Mockito.mock(ClientsDao.class); AccountsDao accounts = Mockito.mock(AccountsDao.class); when(manager.getClientsDao()).thenReturn(clients); when(clients.getClient("alice", organization)).thenReturn(client); when(manager.getAccountsDao()).thenReturn(accounts); when(accounts.getAccount(accountSid)).thenReturn(account); boolean permitted = CallControlHelper.permitted(auth, method, manager, organization); assertTrue(permitted); } }
4,630
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ConferenceResponse.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/ConferenceResponse.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.patterns.StandardResponse; /** * @author [email protected] (Thomas Quintana) */ public final class ConferenceResponse<T> extends StandardResponse<T> { public ConferenceResponse(final T object) { super(object); } public ConferenceResponse(final Throwable cause) { super(cause); } public ConferenceResponse(final Throwable cause, final String message) { super(cause, message); } }
1,332
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
SwitchProxy.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/SwitchProxy.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ @Immutable public class SwitchProxy { private Sid sid; public SwitchProxy(Sid sid) { super(); this.sid = sid; } public Sid getSid(){ return sid; } }
1,240
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
RemoveParticipant.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/RemoveParticipant.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import akka.actor.ActorRef; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class RemoveParticipant { private final ActorRef call; public RemoveParticipant(final ActorRef call) { super(); this.call = call; } public ActorRef call() { return call; } }
1,264
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
UpdateCallScript.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/UpdateCallScript.java
package org.restcomm.connect.telephony.api; import java.net.URI; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; import akka.actor.ActorRef; @Immutable public final class UpdateCallScript { private final ActorRef call; private final Sid account; private final String version; private final URI url; private final String method; private final URI fallbackUrl; private final String fallbackMethod; private final URI callback; private final String callbackMethod; private Boolean moveConnectedCallLeg; public UpdateCallScript(ActorRef call, Sid account, String version, URI url, String method, URI fallbackUrl, String fallbackMethod, URI callback, String callbackMethod, Boolean moveConnectedCallLeg) { super(); this.call = call; this.account = account; this.version = version; this.url = url; this.method = method; this.fallbackUrl = fallbackUrl; this.fallbackMethod = fallbackMethod; this.callback = callback; this.callbackMethod = callbackMethod; this.moveConnectedCallLeg = moveConnectedCallLeg; } public ActorRef call() { return call; } public Sid account() { return account; } public String version() { return version; } public URI url() { return url; } public String method() { return method; } public URI fallbackUrl() { return fallbackUrl; } public String fallbackMethod() { return fallbackMethod; } public URI callback() { return callback; } public String callbackMethod() { return callbackMethod; } public Boolean moveConnecteCallLeg() { return moveConnectedCallLeg; } }
1,871
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
RegisterGateway.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/RegisterGateway.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.dao.entities.Gateway; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class RegisterGateway { private final Gateway gateway; public RegisterGateway(final Gateway gateway) { this.gateway = gateway; } public Gateway getGateway() { return gateway; } }
1,202
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
UserRegistration.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/UserRegistration.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.dao.Sid; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class UserRegistration { private final String user; private final String address; private final Boolean registered; private final Sid organizationsSid; public UserRegistration(final String user, final String address, final Boolean registered, final Sid organizationsSid) { this.user = user; this.address = address; this.registered = registered; this.organizationsSid = organizationsSid; } public String getUser() { return user; } public String getAddress() { return address; } public Boolean getRegistered() { return registered; } public Sid getOrganizationsSid() { return organizationsSid; } public String getUserPlusOrganizationsSid() { return user+":"+organizationsSid; } }
1,906
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
DestroyCall.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/DestroyCall.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import akka.actor.ActorRef; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class DestroyCall { private final ActorRef call; public DestroyCall(final ActorRef call) { super(); this.call = call; } public ActorRef call() { return call; } }
1,252
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CallInfoStreamEvent.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CallInfoStreamEvent.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2017, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it andor modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but OUT ANY WARRANTY; out even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along this program. If not, see <http:www.gnu.orglicenses> */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.stream.StreamEvent; /** * @author [email protected] (Oleg Agafonov) */ public class CallInfoStreamEvent implements StreamEvent { private final CallInfo callInfo; public CallInfoStreamEvent(CallInfo callInfo) { this.callInfo = callInfo; } public CallInfo getCallInfo() { return callInfo; } }
1,211
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
DestroyWaitUrlConfMediaGroup.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/DestroyWaitUrlConfMediaGroup.java
/** * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import akka.actor.ActorRef; /** * @author Amit Bhayani * */ @Immutable public class DestroyWaitUrlConfMediaGroup { private final ActorRef waitUrlConfMediaGroup; public DestroyWaitUrlConfMediaGroup(final ActorRef waitUrlConfMediaGroup) { super(); this.waitUrlConfMediaGroup = waitUrlConfMediaGroup; } public ActorRef getWaitUrlConfMediaGroup() { return waitUrlConfMediaGroup; } }
558
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
Hangup.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/Hangup.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.dao.entities.CallDetailRecord; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class Hangup { private String message; private Integer sipResponse; private Sid requestingAccountSid; private CallDetailRecord callDetailRecord; public Hangup() { super(); } public Hangup(final String message, final Sid requestingAccountSid, final CallDetailRecord callDetailRecord) { this.message = message; this.requestingAccountSid = requestingAccountSid; this.callDetailRecord = callDetailRecord; } public Hangup(final String message, final Integer sipResponse) { this.message = message; this.sipResponse = sipResponse; } public Hangup(final String message) { this.message = message; } public Hangup(final Integer sipResponse) { this.sipResponse = sipResponse; } public String getMessage() { return message; } public Integer getSipResponse() { return sipResponse; } /** * @return accountSid for account initiating this hangup request. */ public Sid getRequestingAccountSid() { return requestingAccountSid; } /** * @return cdr for the call to be terminated */ public CallDetailRecord getCallDetailRecord() { return callDetailRecord; } @Override public String toString() { return "Hangup [message=" + message + ", sipResponse=" + sipResponse + ", requestingAccountSid=" + requestingAccountSid + ", callDetailRecord=" + callDetailRecord + "]"; } }
2,626
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CreateCall.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CreateCall.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.commons.telephony.CreateCallType; import org.restcomm.connect.dao.entities.MediaAttributes; import org.restcomm.connect.extension.api.IExtensionCreateCallRequest; import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * @author [email protected] (Thomas Quintana) * @author [email protected] * @author [email protected] */ @Immutable public final class CreateCall implements IExtensionCreateCallRequest{ private final String from; private final String to; private String username; private String password; private final boolean isFromApi; private final int timeout; private final CreateCallType callType; private final Sid accountId; private boolean createCDR = true; private final Sid parentCallSid; private final URI statusCallbackUrl; private final String statusCallbackMethod; private final List<String> statusCallbackEvent; private String outboundProxy; private Map<String,ArrayList<String>> outboundProxyHeaders; private boolean allowed = true; private final MediaAttributes mediaAttributes; private String customHeaders; //Used for IExtensionCreateCallRequest public CreateCall(final String from, final String to, final String username, final String password, final boolean isFromApi, final int timeout, final CreateCallType type, final Sid accountId, final Sid parentCallSid, final URI statusCallbackUrl, final String statusCallbackMethod, final List<String> statusCallbackEvent) { this(from, to, username, password, isFromApi, timeout, type, accountId, parentCallSid, statusCallbackUrl, statusCallbackMethod, statusCallbackEvent, "", null, new MediaAttributes(), null); } //Used to create CreateCall objects (CallsEndpoint, UssdPushEndpoint, VI) public CreateCall(final String from, final String to, final String username, final String password, final boolean isFromApi, final int timeout, final CreateCallType type, final Sid accountId, final Sid parentCallSid, final URI statusCallbackUrl, final String statusCallbackMethod, final List<String> statusCallbackEvent, final String customHeaders) { this(from, to, username, password, isFromApi, timeout, type, accountId, parentCallSid, statusCallbackUrl, statusCallbackMethod, statusCallbackEvent, "", null, new MediaAttributes(), customHeaders); } //Used to create CreateCall objects with MediaAttributes (VI) public CreateCall(final String from, final String to, final String username, final String password, final boolean isFromApi, final int timeout, final CreateCallType type, final Sid accountId, final Sid parentCallSid, final URI statusCallbackUrl, final String statusCallbackMethod, final List<String> statusCallbackEvent, final MediaAttributes mediaAttributes, final String customHeaders) { this(from, to, username, password, isFromApi, timeout, type, accountId, parentCallSid, statusCallbackUrl, statusCallbackMethod, statusCallbackEvent, "", null, mediaAttributes, customHeaders); } public CreateCall(final String from, final String to, final String username, final String password, final boolean isFromApi, final int timeout, final CreateCallType type, final Sid accountId, final Sid parentCallSid, final URI statusCallbackUrl, final String statusCallbackMethod, final List<String> statusCallbackEvent, final String outboundProxy, final Map<String,ArrayList<String>> outboundProxyHeaders, final MediaAttributes mediaAttributes, final String customHeaders) { super(); this.from = from; this.to = to; this.username = username; this.password = password; this.isFromApi = isFromApi; this.timeout = timeout; this.callType = type; this.accountId = accountId; this.parentCallSid = parentCallSid; this.statusCallbackUrl = statusCallbackUrl; this.statusCallbackMethod = statusCallbackMethod; this.statusCallbackEvent = statusCallbackEvent; this.outboundProxy = outboundProxy; this.outboundProxyHeaders = outboundProxyHeaders; this.mediaAttributes = mediaAttributes; this.customHeaders = customHeaders; } public String from() { return from; } public String to() { return to; } public int timeout() { return timeout; } public CreateCallType type() { return callType; } public Sid accountId() { return accountId; } public String username() { return username; } public String setUsername() { return username; } public String password() { return password; } public String setPassword() { return password; } public boolean isCreateCDR() { return createCDR; } public void setCreateCDR(boolean createCDR) { this.createCDR = createCDR; } public Sid parentCallSid() { return parentCallSid; } public URI statusCallback() { return statusCallbackUrl; } public String statusCallbackMethod() { return statusCallbackMethod; } public List<String> statusCallbackEvent() { return statusCallbackEvent; } /** * IExtensionCreateCallRequest * @return the outboundProxy */ public String getOutboundProxy() { return outboundProxy; } /** * IExtensionCreateCallRequest * @param outboundProxy the outboundProxy to set */ public void setOutboundProxy(String outboundProxy) { this.outboundProxy = outboundProxy; } /** * IExtensionCreateCallRequest * the outboundProxyUsername is a facade to the username field * @return the outboundProxyUsername */ public String getOutboundProxyUsername() { return username; } /** * IExtensionCreateCallRequest * the outboundProxyUsername is a facade to the username field * @param outboundProxyUsername the outboundProxyUsername to set */ public void setOutboundProxyUsername(String outboundProxyUsername) { this.username = outboundProxyUsername; } /** * IExtensionCreateCallRequest * the outboundProxyPassword is a facade to the password field * @return the outboundProxyPassword */ public String getOutboundProxyPassword() { return password; } /** * IExtensionCreateCallRequest * the outboundProxyPassword is a facade to the password field * @param outboundProxyPassword the outboundProxyPassword to set */ public void setOutboundProxyPassword(String outboundProxyPassword) { this.password = outboundProxyPassword; } /** * IExtensionCreateCallRequest * @return the outboundProxyHeaders */ public Map<String,ArrayList<String>> getOutboundProxyHeaders() { return outboundProxyHeaders; } /** * IExtensionCreateCallRequest * @param outboundProxyHeaders the outboundProxyHeaders to set */ public void setOutboundProxyHeaders(Map<String,ArrayList<String>> outboundProxyHeaders) { this.outboundProxyHeaders = outboundProxyHeaders; } /** * IExtensionCreateCallRequest * @return from address */ public String getFrom() { return from; } /** * IExtensionCreateCallRequest * @return to address */ public String getTo() { return to; } /** * IExtensionCreateCallRequest * @return accountId */ public Sid getAccountId() { return accountId; } /** * IExtensionCreateCallRequest * @return boolean fromApi */ @Override public boolean isFromApi() { return isFromApi; } /** * IExtensionCreateCallRequest * @return boolean is child call */ @Override public boolean isParentCallSidExists() { return parentCallSid != null; } /** * IExtensionCreateCallRequest * @return the CreateCallType */ @Override public CreateCallType getType() { return callType; } /** * IExtensionCreateCallRequest * @return the CreateCallType */ @Override public String getRequestURI() { return this.to; } /** * IExtensionRequest * @return accountSid */ @Override public String getAccountSid() { return this.accountId.toString(); } /** * IExtensionRequest * @return is allowed */ @Override public boolean isAllowed() { return this.allowed; } /** * IExtensionRequest * @param allowed */ @Override public void setAllowed(boolean allowed) { this.allowed = allowed; } @Override public String toString() { return "From: "+from+", To: "+to+", Type: "+callType.name()+", AccountId: "+accountId+", isFromApi: "+isFromApi+", parentCallSidExists: "+isParentCallSidExists(); } public MediaAttributes mediaAttributes() { return mediaAttributes; } public String getCustomHeaders () { return customHeaders; } }
10,381
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
StartBridge.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/StartBridge.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author Henrique Rosa ([email protected]) * */ @Immutable public final class StartBridge { public StartBridge() { super(); } }
1,199
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
FeatureAccessRequest.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/FeatureAccessRequest.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.extension.api.IExtensionFeatureAccessRequest; public class FeatureAccessRequest implements IExtensionFeatureAccessRequest { public enum Feature { OUTBOUND_VOICE("outbound-voice"), INBOUND_VOICE("inbound-voice"), OUTBOUND_SMS("outbound-sms"), INBOUND_SMS("inbound-sms"), ASR("asr"), OUTBOUND_USSD("outbound-ussd"), INBOUND_USSD("inbound_ussd"); private final String text; private Feature(final String text) { this.text = text; } @Override public String toString() { return text; } } private Feature feature; private Sid accountSid; private String destinationNumber; public FeatureAccessRequest () {} public FeatureAccessRequest (Feature feature, Sid accountSid) { this.feature = feature; this.accountSid = accountSid; } public FeatureAccessRequest (Feature feature, Sid accountSid, String destinationNumber) { this.feature = feature; this.accountSid = accountSid; this.destinationNumber = destinationNumber; } public Feature getFeature () { return feature; } public void setFeature (Feature feature) { this.feature = feature; } public Sid getAccountId () { return accountSid; } @Override public String getAccountSid () { return accountSid.toString(); } @Override public boolean isAllowed () { return false; } @Override public void setAllowed (boolean allowed) { } public void setAccountSid (Sid accountSid) { this.accountSid = accountSid; } public String getDestinationNumber () { return destinationNumber; } public void setDestinationNumber (String destinationNumber) { this.destinationNumber = destinationNumber; } }
2,889
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GetCallInfo.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/GetCallInfo.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class GetCallInfo { public GetCallInfo() { super(); } }
1,090
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GetLiveCalls.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/GetLiveCalls.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class GetLiveCalls { public GetLiveCalls() {} }
1,093
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
JoinCalls.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/JoinCalls.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import akka.actor.ActorRef; /** * @author Henrique Rosa ([email protected]) * */ @Immutable public final class JoinCalls { private final ActorRef inboundCall; private final ActorRef outboundCall; private final Boolean record; public JoinCalls(final ActorRef inboundCall, final ActorRef outboundCall, final boolean record) { this.inboundCall = inboundCall; this.outboundCall = outboundCall; this.record = record; } public JoinCalls(final ActorRef inboundCall, final ActorRef outboundCall) { this(inboundCall, outboundCall, false); } public ActorRef getInboundCall() { return inboundCall; } public ActorRef getOutboundCall() { return outboundCall; } public boolean shouldRecord() { return this.record; } }
1,867
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
MonitoringServiceResponse.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/MonitoringServiceResponse.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; import java.net.URI; import java.util.List; import java.util.Map; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.dao.entities.InstanceId; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class MonitoringServiceResponse { private final InstanceId instanceId; private final List<CallInfo> callDetailsList; private final Map<String, Integer> countersMap; private final Map<String, Double> durationMap; private final boolean withCallDetailsList; private final URI callDetailsUrl; private final Sid accountSid; public MonitoringServiceResponse(final InstanceId instanceId, final List<CallInfo> callDetailsList, final Map<String, Integer> countersMap, final Map<String, Double> durationMap, final boolean withCallDetailsList, final URI callDetailsUrl, final Sid accountSid) { super(); this.instanceId = instanceId; this.callDetailsList = callDetailsList; this.countersMap = countersMap; this.durationMap = durationMap; this.withCallDetailsList = withCallDetailsList; this.callDetailsUrl = callDetailsUrl; this.accountSid = accountSid; } public List<CallInfo> getCallDetailsList() { return callDetailsList; } public Map<String, Integer> getCountersMap() { return countersMap; } public InstanceId getInstanceId() { return instanceId; } public Map<String, Double> getDurationMap() { return durationMap; } public URI getCallDetailsUrl () { return callDetailsUrl; } public boolean isWithCallDetailsList () { return withCallDetailsList; } public Sid getAccountSid () { return accountSid; } }
2,782
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CallHoldStateChange.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CallHoldStateChange.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class CallHoldStateChange { public static enum State { ONHOLD(), OFFHOLD(); }; private final State state; public CallHoldStateChange(final State state) { super(); this.state = state; } public State state() { return state; } }
1,306
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GetCall.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/GetCall.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class GetCall { private String identifier; public GetCall(final String identifier) { super(); this.identifier= identifier; } public String getIdentifier() { return identifier; } }
1,243
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CallManagerResponse.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CallManagerResponse.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.patterns.StandardResponse; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class CallManagerResponse<T> extends StandardResponse<T> { private CreateCall createCall; public CallManagerResponse(final T object) { super(object); } public CallManagerResponse(final Throwable cause) { super(cause); } public CallManagerResponse(final Throwable cause, final String message) { super(cause, message); } public CallManagerResponse(final Throwable cause, final CreateCall createCall) { super(cause); this.createCall = createCall; } public CreateCall getCreateCall() { return createCall; } }
1,681
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CallResponse.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CallResponse.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.patterns.StandardResponse; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class CallResponse<T> extends StandardResponse<T> { public CallResponse(T object) { super(object); } public CallResponse(final Throwable cause) { super(cause); } public CallResponse(final Throwable cause, final String message) { super(cause, message); } }
1,384
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
AudioPlaybackCompleted.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/AudioPlaybackCompleted.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class AudioPlaybackCompleted { public AudioPlaybackCompleted() { super(); } }
1,109
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ConferenceInfo.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/ConferenceInfo.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import java.util.List; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; import akka.actor.ActorRef; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class ConferenceInfo { private final Sid sid; private final List<ActorRef> participants; private final ConferenceStateChanged.State state; private final String name; private final boolean moderatorPresent; private final int globalParticipants; public ConferenceInfo(final Sid sid, final List<ActorRef> participants, final ConferenceStateChanged.State state, final String name, final boolean moderatorPresent, final int globalParticipants) { super(); this.sid = sid; this.participants = participants; this.state = state; this.name = name; this.moderatorPresent = moderatorPresent; this.globalParticipants = globalParticipants; } public List<ActorRef> participants() { return participants; } public ConferenceStateChanged.State state() { return state; } public String name() { return name; } public Sid sid() { return sid; } public boolean isModeratorPresent() { return moderatorPresent; } public int globalParticipants(){ return globalParticipants; } @Override public String toString() { return "ConferenceInfo [sid=" + sid + ", participants=" + participants + ", state=" + state + ", name=" + name + ", moderatorPresent=" + moderatorPresent + ", globalParticipants=" + globalParticipants + "]"; } }
2,530
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
BridgeManagerResponse.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/BridgeManagerResponse.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.patterns.StandardResponse; import akka.actor.ActorRef; /** * @author Henrique Rosa ([email protected]) * */ @Immutable public final class BridgeManagerResponse extends StandardResponse<ActorRef> { public BridgeManagerResponse(ActorRef object) { super(object); } public BridgeManagerResponse(final Throwable cause) { super(cause); } public BridgeManagerResponse(final Throwable cause, final String message) { super(cause, message); } }
1,572
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GetCallObservers.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/GetCallObservers.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class GetCallObservers { public GetCallObservers() { super(); } }
1,099
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ConferenceModeratorPresent.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/ConferenceModeratorPresent.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * <p> * Tell's {@link Conference} that moderator has not yet joined and it should Transition from * {@link ConferenceStateChanged#State.RUNNING} to {@link ConferenceStateChanged#State.RUNNING_MODERATOR_PRESENT} or from {@link ConferenceStateChanged#State.RUNNING_MODERATOR_ABSENT} to * {@link ConferenceStateChanged#State.RUNNING_MODERATOR_PRESENT} * </p> * * @author Amit Bhayani * @author Maria Farooq */ @Immutable public class ConferenceModeratorPresent { private final Boolean beep; /** * @param beep - If a beep will be played in that case we don't need to send EndSignal(StopMediaGroup) * to media-server as media-server will automatically stop beep when it will receive * play command for beep. If a beep wont be played, then conference need to send * EndSignal(StopMediaGroup) to media-server to stop ongoing music-on-hold. * https://github.com/RestComm/Restcomm-Connect/issues/2024 * this is applicable only for restcomm mediaserver */ public ConferenceModeratorPresent(final Boolean beep) { super(); this.beep = beep; } public Boolean beep() { return beep; } }
2,101
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ConferenceCenterResponse.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/ConferenceCenterResponse.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import akka.actor.ActorRef; import org.restcomm.connect.commons.patterns.StandardResponse; /** * @author [email protected] (Thomas Quintana) */ public final class ConferenceCenterResponse extends StandardResponse<ActorRef> { public ConferenceCenterResponse(final ActorRef object) { super(object); } public ConferenceCenterResponse(final Throwable cause) { super(cause); } public ConferenceCenterResponse(final Throwable cause, final String message) { super(cause, message); } }
1,396
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
StartConference.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/StartConference.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.dao.entities.MediaAttributes; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class StartConference { private final Sid callSid; private final MediaAttributes mediaAttributes; public StartConference(final Sid callSid) { super(); this.callSid = callSid; this.mediaAttributes = new MediaAttributes(); } public StartConference(final Sid callSid, final MediaAttributes mediaAttributes) { super(); this.callSid = callSid; this.mediaAttributes = mediaAttributes; } public Sid callSid(){ return callSid; } public MediaAttributes mediaAttributes() { return mediaAttributes; } }
1,719
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
BridgeStateChanged.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/BridgeStateChanged.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author Henrique Rosa ([email protected]) * */ @Immutable public final class BridgeStateChanged { public enum BridgeState { READY("ready"), HALF_BRIDGED("half bridged"), BRIDGED("bridged"), INACTIVE("completed"), FAILED("failed"); private final String text; private BridgeState(final String text) { this.text = text; } @Override public String toString() { return text; } } private final BridgeState state; public BridgeStateChanged(BridgeState state) { this.state = state; } public BridgeState getState() { return state; } }
1,712
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ChangeCallDirection.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/ChangeCallDirection.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class ChangeCallDirection { public ChangeCallDirection() { super(); } }
1,023
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GetProxies.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/GetProxies.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ @Immutable public class GetProxies { public GetProxies() { super(); } }
1,089
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GetActiveProxy.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/GetActiveProxy.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ @Immutable public class GetActiveProxy { public GetActiveProxy() { super(); } }
1,096
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GetStatistics.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/GetStatistics.java
package org.restcomm.connect.telephony.api; /** * Created by gvagenas on 15/05/2017. */ public class GetStatistics { private final boolean withLiveCallDetails; private final boolean withMgcpStats; private final String accountSid; public GetStatistics (final boolean withLiveCallDetails, final boolean withMgcpStats, final String accountSid) { this.withLiveCallDetails = withLiveCallDetails; this.withMgcpStats = withMgcpStats; this.accountSid = accountSid; } public boolean isWithLiveCallDetails () { return withLiveCallDetails; } public boolean isWithMgcpStats () { return withMgcpStats; } public String getAccountSid () { return accountSid; } }
744
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CallInfo.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CallInfo.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import javax.servlet.sip.SipServletRequest; import javax.servlet.sip.SipServletResponse; import org.joda.time.DateTime; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.dao.entities.MediaAttributes; import org.restcomm.connect.commons.telephony.CreateCallType; /** * @author [email protected] (Thomas Quintana) * @author [email protected] */ @Immutable public final class CallInfo { private final Sid sid; private final Sid accountSid; private CallStateChanged.State state; private final CreateCallType type; private final String direction; private final DateTime dateCreated; private final DateTime dateConUpdated; private final String forwardedFrom; private final String fromName; private final String from; private final String to; private final SipServletRequest invite; private final SipServletResponse lastResponse; private final boolean webrtc; private boolean muted; private boolean isFromApi; private final MediaAttributes mediaAttributes; public CallInfo(final Sid sid, final Sid accountSid, final CallStateChanged.State state, final CreateCallType type, final String direction, final DateTime dateCreated, final String forwardedFrom, final String fromName, final String from, final String to, final SipServletRequest invite, final SipServletResponse lastResponse, final boolean webrtc, final boolean muted, final boolean isFromApi, final DateTime dateConUpdated, final MediaAttributes mediaAttributes) { super(); this.sid = sid; this.accountSid = accountSid; this.state = state; this.direction = direction; this.dateCreated = dateCreated; this.forwardedFrom = forwardedFrom; this.fromName = fromName; this.from = from; this.to = to; this.invite = invite; this.lastResponse = lastResponse; this.dateConUpdated = dateConUpdated; this.type = type; this.webrtc = webrtc; this.muted = muted; this.isFromApi = isFromApi; this.mediaAttributes = mediaAttributes; } public DateTime dateCreated() { return dateCreated; } public DateTime dateConUpdated() { return dateConUpdated; } public String direction() { return direction; } public CreateCallType type() { return type; } public String forwardedFrom() { return forwardedFrom; } public String fromName() { return fromName; } public String from() { return from; } public Sid sid() { return sid; } public Sid accountSid() { return accountSid; } public CallStateChanged.State state() { return state; } public void setState(CallStateChanged.State state) { this.state = state; } public String to() { return to; } public SipServletRequest invite() { return invite; } public SipServletResponse lastResponse() { return lastResponse; } public boolean isWebrtc() { return webrtc; } public boolean isMuted() { return muted; } public void setMute(boolean muted) { this.muted = muted; } public boolean isFromApi() { return isFromApi; } public MediaAttributes mediaAttributes(){ return this.mediaAttributes; } }
4,408
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
StopConference.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/StopConference.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class StopConference { public StopConference() { super(); } }
1,093
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GetConferenceInfo.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/GetConferenceInfo.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class GetConferenceInfo { public GetConferenceInfo() { super(); } }
1,099
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
DestroyConference.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/DestroyConference.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class DestroyConference { private final String name; public DestroyConference(final String name) { super(); this.name = name; } public String name() { return name; } }
1,229
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
Cancel.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/Cancel.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class Cancel { public Cancel() { super(); } }
1,077
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CreateWaitUrlConfMediaGroup.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CreateWaitUrlConfMediaGroup.java
/** * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import akka.actor.ActorRef; /** * @author Amit Bhayani * */ @Immutable public class CreateWaitUrlConfMediaGroup { private final ActorRef confVoiceInterpreter; public CreateWaitUrlConfMediaGroup(final ActorRef confVoiceInterpreter) { this.confVoiceInterpreter = confVoiceInterpreter; } public ActorRef getConfVoiceInterpreter() { return confVoiceInterpreter; } }
535
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CreateBridge.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CreateBridge.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.dao.entities.MediaAttributes; /** * @author Henrique Rosa ([email protected]) * */ @Immutable public final class CreateBridge { private final MediaAttributes mediaAttributes; public CreateBridge(final MediaAttributes mediaAttributes) { super(); this.mediaAttributes = mediaAttributes; } public CreateBridge() { this(new MediaAttributes()); }; public MediaAttributes mediaAttributes() { return mediaAttributes; } }
1,554
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
InitializeOutbound.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/InitializeOutbound.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import javax.servlet.sip.SipURI; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.dao.DaoManager; import org.restcomm.connect.dao.entities.MediaAttributes; import org.restcomm.connect.commons.telephony.CreateCallType; /** * @author [email protected] (Thomas Quintana) * @author [email protected] */ @Immutable public final class InitializeOutbound { // The displayed name of the original user private final String name; // From SipURI private final SipURI from; // To SipURI private final SipURI to; private final String username; private final String password; private final long timeout; private final boolean isFromApi; private final String apiVersion; private final Sid accountId; private final CreateCallType type; private final DaoManager daoManager; private Sid parentCallSid; private final boolean webrtc; private final MediaAttributes mediaAttributes; //IMS parameters private boolean outboundToIms; private String imsProxyAddress; private int imsProxyPort; public InitializeOutbound(final String name, final SipURI from, final SipURI to, final String username, final String password, final long timeout, final boolean isFromApi, final String apiVersion, final Sid accountId, final CreateCallType type, final DaoManager daoManager, final boolean webrtc, final boolean outboundToIms, final String imsProxyAddress, final int imsProxyPort, final MediaAttributes mediaAttributes) { this(name, from, to, username, password, timeout, isFromApi, apiVersion, accountId, type, daoManager, webrtc, mediaAttributes); this.outboundToIms = outboundToIms; this.imsProxyAddress = imsProxyAddress; this.imsProxyPort = imsProxyPort; } public InitializeOutbound(final String name, final SipURI from, final SipURI to, final String username, final String password, final long timeout, final boolean isFromApi, final String apiVersion, final Sid accountId, final CreateCallType type, final DaoManager daoManager, final boolean webrtc) { this(name, from, to, username, password, timeout, isFromApi, apiVersion, accountId, type, daoManager, webrtc, new MediaAttributes()); } public InitializeOutbound(final String name, final SipURI from, final SipURI to, final String username, final String password, final long timeout, final boolean isFromApi, final String apiVersion, final Sid accountId, final CreateCallType type, final DaoManager daoManager, final boolean webrtc, final MediaAttributes mediaAttributes) { super(); this.name = name; this.from = from; this.to = to; this.username = username; this.password = password; this.timeout = timeout; this.isFromApi = isFromApi; this.apiVersion = apiVersion; this.accountId = accountId; this.type = type; this.daoManager = daoManager; this.webrtc = webrtc; this.outboundToIms = outboundToIms; this.imsProxyAddress = imsProxyAddress; this.imsProxyPort = imsProxyPort; this.mediaAttributes = mediaAttributes; } public String name() { return name; } public SipURI from() { return from; } public SipURI to() { return to; } public long timeout() { return timeout; } public boolean isFromApi() { return isFromApi; } public String apiVersion() { return apiVersion; } public Sid accountId() { return accountId; } public String username() { return username; } public String password() { return password; } public CreateCallType type() { return type; } public DaoManager getDaoManager() { return daoManager; } public Sid getParentCallSid() { return parentCallSid; } public void setParentCallSid(Sid parentCallSid) { this.parentCallSid = parentCallSid; } public boolean isWebrtc() { return webrtc; } public boolean isOutboundToIms() { return outboundToIms; } public String getImsProxyAddress() { return imsProxyAddress; } public int getImsProxyPort() { return imsProxyPort; } public MediaAttributes getMediaAttributes() { return mediaAttributes; } }
5,446
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
Reject.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/Reject.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class Reject { private final String reason; public Reject(final String reason) { this.reason = reason; } public String getReason() { return reason; } }
1,205
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CreateConference.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CreateConference.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.dao.entities.MediaAttributes; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class CreateConference { private final String name; private final Sid initialitingCallSid; private final MediaAttributes mediaAttributes; public CreateConference(final String name, final Sid initialitingCallSid) { super(); this.name = name; this.initialitingCallSid = initialitingCallSid; this.mediaAttributes = new MediaAttributes(); } public CreateConference(final String name, final Sid initialitingCallSid, final MediaAttributes mediaAttributes) { super(); this.name = name; this.initialitingCallSid = initialitingCallSid; this.mediaAttributes = mediaAttributes; } public String name() { return name; } public Sid initialitingCallSid(){ return initialitingCallSid; } public MediaAttributes mediaAttributes() { return mediaAttributes; } }
2,005
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
GetRelatedCall.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/GetRelatedCall.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import akka.actor.ActorRef; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class GetRelatedCall { final ActorRef call; public GetRelatedCall(ActorRef call) { super(); this.call = call; } public ActorRef call() { return call; } }
1,161
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
NotFound.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/NotFound.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class NotFound { public NotFound() { super(); } }
1,081
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
StopBridge.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/StopBridge.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author Henrique Rosa ([email protected]) * */ @Immutable public final class StopBridge { private boolean liveCallModification; public StopBridge(final boolean liveCallModification) { this.liveCallModification = liveCallModification; } public boolean isLiveCallModification() { return liveCallModification; } }
1,404
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ExecuteCallScript.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/ExecuteCallScript.java
package org.restcomm.connect.telephony.api; import java.net.URI; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; import akka.actor.ActorRef; @Immutable public final class ExecuteCallScript { private final ActorRef call; private final Sid account; private final String version; private final URI url; private final String method; private final URI fallbackUrl; private final String fallbackMethod; private final long timeout; public ExecuteCallScript(final ActorRef call, final Sid account, final String version, final URI url, final String method, final URI fallbackUrl, final String fallbackMethod, final long timeout) { super(); this.call = call; this.account = account; this.version = version; this.url = url; this.method = method; this.fallbackUrl = fallbackUrl; this.fallbackMethod = fallbackMethod; this.timeout = timeout; } public ActorRef call() { return call; } public Sid account() { return account; } public String version() { return version; } public URI url() { return url; } public String method() { return method; } public URI fallbackUrl() { return fallbackUrl; } public String fallbackMethod() { return fallbackMethod; } public long timeout() { return timeout; } }
1,515
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CallStateChanged.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CallStateChanged.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class CallStateChanged { public enum State { QUEUED("queued"), RINGING("ringing"), CANCELED("canceled"), BUSY("busy"), NOT_FOUND("not-found"), FAILED("failed"), NO_ANSWER( "no-answer"), WAIT_FOR_ANSWER("wait-for-answer"), IN_PROGRESS("in-progress"), COMPLETED("completed"); private final String text; private State(final String text) { this.text = text; } @Override public String toString() { return text; } }; private final State state; private final Integer sipResponse; public CallStateChanged(final State state) { super(); this.state = state; this.sipResponse = null; } public CallStateChanged(final State state, final Integer sipResponse) { super(); this.state = state; this.sipResponse = sipResponse; } public State state() { return state; } public Integer sipResponse() { return sipResponse; } @Override public String toString() { return "CallStateChanged [state=" + state + ", sipResponse=" + sipResponse + "]"; } }
2,176
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
StopWaiting.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/StopWaiting.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author maria */ @Immutable public final class StopWaiting { public StopWaiting() { super(); } }
1,049
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
CallFail.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/CallFail.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class CallFail { private final String reason; public CallFail(final String reason) { super(); this.reason = reason; } public String getReason() { return reason; } }
1,224
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
TextMessage.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/TextMessage.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2013, Telestax Inc and individual contributors * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.restcomm.connect.telephony.api; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class TextMessage { public static enum SmsState {INBOUND_TO_APP, INBOUND_TO_CLIENT, INBOUND_TO_PROXY_OUT, OUTBOUND, NOT_FOUND} private final String from; private final String to; private final SmsState state; public TextMessage(final String from, final String to, final SmsState state) { this.from = from; this.to = to; this.state = state; } public String getFrom() { return from; } public String getTo() { return to; } public SmsState getState() { return state; } }
1,608
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
AddParticipant.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/AddParticipant.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import akka.actor.ActorRef; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.dao.entities.MediaAttributes; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class AddParticipant { private final ActorRef call; private final MediaAttributes mediaAttributes; public AddParticipant(final ActorRef call) { this(call, new MediaAttributes()); } public AddParticipant(final ActorRef call, final MediaAttributes mediaAttributes){ super(); this.call = call; this.mediaAttributes = mediaAttributes; } public ActorRef call() { return call; } public MediaAttributes mediaAttributes(){ return mediaAttributes; } }
1,637
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
Answer.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/Answer.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.dao.Sid; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class Answer { private final Sid callSid; private final boolean confirmCall; public Answer(Sid callSid) { super(); this.callSid = callSid; this.confirmCall = false; } public Answer(Sid callSid, boolean confirmCall) { super(); this.callSid = callSid; this.confirmCall = confirmCall; } public Sid callSid() { return callSid; } public boolean confirmCall() { return confirmCall; } }
1,550
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
RecordingStarted.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/RecordingStarted.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; /** * @author <a href="mailto:[email protected]">gvagenas</a> * */ public class RecordingStarted { public RecordingStarted(){} }
993
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ConferenceModeratorAbsent.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/ConferenceModeratorAbsent.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * <p> * Tell's {@link Conference} that moderator has not yet joined and it should Transition from * {@link ConferenceStateChanged#State.RUNNING} to {@link ConferenceStateChanged#State.RUNNING_MODERATOR_ABSENT} * </p> * * @author Amit Bhayani * */ @Immutable public class ConferenceModeratorAbsent { public ConferenceModeratorAbsent() { super(); } }
1,307
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
Dial.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/Dial.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; import org.restcomm.connect.commons.annotations.concurrency.Immutable; /** * @author [email protected] (Thomas Quintana) */ @Immutable public final class Dial { public Dial() { super(); } }
1,073
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
ConferenceStateChanged.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/ConferenceStateChanged.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */ package org.restcomm.connect.telephony.api; /** * @author [email protected] (Thomas Quintana) * @author [email protected] (Amit Bhayani) * @author [email protected] (Maria Farooq) */ public final class ConferenceStateChanged { public enum State { RUNNING_INITIALIZING, RUNNING_MODERATOR_ABSENT, RUNNING_MODERATOR_PRESENT, STOPPING, COMPLETED, FAILED }; private final String name; private final State state; public ConferenceStateChanged(final String name, final State state) { super(); this.name = name; this.state = state; } public String name() { return name; } public State state() { return state; } public static State translateState(String stateName, State defaultState) { State converetedState = defaultState; if(stateName!=null){ switch (stateName) { case "RUNNING_MODERATOR_ABSENT": converetedState=State.RUNNING_MODERATOR_ABSENT; break; case "RUNNING_MODERATOR_PRESENT": converetedState=State.RUNNING_MODERATOR_PRESENT; break; case "RUNNING_INITIALIZING": converetedState=State.RUNNING_INITIALIZING; break; case "COMPLETED": converetedState=State.COMPLETED; break; case "FAILED": converetedState=State.FAILED; break; case "STOPPING": converetedState=State.STOPPING; break; default: break; } } return converetedState; } }
2,606
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
UssdStreamEvent.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/events/UssdStreamEvent.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2018, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it andor modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but OUT ANY WARRANTY; out even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along this program. If not, see <http:www.gnu.orglicenses> */ package org.restcomm.connect.telephony.api.events; import org.joda.time.DateTime; import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.annotations.concurrency.NotThreadSafe; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.commons.stream.StreamEvent; /** * @author [email protected] (Laslo Horvat) */ @Immutable public final class UssdStreamEvent implements StreamEvent { private final Sid sid; private final Sid accountSid; private final String from; private final String to; private final UssdStreamEvent.Status status; private final UssdStreamEvent.Direction direction; private final String request; private final DateTime dateCreated; public enum Direction { inbound, outbound } public enum Status { started, queued, ringing, in_progress, canceled, failed, not_found, processing, completed; } public UssdStreamEvent(final Sid sid, final Sid accountSid, final String from, final String to, final Status status, final Direction direction, final String request, final DateTime dateCreated) { super(); this.sid = sid; this.accountSid = accountSid; this.from = from; this.to = to; this.status = status; this.direction = direction; this.request = request; this.dateCreated = dateCreated; } public static Builder builder() { return new Builder(); } public Sid getSid() { return sid; } public Sid getAccountSid() { return accountSid; } public String getFrom() { return from; } public String getTo() { return to; } public Status getStatus() { return status; } public Direction getDirection() { return direction; } public String getRequest() { return request; } public DateTime getDateCreated() { return dateCreated; } @NotThreadSafe public static final class Builder { private Sid sid; private Sid accountSid; private String from; private String to; private Status status; private Direction direction; private String request; private DateTime dateCreated; private Builder() { super(); } public UssdStreamEvent build() { if (dateCreated == null) { dateCreated = DateTime.now(); } return new UssdStreamEvent(sid, accountSid, from, to, status, direction, request, dateCreated); } public Builder setSid(Sid sid) { this.sid = sid; return this; } public Builder setAccountSid(Sid accountSid) { this.accountSid = accountSid; return this; } public Builder setFrom(String from) { this.from = from; return this; } public Builder setTo(String to) { this.to = to; return this; } public Builder setStatus(Status status) { this.status = status; return this; } public Builder setDirection(Direction direction) { this.direction = direction; return this; } public Builder setRequest(String request) { this.request = request; return this; } public Builder setDateCreated(DateTime dateCreated) { this.dateCreated = dateCreated; return this; } } }
4,436
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z
B2BUAHelper.java
/FileExtraction/Java_unseen/RestComm_Restcomm-Connect/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java
/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2014, Telestax Inc and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * */package org.restcomm.connect.telephony.api.util; import akka.actor.ActorSystem; import org.apache.log4j.Logger; import org.joda.time.DateTime; import org.mobicents.javax.servlet.sip.SipSessionExt; import org.restcomm.connect.commons.configuration.RestcommConfiguration; import org.restcomm.connect.commons.dao.Sid; import org.restcomm.connect.commons.util.DNSUtils; import org.restcomm.connect.dao.CallDetailRecordsDao; import org.restcomm.connect.dao.DaoManager; import org.restcomm.connect.dao.RegistrationsDao; import org.restcomm.connect.dao.common.OrganizationUtil; import org.restcomm.connect.dao.entities.CallDetailRecord; import org.restcomm.connect.dao.entities.Client; import org.restcomm.connect.dao.entities.Registration; import org.restcomm.connect.telephony.api.CallInfo; import org.restcomm.connect.telephony.api.CallInfoStreamEvent; import org.restcomm.connect.telephony.api.CallStateChanged; import javax.sdp.Connection; import javax.sdp.MediaDescription; import javax.sdp.SdpException; import javax.sdp.SdpFactory; import javax.sdp.SessionDescription; import javax.sdp.SessionName; import javax.servlet.sip.Address; import javax.servlet.sip.ServletParseException; import javax.servlet.sip.SipFactory; import javax.servlet.sip.SipServletMessage; import javax.servlet.sip.SipServletRequest; import javax.servlet.sip.SipServletResponse; import javax.servlet.sip.SipSession; import javax.servlet.sip.SipURI; import java.io.IOException; import java.math.BigDecimal; import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Currency; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Vector; import javax.servlet.sip.SipApplicationSession; /** * Helper methods for proxying SIP messages between Restcomm clients that are connecting in peer to peer mode * * @author [email protected] * @author [email protected] * @author [email protected] */ public class B2BUAHelper { public static final String B2BUA_CALL = "org.restcomm.connect.telephony.api.util.B2BUAHelper"; public static final String FROM_INET_URI = "fromInetURI"; public static final String TO_INET_URI = "toInetURI"; public static final String B2BUA_LAST_REQUEST = "lastRequest"; public static final String B2BUA_LAST_RESPONSE = "lastResponse"; public static final String B2BUA_LAST_FINAL_RESPONSE = "lastFinalResponse"; public static final String EXTENSION_HEADERS = "extensionHeaders"; private static final String B2BUA_LINKED_SESSION = "linkedSession"; private static final String CDR_SID = "callDetailRecord_sid"; private static final String CDR_ACCOUNT_SID = "callDetailRecord_accountSid"; private static final String CDR_DIRECTION = "callDetailRecord_direction"; private static final String CDR_FROM = "callDetailRecord_from"; private static final String CDR_TO = "callDetailRecord_to"; private static final Logger logger = Logger.getLogger(B2BUAHelper.class); // private static CallDetailRecord callRecord = null; private static DaoManager daoManager; /** * @param request * @param client * @param toClient * @throws IOException */ // This is used for redirect calls to Restcomm clients from Restcomm Clients public static boolean redirectToB2BUA(final ActorSystem system, final SipServletRequest request, final Client client, Client toClient, DaoManager storage, SipFactory sipFactory, final boolean patchForNat) throws IOException { request.getSession().setAttribute("lastRequest", request); if (logger.isInfoEnabled()) { logger.info("B2BUA (p2p proxy): Got request:\n" + request.getMethod()); logger.info(String.format("B2BUA: Proxying a session between %s and %s", client.getLogin(), toClient.getLogin())); } if (daoManager == null) { daoManager = storage; } String user = ((SipURI) request.getTo().getURI()).getUser(); final RegistrationsDao registrations = daoManager.getRegistrationsDao(); try { Sid toOrganizationSid = OrganizationUtil.getOrganizationSidBySipURIHost(storage, (SipURI) request.getTo().getURI()); final Registration registration = registrations.getRegistration(user, toOrganizationSid); if (registration != null) { final String location = registration.getLocation(); final String aor = registration.getAddressOfRecord(); SipURI to; SipURI from; SipURI locationURI = null; Sid fromOrganizationSid = OrganizationUtil.getOrganizationSidBySipURIHost(storage, (SipURI) request.getFrom().getURI()); // if both clients don't belong to same organization, call should not be allowed. if(!toOrganizationSid.equals(fromOrganizationSid)){ logger.warn(String.format("B2B clients do not belong to same organization. from-client: %s belong to %s . where as to-client %s belong to %s", client.getLogin(), fromOrganizationSid, user, toOrganizationSid)); return false; } if(patchForNat) { to = (SipURI) sipFactory.createURI(location); from = (SipURI) sipFactory.createURI((registrations.getRegistration(client.getLogin(), fromOrganizationSid)).getLocation()); } else { // https://github.com/RestComm/Restcomm-Connect/issues/2741 support for SBC if (logger.isDebugEnabled()) { logger.debug("B2BUA not patched for NAT, using address of record for to and from"); } to = (SipURI) sipFactory.createURI(aor); locationURI = (SipURI) sipFactory.createURI(location); from = (SipURI) sipFactory.createURI((registrations.getRegistration(client.getLogin(), fromOrganizationSid)).getAddressOfRecord()); } final SipSession incomingSession = request.getSession(); // create and send the outgoing invite and do the session linking incomingSession.setAttribute(B2BUA_LAST_REQUEST, request); SipServletRequest outRequest = sipFactory.createRequest(request.getApplicationSession(), request.getMethod(), from, to); if(patchForNat) { outRequest.setRequestURI(to); } else { outRequest.setRequestURI(locationURI); } if (request.getContent() != null) { final byte[] sdp = request.getRawContent(); String offer = null; if (request.getContentType().equalsIgnoreCase("application/sdp") && patchForNat) { // Issue 308: https://telestax.atlassian.net/browse/RESTCOMM-308 String externalIp = request.getInitialRemoteAddr(); // Issue 306: https://telestax.atlassian.net/browse/RESTCOMM-306 final String initialIpBeforeLB = request.getHeader("X-Sip-Balancer-InitialRemoteAddr"); try { if (initialIpBeforeLB != null && !initialIpBeforeLB.isEmpty()) { offer = patch(sdp, initialIpBeforeLB); } else { offer = patch(sdp, externalIp); } } catch (SdpException e) { logger.error("Unexpected exception while patching sdp ", e); } } if (offer != null) { outRequest.setContent(offer, request.getContentType()); } else { outRequest.setContent(sdp, request.getContentType()); } } addHeadersToMessage(outRequest, getCustomHeaders(request, "X-")); final SipSession outgoingSession = outRequest.getSession(); if (request.isInitial()) { incomingSession.setAttribute(B2BUA_LINKED_SESSION, outgoingSession); outgoingSession.setAttribute(B2BUA_LINKED_SESSION, incomingSession); } outgoingSession.setAttribute(B2BUA_LAST_REQUEST, outRequest); request.createResponse(100).send(); // Issue #307: https://telestax.atlassian.net/browse/RESTCOMM-307 request.getSession().setAttribute(TO_INET_URI, to); if (logger.isInfoEnabled()) logger.info("bypassLoadBalancer is set to: " + RestcommConfiguration.getInstance().getMain().getBypassLbForClients()); if (RestcommConfiguration.getInstance().getMain().getBypassLbForClients()) { ((SipSessionExt) outRequest.getSession()).setBypassLoadBalancer(true); ((SipSessionExt) outRequest.getSession()).setBypassProxy(true); } outRequest.send(); outRequest.getSession().setAttribute(FROM_INET_URI, from); final CallDetailRecord.Builder builder = CallDetailRecord.builder(); builder.setSid(Sid.generate(Sid.Type.CALL)); builder.setInstanceId(RestcommConfiguration.getInstance().getMain().getInstanceId()); builder.setDateCreated(DateTime.now()); builder.setAccountSid(client.getAccountSid()); builder.setTo(toClient.getLogin()); builder.setCallerName(client.getFriendlyName()); builder.setFrom(client.getLogin()); // builder.setForwardedFrom(callInfo.forwardedFrom()); // builder.setPhoneNumberSid(phoneId); builder.setStatus(CallStateChanged.State.QUEUED.name()); builder.setDirection("Client-To-Client"); builder.setApiVersion(client.getApiVersion()); builder.setPrice(new BigDecimal("0.00")); // TODO implement currency property to be read from Configuration builder.setPriceUnit(Currency.getInstance("USD")); final StringBuilder buffer = new StringBuilder(); buffer.append("/").append(client.getApiVersion()).append("/Accounts/"); buffer.append(client.getAccountSid().toString()).append("/Calls/"); buffer.append(client.getSid().toString()); final URI uri = URI.create(buffer.toString()); builder.setUri(uri); CallDetailRecordsDao records = daoManager.getCallDetailRecordsDao(); CallDetailRecord callRecord = builder.build(); records.addCallDetailRecord(callRecord); incomingSession.setAttribute(CDR_SID, callRecord.getSid()); outgoingSession.setAttribute(CDR_SID, callRecord.getSid()); incomingSession.setAttribute(CDR_ACCOUNT_SID, client.getSid()); outgoingSession.setAttribute(CDR_ACCOUNT_SID, client.getSid()); incomingSession.setAttribute(CDR_DIRECTION, "Client-To-Client"); outgoingSession.setAttribute(CDR_DIRECTION, "Client-To-Client"); incomingSession.setAttribute(CDR_FROM, client.getLogin()); outgoingSession.setAttribute(CDR_FROM, client.getLogin()); incomingSession.setAttribute(CDR_TO, toClient.getLogin()); outgoingSession.setAttribute(CDR_TO, toClient.getLogin()); sendCallInfoStreamEvent(system, request, CallStateChanged.State.QUEUED); outgoingSession.getApplicationSession().setAttribute(B2BUA_CALL, "Client-To-Client"); return true; // successfully proxied the SIP request between two registered clients } } catch (Exception e) { if (logger.isInfoEnabled()) { // logger.info(String.format("B2BUA: Error parsing Client Contact URI: %s", location), badUriEx); logger.info("Cannot proxy client to client call"); } } return false; } /** * @param system * @param request * @param fromClient * @param from * @param to * @param proxyUsername * @param proxyPassword * @param storage * @param sipFactory * @param callToSipUri * @param patchForNat * @throws IOException */ // https://telestax.atlassian.net/browse/RESTCOMM-335 // This is used for redirect calls to PSTN Numbers and SIP URIs from Restcomm Clients public static boolean redirectToB2BUA(final ActorSystem system, final SipServletRequest request, final Client fromClient, final SipURI from, SipURI to, String proxyUsername, String proxyPassword, DaoManager storage, SipFactory sipFactory, boolean callToSipUri, final boolean patchForNat) { request.getSession().setAttribute("lastRequest", request); if (logger.isInfoEnabled()) { logger.info("B2BUA (p2p proxy for DID and SIP URIs) - : Got request:\n" + request.getRequestURI().toString()); logger.info(String.format("B2BUA: Proxying a session from %s to %s", from, to)); } if (daoManager == null) { daoManager = storage; } try { final SipSession incomingSession = request.getSession(); // create and send the outgoing invite and do the session linking incomingSession.setAttribute(B2BUA_LAST_REQUEST, request); SipServletRequest outRequest = null; if (fromClient != null) { Address fromAddress = sipFactory.createAddress(from, fromClient.getFriendlyName()); Address toAddress = sipFactory.createAddress(to, to.getUser()); outRequest = sipFactory.createRequest(request.getApplicationSession(), request.getMethod(), fromAddress, toAddress); } else { outRequest = sipFactory.createRequest(request.getApplicationSession(), request.getMethod(), from, to); } outRequest.setRequestURI(to); if(logger.isInfoEnabled()) { logger.info("Request: " + request.getMethod() + " content exists: " + request.getContent() != null+ " content type: " + request.getContentType()); } boolean isBehindLB = false; final String initialIpBeforeLB = request.getHeader("X-Sip-Balancer-InitialRemoteAddr"); String initialPortBeforeLB = request.getHeader("X-Sip-Balancer-InitialRemotePort"); if (initialIpBeforeLB != null) { if (initialPortBeforeLB == null) initialPortBeforeLB = "5060"; if (logger.isDebugEnabled()) { logger.debug("We are behind load balancer, initial IP and Ports are " + initialIpBeforeLB+":"+initialPortBeforeLB); } isBehindLB = true; } if (request.getContent() != null) { final byte[] sdp = request.getRawContent(); String offer = null; if (request.getContentType().equalsIgnoreCase("application/sdp") && patchForNat) { // Issue 308: https://telestax.atlassian.net/browse/RESTCOMM-308 String externalIp = request.getInitialRemoteAddr(); // Issue 306: https://telestax.atlassian.net/browse/RESTCOMM-306 try { if (initialIpBeforeLB != null && !initialIpBeforeLB.isEmpty()) { offer = patch(sdp, initialIpBeforeLB); } else { offer = patch(sdp, externalIp); } } catch (SdpException e) { logger.error("Unexpected exception while patching sdp ", e); } } if (offer != null) { outRequest.setContent(offer, request.getContentType()); } else { outRequest.setContent(sdp, request.getContentType()); } } addHeadersToMessage(outRequest, getCustomHeaders(request, "X-")); final SipSession outgoingSession = outRequest.getSession(); if (request.isInitial()) { incomingSession.setAttribute(B2BUA_LINKED_SESSION, outgoingSession); outgoingSession.setAttribute(B2BUA_LINKED_SESSION, incomingSession); } outgoingSession.setAttribute(B2BUA_LAST_REQUEST, outRequest); request.createResponse(100).send(); // Issue #307: https://telestax.atlassian.net/browse/RESTCOMM-307 request.getSession().setAttribute(TO_INET_URI, to); if (callToSipUri) { if (logger.isInfoEnabled()) logger.info("bypassLoadBalancer is set to: "+RestcommConfiguration.getInstance().getMain().getBypassLbForClients()); if (RestcommConfiguration.getInstance().getMain().getBypassLbForClients()) { ((SipSessionExt) outRequest.getSession()).setBypassLoadBalancer(true); ((SipSessionExt) outRequest.getSession()).setBypassProxy(true); } } Map<String,ArrayList<String>> extensionHeaders = (Map<String,ArrayList<String>>)incomingSession.getAttribute(EXTENSION_HEADERS); addHeadersToMessage(outRequest, extensionHeaders, sipFactory); outRequest.send(); Address originalFromAddress = request.getFrom(); SipURI originalFromUri = (SipURI) originalFromAddress.getURI(); int port = originalFromUri.getPort(); if (port == -1) { port = request.getRemotePort(); originalFromUri.setPort(port); } if(isBehindLB) { // https://github.com/RestComm/Restcomm-Connect/issues/1357 String realIP = initialIpBeforeLB + ":" + initialPortBeforeLB; SipURI uri = sipFactory.createSipURI(null, realIP); if (logger.isDebugEnabled()) { logger.debug("We are behind load balancer, storing initial IP and Ports " + uri); } outRequest.getSession().setAttribute(FROM_INET_URI, uri); } else { if (logger.isDebugEnabled()) { logger.debug("We are not behind load balancer, storing " + FROM_INET_URI +": " + to); } outRequest.getSession().setAttribute(FROM_INET_URI, originalFromUri); } final CallDetailRecord.Builder builder = CallDetailRecord.builder(); builder.setSid(Sid.generate(Sid.Type.CALL)); builder.setInstanceId(RestcommConfiguration.getInstance().getMain().getInstanceId()); builder.setDateCreated(DateTime.now()); builder.setAccountSid(fromClient.getAccountSid()); builder.setTo(to.toString()); builder.setCallerName(fromClient.getFriendlyName()); builder.setFrom(fromClient.getFriendlyName()); // builder.setForwardedFrom(callInfo.forwardedFrom()); // builder.setPhoneNumberSid(phoneId); builder.setStatus(CallStateChanged.State.QUEUED.name()); builder.setDirection("Client-To-Client"); builder.setApiVersion(fromClient.getApiVersion()); builder.setPrice(new BigDecimal("0.00")); // TODO implement currency property to be read from Configuration builder.setPriceUnit(Currency.getInstance("USD")); final StringBuilder buffer = new StringBuilder(); buffer.append("/").append(fromClient.getApiVersion()).append("/Accounts/"); buffer.append(fromClient.getAccountSid().toString()).append("/Calls/"); buffer.append(fromClient.getSid().toString()); final URI uri = URI.create(buffer.toString()); builder.setUri(uri); CallDetailRecordsDao records = daoManager.getCallDetailRecordsDao(); CallDetailRecord callRecord = builder.build(); records.addCallDetailRecord(callRecord); incomingSession.setAttribute(CDR_SID, callRecord.getSid()); outgoingSession.setAttribute(CDR_SID, callRecord.getSid()); incomingSession.setAttribute(CDR_ACCOUNT_SID, fromClient.getSid()); outgoingSession.setAttribute(CDR_ACCOUNT_SID, fromClient.getSid()); incomingSession.setAttribute(CDR_DIRECTION, "Client-To-Client"); outgoingSession.setAttribute(CDR_DIRECTION, "Client-To-Client"); incomingSession.setAttribute(CDR_FROM, fromClient.getLogin()); outgoingSession.setAttribute(CDR_FROM, fromClient.getLogin()); incomingSession.setAttribute(CDR_TO, to.toString()); outgoingSession.setAttribute(CDR_TO, to.toString()); sendCallInfoStreamEvent(system, request, CallStateChanged.State.QUEUED); outgoingSession.getApplicationSession().setAttribute(B2BUA_CALL, "Client-To-Client"); return true; // successfully proxied the SIP request } catch (IOException exception) { if (logger.isInfoEnabled()) { logger.info(String.format("B2BUA: Error while trying to proxy request from %s to %s", from, to)); logger.info("Exception: " + exception); } } return false; } // Issue 308: https://telestax.atlassian.net/browse/RESTCOMM-308 @SuppressWarnings("unchecked") private static String patch(final byte[] data, final String externalIp) throws UnknownHostException, SdpException { final String text = new String(data); if(logger.isInfoEnabled()){ logger.info("About to patch "); logger.info("SDP :" + text); logger.info("Using externalIP: " + externalIp); } final SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(text); SessionName sessionName = SdpFactory.getInstance().createSessionName("Restcomm B2BUA"); sdp.setSessionName(sessionName); // Handle the connection at the session level. fix(sdp.getConnection(), externalIp); // Handle the connections at the media description level. final Vector<MediaDescription> descriptions = sdp.getMediaDescriptions(false); for (final MediaDescription description : descriptions) { fix(description.getConnection(), externalIp); } sdp.getOrigin().setAddress(externalIp); return sdp.toString(); } // Issue 308: https://telestax.atlassian.net/browse/RESTCOMM-308 @SuppressWarnings("unused") private static void fix(final Connection connection, final String externalIp) throws UnknownHostException, SdpException { if (connection != null) { if (Connection.IN.equals(connection.getNetworkType())) { if (Connection.IP4.equals(connection.getAddressType())) { final InetAddress address = DNSUtils.getByName(connection.getAddress()); if (address.isSiteLocalAddress() || address.isAnyLocalAddress() || address.isLoopbackAddress()) { final String ip = address.getHostAddress(); connection.setAddress(externalIp); } } } } } public static SipServletResponse getLinkedResponse(SipServletMessage message) { SipSession linkedB2BUASession = getLinkedSession(message); // if this is an ACK that belongs to a B2BUA session, then we proxy it to the other client if (linkedB2BUASession != null) { SipServletResponse response = (SipServletResponse) linkedB2BUASession.getAttribute(B2BUA_LAST_RESPONSE); return response; } return null; } public static SipServletRequest getLinkedRequest(SipServletMessage message) { SipSession linkedB2BUASession = getLinkedSession(message); if (linkedB2BUASession != null) { SipServletRequest linkedRequest = (SipServletRequest) linkedB2BUASession.getAttribute(B2BUA_LAST_REQUEST); return linkedRequest; } return null; } public static SipSession getLinkedSession(SipServletMessage message) { SipSession sipSession = null; if (message.getSession().isValid()) { sipSession = (SipSession) message.getSession().getAttribute(B2BUA_LINKED_SESSION); } if (sipSession == null) { if(logger.isInfoEnabled()) { logger.info("SIP SESSION is NULL"); } } return sipSession; } /** * @param response * @throws IOException */ public static void forwardResponse(final ActorSystem system, final SipServletResponse response, final boolean patchForNat) throws IOException { if (logger.isInfoEnabled()) { logger.info(String.format("B2BUA: Got response: \n %s", response)); } if (response.getSession() == null || !response.getSession().isValid()) { if (logger.isDebugEnabled()) { logger.debug("Response session is either null or invalidated"); } return; } if (getLinkedSession(response) == null || !getLinkedSession(response).isValid()) { if (logger.isDebugEnabled()) { logger.debug("Linked session of response is either null or invalidated"); } return; } CallDetailRecordsDao records = daoManager.getCallDetailRecordsDao(); if (response.getStatus() > 200) response.getSession().setAttribute(B2BUA_LAST_FINAL_RESPONSE, response); // container handles CANCEL related responses no need to forward them if (response.getStatus() == 487 || (response.getStatus() == 200 && response.getMethod().equalsIgnoreCase("CANCEL"))) { if (logger.isDebugEnabled()) { logger.debug("response to CANCEL not forwarding"); } // Update CallDetailRecord SipServletRequest request = (SipServletRequest) getLinkedSession(response).getAttribute(B2BUA_LAST_REQUEST); CallDetailRecord callRecord = records.getCallDetailRecord((Sid) request.getSession().getAttribute(CDR_SID)); if (callRecord != null) { if(logger.isInfoEnabled()) { logger.info("CDR found! Updating"); } callRecord = callRecord.setStatus(CallStateChanged.State.CANCELED.name()); final DateTime now = DateTime.now(); callRecord = callRecord.setEndTime(now); int seconds; if (callRecord.getStartTime() != null) { seconds = (int) (DateTime.now().getMillis() - callRecord.getStartTime().getMillis()) / 1000; } else { seconds = 0; } callRecord = callRecord.setDuration(seconds); records.updateCallDetailRecord(callRecord); sendCallInfoStreamEvent(system, request, CallStateChanged.State.CANCELED); } return; } // We don't forward 200 OK Response to BYE. if (response.getStatus() == 200 && response.getMethod().equalsIgnoreCase("BYE")) { if (logger.isDebugEnabled()) { logger.debug("response to BYE not forwarding"); } return; } // forward the response if (response.getSession() != null && (!response.getSession().getState().equals(SipSession.State.TERMINATED))) { response.getSession().setAttribute(B2BUA_LAST_RESPONSE, response); } SipServletRequest linkedRequest = (SipServletRequest) getLinkedSession(response).getAttribute(B2BUA_LAST_REQUEST); SipServletResponse clonedResponse = linkedRequest.createResponse(response.getStatus()); SipURI originalURI = null; try { //only fix Contact if necessary, some requests like MESSAGE //doesn't need Contact header if(clonedResponse.getAddressHeader("Contact") != null && response.getAddressHeader("Contact") != null && response.getAddressHeader("Contact").getURI() != null) { originalURI = (SipURI) response.getAddressHeader("Contact").getURI(); if (originalURI != null && originalURI.getUser() != null && !originalURI.getUser().isEmpty()) { ((SipURI) clonedResponse.getAddressHeader("Contact").getURI()).setUser(originalURI.getUser()); } } } catch (ServletParseException | NullPointerException e) { logger.error("Problem while trying to set User part on a clones response for a P2P call, "+e); } CallDetailRecord callRecord = records.getCallDetailRecord((Sid) linkedRequest.getSession().getAttribute(CDR_SID)); Sid organizationSid = daoManager.getAccountsDao().getAccount(callRecord.getAccountSid()).getOrganizationSid(); if (response.getRawContent() != null && response.getRawContent().length > 0 ) { final byte[] sdp = response.getRawContent(); String offer = null; if (response.getContentType().equalsIgnoreCase("application/sdp") && patchForNat) { // Issue 306: https://telestax.atlassian.net/browse/RESTCOMM-306 Registration registration = daoManager.getRegistrationsDao().getRegistration(callRecord.getTo(), organizationSid); String externalIp; if (registration != null) { externalIp = registration.getLocation().split(":")[1].split("@")[1]; } else { externalIp = callRecord.getTo().split(":")[1].split("@")[1]; } try { if(logger.isDebugEnabled()) { logger.debug("Got original address from Registration :" + externalIp); } offer = patch(sdp, externalIp); } catch (SdpException e) { logger.error("Unexpected exception while patching sdp ", e); } } if (offer != null) { clonedResponse.setContent(offer, response.getContentType()); } else { clonedResponse.setContent(sdp, response.getContentType()); } } addHeadersToMessage(clonedResponse, getCustomHeaders(response, "X-")); clonedResponse.send(); // CallDetailRecord callRecord = records.getCallDetailRecord((Sid) request.getSession().getAttribute(CDR_SID)); if (callRecord != null) { if(logger.isInfoEnabled()) { logger.info("CDR found! Updating"); } if (!linkedRequest.getMethod().equalsIgnoreCase("BYE")) { if (response.getStatus() == 100 || response.getStatus() == 180 || response.getStatus() == 183) { callRecord = callRecord.setStatus(CallStateChanged.State.RINGING.name()); } else if (response.getStatus() == 200 || response.getStatus() == 202) { callRecord = callRecord.setStatus(CallStateChanged.State.IN_PROGRESS.name()); callRecord = callRecord.setAnsweredBy(((SipURI) response.getTo().getURI()).getUser()); final DateTime now = DateTime.now(); callRecord = callRecord.setStartTime(now); } else if (response.getStatus() == 486 || response.getStatus() == 600) { callRecord = callRecord.setStatus(CallStateChanged.State.BUSY.name()); } else if (response.getStatus() > 400) { callRecord = callRecord.setStatus(CallStateChanged.State.FAILED.name()); } } else { callRecord = callRecord.setStatus(CallStateChanged.State.COMPLETED.name()); final DateTime now = DateTime.now(); callRecord = callRecord.setEndTime(now); final int seconds = (int) ((DateTime.now().getMillis() - callRecord.getStartTime().getMillis()) / 1000); callRecord = callRecord.setDuration(seconds); } records.updateCallDetailRecord(callRecord); sendCallInfoStreamEvent(system, linkedRequest, CallStateChanged.State.valueOf(callRecord.getStatus())); } } public static void updateCDR(ActorSystem system, SipServletMessage message, CallStateChanged.State state) { CallDetailRecordsDao records = daoManager.getCallDetailRecordsDao(); SipServletRequest request = null; // Update CallDetailRecord if (message instanceof SipServletResponse) { request = (SipServletRequest) getLinkedSession(message).getAttribute(B2BUA_LAST_REQUEST); } else if (message instanceof SipServletRequest) { request = (SipServletRequest) message; } CallDetailRecord callRecord = records.getCallDetailRecord((Sid) request.getSession().getAttribute(CDR_SID)); if (callRecord != null) { if(logger.isInfoEnabled()) { logger.info("CDR found! Updating"); } callRecord = callRecord.setStatus(state.name()); final DateTime now = DateTime.now(); callRecord = callRecord.setEndTime(now); int seconds; if (callRecord.getStartTime() != null) { seconds = (int) (DateTime.now().getMillis() - callRecord.getStartTime().getMillis()) / 1000; } else { seconds = 0; } callRecord = callRecord.setDuration(seconds); records.updateCallDetailRecord(callRecord); sendCallInfoStreamEvent(system, message, state); } } /** * Check whether a SIP request or response belongs to a peer to peer (B2BUA) session * * @param sipMessage * @return */ public static boolean isB2BUASession(SipServletMessage sipMessage) { SipSession linkedB2BUASession = getLinkedSession(sipMessage); return (linkedB2BUASession != null); } private static Map<String, String> getCustomHeaders (SipServletMessage message, String prefix) { Map<String, String> customHeaders = new HashMap<>(); Iterator<String> headersIter = message.getHeaderNames(); while (headersIter.hasNext()) { String header = headersIter.next(); if (header.toUpperCase().startsWith(prefix)) { customHeaders.put(header, message.getHeader(header).toString()); } } return customHeaders; } /** * Method adds custom headers to a SipServlet message * @param message * @param customHeaders */ private static void addHeadersToMessage(SipServletMessage message, Map<String, String> customHeaders) { for (Map.Entry<String, String> entry: customHeaders.entrySet()) { String headerName = entry.getKey(); String headerVal = entry.getValue(); message.addHeader(headerName, headerVal); } } /** * Modify Messages with new headers and header attributes * Moved from CallManager and Call * * The method deals with custom and standard headers, such as R-URI, Route etc * * TODO: refactor/rename/handle more specific headers * @param sipFactory SipFactory * @param message * @param headers */ public static void addHeadersToMessage(SipServletRequest message, Map<String, ArrayList<String>> headers, SipFactory sipFactory) { if (headers != null && sipFactory != null) { for (Map.Entry<String, ArrayList<String>> entry : headers.entrySet()) { //check if header exists String headerName = entry.getKey(); if (logger.isDebugEnabled()) { logger.debug("headerName=" + headerName + " headerVal=" + message.getHeader(headerName)); } if(headerName.equalsIgnoreCase("Request-URI")) { //handle Request-URI javax.servlet.sip.URI reqURI = message.getRequestURI(); if(logger.isDebugEnabled()) { logger.debug("ReqURI="+reqURI.toString()+" msgReqURI="+message.getRequestURI()); } for(String keyValPair :entry.getValue()){ String parName = ""; String parVal = ""; int equalsPos = keyValPair.indexOf("="); parName = keyValPair.substring(0, equalsPos); parVal = keyValPair.substring(equalsPos+1); reqURI.setParameter(parName, parVal); if(logger.isDebugEnabled()) { logger.debug("ReqURI pars ="+parName+"="+parVal+" equalsPos="+equalsPos+" keyValPair="+keyValPair); } } message.setRequestURI(reqURI); if(logger.isDebugEnabled()) { logger.debug("ReqURI="+reqURI.toString()+" msgReqURI="+message.getRequestURI()); } } else if( headerName.equalsIgnoreCase("Route") ){ //handle Route String headerVal = message.getHeader(headerName); //TODO: do we want to add arbitrary parameters? if(logger.isDebugEnabled()) { logger.debug("ROUTE: "+headerName + "=" + headerVal); } //check how many pairs of host +port for(String keyValPair :entry.getValue()){ String parName = ""; String parVal = ""; int equalsPos = keyValPair.indexOf("="); if(equalsPos>0){ parName = keyValPair.substring(0, equalsPos); } parVal = keyValPair.substring(equalsPos+1); if (parName.isEmpty() || parName.equalsIgnoreCase("host_name")) { try { if(logger.isDebugEnabled()) { logger.debug("adding ROUTE parVal =" + parVal); } final SipURI uri = sipFactory.createSipURI(null, parVal); message.pushRoute((SipURI)uri); if(logger.isDebugEnabled()) { logger.debug("added ROUTE parVal =" + uri.toString()); } } catch (Exception e) { if(logger.isDebugEnabled()) { logger.debug("error adding ROUTE uri =" + parVal); } } } if(logger.isDebugEnabled()) { logger.debug("ROUTE pars ="+parName+"="+parVal+" equalsPos="+equalsPos+" keyValPair="+keyValPair); } } } else { StringBuilder sb = new StringBuilder(); try { String headerVal = message.getHeader(headerName); if (headerVal != null && !headerVal.isEmpty()) { if (entry.getValue() instanceof ArrayList) { for (String pair : entry.getValue()) { sb.append(";").append(pair); } } message.setHeader(headerName, headerVal + sb.toString()); } else { if (entry.getValue() instanceof ArrayList) { for (String pair : entry.getValue()) { sb.append(pair).append(";"); } } message.addHeader(headerName, sb.toString()); } } catch (IllegalArgumentException iae) { logger.error("Exception while setting message header: " + iae.getMessage()); } } if (logger.isDebugEnabled()) { logger.debug("headerName=" + headerName + " headerVal=" + message.getHeader(headerName)); } } } else { logger.error("headers are null"); } } private static void sendCallInfoStreamEvent(ActorSystem system, SipServletMessage message, CallStateChanged.State state) { SipSession session = message.getSession(); Object sid = session.getAttribute(CDR_SID); if (sid != null) { CallInfo callInfo = new CallInfo( (Sid) sid, (Sid) session.getAttribute(CDR_ACCOUNT_SID), state, null, (String) session.getAttribute(CDR_DIRECTION), null, null, null, (String) session.getAttribute(CDR_FROM), (String) session.getAttribute(CDR_TO), null, null, false, false, false, null, null ); system.eventStream().publish(new CallInfoStreamEvent(callInfo)); } } public static void dropB2BUA(SipApplicationSession application) { //finish sessions Iterator<?> sessions = application.getSessions(); while(sessions.hasNext()) { Object next = sessions.next(); if (next instanceof SipSession) { try { SipSession session = (SipSession) next; SipServletRequest createRequest = session.createRequest("BYE"); if (logger.isDebugEnabled()) { logger.debug("sending BYE"); } createRequest.send(); } catch (IOException | IllegalStateException ex) { logger.debug("Unable to drop session.", ex); } } } } }
44,880
Java
.java
RestComm/Restcomm-Connect
239
214
788
2012-08-17T17:47:44Z
2023-04-14T20:58:19Z