adobe-aem-api 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Mzc4NzY1OGQyYjRiYzJmMDRiZjIyYmE2YzIyNzU1NzY4NDQzNTU0Mw==
5
- data.tar.gz: !binary |-
6
- NjQ4ODE4NTEzMTliMmY5YjRkNjIxZmU2MWJkMjcwZTk5ZTc2OGQ0ZQ==
2
+ SHA1:
3
+ metadata.gz: 9af6c6e5944dba21c3a02679fed84c94f6479593
4
+ data.tar.gz: d328c58d6060bce53d1a3287e0c4678bdbb19efa
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YjRmYTcxODlhZjQ3OTEyZTBiOGJhY2I2NWQ4MzJlYWZkMzNmMzIyZWQ4MzIz
10
- YjQ4Y2JlMDFkZTZlMGUxOTQwNTE5NzQwODk1YjVlMTM3Njc2ZjEyZTJkNGNh
11
- YjgxN2RjYjIyNWU1NzE1NDJlZDY4MjJhYjhlYjNmNWJjYTllNGU=
12
- data.tar.gz: !binary |-
13
- MDE4NzJmOThhMWY2NTQ3ZTVkMWFhOWFlNGE4NzEyOGJmZTIyNWZiNDNjZmYw
14
- OTc0MWMwMzYxYzM0NTg2MDEzYTBhZjgzYjcwMDYzYThkZjQyMzI4ODRmOGM2
15
- YmFlZWYwZWViMDI0OGVhNzM5NWQyZTk1YWMzOWYwZWQ5MmRhMWY=
6
+ metadata.gz: 5fea19ab39c42c2bf88a0e5ebf52641f63672ce52204f824200df419f7b54ffe193cf8fdf2bf927d158ea272a804f371ee32d82d4cf5bd59be4c09898057b921
7
+ data.tar.gz: cc95a848a862ec798ad7cdf20630641ae7e567c16a51e899f6f540643350938813c3d28eff62432793d8c50fe0f74cdb18ff8cc65be1f3112e9454007aad38a9
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adobe-aem-api (0.0.5)
4
+ adobe-aem-api (0.0.6)
5
+ multipart-post
5
6
  nokogiri
6
7
  recursive-open-struct
7
8
 
@@ -14,11 +15,12 @@ GEM
14
15
  diff-lcs (1.2.5)
15
16
  flexmock (0.9.0)
16
17
  metaclass (0.0.4)
17
- mini_portile (0.5.3)
18
+ mini_portile (0.6.2)
18
19
  mocha (0.13.3)
19
20
  metaclass (~> 0.0.1)
20
- nokogiri (1.6.1)
21
- mini_portile (~> 0.5.0)
21
+ multipart-post (2.0.0)
22
+ nokogiri (1.6.5)
23
+ mini_portile (~> 0.6.0)
22
24
  rack (1.5.2)
23
25
  rack-protection (1.5.3)
24
26
  rack
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'webmock', '~>1.18.0'
29
29
  spec.add_runtime_dependency 'recursive-open-struct'
30
30
  spec.add_runtime_dependency 'nokogiri'
31
+ spec.add_runtime_dependency 'multipart-post'
31
32
  end
@@ -3,6 +3,7 @@ require 'net/http'
3
3
  require 'json'
4
4
  require 'recursive-open-struct'
5
5
  require 'nokogiri'
6
+ require 'net/http/post/multipart'
6
7
 
7
8
  self_dir = File.dirname(__FILE__)
8
9
  Dir["#{self_dir}/**/*.rb"].each do |lib|
@@ -1,29 +1,32 @@
1
+ require 'adobe/aem/replication'
2
+ require 'adobe/aem/site_admin'
3
+ require 'adobe/aem/system'
4
+ require 'adobe/aem/crx_system'
5
+
1
6
  module Adobe
2
7
  module Aem
3
8
  class Api
4
9
  attr_reader :context
5
10
 
11
+ class << self
12
+ def proxy(name, klass)
13
+ define_method name do
14
+ klass.new(@context)
15
+ end
16
+ end
17
+ end
18
+
6
19
  def initialize(options = {})
