gooddata 0.6.0.pre5 → 0.6.0.pre6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +26 -7
- data/lib/gooddata/client.rb +17 -3
- data/lib/gooddata/commands/process.rb +1 -1
- data/lib/gooddata/connection.rb +11 -11
- data/lib/gooddata/model.rb +1 -1
- data/lib/gooddata/models/project.rb +4 -0
- data/lib/gooddata/version.rb +1 -1
- metadata +1 -1
@@ -10,17 +10,36 @@ module GoodData::Bricks
|
|
10
10
|
token = params[:salesforce_token]
|
11
11
|
client_id = params[:salesforce_client_id]
|
12
12
|
client_secret = params[:salesforce_client_secret]
|
13
|
-
|
14
|
-
|
13
|
+
oauth_token = params[:salesforce_oauth_token]
|
14
|
+
refresh_token = params[:salesforce_refresh_token]
|
15
|
+
host = params[:salesforce_host]
|
16
|
+
|
17
|
+
credentials = {}
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
credentials = if (username && password && token)
|
20
|
+
{
|
21
|
+
:username => username,
|
22
|
+
:password => password,
|
23
|
+
:security_token => token
|
24
|
+
}
|
25
|
+
elsif (oauth_token && refresh_token)
|
26
|
+
{
|
27
|
+
:oauth_token => oauth_token,
|
28
|
+
:refresh_token => refresh_token
|
29
|
+
}
|
30
|
+
else
|
31
|
+
fail "Salesforce middleware failed while trying to log in. Either salesforce_username, salesforce_password, salesforce_token or salesforce_oauth_token, salesforce_refresh_token are needed. Additionally you have to specify salesforce_client_id and salesforce_client_secret parameters in both cases"
|
32
|
+
end
|
20
33
|
|
34
|
+
|
35
|
+
credentials.merge!({
|
21
36
|
:client_id => client_id,
|
22
|
-
:client_secret => client_secret
|
37
|
+
:client_secret => client_secret,
|
38
|
+
})
|
39
|
+
credentials[:host] = host unless host.nil?
|
23
40
|
|
41
|
+
Restforce.log = true if params[:salesforce_client_logger]
|
42
|
+
client = Restforce.new(credentials)
|
24
43
|
@app.call(params.merge(:salesforce_client => client))
|
25
44
|
end
|
26
45
|
|
data/lib/gooddata/client.rb
CHANGED
@@ -119,7 +119,7 @@ module GoodData
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def with_project(project, &bl)
|
122
|
-
fail "You have to specify a project when using with_project" if project.nil? || project.empty?
|
122
|
+
fail "You have to specify a project when using with_project" if project.nil? || (project.is_a?(String) && project.empty?)
|
123
123
|
old_project = GoodData.project
|
124
124
|
begin
|
125
125
|
GoodData.use(project)
|
@@ -233,8 +233,22 @@ module GoodData
|
|
233
233
|
connection.delete path, options
|
234
234
|
end
|
235
235
|
|
236
|
-
def
|
237
|
-
connection.
|
236
|
+
def upload_to_user_webdav(file, options={})
|
237
|
+
u = URI(connection.options[:webdav_server] || GoodData.project.links["uploads"])
|
238
|
+
url = URI.join(u.to_s.chomp(u.path.to_s), "/uploads/")
|
239
|
+
connection.upload(file, options.merge({
|
240
|
+
:directory => options[:directory],
|
241
|
+
:staging_url => url
|
242
|
+
}))
|
243
|
+
end
|
244
|
+
|
245
|
+
def upload_to_project_webdav(file, options={})
|
246
|
+
u = URI(connection.options[:webdav_server] || GoodData.project.links["uploads"])
|
247
|
+
url = URI.join(u.to_s.chomp(u.path.to_s), "/project-uploads/", "#{GoodData.project.pid}/")
|
248
|
+
connection.upload(file, options.merge({
|
249
|
+
:directory => options[:directory],
|
250
|
+
:staging_url => url
|
251
|
+
}))
|
238
252
|
end
|
239
253
|
|
240
254
|
def poll(result, key, options={})
|
data/lib/gooddata/connection.rb
CHANGED
@@ -32,10 +32,9 @@ module GoodData
|
|
32
32
|
DEFAULT_URL = 'https://secure.gooddata.com'
|
33
33
|
LOGIN_PATH = '/gdc/account/login'
|
34
34
|
TOKEN_PATH = '/gdc/account/token'
|
35
|
-
STAGE_PATH = '/uploads/'
|
36
35
|
|
37
36
|
attr_reader(:auth_token, :url)
|
38
|
-
attr_accessor :status
|
37
|
+
attr_accessor :status, :options
|
39
38
|
|
40
39
|
|
41
40
|
# Options:
|
@@ -196,14 +195,15 @@ module GoodData
|
|
196
195
|
# Uploads a file to GoodData server
|
197
196
|
# /uploads/ resources are special in that they use a different
|
198
197
|
# host and a basic authentication.
|
199
|
-
def upload(file,
|
198
|
+
def upload(file, options={})
|
200
199
|
ensure_connection
|
201
|
-
# We should have followed a link. If it was correct.
|
202
200
|
|
203
|
-
|
201
|
+
dir = options[:directory] || ''
|
202
|
+
staging_uri = options[:staging_url].to_s
|
203
|
+
url = dir.empty? ? staging_uri : URI.join(staging_uri, "#{dir}/").to_s
|
204
|
+
|
204
205
|
# Make a directory, if needed
|
205
|
-
|
206
|
-
url = stage_url + STAGE_PATH + dir + '/'
|
206
|
+
unless dir.empty? then
|
207
207
|
method = :get
|
208
208
|
GoodData.logger.debug "#{method}: #{url}"
|
209
209
|
begin
|
@@ -230,17 +230,17 @@ module GoodData
|
|
230
230
|
)
|
231
231
|
end
|
232
232
|
end
|
233
|
-
else
|
234
|
-
dir = "."
|
235
233
|
end
|
236
234
|
|
237
235
|
payload = options[:stream] ? "file" : File.read(file)
|
238
236
|
filename = options[:filename] || options[:stream] ? "randome-filename.txt" : File.basename(file)
|
239
237
|
|
240
238
|
# Upload the file
|
239
|
+
puts "uploading the file #{URI.join(url, filename).to_s}"
|
240
|
+
|
241
241
|
req = RestClient::Request.new({
|
242
242
|
:method => :put,
|
243
|
-
:url =>
|
243
|
+
:url => URI.join(url, filename).to_s,
|
244
244
|
:timeout => @options[:timeout],
|
245
245
|
:headers => {
|
246
246
|
:user_agent => GoodData.gem_version_string,
|
@@ -249,7 +249,7 @@ module GoodData
|
|
249
249
|
:raw_response => true
|
250
250
|
}.merge(cookies))
|
251
251
|
resp = req.execute
|
252
|
-
|
252
|
+
true
|
253
253
|
end
|
254
254
|
|
255
255
|
def download(what, where)
|
data/lib/gooddata/model.rb
CHANGED
@@ -491,7 +491,7 @@ module GoodData
|
|
491
491
|
end
|
492
492
|
|
493
493
|
# upload it
|
494
|
-
GoodData.
|
494
|
+
GoodData.upload_to_user_webdav("#{dir}/upload.zip", :directory => File.basename(dir))
|
495
495
|
FileUtils.rm_rf dir
|
496
496
|
|
497
497
|
# kick the load
|
data/lib/gooddata/version.rb
CHANGED