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
23
24
25
# 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']}"
  # We set the datastore to "db" because the default is a store that
  # only exists in the production Mediaflux.
  @store = "db" unless Rails.env.production?
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)


29
30
31
# File 'app/models/mediaflux/project_create_service_request.rb', line 29

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.



36
37
38
# File 'app/models/mediaflux/project_create_service_request.rb', line 36

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

#mediaflux_idObject

Returns the id of the collection created in Mediaflux



41
42
43
44
45
46
# File 'app/models/mediaflux/project_create_service_request.rb', line 41

def mediaflux_id
  # Extract the <id>nnnn</id> value from the output and then extract the
  # numeric value inside of it.
  id_xml = debug_output.match("\&lt\;id\&gt\;[0-9]*\&lt\;\/id\&gt\;").to_s
  id_xml.gsub("&lt;id&gt;", "").gsub("&lt;/id&gt;", "").to_i
end