7
20
  @context = Context.new
8
21
  @context.configuration = Configuration.new(options)
9
22
  @context.connector = Connector.new(@context)
10
23
  end
11
24
 
12
- def replication
13
- Replication.new(@context)
14
- end
25
+ proxy :replication, Replication
26
+ proxy :system, System
27
+ proxy :crx, CrxSystem
28
+ proxy :siteadmin, SiteAdmin
15
29
 
16
- def siteadmin
17
- SiteAdmin.new(@context)
18
- end
19
-
20
- def system
21
- System.new(@context)
22
- end
23
-
24
- def crx
25
- CrxSystem.new(@context)
26
- end
27
30
  end
28
31
  end
29
32
  end
@@ -34,6 +34,12 @@ module Adobe
34
34
  verify(response)
35
35
  end
36
36
 
37
+ def multipart_post(path, data = {}, headers = {})
38
+ post = request(path, 'POST', data)
39
+ response = http.request(post)
40
+ verify(response)
41
+ end
42
+
37
43
  def post(path, data = {}, headers = {})
38
44
  post = request(path, 'POST')
39
45
  post.form_data = data unless data.empty?
@@ -78,15 +84,19 @@ module Adobe
78
84
  end
79
85
 
80
86
  private
81
- def request(path, type='GET')
87
+ def request(path, type='GET', data = {})
82
88
  r = if type == 'GET'
83
89
  Net::HTTP::Get.new(path)
90
+ elsif !data.empty?
91
+ Net::HTTP::Post::Multipart.new(path, data)
84
92
  else
85
93
  Net::HTTP::Post.new(path)
86
94
  end
95
+
87
96
  r.basic_auth @context.configuration.username, @context.configuration.password
88
97
  r['Accept'] = 'application/json'
89
- r['Content-Type'] = 'application/json'
98
+ r['Content-Type'] = 'application/json' unless r.is_a?(Net::HTTP::Post::Multipart)
99
+
90
100
  r
91
101
  end
92
102
 
@@ -101,6 +111,8 @@ module Adobe
101
111
  def verify(response)
102
112
  raise StandardError.new(response.class.to_s) unless
103
113
  [Net::HTTPOK, Net::HTTPCreated, Net::HTTPFound].include?(response.class)
114
+
115
+ response
104
116
  end
105
117
 
106
118
  def parse_json(string)
@@ -76,7 +76,6 @@ module Adobe
76
76
  private
77
77
  def set(name, value)
78
78
  field_name = name.to_s.gsub(/=$/, '')
79
- puts "Setting #{@path} #{field_name} to #{value}"
80
79
  @context.connector.set(@path, field_name, value)
81
80
  end
82
81
  end
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  module Adobe
2
4
  module Aem
3
5
  class System
@@ -8,6 +10,32 @@ module Adobe
8
10
  def update_configuration(name, options)
9
11
  @context.connector.post("/system/console/configMgr/#{name}", options)
10
12
  end
13
+
14
+ def uninstall_bundle(name)
15
+ @context.connector.post("/system/console/bundles/#{name}", action: 'uninstall')
16
+ end
17
+ def stop_bundle(name)
18
+ @context.connector.post("/system/console/bundles/#{name}", action: 'stop')
19
+ end
20
+ def start_bundle(name)
21
+ @context.connector.post("/system/console/bundles/#{name}", action: 'start')
22
+ end
23
+
24
+ def refresh_bundle_imports(name)
25
+ @context.connector.post("/system/console/bundles/#{name}", action: 'refresh')
26
+ end
27
+
28
+ def install_bundle(path)
29
+ options = {
30
+ action: :install,
31
+ bundleStartLevel: 20
32
+ }
33
+
34
+ raise "File: #{path} does not exist" unless File.exists?(path)
35
+ options[:bundlefile] = UploadIO.new(path, 'application/java-archive')
36
+
37
+ @context.connector.multipart_post('/system/console/bundles', options)
38
+ end
11
39
  end
12
40
  end
13
41
  end
@@ -1,5 +1,5 @@
1
1
  module Adobe
2
2
  module Aem
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
5
5
  end
@@ -5,11 +5,11 @@ module Adobe
5
5
  describe Api do
6
6
  describe 'Default values' do
7
7
  before(:all) do
8
- @sinatra_app = MockAem.run
8
+ MockAem.run
9
9
  end
10
10
 
11
11
  after(:all) do
12
- @sinatra_app.quit!
12
+ MockAem.quit!
13
13
  end
14
14
 
15
15
  subject do
@@ -38,8 +38,8 @@ module Adobe
38
38
  end
39
39
 
40
40
  it 'should return list of replication agents' do
41
- subject.should have_at_least(2).agent_types
42
- expect(subject).to have_at_least(1).agent_types
41
+ subject.should have_at_least(2).agents
42
+ expect(subject).to have_at_least(1).agents
43
43
 
44
44
  expect(subject.agents['agents.author']['publish-1']['jcr:content']['jcr:title']).to eq('Publish 1')
45
45
  end
@@ -48,6 +48,36 @@ module Adobe
48
48
  subject.create_agent('agents.author', 'stan')
49
49
  end
50
50
  end
51
+
52
+ describe "System" do
53
+ subject do
54
+ @options = {}
55
+ @options[:port] = 4567
56
+
57
+ Adobe::Aem::Api.new(@options).system
58
+ end
59
+
60
+ it "should uninstall a bundle" do
61
+ b = subject.uninstall_bundle("uk.sponte.bundle").body
62
+ expect(JSON.parse(b)["action"]).to eq("uninstall")
63
+ end
64
+
65
+ it "should refresh_package_imports" do
66
+ b = subject.refresh_bundle_imports("uk.sponte.bundle").body
67
+ expect(JSON.parse(b)["action"]).to eq("refresh")
68
+ end
69
+
70
+ it "should upload package" do
71
+ tempfile = Tempfile.new('upload_package.tmp')
72
+ tempfile.close
73
+
74
+ b = subject.install_bundle(tempfile.path).body
75
+ expect(JSON.parse(b)["action"]).to eq("install")
76
+
77
+ File.delete(tempfile.path)
78
+ end
79
+
80
+ end
51
81
  end
52
82
  end
53
83
 
@@ -0,0 +1,20 @@
1
+ {
2
+ "enabled": "true",
3
+ "jcr:description": "Agent that replicates to the default publish instance.",
4
+ "sling:resourceType": "cq/replication/components/agent",
5
+ "jcr:uuid": "24b0a1ed-79a1-4fd2-84b1-c3c7ac2b6f03",
6
+ "jcr:title": "Publish 1",
7
+ "jcr:mixinTypes": ["mix:versionable"],
8
+ "jcr:baseVersion": "db950b25-0639-49b0-a812-9b7388dda1e8",
9
+ "transportUser": "admin",
10
+ "jcr:isCheckedOut": true,
11
+ "jcr:primaryType": "nt:unstructured",
12
+ "cq:template": "/libs/cq/replication/templates/agent",
13
+ "jcr:predecessors": ["db950b25-0639-49b0-a812-9b7388dda1e8"],
14
+ "retryDelay": "60000",
15
+ "jcr:versionHistory": "9816f959-099e-49a5-af3e-8801de61ab83",
16
+ "logLevel": "info",
17
+ "transportPassword": "admin",
18
+ "transportUri": "http://azaem-pub1-test1.awsdev.telegraph.co.uk:4503/bin/receive?sling:authRequestLogin=1",
19
+ "serializationType": "durbo"
20
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "jcr:created": "Wed Aug 13 2014 09:05:55 GMT+0000",
3
+ "jcr:primaryType": "cq:Page",
4
+ "jcr:createdBy": "admin",
5
+ "jcr:content": {
6
+ "enabled": "true",
7
+ "jcr:description": "Agent that replicates to the default publish instance.",
8
+ "sling:resourceType": "cq/replication/components/agent",
9
+ "jcr:uuid": "24b0a1ed-79a1-4fd2-84b1-c3c7ac2b6f03",
10
+ "jcr:title": "Publish 1",
11
+ "jcr:mixinTypes": ["mix:versionable"],
12
+ "jcr:baseVersion": "db950b25-0639-49b0-a812-9b7388dda1e8",
13
+ "transportUser": "admin",
14
+ "jcr:isCheckedOut": true,
15
+ "jcr:primaryType": "nt:unstructured",
16
+ "cq:template": "/libs/cq/replication/templates/agent",
17
+ "jcr:predecessors": ["db950b25-0639-49b0-a812-9b7388dda1e8"],
18
+ "retryDelay": "60000",
19
+ "jcr:versionHistory": "9816f959-099e-49a5-af3e-8801de61ab83",
20
+ "logLevel": "info",
21
+ "transportPassword": "admin",
22
+ "transportUri": "http://azaem-pub1-test1.awsdev.telegraph.co.uk:4503/bin/receive?sling:authRequestLogin=1",
23
+ "serializationType": "durbo"
24
+ }
25
+ }
@@ -7,4 +7,12 @@ class MockAem < Sinatra::Application
7
7
 
