Skip to content

Commit

Permalink
Merge pull request #2980 from RestComm/bs-156
Browse files Browse the repository at this point in the history
Support custom domains for REST API
  • Loading branch information
gvagenas committed Jul 2, 2018
2 parents 431be6e + 8a2c8a0 commit bfaedaf
Show file tree
Hide file tree
Showing 55 changed files with 1,683 additions and 644 deletions.
Expand Up @@ -37,6 +37,7 @@
import org.restcomm.connect.commons.loader.ObjectFactory;
import org.restcomm.connect.commons.loader.ObjectInstantiationException;
import org.restcomm.connect.commons.util.DNSUtils;
import org.restcomm.connect.core.service.RestcommConnectServiceProvider;
import org.restcomm.connect.dao.DaoManager;
import org.restcomm.connect.dao.entities.InstanceId;
import org.restcomm.connect.dao.entities.Organization;
Expand Down Expand Up @@ -233,10 +234,10 @@ private String home(final ServletContext context) {
}
}

private DaoManager storage(final Configuration configuration, Configuration daoManagerConfiguration, S3AccessTool s3AccessTool, final ClassLoader loader, final ExecutionContext ec) throws ObjectInstantiationException {
private DaoManager storage(final Configuration configuration, Configuration daoManagerConfiguration, final ClassLoader loader) throws ObjectInstantiationException {
final String classpath = daoManagerConfiguration.getString("dao-manager[@class]");
final DaoManager daoManager = (DaoManager) new ObjectFactory(loader).getObjectInstance(classpath);
daoManager.configure(configuration, daoManagerConfiguration, s3AccessTool, ec);
daoManager.configure(configuration, daoManagerConfiguration);
daoManager.start();
return daoManager;
}
Expand Down Expand Up @@ -409,14 +410,15 @@ public void servletInitialized(SipServletContextEvent event) {
// Share the actor system with other servlets.
context.setAttribute(ActorSystem.class.getName(), system);
ec = system.dispatchers().lookup("restcomm-blocking-dispatcher");
context.setAttribute(ExecutionContext.class.getName(), ec);

S3AccessTool s3AccessTool = prepareS3AccessTool(xml);
context.setAttribute(S3AccessTool.class.getName(), s3AccessTool);

// Create the storage system.
DaoManager storage = null;
try {
storage = storage(xml, daoManagerConf, s3AccessTool, loader, ec);
storage = storage(xml, daoManagerConf, loader);
} catch (final ObjectInstantiationException exception) {
logger.error("ObjectInstantiationException during initialization: ", exception);
}
Expand Down
Expand Up @@ -20,12 +20,10 @@
package org.restcomm.connect.commons;

import org.apache.commons.configuration.Configuration;
import org.restcomm.connect.commons.amazonS3.S3AccessTool;
import scala.concurrent.ExecutionContext;

/**
* @author quintana.thomas@gmail.com (Thomas Quintana)
*/
public interface Configurable {
void configure(Configuration configuration, Configuration daoManagerConfiguration, S3AccessTool s3AccessTool, ExecutionContext ec);
void configure(Configuration configuration, Configuration daoManagerConfiguration);
}

This file was deleted.

This file was deleted.

7 changes: 6 additions & 1 deletion restcomm/restcomm.core/pom.xml
Expand Up @@ -31,6 +31,11 @@
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
@@ -1,24 +1,22 @@
/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2018, Telestax Inc and individual contributors
* by the @authors tag.
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2018, 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 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 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.
* 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 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.
* 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.application;
package org.restcomm.connect.core.service;

import javax.servlet.ServletContext;

Expand All @@ -31,7 +29,9 @@
import org.restcomm.connect.core.service.number.NumberSelectorServiceImpl;
import org.restcomm.connect.core.service.profile.ProfileServiceImpl;
import org.restcomm.connect.core.service.recording.RecordingsServiceImpl;
import org.restcomm.connect.core.service.util.UriUtils;
import org.restcomm.connect.dao.DaoManager;
import scala.concurrent.ExecutionContext;

/**
* @author guilherme.jansen@telestax.com
Expand All @@ -45,6 +45,7 @@ public class RestcommConnectServiceProvider {
private ProfileService profileService;
private ClientPasswordHashingService clientPasswordHashingService;
private RecordingService recordingService;
private UriUtils uriUtils;

public static RestcommConnectServiceProvider getInstance() {
if (instance == null) {
Expand All @@ -67,8 +68,12 @@ public void startServices(ServletContext ctx) {
ctx.setAttribute(ClientPasswordHashingService.class.getName(), clientPasswordHashingService);

S3AccessTool s3AccessTool = (S3AccessTool) ctx.getAttribute(S3AccessTool.class.getName());
ExecutionContext ec = (ExecutionContext) ctx.getAttribute(ExecutionContext.class.getName());

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

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

Expand Down Expand Up @@ -96,4 +101,15 @@ public ProfileService provideProfileService() {
*/
public RecordingService recordingService() { return recordingService; }

/**
*
* @return
*/
public UriUtils uriUtils() { return uriUtils; }

//Used for unit testing - not elegant way though
public void setUriUtils(UriUtils uriUtils) {
this.uriUtils = uriUtils;
}

}
Expand Up @@ -20,9 +20,35 @@
package org.restcomm.connect.core.service.api;

import org.restcomm.connect.commons.dao.Sid;
import org.restcomm.connect.dao.entities.MediaAttributes;

import java.net.URI;

public interface RecordingService {

/**
* Upload recording file to Amazon S3
* @param recordingSid
* @param mediaType
* @return
*/
URI storeRecording(Sid recordingSid, MediaAttributes.MediaType mediaType);

/**
* Prepare Recording URL to store in the Recording.fileUrl property.
* This will be used later to access the recording file
* @param apiVersion
* @param accountSid
* @param recordingSid
* @param mediaType
* @return
*/
URI prepareFileUrl (String apiVersion, String accountSid, String recordingSid, MediaAttributes.MediaType mediaType);

/**
*Remove recording file from Amazon S3
* @param recordingSid
*/
void removeRecording(Sid recordingSid);

}

0 comments on commit bfaedaf

Please sign in to comment.