diff --git a/.idea/runConfigurations/Start_Server_Load_Test.xml b/.idea/runConfigurations/Start_Server_Load_Test.xml
new file mode 100644
index 00000000..6d8e2996
--- /dev/null
+++ b/.idea/runConfigurations/Start_Server_Load_Test.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/criterias/AbstractGetCriteria.java b/app/criterias/AbstractGetCriteria.java
index 49cdb24c..43347792 100644
--- a/app/criterias/AbstractGetCriteria.java
+++ b/app/criterias/AbstractGetCriteria.java
@@ -2,14 +2,9 @@
import play.mvc.Http;
+import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static java.util.Objects.requireNonNull;
-
public abstract class AbstractGetCriteria, U>
extends AbstractContextCriteria implements GetCriteria {
@@ -18,7 +13,7 @@ public abstract class AbstractGetCriteria, U
protected AbstractGetCriteria(U id, Http.Request request) {
this.id = id;
- this.request = requireNonNull(request);
+ this.request = request;
}
@Nonnull
@@ -27,6 +22,7 @@ public U getId() {
return id;
}
+ @CheckForNull
@Override
public Http.Request getRequest() {
return request;
diff --git a/app/criterias/GetCriteria.java b/app/criterias/GetCriteria.java
index 638eba1b..ca9f8854 100644
--- a/app/criterias/GetCriteria.java
+++ b/app/criterias/GetCriteria.java
@@ -2,12 +2,14 @@
import play.mvc.Http;
+import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
public interface GetCriteria extends ContextCriteria {
@Nonnull
U getId();
+ @CheckForNull
Http.Request getRequest();
static , U> DefaultGetCriteria from(U id, Http.Request request, String... fetches) {
diff --git a/app/services/api/impl/UserApiServiceImpl.java b/app/services/api/impl/UserApiServiceImpl.java
index 53e245fd..250b58f1 100644
--- a/app/services/api/impl/UserApiServiceImpl.java
+++ b/app/services/api/impl/UserApiServiceImpl.java
@@ -1,6 +1,8 @@
package services.api.impl;
+import auth.ClientName;
import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
import criterias.GetCriteria;
import criterias.LogEntryCriteria;
import criterias.UserCriteria;
@@ -29,6 +31,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import java.util.UUID;
import java.util.function.Function;
@@ -40,6 +43,8 @@
public class UserApiServiceImpl extends
AbstractApiService
implements UserApiService {
+ private static final Set EXCLUDED_CLIENTS = Sets.newHashSet(
+ ClientName.ANONYMOUS, ClientName.PARAMETER, ClientName.HEADER);
private final AuthProvider authProvider;
private final LogEntryService logEntryService;
@@ -72,6 +77,10 @@ public dto.User create(Http.Request request) {
User user = toModel(toDto(request.body().asJson()), request);
authProvider.loggedInProfile(request).ifPresent(profile -> {
+ if (EXCLUDED_CLIENTS.contains(profile.getClientName())) {
+ return;
+ }
+
LinkedAccount linkedAccount = new LinkedAccount().withUser(user);
linkedAccount.providerKey = profile.getClientName();
linkedAccount.providerUserId = profile.getId();
diff --git a/app/services/impl/AccessTokenServiceImpl.java b/app/services/impl/AccessTokenServiceImpl.java
index be2b963c..afedd4a5 100644
--- a/app/services/impl/AccessTokenServiceImpl.java
+++ b/app/services/impl/AccessTokenServiceImpl.java
@@ -121,10 +121,6 @@ protected void postCreate(AccessToken t, Http.Request request) {
protected void preUpdate(AccessToken t, Http.Request request) {
super.preUpdate(t, request);
- if (StringUtils.isBlank(t.key)) {
- t.key = generateKey(AccessToken.KEY_LENGTH);
- }
-
activityActor.tell(
new ActivityProtocol.Activity<>(
ActionType.Update,
@@ -142,6 +138,10 @@ protected void preUpdate(AccessToken t, Http.Request request) {
protected void preSave(AccessToken t, Http.Request request) {
super.preSave(t, request);
+ if (StringUtils.isBlank(t.key)) {
+ t.key = generateKey(AccessToken.KEY_LENGTH);
+ }
+
User loggedInUser = authProvider.loggedInUser(request);
if (t.user == null || t.user.id == null
|| (loggedInUser != null && t.user.id != loggedInUser.id && loggedInUser.role != UserRole.Admin)) {
diff --git a/conf/logback-prod.xml b/conf/logback-prod.xml
new file mode 100644
index 00000000..f8e0e120
--- /dev/null
+++ b/conf/logback-prod.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+ %coloredLevel %logger{15} - %message%n%xException{10}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/load.conf b/load.conf
new file mode 100644
index 00000000..9e695b97
--- /dev/null
+++ b/load.conf
@@ -0,0 +1,28 @@
+include classpath("application.conf")
+
+db.default {
+ driver = "org.postgresql.Driver"
+ url = "jdbc:postgresql://localhost/translatr?reWriteBatchedInserts=true"
+ username = translatr
+ password = translatr
+ logSql = false
+}
+
+redis.host = localhost
+
+play.modules {
+ enabled += modules.NoCacheModule
+}
+
+translatr {
+ baseUrl = "http://localhost:9000"
+}
+
+pac4j {
+ cache.timeout = 0s
+
+ clients.keycloak {
+ host = "sso.repanzar.com"
+ host = ${?KEYCLOAK_HOST}
+ }
+}
diff --git a/ui/apps/cli-generate/tsconfig.app.json b/ui/apps/cli-generate/tsconfig.app.json
index 5b4e12bb..87989d5c 100644
--- a/ui/apps/cli-generate/tsconfig.app.json
+++ b/ui/apps/cli-generate/tsconfig.app.json
@@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
- "types": []
+ "types": ["node"]
},
"files": [
"src/main.ts"
diff --git a/ui/libs/generator/src/lib/api.ts b/ui/libs/generator/src/lib/api.ts
index b2b14eb4..c27463b0 100644
--- a/ui/libs/generator/src/lib/api.ts
+++ b/ui/libs/generator/src/lib/api.ts
@@ -63,6 +63,7 @@ const providers: StaticProvider[] = [
},
{ provide: XhrFactory, useValue: new BrowserXhr() },
{ provide: ErrorHandler, useValue: new ErrorHandler() },
+ { provide: LanguageProvider, useValue: new LanguageProvider() },
{
provide: UserService,
useFactory: (
@@ -88,7 +89,7 @@ const providers: StaticProvider[] = [
errorHandler: ErrorHandler,
languageProvider: LanguageProvider
) => new LocaleService(client, errorHandler, languageProvider),
- deps: [HttpClient, ErrorHandler]
+ deps: [HttpClient, ErrorHandler, LanguageProvider]
},
{
provide: KeyService,
@@ -97,7 +98,7 @@ const providers: StaticProvider[] = [
errorHandler: ErrorHandler,
languageProvider: LanguageProvider
) => new KeyService(client, errorHandler, languageProvider),
- deps: [HttpClient, ErrorHandler]
+ deps: [HttpClient, ErrorHandler, LanguageProvider]
},
{
provide: MessageService,
@@ -106,7 +107,7 @@ const providers: StaticProvider[] = [
errorHandler: ErrorHandler,
languageProvider: LanguageProvider
) => new MessageService(client, errorHandler, languageProvider),
- deps: [HttpClient, ErrorHandler]
+ deps: [HttpClient, ErrorHandler, LanguageProvider]
},
{
provide: AccessTokenService,
diff --git a/ui/libs/generator/src/lib/user.ts b/ui/libs/generator/src/lib/user.ts
index c7f580f0..5ac14ac4 100644
--- a/ui/libs/generator/src/lib/user.ts
+++ b/ui/libs/generator/src/lib/user.ts
@@ -87,7 +87,7 @@ export const createRandomUser = (userService: UserService): Observable `
+Error Report
+============
+
+Source: Translatr SDK
+Date: ${new Date()}
+Request: ${JSON.stringify(request, null, 2)}
+Error: ${JSON.stringify(error, null, 2)}
+------------
+`;
+
export class ErrorHandler {
handleError(error: HttpErrorResponse, request?: RestRequest): Observable {
- console.warn('Handling error for %s:\n%s', JSON.stringify(request), JSON.stringify(error));
+ console.warn(errorTemplate(error, request));
return throwError(error);
}
}
diff --git a/ui/package-lock.json b/ui/package-lock.json
index 428a65f1..456802d3 100644
--- a/ui/package-lock.json
+++ b/ui/package-lock.json
@@ -7739,9 +7739,9 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"@types/node": {
- "version": "12.12.42",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.42.tgz",
- "integrity": "sha512-R/9QdYFLL9dE9l5cWWzWIZByVGFd7lk7JVOJ7KD+E1SJ4gni7XJRLz9QTjyYQiHIqEAgku9VgxdLjMlhhUaAFg=="
+ "version": "12.12.62",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.62.tgz",
+ "integrity": "sha512-qAfo81CsD7yQIM9mVyh6B/U47li5g7cfpVQEDMfQeF8pSZVwzbhwU3crc0qG4DmpsebpJPR49AKOExQyJ05Cpg=="
},
"@types/parse-json": {
"version": "4.0.0",
diff --git a/ui/package.json b/ui/package.json
index 32a3b89c..3ff085c7 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -139,7 +139,7 @@
"@types/jasminewd2": "^2.0.8",
"@types/jest": "^23.3.14",
"@types/jquery": "3.3.6",
- "@types/node": "^12.11.1",
+ "@types/node": "12.12.62",
"@types/sanitize-html": "1.23.0",
"@types/underscore": "1.10.0",
"codelyzer": "^5.1.2",