in src/zgoog_cl_content_repo_gcs.clas.abap [0:0]
METHOD process_serverinfo.
TYPES:
BEGIN OF lty_crep,
crep_id TYPE crep-crep_id,
END OF lty_crep.
DATA: lo_gcs TYPE REF TO zgoog_cl_storage_cont_repo_v1,
lo_entity TYPE REF TO if_http_entity,
lo_abap_sdk_excp TYPE REF TO /goog/cx_sdk.
DATA: lv_status TYPE string,
lv_vendor TYPE string,
lv_version TYPE string,
lv_tst TYPE timestamp,
lv_stst TYPE n LENGTH 14,
lv_date TYPE string,
lv_time TYPE string,
lv_contrep TYPE string,
lv_contrep1 TYPE saearchivi,
lv_pversion TYPE string,
lv_resultas TYPE string,
lv_descript_c TYPE crepdescr-descript,
lv_sdescr TYPE string,
lv_bucket_name TYPE string,
lv_ret_code TYPE i,
lv_build TYPE string,
lv_err_text TYPE string,
lv_descript TYPE string.
DATA: ls_crep TYPE lty_crep,
ls_cont_repo TYPE zgoog_cont_repo.
DATA: lt_crep_tab TYPE STANDARD TABLE OF lty_crep.
lv_status = 'running'.
lv_vendor = 'Google Cloud' ##NO_TEXT.
lv_version = sy-saprl.
GET TIME STAMP FIELD lv_tst.
lv_stst = lv_tst.
format_timestamp( EXPORTING iv_timestamp = lv_stst
IMPORTING ev_date = lv_date
ev_time = lv_time ).
lv_contrep = get_parameter( iv_name = 'contRep '
iv_mandatory = ' ' ).
lv_pversion = get_parameter( iv_name = 'pVersion'
iv_mandatory = 'X' ).
lv_resultas = get_parameter( iv_name = 'resultAs'
iv_default = 'ascii' ).
check_parameter_consistence( ).
IF gs_error IS NOT INITIAL.
RETURN.
ENDIF.
lo_entity = go_server->response.
IF lv_resultas = 'html'.
lo_entity->set_header_field( name = 'Content-Type'
value = 'text/plain' ) ##NO_TEXT.
CONCATENATE
'serverStatus:' gv_sp lv_status gv_nl
'serverTime:' gv_sp lv_time gv_nl
'serverDate:' gv_sp lv_date gv_nl
'serverStatusDescription:' gv_sp lv_descript gv_nl
'pVersion:' gv_sp lv_pversion gv_nl
INTO gv_body.
ELSE.
lo_entity->set_header_field( name = 'Content-Type'
value = 'text/plain' ) ##NO_TEXT.
body_add_field( iv_name = 'serverStatus'
iv_value = lv_status ).
body_add_field( iv_name = 'serverTime'
iv_value = lv_time ).
body_add_field( iv_name = 'serverDate'
iv_value = lv_date ).
body_add_field( iv_name = 'serverStatusDescription'
iv_value = lv_descript ).
body_add_field( iv_name = 'pVersion'
iv_value = lv_pversion ) ##NO_TEXT.
CONCATENATE gv_body gv_nl INTO gv_body.
ENDIF.
IF lv_contrep IS INITIAL.
SELECT * FROM crep
INTO CORRESPONDING FIELDS OF TABLE lt_crep_tab
WHERE crep_type IN ( '03', '04' )
AND crep_id IN (
SELECT archive_id
FROM zgoog_cont_repo ). "#EC CI_SUBRC
ELSE.
SELECT * FROM crep
INTO CORRESPONDING FIELDS OF TABLE lt_crep_tab
WHERE ( crep_type = '03' OR crep_type = '04' )
AND crep_id = lv_contrep. "#EC CI_SUBRC
ENDIF.
LOOP AT lt_crep_tab INTO ls_crep.
lv_contrep = ls_crep-crep_id.
SELECT SINGLE descript FROM crepdescr
INTO lv_descript_c
WHERE crep_id = lv_contrep AND langu = sy-langu.
IF sy-subrc = 0.
lv_descript = lv_descript_c.
ELSE.
lv_descript = space.
ENDIF.
lv_status = 'running'.
lv_sdescr = space.
IF lv_resultas = 'html'.
lo_entity->set_header_field( name = 'Content-Type'
value = 'text/plain' ) ##NO_TEXT.
CONCATENATE
gv_body gv_nl
'contRep:' gv_sp lv_contrep gv_nl
'contRepDescription:' gv_sp lv_descript gv_nl
'contRepStatus:' gv_sp lv_status gv_nl
'contRepStatusDescription:' gv_sp lv_sdescr gv_nl
INTO gv_body ##NO_TEXT.
ELSE.
lo_entity->set_header_field( name = 'Content-Type'
value = 'text/plain' ) ##NO_TEXT.
body_add_field( iv_name = 'contRep'
iv_value = lv_contrep ).
body_add_field( iv_name = 'contRepDescription'
iv_value = lv_descript ).
body_add_field( iv_name = 'contRepStatus'
iv_value = lv_status ).
body_add_field( iv_name = 'contRepStatusDescription'
iv_value = lv_sdescr ) ##NO_TEXT.
CONCATENATE gv_body gv_nl INTO gv_body.
ENDIF.
ENDLOOP.
lv_contrep1 = lv_contrep.
load_goog_repo_config( lv_contrep1 ).
IF gs_error IS NOT INITIAL.
RETURN.
ENDIF.
TRY.
CREATE OBJECT lo_gcs
EXPORTING
iv_key_name = gs_repo_config-keyname.
lv_bucket_name = gs_repo_config-bucket.
lo_gcs->get_buckets( EXPORTING iv_p_bucket = lv_bucket_name
IMPORTING ev_ret_code = lv_ret_code
ev_err_text = lv_err_text ).
CATCH /goog/cx_sdk INTO lo_abap_sdk_excp.
lv_err_text = lo_abap_sdk_excp->get_text( ).
go_server->response->set_status( code = 400
reason = lv_err_text ).
RETURN.
ENDTRY.
IF lo_gcs->is_client_error( lv_ret_code ) = abap_true.
go_server->response->set_status( code = 400
reason = lv_err_text ).
RETURN.
ENDIF.
go_server->response->set_status( code = 200
reason = 'OK' ).