mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Use ldp: prefix in container representations.
This commit is contained in:
parent
f66096a60b
commit
ba42861699
@ -22,7 +22,7 @@ import {
|
|||||||
} from '../util/PathUtil';
|
} from '../util/PathUtil';
|
||||||
import { parseQuads } from '../util/QuadUtil';
|
import { parseQuads } from '../util/QuadUtil';
|
||||||
import { generateResourceQuads } from '../util/ResourceUtil';
|
import { generateResourceQuads } from '../util/ResourceUtil';
|
||||||
import { CONTENT_TYPE, HTTP, LDP, PIM, RDF } from '../util/Vocabularies';
|
import { CONTENT_TYPE, HTTP, LDP, PIM, RDF, VANN } from '../util/Vocabularies';
|
||||||
import type { DataAccessor } from './accessors/DataAccessor';
|
import type { DataAccessor } from './accessors/DataAccessor';
|
||||||
import type { ResourceStore } from './ResourceStore';
|
import type { ResourceStore } from './ResourceStore';
|
||||||
|
|
||||||
@ -63,10 +63,18 @@ export class DataAccessorBasedStore implements ResourceStore {
|
|||||||
|
|
||||||
// In the future we want to use getNormalizedMetadata and redirect in case the identifier differs
|
// In the future we want to use getNormalizedMetadata and redirect in case the identifier differs
|
||||||
const metadata = await this.accessor.getMetadata(identifier);
|
const metadata = await this.accessor.getMetadata(identifier);
|
||||||
|
let representation: Representation;
|
||||||
|
|
||||||
return this.isExistingContainer(metadata) ?
|
if (this.isExistingContainer(metadata)) {
|
||||||
new BasicRepresentation(metadata.quads(), metadata, INTERNAL_QUADS) :
|
// Generate a container representation from the metadata
|
||||||
new BasicRepresentation(await this.accessor.getData(identifier), metadata);
|
const data = metadata.quads();
|
||||||
|
metadata.addQuad(LDP.terms.namespace, VANN.terms.preferredNamespacePrefix, 'ldp');
|
||||||
|
representation = new BasicRepresentation(data, metadata, INTERNAL_QUADS);
|
||||||
|
} else {
|
||||||
|
// Retrieve a document representation from the accessor
|
||||||
|
representation = new BasicRepresentation(await this.accessor.getData(identifier), metadata);
|
||||||
|
}
|
||||||
|
return representation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async addResource(container: ResourceIdentifier, representation: Representation): Promise<ResourceIdentifier> {
|
public async addResource(container: ResourceIdentifier, representation: Representation): Promise<ResourceIdentifier> {
|
||||||
|
@ -57,6 +57,17 @@ describe.each(stores)('An LDP handler without auth using %s', (name, { storeUrn,
|
|||||||
await teardown();
|
await teardown();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can read a folder listing.', async():
|
||||||
|
Promise<void> => {
|
||||||
|
const response = await resourceHelper.getResource(`${BASE}/`);
|
||||||
|
expect(response.statusCode).toBe(200);
|
||||||
|
expect(response.getHeaders()).toHaveProperty('content-type', 'text/turtle');
|
||||||
|
|
||||||
|
const data = response._getData().toString();
|
||||||
|
expect(data).toContain(`<${BASE}/> a ldp:Container`);
|
||||||
|
expect(response.getHeaders().link).toContain(`<${LDP.Container}>; rel="type"`);
|
||||||
|
});
|
||||||
|
|
||||||
it('can add a file to the store, read it and delete it.', async():
|
it('can add a file to the store, read it and delete it.', async():
|
||||||
Promise<void> => {
|
Promise<void> => {
|
||||||
// POST
|
// POST
|
||||||
|
Loading…
x
Reference in New Issue
Block a user