diff --git a/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala b/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala
index f871b46299..ae27a4fdb6 100644
--- a/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala
+++ b/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala
@@ -41,9 +41,17 @@ import code.api.ResourceDocs1_4_0.ResourceDocs300.{ResourceDocs310, ResourceDocs
import code.api.ResourceDocs1_4_0._
import code.api._
import code.api.attributedefinition.AttributeDefinition
+import code.api.berlin.group.v1_3.{OBP_BERLIN_GROUP_1_3, OBP_BERLIN_GROUP_1_3_Alias}
import code.api.berlin.group.ConstantsBG
+import code.api.STET.v1_4.OBP_STET_1_4
+import code.api.Polish.v2_1_1_1.OBP_PAPI_2_1_1_1
+import code.api.MxOF.{OBP_MXOF_1_0_0, CNBV9_1_0_0}
+import code.api.BahrainOBF.v1_0_0.{ApiCollector => BahrainApiCollector}
+import code.api.AUOpenBanking.v1_0_0.{ApiCollector => AUApiCollector}
+import code.api.UKOpenBanking.v2_0_0.OBP_UKOpenBanking_200
+import code.api.UKOpenBanking.v3_1_0.OBP_UKOpenBanking_310
import code.api.cache.Redis
-import code.api.util.APIUtil.{enableVersionIfAllowed, errorJsonResponse, getPropsValue}
+import code.api.util.APIUtil.{enableVersionIfAllowed, versionIsAllowed,errorJsonResponse, getPropsValue}
import code.api.util.ApiRole._
import code.api.util.ErrorMessages.MandatoryPropertyIsNotSet
import code.api.util._
@@ -463,7 +471,95 @@ class Boot extends MdcLoggable {
ApiVersion.setUrlPrefix(ApiPathZero)
// Add the various API versions
+ val scannedApisCount = ScannedApis.versionMapScannedApis.size
+ logger.info(s"ClassScanUtils found $scannedApisCount ScannedApis implementations")
+
ScannedApis.versionMapScannedApis.keys.foreach(enableVersionIfAllowed) // process all scanned apis versions
+
+
+ // Manual registration for ScannedApis if not already registered by ClassScanUtils
+ // This ensures all APIs work in Fat JAR environment where class scanning fails
+
+ if (!ScannedApis.versionMapScannedApis.contains(ConstantsBG.berlinGroupVersion1)) {
+ logger.warn("BGv1.3 was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(ConstantsBG.berlinGroupVersion1)) {
+ LiftRules.statelessDispatch.append(OBP_BERLIN_GROUP_1_3)
+ logger.info(s"${ConstantsBG.berlinGroupVersion1.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
+ if (!ScannedApis.versionMapScannedApis.contains(OBP_BERLIN_GROUP_1_3_Alias.apiVersion)) {
+ logger.warn("BGv1.3 Alias was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(OBP_BERLIN_GROUP_1_3_Alias.apiVersion)) {
+ LiftRules.statelessDispatch.append(OBP_BERLIN_GROUP_1_3_Alias)
+ logger.info(s"${OBP_BERLIN_GROUP_1_3_Alias.apiVersion.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
+ if (!ScannedApis.versionMapScannedApis.contains(ApiVersion.stetV14)) {
+ logger.warn("STET v1.4 was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(ApiVersion.stetV14)) {
+ LiftRules.statelessDispatch.append(OBP_STET_1_4)
+ logger.info(s"${ApiVersion.stetV14.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
+ if (!ScannedApis.versionMapScannedApis.contains(ApiVersion.polishApiV2111)) {
+ logger.warn("Polish API v2.1.1.1 was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(ApiVersion.polishApiV2111)) {
+ LiftRules.statelessDispatch.append(OBP_PAPI_2_1_1_1)
+ logger.info(s"${ApiVersion.polishApiV2111.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
+ if (!ScannedApis.versionMapScannedApis.contains(ApiVersion.mxofV100)) {
+ logger.warn("Mexico Open Finance v1.0.0 was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(ApiVersion.mxofV100)) {
+ LiftRules.statelessDispatch.append(OBP_MXOF_1_0_0)
+ logger.info(s"${ApiVersion.mxofV100.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
+ if (!ScannedApis.versionMapScannedApis.contains(ApiVersion.cnbv9)) {
+ logger.warn("Mexico CNBV9 v1.0.0 was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(ApiVersion.cnbv9)) {
+ LiftRules.statelessDispatch.append(CNBV9_1_0_0)
+ logger.info(s"${ApiVersion.cnbv9.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
+ if (!ScannedApis.versionMapScannedApis.contains(ApiVersion.bahrainObfV100)) {
+ logger.warn("Bahrain OBF v1.0.0 was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(ApiVersion.bahrainObfV100)) {
+ LiftRules.statelessDispatch.append(BahrainApiCollector)
+ logger.info(s"${ApiVersion.bahrainObfV100.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
+ if (!ScannedApis.versionMapScannedApis.contains(ApiVersion.cdsAuV100)) {
+ logger.warn("Australia CDS v1.0.0 was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(ApiVersion.cdsAuV100)) {
+ LiftRules.statelessDispatch.append(AUApiCollector)
+ logger.info(s"${ApiVersion.cdsAuV100.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
+ if (!ScannedApis.versionMapScannedApis.contains(ApiVersion.ukOpenBankingV20)) {
+ logger.warn("UK Open Banking v2.0.0 was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(ApiVersion.ukOpenBankingV20)) {
+ LiftRules.statelessDispatch.append(OBP_UKOpenBanking_200)
+ logger.info(s"${ApiVersion.ukOpenBankingV20.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
+ if (!ScannedApis.versionMapScannedApis.contains(ApiVersion.ukOpenBankingV31)) {
+ logger.warn("UK Open Banking v3.1.0 was NOT found by ClassScanUtils, registering manually")
+ if (versionIsAllowed(ApiVersion.ukOpenBankingV31)) {
+ LiftRules.statelessDispatch.append(OBP_UKOpenBanking_310)
+ logger.info(s"${ApiVersion.ukOpenBankingV31.fullyQualifiedVersion} was ENABLED (manual registration)")
+ }
+ }
+
enableVersionIfAllowed(ApiVersion.v1_2_1)
enableVersionIfAllowed(ApiVersion.v1_3_0)
enableVersionIfAllowed(ApiVersion.v1_4_0)
diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/ResourceDocsAPIMethods.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/ResourceDocsAPIMethods.scala
index 451448aec9..e1d2572f7c 100644
--- a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/ResourceDocsAPIMethods.scala
+++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/ResourceDocsAPIMethods.scala
@@ -138,7 +138,7 @@ trait ResourceDocsAPIMethods extends MdcLoggable with APIMethods220 with APIMeth
case ApiVersion.v1_2_1 => Implementations1_2_1.resourceDocs
case ApiVersion.`dynamic-endpoint` => OBPAPIDynamicEndpoint.allResourceDocs
case ApiVersion.`dynamic-entity` => OBPAPIDynamicEntity.allResourceDocs
- case version: ScannedApiVersion => ScannedApis.versionMapScannedApis(version).allResourceDocs
+ case version: ScannedApiVersion => ScannedApis.versionMapScannedApis.get(version).map(_.allResourceDocs).getOrElse(ArrayBuffer.empty[ResourceDoc])
case _ => ArrayBuffer.empty[ResourceDoc]
}
@@ -161,7 +161,7 @@ trait ResourceDocsAPIMethods extends MdcLoggable with APIMethods220 with APIMeth
case ApiVersion.v1_2_1 => OBPAPI1_2_1.routes
case ApiVersion.`dynamic-endpoint` => OBPAPIDynamicEndpoint.routes
case ApiVersion.`dynamic-entity` => OBPAPIDynamicEntity.routes
- case version: ScannedApiVersion => ScannedApis.versionMapScannedApis(version).routes
+ case version: ScannedApiVersion => ScannedApis.versionMapScannedApis.get(version).map(_.routes).getOrElse(Nil)
case _ => Nil
}
diff --git a/obp-api/src/main/scala/code/api/util/APIUtil.scala b/obp-api/src/main/scala/code/api/util/APIUtil.scala
index 9ddd1fba04..6594cdae45 100644
--- a/obp-api/src/main/scala/code/api/util/APIUtil.scala
+++ b/obp-api/src/main/scala/code/api/util/APIUtil.scala
@@ -2823,7 +2823,8 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
case ApiVersion.v6_0_0 => LiftRules.statelessDispatch.append(v6_0_0.OBPAPI6_0_0)
case ApiVersion.`dynamic-endpoint` => LiftRules.statelessDispatch.append(OBPAPIDynamicEndpoint)
case ApiVersion.`dynamic-entity` => LiftRules.statelessDispatch.append(OBPAPIDynamicEntity)
- case version: ScannedApiVersion => LiftRules.statelessDispatch.append(ScannedApis.versionMapScannedApis(version))
+ case version: ScannedApiVersion =>
+ ScannedApis.versionMapScannedApis.get(version).foreach(api => LiftRules.statelessDispatch.append(api))
case _ => logger.info(s"There is no ${version.toString}")
}
diff --git a/obp-api/src/main/scala/code/util/ClassScanUtils.scala b/obp-api/src/main/scala/code/util/ClassScanUtils.scala
index a57f10f063..35371fdf3a 100644
--- a/obp-api/src/main/scala/code/util/ClassScanUtils.scala
+++ b/obp-api/src/main/scala/code/util/ClassScanUtils.scala
@@ -3,6 +3,7 @@ package code.util
import java.io.File
import com.openbankproject.commons.model.Bank
+import code.util.Helper.MdcLoggable
import org.apache.commons.lang3.StringUtils
import org.clapper.classutil.{ClassFinder, ClassInfo}
import com.openbankproject.commons.util.ReflectUtils
@@ -13,7 +14,7 @@ import scala.reflect.runtime.universe.TypeTag
* this is some util method to scan any class according some rules
* @author shuang
*/
-object ClassScanUtils {
+object ClassScanUtils extends MdcLoggable {
lazy val finder = ClassFinder(getClassPath(this.getClass, classOf[Bank], classOf[String]))
@@ -36,14 +37,23 @@ object ClassScanUtils {
def getSubTypeObjects[T:TypeTag]: List[T] = {
val clazz = ReflectUtils.typeTagToClass[T]
val classes = try {
- finder.getClasses().toList
+ val allClasses = finder.getClasses().toList
+ logger.info(s"ClassScanUtils successfully scanned ${allClasses.size} classes from classpath")
+ allClasses
} catch {
- case _: UnsupportedOperationException =>
+ case e: UnsupportedOperationException =>
// ASM version is too old for some class files (e.g. requires ASM7). In that case,
// skip scanned APIs instead of failing the whole application.
+ logger.warn(s"Class scanning failed with UnsupportedOperationException: ${e.getMessage}")
+ logger.warn("This is expected when running from a Fat JAR. Scanned APIs will not be auto-registered.")
+ Seq.empty
+ case e: Exception =>
+ logger.warn(s"Class scanning failed with ${e.getClass.getSimpleName}: ${e.getMessage}")
Seq.empty
}
- classes.filter(_.implements(clazz.getName)).map(_.name).map(companion[T](_)).toList
+ val filtered = classes.filter(_.implements(clazz.getName))
+ logger.info(s"Found ${filtered.size} classes implementing ${clazz.getName}")
+ filtered.map(_.name).map(companion[T](_)).toList
}
/**
diff --git a/pom.xml b/pom.xml
index b55adaeb2f..dcee3c49f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,6 @@
1.8.2
3.5.0
0.23.30
- 2016.11-RC6-SNAPSHOT
UTF-8
${project.build.sourceEncoding}
@@ -43,11 +42,6 @@
Scala-Tools Dependencies Repository for Releases
https://oss.sonatype.org/content/repositories/releases/
-
- scala-tools.snapshots
- Scala-Tools Dependencies Repository for Snapshots
- https://oss.sonatype.org/content/repositories/snapshots/
-
git-OpenBankProject
OpenBankProject Git based repo