Skip to content

Commit

Permalink
Merge branch 'master' into SHIBUI-922
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Smith committed Dec 6, 2018
2 parents 906086a + 5b9a841 commit 53bc3fa
Show file tree
Hide file tree
Showing 24 changed files with 193 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import edu.internet2.tier.shibboleth.admin.ui.controller.ErrorResponse;
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.MetadataResolver;
import edu.internet2.tier.shibboleth.admin.ui.repository.MetadataResolverRepository;
import org.hibernate.exception.ConstraintViolationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.client.HttpClientErrorException;

import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.NOT_FOUND;

/**
Expand Down Expand Up @@ -41,6 +43,11 @@ public ResponseEntity<?> notFoundHandler(HttpClientErrorException ex) {
throw ex;
}

@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<ErrorResponse> handleDatabaseConstraintViolation(ConstraintViolationException ex) {
return ResponseEntity.status(BAD_REQUEST).body(new ErrorResponse("400", "message.database-constraint"));
}

@ExceptionHandler(Exception.class)
public final ResponseEntity<ErrorResponse> handleAllOtherExceptions(Exception ex) {
ErrorResponse errorResponse = new ErrorResponse("400", ex.getLocalizedMessage());
Expand Down
8 changes: 5 additions & 3 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ label.metadata-provider-type=Metadata Provider Type
label.metadata-provider-name=Metadata Provider Name
label.select-metadata-type=Select a metadata provider type
label.metadata-provider-status=Metadata Provider Status
label.enable-provider-upon-saving=Enable Metadata Provider upon saving?
label.enable-provider-upon-saving=Enable Metadata Provider?
label.certificate-type=Type

label.metadata-file=Metadata File
Expand All @@ -319,6 +319,7 @@ label.select-metadata-provider-type=Select Metadata Provider Type
label.filter-list=Filter List
label.common-attributes=Common Attributes
label.reloading-attributes=Reloading Attributes
label.dynamic-attributes=Dynamic Attributes
label.metadata-filter-plugins=Metadata Filter Plugins
label.advanced-settings=Advanced Settings
label.edit-metadata-provider=Edit Metadata Provider
Expand Down Expand Up @@ -397,6 +398,7 @@ message.wizard-status=Step { index } of { length }
message.entity-id-min-unique=You must add at least one entity id target and they must each be unique.
message.required-for-scripts=Required for Scripts
message.required-for-regex=Required for Regex
message.database-constraint=There was a database constraint problem processing the request. Check the request to ensure that fields that must be unique are truly unique.

tooltip.entity-id=Entity ID
tooltip.service-provider-name=Service Provider Name (Dashboard Display Only)
Expand Down Expand Up @@ -457,7 +459,7 @@ tooltip.http-caching-directory=If httpCaching='file', this attribute specifies w
tooltip.http-max-cache-entries=The maximum number of responses written to cache. This attribute is incompatible with httpClientRef.
tooltip.max-cache-entry-size=The maximum response body size that may be cached, in bytes. This attribute is incompatible with httpClientRef.

tooltip.metadata-provider-name=Metadata Provider Name
tooltip.metadata-provider-name=Metadata Provider Name (for display on the Dashboard only)
tooltip.metadata-provider-type=Metadata Provider Type
tooltip.xml-id=Identifier for logging, identification for command line reload, etc.
tooltip.metadata-url=Identifier for logging, identification for command line reload, etc.
Expand All @@ -469,7 +471,7 @@ tooltip.require-valid-metadata=Whether candidate metadata found by the resolver
tooltip.fail-fast-init=Whether to fail initialization of the underlying MetadataResolverService (and possibly the IdP as a whole) if the initialization of a metadata provider fails. When false, the IdP may start, and will continue to attempt to reload valid metadata if configured to do so, but operations that require valid metadata will fail until it does.
tooltip.use-default-predicate-reg=Flag which determines whether the default CriterionPredicateRegistry will be used if a custom one is not supplied explicitly.
tooltip.satisfy-any-predicates=Flag which determines whether predicates used in filtering are connected by a logical 'OR' (true) or by logical 'AND' (false).
tooltip.enable-provider-upon-saving=Enable Metadata Provider upon saving?
tooltip.enable-provider-upon-saving=If checkbox is clicked, the metadata provider is enabled for integration with the IdP

tooltip.max-validity-interval=Defines the window within which the metadata is valid.
tooltip.require-signed-root=If true, this fails to load metadata with no signature on the root XML element.
Expand Down
8 changes: 5 additions & 3 deletions backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ label.metadata-provider-type=Metadata Provider Type
label.metadata-provider-name=Metadata Provider Name
label.select-metadata-type=Select a metadata provider type
label.metadata-provider-status=Metadata Provider Status
label.enable-provider-upon-saving=Enable Metadata Provider upon saving?
label.enable-provider-upon-saving=Enable Metadata Provider?
label.certificate-type=Type

label.metadata-file=Metadata File
Expand All @@ -319,6 +319,7 @@ label.select-metadata-provider-type=Select Metadata Provider Type
label.filter-list=Filter List
label.common-attributes=Common Attributes
label.reloading-attributes=Reloading Attributes
label.dynamic-attributes=Dynamic Attributes
label.metadata-filter-plugins=Metadata Filter Plugins
label.advanced-settings=Advanced Settings
label.edit-metadata-provider=Edit Metadata Provider
Expand Down Expand Up @@ -403,6 +404,7 @@ message.wizard-status=Step { index } of { length }
message.entity-id-min-unique=You must add at least one entity id target and they must each be unique.
message.required-for-scripts=Required for Scripts
message.required-for-regex=Required for Regex
message.database-constraint=There was a database constraint problem processing the request. Check the request to ensure that fields that must be unique are truly unique.

tooltip.entity-id=Entity ID
tooltip.service-provider-name=Service Provider Name (Dashboard Display Only)
Expand Down Expand Up @@ -463,7 +465,7 @@ tooltip.http-caching-directory=If httpCaching='file', this attribute specifies w
tooltip.http-max-cache-entries=The maximum number of responses written to cache. This attribute is incompatible with httpClientRef.
tooltip.max-cache-entry-size=The maximum response body size that may be cached, in bytes. This attribute is incompatible with httpClientRef.

tooltip.metadata-provider-name=Metadata Provider Name
tooltip.metadata-provider-name=Metadata Provider Name (for display on the Dashboard only)
tooltip.metadata-provider-type=Metadata Provider Type
tooltip.xml-id=Identifier for logging, identification for command line reload, etc.
tooltip.metadata-url=Identifier for logging, identification for command line reload, etc.
Expand All @@ -475,7 +477,7 @@ tooltip.require-valid-metadata=Whether candidate metadata found by the resolver
tooltip.fail-fast-init=Whether to fail initialization of the underlying MetadataResolverService (and possibly the IdP as a whole) if the initialization of a metadata provider fails. When false, the IdP may start, and will continue to attempt to reload valid metadata if configured to do so, but operations that require valid metadata will fail until it does.
tooltip.use-default-predicate-reg=Flag which determines whether the default CriterionPredicateRegistry will be used if a custom one is not supplied explicitly.
tooltip.satisfy-any-predicates=Flag which determines whether predicates used in filtering are connected by a logical 'OR' (true) or by logical 'AND' (false).
tooltip.enable-provider-upon-saving=Enable Metadata Provider upon saving?
tooltip.enable-provider-upon-saving=If checkbox is clicked, the metadata provider is enabled for integration with the IdP

tooltip.max-validity-interval=Defines the window within which the metadata is valid.
tooltip.require-signed-root=If true, this fails to load metadata with no signature on the root XML element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"properties": {
"name": {
"title": "label.metadata-provider-name",
"title": "label.metadata-provider-name-display-only",
"description": "tooltip.metadata-provider-name",
"type": "string",
"widget": {
Expand Down
7 changes: 4 additions & 3 deletions backend/src/test/resources/i18n/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ label.metadata-provider-type=(es) Metadata Provider Type
label.metadata-provider-name=(es) Metadata Provider Name
label.select-metadata-type=(es) Select a metadata provider type
label.metadata-provider-status=(es) Metadata Provider Status
label.enable-provider-upon-saving=(es) Enable Metadata Provider upon saving?
label.enable-provider-upon-saving=(es) Enable Metadata Provider?

label.enable-filter=(es) Enable Filter?
label.required-valid-until=(es) Required Valid Until Filter
Expand All @@ -299,6 +299,7 @@ label.select-metadata-provider-type=(es) Select Metadata Provider Type
label.filter-list=(es) Filter List
label.common-attributes=(es) Common Attributes
label.reloading-attributes=(es) Reloading Attributes
label.dynamic-attributes=(es) Dynamic Attributes
label.metadata-filter-plugins=(es) Metadata Filter Plugins
label.advanced-settings=(es) Advanced Settings
label.edit-metadata-provider=(es) Edit Metadata Provider
Expand Down Expand Up @@ -417,7 +418,7 @@ tooltip.http-caching-directory=(es) If httpCaching=(es) 'file', this attribute s
tooltip.http-max-cache-entries=(es) The maximum number of responses written to cache. This attribute is incompatible with httpClientRef.
tooltip.max-cache-entry-size=(es) The maximum response body size that may be cached, in bytes. This attribute is incompatible with httpClientRef.

tooltip.metadata-provider-name=(es) Metadata Provider Name
tooltip.metadata-provider-name=(es) Metadata Provider Name (for display on the Dashboard only)
tooltip.metadata-provider-type=(es) Metadata Provider Type
tooltip.xml-id=(es) Identifier for logging, identification for command line reload, etc.
tooltip.metadata-url=(es) Identifier for logging, identification for command line reload, etc.
Expand All @@ -428,7 +429,7 @@ tooltip.require-valid-metadata=(es) Whether candidate metadata found by the reso
tooltip.fail-fast-init=(es) Whether to fail initialization of the underlying MetadataResolverService (and possibly the IdP as a whole) if the initialization of a metadata provider fails. When false, the IdP may start, and will continue to attempt to reload valid metadata if configured to do so, but operations that require valid metadata will fail until it does.
tooltip.use-default-predicate-reg=(es) Whether to fail initialization of the underlying MetadataResolverService (and possibly the IdP as a whole) if the initialization of a metadata provider fails. When false, the IdP may start, and will continue to attempt to reload valid metadata if configured to do so, but operations that require valid metadata will fail until it does.
tooltip.satisfy-any-predicates=(es) Flag which determines whether predicates used in filtering are connected by a logical 'OR' (true) or by logical 'AND' (false).
tooltip.enable-provider-upon-saving=(es) Enable Metadata Provider upon saving?
tooltip.enable-provider-upon-saving=(es) If checkbox is clicked, the metadata provider is enabled for integration with the IdP

tooltip.max-validity-interval=(es) Defines the window within which the metadata is valid.
tooltip.require-signed-root=(es) If true, this fails to load metadata with no signature on the root XML element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<sf-form
[schema]="schema$ | async"
[model]="model$ | async"
[validators]="definition.getValidators()"
[validators]="validators$ | async"
[actions]="actions"
(onChange)="valueChangeSubject.next($event)"
(onErrorChange)="statusChangeSubject.next($event)"></sf-form>
Expand Down
13 changes: 12 additions & 1 deletion ui/src/app/metadata/filter/container/edit-filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { UpdateFilterRequest } from '../action/collection.action';
import { CancelCreateFilter, UpdateFilterChanges } from '../action/filter.action';
import { PreviewEntity } from '../../domain/action/entity.action';
import { EntityAttributesFilterEntity } from '../../domain/entity';
import { shareReplay } from 'rxjs/operators';
import { shareReplay, map, withLatestFrom } from 'rxjs/operators';

@Component({
selector: 'edit-filter-page',
Expand All @@ -33,6 +33,8 @@ export class EditFilterComponent {
filter: MetadataFilter;
isValid: boolean;

validators$: Observable<{ [key: string]: any }>;

actions: any;

constructor(
Expand All @@ -50,6 +52,15 @@ export class EditFilterComponent {
this.isValid = valid.value ? valid.value.length === 0 : true;
});

this.validators$ = this.store.select(fromFilter.getFilterNames).pipe(
withLatestFrom(
this.store.select(fromFilter.getSelectedFilter)
),
map(([names, provider]) => this.definition.getValidators(
names.filter(n => n !== provider.name)
))
);

this.store
.select(fromFilter.getFilter)
.subscribe(filter => this.filter = filter);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata/filter/container/filter.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ng-container *ngIf="filter$ | async">
<ng-container>
<router-outlet></router-outlet>
</ng-container>
16 changes: 6 additions & 10 deletions ui/src/app/metadata/filter/container/filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,31 @@ import { ActivatedRoute } from '@angular/router';
import { Observable, Subscription } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { NgbPopoverConfig } from '@ng-bootstrap/ng-bootstrap';

import { MetadataFilter } from '../../domain/model/metadata-filter';
import { SelectFilter } from '../action/collection.action';
import { LoadFilterRequest } from '../action/collection.action';
import * as fromFilter from '../reducer';


@Component({
selector: 'filter-page',
templateUrl: './filter.component.html',
styleUrls: ['./filter.component.scss'],
providers: [NgbPopoverConfig]
styleUrls: [],
providers: []
})
export class FilterComponent implements OnDestroy {
actionsSubscription: Subscription;
filter$: Observable<MetadataFilter>;
filters$: Observable<MetadataFilter[]>;

constructor(
private store: Store<fromFilter.State>,
private route: ActivatedRoute
) {
this.actionsSubscription = this.route.params.pipe(
this.actionsSubscription = this.route.parent.params.pipe(
distinctUntilChanged(),
map(params => {
return new SelectFilter(params.id);
return new LoadFilterRequest(params.providerId);
})
).subscribe(store);

this.filter$ = this.store.select(fromFilter.getSelectedFilter);
}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<sf-form
[schema]="schema$ | async"
[model]="model$ | async"
[validators]="definition.getValidators()"
[validators]="validators$ | async"
(onChange)="valueChangeSubject.next($event)"
(onErrorChange)="statusChangeSubject.next($event)"></sf-form>
</div>
Expand Down
8 changes: 7 additions & 1 deletion ui/src/app/metadata/filter/container/new-filter.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';
import { Subject, Observable, of } from 'rxjs';
import { takeUntil, shareReplay } from 'rxjs/operators';
import { takeUntil, shareReplay, withLatestFrom, map, filter } from 'rxjs/operators';

import * as fromFilter from '../reducer';
import { MetadataFilterTypes } from '../model';
Expand Down Expand Up @@ -33,6 +33,8 @@ export class NewFilterComponent implements OnDestroy, OnInit {
filter: MetadataFilter;
isValid: boolean;

validators$: Observable<{ [key: string]: any }>;

constructor(
private store: Store<fromFilter.State>,
private schemaService: SchemaService
Expand All @@ -42,6 +44,10 @@ export class NewFilterComponent implements OnDestroy, OnInit {
this.schema$ = this.schemaService.get(this.definition.schema).pipe(shareReplay());
this.isSaving$ = this.store.select(fromFilter.getCollectionSaving);
this.model$ = of(<MetadataFilter>{});

this.validators$ = this.store.select(fromFilter.getFilterNames).pipe(
map((names) => this.definition.getValidators(names))
);
}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ng-container *ngIf="filter$ | async">
<router-outlet></router-outlet>
</ng-container>
Empty file.
39 changes: 39 additions & 0 deletions ui/src/app/metadata/filter/container/select-filter.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Component, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable, Subscription } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { NgbPopoverConfig } from '@ng-bootstrap/ng-bootstrap';

import { MetadataFilter } from '../../domain/model/metadata-filter';
import { SelectFilter } from '../action/collection.action';
import * as fromFilter from '../reducer';

@Component({
selector: 'select-filter-page',
templateUrl: './select-filter.component.html',
styleUrls: ['./select-filter.component.scss'],
providers: [NgbPopoverConfig]
})
export class SelectFilterComponent implements OnDestroy {
actionsSubscription: Subscription;
filter$: Observable<MetadataFilter>;

constructor(
private store: Store<fromFilter.State>,
private route: ActivatedRoute
) {
this.actionsSubscription = this.route.params.pipe(
distinctUntilChanged(),
map(params => {
return new SelectFilter(params.id);
})
).subscribe(store);

this.filter$ = this.store.select(fromFilter.getSelectedFilter);
}

ngOnDestroy() {
this.actionsSubscription.unsubscribe();
}
} /* istanbul ignore next */
8 changes: 0 additions & 8 deletions ui/src/app/metadata/filter/effect/collection.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,6 @@ export class FilterCollectionEffects {
)
);

