MXc@sddkZddkZddklZlZddklZddklZddkl Z ddk Z ddk l Z ddk l Z ddklZlZlZdd klZddkZdd klZlZlZdd klZlZeieZd e fd YZ!dS(iN(tquotetunquote(turlparse(tStringIO(tSafeConfigParser(ttime(tetree(toaipmht opensearchtsru(tprofile(tconfigtlogtutil(tcsw2tcsw3tCswcBseZdZeeddZdZdZdZdZdZ e i e dZ d Zd Zd Zd Zed ZdZdZdZdZdZdZdZdZdZedZRS(s Base CSW server s3.0.0cCs|pti|_n ||_ti|_d|_d|_d|_h|_ d|_ t |_ t |_ d|_t |_d|_d|_t |_h|_d|_d|_d|_d|_d|_hdd 6d d 6|_t|_tid ||_||_|id jo)t i!d ||_|ii"dnyt#|t$o ||_nt$|_t#|t%odx|i&D]O\}}|ii'|x0|i&D]"\}}|ii(|||qWqWnOddk)}|i*|ddi+i,} z| ~ } |ii-| WdQXWn3t.j o'|ii/ddd||_0dSX|ii(ddti1i2ti1i3ti1i2t4d|ii5dd|i_6|ii5dd|i_7t8i9|it:i;d|t:i;t<|id|ii=ddp |ii(dd|ii>n|ii=ddo"|ii5ddi?|_n|ii=ddo|ii5dd|_n|ii=ddo|ii5dd|_n|ii=ddo)|ii5dddjo d |_n|ii=dd!o)|ii5dd!djo t@tA_Bn|ii=dd"oeyWt:iCd#|ii5dd"iDd$d} | |id <|iiE| |id d|_d|_t i d |i i |i|_nt|it od|ijot|idd jo`d |_d|_t i d t d |iiD|_|ii|i|_n|idjo)tid ||_|iidn|i|ii}|iid}|iid}d|jo|ii|d|iid&d;|i|i?id<d_|iid&d'||_1t i d=|i1i2Wn:t3j o.}|ii4d.d/d>t||_5nX|idjo/t i |ii@|iiA|i|_nd?}t|ito[d@}d/}|i}|iidAdjp|iidBdjo d.}qdC}nt i dD|i?t i dE|it|it oKd|ijo;|iddFjo'dF|_t i dGdH|idI<s RRt operationst constraintst GetDomainRtfederatedcataloguessConfiguring distributed search.tvaluestFederatedCataloguest,t GetRecordst parameterst outputSchemat GetRecordByIdtHarvestt ResourceTypesSetting MaxRecordDefaultt maxrecordstMaxRecordDefaultR<RmRntloadedsProfiles loaded: %s.R)ttabletrecordstfiltertsourcetgeonode(tgeonode_s(GeoNode repository loaded (geonode): %s.RRs'Could not load repository (geonode): %st HHypermap(t hhypermaps,HHypermap repository loaded (hhypermap): %s.s)Could not load repository (hhypermap): %stodc(Rs0OpenDataCatalog repository loaded (geonode): %s.s#Could not load repository (odc): %st sqlalchemy(R)tdatabaseslocal.app_rootsRepository loaded (local): %s.s%Could not load repository (local): %siisthe document is not validsdocument not well-formedtInvalidParameterValuesHTTP Headers: %s.sParsed request parameters: %sRs-OpenSearch mode detected; processing request.shttp://www.w3.org/2005/Atomt outputschemaRs3.0.0R s2Turning on default csw30:Capabilities for base URLtCSWtGetCapabilitiesR9t HTTP_ACCEPTs%application/opensearchdescription+xmltMissingParameterValuesMissing keyword: %ssCInvalid value for service: %s. Value MUST be CSWt invalid_values;Invalid value for version: %s. Value MUST be 2.0.2 or 3.0.0tVersionNegotiationFailedsKInvalid parameter value in acceptversions: %s. Value MUST be 2.0.2 or 3.0.0t TransactiontOperationNotSupporteds%s operations are not supportedsInvalid value for request: %stresponsehandlerNt requestidtDescribeRecordttargettGetRepositoryItemsInvalid request parameter: %ss'SRU mode detected; processing response.s.OpenSearch mode detected; processing response.s+OAI-PMH mode detected; processing response.R(sversionR(RR(YRt normalize_kvpR4RCR9tfindRFR\R5RZR[R trequest_sru2cswRGRHtoaiargsRRRDRBR/REt _gen_managerRsRdt gen_domainsR R]RWRbtappendR>Rrtpprofilet load_profilesR,RSRUtProfileR<tkeysRt extend_coreRRJR0t pycsw.plugins.repository.geonodeRtGeoNodeRepositoryR)tdbtypeRPRQRRt"pycsw.plugins.repository.hhypermapRtHHypermapRepositorytpycsw.plugins.repository.odcRtOpenDataCatalogRepositoryR?t pycsw.coret RepositoryR-Rwtparse_postdataRR tget_version_integert threadingR_R7tuuidtuuid4tgetcapabilitiestdescriberecordt getdomaintThreadt getrecordststartt_write_acknowledgementt getrecordbyidtgetrepositoryitemt transactiontharvesttresponse_csw2sruRtresponse_csw2opensearchR(&Rttwritert write_headerst version_202taccept_version_202RstopsRtfedcattkeytvaluetget_records_paramstget_records_by_id_paramstharvest_paramstprofttmpt repo_filterRRRRR)terrortlocatorRtcodet http_acceptt basic_optionsR9town_version_integerRzt kvp_versiontkvp_version_integertverst vers_integerRt request_idR((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyR!s $   $   "         $                     $  '&                        !        cCs |iiS(s Handle GetCapabilities request (RBR(Rt((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyRzscCs |iiS(s Handle DescribeRecord request (RBR(Rt((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyR~scCs |iiS(s Handle GetDomain request (RBR(Rt((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyRscCs |iiS(s Handle GetRecords request (RBR(Rt((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyRscCs|ii|S(s Handle GetRecordById request (RBR(Rttraw((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyRscCs |iiS(s" Handle GetRepositoryItem request (RBR(Rt((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyRscCs |iiS(s Handle Transaction request (RBR(Rt((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyRscCs |iiS(s Handle Harvest request (RBR(Rt((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyRscCsd}d}tidt|do|io|intidjo ti|id|i i nti |id|i dd}t |itofd |ijoV|id d joB|id |_d d kl}|i||i i|i }nNd |ijo|id |_n |i|_d |i}d|i i}t |ito|ii|_nd|||fi|i}tid|i i|itid||i i|i|gS(s Generate response RsWriting response.R8s3.5.0tkeep_ns_prefixesR$Rtunicodet outputformatsapplication/jsoni(tfmt_jsons4 s u%s%s%ssResponse code: %ss Response: %s(RZR[RR8t_gen_soap_wrapperRt __version__tcleanup_namespacesRRR/RttostringR$RFR4RGt contenttypetpycsw.core.formatsRtxml2jsonRsR"RRwtbytestdecodeR^tresponse_codesR;(RttxmldecltappinfoRRRts((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyRs>   #     cCstidtitid|iid|ii}tid|ii}d|iid|iidf|i|  #) cCs|iidddjotdn|id}|iidd pB|iiddo@ti||iiddid otd|nd S( s& Verify that transactions are allowed R=R4R%sCSW-T interface is disabledt REMOTE_ADDRt allowed_ipsRs4CSW-T operations not allowed for this IP address: %sN(R RWt RuntimeErrorR-R]R tipaddress_in_whitelistRb(Rtt ipaddress((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyt _test_manager.s  #cCstid|titt|i|dj okxR|iD]D}y|i|||d}WqJ|i|||}qJXqJWtid||SdS(s; Transform CQL query's properties to underlying DB columns sRaw CQL text = %s.tdbcolsInterpolated CQL text = %s.N(RZR[R\RRR0Rg(RttcqlR*R((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyt_cql_update_queryables_mappings=s  c Cs,|iddj otid|idt|id}|idjoddk}tidd}|iidd o|ii dd }nd |id |f}y\tid |i |}|i |ii d d|i ||i tidWq$tj o }tidt|q$Xq(|idjoddk}tidytid|i|i} |idj o| i|i|in| id|i dt|| i tidWq$tj o }tidt|q$Xq(ndS(s Process response handler RsProcessing responsehandler %s.tmailtoiNsEmail detected.t localhostRt smtp_hostsSubject: pycsw %s results %sR9sSending email.s metadata:maint contact_emailsEmail sent successfully.sError processing email: %s.tftps FTP detected.sSending to FTP server.sSTOR %sisFTP sent successfully.sError processing FTP: %s.(R4R0RZR[RRtsmtplibR R]RWtSMTPtsendmailRStquitRPR\tftplibtFTPthostnametusernametlogintpasswordt storbinaryR( RttxmltuprhRJRGtbodytmsgRRNRI((s@/local/public/lgc/web/api.rvdata.us/htdocs/pycsw/pycsw/server.pyt_process_responsehandlerJsF          ! cCs:t}x*|iD]\}}|||i"s