Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
This resolve BS-156
  • Loading branch information
gvagenas committed Jun 29, 2018
1 parent e7b1e10 commit 42f99f1
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 54 deletions.
Expand Up @@ -75,9 +75,6 @@ public void startServices(ServletContext ctx) {

this.recordingService = new RecordingsServiceImpl(daoManager.getRecordingsDao(), s3AccessTool, ec, uriUtils);
ctx.setAttribute(RecordingService.class.getName(), recordingService);



}

/**
Expand Down
Expand Up @@ -141,7 +141,6 @@ public URI resolve(final URI uri, final Sid accountSid) {
}
}

//TODO Resolve based on Organization domain name
String base = selectedConnector.getScheme() + "://" + restcommAddress + ":" + selectedConnector.getPort();
try {
return resolveWithBase(new URI(base), uri);
Expand Down
Expand Up @@ -49,11 +49,6 @@ public MybatisRecordingsDao(final SqlSessionFactory sessions) {
this.sessions = sessions;
}

// public MybatisRecordingsDao(final SqlSessionFactory sessions, final String recordingPath) {
// super();
// this.sessions = sessions;
// }

@Override
public void addRecording(Recording recording) {
final SqlSession session = sessions.openSession();
Expand Down Expand Up @@ -227,40 +222,7 @@ private Recording toRecording(final Map<String, Object> map) {
// s3Uri: https://gvagrestcomm.s3.amazonaws.com/RE4c9c09908b60402c8c0a77e24313f27d.wav
// old S3URI: https://s3.amazonaws.com/restcomm-as-a-service/logs/RE7ddbd5b441574e4ab786a1fddf33eb47.wav?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20170209T103950Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=AKIAIRG5NINXKJAJM5DA%2F20170209%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=b3da2acc17ee9c6aca4cd151e154d94f530670850f0fcade2422f85d1c7cc992
String s3Uri = (String) map.get("s3_uri");
// if (fileUri.contains("s3.amazonaws.com") && s3AccessTool != null) {
// update = true;
// dateUpdated = DateTime.now();
// String tempUri = fileUri;
// String file = String.format("/restcomm/%s/Accounts/%s/Recordings/%s",apiVersion,accountSid,sid);
// String fileExtension = null;
// URI oldS3Uri = null;
// try {
// oldS3Uri = new URI(tempUri);
// } catch (URISyntaxException e) {
// e.printStackTrace();
// }
// if (oldS3Uri != null) {
// String tempS3Uri = oldS3Uri.getPath().replaceFirst("/","").replaceAll("/",",");
// String bucketName = tempS3Uri.split(",")[0].trim();
// String folder = tempS3Uri.split(",")[1].trim();
// String filename = tempS3Uri.split(",")[2].trim();
// fileExtension = filename.contains(".wav") ? ".wav" : ".mp4";
// StringBuffer bucket = new StringBuffer();
// bucket.append(bucketName);
// if (folder != null && !folder.isEmpty())
// bucket.append("/").append(folder);
// s3Uri = s3AccessTool.getS3client().getUrl(bucket.toString(), filename).toString();
// }
// if (fileExtension == null) {
// // assuming as WAV since previous attempt to obtain fileExtension failed
// fileExtension = ".wav";
// }
// fileUri = generateLocalFileUri(file, fileExtension).toString();
// }
recording = new Recording(sid, dateCreated, dateUpdated, accountSid, callSid, duration, apiVersion, uri, DaoUtils.readUri(fileUri), DaoUtils.readUri(s3Uri));
// if (update) {
// updateRecording(recording);
// }
return recording;
}

Expand Down
Expand Up @@ -327,8 +327,6 @@ protected Response getRecordingFile (String accountSid, String sid) {
return ok(recordingUri.toURL().openStream(), contentType).build();
}
} else {
// String recFile = "/restcomm/recordings/" + recording.getSid() + ".wav";
// recordingUri = UriUtils.resolveWithBase(new URI(recFile));
String path = configuration.getString("recordings-path");
if (!path.endsWith("/")) {
path += "/";
Expand Down
1 change: 1 addition & 0 deletions restcomm/restcomm.interpreter/pom.xml
Expand Up @@ -190,6 +190,7 @@
<dependency>
<groupId>org.restcomm</groupId>
<artifactId>restcomm-connect.core</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>
Expand Down
Expand Up @@ -75,7 +75,7 @@ public RcmlserverResolver(String rvdOrigin, String apiPath) {
filterPrefix = null;
}

// if rvdOrigin is null no point in trying to resolveWithBase RVD location. We will return passed uri instead
// if rvdOrigin is null no point in trying to resolve RVD location. We will return passed uri instead
public URI resolveRelative(URI uri) {
if (uri != null && rvdOrigin != null && filterPrefix != null) {
if (uri.isAbsolute())
Expand All @@ -85,7 +85,7 @@ public URI resolveRelative(URI uri) {
if (uriString.startsWith(filterPrefix))
return new URI(rvdOrigin + uri.toString());
} catch (URISyntaxException e) {
logger.error("Cannot resolveWithBase uri: " + uri.toString() + ". Ignoring...", e);
logger.error("Cannot resolve uri: " + uri.toString() + ". Ignoring...", e);
}
}
return uri;
Expand Down
Expand Up @@ -675,7 +675,7 @@ private void onConferenceResponse(Object message) throws TransitionFailedExcepti
path += exitAudio == null || exitAudio.equals("") ? "alert.wav" : exitAudio;
URI uri = null;
try {
uri = uriUtils.resolve(new URI(path));
uri = uriUtils.resolve(new URI(path), accountId);
} catch (final Exception exception) {
final Notification notification = notification(ERROR_NOTIFICATION, 12400, exception.getMessage());
final NotificationsDao notifications = storage.getNotificationsDao();
Expand Down Expand Up @@ -3231,7 +3231,7 @@ protected void playBeepOnEnter(ActorRef source){
path += entryAudio == null || entryAudio.equals("") ? "beep.wav" : entryAudio;
URI uri = null;
try {
uri = uriUtils.resolve(new URI(path));
uri = uriUtils.resolve(new URI(path), accountId);
} catch (final Exception exception) {
final Notification notification = notification(ERROR_NOTIFICATION, 12400, exception.getMessage());
final NotificationsDao notifications = storage.getNotificationsDao();
Expand Down Expand Up @@ -3557,7 +3557,7 @@ private ActorRef buildSubVoiceInterpreter(Tag child) throws MalformedURLExceptio
final URI base = request.getUri();
url = uriUtils.resolveWithBase(base, new URI(child.attribute("url").value()));
} else {
url = uriUtils.resolve(new URI(child.attribute("url").value()));
url = uriUtils.resolve(new URI(child.attribute("url").value()), accountId);
}
String method;
if (child.hasAttribute("method")) {
Expand Down
Expand Up @@ -612,11 +612,6 @@ public synchronized void testRecordCallWithAction() throws InterruptedException,
assertEquals(1,liveCalls);
assertEquals(1, liveCallsArraySize);

// Thread.sleep(3000);
// bobCall.disconnect();
//
// Thread.sleep(7000);

bobCall.listenForDisconnect();

Thread.sleep(8000);
Expand Down

0 comments on commit 42f99f1

Please sign in to comment.