Class: CmisServer::EntryParser
- Inherits:
-
Object
- Object
- CmisServer::EntryParser
- Defined in:
- lib/cmis_server/atom_pub/entry_parser.rb
Instance Attribute Summary collapse
-
#raw_body ⇒ Object
readonly
Returns the value of attribute raw_body.
Instance Method Summary collapse
- #atom_entry ⇒ Object
- #cmis_object_id ⇒ Object
- #content_element ⇒ Object
- #content_stream ⇒ Object
-
#initialize(raw_body) ⇒ EntryParser
constructor
A new instance of EntryParser.
- #object_element ⇒ Object
- #object_properties ⇒ Object
- #object_type ⇒ Object
- #parse ⇒ Object
Constructor Details
#initialize(raw_body) ⇒ EntryParser
Returns a new instance of EntryParser.
10 11 12 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 10 def initialize(raw_body) @raw_body=raw_body end |
Instance Attribute Details
#raw_body ⇒ Object (readonly)
Returns the value of attribute raw_body.
8 9 10 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 8 def raw_body @raw_body end |
Instance Method Details
#atom_entry ⇒ Object
60 61 62 63 64 65 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 60 def atom_entry @atom_entry ||= begin require 'nokogiri' Nokogiri::XML(raw_body) end end |
#cmis_object_id ⇒ Object
55 56 57 58 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 55 def cmis_object_id #ToDo nil end |
#content_element ⇒ Object
67 68 69 70 71 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 67 def content_element atom_entry.at_xpath("//cmisra:content", { 'cmisra' => CMIS_REST_ATOM_NAMESPACE }) end |
#content_stream ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 18 def content_stream if content_element unless @stream base64 = content_element.at_xpath('.//cmisra:base64', { 'cmisra' => CMIS_REST_ATOM_NAMESPACE })&.text media_type = content_element.at_xpath('.//cmisra:mediatype', { 'cmisra' => CMIS_REST_ATOM_NAMESPACE })&.text @stream = CmisServer::ContentStream.new(base64: base64, media_type: media_type) end @stream else nil end end |
#object_element ⇒ Object
73 74 75 76 77 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 73 def object_element atom_entry.at_xpath("//cmisra:object", { 'cmisra' => CMIS_REST_ATOM_NAMESPACE }) end |
#object_properties ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 79 def object_properties unless @properties properties_element = object_element&.at_xpath(".//cmis:properties", { 'cmis' => CMIS_NAMESPACE }) if properties_element @properties = {} # Chercher tous les éléments qui commencent par 'property' props = properties_element.xpath(".//cmis:propertyId | .//cmis:propertyString | .//cmis:propertyInteger | .//cmis:propertyBoolean | .//cmis:propertyDateTime | .//cmis:propertyDecimal", {'cmis' => CMIS_NAMESPACE}) props.each do |prop| key = prop['propertyDefinitionId'] value = prop.at_xpath(".//cmis:value", {'cmis' => CMIS_NAMESPACE})&.text @properties[key] = value if key end else @properties = {} end end @properties end |
#object_type ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 35 def object_type type_id = object_properties["cmis:objectTypeId"] result = CmisServer::TypeRegistry.get_type(type_id) # Si le type n'est pas trouvé dans le registry, utiliser les types de base if result.nil? && type_id case type_id when 'cmis:document' result = CmisServer::DocumentType.base when 'cmis:folder' result = CmisServer::FolderType.base when 'cmis:item' result = CmisServer::ItemType.base end end result end |
#parse ⇒ Object
14 15 16 |
# File 'lib/cmis_server/atom_pub/entry_parser.rb', line 14 def parse object_type.new end |