class DomainServiceImpl implements DomainService, Constants {

	@Override
	public String createDomain(final CreateUpdateDomain createUpdateDomain, final String userId) throws PacManException {
		boolean isDomainExits = domainRepository.existsById(createUpdateDomain.getName());
		if(!isDomainExits) {
			Date currentDate = new Date();
			Domain domain = new Domain();
			domain.setDomainName(createUpdateDomain.getName());
			domain.setDomainDesc(createUpdateDomain.getDesc());
			domain.setConfig(createUpdateDomain.getConfig());
			domain.setModifiedDate(currentDate);
			domain.setCreatedDate(currentDate);
			domain.setUserId(userId);
			domainRepository.save(domain);
			return AdminConstants.DOMAIN_CREATION_SUCCESS;
			
		} else {
			throw new PacManException(AdminConstants.DOMAIN_NAME_EXITS);
		}
	}

}