diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a01ea2e..b4da511a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [2.125.1](https://github.com/open-horizon/exchange-api/pull/725) - 2024-10-22 +- Issue 724: Version conflicts in library(pekko-http) dependencies +- pekko-http 1.0.1 -> 1.1.0 +- pekko-http-jackson 2.3.3 -> 3.0.0 +- pekko-http-cors 1.0.1 -> 1.1.0 +- pekko-slf4j 1.0.1 -> 1.1.1 +- swagger-pekko-http 2.12.0 -> 2.14.0 +- Fixed warnings + ## [2.125.0](https://github.com/open-horizon/exchange-api/pull/720) - 2024-09-30 - Removed support for TLS v1.2. - Removed an API key authentication pathway. diff --git a/build.sbt b/build.sbt index 90677af2..cc969194 100644 --- a/build.sbt +++ b/build.sbt @@ -33,7 +33,7 @@ lazy val root = (project in file(".")) description := "'Containerized exchange-api'", name := "amd64_exchange-api", organization := "org.openhorizon", - pekkoHttpVersion := "[1.0.1]", + pekkoHttpVersion := "[1.1.0]", pekkoVersion := "[1.0.2]", release := sys.env.getOrElse("GIT_SHORT_SHA", versionFunc()), resolvers += Classpaths.typesafeReleases, @@ -51,16 +51,16 @@ lazy val root = (project in file(".")) "org.apache.pekko" %% "pekko-http-xml" % pekkoHttpVersion.value, // "org.apache.pekko" %% "pekko-stream" % "[2.6.14,)", // "org.apache.pekko" %% "pekko-http-spray-json" % "[10.2.1,)", - "com.github.pjfanning" %% "pekko-http-jackson" % "[2.3.3,)", - "org.apache.pekko" %% "pekko-http-cors" % "[1.0.0]", - "org.apache.pekko" %% "pekko-slf4j" % "[1.0.1]", - + "com.github.pjfanning" %% "pekko-http-jackson" % "[3.0.0,)", + "org.apache.pekko" %% "pekko-http-cors" % "[1.1.0]", + "org.apache.pekko" %% "pekko-slf4j" % "[1.1.1]", + "org.json4s" %% "json4s-native" % "4.0.6", "org.json4s" %% "json4s-jackson" % "4.0.6", "jakarta.ws.rs" % "jakarta.ws.rs-api" % "[3.1.0]", // "org.glassfish.jersey.core" % "jersey-common" % "1.2.1", // Required at runtime by javax.ws.rs-api - "com.github.swagger-akka-http" %% "swagger-pekko-http" % "[2.12.0]", // Deprecated in v2.8.0 due to Akka license change to BSL v1.1 + "com.github.swagger-akka-http" %% "swagger-pekko-http" % "[2.14.0]", "com.github.swagger-akka-http" %% "swagger-scala-module" % "[2.12.0,)", //"io.swagger.core.v3" % "swagger-core-jakarta" % "[2.1.12]", // Version 2.1.13+ requires newer versions of slick and slick-hikaricp //"io.swagger.core.v3" % "swagger-jaxrs2-jakarta" % "[2.1.12]", // Version 2.1.13+ requires newer versions of slick and slick-hikaricp diff --git a/docs/QuickStart.md b/docs/QuickStart.md new file mode 100644 index 00000000..01ad858b --- /dev/null +++ b/docs/QuickStart.md @@ -0,0 +1,107 @@ +--- +copyright: +years: 2024 +lastupdated: "2024-10-22" +layout: page +title: "Exchange API Server" +description: "Quick start" + +nav_order: 3 +parent: Management Hub +--- + +# Exchange API Server quick start + +## Intro + +This document describes the environment and the set of steps aiming to create a +local development and debugging environment. + +## Prerequisites + +* OS: Ubuntu 24.04 LTS. + +## Dependencies + +* [Java 17](https://www.java.com/en/) +* [SBT](https://www.scala-sbt.org/) +* [PostgreSQL](https://www.postgresql.org/) + +## Installation + +### Create a new user (optional) + +For development purposes recommended not to use root user. Command below will create +a new Ubuntu user. + +```bash +useradd -d /home/new_user -s /bin/bash -m new_user +sudo passwd new_user +usermod -aG sudo new_user +``` + +### Install Java 17 + +```bash +sudo apt-get update +sudo apt install openjdk-17-jdk -y +``` + +### Install SBT + +```bash +sudo apt-get update +sudo apt-get install apt-transport-https curl gnupg -yqq +echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list +echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list +curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo -H gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --import +sudo chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg +sudo apt-get update +sudo apt-get install sbt +``` + +### Install Postgresql + +```bash +sudo apt-get update +sudo apt-get install postgresql +sudo systemctl status postgresql +``` + +### Configure firewall rule for Postgresql port 5432 + +```bash +sudo iptables -A INPUT -p tcp --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT +``` + +### Create a new DB + +```bash +sudo -u postgres psql +postgres=# CREATE USER new_user WITH PASSWORD 'password'; +postgres=# CREATE DATABASE horizon OWNER new_user; +\q +``` + +### Test connection to DB + +```bash +psql "host=localhost dbname=horizon user=kevin password='password'" +``` + +### Export environment variables + +```bash +export EXCHANGE_DB_NAME=openhorizon +export EXCHANGE_DB_PW=password +export EXCHANGE_DB_USER=new_user +export EXCHANGE_ROOT_PW=root_password +``` + +### Clone exchange-api and run it + +```bash +https://github.com/open-horizon/exchange-api.git +~/exchange-api$ sbt +sbt:amd64_exchange-api> reStart +``` diff --git a/docs/openapi-3-developer.json b/docs/openapi-3-developer.json index febda410..18e3f59e 100644 --- a/docs/openapi-3-developer.json +++ b/docs/openapi-3-developer.json @@ -8,7 +8,7 @@ "name" : "Apache License Version 2.0", "url" : "https://www.apache.org/licenses/LICENSE-2.0" }, - "version" : "2.125.0" + "version" : "2.125.1" }, "externalDocs" : { "description" : "Open-horizon ExchangeAPI", diff --git a/docs/openapi-3-user.json b/docs/openapi-3-user.json index c7d492e5..6bafc98b 100644 --- a/docs/openapi-3-user.json +++ b/docs/openapi-3-user.json @@ -8,7 +8,7 @@ "name" : "Apache License Version 2.0", "url" : "https://www.apache.org/licenses/LICENSE-2.0" }, - "version" : "2.125.0" + "version" : "2.125.1" }, "externalDocs" : { "description" : "Open-horizon ExchangeAPI", diff --git a/src/main/resources/version.txt b/src/main/resources/version.txt index 27913085..0fe613ab 100644 --- a/src/main/resources/version.txt +++ b/src/main/resources/version.txt @@ -1 +1 @@ -2.125.0 +2.125.1 diff --git a/src/main/scala/org/openhorizon/exchangeapi/route/agent/AgentConfigurationManagement.scala b/src/main/scala/org/openhorizon/exchangeapi/route/agent/AgentConfigurationManagement.scala index 6c334a4f..c55fcc5a 100644 --- a/src/main/scala/org/openhorizon/exchangeapi/route/agent/AgentConfigurationManagement.scala +++ b/src/main/scala/org/openhorizon/exchangeapi/route/agent/AgentConfigurationManagement.scala @@ -61,12 +61,16 @@ trait AgentConfigurationManagement extends JacksonSupport with AuthenticationSup certificate <- AgentCertificateVersionsTQ.delete timestamp: Timestamp = ApiTime.nowUTCTimestamp - + + + checkAgentVersionsResult <- AgentVersionsChangedTQ.getChanged("IBM").result + changed <- - if(AgentVersionsChangedTQ.getChanged("IBM").result == 0) + if(checkAgentVersionsResult == 0) AgentVersionsChangedTQ += (timestamp, "IBM") else AgentVersionsChangedTQ.getChanged("IBM").update(timestamp) + configuration <- AgentConfigurationVersionsTQ.delete resource <- ResourceChangesTQ += ResourceChangeRow(category = ResChangeCategory.ORG.toString, changeId = 0L, diff --git a/src/main/scala/org/openhorizon/exchangeapi/route/node/Node.scala b/src/main/scala/org/openhorizon/exchangeapi/route/node/Node.scala index 89df0310..3c4b3db3 100644 --- a/src/main/scala/org/openhorizon/exchangeapi/route/node/Node.scala +++ b/src/main/scala/org/openhorizon/exchangeapi/route/node/Node.scala @@ -18,7 +18,7 @@ import org.openhorizon.exchangeapi.utility.ApiTime.fixFormatting import org.openhorizon.exchangeapi.ExchangeApiApp.{exchAuth, validateWithMsg} import org.openhorizon.exchangeapi.auth.{Access, AccessDeniedException, AuthCache, AuthRoles, AuthenticationSupport, BadInputException, DBProcessingError, IUser, Identity, OrgAndId, Password, ResourceNotFoundException, TNode} import org.openhorizon.exchangeapi.table.deploymentpattern.{PatternRow, Patterns, PatternsTQ} -import org.openhorizon.exchangeapi.table.node.{Node, NodeRow, NodeType, NodesTQ} +import org.openhorizon.exchangeapi.table.node.{NodeRow, NodeType, NodesTQ} import org.openhorizon.exchangeapi.table.node.group.NodeGroupTQ import org.openhorizon.exchangeapi.table.node.group.assignment.NodeGroupAssignmentTQ import org.openhorizon.exchangeapi.table.organization.{OrgLimits, OrgsTQ} diff --git a/src/main/scala/org/openhorizon/exchangeapi/route/user/User.scala b/src/main/scala/org/openhorizon/exchangeapi/route/user/User.scala index d6fe7556..c04fdb68 100644 --- a/src/main/scala/org/openhorizon/exchangeapi/route/user/User.scala +++ b/src/main/scala/org/openhorizon/exchangeapi/route/user/User.scala @@ -12,7 +12,7 @@ import org.apache.pekko.http.scaladsl.model.{StatusCode, StatusCodes} import org.apache.pekko.http.scaladsl.server.Directives.{as, complete, delete, entity, get, patch, path, post, put, _} import org.apache.pekko.http.scaladsl.server.Route import org.openhorizon.exchangeapi.auth.{Access, AuthCache, AuthenticationSupport, BadInputException, IUser, Identity, OrgAndId, Password, Role, TUser} -import org.openhorizon.exchangeapi.table.user.{User, UserRow, UsersTQ} +import org.openhorizon.exchangeapi.table.user.{User => UserTable, UserRow, UsersTQ} import org.openhorizon.exchangeapi.utility.{ApiRespType, ApiResponse, ApiTime, ExchMsg, ExchangePosgtresErrorHandling, HttpCode, StrConstants} import slick.jdbc.PostgresProfile.api._ @@ -92,7 +92,7 @@ trait User extends JacksonSupport with AuthenticationSupport { logger.debug(s"GET /orgs/$organization/users/$realUsername result size: ${list.size}") val users: Map[String, org.openhorizon.exchangeapi.table.user.User] = - list.map(e => e.username -> User(if (identity.isSuperUser || identity.isHubAdmin) e.hashedPw else StrConstants.hiddenPw, e.admin, e.hubAdmin, e.email, e.lastUpdated, e.updatedBy)).toMap + list.map(e => e.username -> UserTable(if (identity.isSuperUser || identity.isHubAdmin) e.hashedPw else StrConstants.hiddenPw, e.admin, e.hubAdmin, e.email, e.lastUpdated, e.updatedBy)).toMap val code: StatusCode = if (users.nonEmpty) StatusCodes.OK diff --git a/src/test/scala/org/openhorizon/exchangeapi/route/user/TestPatchUserRoute.scala b/src/test/scala/org/openhorizon/exchangeapi/route/user/TestPatchUserRoute.scala index f218c2f2..f727f557 100644 --- a/src/test/scala/org/openhorizon/exchangeapi/route/user/TestPatchUserRoute.scala +++ b/src/test/scala/org/openhorizon/exchangeapi/route/user/TestPatchUserRoute.scala @@ -179,7 +179,7 @@ class TestPatchUserRoute extends AnyFunSuite with BeforeAndAfterAll with BeforeA Await.ready(DBCONNECTION.run( TESTUSERS(0).updateUser() andThen TESTUSERS(2).updateUser() andThen - TESTUSERS(4).updateUser + TESTUSERS(4).updateUser() ), AWAITDURATION) }