Class: Adobe::Aem::Connector
- Inherits:
-
Object
- Object
- Adobe::Aem::Connector
- Defined in:
- lib/adobe/aem/connector.rb
Instance Method Summary collapse
- #create_page(path, title, label, template, options = {}) ⇒ Object
- #delete_page(path) ⇒ Object
- #get(path) ⇒ Object
-
#initialize(context) ⇒ Connector
constructor
A new instance of Connector.
- #multipart_post(path, data = {}, headers = {}) ⇒ Object
- #post(path, data = {}, headers = {}) ⇒ Object
- #set(path, name, value) ⇒ Object
Constructor Details
#initialize(context) ⇒ Connector
Returns a new instance of Connector.
7 8 9 |
# File 'lib/adobe/aem/connector.rb', line 7 def initialize(context) @context = context end |
Instance Method Details
#create_page(path, title, label, template, options = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/adobe/aem/connector.rb', line 54 def create_page(path, title, label, template, = {}) post = request('/bin/wcmcommand', 'POST') post.set_form_data({ cmd: 'createPage', parentPath: path, title: title, label: label, replace: true, replaceProperties: true, template: template }) response = http.request(post) verify(response) if .size > 0 set path, title, end doc = Nokogiri::HTML(response.body) returned_path = doc.css('#Location').attr('href').value get("#{returned_path}.1.json") end |
#delete_page(path) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/adobe/aem/connector.rb', line 78 def delete_page(path) post = request('/bin/wcmcommand', 'POST') post.set_form_data({ cmd: 'deletePage', force: true, path: path }) response = http.request(post) verify(response) end |
#get(path) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/adobe/aem/connector.rb', line 11 def get(path) get = request(path) response = http.request(get) verify(response) json = parse_json(response.body) Adobe::Aem::Jcr::Node.new(json, path.gsub(/\.\d\.json/i, ''), @context) end |
#multipart_post(path, data = {}, headers = {}) ⇒ Object
40 41 42 43 44 |
# File 'lib/adobe/aem/connector.rb', line 40 def multipart_post(path, data = {}, headers = {}) post = request(path, 'POST', data) response = http.request(post) verify(response) end |
#post(path, data = {}, headers = {}) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/adobe/aem/connector.rb', line 46 def post(path, data = {}, headers = {}) post = request(path, 'POST') post.form_data = data unless data.empty? response = http.request(post) verify(response) end |
#set(path, name, value) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/adobe/aem/connector.rb', line 20 def set(path, name, value) post = if value.is_a?(Hash) value = { ':content' => value.to_json, ':contentType' => 'json', ':operation' => 'import' } request("#{path}/#{name}", 'POST') else value = {"./#{name}" => value} request(path, 'POST') end post.set_form_data(value) response = http.request(post) verify(response) end |