/*
@Effect()
reloadOrderAfterChange$ = this.actions$.pipe(
ofType<SetOrderFilterSuccess>(FilterCollectionActionTypes.SET_ORDER_FILTER_SUCCESS),
map(() => new GetOrderFilterRequest())
);
*/

@Effect()
setOrder$ = this.actions$.pipe(
ofType<SetOrderFilterRequest>(FilterCollectionActionTypes.SET_ORDER_FILTER_REQUEST),
Expand Down
8 changes: 5 additions & 3 deletions ui/src/app/metadata/filter/filter.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ import { NgbPopoverModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { SearchDialogComponent } from './component/search-dialog.component';
import { SharedModule } from '../../shared/shared.module';
import { EditFilterComponent } from './container/edit-filter.component';
import { FilterComponent } from './container/filter.component';
import { SelectFilterComponent } from './container/select-filter.component';
import { SearchIdEffects } from './effect/search.effect';
import { FilterExistsGuard } from './guard/filter-exists.guard';
import { DomainModule } from '../domain/domain.module';
import { ModuleWithProviders } from '@angular/compiler/src/core';
import { FilterCollectionEffects } from './effect/collection.effect';
import { FormModule } from '../../schema-form/schema-form.module';
import { I18nModule } from '../../i18n/i18n.module';
import { FilterComponent } from './container/filter.component';

@NgModule({
declarations: [
NewFilterComponent,
EditFilterComponent,
FilterComponent,
SearchDialogComponent
SelectFilterComponent,
SearchDialogComponent,
FilterComponent
],
entryComponents: [
SearchDialogComponent
Expand Down
Loading

0 comments on commit 53bc3fa

Please sign in to comment.