diff --git a/readium/opds/src/test/java/org/readium/r2/opds/OPDS1ParserTest.kt b/readium/opds/src/test/java/org/readium/r2/opds/OPDS1ParserTest.kt index 06ec4c5bcf..c748060409 100644 --- a/readium/opds/src/test/java/org/readium/r2/opds/OPDS1ParserTest.kt +++ b/readium/opds/src/test/java/org/readium/r2/opds/OPDS1ParserTest.kt @@ -2,7 +2,6 @@ package org.readium.r2.opds import java.util.* import org.joda.time.DateTime -import org.json.JSONObject import org.junit.Assert.* import org.junit.Test import org.junit.runner.RunWith @@ -223,7 +222,7 @@ class OPDS1ParserTest { ) ) ).toJSON(), - JSONObject(feed.publications[0].jsonManifest) + feed.publications[0].manifest.toJSON() ) assertJSONEquals( @@ -282,7 +281,7 @@ class OPDS1ParserTest { ) ) ).toJSON(), - JSONObject(feed.publications[1].jsonManifest) + feed.publications[1].manifest.toJSON() ) } @@ -356,7 +355,7 @@ class OPDS1ParserTest { ) ) ).toJSON(), - JSONObject(publication!!.jsonManifest) + publication!!.manifest.toJSON() ) } diff --git a/readium/shared/src/main/java/org/readium/r2/shared/publication/Publication.kt b/readium/shared/src/main/java/org/readium/r2/shared/publication/Publication.kt index 6c7bddecd1..a8e6309142 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/publication/Publication.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/publication/Publication.kt @@ -77,33 +77,33 @@ public class Publication( public var cssStyle: String? = null ) : PublicationServicesHolder { - private val _manifest: Manifest + public val manifest: Manifest private val services = ListPublicationServicesHolder() init { services.services = servicesBuilder.build(Service.Context(manifest, container, services)) - _manifest = manifest.copy( + this.manifest = manifest.copy( links = manifest.links + services.services.map(Service::links).flatten() ) } // Shortcuts to manifest properties - public val context: List get() = _manifest.context - public val metadata: Metadata get() = _manifest.metadata - public val links: List get() = _manifest.links + public val context: List get() = manifest.context + public val metadata: Metadata get() = manifest.metadata + public val links: List get() = manifest.links /** Identifies a list of resources in reading order for the publication. */ - public val readingOrder: List get() = _manifest.readingOrder + public val readingOrder: List get() = manifest.readingOrder /** Identifies resources that are necessary for rendering the publication. */ - public val resources: List get() = _manifest.resources + public val resources: List get() = manifest.resources /** Identifies the collection that contains a table of contents. */ - public val tableOfContents: List get() = _manifest.tableOfContents + public val tableOfContents: List get() = manifest.tableOfContents - public val subcollections: Map> get() = _manifest.subcollections + public val subcollections: Map> get() = manifest.subcollections @Deprecated( "Use conformsTo() to check the kind of a publication.", @@ -117,8 +117,13 @@ public class Publication( /** * Returns the RWPM JSON representation for this [Publication]'s manifest, as a string. */ + @Deprecated( + "Jsonify the manifest by yourself.", + replaceWith = ReplaceWith("""manifest.toJSON().toString().replace("\\/", "/")"""), + DeprecationLevel.ERROR + ) public val jsonManifest: String - get() = _manifest.toJSON().toString().replace("\\/", "/") + get() = manifest.toJSON().toString().replace("\\/", "/") /** * The URL from which the publication resources are relative to, computed from the [Link] with @@ -158,7 +163,7 @@ public class Publication( * Returns whether this publication conforms to the given Readium Web Publication Profile. */ public fun conformsTo(profile: Profile): Boolean = - _manifest.conformsTo(profile) + manifest.conformsTo(profile) /** * Finds the first [Link] with the given HREF in the publication's links. @@ -169,24 +174,24 @@ public class Publication( * If there's no match, tries again after removing any query parameter and anchor from the * given [href]. */ - public fun linkWithHref(href: Url): Link? = _manifest.linkWithHref(href) + public fun linkWithHref(href: Url): Link? = manifest.linkWithHref(href) /** * Finds the first [Link] having the given [rel] in the publications's links. */ - public fun linkWithRel(rel: String): Link? = _manifest.linkWithRel(rel) + public fun linkWithRel(rel: String): Link? = manifest.linkWithRel(rel) /** * Finds all [Link]s having the given [rel] in the publications's links. */ - public fun linksWithRel(rel: String): List = _manifest.linksWithRel(rel) + public fun linksWithRel(rel: String): List = manifest.linksWithRel(rel) /** * Creates a new [Locator] object from a [Link] to a resource of this publication. * * Returns null if the resource is not found in this publication. */ - public fun locatorFromLink(link: Link): Locator? = _manifest.locatorFromLink(link) + public fun locatorFromLink(link: Link): Locator? = manifest.locatorFromLink(link) /** * Returns the resource targeted by the given non-templated [link]. @@ -672,11 +677,11 @@ public class Publication( public fun link(predicate: (Link) -> Boolean): Link? = null @Deprecated( - "Use [jsonManifest] instead", - ReplaceWith("jsonManifest"), + "Jsonify the manifest by yourself", + ReplaceWith("manifest.toJSON()"), level = DeprecationLevel.ERROR ) - public fun toJSON(): JSONObject = JSONObject(jsonManifest) + public fun toJSON(): JSONObject = throw NotImplementedError() @Deprecated( "Use `metadata.effectiveReadingProgression` instead", diff --git a/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationAdapter.kt b/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationAdapter.kt index 4f2a339b50..27e58b224b 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationAdapter.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/catalogs/PublicationAdapter.kt @@ -77,7 +77,7 @@ class PublicationAdapter( oldItem: Publication, newItem: Publication ): Boolean { - return oldItem.jsonManifest == newItem.jsonManifest + return oldItem.manifest == newItem.manifest } } }