class Grapefruit::CmisClient
Attributes
repository[RW]
root[RW]
sites[RW]
ticket[RW]
Public Class Methods
new(url, username, password)
click to toggle source
# File lib/grapefruit/cmis_client.rb, line 9 def initialize(url, username, password) @url = url @username = username @password = password fetch_ticket #Loading Alfresco repository using active_cmis client self.repository = ActiveCMIS.load_config('alfresco_config', File.expand_path(ENV["CMIS_YML"])) self.root = repository.root_folder self.sites = fetch_sites end
Public Instance Methods
create_folder(folder)
click to toggle source
# File lib/grapefruit/cmis_client.rb, line 38 def create_folder(folder) xml = folder.to_xml response = RestClient.post("#{ENV['CMIS_HOST']}/alfresco/s/cmis/p/children?alf_ticket=#{ticket}", xml.strip, :content_type => :atom) doc = Nokogiri::XML.parse(response) ns = doc.collect_namespaces folder.cmis_object_id = doc.xpath("//cmis:propertyId[@propertyDefinitionId='cmis:objectId']", ns).text().strip # Handle errors folder end
fetch_sites()
click to toggle source
# File lib/grapefruit/cmis_client.rb, line 26 def fetch_sites sites = root.items.select { |i| i.name == "Sites" }[0] end
fetch_ticket()
click to toggle source
# File lib/grapefruit/cmis_client.rb, line 20 def fetch_ticket client = RestClient.get ticket_url doc = Nokogiri::XML.parse(client.to_str) self.ticket ||= doc.xpath("/ticket").text end
root_node_url()
click to toggle source
# File lib/grapefruit/cmis_client.rb, line 34 def root_node_url "#{ENV['CMIS_HOST']}/alfresco/s/cmis/s/workspace:SpacesStore/i/51ccddc0-d1e6-43fe-b75e-87675659977e/tree" end
ticket_url()
click to toggle source
# File lib/grapefruit/cmis_client.rb, line 30 def ticket_url "#{@url}/alfresco/service/api/login?u=#{@username}&pw=#{@password}" end