-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
815 additions
and
441 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
cd libs/ && ./install.sh && cd .. | ||
|
||
mvn clean package && docker build --no-cache -t datainsiderco/bi-service:oss . | ||
mvn clean package && docker build --no-cache -t datainsiderco/bi-service:main . |
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
Binary file renamed
BIN
+6.94 MB
bi-service/libs/clients-2.2.29.jar → bi-service/libs/clients-2.2.31.jar
Binary file not shown.
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
14 changes: 0 additions & 14 deletions
14
bi-service/src/main/scala/co/datainsider/bi/controller/http/filter/LicenceFilter.scala
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
bi-service/src/main/scala/co/datainsider/bi/controller/http/filter/LicenceServerFilter.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,55 @@ | ||
package co.datainsider.bi.controller.http.filter | ||
|
||
import com.twitter.finagle.http.{Request, Response} | ||
import com.twitter.finagle.{Service, SimpleFilter} | ||
import com.twitter.inject.Logging | ||
import com.twitter.util.Future | ||
import datainsider.client.filter.UserContext.UserContextSyntax | ||
import datainsider.client.util.ZConfig | ||
import datainsider.licence.exception.LicenceExpiredError | ||
import datainsider.licence.service.LicenceClientService | ||
|
||
import java.sql.Date | ||
import java.text.SimpleDateFormat | ||
import java.time.Duration | ||
import javax.inject.Inject | ||
|
||
class LicenceServerFilter @Inject() (licenceClientService: LicenceClientService) | ||
extends SimpleFilter[Request, Response] | ||
with Logging { | ||
val dateFormat = new SimpleDateFormat("dd MM yyyy HH:mm:ss Z") | ||
override def apply(request: Request, service: Service[Request, Response]): Future[Response] = { | ||
try { | ||
// val licenceKey = request.currentOrganization.get.licenceKey.get | ||
val timeOfMonthMillis: Long = Duration.ofDays(30).toMillis | ||
val timeOfDayMillis: Long = Duration.ofDays(1).toMillis | ||
|
||
require(request.currentOrganization.get.licenceKey.isDefined) | ||
|
||
for { | ||
licence <- licenceClientService.get(request.currentOrganization.get.licenceKey.get) | ||
response <- service(request) | ||
} yield { | ||
val terminatedTimeMillis = licence.expiredAt + timeOfMonthMillis | ||
val terminatedDate = new Date(terminatedTimeMillis) | ||
if (terminatedTimeMillis < System.currentTimeMillis()) { | ||
throw LicenceExpiredError(s"Your license was terminated ${dateFormat.format(terminatedDate)}") | ||
} | ||
|
||
if (licence.expiredAt < System.currentTimeMillis()) { | ||
val withinDays: Long = (terminatedTimeMillis - System.currentTimeMillis()) / timeOfDayMillis | ||
response.headerMap.add( | ||
ZConfig.getString("licence.field_name"), | ||
s"Your license is expired. Please make sure to charge for your license before ${dateFormat | ||
.format(terminatedDate)}/ within ${withinDays} days. Otherwise, your service will be terminated." | ||
) | ||
} | ||
response | ||
} | ||
} catch { | ||
case e: Throwable => | ||
logger.error(s"LicenceFilter::apply ${e.getMessage}", e) | ||
service(request) | ||
} | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
cd libs && ./install.sh && cd ../ | ||
|
||
mvn clean package -DskipTests && docker build --no-cache -t registry.gitlab.com/datainsider/user-profile:oss . | ||
mvn clean package -DskipTests && docker build --no-cache -t datainsiderco/caas-service:main . |
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 |
---|---|---|
|
@@ -41,6 +41,7 @@ caas { | |
org_email { | ||
google = "^(.+)@datainsider.co" | ||
} | ||
default_organization_id = 0 | ||
|
||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -41,7 +41,7 @@ caas { | |
org_email { | ||
google = "^(.+)@datainsider.co" | ||
} | ||
|
||
default_organization_id = 0 | ||
} | ||
|
||
db { | ||
|
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 |
---|---|---|
|
@@ -41,6 +41,7 @@ caas { | |
org_email { | ||
google = "^(.+)@datainsider.co" | ||
} | ||
default_organization_id = 0 | ||
|
||
} | ||
|
||
|
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
Binary file renamed
BIN
+6.89 MB
caas-service/libs/clients-2.2.29.jar → caas-service/libs/clients-2.2.31.jar
Binary file not shown.
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.