auth::authority::create (public)

 auth::authority::create [ -authority_id authority_id ] -array array

Defined in packages/acs-authentication/tcl/authority-procs.tcl

Create a new authentication authority.

Switches:
-authority_id (optional)
-array (required)
Name of an array containing the column values. The entries are:
  • short_name Short name for authority. Used as a key by applications to identify this authority.
  • pretty_name Label for the authority to be shown in a list to users picking an authority.
  • enabled_p 't' if this authority available, 'f' if it's disabled. Defaults to 'f'.
  • sort_order Sort ordering determines the order in which authorities are listed in the user interface. Defaults to the currently highest sort order plus one.
  • auth_impl_id The ID of the implementation of the 'auth_authentication' service contract. Defaults to none.
  • pwd_impl_id The ID of the implementation of the 'auth_password' service contract. Defaults to none.
  • forgotten_pwd_url An alternative URL to redirect to when the user has forgotten his/her password. Defaults to none.
  • change_pwd_url An alternative URL to redirect to when the user wants to change his/her password. Defaults to none.
  • register_impl_id The ID of the implementation of the 'auth_registration' service contract. Defaults to none.
  • register_url An alternative URL to redirect to when the user wants to register for an account. Defaults to none.
  • user_info_impl_id The ID of the implementation of the 'auth_user_info' service contract. Defaults to none.
  • get_doc_impl_id Id of the 'auth_sync_retrieve' service contract implementation
  • process_doc_impl_id Id of the 'auth_sync_process' service contract implementation
  • batch_sync_enabled_p Is batch sync enabled for the authority?
Options:
-authority_id
Authority_id, or blank if you want one generated for you.
Author:
Lars Pind <lars@collaboraid.biz>

Partial Call Graph (max 5 caller/called nodes):
%3 test_auth_authority_api auth_authority_api (test acs-authentication) auth::authority::create auth::authority::create test_auth_authority_api->auth::authority::create test_sync_batch_ims_example_doc sync_batch_ims_example_doc (test acs-authentication) test_sync_batch_ims_example_doc->auth::authority::create test_sync_batch_ims_test sync_batch_ims_test (test acs-authentication) test_sync_batch_ims_test->auth::authority::create ad_conn ad_conn (public) auth::authority::create->ad_conn auth::authority::edit auth::authority::edit (public) auth::authority::create->auth::authority::edit auth::authority::get_column_defaults auth::authority::get_column_defaults (private) auth::authority::create->auth::authority::get_column_defaults auth::authority::get_id_flush auth::authority::get_id_flush (private) auth::authority::create->auth::authority::get_id_flush auth::authority::get_required_columns auth::authority::get_required_columns (private) auth::authority::create->auth::authority::get_required_columns acs::test::auth::install acs::test::auth::install (private) acs::test::auth::install->auth::authority::create packages/acs-admin/www/auth/authority.tcl packages/acs-admin/ www/auth/authority.tcl packages/acs-admin/www/auth/authority.tcl->auth::authority::create

Testcases:
auth_authority_api, sync_batch_ims_example_doc, sync_batch_ims_test
Source code:
    upvar $array row

    db_transaction {

        if { $authority_id eq "" } {
            set authority_id [db_nextval "acs_object_id_seq"]
        }

        set names [array names row]

        array set column_defaults [get_column_defaults]
        set all_columns [array names column_defaults]

        # Check that the columns provided in the array are all valid
        # Set array entries as local variables
        foreach name $names {
            if {$name ni $all_columns} {
                error "Attribute '$name' isn't valid for auth_authorities."
            }
            set $name $row($name)
        }

        # Check that the required columns are there
        foreach name [get_required_columns] {
            if { ![info exists $name] } {
                error "Required column '$name' missing for auth_authorities."
            }
        }

        # Set default values for columns not provided
        foreach column $all_columns {
            if { $column ni $names } {
                set $column $column_defaults($column)
            }
        }

        if {[ns_conn isconnected]} {
            set context_id    [ad_conn package_id]
            set creation_user [ad_conn user_id]
            set creation_ip   [ad_conn peeraddr]
        } else {
            set context_id    ""
            set creation_user ""
            set creation_ip   ""
        }

        # Auto generate short name if not provided and make
        # sure it's unique
        # TODO: check for max length 255?
        if { $short_name eq "" } {
            set existing_short_names [db_list select_short_names {
                select short_name
                from auth_authorities
            }]
            set short_name [util_text_to_url  -replacement "_"  -existing_urls $existing_short_names  -text $pretty_name]
        }

        db_transaction {
            set authority_id [db_exec_plsql create_authority {}]

            # Set the arguments not taken by the new function with an update statement
            # LARS: Great, we had a nice abstraction going, so you only had to add a new column in
            # one place, now that abstraction is broken, because you have to add it here as well
            foreach column {
                user_info_impl_id
                get_doc_impl_id
                process_doc_impl_id
                batch_sync_enabled_p
                help_contact_text_format
            } {
                set edit_columns($column) [set $column]
            }

            edit -authority_id $authority_id -array edit_columns
        }
    }

    # Flush the cache, so that if we've tried to request this short_name while it didn't exist, we will now find it
    if { [info exists row(short_name)] && $row(short_name) ne "" } {
        get_id_flush -short_name $row(short_name)
    }

    return $authority_id
Generic XQL file:
packages/acs-authentication/tcl/authority-procs.xql

PostgreSQL XQL file:
<fullquery name="auth::authority::create.create_authority">
    <querytext>
            select authority__new(
                :authority_id,
                null, -- object_type
                :short_name,
                :pretty_name,
                :enabled_p,
                :sort_order,
                :auth_impl_id,
                :pwd_impl_id,
                :forgotten_pwd_url,
                :change_pwd_url,
                :register_impl_id,
                :register_url,
                :help_contact_text,
                :creation_user,
                :creation_ip,
                :context_id
            );                    
        </querytext>
</fullquery>
packages/acs-authentication/tcl/authority-procs-postgresql.xql

Oracle XQL file:
<fullquery name="auth::authority::create.create_authority">
    <querytext>
            begin
            :1 := authority.new(
                authority_id => :authority_id,
                short_name => :short_name,
                pretty_name => :pretty_name,
                enabled_p => :enabled_p,
                sort_order => :sort_order,
                auth_impl_id => :auth_impl_id,
                pwd_impl_id => :pwd_impl_id,
                forgotten_pwd_url => :forgotten_pwd_url,
                change_pwd_url => :change_pwd_url,
                register_impl_id => :register_impl_id,
                register_url => :register_url,
                help_contact_text => :help_contact_text,
                creation_user => :creation_user,
                creation_ip => :creation_ip,
                context_id => :context_id
            );   
            end;                 
        </querytext>
</fullquery>
packages/acs-authentication/tcl/authority-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: