site_node::verify_folder_name (public)

 site_node::verify_folder_name -parent_node_id parent_node_id \
    [ -current_node_id current_node_id ] \
    [ -instance_name instance_name ] [ -folder folder ]

Defined in packages/acs-tcl/tcl/site-nodes-procs.tcl

Verifies that the given folder name is valid for a folder under the given parent_node_id. If current_node_id is supplied, it's assumed that we're renaming an existing node, not creating a new one. If folder name is not supplied, we'll generate one from the instance name, which must then be supplied.

Switches:
-parent_node_id (required)
-current_node_id (optional)
-instance_name (optional)
-folder (optional)
Returns:
folder name, or empty string if the supplied folder name wasn't acceptable.

Partial Call Graph (max 5 caller/called nodes):
%3 test_site_node_verify_folder_name site_node_verify_folder_name (test acs-tcl) site_node::verify_folder_name site_node::verify_folder_name test_site_node_verify_folder_name->site_node::verify_folder_name acs_package_root_dir acs_package_root_dir (public) site_node::verify_folder_name->acs_package_root_dir ad_file ad_file (public) site_node::verify_folder_name->ad_file site_node::exists_p site_node::exists_p (public) site_node::verify_folder_name->site_node::exists_p site_node::get site_node::get (public) site_node::verify_folder_name->site_node::get site_node::get_children site_node::get_children (public) site_node::verify_folder_name->site_node::get_children packages/acs-subsite/www/admin/applications/application-add.tcl packages/acs-subsite/ www/admin/applications/application-add.tcl packages/acs-subsite/www/admin/applications/application-add.tcl->site_node::verify_folder_name packages/acs-subsite/www/admin/applications/multiple-add.tcl packages/acs-subsite/ www/admin/applications/multiple-add.tcl packages/acs-subsite/www/admin/applications/multiple-add.tcl->site_node::verify_folder_name packages/acs-subsite/www/admin/subsite-add.tcl packages/acs-subsite/ www/admin/subsite-add.tcl packages/acs-subsite/www/admin/subsite-add.tcl->site_node::verify_folder_name

Testcases:
site_node_verify_folder_name
Source code:
    set existing_urls [site_node::get_children -node_id $parent_node_id -element name]

    array set parent_node [site_node::get -node_id $parent_node_id]
    if { $parent_node(package_key) ne "" } {
        # Find all the page or directory names under this package
        foreach path [glob -nocomplain -types d "[acs_package_root_dir $parent_node(package_key)]/www/*"] {
            lappend existing_urls [lindex [ad_file split $path] end]
        }
        foreach path [glob -nocomplain -types f "[acs_package_root_dir $parent_node(package_key)]/www/*.adp"] {
            lappend existing_urls [file rootname [lindex [ad_file split $path] end]]
        }
        foreach path [glob -nocomplain -types f "[acs_package_root_dir $parent_node(package_key)]/www/*.tcl"] {
            set name [file rootname [lindex [ad_file split $path] end]]
            if { $name ni $existing_urls } {
                lappend existing_urls $name
            }
        }
    }

    if { $folder ne "" } {
        if { $folder in $existing_urls } {
            # The folder is on the list
            if { $current_node_id eq "" } {
                # New node: Complain
                return {}
            } else {
                # Renaming an existing node: Check to see if the node is merely conflicting with itself
                set parent_url [site_node::get_url -node_id $parent_node_id]
                set new_node_url "$parent_url$folder"
                if { ![site_node::exists_p -url $new_node_url]
                     || $current_node_id != [site_node::get_node_id -url $new_node_url]
                 } {
                    return {}
                }
            }
        }
    } else {
        # Autogenerate folder name
        if { $instance_name eq "" } {
            error "Instance name must be supplied when folder name is empty."
        }

        set folder [util_text_to_url  -existing_urls $existing_urls  -text $instance_name]
    }
    return $folder
Generic XQL file:
packages/acs-tcl/tcl/site-nodes-procs.xql

PostgreSQL XQL file:
packages/acs-tcl/tcl/site-nodes-procs-postgresql.xql

Oracle XQL file:
packages/acs-tcl/tcl/site-nodes-procs-oracle.xql

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