Binary Resource Bug
Beim Erstellen von Binary Resources geht der rdf store verloren, was die Ressourcen nach dem Erstellen unbenutzbar macht.
Ein Beispiel Programm welches den Zustand des Facts/stores an verschiedenen Stellen der Erstellung zeigt (ausführbar in "/examples/binaryExample/"):
1. Nach Erstellung eines Candidates:
const candidate = service.getFactDagResourceFactory().createEmptyBinaryFactCandidate(resourceID, fs.createReadStream("./src/logo.png"), "image/png");
candidate.attributeToAuthority(idFactory.createAuthorityResourceID(authorityID));
candidate.addGeneratingActivity(activity)
console.log(candidate.resourceID)
console.log(candidate.serialize())
Output:
LdpResourceID {
toString: [Function (anonymous)],
_authorityID: 'http://localhost:8082',
_resourceID: '/facts/imgTest'
}
@prefix : </#>.
@prefix f: </facts/>.
@prefix prov: <http://www.w3.org/ns/prov#>.
f:imgTest
a prov:Entity;
prov:wasAttributedTo
"fact::http://localhost:8082/.well-known/factdag-authority";
prov:wasGeneratedBy
"fact:2020-08-17T10:03:25.000Z:http://localhost:8082/activities/binaryTest".
2. Nach Erstellen des Facts:
const fact = await service.createBinaryFactResource(candidate);
console.log(fact.factID)
console.log(fact.serialize())
Output:
LdpFactID {
toString: [Function (anonymous)],
_authorityID: 'http://localhost:8082',
_resourceID: '/facts/imgTest',
_revisionID: undefined
}
@prefix : </#>.
3. Und nach Abfrage der letzten Revision:
const resource = await service.getLastBinaryFactRevision(resourceID,"image/png");
console.log(resource.factID)
console.log(resource.serialize())
Output:
LdpFactID {
toString: [Function (anonymous)],
_authorityID: 'http://localhost:8082',
_resourceID: '/facts/imgTest',
_revisionID: 2020-08-17T10:03:26.000Z
}
@prefix : </#>.
Der rdf store wird also nicht mit in den Fact übernommen. Jegliche Methode die versucht die Resource zu nutzen, z.B. service.getRevisionListByID()
schlägt fehl mit
Error: This resources cannot be interpreted as a FactDAG element at Function.determineCorrectResource
Seltsamerweise scheint es allerdings noch einen zweiten store zu geben auf den beispielsweise trellis zugreift, da in der trellis Webansicht folgendes steht:
In createBinaryFactResource()
wird candidate.store
bereits nicht mehr verwendet:
public async createBinaryFactResource(candidate: BinaryFactCandidate<EmptyTrunk | LdpTrunk>): Promise<BinaryFact<LdpTrunk>> {
const location = candidate.resourceID.directory;
const ldpResource = await this.ldpClient.createLDPNonRDFSource(location, candidate.resourceID.resourceName, candidate.binaryContent, candidate.contentType);
const givenResourceID = this.idFactory.parseURIToResourceID(ldpResource.resourceURI.toString());
return this.factDagResourceFactory.createBinaryFact(ldpResource, givenResourceID);
}