Skip to content
71 changes: 50 additions & 21 deletions src/ExternalResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down