1*bb113e63SAndrew Rist# ************************************************************* 2*bb113e63SAndrew Rist# 3*bb113e63SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4*bb113e63SAndrew Rist# or more contributor license agreements. See the NOTICE file 5*bb113e63SAndrew Rist# distributed with this work for additional information 6*bb113e63SAndrew Rist# regarding copyright ownership. The ASF licenses this file 7*bb113e63SAndrew Rist# to you under the Apache License, Version 2.0 (the 8*bb113e63SAndrew Rist# "License"); you may not use this file except in compliance 9*bb113e63SAndrew Rist# with the License. You may obtain a copy of the License at 10*bb113e63SAndrew Rist# 11*bb113e63SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12*bb113e63SAndrew Rist# 13*bb113e63SAndrew Rist# Unless required by applicable law or agreed to in writing, 14*bb113e63SAndrew Rist# software distributed under the License is distributed on an 15*bb113e63SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*bb113e63SAndrew Rist# KIND, either express or implied. See the License for the 17*bb113e63SAndrew Rist# specific language governing permissions and limitations 18*bb113e63SAndrew Rist# under the License. 19*bb113e63SAndrew Rist# 20*bb113e63SAndrew Rist# ************************************************************* 21cdf0e10cSrcweir# 22cdf0e10cSrcweir# # ------------------------------------------------------------------------------ 23cdf0e10cSrcweir# 24cdf0e10cSrcweir# sub DB_INSERT_INTO_TABLE_STATUS() 25cdf0e10cSrcweir# { 26cdf0e10cSrcweir# # my $sDocID = shift; 27cdf0e10cSrcweir# # my $sDBDistinct = shift; 28cdf0e10cSrcweir# 29cdf0e10cSrcweir# my $sHostname = hostname; 30cdf0e10cSrcweir# 31cdf0e10cSrcweir# my $sSQL = "INSERT INTO status (docid, dbdistinct2, hostname)"; 32cdf0e10cSrcweir# $sSQL .= " VALUES ($docid, '$dbdistinct', '$sHostname')"; 33cdf0e10cSrcweir# ExecSQL($sSQL); 34cdf0e10cSrcweir# } 35cdf0e10cSrcweir# sub DB_UPDATE_TABLE_STATUS_SET_INFO($) 36cdf0e10cSrcweir# { 37cdf0e10cSrcweir# # my $sDocID = shift; 38cdf0e10cSrcweir# # my $sDBDistinct = shift; 39cdf0e10cSrcweir# my $sInfo = shift; 40cdf0e10cSrcweir# 41cdf0e10cSrcweir# # my $sHostname = hostname; 42cdf0e10cSrcweir# 43cdf0e10cSrcweir# my $sInsertSQL = "UPDATE status SET info='$sInfo' WHERE docid=$docid AND dbdistinct2='$dbdistinct'"; 44cdf0e10cSrcweir# ExecSQL($sInsertSQL); 45cdf0e10cSrcweir# } 46cdf0e10cSrcweir# 47cdf0e10cSrcweir# sub DB_UPDATE_TABLE_DOCUMENTS_SET_STATE_INFO($$) 48cdf0e10cSrcweir# { 49cdf0e10cSrcweir# # my $sDocID = shift; 50cdf0e10cSrcweir# my $sStatus = shift; 51cdf0e10cSrcweir# my $sError = shift; 52cdf0e10cSrcweir# 53cdf0e10cSrcweir# my $sSQL = "UPDATE documents"; 54cdf0e10cSrcweir# $sSQL .= " SET state='" . $sStatus . "'"; 55cdf0e10cSrcweir# $sSQL .= ",info='" . $sError . "'"; 56cdf0e10cSrcweir# $sSQL .= " WHERE docid=$docid"; 57cdf0e10cSrcweir# ExecSQL($sSQL); 58cdf0e10cSrcweir# } 59cdf0e10cSrcweir# sub DB_UPDATE_TABLE_STATUS_SET_STATE($) 60cdf0e10cSrcweir# { 61cdf0e10cSrcweir# # my $sDocID = shift; 62cdf0e10cSrcweir# my $sStatus = shift; 63cdf0e10cSrcweir# 64cdf0e10cSrcweir# my $sSQL = "UPDATE status"; 65cdf0e10cSrcweir# $sSQL .= " SET state='" . $sStatus . "'"; 66cdf0e10cSrcweir# $sSQL .= " WHERE docid=$docid"; 67cdf0e10cSrcweir# ExecSQL($sSQL); 68cdf0e10cSrcweir# } 69cdf0e10cSrcweir# 70cdf0e10cSrcweir# # sub DB_UPDATE_TABLE_STATUS_SET_STATE_FAILED() 71cdf0e10cSrcweir# # { 72cdf0e10cSrcweir# # DB_UPDATE_TABLE_STATUS_SET_STATE("FAILED-FAILED"); 73cdf0e10cSrcweir# # } 74cdf0e10cSrcweir# # ------------------------------------------------------------------------------ 75cdf0e10cSrcweir# # sub getDBConnectionString() 76cdf0e10cSrcweir# # { 77cdf0e10cSrcweir# # # return "server:jakobus,db:jobs_convwatch,user:admin,passwd:admin"; 78cdf0e10cSrcweir# # return "server:unoapi,db:jobs_convwatch,user:convwatch,passwd:convwatch"; 79cdf0e10cSrcweir# # } 80cdf0e10cSrcweir# # ------------------------------------------------------------------------------ 81cdf0e10cSrcweir# sub getSourceInfo($) 82cdf0e10cSrcweir# { 83cdf0e10cSrcweir# my $sDBStr = shift; 84cdf0e10cSrcweir# 85cdf0e10cSrcweir# my $sSourceVersion; 86cdf0e10cSrcweir# if ( $sDBStr =~ / sourceversion='(.*?)',/ ) 87cdf0e10cSrcweir# { 88cdf0e10cSrcweir# $sSourceVersion = $1; 89cdf0e10cSrcweir# log_print( "sSourceVersion: $sSourceVersion\n"); 90cdf0e10cSrcweir# } 91cdf0e10cSrcweir# if (! $sSourceVersion) 92cdf0e10cSrcweir# { 93cdf0e10cSrcweir# log_print( "Error: no value for sourceversion found.\n"); 94cdf0e10cSrcweir# return; 95cdf0e10cSrcweir# } 96cdf0e10cSrcweir# my $sSourceName; 97cdf0e10cSrcweir# if ( $sDBStr =~ / sourcename='(.*?)',/ ) 98cdf0e10cSrcweir# { 99cdf0e10cSrcweir# $sSourceName = $1; 100cdf0e10cSrcweir# log_print( "sSourceName: $sSourceName\n"); 101cdf0e10cSrcweir# } 102cdf0e10cSrcweir# my $sSourceCreatorType; 103cdf0e10cSrcweir# if ( $sDBStr =~ / sourcecreatortype='(.*?)',/ ) 104cdf0e10cSrcweir# { 105cdf0e10cSrcweir# $sSourceCreatorType = $1; 106cdf0e10cSrcweir# log_print( "sSourceCreatorType: $sSourceCreatorType\n"); 107cdf0e10cSrcweir# } 108cdf0e10cSrcweir# return $sSourceVersion, $sSourceName, $sSourceCreatorType; 109cdf0e10cSrcweir# } 110cdf0e10cSrcweir# # ------------------------------------------------------------------------------ 111cdf0e10cSrcweir# sub getDestinationInfo($) 112cdf0e10cSrcweir# { 113cdf0e10cSrcweir# my $sDBStr = shift; 114cdf0e10cSrcweir# 115cdf0e10cSrcweir# my $sDestinationVersion; 116cdf0e10cSrcweir# if ( $sDBStr =~ / destinationversion='(.*?)',/ ) 117cdf0e10cSrcweir# { 118cdf0e10cSrcweir# $sDestinationVersion = $1; 119cdf0e10cSrcweir# log_print( "sDestinationVersion: $sDestinationVersion\n"); 120cdf0e10cSrcweir# } 121cdf0e10cSrcweir# if (! $sDestinationVersion) 122cdf0e10cSrcweir# { 123cdf0e10cSrcweir# log_print( "Error: no value for destinationversion found.\n"); 124cdf0e10cSrcweir# return; 125cdf0e10cSrcweir# } 126cdf0e10cSrcweir# my $sDestinationName; 127cdf0e10cSrcweir# if ( $sDBStr =~ / destinationname='(.*?)',/ ) 128cdf0e10cSrcweir# { 129cdf0e10cSrcweir# $sDestinationName = $1; 130cdf0e10cSrcweir# log_print( "sDestinationName: $sDestinationName\n"); 131cdf0e10cSrcweir# } 132cdf0e10cSrcweir# my $sDestinationCreatorType; 133cdf0e10cSrcweir# if ( $sDBStr =~ / destinationcreatortype='(.*?)',/ ) 134cdf0e10cSrcweir# { 135cdf0e10cSrcweir# $sDestinationCreatorType = $1; 136cdf0e10cSrcweir# log_print( "sDestinationCreatorType: $sDestinationCreatorType\n"); 137cdf0e10cSrcweir# } 138cdf0e10cSrcweir# return $sDestinationVersion, $sDestinationName, $sDestinationCreatorType; 139cdf0e10cSrcweir# } 140cdf0e10cSrcweir# # ------------------------------------------------------------------------------ 141cdf0e10cSrcweir# # sub getMailAddress($) 142cdf0e10cSrcweir# # { 143cdf0e10cSrcweir# # my $sDBStr = shift; 144cdf0e10cSrcweir# # my $sMailAddress = ""; 145cdf0e10cSrcweir# # if ( $sDBStr =~ / mailfeedback='(.*?)',/ ) 146cdf0e10cSrcweir# # { 147cdf0e10cSrcweir# # $sMailAddress = $1; 148cdf0e10cSrcweir# # log_print( "sMailAddress: $sMailAddress\n"); 149cdf0e10cSrcweir# # } 150cdf0e10cSrcweir# # return $sMailAddress; 151cdf0e10cSrcweir# # } 152cdf0e10cSrcweir# 153cdf0e10cSrcweir# # sub getDocumentInfo($) 154cdf0e10cSrcweir# # { 155cdf0e10cSrcweir# # my $sDBStr = shift; 156cdf0e10cSrcweir# # 157cdf0e10cSrcweir# # my $sDocumentPoolPath; 158cdf0e10cSrcweir# # if ( $sDBStr =~ / documentpoolpath='(.*?)',/ ) 159cdf0e10cSrcweir# # { 160cdf0e10cSrcweir# # $sDocumentPoolPath = $1; 161cdf0e10cSrcweir# # log_print( "sDocumentPoolPath: $sDocumentPoolPath\n"); 162cdf0e10cSrcweir# # } 163cdf0e10cSrcweir# # if (! $sDocumentPoolPath) 164cdf0e10cSrcweir# # { 165cdf0e10cSrcweir# # log_print( "Error: no value for documentpoolpath found.\n"); 166cdf0e10cSrcweir# # return; 167cdf0e10cSrcweir# # } 168cdf0e10cSrcweir# # my $sDocumentPool; 169cdf0e10cSrcweir# # if ( $sDBStr =~ / documentpool='(.*?)',/ ) 170cdf0e10cSrcweir# # { 171cdf0e10cSrcweir# # $sDocumentPool = $1; 172cdf0e10cSrcweir# # log_print( "sDocumentPool: $sDocumentPool\n"); 173cdf0e10cSrcweir# # } 174cdf0e10cSrcweir# # if (! $sDocumentPool) 175cdf0e10cSrcweir# # { 176cdf0e10cSrcweir# # log_print( "Error: no value for documentpool found.\n"); 177cdf0e10cSrcweir# # return; 178cdf0e10cSrcweir# # } 179cdf0e10cSrcweir# # my $sDocumentName; 180cdf0e10cSrcweir# # if ( $sDBStr =~ / name='(.*?)',/ ) 181cdf0e10cSrcweir# # { 182cdf0e10cSrcweir# # $sDocumentName = $1; 183cdf0e10cSrcweir# # log_print( "sDocumentName: $sDocumentName\n"); 184cdf0e10cSrcweir# # } 185cdf0e10cSrcweir# # return $sDocumentPoolPath, $sDocumentPool, $sDocumentName; 186cdf0e10cSrcweir# # } 187cdf0e10cSrcweir# 188cdf0e10cSrcweir# sub getDistinct($) 189cdf0e10cSrcweir# { 190cdf0e10cSrcweir# my $sDBStr = shift; 191cdf0e10cSrcweir# my $sDBDistinct; 192cdf0e10cSrcweir# if ( $sDBStr =~ / dbdistinct2='(\S*?)',/ ) 193cdf0e10cSrcweir# { 194cdf0e10cSrcweir# $sDBDistinct = $1; 195cdf0e10cSrcweir# log_print( "dbdistinct2: $sDBDistinct\n"); 196cdf0e10cSrcweir# } 197cdf0e10cSrcweir# return $sDBDistinct; 198cdf0e10cSrcweir# } 199cdf0e10cSrcweir# 200cdf0e10cSrcweir# sub getIDInfo($) 201cdf0e10cSrcweir# { 202cdf0e10cSrcweir# my $sDBStr = shift; 203cdf0e10cSrcweir# # my $dbdistinct; 204cdf0e10cSrcweir# 205cdf0e10cSrcweir# my $sDBDistinct = getDistinct($sDBStr); 206cdf0e10cSrcweir# # if ( $sDBStr =~ / dbdistinct2='(\S*?)',/ ) 207cdf0e10cSrcweir# # { 208cdf0e10cSrcweir# # $sDBDistinct = $1; 209cdf0e10cSrcweir# # log_print( "dbdistinct2: $sDBDistinct\n"); 210cdf0e10cSrcweir# # } 211cdf0e10cSrcweir# if (! $sDBDistinct) 212cdf0e10cSrcweir# { 213cdf0e10cSrcweir# log_print( "Error: no dbdistinct given.\n"); 214cdf0e10cSrcweir# return; 215cdf0e10cSrcweir# } 216cdf0e10cSrcweir# my $sDocID; 217cdf0e10cSrcweir# if ( $sDBStr =~ / docid=(\S*?),/ ) 218cdf0e10cSrcweir# { 219cdf0e10cSrcweir# $sDocID = $1; 220cdf0e10cSrcweir# log_print( "docid: $sDocID\n"); 221cdf0e10cSrcweir# } 222cdf0e10cSrcweir# if (! $sDocID) 223cdf0e10cSrcweir# { 224cdf0e10cSrcweir# log_print( "Error: no docid given.\n"); 225cdf0e10cSrcweir# return; 226cdf0e10cSrcweir# } 227cdf0e10cSrcweir# return $sDBDistinct, $sDocID; 228cdf0e10cSrcweir# } 229cdf0e10cSrcweir# 230