diff --git a/restcomm/restcomm.application/src/main/webapp/WEB-INF/conf/restcomm.xml b/restcomm/restcomm.application/src/main/webapp/WEB-INF/conf/restcomm.xml
index e808bcdaec..2965a210c1 100644
--- a/restcomm/restcomm.application/src/main/webapp/WEB-INF/conf/restcomm.xml
+++ b/restcomm/restcomm.application/src/main/webapp/WEB-INF/conf/restcomm.xml
@@ -322,8 +322,7 @@
-
A
+
+
-
-
3600
diff --git a/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/DnsProvisioningManager.java b/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/DnsProvisioningManager.java
index cf33efdbdc..ab516b189a 100644
--- a/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/DnsProvisioningManager.java
+++ b/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/DnsProvisioningManager.java
@@ -20,7 +20,6 @@
package org.restcomm.connect.dns;
import org.apache.commons.configuration.Configuration;
-import org.restcomm.connect.commons.patterns.StandardResponse;
public interface DnsProvisioningManager {
@@ -31,8 +30,43 @@ public interface DnsProvisioningManager {
*/
void init(Configuration dnsConfiguration);
- StandardResponse> createResourceRecord(final String name);
- StandardResponse> readResourceRecord();
- StandardResponse> updateResourceRecord();
- StandardResponse> deleteResourceRecord();
+ /**
+ * @param name The name of the domain you want to perform the action on.
+ * Enter a sub domain name only. For example to add 'company1.restcomm.com',
+ * provide only 'company1' and provide hosted zone for 'restcomm.com'
+ * @param hostedZoneId hostedZoneId The ID of the hosted zone that contains the resource record sets that you want to change.
+ * If none provided, then default will be used as per configuration
+ * @return true if operation successful, false otherwise.
+ */
+ boolean createResourceRecord(final String name, final String hostedZoneId);
+
+ /**
+ * @param name The name of the domain you want to perform the action on.
+ * Enter a sub domain name only. For example to add 'company1.restcomm.com',
+ * provide only 'company1' and provide hosted zone for 'restcomm.com'
+ * @param hostedZoneId hostedZoneId The ID of the hosted zone that contains the resource record sets that you want to change.
+ * If none provided, then default will be used as per configuration
+ * @return true if operation successful, false otherwise.
+ */
+ boolean readResourceRecord(final String name, final String hostedZoneId);
+
+ /**
+ * @param name The name of the domain you want to perform the action on.
+ * Enter a sub domain name only. For example to add 'company1.restcomm.com',
+ * provide only 'company1' and provide hosted zone for 'restcomm.com'
+ * @param hostedZoneId hostedZoneId The ID of the hosted zone that contains the resource record sets that you want to change.
+ * If none provided, then default will be used as per configuration
+ * @return true if operation successful, false otherwise.
+ */
+ boolean updateResourceRecord(final String name, final String hostedZoneId);
+
+ /**
+ * @param name The name of the domain you want to perform the action on.
+ * Enter a sub domain name only. For example to add 'company1.restcomm.com',
+ * provide only 'company1' and provide hosted zone for 'restcomm.com'
+ * @param hostedZoneId hostedZoneId The ID of the hosted zone that contains the resource record sets that you want to change.
+ * If none provided, then default will be used as per configuration
+ * @return true if operation successful, false otherwise.
+ */
+ boolean deleteResourceRecord(final String name, final String hostedZoneId);
}
diff --git a/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/DnsProvisioningManagerProvider.java b/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/DnsProvisioningManagerProvider.java
index 1865c6a589..4843f701f1 100644
--- a/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/DnsProvisioningManagerProvider.java
+++ b/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/DnsProvisioningManagerProvider.java
@@ -23,6 +23,7 @@
import javax.servlet.ServletContext;
import org.apache.commons.configuration.Configuration;
+import org.apache.log4j.Logger;
import org.restcomm.connect.commons.loader.ObjectFactory;
import org.restcomm.connect.commons.loader.ObjectInstantiationException;
@@ -32,6 +33,8 @@
* @author maria farooq
*/
public class DnsProvisioningManagerProvider {
+ protected Logger logger = Logger.getLogger(DnsProvisioningManagerProvider.class);
+
Configuration configuration;
ServletContext context;
@@ -40,9 +43,15 @@ public DnsProvisioningManagerProvider(Configuration configuration, ServletContex
this.context = context;
}
- public DnsProvisioningManager create() {
+ /**
+ * @return initialized instance of DnsProvisioningManager
+ */
+ private DnsProvisioningManager create() {
final String dnsProvisioningManagerClass = configuration.getString("dns-provisioning[@class]");
Configuration dnsProvisioningConfiguration = configuration.subset("dns-provisioning");
+ if(dnsProvisioningManagerClass == null || dnsProvisioningManagerClass.trim().equals("")){
+ return null;
+ }
DnsProvisioningManager dnsProvisioningManager;
try {
dnsProvisioningManager = (DnsProvisioningManager) new ObjectFactory(getClass().getClassLoader())
diff --git a/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/api/ResourceRecord.java b/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/api/ResourceRecord.java
deleted file mode 100644
index e7a222021d..0000000000
--- a/restcomm/restcomm.dns.api/src/main/java/org/restcomm/connect/dns/api/ResourceRecord.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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
- *
- */
-package org.restcomm.connect.dns.api;
-
-import org.restcomm.connect.commons.annotations.concurrency.Immutable;
-
-/**
- * @author maria.farooq@telestax.com
- */
-@Immutable
-public class ResourceRecord {
-
-}
diff --git a/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/OrganizationsEndpoint.java b/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/OrganizationsEndpoint.java
index d2b01b2e87..0c5d3b2061 100644
--- a/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/OrganizationsEndpoint.java
+++ b/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/OrganizationsEndpoint.java
@@ -43,15 +43,15 @@
import javax.ws.rs.core.UriInfo;
import org.apache.commons.configuration.Configuration;
+import org.joda.time.DateTime;
import org.restcomm.connect.commons.dao.Sid;
-import org.restcomm.connect.dao.entities.Account;
import org.restcomm.connect.dao.entities.Organization;
import org.restcomm.connect.dao.entities.OrganizationList;
import org.restcomm.connect.dao.entities.RestCommResponse;
import org.restcomm.connect.dns.DnsProvisioningManager;
import org.restcomm.connect.dns.DnsProvisioningManagerProvider;
-import org.restcomm.connect.http.converter.AccountConverter;
-import org.restcomm.connect.http.converter.AccountListConverter;
+import org.restcomm.connect.http.converter.OrganizationConverter;
+import org.restcomm.connect.http.converter.OrganizationListConverter;
import org.restcomm.connect.http.converter.RestCommResponseConverter;
import com.google.gson.Gson;
@@ -65,13 +65,14 @@ public class OrganizationsEndpoint extends SecuredEndpoint {
@Context
protected ServletContext context;
protected DnsProvisioningManager dnsProvisioningManager;
- protected Configuration runtimeConfiguration;
- protected Configuration rootConfiguration; // top-level configuration element
protected Gson gson;
protected XStream xstream;
private final String MSG_EMPTY_DOMAIN_NAME = "domain name can not be empty. Please, choose a valid name and try again.";
private final String MSG_INVALID_DOMAIN_NAME_PATTERN= "Total Length of domain_name can be upto 255 Characters. It can contain only letters, number and hyphen - sign.. Please, choose a valid name and try again.";
private final String MSG_DOMAIN_NAME_NOT_AVAILABLE = "This domain name is not available. Please, choose a different name and try again.";
+ private String DOMAIN_NAME_VALIDATION_PATTERN="[A-Za-z0-9\\-\\.]{1,255}";
+ private String SUB_DOMAIN_NAME_VALIDATION_PATTERN="[A-Za-z0-9\\-]{1,255}";
+ private OrganizationListConverter listConverter;
public OrganizationsEndpoint() {
super();
@@ -79,29 +80,41 @@ public OrganizationsEndpoint() {
// used for testing
public OrganizationsEndpoint(ServletContext context, HttpServletRequest request) {
- super(context,request);
+ super(context, request);
}
@PostConstruct
void init() {
- rootConfiguration = (Configuration) context.getAttribute(Configuration.class.getName());
- runtimeConfiguration = rootConfiguration.subset("runtime-settings");
- super.init(runtimeConfiguration);
- final AccountConverter converter = new AccountConverter(runtimeConfiguration);
+ configuration = (Configuration) context.getAttribute(Configuration.class.getName());
+ super.init(configuration.subset("runtime-settings"));
+
+ registerConverters();
+
+ // Make sure there is an authenticated account present when this endpoint is used
+ // get manager from context or create it if it does not exist
+ try {
+ dnsProvisioningManager = new DnsProvisioningManagerProvider(configuration, context).get();
+ } catch(Exception e) {
+ logger.error("Unable to get dnsProvisioningManager", e);
+ }
+ }
+
+ private void registerConverters(){
+ final OrganizationConverter converter = new OrganizationConverter(configuration);
+ listConverter = new OrganizationListConverter(configuration);
final GsonBuilder builder = new GsonBuilder();
- builder.registerTypeAdapter(Account.class, converter);
+ builder.serializeNulls();
+ builder.registerTypeAdapter(Organization.class, converter);
+ builder.registerTypeAdapter(OrganizationList.class, listConverter);
builder.setPrettyPrinting();
gson = builder.create();
xstream = new XStream();
xstream.alias("RestcommResponse", RestCommResponse.class);
xstream.registerConverter(converter);
- xstream.registerConverter(new AccountListConverter(runtimeConfiguration));
- xstream.registerConverter(new RestCommResponseConverter(runtimeConfiguration));
- // Make sure there is an authenticated account present when this endpoint is used
- // get manager from context or create it if it does not exist
- dnsProvisioningManager = new DnsProvisioningManagerProvider(configuration, context).get();
+ xstream.registerConverter(listConverter);
+ xstream.registerConverter(new RestCommResponseConverter(configuration));
}
-
+
/**
* @param organizationSid
* @param responseType
@@ -115,16 +128,16 @@ protected Response getOrganization(final String organizationSid, final MediaType
if (!Sid.pattern.matcher(organizationSid).matches()) {
return status(BAD_REQUEST).build();
- }else{
+ } else {
try {
//if account is not super admin then allow to read only affiliated organization
- if(!isSuperAdmin()){
- if(userIdentityContext.getEffectiveAccount().getOrganizationSid().equals(new Sid(organizationSid))){
+ if (!isSuperAdmin()) {
+ if (userIdentityContext.getEffectiveAccount().getOrganizationSid().equals(new Sid(organizationSid))) {
organization = organizationsDao.getOrganization(new Sid(organizationSid));
- }else{
+ } else {
return status(FORBIDDEN).build();
}
- }else{
+ } else {
organization = organizationsDao.getOrganization(new Sid(organizationSid));
}
} catch (Exception e) {
@@ -178,7 +191,7 @@ protected Response getOrganizations(UriInfo info, final MediaType responseType)
}
/**
- * putOrganization
+ * putOrganization create new organization
* @param domainName
* @param data
* @param applicationJsonType
@@ -193,7 +206,7 @@ protected Response putOrganization(String domainName, MultivaluedMap