@Override
public void setupRemoteCall(String remoteAppURL, String methodCode, RemoteCallFormat format, Charset charset)
throws UnifyException {
logDebug("Setting up remote call with code = [{0}], remoteAppURL = [{1}]...", methodCode, remoteAppURL);
if (preferences.isKey(remoteAppURL, methodCode)) {
throw new UnifyException(UnifyWebErrorConstants.REMOTECALL_CLIENT_SETUP_CODE_EXISTS, remoteAppURL,
methodCode);
}
logDebug("Discovering remote call method with code [{0}] for remote application [{1}]...", methodCode,
remoteAppURL);
String discoveryURL = getDiscoveryURL(remoteAppURL);
if (!isRemoteCallSetup(discoveryURL, APIDiscoveryRemoteCallCodeConstants.DISCOVER_REMOTE_CALL)) {
preferences.get(discoveryURL, APIDiscoveryRemoteCallCodeConstants.DISCOVER_REMOTE_CALL, discoveryURL,
RemoteCallFormat.JSON, StandardCharsets.UTF_8);
}
DiscoverRemoteCallResult result =
remoteCall(DiscoverRemoteCallResult.class, discoveryURL, new DiscoverRemoteCallParams(methodCode));
checkError(result);
preferences.get(remoteAppURL, methodCode, result.getRemoteCallInfo().getUrl(), format, charset);
logDebug("...remote call setup completed.");
}