Skip to content
Snippets Groups Projects
Commit 25a1a676 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-2966 OZG-3171 adjust handle errorResponse, changed somehow; adjust BE

parent 098b2d15
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { getApiErrorFromHttpErrorResponse } from '@goofy-client/tech-shared';
import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Actions, createEffect, ofType } from '@ngrx/effects';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { catchError, mergeMap, switchMap, tap } from 'rxjs/operators'; import { catchError, mergeMap, switchMap, tap } from 'rxjs/operators';
...@@ -42,7 +41,7 @@ export class BinaryFileEffects { ...@@ -42,7 +41,7 @@ export class BinaryFileEffects {
ofType(BinaryFileActions.downloadPdf), ofType(BinaryFileActions.downloadPdf),
switchMap((action: DownloadBinaryFileAsPdfAction) => this.binaryFileRepository.downloadPdf(action.uri).pipe( switchMap((action: DownloadBinaryFileAsPdfAction) => this.binaryFileRepository.downloadPdf(action.uri).pipe(
mergeMap((fileData: Blob) => [BinaryFileActions.saveAsPdf({ fileData, fileName: action.fileName }), action.successAction()]), mergeMap((fileData: Blob) => [BinaryFileActions.saveAsPdf({ fileData, fileName: action.fileName }), action.successAction()]),
catchError(error => of(action.failureAction(getApiErrorFromHttpErrorResponse(error)))) catchError(error => of(action.failureAction(error.error)))
)) ))
) )
); );
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
*/ */
import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponseBase } from '@angular/common/http'; import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponseBase } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ContentType } from 'libs/binary-file-shared/src/lib/binary-file.repository';
import { Observable, throwError } from 'rxjs'; import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators'; import { catchError } from 'rxjs/operators';
...@@ -36,15 +35,15 @@ export class HttpBinaryFileInterceptor implements HttpInterceptor { ...@@ -36,15 +35,15 @@ export class HttpBinaryFileInterceptor implements HttpInterceptor {
public intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { public intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req).pipe(catchError((response: HttpResponseBase) => { return next.handle(req).pipe(catchError((response: HttpResponseBase) => {
if (this.shouldConvertToJson(response)) { if (this.shouldConvertToJson((<any>response).error)) {
return this.convertToJson(<HttpErrorResponse>response) return this.convertToJson((<HttpErrorResponse>response).error)
} }
return throwError(response); return throwError(response);
})); }));
} }
private shouldConvertToJson(err: HttpResponseBase): boolean { private shouldConvertToJson(err: HttpResponseBase): boolean {
return err instanceof HttpErrorResponse && err.error instanceof Blob && err.error.type === ContentType.APPLICATION_JSON; return err instanceof HttpErrorResponse && err.error instanceof Blob && err.error.type === 'application/json';
} }
convertToJson(errorResponse: HttpErrorResponse): Promise<any> { convertToJson(errorResponse: HttpErrorResponse): Promise<any> {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { EMPTY_STRING, getFirstLetter, getStringValue, isNotEmpty, isNotNull } from '@goofy-client/tech-shared'; import { EMPTY_STRING, getFirstLetter, getStringValue, isNotEmpty, isNotNull } from '@goofy-client/tech-shared';
import { isNull } from 'lodash-es'; import { isNil, isNull } from 'lodash-es';
import { UserProfileResource } from './user-profile.model'; import { UserProfileResource } from './user-profile.model';
export const NO_NAME_MESSAGE: string = 'Benutzer ohne hinterlegtem Namen'; export const NO_NAME_MESSAGE: string = 'Benutzer ohne hinterlegtem Namen';
...@@ -33,7 +33,7 @@ export function existsName(userProfile: UserProfileResource): boolean { ...@@ -33,7 +33,7 @@ export function existsName(userProfile: UserProfileResource): boolean {
} }
export function getUserName(userProfile: UserProfileResource): string { export function getUserName(userProfile: UserProfileResource): string {
if (isNull(userProfile)) { if (isNil(userProfile)) {
return UNKNOWN_USER; return UNKNOWN_USER;
} }
if (existsName(userProfile)) { if (existsName(userProfile)) {
......
...@@ -42,14 +42,9 @@ public class UserManagerProperties { ...@@ -42,14 +42,9 @@ public class UserManagerProperties {
private String url; private String url;
private String profileTemplate; private String profileTemplate;
private String searchTempalte; private String searchTempalte;
private String internalurl; private String internalurl;
String getProfileTemplate() { String getFullInternalUrlTemplate() {
return url + profileTemplate;
}
String getInternalUrlTemplate() {
return internalurl + MIGRATION_PATH; return internalurl + MIGRATION_PATH;
} }
} }
\ No newline at end of file
...@@ -21,7 +21,7 @@ public class UserManagerUrlProvider { ...@@ -21,7 +21,7 @@ public class UserManagerUrlProvider {
} }
public String getInternalUserIdTemplate() { public String getInternalUserIdTemplate() {
return userManagerProperties.getInternalUrlTemplate(); return userManagerProperties.getFullInternalUrlTemplate();
} }
public boolean isConfiguredForUserProfile() { public boolean isConfiguredForUserProfile() {
......
...@@ -63,7 +63,8 @@ public class UserRemoteService { ...@@ -63,7 +63,8 @@ public class UserRemoteService {
public Optional<UserId> getUserId(UserId externalUserId) { public Optional<UserId> getUserId(UserId externalUserId) {
try { try {
if (userManagerUrlProvider.isConfiguredForInternalUserId()) { if (userManagerUrlProvider.isConfiguredForInternalUserId()) {
var internalId = restTemplate.getForObject(userManagerProperties.getInternalUrlTemplate(), String.class, externalUserId.toString()); var internalId = restTemplate.getForObject(userManagerProperties.getFullInternalUrlTemplate(), String.class,
externalUserId.toString());
return StringUtils.isNotEmpty(internalId) ? Optional.of(UserId.from(internalId)) : Optional.empty(); return StringUtils.isNotEmpty(internalId) ? Optional.of(UserId.from(internalId)) : Optional.empty();
} else { } else {
return Optional.empty(); return Optional.empty();
......
...@@ -73,7 +73,7 @@ class UserRemoteServiceTest { ...@@ -73,7 +73,7 @@ class UserRemoteServiceTest {
@BeforeEach @BeforeEach
void mock() { void mock() {
when(userManagerProperties.getInternalUrlTemplate()).thenReturn(internalUrlTemplate); when(userManagerProperties.getFullInternalUrlTemplate()).thenReturn(internalUrlTemplate);
when(userManagerUrlProvider.isConfiguredForInternalUserId()).thenReturn(true); when(userManagerUrlProvider.isConfiguredForInternalUserId()).thenReturn(true);
} }
...@@ -131,7 +131,7 @@ class UserRemoteServiceTest { ...@@ -131,7 +131,7 @@ class UserRemoteServiceTest {
void shouldNotCallUserManagerProperties() { void shouldNotCallUserManagerProperties() {
service.getUserId(UserProfileTestFactory.ID); service.getUserId(UserProfileTestFactory.ID);
verify(userManagerProperties, never()).getInternalUrlTemplate(); verify(userManagerProperties, never()).getFullInternalUrlTemplate();
} }
@Test @Test
......
...@@ -144,7 +144,7 @@ class VorgangControllerITCase { ...@@ -144,7 +144,7 @@ class VorgangControllerITCase {
when(remoteService.findVorgangWithEingang(anyString())).thenReturn(VorgangWithEingangTestFactory.create()); when(remoteService.findVorgangWithEingang(anyString())).thenReturn(VorgangWithEingangTestFactory.create());
doRequest() doRequest()
.andExpect(jsonPath("$._links.assignedTo.href").value("https://localhost9092/api/userProfiles/" + UserProfileTestFactory.ID)); .andExpect(jsonPath("$._links.assignedTo.href").value("http://localhost9092/api/userProfiles/" + UserProfileTestFactory.ID));
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment