diff --git a/src/init/RootContainerInitializer.ts b/src/init/RootContainerInitializer.ts index ef88a2fb0..db8734b91 100644 --- a/src/init/RootContainerInitializer.ts +++ b/src/init/RootContainerInitializer.ts @@ -64,6 +64,7 @@ export class RootContainerInitializer extends Initializer { metadata.contentType = TEXT_TURTLE; + this.logger.debug(`Creating root container at ${this.baseId.path}`); await this.store.setRepresentation(this.baseId, { binary: true, data: guardedStreamFrom([]), diff --git a/src/storage/mapping/ExtensionBasedMapper.ts b/src/storage/mapping/ExtensionBasedMapper.ts index ef214a92f..f2a9982d5 100644 --- a/src/storage/mapping/ExtensionBasedMapper.ts +++ b/src/storage/mapping/ExtensionBasedMapper.ts @@ -64,8 +64,8 @@ export class ExtensionBasedMapper implements FileIdentifierMapper { * @returns A ResourceLink with all the necessary metadata. */ public async mapUrlToFilePath(identifier: ResourceIdentifier, contentType?: string): Promise { - const path = getRelativePath(this.baseRequestURI, identifier, this.logger); - validateRelativePath(path, identifier, this.logger); + const path = getRelativePath(this.baseRequestURI, identifier); + validateRelativePath(path, identifier); let filePath = getAbsolutePath(this.rootFilepath, path); diff --git a/src/storage/mapping/FixedContentTypeMapper.ts b/src/storage/mapping/FixedContentTypeMapper.ts index 1a01efd3e..700c6e799 100644 --- a/src/storage/mapping/FixedContentTypeMapper.ts +++ b/src/storage/mapping/FixedContentTypeMapper.ts @@ -29,8 +29,8 @@ export class FixedContentTypeMapper implements FileIdentifierMapper { } public async mapUrlToFilePath(identifier: ResourceIdentifier, contentType?: string): Promise { - const path = getRelativePath(this.baseRequestURI, identifier, this.logger); - validateRelativePath(path, identifier, this.logger); + const path = getRelativePath(this.baseRequestURI, identifier); + validateRelativePath(path, identifier); const filePath = getAbsolutePath(this.rootFilepath, path); diff --git a/src/storage/mapping/MapperUtil.ts b/src/storage/mapping/MapperUtil.ts index e3e660f6e..22f6b3a03 100644 --- a/src/storage/mapping/MapperUtil.ts +++ b/src/storage/mapping/MapperUtil.ts @@ -1,12 +1,14 @@ import { posix } from 'path'; import type { ResourceIdentifier } from '../../ldp/representation/ResourceIdentifier'; -import type { Logger } from '../../logging/Logger'; +import { getLoggerFor } from '../../logging/LogUtil'; import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError'; import { NotFoundHttpError } from '../../util/errors/NotFoundHttpError'; import { decodeUriPathComponents } from '../../util/PathUtil'; const { join: joinPath } = posix; +const logger = getLoggerFor('MapperUtil'); + /** * Get the absolute file path based on the rootFilepath of the store. * @param rootFilepath - The root file path. @@ -22,14 +24,13 @@ export const getAbsolutePath = (rootFilepath: string, path: string, identifier = * Strips the baseRequestURI from the identifier and checks if the stripped base URI matches the store's one. * @param baseRequestURI - Base URL for requests. * @param identifier - Incoming identifier. - * @param logger - A logger instance. * * @throws {@link NotFoundHttpError} * If the identifier does not match the baseRequestURI path of the store. * * @returns A string representing the relative path. */ -export const getRelativePath = (baseRequestURI: string, identifier: ResourceIdentifier, logger: Logger): string => { +export const getRelativePath = (baseRequestURI: string, identifier: ResourceIdentifier): string => { if (!identifier.path.startsWith(baseRequestURI)) { logger.warn(`The URL ${identifier.path} is outside of the scope ${baseRequestURI}`); throw new NotFoundHttpError(); @@ -45,9 +46,8 @@ export const getRelativePath = (baseRequestURI: string, identifier: ResourceIden * * @param path - A relative path, as generated by {@link getRelativePath}. * @param identifier - A resource identifier. - * @param logger - A logger instance. */ -export const validateRelativePath = (path: string, identifier: ResourceIdentifier, logger: Logger): void => { +export const validateRelativePath = (path: string, identifier: ResourceIdentifier): void => { if (!path.startsWith('/')) { logger.warn(`URL ${identifier.path} needs a / after the base`); throw new BadRequestHttpError('URL needs a / after the base');