@@ -2,11 +2,10 @@ import fetch from "node-fetch";
2
2
import { app } from "../app" ;
3
3
import { Decorators } from "divaservices-utils" ;
4
4
import {
5
- USERNAME ,
6
- PASSWORD ,
7
5
SERVICES_API ,
8
6
WEBSERVICES_XML_FILEPATH ,
9
- COLLECTIONS_API
7
+ COLLECTIONS_API ,
8
+ WORKFLOWS_API
10
9
} from "../../config" ;
11
10
12
11
export const getServicesAPI = async ( ) => {
@@ -21,7 +20,7 @@ export const getServicesAPI = async () => {
21
20
return xml ;
22
21
} ;
23
22
24
- export const sendWorkflowSteps = xml => {
23
+ export const sendWorkflowSteps = async ( xml , installation = false ) => {
25
24
// const xhr = new XMLHttpRequest();
26
25
// xhr.open(
27
26
// "POST",
@@ -34,36 +33,67 @@ export const sendWorkflowSteps = xml => {
34
33
// xhr.setRequestHeader("password", PASSWORD);
35
34
// xhr.send(xml);
36
35
37
- fetch (
38
- "http://diufvm17.unifr.ch:8080/exist/projects/diae/api/workflow/save?id=" +
39
- app . workflowId ,
40
- {
41
- method : "POST" ,
42
- body : xml ,
43
- headers : {
44
- "Content-Type" : "text/xml" ,
45
- username : USERNAME ,
46
- password : PASSWORD
47
- }
36
+ const install = installation ? "install=true&" : "" ;
37
+
38
+ return await fetch ( `${ WORKFLOWS_API } /save?${ install } id=${ app . workflowId } ` , {
39
+ method : "POST" ,
40
+ body : xml ,
41
+ headers : {
42
+ "Content-Type" : "text/xml"
48
43
}
49
- ) ;
44
+ } ) ;
50
45
} ;
51
46
52
47
export const openWorkflowFromId = async id => {
53
48
let xml ;
54
49
if ( process . env . NODE_ENV === "production" ) {
55
- const workflow = await fetch (
56
- "http://diufvm17.unifr.ch:8080/exist/projects/diae/api/workflow?id=" + id ,
57
- {
58
- headers : {
59
- "Content-Type" : "text/xml"
60
- }
50
+ const workflow = await fetch ( `${ WORKFLOWS_API } ?id=${ id } ` , {
51
+ headers : {
52
+ "Content-Type" : "text/xml"
61
53
}
62
- ) ;
54
+ } ) ;
63
55
xml = await workflow . text ( ) ;
64
56
} else {
65
- const filepath = "api/example.xml" ;
66
- xml = ( await import ( `!!raw-loader!../../${ filepath } ` ) ) . default ;
57
+ xml = `<Workflow>
58
+ <Id>116</Id>
59
+ <Information>
60
+ <Name>new rofklow</Name>
61
+ <Author/>
62
+ </Information>
63
+ <Steps>
64
+ <Step>
65
+ <No>0</No>
66
+ <Name>OcropusBinarization</Name>
67
+ <Service>
68
+ <Key>6</Key>
69
+ </Service>
70
+ <Inputs>
71
+ <Data>
72
+ <Name>inputImage</Name>
73
+ <Path>qwertz/2299942_0.jpg</Path>
74
+ </Data>
75
+ </Inputs>
76
+ </Step>
77
+ <Step>
78
+ <No>1</No>
79
+ <Name>OtsuBinarization</Name>
80
+ <Service>
81
+ <Key>0</Key>
82
+ </Service>
83
+ <Inputs>
84
+ <Data>
85
+ <Name>inputImage</Name>
86
+ <Value>
87
+ <WorkflowStep>
88
+ <Ref>0</Ref>
89
+ <ServiceOutputName>ocropusBinaryImage</ServiceOutputName>
90
+ </WorkflowStep>
91
+ </Value>
92
+ </Data>
93
+ </Inputs>
94
+ </Step>
95
+ </Steps>
96
+ </Workflow>` ;
67
97
}
68
98
return xml ;
69
99
} ;
@@ -248,120 +278,6 @@ export const getCollectionsAPI = async () => {
248
278
</File>
249
279
</Files>
250
280
</Collection>
251
- <Collection>
252
- <Id>134</Id>
253
- <Url>http://134.21.72.190:8080/collections/qwertz</Url>
254
- <Author/>
255
- <Name>qwertz</Name>
256
- <Files>
257
- <File>
258
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
259
- <Identifier>qwertz/2299942_0.jpg</Identifier>
260
- <Options>
261
- <Mime-type>image/jpeg</Mime-type>
262
- </Options>
263
- </File>
264
- <File>
265
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
266
- <Identifier>qwertz/2299942_0.jpg</Identifier>
267
- <Options>
268
- <Mime-type>image/jpeg</Mime-type>
269
- </Options>
270
- </File>
271
- <File>
272
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
273
- <Identifier>qwertz/2299942_0.jpg</Identifier>
274
- <Options>
275
- <Mime-type>image/jpeg</Mime-type>
276
- </Options>
277
- </File>
278
- <File>
279
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299913_0.jpg</Url>
280
- <Identifier>qwertz/2299913_0.jpg</Identifier>
281
- <Options>
282
- <Mime-type>image/jpeg</Mime-type>
283
- </Options>
284
- </File>
285
- <File>
286
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299918_0.jpg</Url>
287
- <Identifier>qwertz/2299918_0.jpg</Identifier>
288
- <Options>
289
- <Mime-type>image/jpeg</Mime-type>
290
- </Options>
291
- </File>
292
- <File>
293
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299907_0.jpg</Url>
294
- <Identifier>qwertz/2299907_0.jpg</Identifier>
295
- <Options>
296
- <Mime-type>image/jpeg</Mime-type>
297
- </Options>
298
- </File>
299
- <File>
300
- <Url>http://134.21.72.190:8080/files/qwertz/original/2986434_0.jpg</Url>
301
- <Identifier>qwertz/2986434_0.jpg</Identifier>
302
- <Options>
303
- <Mime-type>image/jpeg</Mime-type>
304
- </Options>
305
- </File>
306
- </Files>
307
- </Collection>
308
- <Collection>
309
- <Id>134</Id>
310
- <Url>http://134.21.72.190:8080/collections/qwertz</Url>
311
- <Author/>
312
- <Name>qwertz</Name>
313
- <Files>
314
- <File>
315
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
316
- <Identifier>qwertz/2299942_0.jpg</Identifier>
317
- <Options>
318
- <Mime-type>image/jpeg</Mime-type>
319
- </Options>
320
- </File>
321
- <File>
322
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
323
- <Identifier>qwertz/2299942_0.jpg</Identifier>
324
- <Options>
325
- <Mime-type>image/jpeg</Mime-type>
326
- </Options>
327
- </File>
328
- <File>
329
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
330
- <Identifier>qwertz/2299942_0.jpg</Identifier>
331
- <Options>
332
- <Mime-type>image/jpeg</Mime-type>
333
- </Options>
334
- </File>
335
- <File>
336
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299913_0.jpg</Url>
337
- <Identifier>qwertz/2299913_0.jpg</Identifier>
338
- <Options>
339
- <Mime-type>image/jpeg</Mime-type>
340
- </Options>
341
- </File>
342
- <File>
343
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299918_0.jpg</Url>
344
- <Identifier>qwertz/2299918_0.jpg</Identifier>
345
- <Options>
346
- <Mime-type>image/jpeg</Mime-type>
347
- </Options>
348
- </File>
349
- <File>
350
- <Url>http://134.21.72.190:8080/files/qwertz/original/2299907_0.jpg</Url>
351
- <Identifier>qwertz/2299907_0.jpg</Identifier>
352
- <Options>
353
- <Mime-type>image/jpeg</Mime-type>
354
- </Options>
355
- </File>
356
- <File>
357
- <Url>http://134.21.72.190:8080/files/qwertz/original/2986434_0.jpg</Url>
358
- <Identifier>qwertz/2986434_0.jpg</Identifier>
359
- <Options>
360
- <Mime-type>image/jpeg</Mime-type>
361
- </Options>
362
- </File>
363
- </Files>
364
- </Collection>
365
281
<Collection>
366
282
<Id>134</Id>
367
283
<Url>http://134.21.72.190:8080/collections/qwertz</Url>
0 commit comments