Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

698 ldp patch import resource one by one #987

Merged
merged 62 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
df1b1f4
creating Mirror graph, protecting LDP actions against Mirror data
nikoPLP Jan 9, 2022
5a37663
fixing bug with root container not having his children as sub container
nikoPLP Jan 9, 2022
9e0daac
working void service for localData, need to test for mirror data
nikoPLP Jan 10, 2022
9907f66
creating Mirror graph, protecting LDP actions against Mirror data
nikoPLP Jan 9, 2022
776255c
Merge branch '849_mirror_service' of ssh://github.com/assemblee-virtu…
nikoPLP Jan 10, 2022
6627e10
first version of mirror service, brutaly mirrors everything everytime…
nikoPLP Jan 11, 2022
63471b2
starting the registry service asynchroniously again, so it can play w…
nikoPLP Jan 17, 2022
b81cb13
working void service for localData, need to test for mirror data
nikoPLP Jan 10, 2022
8de986a
creating Mirror graph, protecting LDP actions against Mirror data
nikoPLP Jan 9, 2022
c734b4a
first version of mirror service, brutaly mirrors everything everytime…
nikoPLP Jan 11, 2022
2f9819c
starting the registry service asynchroniously again, so it can play w…
nikoPLP Jan 17, 2022
97dafaf
Merge branch '849_mirror_service' of ssh://github.com/assemblee-virtu…
nikoPLP May 28, 2022
b3108d9
allowing multiple void#class in each partition
nikoPLP May 29, 2022
d913f9c
logging fdone properly at Mirror service startup. errors do not crash…
nikoPLP May 29, 2022
4269ba1
ldp.mirror service become independant mirror service. automatic creat…
nikoPLP May 31, 2022
3d32d03
FOLLOW of the relay actor once the mirror is done
nikoPLP Jun 1, 2022
3538c50
updateBot working well for create, update, delete. permission changes…
nikoPLP Jun 2, 2022
de26b7d
fix bug race condition on OIDC issuer retrieval
nikoPLP Jun 3, 2022
2e2ad02
ldp.container.isEmpty action
nikoPLP Jun 3, 2022
585b489
fixing the bug of first level containers not attached to root container
nikoPLP Jun 3, 2022
4f86bbf
UpdateBot: changing permissions sends activities to followers. it works
nikoPLP Jun 3, 2022
ab92036
docker service for migration + initial documentation
nikoPLP Jun 4, 2022
d574741
prettier
nikoPLP Jun 4, 2022
3f98975
working void service for localData, need to test for mirror data
nikoPLP Jan 10, 2022
872a7f6
creating Mirror graph, protecting LDP actions against Mirror data
nikoPLP Jan 9, 2022
f2647fa
first version of mirror service, brutaly mirrors everything everytime…
nikoPLP Jan 11, 2022
2970094
starting the registry service asynchroniously again, so it can play w…
nikoPLP Jan 17, 2022
99e4363
allowing multiple void#class in each partition
nikoPLP May 29, 2022
93690b2
logging fdone properly at Mirror service startup. errors do not crash…
nikoPLP May 29, 2022
2046418
ldp.mirror service become independant mirror service. automatic creat…
nikoPLP May 31, 2022
97d8596
FOLLOW of the relay actor once the mirror is done
nikoPLP Jun 1, 2022
2914013
updateBot working well for create, update, delete. permission changes…
nikoPLP Jun 2, 2022
52e506b
fix bug race condition on OIDC issuer retrieval
nikoPLP Jun 3, 2022
109f894
ldp.container.isEmpty action
nikoPLP Jun 3, 2022
8e7ef64
fixing the bug of first level containers not attached to root container
nikoPLP Jun 3, 2022
d6f8950
UpdateBot: changing permissions sends activities to followers. it works
nikoPLP Jun 3, 2022
4308567
docker service for migration + initial documentation
nikoPLP Jun 4, 2022
7bb4ac5
prettier
nikoPLP Jun 4, 2022
c04d38e
merge
nikoPLP Jun 4, 2022
6029cbc
Automatic prettier
nikoPLP Jun 4, 2022
733c3fc
prevent chain mirroring
nikoPLP Jun 5, 2022
331ea95
removing details in the 403 status text because it crashes the server…
nikoPLP Jun 5, 2022
dbefed2
Merge branch '849_mirror_service' of ssh://github.com/assemblee-virtu…
nikoPLP Jun 5, 2022
7ba2d78
Automatic prettier
nikoPLP Jun 5, 2022
d010efb
cleanup and more comments inline
nikoPLP Jun 5, 2022
4281239
prettier
nikoPLP Jun 5, 2022
a791775
PATCH action on containers. format is SPARQL-UPDATE
nikoPLP Jun 5, 2022
0a6dcf2
prettier
nikoPLP Jun 5, 2022
b7bab59
cron to refresh every hour the orphan mirrored resources + detach a r…
nikoPLP Jun 5, 2022
a693863
fix iteration on parsed sparql
nikoPLP Jun 5, 2022
311b6b7
Use same SemApps package versions for mirror service
srosset81 Jun 20, 2022
4a3b8bf
fix bug migration
nikoPLP Jun 23, 2022
cf75d68
Merge branch '698_ldp_patch_import_resource_one_by_one' of ssh://gith…
nikoPLP Jun 23, 2022
93dcb39
fixing all comments in merge request
nikoPLP Jun 23, 2022
963b521
prettier
nikoPLP Jun 23, 2022
5524eac
preferred view redirect. fixes #771
nikoPLP Jun 24, 2022
1d49099
prettier
nikoPLP Jun 24, 2022
fe3a72c
doc for preferre view
nikoPLP Jun 24, 2022
4382535
more cosmetic fixes
nikoPLP Jun 27, 2022
483dd5e
Automatic prettier
nikoPLP Jun 27, 2022
06e1958
binding this to preferredViewForResource so user can access broker
nikoPLP Jun 27, 2022
5a51bf5
Add missing predicate in context
srosset81 Jun 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/middleware/packages/ldp/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ module.exports = {
containers: [],
podProvider: false,
mirrorGraphName: 'http://semapps.org/mirror',
defaultContainerOptions: {}
defaultContainerOptions: {},
preferredViewForResource: null,
},
dependencies: ['ldp.container', 'ldp.resource', 'ldp.registry'],
async created() {
const { baseUrl, containers, ontologies, podProvider, defaultContainerOptions, mirrorGraphName } = this.settings;
const { baseUrl, containers, ontologies, podProvider, defaultContainerOptions, mirrorGraphName, preferredViewForResource } = this.settings;

await this.broker.createService(LdpContainerService, {
settings: {
Expand All @@ -32,7 +33,8 @@ module.exports = {
baseUrl,
ontologies,
podProvider,
mirrorGraphName
mirrorGraphName,
preferredViewForResource
},
hooks: this.schema.hooksResource || {}
});
Expand Down
30 changes: 25 additions & 5 deletions src/middleware/packages/ldp/services/resource/actions/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,35 @@ module.exports = {
api: async function api(ctx) {
const { id, containerUri } = ctx.params;
const resourceUri = urlJoin(containerUri, id);
const { accept, controlledActions } = {
const { accept, controlledActions, preferredView } = {
...(await ctx.call('ldp.registry.getByUri', { resourceUri })),
...ctx.meta.headers
};
try {
ctx.meta.$responseType = ctx.meta.$responseType || accept;
return await ctx.call(controlledActions.get || 'ldp.resource.get', {

if (ctx.meta.accepts && ctx.meta.accepts.includes('text/html') && this.settings.preferredViewForResource) {
const webId = ctx.meta.webId || 'anon';
const resourceExist = await ctx.call('ldp.resource.exist', { resourceUri, webId });
if (resourceExist) {
const redirect = await this.settings.preferredViewForResource(resourceUri, preferredView);
srosset81 marked this conversation as resolved.
Show resolved Hide resolved
if (redirect && redirect !== resourceUri) {
ctx.meta.$statusCode = 302
ctx.meta.$location = redirect
ctx.meta.$responseHeaders = {
'Content-Length': 0
};
return;
}
}
}

const res = await ctx.call(controlledActions.get || 'ldp.resource.get', {
resourceUri,
accept
});
ctx.meta.$responseType = ctx.meta.$responseType || accept;
return res;

} catch (e) {
console.error(e);
ctx.meta.$statusCode = e.code || 500;
Expand Down Expand Up @@ -65,14 +84,15 @@ module.exports = {
...ctx.params
};

const mirror = isMirror(resourceUri, this.settings.baseUrl);

const resourceExist = await ctx.call('ldp.resource.exist', { resourceUri, webId });

if (resourceExist) {

const blandNodeQuery = buildBlankNodesQuery(queryDepth);
const dereferenceQuery = buildDereferenceQuery(dereference);

const mirror = isMirror(resourceUri, this.settings.baseUrl);

let result = await ctx.call('triplestore.query', {
query: `
${getPrefixRdf(this.settings.ontologies)}
Expand Down
3 changes: 2 additions & 1 deletion src/middleware/packages/ldp/services/resource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = {
baseUrl: null,
ontologies: [],
podProvider: false,
mirrorGraphName: null
mirrorGraphName: null,
preferredViewForResource: null
},
dependencies: ['triplestore', 'jsonld'],
actions: {
Expand Down
2 changes: 2 additions & 0 deletions src/middleware/packages/middlewares/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const throw500 = msg => {

const negotiateAccept = (req, res, next) => {
if (!req.$ctx.meta.headers) req.$ctx.meta.headers = {};
// we keep the full list for further use
req.$ctx.meta.accepts = req.headers.accept;
if (req.headers.accept === '*/*') req.headers.accept = undefined;
if (req.headers.accept !== undefined) {
try {
Expand Down
1 change: 0 additions & 1 deletion src/middleware/packages/mime-types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const negotiateType = function(incomingType) {
accept: negotiatorType
}
});

const rawNegotiatedAccept = negotiator.mediaType(availableMediaTypes);
if (rawNegotiatedAccept !== undefined) {
return TYPES_REPO.filter(tr => tr.mimeFull.includes(rawNegotiatedAccept))[0];
Expand Down