Class: Mediaflux::ProjectCreateServiceRequest

Inherits:
Request
  • Object
show all
Defined in:
app/models/mediaflux/project_create_service_request.rb

Instance Attribute Summary collapse

Attributes inherited from Request

#session_token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

build_post_request, default_xml_namespace, default_xml_namespace_uri, #error?, find_or_create_http_client, format_date_for_mediaflux, request_path, #resolve, #resolved?, #response_body, #response_error, #response_xml, uri, #xml_payload, #xtoshell_xml

Constructor Details

#initialize(session_token:, project:, token: nil) ⇒ ProjectCreateServiceRequest

Constructor

Parameters:

  • session_token (String)

    the API token for the authenticated session

  • token (String) (defaults to: nil)

    Optional User token for the person executing the command

  • project (Project)

    A project object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/mediaflux/project_create_service_request.rb', line 10

def initialize(session_token:, project:, token: nil)
  super(session_token: session_token)
  @token = token
  @project = project
  @data_manager = @project..data_manager
  @data_sponsor = @project..data_sponsor
  @title = @project..title
  @description = @project..description
  @directory = @project..project_directory
  @project_id = @project..project_id
  @department = departments_string(@project..departments)
  @quota = "#{@project..storage_capacity['size']['approved']} #{@project..storage_capacity['unit']['approved']}"
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



4
5
6
# File 'app/models/mediaflux/project_create_service_request.rb', line 4

def document
  @document
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



4
5
6
# File 'app/models/mediaflux/project_create_service_request.rb', line 4

def service_name
  @service_name
end

#tokenObject (readonly)

Returns the value of attribute token.



4
5
6
# File 'app/models/mediaflux/project_create_service_request.rb', line 4

def token
  @token
end

Class Method Details

.serviceString

Specifies the Mediaflux service to use when creating project

Returns:

  • (String)


26
27
28
# File 'app/models/mediaflux/project_create_service_request.rb', line 26

def self.service
  "tigerdata.project.create"
end

Instance Method Details

#debug_outputObject

Returns the entire response returned by the project create service. This includes debug information that is useful to troubleshoot issues if the request fails.



33
34
35
# File 'app/models/mediaflux/project_create_service_request.rb', line 33

def debug_output
  response_xml.xpath("response/reply/result/result").to_s
end

#mediaflux_idObject

Returns the id of the collection created in Mediaflux



38
39
40
41
42
43
44
# File 'app/models/mediaflux/project_create_service_request.rb', line 38

def mediaflux_id
  # Extract the <id>nnnn</id> value from the output and then extract the
  # numeric value inside of it.
  decoded_string = CGI.unescapeHTML(debug_output)
  xml_doc  = Nokogiri::XML(decoded_string)
  (xml_doc.xpath("result/result/id/text()").to_s).to_i
end