#
# Copyright for the Uniform Repository Service (c) 1995 - 2025 # by Gerald Banon. All rights reserved. # Version 2.1 # resolve.tcl # # Created by GJFB in 2025-09-06 from an old version of from.tcl # # If the document is in the current local collection, it is returned, # otherwise it is searched within the scope of the whole URLib # collection and of the local bibliographic mirror # (unless the call is done from another mirror) and the # document corresponding to the official version or the most recent # metadata last update is returned. # # Examples: if 0 { http://mtc-m12.sid.inpe.br/urn:doi:10.17487/RFC8141?ibiurl.clientinformation.citingitem=urlib.net/www/2023/06.03.21.17&linktype=relative http://gjfb0520.sid.inpe.br/urn:doi:10.1590/0001-3765202320210807?ibiurl.clientinformation.citingitem=urlib.net/www/2023/11.16.13.37&linktype=relative http://gjfb:1905/urn:doi:10.1590/0001-3765202320210807?ibiurl.clientinformation.citingitem=urlib.net/www/2023/11.16.13.37&linktype=relative # both URL below are not processed by Resolve http://gjfb:1905/upn:4CR88AP:QABCDSTQQW/4BT93R5?ibiurl.clientinformation.citingitem=iconet.com.br/banon/2001/04.28.19.50&linktype=relative http://gjfb:1905/upn:4CR88AP-:QABCDSTQQW/4BT93R5?ibiurl.clientinformation.citingitem=iconet.com.br/banon/2001/04.28.19.50&linktype=relative } # this sort of URL must call the solve cgi script proc Resolve {} { if [catch { global env # OBS: resolverID == uriPrefix # resolverID and destination regexp {^/(.+:.+):(.+)$} $env(PATH_INFO) m resolverID destination # ibiResolver (localSite) set ibiResolver $env(SERVER_NAME):$env(SERVER_PORT) # homePath set homePath $env(DOCUMENT_ROOT) # URLibServiceRepository set URLibServiceRepository $env(URLIB_SERVICE_REP) source $homePath/col/$URLibServiceRepository/doc/utilities1.tcl ;# StoreArray if 0 { puts {Content-Type: text/html} puts {} puts $env(PATH_INFO) ;# => /urn:doi:10.17487/RFC8141 puts
puts $resolverID ;# => urn:doi puts
puts $destination ;# 10.17487/RFC8141 } # Store xxx C:/tmp/bbb.txt auto 0 a if ![info exists resolverID] { puts "Location: http://$ibiResolver/customizeerror.cgi/603" puts "" return } if [string equal {urn:ibi} $resolverID] { puts "Location: http://$ibiResolver/customizeerror.cgi/602" puts "" } if {[info exists env(QUERY_STRING)] && [string compare {} $env(QUERY_STRING)] != 0} { set queryString ?$env(QUERY_STRING) } else { set queryString {} } if 0 { puts
puts --$queryString-- ;# => --?ibiurl.clientinformation.citingitem=urlib.net/www/2023/06.03.21.17-- } package require http if 0 { # manual update of uriPrefixXresolverURLarray set uriPrefixXresolverURLarray(upn:4CR88AP) $ibiResolver ;# added by GJFB in 2025-06-11 set uriPrefixXresolverURLarray(upn:4CR88AP-) $ibiResolver ;# added by GJFB in 2025-06-11 set uriPrefixXresolverURLarray(urn:doi) doi.org ;# added by GJFB in 2023-12-26 # set uriPrefixXresolverURLarray(purl) purl.org } else { # automatic update of uriPrefixXresolverURLarray if [file exists $homePath/col/$URLibServiceRepository/auxdoc/uriPrefixXresolverURLarray.tcl] { source $homePath/col/$URLibServiceRepository/auxdoc/uriPrefixXresolverURLarray.tcl ;# set uriPrefixXresolverURLarray cache } # see: Returning the resolver URL of a given URN or UPN # set url http://gjfb:1905/col/urlib.net/www/2025/09.08.04.08/doc/script.cgi?upn:4CR88AP # set url http://$ibiResolver/col/urlib.net/www/2025/09.08.04.08/doc/script.cgi?$resolverID set url http://urlib.net/col/urlib.net/www/2025/09.08.04.08/doc/script.cgi?$resolverID if [catch {http::geturl $url} token] { # nothing to do } else { if {[http::ncode $token] == 200} { set uriPrefixXresolverURLarray($resolverID) [string trim [http::data $token]] ;# trim is a must - update uriPrefixXresolverURLarray cache if ![string equal {} $uriPrefixXresolverURLarray($resolverID)] { StoreArray uriPrefixXresolverURLarray $homePath/col/$URLibServiceRepository/auxdoc/uriPrefixXresolverURLarray.tcl w list array 1 } } http::cleanup $token } } if {![info exists uriPrefixXresolverURLarray($resolverID)] || [string equal {} $uriPrefixXresolverURLarray($resolverID)]} { puts "Location: http://$ibiResolver/customizeerror.cgi/603" puts "" return } if [regexp {upn:4CR88AP-?} $resolverID] { # upn:4CR88AP or upn:4CR88AP- set link $uriPrefixXresolverURLarray($resolverID)/$resolverID:$destination$queryString } elseif {[regexp {urn:doi} $resolverID]} { ;# added by GJFB in 2023-11-11 to display a copy (if any) of the item identified by its doi - added by GJFB in 2025-06-29 # urn:doi global serverAddress ;# used by SetFieldValue # source $homePath/col/$URLibServiceRepository/doc/utilities1.tcl source $homePath/col/$URLibServiceRepository/doc/utilitiesMirror.tcl source $homePath/col/$URLibServiceRepository/doc/cgi/mirrorfind-.tcl # serverAddress set serverAddress [list $env(SERVER_NAME) $env(URLIB_PORT)] set resultList [FindMetadataRepositories "doi $destination" 0 {} {} no no 1] if 0 { puts {Content-Type: text/html} puts {} puts --$resultList-- } if [string equal {} $resultList] { # no copies of the item identified by its doi were found in the URLib collection set link $uriPrefixXresolverURLarray($resolverID)/$destination$queryString ;# use doi } else { # a copy was found if [catch {http::geturl http://doi.org/} token] { ;# if added by GJFB in 2025-06-29 # site not found - use the copy foreach {site rep-i} [lindex $resultList 0] {break} # puts --$site-- # puts --${rep-i}-- SetFieldValue $site ${rep-i} identifier # puts --$identifier-- set link $uriPrefixXresolverURLarray(upn:4CR88AP)/upn:4CR88AP:$identifier$queryString ;# use ibi copy } else { # use the original - added by GJFB in 2025-06-29 http::cleanup $token set link $uriPrefixXresolverURLarray($resolverID)/$destination ;# use doi } } } else { # purl... return } if 0 { # testing 'Example of robust hypertext and authentic data' (QABCDSTQQW/4AEFPDB) when GetOptimizedListOfSites was executed using MultipleExecute if [file exists $homePath/fileFlag] { # set xWaitQueue 0; after 1000 {set xWaitQueue 1}; vwait xWaitQueue set xWaitQueue 0; after 2000 {set xWaitQueue 1}; vwait xWaitQueue ;# OK } else { set x x Store x $homePath/fileFlag } } # location http://doi.org/10.17487/RFC8141 gerado em solve puts "Location: http://$link" puts "" # => Location: http://doi.org/10.1590/0001-3765202320210807?ibiurl.clientinformation.citingitem=urlib.net/www/2023/11.16.13.37&linktype=relative } m] { if ![string equal {} $m] { puts {Content-Type: text/html} puts {} puts "Resolve: $m" if 0 {global errorInfo; puts$errorInfo} } } } #