Skip to content

Commit

Permalink
apply new name changes (#22298)
Browse files Browse the repository at this point in the history
* name changes and refactoring

* name changes and refactoring
  • Loading branch information
arifsaikat-microsoft authored Jun 15, 2021
1 parent 39ed5c7 commit 3430944
Show file tree
Hide file tree
Showing 57 changed files with 821 additions and 661 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.communication.callingserver;

import com.azure.communication.callingserver.models.AddParticipantResult;
import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult;
import com.azure.communication.callingserver.models.PlayAudioOptions;
import com.azure.communication.callingserver.models.PlayAudioResult;
Expand Down Expand Up @@ -182,7 +183,7 @@ public Response<CancelAllMediaOperationsResult> cancelAllMediaOperationsWithResp
* @return response for a successful add participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Void addParticipant(
public AddParticipantResult addParticipant(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext) {
Expand All @@ -200,7 +201,7 @@ public Void addParticipant(
* @return response for a successful add participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> addParticipantWithResponse(
public Response<AddParticipantResult> addParticipantWithResponse(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@

package com.azure.communication.callingserver;

import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;

import java.util.Objects;

import com.azure.communication.callingserver.implementation.CallConnectionsImpl;
import com.azure.communication.callingserver.implementation.converters.InviteParticipantRequestConverter;
import com.azure.communication.callingserver.implementation.converters.CancelAllMediaOperationsResultConverter;
import com.azure.communication.callingserver.implementation.converters.CallingServerErrorConverter;
import com.azure.communication.callingserver.implementation.converters.CancelAllMediaOperationsResultConverter;
import com.azure.communication.callingserver.implementation.converters.InviteParticipantRequestConverter;
import com.azure.communication.callingserver.implementation.converters.PlayAudioResultConverter;
import com.azure.communication.callingserver.implementation.models.CommunicationErrorException;
import com.azure.communication.callingserver.implementation.models.AddParticipantRequest;
import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsRequest;
import com.azure.communication.callingserver.implementation.models.InviteParticipantsRequest;
import com.azure.communication.callingserver.implementation.models.CommunicationErrorResponseException;
import com.azure.communication.callingserver.implementation.models.PlayAudioRequest;
import com.azure.communication.callingserver.models.AddParticipantResult;
import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult;
import com.azure.communication.callingserver.models.PlayAudioOptions;
import com.azure.communication.callingserver.models.PlayAudioResult;
Expand All @@ -27,9 +23,13 @@
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;

import reactor.core.publisher.Mono;

import java.util.Objects;

import static com.azure.core.util.FluxUtil.monoError;
import static com.azure.core.util.FluxUtil.withContext;

/**
* Async client that supports call connection operations.
*/
Expand Down Expand Up @@ -132,7 +132,7 @@ Mono<PlayAudioResult> playAudioInternal(String audioFileUri, PlayAudioOptions pl
Mono<PlayAudioResult> playAudioInternal(PlayAudioRequest playAudioRequest) {
try {
return callConnectionInternal.playAudioAsync(callConnectionId, playAudioRequest)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.just(PlayAudioResultConverter.convert(result)));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -236,7 +236,7 @@ Mono<Response<PlayAudioResult>> playAudioWithResponseInternal(
contextValue = context == null ? contextValue : context;
return callConnectionInternal
.playAudioWithResponseAsync(callConnectionId, playAudioRequest, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response ->
new SimpleResponse<>(response, PlayAudioResultConverter.convert(response.getValue())));
});
Expand All @@ -254,7 +254,7 @@ Mono<Response<PlayAudioResult>> playAudioWithResponseInternal(
public Mono<Void> hangup() {
try {
return callConnectionInternal.hangupCallAsync(callConnectionId)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand All @@ -275,7 +275,7 @@ Mono<Response<Void>> hangupWithResponse(Context context) {
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return callConnectionInternal.hangupCallWithResponseAsync(callConnectionId, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -295,7 +295,7 @@ public Mono<CancelAllMediaOperationsResult> cancelAllMediaOperations(String oper
CancelAllMediaOperationsRequest request = new CancelAllMediaOperationsRequest();
request.setOperationContext(operationContext);
return callConnectionInternal.cancelAllMediaOperationsAsync(callConnectionId, request)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.just(CancelAllMediaOperationsResultConverter.convert(result)));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -324,7 +324,7 @@ Mono<Response<CancelAllMediaOperationsResult>> cancelAllMediaOperationsWithRespo
contextValue = context == null ? contextValue : context;
return callConnectionInternal
.cancelAllMediaOperationsWithResponseAsync(callConnectionId, request, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response ->
new SimpleResponse<>(response, CancelAllMediaOperationsResultConverter.convert(response.getValue())));
});
Expand All @@ -343,18 +343,19 @@ Mono<Response<CancelAllMediaOperationsResult>> cancelAllMediaOperationsWithRespo
* @return response for a successful add participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> addParticipant(
public Mono<AddParticipantResult> addParticipant(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext) {
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
InviteParticipantsRequest request = InviteParticipantRequestConverter.convert(participant,
AddParticipantRequest request = InviteParticipantRequestConverter.convert(participant,
alternateCallerId,
operationContext,
null);
return callConnectionInternal.inviteParticipantsAsync(callConnectionId, request)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
return callConnectionInternal.addParticipantAsync(callConnectionId, request)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(result -> Mono.just(new AddParticipantResult(result.getParticipantId())));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand All @@ -370,28 +371,30 @@ public Mono<Void> addParticipant(
* @return response for a successful add participant request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> addParticipantWithResponse(
public Mono<Response<AddParticipantResult>> addParticipantWithResponse(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext) {
return addParticipantWithResponse(participant, alternateCallerId, operationContext, null);
}

Mono<Response<Void>> addParticipantWithResponse(
Mono<Response<AddParticipantResult>> addParticipantWithResponse(
CommunicationIdentifier participant,
String alternateCallerId,
String operationContext,
Context context) {
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
InviteParticipantsRequest request =
AddParticipantRequest request =
InviteParticipantRequestConverter
.convert(participant, alternateCallerId, operationContext, null);
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return callConnectionInternal
.inviteParticipantsWithResponseAsync(callConnectionId, request, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.addParticipantWithResponseAsync(callConnectionId, request, contextValue)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response ->
new SimpleResponse<>(response, new AddParticipantResult(response.getValue().getParticipantId())));
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -408,7 +411,7 @@ Mono<Response<Void>> addParticipantWithResponse(
public Mono<Void> removeParticipant(String participantId) {
try {
return callConnectionInternal.removeParticipantAsync(callConnectionId, participantId)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand All @@ -431,7 +434,7 @@ Mono<Response<Void>> removeParticipantWithResponse(String participantId, Context
contextValue = context == null ? contextValue : context;
return callConnectionInternal
.removeParticipantWithResponseAsync(callConnectionId, participantId, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException);
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import com.azure.communication.callingserver.implementation.CallConnectionsImpl;
import com.azure.communication.callingserver.implementation.ServerCallsImpl;
import com.azure.communication.callingserver.implementation.converters.CallConnectionRequestConverter;
import com.azure.communication.callingserver.implementation.converters.JoinCallRequestConverter;
import com.azure.communication.callingserver.implementation.converters.CallingServerErrorConverter;
import com.azure.communication.callingserver.implementation.models.CommunicationErrorException;
import com.azure.communication.callingserver.implementation.converters.JoinCallRequestConverter;
import com.azure.communication.callingserver.implementation.models.CommunicationErrorResponseException;
import com.azure.communication.callingserver.implementation.models.CreateCallRequest;
import com.azure.communication.callingserver.models.CreateCallOptions;
import com.azure.communication.callingserver.models.JoinCallOptions;
Expand Down Expand Up @@ -90,7 +90,7 @@ public Mono<CallConnectionAsync> createCallConnection(
Objects.requireNonNull(createCallOptions, "'createCallOptions' cannot be null.");
CreateCallRequest request = CallConnectionRequestConverter.convert(source, targets, createCallOptions);
return callConnectionInternal.createCallAsync(request)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(response -> Mono.just(new CallConnectionAsync(response.getCallConnectionId(), callConnectionInternal)));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -116,7 +116,7 @@ public Mono<Response<CallConnectionAsync>> createCallConnectionWithResponse(
Objects.requireNonNull(createCallOptions, "'CreateCallOptions' cannot be null.");
CreateCallRequest request = CallConnectionRequestConverter.convert(source, targets, createCallOptions);
return callConnectionInternal.createCallWithResponseAsync(request)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response -> new SimpleResponse<>(response, new CallConnectionAsync(response.getValue().getCallConnectionId(), callConnectionInternal)));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -133,7 +133,7 @@ Mono<CallConnection> createCallConnectionInternal(
Objects.requireNonNull(createCallOptions, "'createCallOptions' cannot be null.");
CreateCallRequest request = CallConnectionRequestConverter.convert(source, targets, createCallOptions);
return callConnectionInternal.createCallAsync(request)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(response -> Mono.just(new CallConnection(new CallConnectionAsync(response.getCallConnectionId(), callConnectionInternal))));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -153,7 +153,7 @@ Mono<Response<CallConnection>> createCallConnectionWithResponseInternal(
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return callConnectionInternal.createCallWithResponseAsync(request, contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response -> new SimpleResponse<>(response,
new CallConnection(new CallConnectionAsync(response.getValue().getCallConnectionId(), callConnectionInternal))));
});
Expand All @@ -180,7 +180,7 @@ public Mono<CallConnectionAsync> join(
Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null.");
return serverCallInternal
.joinCallAsync(serverCallId, JoinCallRequestConverter.convert(source, joinCallOptions))
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(response -> Mono.just(new CallConnectionAsync(response.getCallConnectionId(), callConnectionInternal)));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand All @@ -205,7 +205,7 @@ public Mono<CallConnectionAsync> join(
Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null.");
return serverCallInternal.
joinCallWithResponseAsync(serverCallId, JoinCallRequestConverter.convert(source, joinCallOptions))
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response -> new SimpleResponse<>(response,
new CallConnectionAsync(response.getValue().getCallConnectionId(), callConnectionInternal)));
} catch (RuntimeException ex) {
Expand All @@ -222,7 +222,7 @@ Mono<CallConnection> joinInternal(
Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null.");
return serverCallInternal
.joinCallAsync(serverCallId, JoinCallRequestConverter.convert(source, joinCallOptions))
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.flatMap(response ->
Mono.just(new CallConnection(new CallConnectionAsync(response.getCallConnectionId(),
callConnectionInternal))));
Expand All @@ -244,7 +244,7 @@ Mono<CallConnection> joinInternal(
contextValue = context == null ? contextValue : context;
return serverCallInternal
.joinCallWithResponseAsync(serverCallId, JoinCallRequestConverter.convert(source, joinCallOptions), contextValue)
.onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException)
.onErrorMap(CommunicationErrorResponseException.class, CallingServerErrorConverter::translateException)
.map(response ->
new SimpleResponse<>(
response,
Expand Down
Loading

0 comments on commit 3430944

Please sign in to comment.