Class: Viewpoint::SPWS::Websvc::Copy

Inherits:
Object
  • Object
show all
Includes:
WebServiceBase
Defined in:
lib/spws/websvc/copy.rb

Overview

This class represents the Sharepoint Copy Web Service.

Constant Summary

Constant Summary

Constants included from WebServiceBase

WebServiceBase::NAMESPACES

Instance Attribute Summary

Attributes included from WebServiceBase

#spcon

Attributes included from Viewpoint::SPWS

#logger

Instance Method Summary collapse

Methods included from Viewpoint::SPWS

root_logger, set_log_level

Constructor Details

#initialize(spcon) ⇒ Copy



24
25
26
27
28
# File 'lib/spws/websvc/copy.rb', line 24

def initialize(spcon)
  @default_ns  = 'http://schemas.microsoft.com/sharepoint/soap/'
  @ws_endpoint = '_vti_bin/Copy.asmx'
  super
end

Instance Method Details

#copy_into_items(srcfile, tgturls) ⇒ Object

TODO:

parse the return and check for errors

Copies a document represented by a Byte array to one or more locations on a server.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/spws/websvc/copy.rb', line 35

def copy_into_items(srcfile, tgturls)
  soapmsg = build_soap_envelope do |type, builder|
    if(type == :header)
    else
      builder.CopyIntoItems {
        builder.parent.default_namespace = @default_ns
        builder.SourceUrl(srcfile)
        builder.DestinationUrls {
          tgturls.each {|tgt| builder.string(tgt) }
        }
        builder.Fields
        builder.Stream(Base64.encode64(File.read(srcfile)))
      }
    end
  end

  soaprsp = Nokogiri::XML(send_soap_request(soapmsg.doc.to_xml))
end

#copy_into_items_local(srcurl, tgturls) ⇒ Object

TODO:

parse the return and check for errors

Copies a document from one location on a server running Windows SharePoint Services

to another location on the same server.


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/spws/websvc/copy.rb', line 60

def copy_into_items_local(srcurl, tgturls)
  soapmsg = build_soap_envelope do |type, builder|
    if(type == :header)
    else
      builder.CopyIntoItemsLocal {
        builder.parent.default_namespace = @default_ns
        builder.SourceUrl(srcurl)
        builder.DestinationUrls {
          tgturls.each {|tgt| builder.string(tgt) }
        }
      }
    end
  end

  soaprsp = Nokogiri::XML(send_soap_request(soapmsg.doc.to_xml))
end

#get_item(tgturl) ⇒ Hash

Generates a Byte array representation of a document



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/spws/websvc/copy.rb', line 84

def get_item(tgturl)
  soapmsg = build_soap_envelope do |type, builder|
    if(type == :header)
    else
      builder.GetItem {
        builder.parent.default_namespace = @default_ns
        builder.Url(tgturl)
      }
    end
  end

  soaprsp = Nokogiri::XML(send_soap_request(soapmsg.doc.to_xml))
  ns = {"xmlns"=> @default_ns}
  data = {}
  data[:stream] = soaprsp.xpath('//xmlns:GetItemResponse/xmlns:Stream',ns).first.content
  fields = []
  soaprsp.xpath('//xmlns:GetItemResponse/xmlns:Fields/xmlns:FieldInformation',ns).each do |f|
    fields << {:type => f['Type'], :display_name => f['DisplayName'],
      :id => f['Id'], :value => f['Value']}
  end
  data[:fields] = fields
  data
end