blob: 5b098b93e7b5d64d4b15a86fa0a027745e975cbc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package edu.stsci.jscu
import groovy.json.JsonOutput
import org.apache.commons.io.FileUtils
import com.cloudbees.groovy.cps.NonCPS
class DataConfig implements Serializable {
String root = '.'
String server_id = ''
String match_prefix = '(.*)'
String direction
Boolean managed = true
Boolean keep_data = false
int keep_builds = 20
int keep_days = 10
def data = [:]
DataConfig(String direction = "upload") {
this.direction = direction.toLowerCase()
if (!this.isUpload() && !this.isDownload()) {
throw new Exception("DataConfig.direction argument must be 'upload'"
+ "or 'download' (got: ${this.direction})")
}
}
@NonCPS
def isUpload() {
return this.direction.startsWith('u')
}
@NonCPS
def isDownload() {
return this.direction.startswith('d')
}
def insert(String name, String block) {
/* Store JSON directly as string */
this.data[name] = block
}
def insert(String name, block=[:]) {
/* Convert a Groovy Map to JSON and store it */
this.data[name] = JsonOutput.toJson(block)
}
}
|