8
8
  set :static, true
9
9
  set :public_folder, File.join(File.dirname(__FILE__), '../data')
10
+
11
+ post '/bin/wcmcommand' do
12
+ '<html><div id=Location href=/etc/replication/agents.author/stan /></html>'
13
+ end
14
+
15
+ post '/system/console/bundles/?:id?' do
16
+ params.to_json
17
+ end
10
18
  end
metadata CHANGED
@@ -1,139 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adobe-aem-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislaw Wozniak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-16 00:00:00.000000000 Z
11
+ date: 2015-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mocha
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.13.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.13.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rr
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.0.4
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.0.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: flexmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.9.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.9.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sinatra
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 1.4.5
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.4.5
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: webmock
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: 1.18.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.18.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: recursive-open-struct
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: nokogiri
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: multipart-post
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
153
  description: Provides functionality to manage Adobe AEM instances.
@@ -143,8 +157,8 @@ executables: []
143
157
  extensions: []
144
158
  extra_rdoc_files: []
145
159
  files:
146
- - .gitignore
147
- - .travis.yml
160
+ - ".gitignore"
161
+ - ".travis.yml"
148
162
  - Gemfile
149
163
  - Gemfile.lock
150
164
  - LICENSE.txt
@@ -170,6 +184,8 @@ files:
170
184
  - spec/data/etc/replication/agent.json
171
185
  - spec/data/etc/replication/agents.author.1.json
172
186
  - spec/data/etc/replication/agents.author/publish-1.1.json
187
+ - spec/data/etc/replication/agents.author/publish-1/jcr:content.1.json
188
+ - spec/data/etc/replication/agents.author/stan.1.json
173
189
  - spec/helpers/mock_aem.rb
174
190
  - spec/spec_helper.rb
175
191
  homepage: ''
@@ -182,17 +198,17 @@ require_paths:
182
198
  - lib
183
199
  required_ruby_version: !ruby/object:Gem::Requirement
184
200
  requirements:
185
- - - ! '>='
201
+ - - ">="
186
202
  - !ruby/object:Gem::Version
187
203
  version: '0'
188
204
  required_rubygems_version: !ruby/object:Gem::Requirement
189
205
  requirements:
190
- - - ! '>='
206
+ - - ">="
191
207
  - !ruby/object:Gem::Version
192
208
  version: '0'
193
209
  requirements: []
194
210
  rubyforge_project:
195
- rubygems_version: 2.2.2
211
+ rubygems_version: 2.4.2
196
212
  signing_key:
197
213
  specification_version: 4
198
214
  summary: Adobe AEM Api gem
@@ -202,5 +218,8 @@ test_files:
202
218
  - spec/data/etc/replication/agent.json
203
219
  - spec/data/etc/replication/agents.author.1.json
204
220
  - spec/data/etc/replication/agents.author/publish-1.1.json
221
+ - spec/data/etc/replication/agents.author/publish-1/jcr:content.1.json
222
+ - spec/data/etc/replication/agents.author/stan.1.json
205
223
  - spec/helpers/mock_aem.rb
206
224
  - spec/spec_helper.rb
225
+ has_rdoc: