(:~ : Global constants and functions. : : @author Rave Technologies, https://www.rave-tech.com/, 2017 :) (:~ : Update History : : Modified on 16/03/21: Intorduced new database URLs :) module namespace config = 'http://www.rave-tech.com/bloomsbury/config'; import module namespace Session = 'http://basex.org/modules/session'; (:~ Processing Server. :) declare variable $config:Server as xs:string := 'http://172.20.2.103:8984/'; (:~ Mail Server :) declare variable $config:MailServer as xs:string := 'http://172.20.1.93/xml-cms-api/emailservice'; (:~ Content Databases. :) declare variable $config:AuditDatabase as xs:string := 'SYS_AUDIT'; declare variable $config:ContentMetadataDatabse as xs:string := 'SYS_CONTENT_METADATA'; declare variable $config:URLsDatabse as xs:string := 'URLs'; declare variable $config:CoreDatabase as xs:string := 'bloomsbury'; declare variable $config:LooseleafDatabase as xs:string := 'looseleaf'; declare variable $config:MonographDatabase as xs:string := 'monograph'; declare variable $config:archiveDatabase as xs:string := 'archive'; declare variable $config:articleDatabase as xs:string := 'article'; declare variable $config:referenceDatabase as xs:string := 'reference'; declare variable $config:playDatabase as xs:string := 'play'; declare variable $config:screenplayDatabase as xs:string := 'screenplay'; declare variable $config:Person as xs:string := 'person'; declare variable $config:fashionDatabase as xs:string := 'fashion'; declare variable $config:Audio as xs:string := 'audio'; declare variable $config:Video as xs:string := 'video'; declare variable $config:Publisher as xs:string := 'publisher'; declare variable $config:Organisation as xs:string := 'organisation'; declare variable $config:Series as xs:string := 'series'; declare variable $config:Image as xs:string := 'image'; declare variable $config:MetadataOnlyContentDatabase as xs:string := 'metadataonlycontent'; declare variable $config:ContentManagementDatabase as xs:string := 'content-management'; declare variable $config:ContentManagementCollection as xs:string := '/content-management/'; declare variable $config:OnixDB as xs:string := 'ONIXDB'; declare variable $config:Onix as xs:string := '/ONIX/'; (:~ Debug on/off. :) declare variable $config:Debug as xs:boolean := fn:true(); (:~ Job Queue :) declare variable $config:queueXml as xs:boolean := 'job-queue.xml'; (:~ Job Queue Path :) declare variable $config:queueDir as xs:boolean := '/queue/'; (:~ Main Directories of the application. :) (:~ User Directory. :) declare variable $config:UserDir as xs:string := '/user/'; (:~ Taxonomy Directory. :) declare variable $config:TaxonomyDir as xs:string := '/taxonomies/'; (:~ Configuration Directory. :) declare variable $config:ConfigDir as xs:string := '/config/'; (:~ Pipeline Directory. :) declare variable $config:PipelineDir as xs:string := '/pipelines/'; (:~ Transformation Directory. :) declare variable $config:TransformDir as xs:string := '/transforms/'; (:~ Validation Directory. :) declare variable $config:ValidationDir as xs:string := '/validation/'; (:~ Product Directory. :) declare variable $config:ProductDir as xs:string := '/products/'; (:~ Content Directory. :) declare variable $config:ContentDir as xs:string := '/content/'; (:~ Latest Directory to keep latest version. :) declare variable $config:LatestDir as xs:string := '/latest/'; (:~ Jobs Directory. :) declare variable $config:JobDir as xs:string := '/jobs/'; (:~ docx Directory. :) declare variable $config:WordDir as xs:string := '/word/'; (:~ Version Directory to keep old version. :) declare variable $config:VersionDir as xs:string := '/version/'; (:~ metadata Directory to keep content metadata xml. :) declare variable $config:Metadata as xs:string := '/metadata/'; (:~ Audit Directory. :) declare variable $config:AuditDir as xs:string := 'audit/'; (:~ Report Directory. :) declare variable $config:ReportDir as xs:string := '/reports/'; (:~ To keep lock information. :) declare variable $config:LockDir as xs:string := '/locks/'; (:~ Temp Directory. :) declare variable $config:TempDir as xs:string := 'D:\bloomsbury-CMS\bl-workspace\'; (:~ Pipeline output directory for temp :) declare variable $config:TempPipelineDir as xs:string := fn:concat($config:TempDir,'pipeline_output/'); (:~ Validator files :) (:~ Product RELAX NG. :) declare variable $config:ProductRelaxNG as xs:string := 'product-manifest.rnc'; (:~ Taxonomy RELAX NG. :) declare variable $config:TaxonomyRelaxNG as xs:string := 'taxonomy.rnc'; (:~ Pipeline RELAX NG. :) declare variable $config:PipelineRelaxNG as xs:string := 'pipeline.rnc'; (:~ Taxonomy Schematron. :) declare variable $config:TaxonomySchematron as xs:string := 'taxonomy.sch'; (:~ Configurable XML files location :) (:~ Status XML Path. :) declare variable $config:StatusFile as xs:string := fn:concat($config:ConfigDir,'content_statuses.xml'); (:~ Content Type XML Path. :) declare variable $config:ContentType as xs:string := fn:concat($config:ConfigDir,'content-types.xml'); (:~ Role XML Path. :) declare variable $config:Role as xs:string := fn:concat($config:ConfigDir,'user-roles.xml'); (:~ Organization chart XML Path. :) declare variable $config:OrgChart as xs:string := fn:concat($config:ConfigDir,'organization_chart.xml'); (:~ Pipeline Configuration file path :) declare variable $config:PipelineConfig as xs:string := fn:concat($config:ConfigDir,'ingest-pipeline-config.xml'); (:~ Pipeline Configuration file path :) declare variable $config:DownloadConfig as xs:string := fn:concat($config:ConfigDir,'content-download.xml'); (:~ Global prefixes :) (:~ User ID prefix. :) declare variable $config:UserIDPrefix as xs:string := "USR"; (:~ Password token prefix. :) declare variable $config:PasswordTokenPrefix as xs:string := "TKN"; (:~ Job ID prefix. :) declare variable $config:JobIDPrefix as xs:string := "SCH"; (:~ Product ID prefix. :) declare variable $config:ProductIDPrefix as xs:string := "PRD"; (:~ Taxonomy ID prefix. :) declare variable $config:TaxonomyIDPrefix as xs:string := "TAX"; (:~ Global XSLT :) (:~ DocBook to WordML. :) declare variable $config:DocBook2WordML as xs:string := fn:concat($config:TransformDir,'docBook2WordML.xsl'); (:~ Pagination Default values :) (:~ Maximum number of records to display in a page :) declare variable $config:size as xs:integer := 10; (:~ First page to display :) declare variable $config:page as xs:integer := 1; (:~ Allowed login failure attempt :) declare variable $config:LoginAttempt as xs:integer := 3; (:~ Global file name :) (:~ Common file name to keep audit information :) declare variable $config:AuditFileName as xs:string := 'audit.xml'; (:~ Common file name to keep version control :) declare variable $config:VersionControlFileName as xs:string := 'version.xml'; (:~ DOC XML Path :) declare variable $config:DocXml as xs:string := "word/document.xml"; (:~ Style XML Path :) declare variable $config:StyleXml as xs:string := "word/styles.xml"; declare variable $config:WordStyle as xs:string := fn:concat($config:TransformDir,'styles.xslt'); (:~ DOC image relationship file :) declare variable $config:DocRelXml as xs:string := "word/_rels/document.xml.rels"; (:~ Looseleaf header file :) declare variable $config:HeaderXml as xs:string := "header.xml"; (:~ To keep extra information of the documents: like Area/Content Type :) declare variable $config:InfoXml as xs:string := 'properties.xml'; (:~ To keep content metadata information :) declare variable $config:MetaXml as xs:string := 'metadata.xml'; (:~ To keep content classify information :) declare variable $config:ClassifyXml as xs:string := 'classify.xml'; (:~ password token default validity :) declare variable $config:PTokenValidity as xs:duration := xs:dayTimeDuration('P2D'); (:~ Output Directory to store downloaded content. :) declare variable $config:OutDir as xs:string := 'D:\output\download\'; (:~ Report Directory to store downloaded report. :) declare variable $config:PublishReportDir as xs:string := 'C:\output\download\report\'; (:~ Output Directory to store published content. :) declare variable $config:PublishDir as xs:string := 'C:\Program Files (x86)\BaseX\output\publish\'; declare variable $config:Xmlziplocation as xs:string := 'C:\output\download\xmlzip\'; (:~ : Display debug message in serer log : @param message The message to print in log file : @return empty sequence :) declare %updating function config:update-message( $message as xs:string ) { if($config:Debug) then admin:write-log($message) else () }; (:~ : Display debug message in serer log : @param message The message to print in log file : @return empty sequence :) declare function config:non-update-message( $message as xs:string ) { if($config:Debug) then admin:write-log($message) else () }; (:~ Checks if the current client is logged in. If not, raises an error. :) declare function config:session-check( $SKey as xs:string ) as empty-sequence() { if(Session:get($SKey)) then () else fn:error(xs:QName('config:authentication'), 'Invalid token.') }; (:~ Get Session value (username) :) declare function config:session-value( $SKey as xs:string ) { Session:get($SKey) }; (:~ Return error message to the UI if authentication fails :) declare %rest:error("config:authentication") %rest:error-param("description", "{$message}") function config:error($message) { Failure{$message}, config:non-update-message("***Invalid Token***") }; (:~ : Generate Session ID for the user : @param $email User email address : @return element(result) :) declare function config:session-id( $email as xs:string ) { let $dateTime := fn:current-date() let $day := fn:day-from-date($dateTime) let $month := fn:month-from-date($dateTime) let $year := fn:year-from-date($dateTime) let $time := fn:current-time() let $hour := fn:hours-from-time($time) let $minute := fn:minutes-from-time($time) let $second := fn:seconds-from-time($time) let $token := fn:concat(fn:string(($day * 25) + ($month * 16) + ($year * 1000) + ($hour * 22) + ($minute * 40) + ($second * 40)),'$$$',$email) return string(convert:string-to-hex($token)) };