Skip to content

Commit

Permalink
#1 - Added content encoding support
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed Jul 2, 2024
1 parent ce8dc77 commit 4a632dc
Show file tree
Hide file tree
Showing 149 changed files with 218 additions and 163 deletions.
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ lazy val oni = project
circeGeneric,
circeParser,
commonsCodec,
helidonEncodingDeflate,
helidonEncodingGzip,
hibernateCore,
hibernateEnvers,
hibernateHikari,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ object TestEntityFactory:
entity.setRankLevel(Strings.random(6))
entity.setRankName(Strings.random(12))

if random.nextBoolean() then
entity.setAphiaId(random.nextLong(100000000))
if random.nextBoolean() then entity.setAphiaId(random.nextLong(100000000))

// DON'T DO THIS. The ID should be assigned by the database. Otherwise inserts will fail.
// entity.setId(nextConceptId.incrementAndGet())
Expand Down
25 changes: 12 additions & 13 deletions it/src/main/scala/org/mbari/oni/services/ConceptServiceSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ trait ConceptServiceSuite extends DatabaseFunSuite with UserAuthMixin:
yield updatedChild
)


attempt match
case Left(e) =>
fail("Failed to update")
Expand All @@ -292,7 +291,8 @@ trait ConceptServiceSuite extends DatabaseFunSuite with UserAuthMixin:
test("update parent") {

val root = TestEntityFactory.buildRoot(3)
val grandChild = root.getChildConcepts
val grandChild = root
.getChildConcepts
.iterator()
.next()
.getChildConcepts
Expand Down Expand Up @@ -330,8 +330,9 @@ trait ConceptServiceSuite extends DatabaseFunSuite with UserAuthMixin:
}

test("update (parent multiple times)") {
val root = TestEntityFactory.buildRoot(5)
val grandChild = root.getChildConcepts
val root = TestEntityFactory.buildRoot(5)
val grandChild = root
.getChildConcepts
.iterator()
.next()
.getChildConcepts
Expand All @@ -344,30 +345,28 @@ trait ConceptServiceSuite extends DatabaseFunSuite with UserAuthMixin:

val attempt = runWithUserAuth(user =>
for
rootEntity <- conceptService.init(root)
grandChildEntity <- Right(grandChild)
updatedGrandChild1 <- conceptService.update( grandChildEntity.getName, update1, user.username)
updatedGrandChild2 <- conceptService.update( grandChildEntity.getName, update2, user.username)

rootEntity <- conceptService.init(root)
grandChildEntity <- Right(grandChild)
updatedGrandChild1 <- conceptService.update(grandChildEntity.getName, update1, user.username)
updatedGrandChild2 <- conceptService.update(grandChildEntity.getName, update2, user.username)
yield updatedGrandChild2
)

attempt match
case Left(e) =>
case Left(e) =>
fail("Failed to update")
case Right(grandChild) =>
conceptService.findParentByChildName(grandChild.name) match
case Left(e) =>
case Left(e) =>
fail("Failed to find parent")
case Right(found) =>
assertEquals(found.name, childsParent.getName)
historyService.findByConceptName(grandChild.name) match
case Left(e) =>
case Left(e) =>
fail("Failed to find history")
case Right(found) =>
assertEquals(found.size, 2)


}

test("delete") {
Expand Down
1 change: 1 addition & 0 deletions oni/src/docs/_docs/development/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ This is a normal [sbt](https://www.scala-sbt.org) project. You can compile code
Documentation can be added as markdown files in `docs` and will be included automatically when you run `scaladoc`.

When updating SBT version, make sure to update the devcontainer image in [devcontainer.json](.devcontainer/devcontainer.json). It's versions are `eclipse-temurin-<java.version>_<sbt.version>_<scala.version>`

32 changes: 32 additions & 0 deletions oni/src/docs/_docs/development/nima.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# nima

Oni uses Helidon's Webserver (aka Nima) to serve the web application.

## Supporting gzip

From [Slack](https://helidon.slack.com/archives/CCS216A5A/p1719928229654769?thread_ts=1719792358.413759&cid=CCS216A5A)

ne way (and probably the easiest way) would be to simply add the following dependencies. These will be automatically discovered and used. It is not needed to do anything else.

```xml
<!-- gzip -->
<dependency>
<groupId>io.helidon.http.encoding</groupId>
<artifactId>helidon-http-encoding-gzip</artifactId>
</dependency>
<!-- deflate -->
<dependency>
<groupId>io.helidon.http.encoding</groupId>
<artifactId>helidon-http-encoding-deflate</artifactId>
</dependency>
```

Other way, if you would not want it to be automatically discovered and you would want to do it programatically yourselft would be to use something like this:

```java
WebServer.builder()
.contentEncoding(encodingBuilder -> encodingBuilder.contentEncodingsDiscoverServices(false)
.addContentEncoding(GzipEncoding.create())
.addContentEncoding(DeflateEncoding.create()))
```
But even for that you need the above dependencies.
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/VARSException.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/ConceptNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/ConceptTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/ILink.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/LinkComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/LinkNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/LinkUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/MediaNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/MediaTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/Msg.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/NamedMedia.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/domain/PhylogenyNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.etc.jdk;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/etc/jdk/Logging.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.etc.jdk;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/etc/jdk/Preconditions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.etc.jdk;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/jpa/IPersistentObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jpa;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/jpa/KeyNullifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jpa;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/jpa/TransactionLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jpa;
Expand Down
2 changes: 1 addition & 1 deletion oni/src/main/java/org/mbari/oni/jpa/URIConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jpa;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jpa;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jpa.entities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jpa.entities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jpa.entities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jpa.entities;
Expand Down
Loading

0 comments on commit 4a632dc

Please sign in to comment.