active_cmis 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "active_cmis"
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joeri Samson"]
12
- s.date = "2012-11-05"
12
+ s.date = "2013-05-08"
13
13
  s.description = "A CMIS library implementing both reading and updating capabilities through the AtomPub/REST binding to CMIS."
14
14
  s.email = "joeri@xaop.com"
15
15
  s.extra_rdoc_files = [
@@ -89,14 +89,14 @@ module ActiveCMIS
89
89
  value.text.to_i
90
90
  end
91
91
  def _rb2cmis(xml, value)
92
- v = value.to_int
92
+ v = value.to_i
93
93
  if (min_value && v < min_value) || (max_value && v > max_value)
94
94
  raise Error::InvalidArgument.new("OutOfBounds: #{v} should be between #{min_value} and #{max_value}")
95
95
  end
96
96
  xml["c"].value("%i" % v)
97
97
  end
98
98
  def can_handle?(value)
99
- value.respond_to?(:to_int)
99
+ value.respond_to?(:to_i)
100
100
  end
101
101
 
102
102
  private :_cmis2rb, :_rb2cmis
@@ -233,12 +233,14 @@ module ActiveCMIS
233
233
 
234
234
  result = super
235
235
 
236
- unless checkin || key.nil? || updated_contents.nil?
237
- # Don't set content_stream separately if it can be done by setting the content during create
238
- #
239
- # TODO: For checkin we could try to see if we can save it via puts *before* we checkin,
240
- # If not checking in we should also try to see if we can actually save it
241
- result << {:message => :save_content_stream, :parameters => [updated_contents]}
236
+ if !key.nil? && !updated_contents.nil?
237
+ if checkin
238
+ # Update the content stream before checking in
239
+ result.unshift(:message => :save_content_stream, :parameters => [updated_contents])
240
+ else
241
+ # TODO: check that the content stream is updateable
242
+ result << {:message => :save_content_stream, :parameters => [updated_contents]}
243
+ end
242
244
  end
243
245
 
244
246
  result
@@ -346,15 +346,15 @@ module ActiveCMIS
346
346
  def render_atom_entry(properties = self.class.attributes, attributes = self.attributes, options = {})
347
347
  builder = Nokogiri::XML::Builder.new do |xml|
348
348
  xml.entry(NS::COMBINED) do
349
- xml.parent.namespace = xml.parent.namespace_definitions.detect {|ns| ns.prefix == "at"}
350
- xml["at"].author do
351
- xml["at"].name conn.user # FIXME: find reliable way to set author?
349
+ xml.parent.default_namespace = NS::COMBINED["xmlns:at"]
350
+ xml.author do
351
+ xml.name conn.user # FIXME: find reliable way to set author?
352
352
  end
353
- xml["at"].title attributes["cmis:name"]
353
+ xml.title attributes["cmis:name"]
354
354
  if attributes["cmis:objectId"]
355
- xml["at"].id_ attributes["cmis:objectId"]
355
+ xml.id_ attributes["cmis:objectId"]
356
356
  else
357
- xml["at"].id_ "random-garbage"
357
+ xml.id_ "random-garbage"
358
358
  end
359
359
  xml["cra"].object do
360
360
  xml["c"].properties do
@@ -398,7 +398,7 @@ module ActiveCMIS
398
398
 
399
399
  if result.empty? && checkin
400
400
  # NOTE: this needs some thinking through: in particular this may not work well if there would be an updated content stream
401
- result << {:message => :save_attributes, :parameters => [[], [], checkin]}
401
+ result << {:message => :save_attributes, :parameters => [{}, {}, checkin]}
402
402
  end
403
403
 
404
404
  result
@@ -433,7 +433,7 @@ module ActiveCMIS
433
433
  if attributes.empty? && checkin.nil?
434
434
  raise "Error: saving attributes but nothing to do"
435
435
  end
436
- properties = self.class.attributes.reject {|key,_| !updated_attributes.include?(key)}
436
+ properties = self.class.attributes.select {|key,_| updated_attributes.include?(key)}
437
437
  body = render_atom_entry(properties, values, :checkin => checkin)
438
438
 
439
439
  if checkin.nil?
@@ -457,7 +457,7 @@ module ActiveCMIS
457
457
  end
458
458
 
459
459
  uri = self_link(parameters)
460
- response = conn.put(uri, body)
460
+ response = conn.put(uri, body, "Content-Type" => "application/atom+xml;type=entry")
461
461
 
462
462
  data = Nokogiri::XML.parse(response, nil, nil, Nokogiri::XML::ParseOptions::STRICT).xpath("at:entry", NS::COMBINED)
463
463
  if data.xpath("cra:object/c:properties/c:propertyId[@propertyDefinitionId = 'cmis:objectId']/c:value", NS::COMBINED).text == id
@@ -2,7 +2,7 @@ module ActiveCMIS
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- PATCH = 2
5
+ PATCH = 3
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_cmis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-05 00:00:00.000000000 Z
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70335761070080 !ruby/object:Gem::Requirement
16
+ requirement: &70197899383240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.4.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70335761070080
24
+ version_requirements: *70197899383240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ntlm-http
27
- requirement: &70335760996720 !ruby/object:Gem::Requirement
27
+ requirement: &70197899382120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.1.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70335760996720
35
+ version_requirements: *70197899382120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: require_relative
38
- requirement: &70335760994260 !ruby/object:Gem::Requirement
38
+ requirement: &70197899381480 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.0.2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70335760994260
46
+ version_requirements: *70197899381480
47
47
  description: A CMIS library implementing both reading and updating capabilities through
48
48
  the AtomPub/REST binding to CMIS.
49
49
  email: joeri@xaop.com