-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivity.go
53 lines (41 loc) · 1.42 KB
/
activity.go
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
47
48
49
50
51
52
53
package gdrivedelete
import (
s "strings"
"github.com/DipeshTest/allstarsshared/gdrive"
"github.com/TIBCOSoftware/flogo-lib/core/activity"
"github.com/TIBCOSoftware/flogo-lib/logger"
)
// MyActivity is a stub for your Activity implementation
type MyActivity struct {
metadata *activity.Metadata
}
var log = logger.GetLogger("activity-gdrivedelete")
// NewActivity creates a new activity
func NewActivity(metadata *activity.Metadata) activity.Activity {
return &MyActivity{metadata: metadata}
}
// Metadata implements activity.Activity.Metadata
func (a *MyActivity) Metadata() *activity.Metadata {
return a.metadata
}
// Eval implements activity.Activity.Eval
func (a *MyActivity) Eval(context activity.Context) (done bool, err error) {
accessToken := s.TrimSpace(context.GetInput("accessToken").(string))
fileId := s.TrimSpace(context.GetInput("fileId").(string))
timeout := s.TrimSpace(context.GetInput("timeout").(string))
if len(s.TrimSpace(accessToken)) == 0 {
context.SetOutput("statusCode", "105")
context.SetOutput("message", "Access Token field is blank")
} else if len(s.TrimSpace(fileId)) == 0 {
context.SetOutput("statusCode", "106")
context.SetOutput("message", "File ID field is blank")
} else {
if len(timeout) == 0 {
timeout = "120"
}
code, msg := gdrive.DeleteFile(fileId, accessToken, timeout)
context.SetOutput("statusCode", code)
context.SetOutput("message", msg)
}
return true, err
}