Exemplo n.º 1
0
        public void SetLicenseMetadata_ToNoLicenseUrl_OriginalHasLicenseUrlInEn_ClearsEn()
        {
            string dataDivContent         = @"<div lang='en' data-book='licenseUrl'>http://creativecommons.org/licenses/by-nc-sa/3.0/</div>";
            var    dom                    = MakeDom(dataDivContent);
            var    collectionSettings     = new CollectionSettings();
            var    bookData               = new BookData(dom, collectionSettings, null);
            var    creativeCommonsLicense = (CreativeCommonsLicense)(BookCopyrightAndLicense.GetMetadata(dom, bookData).License);

            Assert.IsTrue(creativeCommonsLicense.AttributionRequired);             // yes, we got a CC license from the 'en' licenseUrl
            var newLicense  = new CustomLicense();
            var newMetaData = new Metadata();

            newMetaData.License = newLicense;
            BookCopyrightAndLicense.SetMetadata(newMetaData, dom, null, bookData, false);
            AssertThatXmlIn.Dom(dom.RawDom).HasNoMatchForXpath("//div[@data-book='licenseUrl']");
        }
        public CustomLicense Add(int applicationId, int schemaId, MemoryStream stream, string mimeType, string fileName, LoggedInUserDetails user)
        {
            // Check access
            _security.CheckAccessToApplication(user, applicationId);

            // Setup data
            var customLicense = new CustomLicense
            {
                Content   = stream.ToArray(),
                CreatedBy = user.ID.Value,
                MimeType  = mimeType,
                FileName  = fileName,
                CreatedAt = GetDate
            };

            // Save custom license
            _customLicenses.Add(customLicense);

            // Create org license for custom license
            CreateOrganisationLicense(applicationId, schemaId, user, customLicense.ID);

            // Return result
            return(customLicense);
        }