Commit f115086fd175df4374b7bd254f4ba90dfc8ca0f8

Authored by Myriam Bouchemit
2 parents fa328fd7 a5ec00c9

Merge branch 'master' of https://gitlab.irap.omp.eu/CDPP/DDServer

Showing 45 changed files with 1855 additions and 40 deletions   Show diff stats
CMakeLists.txt
... ... @@ -68,23 +68,25 @@ add_subdirectory(src/DECODERS/nc2nc)
68 68 add_subdirectory(src/DECODERS/themis)
69 69 add_subdirectory(src/DATA/TOOLS)
70 70 add_subdirectory(src/DDSERVICES/TOOLS)
  71 +add_subdirectory(src/DDADMIN/TOOLS)
71 72 add_subdirectory(tests)
72 73  
73 74 install(FILES "scripts/StartServer" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
74 75 install(FILES "scripts/DDServer.env" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
75   -install(FILES "scripts/AddLocalVI.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
76   -install(FILES "scripts/UpdateInfoVI.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
77   -install(FILES "scripts/RemoveVI.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
78   -install(FILES "scripts/MakeRemoteProxy.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  76 +file(GLOB scripts "scripts/*.sh")
  77 +install(FILES ${scripts} DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
79 78  
80 79 install(DIRECTORY "src/CALLEXT/" DESTINATION bin/CALLEXT)
81 80 install(DIRECTORY "src/DATA/MANAGER/" DESTINATION bin/DATAMANAGER)
82 81 install(DIRECTORY "src/DATA/TEMPLATES/" DESTINATION bin)
83 82 install(DIRECTORY "src/REMOTEDATA/" DESTINATION bin/REMOTEDATA)
  83 +install(DIRECTORY "src/DDADMIN/MANAGER/" DESTINATION bin/USERMANAGER)
84 84 install(DIRECTORY "src/DDSERVICES/SOAP/" DESTINATION DDService)
85 85 install(DIRECTORY "src/DDSERVICES/REST/" DESTINATION DDService)
86 86  
87 87 install(FILES "src/DECODERS/cdf2nc/cdf_to_netcdf_mapping.dat" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
88   -install(FILES "src/REMOTEDATA/Bases.xml" DESTINATION ${DDBASEINFO} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
  88 +
  89 +file(GLOB config_files "info/REMOTEDATA/*.xml")
  90 +install(FILES ${config_files} DESTINATION ${DDBASEINFO} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
89 91  
90 92 SET(CMAKE_VERBOSE_MAKEFILE ON)
... ...
CMakeLists.txt.All 0 โ†’ 100644
... ... @@ -0,0 +1,92 @@
  1 +cmake_minimum_required(VERSION 2.6)
  2 +
  3 +PROJECT(DDServer)
  4 +
  5 +add_definitions( -DLINUX )
  6 +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}/bin/)
  7 +set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}/lib/)
  8 +
  9 +if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  10 + #64 bits
  11 + MESSAGE( STATUS "64 bits" )
  12 + set(CMAKE_C_FLAGS_DEBUG "-ggdb -DLINUX -Dlinux -m64 -march=core2 -fPIC -D_REENTRANT -pthread")
  13 + set(CMAKE_C_FLAGS_RELEASE "-DLINUX -Dlinux -m64 -march=core2 -fPIC -D_REENTRANT -pthread")
  14 + set(USRLIB_DIR "/usr/lib64/:/usr/local/lib64/")
  15 +else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  16 + #32 bits
  17 + MESSAGE( STATUS "32 bits" )
  18 + set(CMAKE_C_FLAGS_DEBUG "-ggdb -DLINUX -march=i686 -fPIC -Dlinux -D_REENTRANT -malign-double -pthread")
  19 + set(CMAKE_C_FLAGS_DEBUG "-DLINUX -march=i686 -fPIC -Dlinux -D_REENTRANT -malign-double -pthread")
  20 + set(USRLIB_DIR "/usr/lib/:/usr/local/lib/")
  21 +endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  22 +
  23 +set (USERLOCAL_ROOT "/usr/local/lib/")
  24 +if (EXISTS "$ENV{USERLOCAL_ROOT}")
  25 + set(USERLOCAL_ROOT "$ENV{USERLOCAL_ROOT}")
  26 + message("USERLOCAL_ROOT forced to ${USERLOCAL_ROOT}")
  27 +endif()
  28 +
  29 +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
  30 +
  31 +find_package( Threads REQUIRED )
  32 +find_package( CRYPT REQUIRED )
  33 +find_package( NetCDF REQUIRED )
  34 +find_package( DDClient REQUIRED )
  35 +find_package( CDF REQUIRED )
  36 +find_package( LibXML2 REQUIRED )
  37 +
  38 +get_filename_component(NETCDFLIB_DIR ${NETCDFLIBRARIES} PATH)
  39 +get_filename_component(DDCLIENTLIB_DIR ${DDCLIENTLIBRARIES} PATH)
  40 +set(DDSERVICE_URL $ENV{DDSERVICE_URL})
  41 +set(DDRESPATH $ENV{DDRESPATH})
  42 +set(DDBASEDATA "$ENV{DDBASEPATH}/DATA")
  43 +set(DDBASEINFO "$ENV{DDBASEPATH}/INFO")
  44 +set(PROXY_HOST $ENV{PROXY_HOST})
  45 +set(PROXY_USERPWD $ENV{PROXY_USERPWD})
  46 +
  47 +configure_file (
  48 + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env.in"
  49 + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env"
  50 +)
  51 +
  52 +configure_file (
  53 + "${CMAKE_SOURCE_DIR}/src/DDSERVICES/SOAP/DDserverWeb_ini.php.in"
  54 + "${CMAKE_SOURCE_DIR}/src/DDSERVICES/SOAP/DDserverWeb_ini.php"
  55 +)
  56 +
  57 +configure_file (
  58 + "${CMAKE_SOURCE_DIR}/src/DDSERVICES/SOAP/dd.wsdl.in"
  59 + "${CMAKE_SOURCE_DIR}/src/DDSERVICES/SOAP/dd.wsdl"
  60 +)
  61 +
  62 +MESSAGE( STATUS "Build DD_Server Project" )
  63 +add_subdirectory(src/SERVER)
  64 +add_subdirectory(src/DECODERS/ascii2nc)
  65 +add_subdirectory(src/DECODERS/cdf2nc)
  66 +add_subdirectory(src/DECODERS/cdfnew2nc)
  67 +add_subdirectory(src/DECODERS/nc2nc)
  68 +add_subdirectory(src/DECODERS/themis)
  69 +add_subdirectory(src/DATA/TOOLS)
  70 +add_subdirectory(src/DDSERVICES/TOOLS)
  71 +add_subdirectory(src/DDADMIN/TOOLS)
  72 +add_subdirectory(tests)
  73 +
  74 +install(FILES "scripts/StartServer" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  75 +install(FILES "scripts/DDServer.env" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  76 +file(GLOB scripts "scripts/*.sh")
  77 +install(FILES ${scripts} DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  78 +
  79 +install(DIRECTORY "src/CALLEXT/" DESTINATION bin/CALLEXT)
  80 +install(DIRECTORY "src/DATA/MANAGER/" DESTINATION bin/DATAMANAGER)
  81 +install(DIRECTORY "src/DATA/TEMPLATES/" DESTINATION bin)
  82 +install(DIRECTORY "src/REMOTEDATA/" DESTINATION bin/REMOTEDATA)
  83 +install(DIRECTORY "src/DDADMIN/MANAGER/" DESTINATION bin/USERMANAGER)
  84 +install(DIRECTORY "src/DDSERVICES/SOAP/" DESTINATION DDService)
  85 +install(DIRECTORY "src/DDSERVICES/REST/" DESTINATION DDService)
  86 +
  87 +install(FILES "src/DECODERS/cdf2nc/cdf_to_netcdf_mapping.dat" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
  88 +
  89 +file(GLOB config_files "info/REMOTEDATA/*.xml")
  90 +install(FILES ${config_files} DESTINATION ${DDBASEINFO} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
  91 +
  92 +SET(CMAKE_VERBOSE_MAKEFILE ON)
... ...
CMakeLists.txt.DDServerOnly 0 โ†’ 100644
... ... @@ -0,0 +1,56 @@
  1 +cmake_minimum_required(VERSION 2.6)
  2 +
  3 +PROJECT(DDServer)
  4 +
  5 +add_definitions( -DLINUX )
  6 +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}/bin/)
  7 +set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}/lib/)
  8 +
  9 +if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  10 + #64 bits
  11 + MESSAGE( STATUS "64 bits" )
  12 + set(CMAKE_C_FLAGS_DEBUG "-ggdb -DLINUX -Dlinux -m64 -march=core2 -fPIC -D_REENTRANT -pthread")
  13 + set(CMAKE_C_FLAGS_RELEASE "-DLINUX -Dlinux -m64 -march=core2 -fPIC -D_REENTRANT -pthread")
  14 + set(USRLIB_DIR "/usr/lib64/:/usr/local/lib64/")
  15 +else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  16 + #32 bits
  17 + MESSAGE( STATUS "32 bits" )
  18 + set(CMAKE_C_FLAGS_DEBUG "-ggdb -DLINUX -march=i686 -fPIC -Dlinux -D_REENTRANT -malign-double -pthread")
  19 + set(CMAKE_C_FLAGS_DEBUG "-DLINUX -march=i686 -fPIC -Dlinux -D_REENTRANT -malign-double -pthread")
  20 + set(USRLIB_DIR "/usr/lib/:/usr/local/lib/")
  21 +endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  22 +
  23 +set (USERLOCAL_ROOT "/usr/local/lib/")
  24 +if (EXISTS "$ENV{USERLOCAL_ROOT}")
  25 + set(USERLOCAL_ROOT "$ENV{USERLOCAL_ROOT}")
  26 + message("USERLOCAL_ROOT forced to ${USERLOCAL_ROOT}")
  27 +endif()
  28 +
  29 +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
  30 +
  31 +find_package( Threads REQUIRED )
  32 +find_package( CRYPT REQUIRED )
  33 +find_package( NetCDF REQUIRED )
  34 +find_package( DDClient REQUIRED )
  35 +
  36 +get_filename_component(NETCDFLIB_DIR ${NETCDFLIBRARIES} PATH)
  37 +get_filename_component(DDCLIENTLIB_DIR ${DDCLIENTLIBRARIES} PATH)
  38 +set(DDRESPATH $ENV{DDRESPATH})
  39 +set(DDBASEDATA "$ENV{DDBASEPATH}/DATA")
  40 +set(DDBASEINFO "$ENV{DDBASEPATH}/INFO")
  41 +set(PROXY_HOST $ENV{PROXY_HOST})
  42 +set(PROXY_USERPWD $ENV{PROXY_USERPWD})
  43 +
  44 +configure_file (
  45 + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env.in"
  46 + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env"
  47 +)
  48 +
  49 +MESSAGE( STATUS "Build DD_Server ONLY from DD Server Project" )
  50 +add_subdirectory(src/SERVER)
  51 +
  52 +install(FILES "scripts/StartServer" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  53 +install(FILES "scripts/DDServer.env" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  54 +
  55 +
  56 +SET(CMAKE_VERBOSE_MAKEFILE ON)
... ...
CMakeLists.txt.ServicesOnly 0 โ†’ 100644
... ... @@ -0,0 +1,92 @@
  1 +cmake_minimum_required(VERSION 2.6)
  2 +
  3 +PROJECT(DDServer)
  4 +
  5 +add_definitions( -DLINUX )
  6 +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}/bin/)
  7 +set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}/lib/)
  8 +
  9 +if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  10 + #64 bits
  11 + MESSAGE( STATUS "64 bits" )
  12 + set(CMAKE_C_FLAGS_DEBUG "-ggdb -DLINUX -Dlinux -m64 -march=core2 -fPIC -D_REENTRANT -pthread")
  13 + set(CMAKE_C_FLAGS_RELEASE "-DLINUX -Dlinux -m64 -march=core2 -fPIC -D_REENTRANT -pthread")
  14 + set(USRLIB_DIR "/usr/lib64/:/usr/local/lib64/")
  15 +else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  16 + #32 bits
  17 + MESSAGE( STATUS "32 bits" )
  18 + set(CMAKE_C_FLAGS_DEBUG "-ggdb -DLINUX -march=i686 -fPIC -Dlinux -D_REENTRANT -malign-double -pthread")
  19 + set(CMAKE_C_FLAGS_DEBUG "-DLINUX -march=i686 -fPIC -Dlinux -D_REENTRANT -malign-double -pthread")
  20 + set(USRLIB_DIR "/usr/lib/:/usr/local/lib/")
  21 +endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  22 +
  23 +set (USERLOCAL_ROOT "/usr/local/lib/")
  24 +if (EXISTS "$ENV{USERLOCAL_ROOT}")
  25 + set(USERLOCAL_ROOT "$ENV{USERLOCAL_ROOT}")
  26 + message("USERLOCAL_ROOT forced to ${USERLOCAL_ROOT}")
  27 +endif()
  28 +
  29 +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
  30 +
  31 +find_package( Threads REQUIRED )
  32 +find_package( CRYPT REQUIRED )
  33 +find_package( NetCDF REQUIRED )
  34 +find_package( DDClient REQUIRED )
  35 +find_package( CDF REQUIRED )
  36 +find_package( LibXML2 REQUIRED )
  37 +
  38 +get_filename_component(NETCDFLIB_DIR ${NETCDFLIBRARIES} PATH)
  39 +get_filename_component(DDCLIENTLIB_DIR ${DDCLIENTLIBRARIES} PATH)
  40 +set(DDSERVICE_URL $ENV{DDSERVICE_URL})
  41 +set(DDRESPATH $ENV{DDRESPATH})
  42 +set(DDBASEDATA "$ENV{DDBASEPATH}/DATA")
  43 +set(DDBASEINFO "$ENV{DDBASEPATH}/INFO")
  44 +set(PROXY_HOST $ENV{PROXY_HOST})
  45 +set(PROXY_USERPWD $ENV{PROXY_USERPWD})
  46 +
  47 +configure_file (
  48 + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env.in"
  49 + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env"
  50 +)
  51 +
  52 +configure_file (
  53 + "${CMAKE_SOURCE_DIR}/src/DDSERVICES/SOAP/DDserverWeb_ini.php.in"
  54 + "${CMAKE_SOURCE_DIR}/src/DDSERVICES/SOAP/DDserverWeb_ini.php"
  55 +)
  56 +
  57 +configure_file (
  58 + "${CMAKE_SOURCE_DIR}/src/DDSERVICES/SOAP/dd.wsdl.in"
  59 + "${CMAKE_SOURCE_DIR}/src/DDSERVICES/SOAP/dd.wsdl"
  60 +)
  61 +
  62 +MESSAGE( STATUS "Build DD_Server Project" )
  63 +# add_subdirectory(src/SERVER)
  64 +# add_subdirectory(src/DECODERS/ascii2nc)
  65 +# add_subdirectory(src/DECODERS/cdf2nc)
  66 +# add_subdirectory(src/DECODERS/cdfnew2nc)
  67 +# add_subdirectory(src/DECODERS/nc2nc)
  68 +# add_subdirectory(src/DECODERS/themis)
  69 +# add_subdirectory(src/DATA/TOOLS)
  70 +# add_subdirectory(src/DDSERVICES/TOOLS)
  71 +# add_subdirectory(src/DDADMIN/TOOLS)
  72 +# add_subdirectory(tests)
  73 +#
  74 +# install(FILES "scripts/StartServer" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  75 +# install(FILES "scripts/DDServer.env" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  76 +# file(GLOB scripts "scripts/*.sh")
  77 +# install(FILES ${scripts} DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
  78 +#
  79 +# install(DIRECTORY "src/CALLEXT/" DESTINATION bin/CALLEXT)
  80 +# install(DIRECTORY "src/DATA/MANAGER/" DESTINATION bin/DATAMANAGER)
  81 +# install(DIRECTORY "src/DATA/TEMPLATES/" DESTINATION bin)
  82 +# install(DIRECTORY "src/REMOTEDATA/" DESTINATION bin/REMOTEDATA)
  83 +# install(DIRECTORY "src/DDADMIN/MANAGER/" DESTINATION bin/USERMANAGER)
  84 +install(DIRECTORY "src/DDSERVICES/SOAP/" DESTINATION DDService)
  85 +install(DIRECTORY "src/DDSERVICES/REST/" DESTINATION DDService)
  86 +
  87 +# install(FILES "src/DECODERS/cdf2nc/cdf_to_netcdf_mapping.dat" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
  88 +#
  89 +# file(GLOB config_files "info/REMOTEDATA/*.xml")
  90 +# install(FILES ${config_files} DESTINATION ${DDBASEINFO} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
  91 +
  92 +SET(CMAKE_VERBOSE_MAKEFILE ON)
... ...
compilAndInstall.sh
... ... @@ -5,7 +5,7 @@ usage="
5 5 \n
6 6 \n Usage : $0 -d <Destination path> -u <DDService URL> -r <DD.res directory path> -b <DDBASE path> [-l <User local directory. By default, it's /usr/local>] [-p <Proxy host:port>] [-a <Proxy user name:password for authentication>]
7 7 \n
8   - \n $0 -d /opt/tools/DDServer -u http://amdadev.fr/DDService -r /var/amda-data/ -b /var/amda-data/DDBASE -l /opt/local -h 'myproxy.fr:9090' -p 'username:userpwd'
  8 + \n $0 -d /opt/tools/DDServer -u http://amdadev.fr/DDService -r /var/amda-data/ -b /var/amda-data/DDBASE -l /opt/local -p 'myproxy.fr:9090' -a 'username:userpwd'
9 9 \n
10 10 \n
11 11 \n ###"
... ...
info/DDADMIN/AddUser.json 0 โ†’ 100644
... ... @@ -0,0 +1,10 @@
  1 +{ "action" : "add",
  2 + "pwd_hashed" : false,
  3 + "news" : true,
  4 + "sendEmail" : false,
  5 + "login" : "test",
  6 + "pwd" : "testpass",
  7 + "first_name" : "Huang",
  8 + "last_name" : "Shiyong",
  9 + "email" : "ebudnik@irap.omp.eu",
  10 + "groups" : "" }
... ...
info/DDADMIN/AddVi.json 0 โ†’ 100644
... ... @@ -0,0 +1,9 @@
  1 +{ "brief" : "jedi",
  2 + "ViId" : "juno_jedi_i180",
  3 + "mission" : "JUNO",
  4 + "instrument" : "JEDI",
  5 + "mission_dir" : "JUNO/",
  6 + "location" : "JEDI/I_180",
  7 + "min_sampling" : "2",
  8 + "max_sampling" : "3" }
  9 +
0 10 \ No newline at end of file
... ...
src/REMOTEDATA/Bases.xml renamed to info/REMOTEDATA/Bases.xml
1 1 <?xml version="1.0"?>
2 2 <dataRoot xml:id="myRemoteData-treeRootNode">
3   - <dataCenter name="CDAWeb" desc="Coordinated_Data_Analysis" id1="CDAWEB" xml:id="CDAWEB"/>
  3 + <dataCenter name="CDAWeb" desc="Coordinated_Data_Analysis" addable="true" id1="CDAWEB" xml:id="CDAWEB"/>
4 4 <!--<dataCenter name="MAPSKP@IRAP" desc="Cassini MAPS_Key_Parameters" group="" default="yes" id1="MAPSKP" xml:id="MAPSKP"/>-->
5 5 <dataCenter name="THEMIS" desc="Mirror_IRAP_Data_Base" default="yes" id1="THEMIS" xml:id="THEMIS"/>
6 6 </dataRoot>
... ...
src/REMOTEDATA/ThemisTreeTemplate.xml renamed to info/REMOTEDATA/ThemisTreeTemplate.xml
info/REMOTEDATA/mapCDAWEB.xml 0 โ†’ 100644
... ... @@ -0,0 +1,49 @@
  1 +<?xml version="1.0"?>
  2 +<ALIASES>
  3 + <observatory xml:id='AC'>ACE</observatory>
  4 + <observatory xml:id='EQ'>EQUATOR-S</observatory>
  5 + <observatory xml:id="IMP-8">IMP8</observatory>
  6 + <observatory xml:id="I8">IMP8</observatory>
  7 + <observatory xml:id="G0">GOES_10</observatory>
  8 + <observatory xml:id="G10">GOES_10</observatory>
  9 + <observatory xml:id="G11">GOES_11</observatory>
  10 + <observatory xml:id="G12">GOES_12</observatory>
  11 + <observatory xml:id="CT">CL</observatory>
  12 + <observatory xml:id="PO">POLAR</observatory>
  13 + <observatory xml:id="IM">IMAGE</observatory>
  14 + <observatory xml:id="AHEAD">STA</observatory>
  15 + <observatory xml:id="BEHIND">STB</observatory>
  16 + <observatory xml:id="STEREOA">STA</observatory>
  17 + <observatory xml:id="STEREOB">STB</observatory>
  18 + <observatory xml:id="CRRES_SATELLITE">CRRES</observatory>
  19 + <observatory xml:id="RBSP-A-RBSPICE">RBSP-A</observatory>
  20 + <observatory xml:id="RBSP-B-RBSPICE">RBSP-B</observatory>
  21 + <observatory xml:id="RBSPA">RBSP-A</observatory>
  22 + <observatory xml:id="RBSPB">RBSP-B</observatory>
  23 + <instrument xml:id="SWI">SWICS</instrument>
  24 + <instrument xml:id="ULE">ULEIS</instrument>
  25 + <instrument xml:id='SEP'>SEPICA</instrument>
  26 + <instrument xml:id="FGM_SPIN">FGM</instrument>
  27 + <instrument xml:id="ECT-HOPE-SCI-L2">ECT</instrument>
  28 + <instrument xml:id="ECT-REPT-SCI-L2">ECT</instrument>
  29 + <instrument xml:id="ECT-MAGEIS-L2">ECT</instrument>
  30 + <instrument xml:id="MAGNETOMETER">EMFISIS</instrument>
  31 + <instrument xml:id="EMFISIS-L2">EMFISIS</instrument>
  32 + <instrument xml:id="EMFISIS-L3">EMFISIS</instrument>
  33 + <instrument xml:id="LEV-2">RBSPICE</instrument>
  34 + <instrument xml:id="EFW-L2">EFW</instrument>
  35 + <instrument xml:id="HFR-WAVEFORM">EMFISIS</instrument>
  36 + <instrument xml:id="WFR-WAVEFORM-CONTINUOUS-BURST">EMFISIS</instrument>
  37 + <instrument xml:id="SEPT>STEREO-A IMPACT/SEPT">SEPT</instrument>
  38 + <instrument xml:id="SEPT>STEREO-B IMPACT/SEPT">SEPT</instrument>
  39 + <instrument xml:id="SIT>STEREO-A IMPACT/SIT">SIT</instrument>
  40 + <instrument xml:id="SIT>STEREO-B IMPACT/SIT">SIT</instrument>
  41 + <instrument xml:id="LET>STEREO-A IMPACT/LET">LET</instrument>
  42 + <instrument xml:id="LET>STEREO-B IMPACT/LET">LET</instrument>
  43 + <instrument xml:id="STE>STEREO-A IMPACT/STE">STE</instrument>
  44 + <instrument xml:id="STE>STEREO-B IMPACT/STE">STE</instrument>
  45 + <instrument xml:id="SWEA_DISB>STEREO-A IMPACT/SWEA">SWEA</instrument>
  46 + <instrument xml:id="SWEA_DISB>STEREO-B IMPACT/SWEA">SWEA</instrument>
  47 + <instrument xml:id="SWEA_DIST>STEREO-A IMPACT/SWEA">SWEA</instrument>
  48 + <instrument xml:id="SWEA_DIST>STEREO-B IMPACT/SWEA">SWEA</instrument>
  49 +</ALIASES>
... ...
scripts/AddUser.sh 0 โ†’ 100755
... ... @@ -0,0 +1,21 @@
  1 +#!/bin/sh
  2 +
  3 +if [ $# -eq 0 ]
  4 + then
  5 + echo "json input be defined"
  6 + exit
  7 + fi
  8 +
  9 +while getopts "j:" options; do
  10 + case $options in
  11 + j ) JSON_FILE=`echo $OPTARG`;;
  12 + esac
  13 +done
  14 +
  15 +BASEDIR=$(dirname "$0")
  16 +
  17 +. ${BASEDIR}/DDServer.env
  18 + php ${USERMANAGER}/UserManager.php --json $JSON_FILE
  19 +
  20 +
  21 +
... ...
scripts/AddUserGroups.sh 0 โ†’ 100755
... ... @@ -0,0 +1,16 @@
  1 +#!/bin/sh
  2 +
  3 +if [ $# -le 1 ]
  4 + then
  5 + echo "user and group[s] should be defined"
  6 + exit
  7 + fi
  8 +
  9 +BASEDIR=$(dirname "$0")
  10 +
  11 +. ${BASEDIR}/DDServer.env
  12 +
  13 + php ${USERMANAGER}/UserManager.php "groups" $1 $2
  14 +
  15 +
  16 +
... ...
scripts/CleanRemote.sh 0 โ†’ 100755
... ... @@ -0,0 +1,10 @@
  1 +#!/bin/sh
  2 +
  3 +BASEDIR=$(dirname "$0")
  4 +
  5 +. ${BASEDIR}/DDServer.env
  6 +
  7 +php ${DATAMANAGER}/CleanRemote.php
  8 +
  9 +
  10 +
... ...
scripts/DDServer.env.in
1 1 #!/bin/bash
2 2  
3 3 DDBASE=@DDBASEDATA@
  4 +DDINFO=@DDBASEINFO@
4 5 DDPATH=@DDRESPATH@
5 6 DDLIB=@DDCLIENTLIB_DIR@/
6 7 DDBASEBIN=@CMAKE_INSTALL_PREFIX@/bin
... ... @@ -8,9 +9,12 @@ LD_LIBRARY_PATH=$DDLIB/:@NETCDFLIB_DIR@:@libcdf_LIBRARY_DIR@:@USRLIB_DIR@
8 9 DATAMANAGER=@CMAKE_INSTALL_PREFIX@/bin/DATAMANAGER
9 10 REMOTEDATA=@CMAKE_INSTALL_PREFIX@/bin/REMOTEDATA
10 11 CALLEXT=@CMAKE_INSTALL_PREFIX@/bin/CALLEXT
  12 +USERMANAGER=@CMAKE_INSTALL_PREFIX@/bin/USERMANAGER
11 13 PROXY_HOST="@PROXY_HOST@"
12 14 PROXY_USERPWD="@PROXY_USERPWD@"
13 15  
14   -export DDBASE DDPATH DDBASEBIN DDLIB LD_LIBRARY_PATH
15   -export DATAMANAGER REMOTEDATA CALLEXT
  16 +export DDBASE DDPATH DDBASEBIN DDLIB LD_LIBRARY_PATH DDINFO
  17 +export DATAMANAGER REMOTEDATA CALLEXT USERMANAGER
16 18 export PROXY_HOST PROXY_USERPWD
  19 +export AMDA_USERS_INFO=AMDA_Users_Info.xml
  20 +export AMDA_GROUPS_INFO=AMDA_Users.xml
17 21 \ No newline at end of file
... ...
scripts/DeleteUser.sh 0 โ†’ 100755
... ... @@ -0,0 +1,16 @@
  1 +#!/bin/sh
  2 +
  3 +if [ $# -eq 0 ]
  4 + then
  5 + echo "user should be defined"
  6 + exit
  7 + fi
  8 +
  9 +BASEDIR=$(dirname "$0")
  10 +
  11 +. ${BASEDIR}/DDServer.env
  12 +
  13 + php ${USERMANAGER}/UserManager.php "delete" $1
  14 +
  15 +
  16 +
... ...
scripts/SyncManunjaFromCdpp3.sh 0 โ†’ 100755
... ... @@ -0,0 +1,42 @@
  1 +#!/bin/sh
  2 +
  3 +# run at manunja
  4 +# MISSIONS_LIST example
  5 +# ACE
  6 +# GRD/AE
  7 +
  8 +export DDBASE=/data/DDBASE/DATA
  9 +export remote=cdpp3.irap.omp.eu
  10 +export DDLIB=/home/budnik/AMDANEW/DDLIB/lib
  11 +export DECODERTOOLS=/home/budnik/depotDECODER/TOOLS
  12 +
  13 +MISSIONS=${DDBASE}/../MISSIONS_LIST_CDPP3
  14 +
  15 +if [ -f ${MISSIONS} ]; then
  16 + while read Mission
  17 + do
  18 + # if empty line - continue
  19 + [ -z "$Mission" ] && continue
  20 +
  21 + for Dir in $(find -L $DDBASE/$Mission* -maxdepth 4 -type d -links 2)
  22 + do
  23 +
  24 + remoteDir="${Dir/data/data1}"
  25 + sshpass -p "xxx" rsync -auvr budnik@${remote}:${remoteDir}/*nc.gz ${Dir}
  26 + sshpass -p "xxx" rsync -vu budnik@${remote}:${remoteDir}/*times.nc ${Dir}
  27 + sshpass -p "xxx" rsync -vu budnik@${remote}:${remoteDir}/*info* ${Dir}
  28 + # sshpass -p "xxx" rsync -vu budnik@${remote}:${remoteDir}/Vesrion ${Dir}
  29 + # sshpass -p "xxx" rsync -vu budnik@${remote}:${remoteDir}/*Stop ${Dir}
  30 +
  31 + cd ${Dir}
  32 + ls | xargs chown -R budnik:dd ${Dir}
  33 + ls | xargs chmod -R ug+w ${Dir}
  34 + ./clean
  35 + cd ${DDBASE}/..
  36 +
  37 + php ${DECODERTOOLS}/DataBaseLog/updateDataBaseLog.php ${Dir} budnik fromCDPP3
  38 +
  39 + # echo ${Dir} `date +"%Y-%m-%d"` >> sync.log
  40 + done
  41 + done <${MISSIONS}
  42 + fi
... ...
src/DATA/MANAGER/CleanRemote.php 0 โ†’ 100644
... ... @@ -0,0 +1,21 @@
  1 +<?php
  2 +
  3 +/**
  4 +* @file CleanRemote.php
  5 +* @brief DD Server Tools:
  6 +*/
  7 + if (!function_exists('__autoload'))
  8 + {
  9 + function __autoload($class_name) {
  10 + require_once $class_name . '.php';
  11 + }
  12 + }
  13 +
  14 + putenv("LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH"));
  15 + putenv("PATH=./:".getenv("DDBASEBIN").":/bin:/usr/bin");
  16 + set_include_path("./:".getenv("DATAMANAGER"));
  17 +
  18 + $baseMgr = new DDBaseMgr();
  19 + $baseMgr->cleanRemote();
  20 +
  21 +?>
... ...
src/DATA/MANAGER/DDBaseMgr.php
... ... @@ -290,6 +290,75 @@ class DDBaseMgr
290 290 system("infoLocal2nc ".$this->info_xml." ".$this->info);
291 291 chdir($currDir);
292 292 }
  293 +
  294 + public function cleanRemote($opt = NULL)
  295 + {
  296 + $res_before = disk_free_space(getenv("DDBASE"));
  297 + $Days = 10; // default
  298 + $SecDay = 3600*24;
  299 + $nodata = false;
  300 +
  301 + if (isset($opt)) {
  302 + if ($opt == "NODATA")
  303 + $nodata = true;
  304 + else {
  305 + $Days = is_numeric($opt) ? $opt : 10;
  306 + settype($Days, "int");
  307 + echo "!!!!!!!!!!!!!!!! Days ".$Days.PHP_EOL;
  308 + }
  309 + }
  310 +
  311 + $GlobalDelta = $Days*$SecDay;
  312 +
  313 + $xp = new domxpath($this->DDsysDoc);
  314 + $dataSets = $xp->query("//NAME[attribute::base!='LOCAL']");
  315 +
  316 + for ($i = 0; $i < $dataSets->length; $i++)
  317 + {
  318 + $parent = $dataSets->item($i)->parentNode;
  319 + $location = $parent->getElementsByTagName("LOCATION")->item(0)->nodeValue;
  320 +
  321 + if (!is_dir($location)) {
  322 + $parent->parentNode->removeChild($parent);
  323 + }
  324 + else {
  325 + $time_info = $parent->getElementsByTagName("TIMES")->item(0)->nodeValue;
  326 + chdir($location);
  327 + system("./clean");
  328 + touch($location."/LOCK");
  329 +
  330 + fprintf(STDERR,"In the ".$location."\n");
  331 +
  332 + /* Delete No Data Intervals */
  333 + if ($nodata) {
  334 + system("CleanNoData ".$time_info);
  335 + }
  336 + /* Delete Old Files */
  337 + else {
  338 + foreach (glob("*.gz") as $filename) {
  339 + $info = stat($filename);
  340 + if ((time() - $info['atime']) > $GlobalDelta) {
  341 + //fprintf(STDERR, $filename."\n");
  342 + system("TimesUpdate -d ".$time_info." ".$filename);
  343 + }
  344 + //fprintf(STDERR, date("Y-m-d",$info['atime'])." - ".date("Y-m-d",$info['mtime'])."\n");
  345 + }
  346 + }
  347 +
  348 + system("DDClearTimes ".$time_info);
  349 + unlink($location."/LOCK");
  350 + }
  351 + }
  352 + /*
  353 + $res_after = disk_free_space(getenv("DDBASE"));
  354 + $difference = ($res_after - $res_before)/1024.0;
  355 + $res_after /= 1024.0;
  356 + fprintf(STDERR,"+ Free Space ".$difference." kB\n");
  357 + fprintf(STDERR," Free Space ".$res_after." kB\n");*/
  358 +
  359 + $this->DDsysDoc->save($this->DDsys);
  360 + system("makeDDsys");
  361 + }
293 362 }
294 363 ?>
295 364  
... ...
src/DATA/TOOLS/ClearTimes.c renamed to src/DATA/TOOLS/DDClearTimes.c
src/DDADMIN/MANAGER/UserManager.php 0 โ†’ 100755
... ... @@ -0,0 +1,429 @@
  1 +<?php
  2 +
  3 +class UserManagerClass
  4 +{
  5 + protected $infoXml;
  6 + protected $stderr;
  7 + protected $rootElement;
  8 +
  9 + function __construct($stderr)
  10 + {
  11 + $this->stderr = $stderr;
  12 +
  13 + $this->infoXml = new DomDocument("1.0","UTF-8");
  14 + $this->infoXml->preserveWhiteSpace = false;
  15 + $this->infoXml->formatOutput = true;
  16 +
  17 + }
  18 +
  19 + function GetInfoXmlFilePath()
  20 + {
  21 + return getenv("DDINFO")."/".getenv("AMDA_USERS_INFO");
  22 + }
  23 +
  24 + function GetGroupsXmlFilePath()
  25 + {
  26 + return getenv("DDINFO")."/".getenv("AMDA_GROUPS_INFO");
  27 + }
  28 +
  29 + function LoadInfoXmlFile()
  30 + {
  31 + if (file_exists($this->GetInfoXmlFilePath()))
  32 + {
  33 + $this->infoXml->load($this->GetInfoXmlFilePath());
  34 + $this->rootElement = $this->infoXml->documentElement;
  35 + }
  36 + else
  37 + {
  38 + $this->rootElement = $this->infoXml->createElement("users");
  39 + $this->infoXml->appendChild($this->rootElement);
  40 + }
  41 +
  42 + return 1;
  43 + }
  44 +
  45 + function AddUser($login, $pwd_hash, $first_name, $last_name, $email, $news, $groups)
  46 + {
  47 + if (!$this->LoadInfoXmlFile())
  48 + return 0;
  49 +
  50 + $users = $this->infoXml->getElementsByTagName("user");
  51 +
  52 + //test if login is already used
  53 + for ($i = 0; $i < $users->length; $i++)
  54 + {
  55 + $crtLogin = $users->item($i)->getAttribute("login");
  56 + if ($crtLogin == $login)
  57 + {
  58 + fprintf($this->stderr,"Login already exist on users info file\n");
  59 + return 0;
  60 + }
  61 + }
  62 +
  63 + date_default_timezone_set('UTC');
  64 + $user = $this->infoXml->createElement("user");
  65 + $user->setAttribute("login",$login);
  66 + $user->setAttribute("name",$last_name);
  67 + $user->setAttribute("first_name",$first_name);
  68 + $user->setAttribute("group",$groups);
  69 + $user->setAttribute("email",$email);
  70 + $user->setAttribute("date",date('j/m/y'));
  71 + $user->setAttribute("news",$news);
  72 +
  73 + $this->rootElement->appendChild($user);
  74 +
  75 +
  76 + exec('DDadmin -a '.$login.' '.$pwd_hash,$output,$return);
  77 +
  78 + if ($return != 0)
  79 + {
  80 + fprintf($this->stderr,"DDadmin error : ".$output[0]."\n");
  81 + return 0;
  82 + }
  83 + else
  84 + $this->infoXml->save($this->GetInfoXmlFilePath());
  85 +
  86 + return 1;
  87 + }
  88 +
  89 + function ModifyUserPwd($login, $pwd_hash, $pwd_hash_new)
  90 + {
  91 + exec('DDadmin -m '.$login.' '.$pwd_hash.' '.$pwd_hash_new,$output,$return);
  92 +
  93 + if ($return != 0)
  94 + {
  95 + fprintf($this->stderr,"DDadmin error : ".$output[0]."\n");
  96 + return 0;
  97 + }
  98 +
  99 + return 1;
  100 + }
  101 +
  102 + function ModifyUserGroup($login,$groups)
  103 + {
  104 + if (!$this->LoadInfoXmlFile())
  105 + return 0;
  106 +
  107 + $users = $this->infoXml->getElementsByTagName("user");
  108 +
  109 + for ($i = 0; $i < $users->length; $i++)
  110 + {
  111 + $crtLogin = $users->item($i)->getAttribute("login");
  112 + if ($crtLogin == $login)
  113 + {
  114 + $users->item($i)->setAttribute("group",$groups);
  115 + $this->infoXml->save($this->GetInfoXmlFilePath());
  116 + return 1;
  117 + }
  118 + }
  119 +
  120 + fprintf($this->stderr,"Cannot found user\n");
  121 + return 0;
  122 + }
  123 +
  124 + function ResetUserPwd($login)
  125 + {
  126 + exec('DDadmin -r '.$login,$output,$return);
  127 +
  128 + if ($return != 0)
  129 + {
  130 + fprintf($this->stderr,"DDadmin error : ".$output."\n");
  131 + return 0;
  132 + }
  133 + else
  134 + fprintf($this->stderr,"New password is : ".$output[0]."\n");
  135 +
  136 + return 1;
  137 + }
  138 +
  139 + function DeleteUser($login)
  140 + {
  141 + if (!$this->LoadInfoXmlFile())
  142 + return 0;
  143 +
  144 + $users = $this->infoXml->getElementsByTagName("user");
  145 +
  146 + for ($i = 0; $i < $users->length; $i++)
  147 + {
  148 + $crtLogin = $users->item($i)->getAttribute("login");
  149 + if ($crtLogin == $login)
  150 + {
  151 + $this->rootElement->removeChild($users->item($i));
  152 + break;
  153 + }
  154 + }
  155 +
  156 + exec('DDadmin -d '.$login,$output,$return);
  157 +
  158 + if ($return != 0)
  159 + {
  160 + fprintf($this->stderr,"DDadmin error : ".$output[0]."\n");
  161 + return 0;
  162 + }
  163 +
  164 + $this->infoXml->save($this->GetInfoXmlFilePath());
  165 +
  166 + return 1;
  167 + }
  168 +
  169 + //This function will be deprecated for AMDA-NG
  170 + function GenerateGroupsXmlFile()
  171 + {
  172 + if (!$this->LoadInfoXmlFile())
  173 + return 0;
  174 +
  175 + $users = $this->infoXml->getElementsByTagName("user");
  176 +
  177 + $groupsXml = new DomDocument("1.0","UTF-8");
  178 + $groupsXml->preserveWhiteSpace = false;
  179 + $groupsXml->formatOutput = true;
  180 + $rootGroupsElement = $groupsXml->createElement("AMDA_USERS");
  181 + $groupsXml->appendChild($rootGroupsElement);
  182 +
  183 + for ($i = 0; $i < $users->length; $i++)
  184 + {
  185 + if (strcmp($users->item($i)->getAttribute("group"),"") == 0)
  186 + continue;
  187 + $u = $groupsXml->createElement("user",$users->item($i)->getAttribute("login"));
  188 + $u->setAttribute("group",$users->item($i)->getAttribute("group"));
  189 + $rootGroupsElement->appendChild($u);
  190 + }
  191 +
  192 + $groupsXml->save($this->GetGroupsXmlFilePath());
  193 +
  194 + return 1;
  195 + }
  196 +
  197 + function SendRegistrationMail($login,$pwd,$first_name, $last_name, $email)
  198 + {
  199 + $subject = 'AMDA registration';
  200 +
  201 + $msg = "Dear $first_name $last_name, \r\n\r\n";
  202 + $msg .= "Thanks for your interest in AMDA\r\n\r\n";
  203 + $msg .= "Your login: $login \r\n";
  204 + $msg .= " password: $pwd \r\n\r\n";
  205 + $msg .= "at http://cdpp3.irap.omp.eu \r\n\r\n";
  206 + $msg .= "Please contact us in case of any problems or questions.\r\n\r\n";
  207 + $msg .= "Best regards,\r\n\r\n";
  208 + $msg .= "CDPP-AMDA Team";
  209 +
  210 + $headers = "From: amda@irap.omp.eu " . "\r\n".
  211 + "Reply-To: amda@irap.omp.eu " . "\r\n".
  212 + "Cc: amda@irap.omp.eu" . "\r\n".
  213 + "Content-type: text/plain; charset=utf-8\r\n";
  214 + mail($email, $subject, $msg, $headers);
  215 +
  216 + }
  217 +
  218 + function Check()
  219 + {
  220 + if (!$this->LoadInfoXmlFile())
  221 + return 0;
  222 +
  223 + $users = $this->infoXml->getElementsByTagName("user");
  224 +
  225 + exec('DDadmin -l',$output,$return);
  226 +
  227 + if ($return != 0)
  228 + {
  229 + fprintf($this->stderr,"DDadmin error : ".$output[0]."\n");
  230 + return 0;
  231 + }
  232 +
  233 + $ddAdminUsers = explode(',',$output[0]);
  234 +
  235 + for ($i = 0; $i < $users->length; $i++)
  236 + {
  237 + $found = false;
  238 + for ($j = 0; $j < count($ddAdminUsers); $j++)
  239 + if (strcmp($users->item($i)->getAttribute("login"),$ddAdminUsers[$j]) == 0)
  240 + {
  241 + $found = true;
  242 + break;
  243 + }
  244 + if (!$found)
  245 + fprintf($this->stderr,"User ".$users->item($i)->getAttribute("login")." not found on nc file\n");
  246 + }
  247 +
  248 + for ($i = 0; $i < count($ddAdminUsers); $i++)
  249 + {
  250 + $found = false;
  251 + for ($j = 0; $j < $users->length; $j++)
  252 + if (strcmp($users->item($j)->getAttribute("login"),$ddAdminUsers[$i]) == 0)
  253 + {
  254 + $found = true;
  255 + break;
  256 + }
  257 + if (!$found)
  258 + fprintf($this->stderr,"User ".$ddAdminUsers[$i]." not found on info file\n");
  259 + }
  260 +
  261 + return 1;
  262 + }
  263 +}
  264 +
  265 +//-----------------------------------------------------------------------------------------------------
  266 + //crypt the password with the salt corresponding to the login
  267 + function cryptPwd($login,$pwd)
  268 + {
  269 + exec('DDadmin -s '.$login,$output,$return);
  270 +
  271 + if ($return != 0)
  272 + {
  273 + fprintf($this->stderr,"DDadmin error : ".$output."\n");
  274 + return '';
  275 + }
  276 +
  277 + $salt = $output[0];
  278 +
  279 + return crypt($pwd,$salt);
  280 + }
  281 +
  282 +//----------------------------------------------------------------------------------------------------
  283 + putenv("LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH"));
  284 + putenv("PATH=./:".getenv("DDBASEBIN").":/bin:/usr/bin");
  285 +
  286 + $stderr = fopen("php://stderr","w");
  287 +
  288 + $shortopts = "j:";
  289 + $longopts = array("json:");
  290 + $options = getopt($shortopts, $longopts);
  291 + $json_file = "";
  292 + if (array_key_exists("json",$options)) {
  293 + $json_file = $options["json"];
  294 + }
  295 + else if (array_key_exists("j",$options)) {
  296 + $json_file = $options["j"];
  297 + }
  298 +
  299 + if (!empty($json_file)) {
  300 + if (!file_exists($json_file)) {
  301 + echo "[ERROR] Cannot find json file: ".$json_file.PHP_EOL;
  302 + exit(1);
  303 + }
  304 + $json_string = file_get_contents($json_file);
  305 + $args = json_decode($json_string);
  306 + if (empty($args)) {
  307 + echo "[ERROR] Cannot decode json data from: ".$json_file.PHP_EOL;
  308 + exit(1);
  309 + }
  310 + }
  311 + else {
  312 + $args = new stdClass();
  313 + $args->action = $argv[1];
  314 + switch ($args->action)
  315 + {
  316 + case 'delete' :
  317 + $args->login = $argv[2];
  318 + break;
  319 + case 'groups' :
  320 + $args->login = $argv[2];
  321 + $args->groups = $argv[3];
  322 + break;
  323 + case 'add' :
  324 + $args->login = $argv[6];
  325 + $args->pwd = $argv[7];
  326 + $args->first_name= $argv[8];
  327 + $args->last_name= $argv[9];
  328 + $args->email= $argv[10];
  329 + $args->pwd_hashed = $argv[2];
  330 + $args->news= $argv[3];
  331 + $args->groups= $argv[4];
  332 + $args->sendEmail= $argv[5];
  333 + break;
  334 + default :
  335 + fprintf($stderr,"Not implemented action ".$args->action."\n");
  336 + exit;
  337 + }
  338 + }
  339 +
  340 + if (!isset($args->action))
  341 + {
  342 + fprintf($stderr,"Missing action argument\n");
  343 + exit;
  344 + }
  345 +
  346 + $userManager = new UserManagerClass($stderr);
  347 +
  348 + switch ($args->action)
  349 + {
  350 + case 'add' :
  351 + if (!isset($args->login) || !isset($args->pwd) || !isset($args->first_name) || !isset($args->last_name) ||
  352 + !isset($args->email))
  353 + {
  354 + fprintf($stderr,"Missing argument(s) to add a user\n");
  355 + exit;
  356 + }
  357 +
  358 + if (isset($args->pwd_hashed) && !($args->pwd_hashed))
  359 + $pwd_hash = crypt($args->pwd,chr(rand(97,122)).chr(rand(97,122)));
  360 + else
  361 + $pwd_hash = $args->pwd;
  362 +
  363 + if ($userManager->AddUser($args->login,$pwd_hash,$args->first_name,$args->last_name,$args->email,
  364 + isset($args->news) ? $args->news : 1,
  365 + isset($args->groups) ? $args->groups : ''))
  366 + {
  367 + $userManager->GenerateGroupsXmlFile();
  368 + if (isset($args->sendEmail) && $args->sendEmail)
  369 + $userManager->SendRegistrationMail($args->login,$args->pwd,$args->first_name,$args->last_name,$args->email);
  370 + fprintf($stderr,"User ".$args->login." added\n");
  371 + }
  372 + break;
  373 + case 'modify' :
  374 + if (!isset($args->login) || !isset($args->pwd) || !isset($args->pwd_new))
  375 + {
  376 + fprintf($stderr,"Missing argument(s) to modify the user password\n");
  377 + exit;
  378 + }
  379 +
  380 + if (isset($args->pwd_hashed) && !($args->pwd_hashed))
  381 + $pwd_hash = cryptPwd($args->login,$args->pwd);
  382 + else
  383 + $pwd_hash = $args->pwd;
  384 +
  385 + if (isset($args->pwd_new_hashed) && !($args->pwd_new_hashed))
  386 + $pwd_new_hash = crypt($args->pwd_new,chr(rand(97,122)).chr(rand(97,122)));
  387 + else
  388 + $pwd_new_hash = $args->pwd_new;
  389 +
  390 + if ($userManager->ModifyUserPwd($args->login,$pwd_hash,$pwd_new_hash))
  391 + fprintf($stderr,"Password of".$args->login." modified\n");
  392 + break;
  393 + case 'groups' :
  394 + if (!isset($args->login) || !isset($args->groups))
  395 + {
  396 + fprintf($stderr,"Missing argument(s) to modify the user groups\n");
  397 + exit;
  398 + }
  399 + if ($userManager->ModifyUserGroup($args->login,$args->groups))
  400 + {
  401 + $userManager->GenerateGroupsXmlFile();
  402 + fprintf($stderr,"Groups of ".$args->login." modified\n");
  403 + }
  404 + break;
  405 + case 'reset' :
  406 + if (!isset($args->login))
  407 + {
  408 + fprintf($stderr,"Missing argument(s) to reset the user password\n");
  409 + exit;
  410 + }
  411 + $userManager->ResetUserPwd($args->login);
  412 + break;
  413 + case 'delete' :
  414 + if (!isset($args->login))
  415 + {
  416 + fprintf($stderr,"Missing argument(s) to delete user\n");
  417 + exit;
  418 + }
  419 + if ($userManager->DeleteUser($args->login))
  420 + {
  421 + $userManager->GenerateGroupsXmlFile();
  422 + fprintf($stderr,"User ".$args->login." deleted\n");
  423 + }
  424 + break;
  425 + case 'check' :
  426 + $userManager->Check();
  427 + break;
  428 + }
  429 +?>
... ...
src/DDADMIN/TOOLS/CMakeLists.txt 0 โ†’ 100644
... ... @@ -0,0 +1,25 @@
  1 +
  2 +PROJECT(DDadmin)
  3 +
  4 +include_directories(
  5 + ${DDCLIENTINCLUDE_DIR}
  6 + ${NETCDFINCLUDE_DIR}
  7 +)
  8 +
  9 +#Configuration de l'exรฉcutable
  10 +file(
  11 + GLOB_RECURSE
  12 + source_files
  13 + ./*
  14 +)
  15 +
  16 +ADD_EXECUTABLE (DDadmin ${source_files} )
  17 +
  18 +target_link_libraries(
  19 + DDadmin
  20 + ${CRYPT_LIBRARY}
  21 + ${DDCLIENTLIBRARY}
  22 + ${NETCDFLIBRARY}
  23 +)
  24 +
  25 +install (TARGETS DDadmin DESTINATION bin)
... ...
src/DDADMIN/DDadmin.c renamed to src/DDADMIN/TOOLS/DDadmin.c
... ... @@ -330,7 +330,7 @@ int GetFileInfo(t_UserFileInfo *fileInfo)
330 330 {
331 331 int status;
332 332  
333   - if (((status = nc_inq_unlimdim(fileInfo->ncID, (size_t *)&fileInfo->UserID)) != NC_NOERR) ||
  333 + if (((status = nc_inq_unlimdim(fileInfo->ncID, (int *)&fileInfo->UserID)) != NC_NOERR) ||
334 334 ((status = nc_inq_dimlen(fileInfo->ncID, fileInfo->UserID, (size_t *)&fileInfo->MaxRecords)) != NC_NOERR) ||
335 335 ((status = nc_inq_dimid(fileInfo->ncID, NC_USER_LEN_NAME, &fileInfo->UserLenID)) != NC_NOERR) ||
336 336 ((status = nc_inq_dimid(fileInfo->ncID, NC_PWD_LEN_NAME, &fileInfo->PwdLenID)) != NC_NOERR) ||
... ...
src/DDSERVICES/HAPI/.htaccess 0 โ†’ 100644
... ... @@ -0,0 +1,8 @@
  1 +Options -MultiViews +FollowSymLinks
  2 +RewriteEngine on
  3 +
  4 +RewriteBase /~budnik/hapi/
  5 +#remove the need for .php extention
  6 +RewriteCond %{REQUEST_FILENAME} !-d
  7 +RewriteCond %{REQUEST_FILENAME}\.php -f
  8 +RewriteRule ^(.*)$ $1.php
... ...
src/DDSERVICES/HAPI/AMDA_HAPI.list 0 โ†’ 100644
... ... @@ -0,0 +1,3 @@
  1 +ace-imf-all
  2 +tao-mars-sw
  3 +tao-venus-sw
... ...
src/DDSERVICES/HAPI/capabilities.php 0 โ†’ 100644
... ... @@ -0,0 +1,13 @@
  1 +<?php
  2 +
  3 + $response = array();
  4 + $response["HAPI"] = "2.0";
  5 + $response["status"] = array("code" => 1200, "msg" => "OK");
  6 + $response["outputFormats"] = array("csv");
  7 +
  8 + header('Content-Type: application/json');
  9 + header("Access-Control-Allow-Origin: *");
  10 + header("Access-Control-Allow-Methods: GET");
  11 +
  12 + exit(json_encode($response));
  13 +?>
... ...
src/DDSERVICES/HAPI/catalog.php 0 โ†’ 100644
... ... @@ -0,0 +1,21 @@
  1 +<?php
  2 +
  3 + $response = array();
  4 + $response["HAPI"] = "2.0";
  5 + $response["status"] = array("code" => 1200, "msg" => "OK");
  6 +
  7 + $catalog = array();
  8 + $datasets = file("AMDA_HAPI.list");
  9 +
  10 + foreach ($datasets as $dataset) {
  11 + $catalog[] = array("id" => str_replace("\n","",$dataset));
  12 + }
  13 +
  14 + $response["catalog"] = $catalog;
  15 +
  16 + header('Content-Type: application/json');
  17 + header("Access-Control-Allow-Origin: *");
  18 + header("Access-Control-Allow-Methods: GET");
  19 +
  20 + exit(json_encode($response));
  21 +?>
... ...
src/DDSERVICES/HAPI/data.php 0 โ†’ 100644
... ... @@ -0,0 +1,83 @@
  1 +<?php
  2 +
  3 + function rglob($pattern, $flags = 0) {
  4 + $files = glob($pattern, $flags);
  5 + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
  6 + $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
  7 + }
  8 + return $files;
  9 + }
  10 +
  11 + function disable_ob() {
  12 + // Turn off output buffering
  13 + ini_set('output_buffering', 'off');
  14 + // Turn off PHP output compression
  15 + ini_set('zlib.output_compression', false);
  16 + // Implicitly flush the buffer(s)
  17 + ini_set('implicit_flush', true);
  18 + ob_implicit_flush(true);
  19 + // Clear, and turn off output buffering
  20 + while (ob_get_level() > 0) {
  21 + // Get the curent level
  22 + $level = ob_get_level();
  23 + // End the buffering
  24 + ob_end_clean();
  25 + // If the current level has not changed, abort
  26 + if (ob_get_level() == $level) break;
  27 + }
  28 + // Disable apache output buffering/compression
  29 + if (function_exists('apache_setenv')) {
  30 + apache_setenv('no-gzip', '1');
  31 + apache_setenv('dont-vary', '1');
  32 + }
  33 + }
  34 +
  35 + $METADATA_DIR = "/home/budnik/public_html/hapi/PARAM_DEF";
  36 + $response = array();
  37 + $response["HAPI"] = "2.0";
  38 +
  39 + if (!$_GET["id"]) {
  40 + header("HTTP/1.1 404 NO SUCH ID");
  41 + $response["status"] = 1406;
  42 + $response["msg"] = "NO SUCH ID !!!";
  43 +
  44 + header('Content-Type: application/json');
  45 +
  46 + exit(json_encode($response));
  47 + }
  48 +
  49 + header('Content-Type: text/csv');
  50 +
  51 + $id = $_GET["id"];
  52 + $tmin = $_GET["time_min"];
  53 + $tmax = $_GET["time_max"];
  54 +
  55 + if ($_GET["parameters"]) {
  56 + $params = $_GET["parameters"];
  57 + }
  58 + else {
  59 + $params = null;
  60 + }
  61 +
  62 + $ddId = strtr($id, "-", "_");
  63 +
  64 + if ($params) {
  65 + $cmd = "python -u reader.py -tmin $tmin -tmax $tmax -id $ddId -param $params";
  66 + }
  67 + else {
  68 + $cmd = "python -u reader.py -tmin $tmin -tmax $tmax -id $ddId";
  69 + }
  70 +
  71 + disable_ob();
  72 + header("Access-Control-Allow-Origin: *");
  73 + header("Access-Control-Allow-Methods: GET");
  74 + $handle = popen($cmd, 'r');
  75 + while(!feof($handle)) {
  76 + $buffer = fgets($handle);
  77 + echo "$buffer";
  78 + ob_flush();
  79 + }
  80 +
  81 + pclose($handle);
  82 +
  83 +?>
... ...
src/DDSERVICES/HAPI/index.html 0 โ†’ 100644
... ... @@ -0,0 +1,10 @@
  1 +<!DOCTYPE HTML>
  2 +<html>
  3 +<head>
  4 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5 +<title>Welcome on Amda</title>
  6 +</head>
  7 +<body>
  8 +<h2> Nice to see you </h2>
  9 +</body>
  10 +</html>
0 11 \ No newline at end of file
... ...
src/DDSERVICES/HAPI/info.php 0 โ†’ 100644
... ... @@ -0,0 +1,92 @@
  1 +<?php
  2 +
  3 + function rglob($pattern, $flags = 0) {
  4 + $files = glob($pattern, $flags);
  5 + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
  6 + $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
  7 + }
  8 + return $files;
  9 + }
  10 +
  11 + $METADATA_DIR = "PARAM_DEF";
  12 +
  13 + $response = array();
  14 + $response["HAPI"] = "2.0";
  15 + header('Content-Type: application/json');
  16 +
  17 + if (!$_GET["id"]) {
  18 + $response["status"] = 404;
  19 + $response["msg"] = "No ID !!!";
  20 +
  21 + exit(json_encode($response));
  22 + }
  23 +
  24 + $id = $_GET["id"];
  25 +
  26 + if ($_GET["parameters"]) {
  27 + $paramRequest = explode(",",$_GET["parameters"]);
  28 + }
  29 + else {
  30 + $paramRequest = null;
  31 + }
  32 +
  33 + $pattern = "$id.xml";
  34 + $files = rglob($pattern);
  35 +
  36 + $xmlName = $files[0];
  37 +
  38 + if (!file_exists($xmlName)) {;
  39 + header("HTTP/1.1 404 NO SUCH ID");
  40 + $response["status"] = array("code" => 1406, "message" => "NO SUCH ID");
  41 + exit(json_encode($response));
  42 + }
  43 +
  44 + $dom = new DomDocument("1.0");
  45 + $dom->load($xmlName);
  46 +
  47 + $dataset = $dom->getElementsByTagName("Spase")->item(0);
  48 +
  49 + $parameters = $dataset->getElementsByTagName('Parameter');
  50 + if ( $parameters->length == 0 ) {
  51 + header("HTTP/1.1 404 NO PARAMETERS");
  52 + $response["status"] = array("code" => 1406, "message" => "NO PARAMETERS");
  53 + exit(json_encode($response));
  54 + }
  55 +
  56 + $paramDom = new DomDocument("1.0");
  57 +
  58 + $parametersResponse = array(array("name" => "Time", "type" => "isotime", "length" => 20, "units" => "", "fill" =>""));
  59 + foreach ( $parameters as $param ) {
  60 + $oneParam = array();
  61 + $oneParam["type"] = "double";
  62 + $paramId = $param->getElementsByTagName('ParameterKey')->item(0)->nodeValue;
  63 + if (file_exists("$METADATA_DIR/$paramId.xml")) {
  64 + $paramDom->load("$METADATA_DIR/$paramId.xml");
  65 + $process = $paramDom->getElementsByTagName("process")->item(0)->nodeValue;
  66 + if (!$process) {
  67 + $baseParam = $paramDom->getElementsByTagName("baseParam")->item(0);
  68 + $oneParam["name"] = $baseParam->getAttribute('name');
  69 + $oneParam["description"] = $param->getElementsByTagName('Description')->item(0)->nodeValue;
  70 + $oneParam["fill"] = $param->getElementsByTagName('FillValue')->item(0)->nodeValue;
  71 + $oneParam["units"] = $param->getElementsByTagName('Units')->item(0)->nodeValue;
  72 + $size = $param->getElementsByTagName('Size');
  73 + if ($size->length > 0) {
  74 + $oneParam["size"] = array(intval($size->item(0)->nodeValue));
  75 + }
  76 + if ($paramRequest && !in_array($baseParam->getAttribute('name'), $paramRequest)) {
  77 + //
  78 + } else {
  79 + $parametersResponse[] = $oneParam;
  80 + }
  81 + }
  82 + }
  83 + }
  84 +
  85 + $response["startDate"] = $dataset->getElementsByTagName('StartDate')->item(0)->nodeValue;
  86 + $response["stopDate"] = $dataset->getElementsByTagName('StopDate')->item(0)->nodeValue;
  87 + $response["cadence"] = $dataset->getElementsByTagName('Cadence')->item(0)->nodeValue;
  88 + $response["parameters"] = $parametersResponse;
  89 + $response["status"] = array("code" => 1200, "msg" => "OK");
  90 +
  91 + exit(json_encode($response));
  92 +?>
0 93 \ No newline at end of file
... ...
src/DDSERVICES/HAPI/reader.py 0 โ†’ 100644
... ... @@ -0,0 +1,385 @@
  1 +#! /usr/bin/python
  2 +# -*- coding: utf-8 -*-
  3 +
  4 +
  5 +"""
  6 + Python reader to stream csv HAPI formatted data
  7 + python reader.py -tmin 1991-01-01T00:00:00 -tmax 1992-01-01T00:00:00 -id tao_mars_dsc -path /Users/aloh/Documents/Work/HAPI/hapi_amda/data/tao/TAO/MARS/SW/
  8 +
  9 + gcc GetFileNames.c DD_time.c -lnetcdf -o GetFileNames
  10 +"""
  11 +
  12 +
  13 +import sys
  14 +import os
  15 +import shutil
  16 +import gzip
  17 +import tempfile
  18 +import time
  19 +import calendar
  20 +import datetime
  21 +import dateutil.parser
  22 +import xml.etree.ElementTree as ET
  23 +import numpy
  24 +from numpy import __version__ as numpy_version
  25 +from collections import OrderedDict
  26 +
  27 +#import ctypes
  28 +import subprocess
  29 +
  30 +
  31 +
  32 +#_DDSYS_PATH = os.environ['DDBASE'] + '/DDsys.xml'
  33 +#_GETFILENAMES = os.environ['DDBASEBIN'] + '/GetFileNames'
  34 +_DDSYS_PATH = '/data/DDBASE/DATA/DDsys.xml'
  35 +_GETFILENAMES = '/home/budnik/AMDANEW/DDLIB/bin/GetFileNames'
  36 +os.environ['LD_LIBRARY_PATH'] = '/home/budnik/AMDANEW/DDLIB/lib/'
  37 +
  38 +from netCDF4 import Dataset as ncDataset
  39 +from netCDF4 import __version__ as netCDF_version
  40 +
  41 +#print('# numpy: {}, netCDF4: {}'.format(numpy_version, netCDF_version))
  42 +# recommended: numpy='1.11.3', netCDF4='1.4.2'
  43 +
  44 +
  45 +def parse_arguments(argv):
  46 + """ Re-organize the arguments
  47 + ['-x', '34', '-y', '-z', '2']
  48 + would become
  49 + [['-x', '34'], ['-y', True], ['-z', '2']]
  50 + """
  51 + newargv = []
  52 + i = 0
  53 + while i < len(argv):
  54 + argtuple = [0, 0]
  55 + if argv[i].startswith('-'):
  56 + argtuple[0] = argv[i]
  57 + if i == len(argv)-1:
  58 + argtuple[1] = True
  59 + i += 1
  60 + elif argv[i+1].startswith('-'):
  61 + argtuple[1] = True
  62 + i += 1
  63 + else:
  64 + argtuple[1] = argv[i+1]
  65 + i += 2
  66 + else:
  67 + i += 1
  68 + newargv.append( tuple(argtuple) )
  69 + return newargv
  70 +
  71 +
  72 +def read_time_arg(argv, name):
  73 + """ Read the requested time argument.
  74 +
  75 + Parameters
  76 + ----------
  77 + argv : list
  78 + List of arguments
  79 + name : str
  80 + tmin or tmax
  81 +
  82 + Returns
  83 + -------
  84 + time : str
  85 + Time correctly formatted
  86 + """
  87 + assert name in ['tmin', 'tmax'], 'name should be tmin or tmax'
  88 +
  89 + for arg in argv:
  90 +
  91 + if name in arg[0].lower():
  92 +
  93 + # Check the time format
  94 + time = arg[1]
  95 + assert isinstance(time, str), 'time is not a string'
  96 +
  97 + try:
  98 + istime = (time[4] == '-') & (time[8] == 'T') & (time[11] == ':') & (time[14] == ':')
  99 + except:
  100 + istime = False
  101 + #assert istime, 'time doesnt seem like yyyy-dddThh:mm:ss'
  102 +
  103 + return dateutil.parser.parse(time, ignoretz=True)
  104 +
  105 + return None
  106 +
  107 +
  108 +def read_id_arg(argv):
  109 + """ Read the requested ID argument
  110 +
  111 + Parameters
  112 + ----------
  113 + argv : list
  114 + List of arguments
  115 + """
  116 + for arg in argv:
  117 +
  118 + if 'id' in arg[0].lower():
  119 +
  120 + iden = arg[1]
  121 +
  122 + return iden
  123 +
  124 + return None
  125 +
  126 +
  127 +def read_param_arg(argv):
  128 + """ Read the requested parameters argument
  129 +
  130 + Parameters
  131 + ----------
  132 + argv : list
  133 + List of arguments
  134 + """
  135 + for arg in argv:
  136 +
  137 + if ('param' in arg[0].lower()) or ('parameters' in arg[0].lower()):
  138 +
  139 + params = arg[1].split(',')
  140 +
  141 + return params
  142 +
  143 + return None
  144 +
  145 +
  146 +def read_path_arg(argv):
  147 + """ Read the requested parameters argument
  148 +
  149 + Parameters
  150 + ----------
  151 + argv : list
  152 + List of arguments
  153 + """
  154 + for arg in argv:
  155 +
  156 + if 'path' in arg[0].lower():
  157 +
  158 + path = arg[1]
  159 +
  160 + return path
  161 +
  162 + return None
  163 +
  164 +def open_netcdf(fname):
  165 + if fname.endswith(".gz"):
  166 + infile = gzip.open(fname, 'rb')
  167 + tmp = tempfile.NamedTemporaryFile(delete=False)
  168 + shutil.copyfileobj(infile, tmp)
  169 + infile.close()
  170 + tmp.close()
  171 + data = ncDataset(tmp.name)
  172 + os.unlink(tmp.name)
  173 + else:
  174 + data = ncDataset(fname)
  175 + return data
  176 +
  177 +
  178 +def amda_to_datetime(amda_time):
  179 + """
  180 + Convert amda DD time to datetime.
  181 + :param amda_time: (string) encoded time.
  182 + :return: (datetime.datetime)
  183 + """
  184 + # str_time_year = "".join([c.item().decode('ascii') for c in amda_time[0:4]])
  185 + # str_time_jday = "{:03d}".format(int("".join([c.item().decode('ascii') for c in amda_time[4:7]]))+1)
  186 + # str_time_hmsm = "".join([c.item().decode('ascii') for c in amda_time[7:]])
  187 +
  188 + str_time_year = "".join(amda_time[0:4])
  189 + str_time_jday = "{:03d}".format(int("".join(amda_time[4:7]))+1)
  190 + str_time_hmsm = "".join([c for c in amda_time[7:] if isinstance(c, str)])
  191 + return datetime.datetime.strptime(str_time_year+str_time_jday+str_time_hmsm+'000',"%Y%j%H%M%S%f")
  192 +
  193 +
  194 +def get_metadata_from_ddsys(name, localpath):
  195 + """
  196 + Get dataset information from ddsys.xml file, using dataset name
  197 + :param name: (string) DD dataset name
  198 + :return: (dict)
  199 + """
  200 +
  201 + metadata = {}
  202 + dd_sys = ET.parse(_DDSYS_PATH)
  203 + for record in dd_sys.getroot().iter('VI'):
  204 +
  205 + # selecting only the <VI>...</VI> element with the correct ID
  206 + if record[0].text == name:
  207 +
  208 + for child in record:
  209 + metadata[child.tag] = child.text
  210 +
  211 + if localpath is None:
  212 + localpath = metadata['LOCATION']
  213 +
  214 + dd_info = ET.parse('{}{}'.format(localpath, metadata['INFO'].replace('.nc', '.xml')))
  215 + for child in dd_info.getroot():
  216 + if child.tag.startswith('Global') or child.tag.startswith('Local'):
  217 + metadata[child.tag] = dateutil.parser.parse(child.text, ignoretz=True)
  218 + else:
  219 + metadata[child.tag] = child.text
  220 +
  221 + return metadata
  222 +
  223 +
  224 +def get_start_stop_from_times_nc_file_v0(metadata, localpath):
  225 + """
  226 + Get StartTime, StopTime and FileName from the times.nc file of th current dataset
  227 + :param metadata: (dict) DDsys metadata for the current dataset
  228 + :return: (numpy.array, numpy.array, numpy.array)
  229 + """
  230 + if localpath is None:
  231 + localpath = metadata['LOCATION']
  232 +
  233 + times_nc_file = "{}{}".format(localpath, metadata['TIMES'])
  234 +
  235 + times_nc_data = open_netcdf(times_nc_file)
  236 +
  237 + def parse_filename(name_array, localpath=localpath):
  238 + return "{}{}".format(localpath, ''.join(name_array.data))
  239 +
  240 + start = map(amda_to_datetime, times_nc_data.variables['StartTime'])
  241 + stop = map(amda_to_datetime, times_nc_data.variables['StopTime'])
  242 + filenames = map(parse_filename, times_nc_data.variables['FileName'])
  243 +
  244 + # return numpy.array([amda_to_datetime(item) for item in times_nc_data.variables['StartTime']]), \
  245 + # numpy.array([amda_to_datetime(item) for item in times_nc_data.variables['StopTime']]), \
  246 + # numpy.array(["{}{}".format(localpath, ''.join(item.data))
  247 + # for item in times_nc_data.variables['FileName']])
  248 + return numpy.array(start), numpy.array(stop), numpy.array(filenames)
  249 +
  250 +
  251 +def get_start_stop_from_times_nc_file(metadata, localpath, tmin, tmax):
  252 + """
  253 + """
  254 +
  255 + if localpath is None:
  256 + localpath = metadata['LOCATION']
  257 +
  258 + times_nc_file = "{}{}".format(localpath, metadata['TIMES'])
  259 + start = calendar.timegm(tmin.timetuple())
  260 + stop = calendar.timegm(tmax.timetuple())
  261 +
  262 + command = _GETFILENAMES+' '+str(times_nc_file)+' '+str(start)+' '+str(stop)
  263 + result = subprocess.check_output(command, shell=True)
  264 + result = result.strip(';').split(';')
  265 + result = ['{}{}'.format(localpath, rr) for rr in result]
  266 + return result
  267 +
  268 +
  269 +def check_time_range(tmin, tmax, metadata):
  270 + """ Check that start and stop are within the metadata Global time range
  271 +
  272 + Parameters
  273 + ----------
  274 + tmin : datetime
  275 + tmax : datetime
  276 + metadata : dict
  277 + """
  278 + if tmin < metadata['GlobalStart']:
  279 + raise ValueError('tmin lower than GlobalStart {}'.format(metadata['GlobalStart']))
  280 + if tmax > metadata['GlobalStop']:
  281 + raise ValueError('tmax greater than GlobalStop {}'.format(metadata['GlobalStop']))
  282 + return
  283 +
  284 +
  285 +#--------------------------------------------------#
  286 +def main(argv):
  287 + argv = parse_arguments(argv)
  288 +
  289 + tmin = read_time_arg(argv, 'tmin')
  290 + tmax = read_time_arg(argv, 'tmax')
  291 + iden = read_id_arg(argv)
  292 + para = read_param_arg(argv)
  293 + path = read_path_arg(argv)
  294 +
  295 + meta = get_metadata_from_ddsys(iden, localpath=path)
  296 + check_time_range(tmin, tmax, meta)
  297 +
  298 + # start, stop, files = get_start_stop_from_times_nc_file(meta, localpath=path, tmin=tmin, tmax=tmax)
  299 +
  300 + # timemask = (start <= tmax) & (stop >= tmin)
  301 +
  302 + # for ncfile in files[timemask]:
  303 +
  304 + files = get_start_stop_from_times_nc_file(meta, localpath=path, tmin=tmin, tmax=tmax)
  305 + for ncfile in files:
  306 + nc = open_netcdf(ncfile + '.gz')
  307 + cur_start_time = amda_to_datetime(nc.variables['StartTime']) # extract amda-formatted start_time
  308 + cur_end_time = amda_to_datetime(nc.variables['StopTime']) # extract amda-formatted end_time
  309 +
  310 + variables = nc.variables
  311 + # if para is not None:
  312 + # para_dict = []
  313 + # para_vari = []
  314 + # for par in para:
  315 + # if ('[' in par) & (']' in par):
  316 + # para_index = int(par[par.find('[')+1:par.find(']')])
  317 + # para_name = par.split('[')[0]
  318 + # else:
  319 + # para_index = None
  320 + # para_name = par
  321 + # para_dict.append( (para_name, para_index) )
  322 + # para_vari.append( (para_name, variables[para_name]))
  323 +
  324 + # var_index = OrderedDict(para_dict)
  325 + # variables = OrderedDict(para_vari)
  326 +
  327 + # print(var_index)
  328 + # print(variables)
  329 +
  330 + if para is not None:
  331 + variables = OrderedDict([(key.split('[')[0], variables[key.split('[')[0]]) for key in para])
  332 + var_index = OrderedDict([(key.split('[')[0], []) for key in para])
  333 +
  334 + for par in para:
  335 + if ('[' in par) & (']' in par):
  336 + para_index = int(par[par.find('[')+1:par.find(']')])
  337 + para_name = par.split('[')[0]
  338 + else:
  339 + para_index = None
  340 + para_name = par
  341 + var_index[para_name].append(para_index)
  342 +
  343 + #variables = OrderedDict([(key, variables[key]) for key in para])
  344 + if tmin <= cur_end_time and tmax >= cur_start_time: # checking if file contains data within interval
  345 + # time = [amda_to_datetime(cur_time) for cur_time in nc.variables['Time']]
  346 + time = map(amda_to_datetime, nc.variables['Time'])
  347 +
  348 + for cur_index, cur_dt in enumerate(time):
  349 + if cur_dt > tmax:
  350 + break
  351 +
  352 + if cur_dt >= tmin and cur_dt <= tmax:
  353 + stream = '{}'.format(cur_dt.isoformat())
  354 + for var in variables:
  355 + if not 'Time' in var:
  356 + cur_data = nc.variables[var][cur_index]
  357 +
  358 + # check if this is a vector (for the velocity)
  359 + # assert isinstance(cur_data, numpy.ndarray), '{}, index {} is not a numpy.ndarray'.format(var, cur_index)
  360 + if isinstance(cur_data, numpy.ndarray):
  361 + if cur_data.size > 1:
  362 + # for item in cur_data:
  363 + # stream += ', {}'.format(item)
  364 +
  365 + if para is not None:
  366 + if var_index[var] == [None]:
  367 + for item in cur_data:
  368 + stream += ', {}'.format(item)
  369 + else:
  370 + for i in var_index[var]:
  371 + stream += ', {}'.format(cur_data[i])
  372 + else:
  373 + for item in cur_data:
  374 + stream += ', {}'.format(item)
  375 + else:
  376 + stream += ', {}'.format(cur_data)
  377 + else:
  378 + stream += ', {}'.format(cur_data)
  379 + print(stream)
  380 +
  381 +#--------------------------------------------------#
  382 +
  383 +
  384 +if __name__ == "__main__":
  385 + main(sys.argv[1:])
... ...
src/DDSERVICES/REST/getDataUrl.php 0 โ†’ 100644
... ... @@ -0,0 +1,11 @@
  1 +<?php
  2 +
  3 + require_once 'DDserverWeb.php';
  4 +
  5 + $ddserveur_ws = new DDService();
  6 +
  7 + $res = $ddserveur_ws->getDataUrl($_GET['dataSet'],$_GET['StartTime'],$_GET['StopTime']);
  8 +
  9 + echo json_encode($res);
  10 +
  11 +?>
... ...
src/DDSERVICES/REST/getGranulesIndex.php
... ... @@ -13,7 +13,7 @@
13 13  
14 14 // $dataSet = strtr($_GET['id'], $replace);
15 15  
16   - $referXML = baseDir."DDsys.xml";
  16 + $referXML = baseDir."/DDsys.xml";
17 17 $DDsys = new DOMDocument("1.0");
18 18 $DDsys->load($referXML);
19 19  
... ...
src/DDSERVICES/REST/getGranulesSize.php
... ... @@ -18,7 +18,7 @@
18 18 exit();
19 19 }
20 20 $ddSys = new DOMDocument('1.0');
21   - $ddSys->load(baseDir."DDsys.xml");
  21 + $ddSys->load(baseDir."/DDsys.xml");
22 22 $xp = new DOMXpath($ddSys);
23 23  
24 24 $VI = $xp->query("//NAME[.='".$dataSet."']");
... ...
src/DDSERVICES/REST/getLastRealUpdate.php 0 โ†’ 100644
... ... @@ -0,0 +1,39 @@
  1 +<?php
  2 +/**
  3 +* @file getLastRealUpdate.php
  4 +* @brief Returns modif date of the last modified data file (*.nc.gz) for a given DataSet
  5 +* @version $Id: $
  6 +*/
  7 +
  8 + if (!isset($_GET['id'])) exit('INPUT ERROR');
  9 +
  10 + require_once './DDserverWeb_ini.php';
  11 +
  12 + error_reporting(E_ERROR | E_WARNING | E_PARSE);
  13 +
  14 + $replace = array("-" => "_");
  15 +
  16 + $dataSet = strtr($_GET['id'], $replace);
  17 +
  18 + $referXML = baseDir."/DDsys.xml";
  19 + $DDsys = new DOMDocument("1.0");
  20 + $DDsys->load($referXML);
  21 + $xp = new domxpath($DDsys);
  22 + $VI_NAME = $xp->query("//NAME[.='".$dataSet."']");
  23 +
  24 + if ($VI_NAME->item(0)->nodeValue != NULL)
  25 + {
  26 + $VI = $VI_NAME->item(0)->parentNode;
  27 + $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue;
  28 + $find = 'find '.$location.' -name \'*.nc.gz\' -type f -printf \'%T@ %p\n\' | sort -n | tail -1 | cut -f2- -d" "';
  29 + $lastFile = exec($find);
  30 + if (!file_exists($lastFile))
  31 + exit('NO SUCH FILE '.$lastFile);
  32 + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '.$lastFile; // for NFS
  33 + $dateModif = exec($cmd);
  34 + exit($dateModif);
  35 + }
  36 + else {
  37 + exit('NO SUCH DATASET');
  38 + }
  39 +?>
... ...
src/DDSERVICES/REST/getLastUpdate.php 0 โ†’ 100644
... ... @@ -0,0 +1,40 @@
  1 +<?php
  2 +
  3 +/**
  4 +* @file getLastUpdate.php
  5 +* @brief Returns last modif of *_times.nc for a given DataSet
  6 +* @version $Id: $
  7 +*/
  8 +
  9 + if (!isset($_GET['id'])) exit('INPUT ERROR');
  10 +
  11 + require_once './DDserverWeb_ini.php';
  12 +
  13 + error_reporting(E_ERROR | E_WARNING | E_PARSE);
  14 +
  15 + $replace = array("-" => "_");
  16 +
  17 + $dataSet = strtr($_GET['id'], $replace);
  18 +
  19 + $referXML = baseDir."/DDsys.xml";
  20 + $DDsys = new DOMDocument("1.0");
  21 + $DDsys->load($referXML);
  22 + $xp = new domxpath($DDsys);
  23 + $VI_NAME = $xp->query("//NAME[.='".$dataSet."']");
  24 +
  25 + if ($VI_NAME->item(0)->nodeValue != NULL)
  26 + {
  27 + $VI = $VI_NAME->item(0)->parentNode;
  28 + $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue;
  29 + $times = $VI->getElementsByTagName("TIMES")->item(0)->nodeValue;
  30 + if (!file_exists($location.$times))
  31 + exit('NO TIMES FILE');
  32 +
  33 + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '. $location.$times; // for NFS
  34 + $dateModif = exec($cmd);
  35 + exit($dateModif);
  36 + }
  37 + else {
  38 + exit('NO SUCH DATASET');
  39 + }
  40 +?>
... ...
src/DDSERVICES/REST/getStartStop.php 0 โ†’ 100644
... ... @@ -0,0 +1,43 @@
  1 +<?php
  2 +
  3 +/**
  4 +* @file getStartStop.php
  5 +* @brief Returns GlobalStart - GlobalStop for a given DataSet
  6 +* @version $Id: $
  7 +*/
  8 +
  9 + if (!isset($_GET['id'])) exit('INPUT ERROR');
  10 +
  11 + require_once './DDserverWeb_ini.php';
  12 +
  13 + error_reporting(E_ERROR | E_WARNING | E_PARSE);
  14 +
  15 + $replace = array("-" => "_");
  16 +
  17 + $dataSet = strtr($_GET['id'], $replace);
  18 +
  19 + $referXML = baseDir."/DDsys.xml";
  20 + $DDsys = new DOMDocument("1.0");
  21 + $DDsys->load($referXML);
  22 + $xp = new domxpath($DDsys);
  23 + $VI_NAME = $xp->query("//NAME[.='".$dataSet."']");
  24 +
  25 + if ($VI_NAME->item(0)->nodeValue != NULL)
  26 + {
  27 + $VI = $VI_NAME->item(0)->parentNode;
  28 + $location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue;
  29 + $info = basename($VI->getElementsByTagName("INFO")->item(0)->nodeValue, '.nc').'.xml';
  30 + if (!file_exists($location.$info))
  31 + exit('NO INFO XML');
  32 +
  33 + $infoDom = new DOMDocument("1.0");
  34 + $infoDom->loadXML(file_get_contents($location.$info)); // for NFS
  35 +
  36 + $Start = $infoDom->getElementsByTagName("GlobalStart")->item(0)->nodeValue;
  37 + $Stop = $infoDom->getElementsByTagName("GlobalStop")->item(0)->nodeValue;
  38 + exit($Start.",".$Stop);
  39 + }
  40 + else {
  41 + exit('NO SUCH DATASET');
  42 + }
  43 +?>
... ...
src/DDSERVICES/SOAP/DDserverWeb.php
... ... @@ -114,7 +114,7 @@
114 114  
115 115 function getUserGroups()
116 116 {
117   - if (file_exists(extBaseDir."AMDA_Users.xml")) return extWebAlias."AMDA_Users.xml";
  117 + if (file_exists(extBaseDir."/AMDA_Users.xml")) return extWebAlias."AMDA_Users.xml";
118 118 else return NOUSERGROUPSSPECIFIED;
119 119 }
120 120  
... ... @@ -157,9 +157,9 @@
157 157 {
158 158 //get user
159 159 $user_dom = new DomDocument("1.0");
160   - if (!file_exists(extBaseDir."AMDA_Users.xml"))
  160 + if (!file_exists(extBaseDir."/AMDA_Users.xml"))
161 161 return array();
162   - $user_dom->load(extBaseDir."AMDA_Users.xml");
  162 + $user_dom->load(extBaseDir."/AMDA_Users.xml");
163 163  
164 164 $user_nodes = $user_dom->getElementsByTagName('user');
165 165  
... ... @@ -183,9 +183,9 @@
183 183  
184 184 //get local missions
185 185 $mis_dom = new DomDocument("1.0");
186   - if (!file_exists(extBaseDir."Missions.xml"))
  186 + if (!file_exists(extBaseDir."/Missions.xml"))
187 187 return array();
188   - $mis_dom->load(extBaseDir."Missions.xml");
  188 + $mis_dom->load(extBaseDir."/Missions.xml");
189 189  
190 190 $local_nodes = $mis_dom->getElementsByTagName('Local');
191 191 if ($local_nodes->length < 1)
... ... @@ -307,20 +307,75 @@
307 307 }
308 308 }
309 309  
  310 +/**
  311 +* Returns date of last modif of *times.nc in DD Base
  312 +*/
  313 +
  314 + function getLastUpdate($dataSet)
  315 + {
  316 + $referXML = baseDir."/DDsys.xml";
  317 + $DDsys = new DOMDocument("1.0");
  318 + $DDsys->load($referXML);
  319 + $xp = new domxpath($DDsys);
  320 + $VI = $xp->query("//NAME[.='".$dataSet."']");
  321 +
  322 + if ($VI->item(0)->nodeValue != NULL)
  323 + {
  324 + $location = $VI->item(0)->parentNode->getElementsByTagName("LOCATION")->item(0)->nodeValue;
  325 + $times = $VI->getElementsByTagName("TIMES")->item(0)->nodeValue;
  326 + if (!file_exists($location.$times))
  327 + return null;
  328 +
  329 + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '. $location.$times; // for NFS
  330 + $dateModif = exec($cmd);
  331 + return $dateModif;
  332 + }
  333 +
  334 + return null;
  335 + }
  336 +
  337 +/**
  338 +* Returns modif date of the last modified data file (*.nc.gz) for a given DataSet
  339 +*/
310 340  
  341 + function getLastRealUpdate($dataSet)
  342 + {
  343 + $referXML = baseDir."/DDsys.xml";
  344 + $DDsys = new DOMDocument("1.0");
  345 + $DDsys->load($referXML);
  346 + $xp = new domxpath($DDsys);
  347 + $VI = $xp->query("//NAME[.='".$dataSet."']");
  348 +
  349 + if ($VI->item(0)->nodeValue != NULL)
  350 + {
  351 + $location = $VI->item(0)->parentNode->getElementsByTagName("LOCATION")->item(0)->nodeValue;
  352 +
  353 + $find = 'find '.$location.' -name \'*.nc.gz\' -type f -printf \'%T@ %p\n\' | sort -n | tail -1 | cut -f2- -d" "';
  354 + $lastFile = exec($find);
  355 + if (!file_exists($lastFile))
  356 + exit('NO SUCH FILE '.$lastFile);
  357 + $cmd = 'date "+%Y-%m-%dT%H:%M:%SZ" -u -r '.$lastFile; // for NFS
  358 +
  359 + $dateModif = exec($cmd);
  360 + return $dateModif;
  361 + }
  362 +
  363 + return null;
  364 + }
  365 +
  366 +
311 367 /**
312 368 * Returns String Start-Stop for local DataSet in DD Base
313 369 */
314 370  
315 371 function getStartStop($dataSet)
316 372 {
317   - if ($dataSet != "compound") {
318   - $referFile = baseDir."/refer.nc";
319   - $cmd = DDBASEBIN."/StartStop ".$referFile." ".$dataSet;
320   - $res = system($cmd);
321   -
322   - return $res;
323   - }
  373 +
  374 + $referFile = baseDir."/refer.nc";
  375 + $cmd = DDBASEBIN."/StartStop ".$referFile." ".$dataSet;
  376 + $res = system($cmd);
  377 +
  378 + return $res;
324 379 }
325 380  
326 381 /**
... ...
src/DDSERVICES/SOAP/dd.wsdl.in
... ... @@ -62,6 +62,18 @@
62 62 <message name='getStartStopResponse'>
63 63 <part name='Result' type='xsd:string'/>
64 64 </message>
  65 +<message name='getLastUpdateRequest'>
  66 + <part name='dataSet' type='xsd:string'/>
  67 +</message>
  68 +<message name='getLastUpdateResponse'>
  69 + <part name='Result' type='xsd:string'/>
  70 +</message>
  71 +<message name='getLastRealUpdateRequest'>
  72 + <part name='dataSet' type='xsd:string'/>
  73 +</message>
  74 +<message name='getLastRealUpdateResponse'>
  75 + <part name='Result' type='xsd:string'/>
  76 +</message>
65 77 <message name='getInfoRequest'>
66 78 <part name='dataSet' type='xsd:string'/>
67 79 <part name='infoName' type='xsd:string'/>
... ... @@ -147,6 +159,14 @@
147 159 <operation name='getStartStop'>
148 160 <input message='tns:getStartStopRequest'/>
149 161 <output message='tns:getStartStopResponse'/>
  162 + </operation>
  163 + <operation name='getLastUpdate'>
  164 + <input message='tns:getLastUpdateRequest'/>
  165 + <output message='tns:getLastUpdateResponse'/>
  166 + </operation>
  167 + <operation name='getLastRealUpdate'>
  168 + <input message='tns:getLastRealUpdateRequest'/>
  169 + <output message='tns:getLastRealUpdateResponse'/>
150 170 </operation>
151 171 <operation name='getInfo'>
152 172 <input message='tns:getInfoRequest'/>
... ... @@ -240,7 +260,29 @@
240 260 <soap:body use='encoded'
241 261 encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
242 262 </output>
243   - </operation>
  263 + </operation>
  264 + <operation name='getLastUpdate'>
  265 + <soap:operation soapAction='getLastUpdate'/>
  266 + <input>
  267 + <soap:body use='encoded'
  268 + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  269 + </input>
  270 + <output>
  271 + <soap:body use='encoded'
  272 + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  273 + </output>
  274 + </operation>
  275 + <operation name='getLastRealUpdate'>
  276 + <soap:operation soapAction='getLastRealUpdate'/>
  277 + <input>
  278 + <soap:body use='encoded'
  279 + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  280 + </input>
  281 + <output>
  282 + <soap:body use='encoded'
  283 + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
  284 + </output>
  285 + </operation>
244 286 <operation name='getInfo'>
245 287 <soap:operation soapAction='getSInfo'/>
246 288 <input>
... ...
src/DECODERS/cdfnew2nc/cdfnew2nc.c
... ... @@ -1392,7 +1392,7 @@ char * ptr;
1392 1392 while (uiPtr == NULL || dPtr == NULL) {
1393 1393 uiPtr = (unsigned int *) malloc (sizeof(unsigned int) * numValues * numRecs);
1394 1394 dPtr = (double *) malloc (sizeof(double) * numValues * numRecs);
1395   - if (iPtr == NULL) {
  1395 + if (uiPtr == NULL) {
1396 1396 if (DEBUG) insufficient_memory();
1397 1397 divide *= 2;
1398 1398 numRecs = totRecs / divide;
... ...
src/REMOTEDATA/CDAWEB.php
... ... @@ -438,7 +438,8 @@ class CDAWEB extends RemoteDataCenterClass
438 438 {
439 439 error_log("ERROR no response for : ".$ds." : ".$start." - ".$stop.PHP_EOL,3,err);
440 440 error_log($res->saveXML(),3,err);
441   - exit();
  441 + $this->closeConnection();
  442 + return array();
442 443 }
443 444  
444 445 $fileNames = $res->getElementsByTagName("Name");
... ...
src/REMOTEDATA/RemoteDataCenterClass.php
... ... @@ -30,6 +30,7 @@ abstract class RemoteDataCenterClass
30 30 {
31 31 $this->baseID = get_class($this);
32 32 $this->location = RemoteData."/bases/".$this->baseID;
  33 + date_default_timezone_set('UTC');
33 34 }
34 35  
35 36 /* Function to change External Bases stuff in case of existing AMDA aliases.
... ... @@ -75,12 +76,12 @@ abstract class RemoteDataCenterClass
75 76 public function initProxy()
76 77 {
77 78 if (!is_dir($this->location))
78   - mkdir($this->location, 0755, true);
  79 + mkdir($this->location, 0775, true);
79 80  
80 81 $this->DDserverDir = RemoteData."/DDServer/".$this->baseID;
81 82  
82 83 if (!is_dir($this->DDserverDir))
83   - mkdir($this->DDserverDir, 0755, true);
  84 + mkdir($this->DDserverDir, 0775, true);
84 85  
85 86 $this->init();
86 87  
... ...
src/REMOTEDATA/THEMIS.php
... ... @@ -8,26 +8,26 @@ class THEMIS extends RemoteDataCenterClass
8 8 {
9 9 // /THEMIS_B1/themisdata
10 10  
11   - protected $baseMgr;
  11 + protected $baseMgr;
12 12 protected $domTemplate;
13   -
  13 + protected $xmlTemplate;
14 14  
15 15 public function init()
16 16 {
17 17 error_log("THEMIS Proxy creation on ".date("Y-m-d\TH:i:s").PHP_EOL,3,log);
18 18 error_log("THEMIS Proxy creation on ".date("Y-m-d\TH:i:s").PHP_EOL,3,err);
19   -
  19 + $this->xmlTemplate = strval(RemoteData).ThemisConfigClass::$TemplateXml;
20 20 }
21 21  
22 22 protected function getRemoteTree()
23 23 {
24   - if (!file_exists(ThemisConfigClass::$TemplateXml)) {
  24 + if (!file_exists($this->xmlTemplate)) {
25 25 error_log('Cannot find THEMIS tree template'.PHP_EOL,3,err);
26 26 exit('Cannot find THEMIS tree template');
27 27 }
28 28  
29 29 $this->domTemplate = new DomDocument("1.0");
30   - if (!$this->domTemplate->load(ThemisConfigClass::$TemplateXml)) {
  30 + if (!$this->domTemplate->load($this->xmlTemplate)) {
31 31 error_log('Cannot load THEMIS tree template'.PHP_EOL,3,err);
32 32 exit('Cannot load THEMIS tree template');
33 33 }
... ...
src/REMOTEDATA/ThemisConfigClass.php
... ... @@ -13,8 +13,8 @@ class ThemisConfigClass
13 13 public static $NFS_DIR = "/THEMIS_B1/themisdata";
14 14 public static $level = "l2";
15 15 public static $format = "cdf";
16   - public static $themis = array('A'); //, 'B', 'C', 'D', 'E');
17   - public static $TemplateXml = "ThemisTreeTemplate.xml";
  16 + public static $themis = array('A', 'B', 'C', 'D', 'E');
  17 + public static $TemplateXml = "/ThemisTreeTemplate.xml";
18 18 public static $START_YEAR = "2007";
19 19 public static $program = array('peim' => 'themis_esamom2nc', 'peem' => 'themis_esamom2nc',
20 20 'peif' => 'themis_esa2nc', 'peef' => 'themis_esa2nc',
... ...
src/REMOTEDATA/makeProxy.php
... ... @@ -24,7 +24,7 @@
24 24  
25 25 $LOGDIR = $DDBASE."/../LOG";
26 26 if (!is_dir($LOGDIR))
27   - mkdir($LOGDIR, 0755, true);
  27 + mkdir($LOGDIR, 0775, true);
28 28  
29 29 define("log",$LOGDIR."/ProxyCreate.log");
30 30 define("err",$LOGDIR."/ProxyCreate.err");
... ... @@ -34,6 +34,11 @@
34 34  
35 35 define('RemoteData', $DDBASE."/../INFO");
36 36  
  37 + // check permissions
  38 + $perms = fileperms(RemoteData);
  39 + if (! ($perms & 0x0010))
  40 + exit('chmod -R g+wrx INFO dir !!! no write perms for group (apache)'.PHP_EOL);
  41 +
37 42 if (!file_exists(RemoteData."/Bases.xml"))
38 43 exit('No Bases.xml'.PHP_EOL);
39 44  
... ... @@ -44,8 +49,7 @@
44 49 $bases = $basesDom->getElementsByTagName("dataCenter");
45 50 if ($bases->length == 0)
46 51 exit('No Bases'.PHP_EOL);
47   -
48   -// $bases = array("CDAWEB");
  52 +
49 53 $useSpase = true;
50 54  
51 55 foreach ($bases as $base)
... ...
src/SERVER/ncfileop.c
... ... @@ -271,6 +271,7 @@ int VarSize(nc_type type)
271 271 size_t MaxRecord(int ncID)
272 272 /* ncID - ID of already open NC file */
273 273 {
  274 + static char TimeDimName[] = "Time";
274 275 int timedimid; /* ID for dimension "Time" */
275 276  
276 277 int nvars;
... ... @@ -290,7 +291,7 @@ size_t MaxRecord(int ncID)
290 291 /*--- general information -------*/
291 292 status = nc_inq_ndims(ncID,&ndims);
292 293 status = nc_inq_nvars(ncID,&nvars);
293   - status = nc_inq_unlimdim(ncID, &timedimid); /* What is unlimited dimension ID */
  294 + status = nc_inq_dimid(ncID,TimeDimName,&timedimid);
294 295  
295 296 /*---- memory allocation --------*/
296 297 dimleng_arr = (size_t *)malloc(ndims * sizeof(size_t));
... ...