diff --git a/src/ExternalResource.ts b/src/ExternalResource.ts index dba0183..2765622 100644 --- a/src/ExternalResource.ts +++ b/src/ExternalResource.ts @@ -53,9 +53,11 @@ export class ExternalResource implements IExternalResource { if (!id.endsWith("/")) { id += "/"; } + + const profile = service.getProfile(); if ( - service.getProfile() && - (Utils.isImageProfile(service.getProfile()) || + profile && + (Utils.isImageProfile(profile) || Utils.isImageServiceType(service.getIIIFResourceType())) ) { infoUri = id + "info.json"; @@ -175,22 +177,41 @@ export class ExternalResource implements IExternalResource { } } - this.clickThroughService = Utils.getService( + const clickThroughService = Utils.getService( resource, ServiceProfile.AUTH_1_CLICK_THROUGH ); - this.loginService = Utils.getService( + if (clickThroughService) { + this.clickThroughService = clickThroughService; + } + const loginService = Utils.getService( resource, ServiceProfile.AUTH_1_LOGIN ); - this.externalService = Utils.getService( + if (loginService) { + this.loginService = loginService; + } + const externalService = Utils.getService( resource, ServiceProfile.AUTH_1_EXTERNAL ); - this.kioskService = Utils.getService( + if (externalService) { + this.externalService = externalService; + } + const kioskService = Utils.getService( resource, ServiceProfile.AUTH_1_KIOSK ); + if (kioskService) { + this.kioskService = kioskService; + } + const probeService = Utils.getService( + resource, + ServiceProfile.AUTH_1_PROBE + ); + if (probeService) { + this.probeService = probeService; + } if (this.clickThroughService) { this.logoutService = this.clickThroughService.getService( @@ -199,9 +220,11 @@ export class ExternalResource implements IExternalResource { this.tokenService = this.clickThroughService.getService( ServiceProfile.AUTH_1_TOKEN ); - this.probeService = this.clickThroughService.getService( - ServiceProfile.AUTH_1_PROBE - ); + if (!this.probeService) { + this.probeService = this.clickThroughService.getService( + ServiceProfile.AUTH_1_PROBE + ); + } } else if (this.loginService) { this.logoutService = this.loginService.getService( ServiceProfile.AUTH_1_LOGOUT @@ -210,10 +233,12 @@ export class ExternalResource implements IExternalResource { ServiceProfile.AUTH_1_TOKEN ); - this.probeService = Utils.getService( - resource, - ServiceProfile.AUTH_1_PROBE - ); + if (!this.probeService) { + this.probeService = Utils.getService( + resource, + ServiceProfile.AUTH_1_PROBE + ); + } // @deprecated - the probe should be on the resource. if (!this.probeService) { @@ -228,10 +253,12 @@ export class ExternalResource implements IExternalResource { this.tokenService = this.externalService.getService( ServiceProfile.AUTH_1_TOKEN ); - this.probeService = Utils.getService( - resource, - ServiceProfile.AUTH_1_PROBE - ); + if (!this.probeService) { + this.probeService = Utils.getService( + resource, + ServiceProfile.AUTH_1_PROBE + ); + } // @deprecated - the probe should be on the resource. if (!this.probeService) { @@ -246,10 +273,12 @@ export class ExternalResource implements IExternalResource { this.tokenService = this.kioskService.getService( ServiceProfile.AUTH_1_TOKEN ); - this.probeService = Utils.getService( - resource, - ServiceProfile.AUTH_1_PROBE - ); + if (!this.probeService) { + this.probeService = Utils.getService( + resource, + ServiceProfile.AUTH_1_PROBE + ); + } // @deprecated - the probe should be on the resource. if (!this.probeService) {