added svcapi ui and camunda code
[it/otf.git] / otf-frontend / server / src / feathers / services / test-instances / test-instances.hooks.js
1 /*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
2 #                                                                              #\r
3 #   Licensed under the Apache License, Version 2.0 (the "License");            #\r
4 #   you may not use this file except in compliance with the License.           #\r
5 #   You may obtain a copy of the License at                                    #\r
6 #                                                                              #\r
7 #       http://www.apache.org/licenses/LICENSE-2.0                             #\r
8 #                                                                              #\r
9 #   Unless required by applicable law or agreed to in writing, software        #\r
10 #   distributed under the License is distributed on an "AS IS" BASIS,          #\r
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
12 #   See the License for the specific language governing permissions and        #\r
13 #   limitations under the License.                                             #\r
14 ##############################################################################*/\r
15 \r
16 \r
17 const { authenticate } = require('@feathersjs/authentication').hooks;\r
18 const { iff } = require('feathers-hooks-common');\r
19 const { permissions, limitFields } = require('../../hooks/permissions/permissions');\r
20 const convertToJSON = require('../../hooks/convertToJSON.js');\r
21 const convertToYAML = require('../../hooks/convertToYAML.js');\r
22 const testDefinitionIsDeployed = require('../../hooks/testDefinitionIsDeployed.js');\r
23 const {skipRemainingHooks} = require('feathers-hooks-common');\r
24 \r
25 \r
26 module.exports = {\r
27         before: {\r
28                 all: [authenticate('jwt'), permissions('testInstances')],\r
29                 find: [],\r
30                 get: [],\r
31                 create: [iff(testDefinitionIsDeployed(), convertToJSON()).else(function(context) {\r
32                         \r
33                         throw new Error('Test Definition Must have a deployed BPMN.');\r
34                         \r
35                   }\r
36          )],\r
37                 update: [convertToJSON()],\r
38                 patch: [],\r
39                 remove: [\r
40                 ]\r
41         },\r
42 \r
43         after: {\r
44                 all: [],\r
45                 find: [convertToYAML()],\r
46                 get: [ convertToYAML()],\r
47                 create: [],\r
48                 update: [],\r
49                 patch: [],\r
50                 remove: []\r
51         },\r
52 \r
53         error: {\r
54                 all: [],\r
55                 find: [],\r
56                 get: [],\r
57                 create: [],\r
58                 update: [],\r
59                 patch: [],\r
60                 remove: []\r
61         }\r
62 };\r