Skip to content

Commit

Permalink
Add support for DocumentLibrary and file uploads.
Browse files Browse the repository at this point in the history
  • Loading branch information
zenchild committed Feb 14, 2012
1 parent d896d7f commit 9b8c5b6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/viewpoint/spws/spws_client.rb
Expand Up @@ -75,7 +75,7 @@ def get_list(list)
lists_ws.get_list(list)
end

# Add a List to thiis site
# Add a List to this site
# @param [String] name A name for the List
# @param [String] desc A description of the List
# @param [Integer] list_type The list template id. Use the LIST_TYPES Hash.
Expand Down
18 changes: 12 additions & 6 deletions lib/viewpoint/spws/types/document_library.rb
Expand Up @@ -22,14 +22,20 @@
class Viewpoint::SPWS::Types::DocumentLibrary < Viewpoint::SPWS::Types::List
include Viewpoint::SPWS::Types

# @param [Viewpoint::SPWS::Websvc::List] ws The webservice instance this List spawned from
# @param [Nokogiri::XML::Element] xml the List element we are building from
def initialize(ws, xml)
@copy_ws = Viewpoint::SPWS::Websvc::Copy.new(ws.spcon)
super
end

# Add a Document to this List
# @param [Hash] opts parameters for this Document
# @option opts [String] :title The title of this Document
# @option opts [String] :file Path to the file to upload
# @return [Viewpoint::SPWS::Types::ListItem] The newly added Task
def add_item!(opts)
raise "Title argument required" unless opts[:title]

super(topts)
def add_file!(opts)
raise "Valid file argument required" unless(opts[:file] && File.exists?(opts[:file]))
fqpath = "#{self.path}/#{File.basename(opts[:file])}"
@copy_ws.copy_into_items(opts[:file], [fqpath])
end

end
2 changes: 2 additions & 0 deletions lib/viewpoint/spws/websvc/lists.rb
Expand Up @@ -436,6 +436,8 @@ def get_file(file_ref)
# Parse the SOAP Response and return an appropriate List type
def new_list(xmllist)
case xmllist['ServerTemplate']
when "101"
Types::DocumentLibrary.new(self, xmllist)
when "107"
Types::TasksList.new(self, xmllist)
else
Expand Down
1 change: 0 additions & 1 deletion lib/viewpoint/spws/websvc/web_service_base.rb
Expand Up @@ -36,7 +36,6 @@ def initialize(spcon)
raise "Auth failure" unless(@spcon.authenticate(@ws_endpoint))
end


private

def build_soap_envelope
Expand Down

0 comments on commit 9b8c5b6

Please sign in to comment.