xowiki::Package instproc invoke

 <instance of xowiki::Package[i]> invoke

Defined in

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_folder_with_page create_folder_with_page (test ) xowiki::Package instproc invoke xowiki::Package instproc invoke test_create_folder_with_page->xowiki::Package instproc invoke test_create_form_with_form_instance create_form_with_form_instance (test xowiki) test_create_form_with_form_instance->xowiki::Package instproc invoke test_create_workflow_with_instance create_workflow_with_instance (test xowf) test_create_workflow_with_instance->xowiki::Package instproc invoke test_xowf xowf (test ) test_xowf->xowiki::Package instproc invoke ad_log ad_log (public) xowiki::Package instproc invoke->ad_log ad_return_complaint ad_return_complaint (public) xowiki::Package instproc invoke->ad_return_complaint ad_script_abort ad_script_abort (public) xowiki::Package instproc invoke->ad_script_abort ad_try ad_try (public) xowiki::Package instproc invoke->ad_try

Testcases:
create_folder_with_page, xowf, create_workflow_with_instance, create_form_with_form_instance
Source code:
#
# Do we have a valid method?
#
if {![regexp {^[.a-zA-Z0-9_-]+$} $method]} {
  return [:error_msg "No valid method provided!"]
}

#
# Call the method on the resolved page. This call might trigger an
# ad_script_abort, so use ad_try to catch these properly.
#
ad_try {
  set page_or_package [:resolve_page -lang [:default_language] ${:object} method]
} on error {errorMsg} {
  #
  # Report true errors in the error log and return the template.
  #
  ad_log error $errorMsg
  return [:error_msg -template_file $error_template [ns_quotehtml $errorMsg]]
}

#
# Set the invoke object, such it might be used later
#
::xo::cc invoke_object $page_or_package

#:log "--r resolve_page '${:object}' => $page_or_package"
if {$page_or_package ne ""} {

  # TODO: remove me when settled
  if {[$page_or_package istype ::xowiki::FormPage] && [$page_or_package info vars storage_type] eq ""} {ad_log notice "$page_or_package has no storage_type"}

  #
  # Check, of the target is a symbolic link
  #
  if {[$page_or_package istype ::xowiki::FormPage]
      && [$page_or_package is_link_page]
    } {
    #
    # If the target is a symbolic link, we may want to call the
    # method on the target. The default behavior is defined in the
    # array delegate_link_to_target, but if can be overruled with
    # the boolean query parameter "deref".
    #
    set deref [[self class] exists delegate_link_to_target($method)]
    if {[:exists_query_parameter deref]} {
      set deref [:query_parameter deref:boolean]
    }

    #:log "LINK <$method> default deref $deref"
    if {$deref} {
      set target [$page_or_package get_target_from_link_page]
      #:log "delegate $method from $page_or_package [$page_or_package name] to $target [$target name]"
      if {$target ne ""} {
        $target set __link_source $page_or_package
        set page_or_package $target
      }
    }
  }

  #:log "call procsearch www-$method on: [$page_or_package info precedence]"
  if {[$page_or_package procsearch www-$method] eq ""} {
    return [:error_msg "Method <b>'[ns_quotehtml $method]'</b> is not defined for this object"]
  } else {

    #:log "${:object} id=$page_or_package method=$method (${:id} batch_mode $batch_mode)"

    if {$batch_mode} {
      ${:id} set __batch_mode 1
    }

    ad_try {
      set r [:call $page_or_package $method ""]
    } on error {errorMsg} {
      if {[string match "*for parameter*" $errorMsg]} {
        #
        # The exception might have been due to invalid input parameters
        #
        ad_return_complaint 1 [ns_quotehtml $errorMsg]
        ad_script_abort
      } else {
        #
        # The exception was a real error
        #
        ad_log error "error during invocation of method $method errorMsg: $errorMsg$::errorInfo"
        return [:error_msg -status_code 500  -template_file $error_template  "error during [ns_quotehtml $method]: <pre>[ns_quotehtml $errorMsg]</pre>"]
      }

    } finally {
      if {$batch_mode} {
        ${:id} unset -nocomplain __batch_mode
      }
    }

    return $r
  }
} else {
  #
  # The requested page was not found, provide an error message and
  # an optional link for creating the page. The creation link
  # depends on the method "create_new_snippet", which checks
  # whether the policy in place supports "edit-new" permissions
  # for the current user.
  #
  set path [::xowiki::Includelet html_encode ${:object}]
  set edit_snippet [:create_new_snippet $path]
  return [:error_msg -status_code 404 -template_file $error_template  "Page <b>'[ns_quotehtml $path]'</b> is not available. $edit_snippet"]
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: