-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'aws-poc' into feature/1416-aws-emr-poc
% Conflicts: % pom.xml
- Loading branch information
Showing
28 changed files
with
374 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
menas/src/main/scala/za/co/absa/enceladus/menas/LineageConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2018 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.enceladus.menas | ||
|
||
import za.co.absa.enceladus.utils.config.ConfigReader | ||
|
||
object LineageConfig { | ||
final val config = new ConfigReader() | ||
final val apiUrl: Option[String] = config.readStringConfigIfExist("menas.lineage.readApiUrl").filter(_.trim.nonEmpty) | ||
final val jarName = "spline" | ||
final val subSpace = "lineage" | ||
|
||
final val mappingPathForController = "/" + subSpace + "/app/**" | ||
final val resourceHandler = "/" + subSpace + "/**" | ||
final val resourceLocation = "/webjars/" + jarName + "/" | ||
final val executionIdApiTemplate: Option[String] = apiUrl.map(_ + "/execution-events?dataSourceUri=%s&applicationId=%s") | ||
|
||
def baseUrl(baseUrlPrefix: String): String = { | ||
val delimiter = if (baseUrlPrefix.takeRight(1) == "/") "" else "/" | ||
s"$baseUrlPrefix$delimiter$subSpace/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
menas/src/main/scala/za/co/absa/enceladus/menas/WebJarsResourceFuzzyResolver.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2018 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.enceladus.menas | ||
|
||
import org.springframework.web.servlet.resource.WebJarsResourceResolver | ||
import org.webjars.WebJarAssetLocator | ||
|
||
class WebJarsResourceFuzzyResolver(webJarAssetLocator: WebJarAssetLocator) | ||
extends WebJarsResourceResolver(webJarAssetLocator) { | ||
|
||
private val webjarPartialPathExtractor = """^.*/([^/]+/[^/]+)/?$""".r | ||
|
||
override def findWebJarResourcePath(path: String): String = { | ||
Option(super.findWebJarResourcePath(path)) | ||
.orElse(findFullPath(path)) | ||
.flatMap(webjarPartialPathExtractor.findFirstMatchIn(_).map(_.group(1))) | ||
.orNull | ||
} | ||
|
||
private def findFullPath(path: String): Option[String] = | ||
try { | ||
Option(webJarAssetLocator.getFullPath(path)) | ||
} catch { | ||
case _: IllegalArgumentException => None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
menas/src/main/scala/za/co/absa/enceladus/menas/controllers/LineageController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2018 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.enceladus.menas.controllers | ||
|
||
import javax.servlet.http.HttpServletRequest | ||
import org.apache.commons.io.IOUtils | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.core.io.ClassPathResource | ||
import org.springframework.http.MediaType.TEXT_HTML_VALUE | ||
import org.springframework.stereotype.Controller | ||
import org.springframework.web.bind.annotation.{RequestMapping, ResponseBody} | ||
import org.webjars.WebJarAssetLocator | ||
import za.co.absa.enceladus.menas.LineageConfig | ||
|
||
@Controller | ||
class LineageController @Autowired()(webJarAssetLocator: WebJarAssetLocator) { | ||
|
||
@RequestMapping(path = Array(LineageConfig.mappingPathForController), produces = Array(TEXT_HTML_VALUE)) | ||
@ResponseBody | ||
def index(httpRequest: HttpServletRequest): String = { | ||
val resourceName = webJarAssetLocator.getFullPath(LineageConfig.jarName, "index.html") | ||
|
||
val resource = new ClassPathResource(resourceName) | ||
|
||
val baseUrl = LineageConfig.baseUrl(httpRequest.getContextPath) | ||
// TODO: Don't use string replaces #1116 | ||
IOUtils.toString(resource.getInputStream, "UTF-8") | ||
.replaceAllLiterally( | ||
"/*[[${embeddedMode}]]*/", | ||
"true; //") | ||
.replaceAllLiterally( | ||
"/*[[${apiUrl}]]*/", | ||
s"'${LineageConfig.apiUrl.getOrElse("")}'; //") | ||
.replaceAllLiterally( | ||
"""<base href="/" th:href="@{/}">""", | ||
s"""<base href="$baseUrl">""") | ||
.replaceAllLiterally("/*[+", "") | ||
.replaceAllLiterally("+]*/", "") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.