diff --git a/docker/docker-compose-rest.yml b/docker/docker-compose-rest.yml index c99e469941..370ccbbdf1 100644 --- a/docker/docker-compose-rest.yml +++ b/docker/docker-compose-rest.yml @@ -81,15 +81,22 @@ services: # Keep Solr data directory between reboots - solr_data:/var/solr/data # Initialize all DSpace Solr cores using the mounted local configsets (see above), then start Solr + # * First, run precreate-core to create the core (if it doesn't yet exist). If exists already, this is a no-op + # * Second, copy updated configs from mounted configsets to this core. If it already existed, this updates core + # to the latest configs. If it's a newly created core, this is a no-op. entrypoint: - /bin/bash - '-c' - | init-var-solr precreate-core authority /opt/solr/server/solr/configsets/dspace/authority + cp -r -u /opt/solr/server/solr/configsets/dspace/authority/* authority precreate-core oai /opt/solr/server/solr/configsets/dspace/oai + cp -r -u /opt/solr/server/solr/configsets/dspace/oai/* oai precreate-core search /opt/solr/server/solr/configsets/dspace/search + cp -r -u /opt/solr/server/solr/configsets/dspace/search/* search precreate-core statistics /opt/solr/server/solr/configsets/dspace/statistics + cp -r -u /opt/solr/server/solr/configsets/dspace/statistics/* statistics exec solr -f volumes: assetstore: diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 7941adc35c..49e96a028a 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -11,10 +11,12 @@ import { FORBIDDEN_PATH, FORGOT_PASSWORD_PATH, INFO_MODULE_PATH, + INTERNAL_SERVER_ERROR, + LEGACY_BITSTREAM_MODULE_PATH, PROFILE_MODULE_PATH, REGISTER_PATH, + REQUEST_COPY_MODULE_PATH, WORKFLOW_ITEM_MODULE_PATH, - LEGACY_BITSTREAM_MODULE_PATH, REQUEST_COPY_MODULE_PATH, } from './app-routing-paths'; import { COLLECTION_MODULE_PATH } from './collection-page/collection-page-routing-paths'; import { COMMUNITY_MODULE_PATH } from './community-page/community-page-routing-paths'; @@ -29,167 +31,171 @@ import { GroupAdministratorGuard } from './core/data/feature-authorization/featu import { ThemedPageInternalServerErrorComponent } from './page-internal-server-error/themed-page-internal-server-error.component'; import { ServerCheckGuard } from './core/server-check/server-check.guard'; - @NgModule({ imports: [ - RouterModule.forRoot([{ - path: '', canActivate: [AuthBlockingGuard], + RouterModule.forRoot([ + { path: INTERNAL_SERVER_ERROR, component: ThemedPageInternalServerErrorComponent }, + { + path: '', canActivate: [ServerCheckGuard, AuthBlockingGuard], children: [ { path: '', redirectTo: '/home', pathMatch: 'full' }, - { path: 'reload/:rnd', component: ThemedPageNotFoundComponent, pathMatch: 'full', canActivate: [ServerCheckGuard, ReloadGuard] }, + { + path: 'reload/:rnd', + component: ThemedPageNotFoundComponent, + pathMatch: 'full', + canActivate: [ReloadGuard] + }, { path: 'home', loadChildren: () => import('./home-page/home-page.module') .then((m) => m.HomePageModule), data: { showBreadcrumbs: false }, - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: 'community-list', loadChildren: () => import('./community-list-page/community-list-page.module') .then((m) => m.CommunityListPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: 'id', loadChildren: () => import('./lookup-by-id/lookup-by-id.module') .then((m) => m.LookupIdModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: 'handle', loadChildren: () => import('./lookup-by-id/lookup-by-id.module') .then((m) => m.LookupIdModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: REGISTER_PATH, loadChildren: () => import('./register-page/register-page.module') .then((m) => m.RegisterPageModule), - canActivate: [ServerCheckGuard, SiteRegisterGuard] + canActivate: [SiteRegisterGuard] }, { path: FORGOT_PASSWORD_PATH, loadChildren: () => import('./forgot-password/forgot-password.module') .then((m) => m.ForgotPasswordModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: COMMUNITY_MODULE_PATH, loadChildren: () => import('./community-page/community-page.module') .then((m) => m.CommunityPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: COLLECTION_MODULE_PATH, loadChildren: () => import('./collection-page/collection-page.module') .then((m) => m.CollectionPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: ITEM_MODULE_PATH, loadChildren: () => import('./item-page/item-page.module') .then((m) => m.ItemPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, - { path: 'entities/:entity-type', + { + path: 'entities/:entity-type', loadChildren: () => import('./item-page/item-page.module') .then((m) => m.ItemPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: LEGACY_BITSTREAM_MODULE_PATH, loadChildren: () => import('./bitstream-page/bitstream-page.module') .then((m) => m.BitstreamPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: BITSTREAM_MODULE_PATH, loadChildren: () => import('./bitstream-page/bitstream-page.module') .then((m) => m.BitstreamPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: 'mydspace', loadChildren: () => import('./my-dspace-page/my-dspace-page.module') .then((m) => m.MyDSpacePageModule), - canActivate: [ServerCheckGuard, AuthenticatedGuard, EndUserAgreementCurrentUserGuard] + canActivate: [AuthenticatedGuard, EndUserAgreementCurrentUserGuard] }, { path: 'search', loadChildren: () => import('./search-page/search-page-routing.module') .then((m) => m.SearchPageRoutingModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: 'browse', loadChildren: () => import('./browse-by/browse-by-page.module') .then((m) => m.BrowseByPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: ADMIN_MODULE_PATH, loadChildren: () => import('./admin/admin.module') .then((m) => m.AdminModule), - canActivate: [ServerCheckGuard, SiteAdministratorGuard, EndUserAgreementCurrentUserGuard] + canActivate: [SiteAdministratorGuard, EndUserAgreementCurrentUserGuard] }, { path: 'login', loadChildren: () => import('./login-page/login-page.module') - .then((m) => m.LoginPageModule), - canActivate: [ServerCheckGuard] + .then((m) => m.LoginPageModule) }, { path: 'logout', loadChildren: () => import('./logout-page/logout-page.module') - .then((m) => m.LogoutPageModule), - canActivate: [ServerCheckGuard] + .then((m) => m.LogoutPageModule) }, { path: 'submit', loadChildren: () => import('./submit-page/submit-page.module') .then((m) => m.SubmitPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: 'import-external', loadChildren: () => import('./import-external-page/import-external-page.module') .then((m) => m.ImportExternalPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: 'workspaceitems', loadChildren: () => import('./workspaceitems-edit-page/workspaceitems-edit-page.module') .then((m) => m.WorkspaceitemsEditPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: WORKFLOW_ITEM_MODULE_PATH, loadChildren: () => import('./workflowitems-edit-page/workflowitems-edit-page.module') .then((m) => m.WorkflowItemsEditPageModule), - canActivate: [ServerCheckGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: PROFILE_MODULE_PATH, loadChildren: () => import('./profile-page/profile-page.module') .then((m) => m.ProfilePageModule), - canActivate: [ServerCheckGuard, AuthenticatedGuard, EndUserAgreementCurrentUserGuard] + canActivate: [AuthenticatedGuard, EndUserAgreementCurrentUserGuard] }, { path: PROCESS_MODULE_PATH, loadChildren: () => import('./process-page/process-page.module') .then((m) => m.ProcessPageModule), - canActivate: [ServerCheckGuard, AuthenticatedGuard, EndUserAgreementCurrentUserGuard] + canActivate: [AuthenticatedGuard, EndUserAgreementCurrentUserGuard] }, { path: INFO_MODULE_PATH, - loadChildren: () => import('./info/info.module').then((m) => m.InfoModule), - canActivate: [ServerCheckGuard] + loadChildren: () => import('./info/info.module').then((m) => m.InfoModule) }, { path: REQUEST_COPY_MODULE_PATH, loadChildren: () => import('./request-copy/request-copy.module').then((m) => m.RequestCopyModule), - canActivate: [ServerCheckGuard, AuthenticatedGuard, EndUserAgreementCurrentUserGuard] + canActivate: [AuthenticatedGuard, EndUserAgreementCurrentUserGuard] }, { path: FORBIDDEN_PATH, @@ -198,18 +204,17 @@ import { ServerCheckGuard } from './core/server-check/server-check.guard'; { path: 'statistics', loadChildren: () => import('./statistics-page/statistics-page-routing.module') - .then((m) => m.StatisticsPageRoutingModule), - canActivate: [ServerCheckGuard] + .then((m) => m.StatisticsPageRoutingModule) }, { path: ACCESS_CONTROL_MODULE_PATH, loadChildren: () => import('./access-control/access-control.module').then((m) => m.AccessControlModule), - canActivate: [ServerCheckGuard, GroupAdministratorGuard], + canActivate: [GroupAdministratorGuard], }, - { path: '500', component: ThemedPageInternalServerErrorComponent }, { path: '**', pathMatch: 'full', component: ThemedPageNotFoundComponent }, - ]} - ],{ + ] + } + ], { onSameUrlNavigation: 'reload', }) ], diff --git a/src/app/core/server-check/server-check.guard.spec.ts b/src/app/core/server-check/server-check.guard.spec.ts index fc072cd73c..a9c03d1cd7 100644 --- a/src/app/core/server-check/server-check.guard.spec.ts +++ b/src/app/core/server-check/server-check.guard.spec.ts @@ -1,16 +1,63 @@ -import { TestBed } from '@angular/core/testing'; - import { ServerCheckGuard } from './server-check.guard'; +import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { take } from 'rxjs/operators'; +import { getPageInternalServerErrorRoute } from '../../app-routing-paths'; +import { Router } from '@angular/router'; +import { RootDataService } from '../data/root-data.service'; +import { Root } from '../data/root.model'; +import SpyObj = jasmine.SpyObj; describe('ServerCheckGuard', () => { let guard: ServerCheckGuard; + let router: SpyObj; + let rootDataServiceStub: SpyObj; + + rootDataServiceStub = jasmine.createSpyObj('RootDataService', { + findRoot: jasmine.createSpy('findRoot') + }); + router = jasmine.createSpyObj('Router', { + navigateByUrl: jasmine.createSpy('navigateByUrl') + }); beforeEach(() => { - TestBed.configureTestingModule({}); - guard = TestBed.inject(ServerCheckGuard); + guard = new ServerCheckGuard(router, rootDataServiceStub); + }); + + afterEach(() => { + router.navigateByUrl.calls.reset(); }); it('should be created', () => { expect(guard).toBeTruthy(); }); + + describe('when root endpoint has succeeded', () => { + beforeEach(() => { + rootDataServiceStub.findRoot.and.returnValue(createSuccessfulRemoteDataObject$({} as any)); + }); + + it('should not redirect to error page', () => { + guard.canActivate({} as any, {} as any).pipe( + take(1) + ).subscribe((canActivate: boolean) => { + expect(canActivate).toEqual(true); + expect(router.navigateByUrl).not.toHaveBeenCalled(); + }); + }); + }); + + describe('when root endpoint has not succeeded', () => { + beforeEach(() => { + rootDataServiceStub.findRoot.and.returnValue(createFailedRemoteDataObject$()); + }); + + it('should redirect to error page', () => { + guard.canActivate({} as any, {} as any).pipe( + take(1) + ).subscribe((canActivate: boolean) => { + expect(canActivate).toEqual(false); + expect(router.navigateByUrl).toHaveBeenCalledWith(getPageInternalServerErrorRoute()); + }); + }); + }); }); diff --git a/src/app/core/server-check/server-check.guard.ts b/src/app/core/server-check/server-check.guard.ts index 32ff57ebb3..b7982eee9a 100644 --- a/src/app/core/server-check/server-check.guard.ts +++ b/src/app/core/server-check/server-check.guard.ts @@ -1,26 +1,37 @@ import { Injectable } from '@angular/core'; -import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router'; +import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router'; + import { Observable } from 'rxjs'; -import { RootDataService } from '../data/root-data.service'; import { map, tap } from 'rxjs/operators'; + +import { RootDataService } from '../data/root-data.service'; import { RemoteData } from '../data/remote-data'; import { getPageInternalServerErrorRoute } from '../../app-routing-paths'; -import { Router } from '@angular/router'; +import { getFirstCompletedRemoteData } from '../shared/operators'; @Injectable({ providedIn: 'root' }) +/** + * A guard that checks if root api endpoint is reachable. + * If not redirect to 500 error page + */ export class ServerCheckGuard implements CanActivate { - constructor(private router: Router,private rootDataService: RootDataService) {} + constructor(private router: Router, private rootDataService: RootDataService) { + } + /** + * True when root api endpoint is reachable. + */ canActivate( route: ActivatedRouteSnapshot, - state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + state: RouterStateSnapshot): Observable { return this.rootDataService.findRoot().pipe( - map( (res: RemoteData) => res.hasSucceeded ), - tap( (responsehasSucceeded: boolean) => { - if (!responsehasSucceeded) { + getFirstCompletedRemoteData(), + map((res: RemoteData) => res.hasSucceeded), + tap((hasSucceeded: boolean) => { + if (!hasSucceeded) { this.router.navigateByUrl(getPageInternalServerErrorRoute()); } }), diff --git a/src/app/item-page/item-page-routing.module.ts b/src/app/item-page/item-page-routing.module.ts index 2c6631dd1a..7d7912bb42 100644 --- a/src/app/item-page/item-page-routing.module.ts +++ b/src/app/item-page/item-page-routing.module.ts @@ -15,6 +15,7 @@ import { ThemedItemPageComponent } from './simple/themed-item-page.component'; import { ThemedFullItemPageComponent } from './full/themed-full-item-page.component'; import { VersionPageComponent } from './version-page/version-page/version-page.component'; import { BitstreamRequestACopyPageComponent } from '../shared/bitstream-request-a-copy-page/bitstream-request-a-copy-page.component'; +import { REQUEST_COPY_MODULE_PATH } from '../app-routing-paths'; @NgModule({ imports: [ @@ -47,7 +48,7 @@ import { BitstreamRequestACopyPageComponent } from '../shared/bitstream-request- canActivate: [AuthenticatedGuard] }, { - path: ':request-a-copy', + path: REQUEST_COPY_MODULE_PATH, component: BitstreamRequestACopyPageComponent, } ], diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 6eca2c1f5d..fede29a047 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -16,7 +16,7 @@ "500.page-internal-server-error": "Service Unavailable", - "500.help": "The server is temporarily unable to service yourrequest due to maintenance downtime or capacityproblems. Please try again later.", + "500.help": "The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.", "500.link.home-page": "Take me to the home page", @@ -2435,7 +2435,7 @@ "menu.section.icon.control_panel": "Control Panel menu section", - "menu.section.icon.curation_task": "Curation Task menu section", + "menu.section.icon.curation_tasks": "Curation Task menu section", "menu.section.icon.edit": "Edit menu section", @@ -2455,6 +2455,8 @@ "menu.section.icon.statistics_task": "Statistics Task menu section", + "menu.section.icon.workflow": "Administer workflow menu section", + "menu.section.icon.unpin": "Unpin sidebar",