Changeset 37233
- Timestamp:
- 2023-01-31T23:41:56+13:00 (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cgiactions/metadataaction.pm
r37215 r37233 75 75 "get-archives-text" => { 76 76 'compulsory-args' => [ "d" ], 77 'optional-args' => [ "dv" ] },77 'optional-args' => [ "dv" ] 78 78 #'compulsory-args' => [ "d" ], 79 #'optional-args' => [ "section" ] }, 79 #'optional-args' => [ "section" ] }, 80 }, 80 81 81 82 #GET METHODS 82 83 "get-import-metadata" => { 83 84 'compulsory-args' => [ "d", "metaname" ], 84 'optional-args' => [ "metapos" ] }, 85 'optional-args' => [ "metapos" ] 86 }, 85 87 86 88 "get-archives-metadata" => { 87 89 'compulsory-args' => [ "d", "metaname" ], 88 'optional-args' => [ "dv", "metapos" ] }, 90 'optional-args' => [ "dv", "metapos" ] 91 }, 89 92 90 93 "get-archives-assocfile" => { 91 94 'compulsory-args' => [ "d", "assocname" ], 92 'optional-args' => [ "dv" ] }, 95 'optional-args' => [ "dv" ] 96 }, 93 97 94 98 "get-index-metadata" => { 95 99 'compulsory-args' => [ "d", "metaname" ], 96 'optional-args' => [ "metapos" ] }, 100 'optional-args' => [ "metapos" ] 101 }, 97 102 98 103 "get-metadata" => { # alias for get-index-metadata 99 104 'compulsory-args' => [ "d", "metaname" ], 100 'optional-args' => [ "metapos" ] }, 105 'optional-args' => [ "metapos" ] 106 }, 101 107 102 108 "get-live-metadata" => { 103 109 'compulsory-args' => [ "d", "metaname" ], 104 'optional-args' => [ ] }, 110 'optional-args' => [ ] 111 }, 105 112 106 113 "get-metadata-array" => { # where param can be ONE of: index (default), import, archives, live … … 108 115 'optional-args' => [ "where" ], 109 116 'help-string' => [ 110 'metadata-server.pl?a=get-metadata-array&c=demo&where=index&json=[{"docid":"HASHc5bce2d6d3e5b04e470ec9","metatable":[{"metaname":"username","metapos":"all"},{"metaname":"usertimestamp","metapos":"all"}, {"metaname":"usercomment","metapos":"all"}]}]' 111 ]} 117 'metadata-server.pl?a=get-metadata-array&c=demo&where=index&json=[{"docid":"HASHc5bce2d6d3e5b04e470ec9","metatable":[{"metaname":"username","metapos":"all"},{"metaname":"usertimestamp","metapos":"all"}, {"metaname":"usercomment","metapos":"all"}]}]' ] 118 }, 119 120 "get-fldv-info" => { 121 'compulsory-args' => [ "d", ], 122 'optional-args' => [ ], 123 'help-string' => [ 124 "fldv is short for file-level document-version history. It refers to the filesystem level approach Greenstone takes to keeping a document version history of the documents formed in the 'archives' directory. When collection is imported with -keepold, for example, any existing documents in the archives area get 'bundled up' as a subfolder called 'nminus-1' within the newly formed document. If there is an existing 'nminus-1' subdirectory then this is moved to nminus-2 prior to forming a new 'nminus-1'. And so on.", 125 "Calling this action returns in JSON formated the array of 'nminus-<n>' subdirectories that a particular document has." ] 126 } 112 127 }; 128 113 129 114 130 # To get the final action_table of all available subroutines in this class, … … 1058 1074 } 1059 1075 1076 1077 1078 sub get_fldv_info 1079 { 1080 my $self = shift @_; 1081 1082 my $username = $self->{'username'}; 1083 my $collect = $self->{'collect'}; 1084 my $gsdl_cgi = $self->{'gsdl_cgi'}; 1085 my $infodbtype = $self->{'infodbtype'}; 1086 1087 # Obtain the collect dir 1088 my $site = $self->{'site'}; 1089 my $collect_dir = $gsdl_cgi->get_collection_dir($site); 1090 1091 my $archive_dir = &util::filename_cat($collect_dir, $collect, "archives"); 1092 1093 # look up additional args 1094 my $docid = $self->{'d'}; 1095 1096 1097 my $arcinfo_doc_filename = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-doc", $archive_dir); 1098 my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $docid); 1099 1100 # This now stores the full pathname [is this still true??] 1101 my $doc_file = $doc_rec->{'doc-file'}->[0]; 1102 1103 my ($unused_doc_tailname, $doc_dirname) = File::Basename::fileparse($doc_file); 1104 my $doc_full_dirname = &util::filename_cat($archive_dir,$doc_dirname); 1105 1106 my $fldv_full_dirname = &util::filename_cat($doc_full_dirname,$FLDV_HISTORY_DIR); 1107 1108 my $sorted_fldv_filtered_dirs_json = "[]"; 1109 if (-d $fldv_full_dirname) { 1110 my $fldv_filtered_dirs = &FileUtils::readDirectoryFiltered($fldv_full_dirname,undef,"^nminus-\\d+\$"); 1111 1112 my @sorted_fldv_filtered_dirs = sort { 1113 my ($a_num) = ($a =~ m/(\d+)$/); 1114 my ($b_num) = ($b =~ m/(\d+)$/); 1115 1116 # sort into ascending order 1117 return $a_num <=> $b_num; 1118 } @$fldv_filtered_dirs; 1119 1120 $sorted_fldv_filtered_dirs_json = encode_json \@sorted_fldv_filtered_dirs; 1121 } 1122 1123 $gsdl_cgi->generate_ok_message($sorted_fldv_filtered_dirs_json); 1124 } 1125 1126 1060 1127 sub get_metadata_from_archive_xml 1061 1128 {
Note:
See TracChangeset
for help on using the changeset viewer.