private Domain getDomainForName(String name) { Domain domain = null; if (StringUtils.isNotBlank(name)) { //removing all the special characters and trimming its length to 190 to make the domain valid. String domainName = StringUtils.substring(name.replaceAll("\\W", ""), 0, 190); if (StringUtils.isNotBlank(domainName)) { domain = _domainService.getDomainByName(domainName, Domain.ROOT_DOMAIN); if (domain == null) { domain = _domainService.createDomain(domainName, Domain.ROOT_DOMAIN, domainName, UUID.randomUUID().toString()); } } } return domain; }
@Override public void execute() { CallContext.current().setEventDetails("Domain Name: " + getDomainName() + ((getParentDomainId() != null) ? ", Parent DomainId :" + getParentDomainId() : "")); Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID()); if (domain != null) { DomainResponse response = _responseGenerator.createDomainResponse(domain); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create domain"); } } }
@Override public void execute() { CallContext.current().setEventDetails("Domain Name: " + getDomainName() + ((getParentDomainId() != null) ? ", Parent DomainId :" + getParentDomainId() : "")); final Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID(), getEmail()); if (domain != null) { final DomainResponse response = _responseGenerator.createDomainResponse(domain); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create domain"); } }