public void Publish(int id, int appId, int schemaId, LoggedInUserDetails user)
        {
            // Check access
            _security.CheckBasicAccess(user);

            // Check whether organisation is active
            if (!user.Organization.IsActive)
            {
                throw new BaseException(orgIsInactiveError);
            }

            // Get license
            var license = _service.FirstOrDefault(i => i.ID == id);

            // Get published license
            var licenses = _service.Where(i => i.ApplicationID == appId)
                           .Where(i => i.Status == (int)PublishStatus.Published && i.DataSchemaID == schemaId);

            // Check whether published license alredy present
            if (licenses.Any())
            {
                throw new BaseException("You can't publish if published license already exists.");
            }

            // Check whether license is ready to be published
            if (license.Status != (int)PublishStatus.ReadyToPublish)
            {
                throw new BaseException("Only ready to publish licenses can be published.");
            }

            // Update details
            license.Status      = (int)PublishStatus.Published;
            license.PublishedAt = GetDate;
            license.PublishedBy = user.ID.Value;

            // Save changes
            _service.Update(license);

            // Setup url to download license
            //var linkToDownloadLicense = _urls.ToDownloadLicense(appId, schemaId, id);
            var linkToDownloadLicense = _urls.ToDownloadLicenseView(appId, schemaId, id);

            // Send notification about new data provider
            if (license.ProviderEndpointID != 0)
            {
                _notificationService.User.NewProviderLicenseInBackground(license.ID, appId, linkToDownloadLicense);
            }
        }