diff --git a/src/persist/zcl_abapgit_persist_background.clas.abap b/src/persist/zcl_abapgit_persist_background.clas.abap new file mode 100644 index 000000000..36e220408 --- /dev/null +++ b/src/persist/zcl_abapgit_persist_background.clas.abap @@ -0,0 +1,164 @@ +CLASS zcl_abapgit_persist_background DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. + + CONSTANTS: BEGIN OF c_method, + nothing TYPE string VALUE 'nothing' ##NO_TEXT, + pull TYPE string VALUE 'pull' ##NO_TEXT, + push TYPE string VALUE 'push' ##NO_TEXT, + END OF c_method. + + CONSTANTS: BEGIN OF c_amethod, + fixed TYPE string VALUE 'fixed' ##NO_TEXT, + auto TYPE string VALUE 'auto' ##NO_TEXT, + END OF c_amethod. + + TYPES: BEGIN OF ty_xml, + method TYPE string, + username TYPE string, + password TYPE string, + amethod TYPE string, + aname TYPE string, + amail TYPE string, + END OF ty_xml. + + TYPES: BEGIN OF ty_background, + key TYPE zcl_abapgit_persistence_db=>ty_value. + INCLUDE TYPE ty_xml. + TYPES: END OF ty_background. + TYPES: tt_background TYPE STANDARD TABLE OF ty_background WITH DEFAULT KEY. + + METHODS constructor. + + METHODS list + RETURNING VALUE(rt_list) TYPE tt_background + RAISING zcx_abapgit_exception. + + METHODS modify + IMPORTING is_data TYPE ty_background + RAISING zcx_abapgit_exception. + + METHODS delete + IMPORTING iv_key TYPE ty_background-key + RAISING zcx_abapgit_exception. + + METHODS exists + IMPORTING iv_key TYPE ty_background-key + RETURNING VALUE(rv_yes) TYPE abap_bool + RAISING zcx_abapgit_exception. + + PRIVATE SECTION. + DATA: mo_db TYPE REF TO zcl_abapgit_persistence_db, + mt_jobs TYPE tt_background. + + METHODS from_xml + IMPORTING iv_string TYPE string + RETURNING VALUE(rs_xml) TYPE ty_xml + RAISING zcx_abapgit_exception. + + METHODS to_xml + IMPORTING is_background TYPE ty_background + RETURNING VALUE(rv_string) TYPE string. + +ENDCLASS. + + + +CLASS ZCL_ABAPGIT_PERSIST_BACKGROUND IMPLEMENTATION. + + + METHOD constructor. + mo_db = zcl_abapgit_persistence_db=>get_instance( ). + ENDMETHOD. + + + METHOD delete. + + TRY. + mo_db->read( iv_type = zcl_abapgit_persistence_db=>c_type_background + iv_value = iv_key ). + CATCH zcx_abapgit_not_found. + RETURN. + ENDTRY. + + mo_db->delete( iv_type = zcl_abapgit_persistence_db=>c_type_background + iv_value = iv_key ). + + DELETE mt_jobs WHERE key = iv_key. + + ENDMETHOD. + + + METHOD exists. + + list( ). " Ensure mt_jobs is populated + READ TABLE mt_jobs WITH KEY key = iv_key TRANSPORTING NO FIELDS. + rv_yes = boolc( sy-subrc = 0 ). + + ENDMETHOD. "exists + + + METHOD from_xml. + CALL TRANSFORMATION id + OPTIONS value_handling = 'accept_data_loss' + SOURCE XML iv_string + RESULT data = rs_xml ##NO_TEXT. + ENDMETHOD. + + + METHOD list. + + DATA: lt_list TYPE zcl_abapgit_persistence_db=>tt_content, + ls_xml TYPE ty_xml. + + FIELD-SYMBOLS: LIKE LINE OF lt_list, + LIKE LINE OF rt_list. + + IF lines( mt_jobs ) > 0. + rt_list = mt_jobs. + RETURN. + ENDIF. + + + lt_list = mo_db->list_by_type( zcl_abapgit_persistence_db=>c_type_background ). + + LOOP AT lt_list ASSIGNING . + ls_xml = from_xml( -data_str ). + + APPEND INITIAL LINE TO rt_list ASSIGNING . + MOVE-CORRESPONDING ls_xml TO . + -key = -value. + ENDLOOP. + + mt_jobs = rt_list. + + ENDMETHOD. + + + METHOD modify. + + ASSERT NOT is_data-key IS INITIAL. + + mo_db->modify( + iv_type = zcl_abapgit_persistence_db=>c_type_background + iv_value = is_data-key + iv_data = to_xml( is_data ) ). + + DELETE mt_jobs WHERE key = is_data-key. + APPEND is_data TO mt_jobs. + + ENDMETHOD. + + + METHOD to_xml. + DATA: ls_xml TYPE ty_xml. + + MOVE-CORRESPONDING is_background TO ls_xml. + + CALL TRANSFORMATION id + SOURCE data = ls_xml + RESULT XML rv_string. + ENDMETHOD. +ENDCLASS. diff --git a/src/persist/zcl_abapgit_persist_background.clas.xml b/src/persist/zcl_abapgit_persist_background.clas.xml new file mode 100644 index 000000000..2208594ad --- /dev/null +++ b/src/persist/zcl_abapgit_persist_background.clas.xml @@ -0,0 +1,18 @@ + + + + + + ZCL_ABAPGIT_PERSIST_BACKGROUND + 1 + E + Persist background + 2 + 1 + X + X + X + + + + diff --git a/src/persist/zcl_abapgit_persist_migrate.clas.abap b/src/persist/zcl_abapgit_persist_migrate.clas.abap new file mode 100644 index 000000000..3717eb231 --- /dev/null +++ b/src/persist/zcl_abapgit_persist_migrate.clas.abap @@ -0,0 +1,414 @@ +CLASS zcl_abapgit_persist_migrate DEFINITION PUBLIC CREATE PUBLIC. + + PUBLIC SECTION. + CLASS-METHODS: run RAISING zcx_abapgit_exception. + + PRIVATE SECTION. + CONSTANTS: + c_text TYPE string VALUE 'Generated by abapGit' ##NO_TEXT. + + CLASS-METHODS: + migrate_settings + RAISING zcx_abapgit_exception, + table_create + RAISING zcx_abapgit_exception, + table_exists + RETURNING VALUE(rv_exists) TYPE abap_bool, + lock_create + RAISING zcx_abapgit_exception, + lock_exists + RETURNING VALUE(rv_exists) TYPE abap_bool, + settings_exists + RETURNING VALUE(rv_exists) TYPE abap_bool. + +ENDCLASS. + + + +CLASS ZCL_ABAPGIT_PERSIST_MIGRATE IMPLEMENTATION. + + + METHOD lock_create. + + DATA: lv_obj_name TYPE tadir-obj_name, + ls_dd25v TYPE dd25v, + lt_dd26e TYPE STANDARD TABLE OF dd26e WITH DEFAULT KEY, + lt_dd27p TYPE STANDARD TABLE OF dd27p WITH DEFAULT KEY. + + FIELD-SYMBOLS: LIKE LINE OF lt_dd26e, + LIKE LINE OF lt_dd27p. + + + ls_dd25v-viewname = zcl_abapgit_persistence_db=>c_lock. + ls_dd25v-aggtype = 'E'. + ls_dd25v-roottab = zcl_abapgit_persistence_db=>c_tabname. + ls_dd25v-ddlanguage = zif_abapgit_definitions=>gc_english. + ls_dd25v-ddtext = c_text. + + APPEND INITIAL LINE TO lt_dd26e ASSIGNING . + -viewname = zcl_abapgit_persistence_db=>c_lock. + -tabname = zcl_abapgit_persistence_db=>c_tabname. + -tabpos = '0001'. + -fortabname = zcl_abapgit_persistence_db=>c_tabname. + -enqmode = 'E'. + + APPEND INITIAL LINE TO lt_dd27p ASSIGNING . + -viewname = zcl_abapgit_persistence_db=>c_lock. + -objpos = '0001'. + -viewfield = 'TYPE'. + -tabname = zcl_abapgit_persistence_db=>c_tabname. + -fieldname = 'TYPE'. + -keyflag = abap_true. + + APPEND INITIAL LINE TO lt_dd27p ASSIGNING . + -viewname = zcl_abapgit_persistence_db=>c_lock. + -objpos = '0002'. + -viewfield = 'VALUE'. + -tabname = zcl_abapgit_persistence_db=>c_tabname. + -fieldname = 'VALUE'. + -keyflag = abap_true. + + CALL FUNCTION 'DDIF_ENQU_PUT' + EXPORTING + name = zcl_abapgit_persistence_db=>c_lock + dd25v_wa = ls_dd25v + TABLES + dd26e_tab = lt_dd26e + dd27p_tab = lt_dd27p + EXCEPTIONS + enqu_not_found = 1 + name_inconsistent = 2 + enqu_inconsistent = 3 + put_failure = 4 + put_refused = 5 + OTHERS = 6. + IF sy-subrc <> 0. + zcx_abapgit_exception=>raise( 'migrate, error from DDIF_ENQU_PUT' ). + ENDIF. + + lv_obj_name = zcl_abapgit_persistence_db=>c_lock. + CALL FUNCTION 'TR_TADIR_INTERFACE' + EXPORTING + wi_tadir_pgmid = 'R3TR' + wi_tadir_object = 'ENQU' + wi_tadir_obj_name = lv_obj_name + wi_set_genflag = abap_true + wi_test_modus = abap_false + wi_tadir_devclass = '$TMP' + EXCEPTIONS + OTHERS = 1. + IF sy-subrc <> 0. + zcx_abapgit_exception=>raise( 'migrate, error from TR_TADIR_INTERFACE' ). + ENDIF. + + CALL FUNCTION 'DDIF_ENQU_ACTIVATE' + EXPORTING + name = zcl_abapgit_persistence_db=>c_lock + EXCEPTIONS + not_found = 1 + put_failure = 2 + OTHERS = 3. + IF sy-subrc <> 0. + zcx_abapgit_exception=>raise( 'migrate, error from DDIF_ENQU_ACTIVATE' ). + ENDIF. + + ENDMETHOD. + + + METHOD lock_exists. + + DATA: lv_viewname TYPE dd25l-viewname. + + + SELECT SINGLE viewname FROM dd25l INTO lv_viewname + WHERE viewname = zcl_abapgit_persistence_db=>c_lock. + rv_exists = boolc( sy-subrc = 0 ). + + ENDMETHOD. + + + METHOD migrate_settings. + + DATA: lr_settings TYPE REF TO zcl_abapgit_settings. + DATA: lr_persist_settings TYPE REF TO zcl_abapgit_persist_settings. + DATA: lv_critical_tests_as_string TYPE string. + DATA: lv_critical_tests_as_boolean TYPE abap_bool. + DATA: lv_max_lines_as_string TYPE string. + DATA: lv_flag TYPE abap_bool. + DATA: lv_max_lines_as_integer TYPE i. + DATA: lv_s_param_value TYPE string. + DATA: lv_i_param_value TYPE i. + DATA: lv_adt_jump_enabled_as_string TYPE string. + DATA: lv_adt_jump_enabled_as_boolean TYPE abap_bool. + + + lr_persist_settings = zcl_abapgit_persist_settings=>get_instance( ). + + CREATE OBJECT lr_settings. + lr_settings->set_defaults( ). + + TRY. + lr_settings->set_proxy_url( + zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = 'SETTINGS' + iv_value = 'PROXY_URL' ) ). + CATCH zcx_abapgit_not_found. + ENDTRY. + + TRY. + lr_settings->set_proxy_port( + zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = 'SETTINGS' + iv_value = 'PROXY_PORT' ) ). + CATCH zcx_abapgit_not_found. + ENDTRY. + + TRY. + lv_flag = zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = 'SETTINGS' + iv_value = 'PROXY_AUTH' ). + lr_settings->set_proxy_authentication( lv_flag ). + CATCH zcx_abapgit_not_found. + ENDTRY. + + TRY. + lv_critical_tests_as_string = zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = 'SETTINGS' + iv_value = 'CRIT_TESTS' ). + lv_critical_tests_as_boolean = lv_critical_tests_as_string. + lr_settings->set_run_critical_tests( lv_critical_tests_as_boolean ). + CATCH zcx_abapgit_not_found. + ENDTRY. + + TRY. + lv_max_lines_as_string = zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = 'SETTINGS' + iv_value = 'MAX_LINES' ). + lv_max_lines_as_integer = lv_max_lines_as_string. + lr_settings->set_max_lines( lv_max_lines_as_integer ). + CATCH zcx_abapgit_not_found cx_sy_conversion_no_number. + ENDTRY. + + TRY. + lv_adt_jump_enabled_as_string = zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = 'SETTINGS' + iv_value = 'ADT_JUMP' ). + lv_adt_jump_enabled_as_boolean = lv_adt_jump_enabled_as_string. + lr_settings->set_adt_jump_enanbled( lv_adt_jump_enabled_as_boolean ). + CATCH zcx_abapgit_not_found. + ENDTRY. + + TRY. + lv_s_param_value = zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = 'SETTINGS' + iv_value = 'COMMENT_LEN' ). + lv_i_param_value = lv_s_param_value. + lr_settings->set_commitmsg_comment_length( lv_i_param_value ). + CATCH zcx_abapgit_not_found cx_sy_conversion_no_number. + ENDTRY. + + TRY. + lv_s_param_value = zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = 'SETTINGS' + iv_value = 'BODY_SIZE' ). + lv_i_param_value = lv_s_param_value. + lr_settings->set_commitmsg_body_size( lv_i_param_value ). + CATCH zcx_abapgit_not_found cx_sy_conversion_no_number. + ENDTRY. + + lr_persist_settings->modify( io_settings = lr_settings ). + + TRY. + zcl_abapgit_persistence_db=>get_instance( )->delete( + iv_type = 'SETTINGS' + iv_value = 'PROXY_URL' ). + CATCH zcx_abapgit_exception. + ENDTRY. + + TRY. + zcl_abapgit_persistence_db=>get_instance( )->delete( + iv_type = 'SETTINGS' + iv_value = 'PROXY_PORT' ). + CATCH zcx_abapgit_exception. + ENDTRY. + + TRY. + zcl_abapgit_persistence_db=>get_instance( )->delete( + iv_type = 'SETTINGS' + iv_value = 'PROXY_AUTH' ). + CATCH zcx_abapgit_exception. + ENDTRY. + + TRY. + zcl_abapgit_persistence_db=>get_instance( )->delete( + iv_type = 'SETTINGS' + iv_value = 'CRIT_TESTS' ). + CATCH zcx_abapgit_exception. + ENDTRY. + + TRY. + zcl_abapgit_persistence_db=>get_instance( )->delete( + iv_type = 'SETTINGS' + iv_value = 'MAX_LINES' ). + CATCH zcx_abapgit_exception. + ENDTRY. + + TRY. + zcl_abapgit_persistence_db=>get_instance( )->delete( + iv_type = 'SETTINGS' + iv_value = 'ADT_JUMP' ). + CATCH zcx_abapgit_exception. + ENDTRY. + + TRY. + zcl_abapgit_persistence_db=>get_instance( )->delete( + iv_type = 'SETTINGS' + iv_value = 'COMMENT_LEN' ). + CATCH zcx_abapgit_exception. + ENDTRY. + + TRY. + zcl_abapgit_persistence_db=>get_instance( )->delete( + iv_type = 'SETTINGS' + iv_value = 'BODY_SIZE' ). + CATCH zcx_abapgit_exception. + ENDTRY. + + ENDMETHOD. + + + METHOD run. + + IF table_exists( ) = abap_false. + table_create( ). + ENDIF. + + IF lock_exists( ) = abap_false. + lock_create( ). + ENDIF. + + IF settings_exists( ) = abap_false. + migrate_settings( ). + ENDIF. + + ENDMETHOD. + + + METHOD settings_exists. + + TRY. + zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = 'SETTINGS' + iv_value = '' ). + rv_exists = abap_true. + CATCH zcx_abapgit_not_found. + rv_exists = abap_false. + ENDTRY. + ENDMETHOD. + + + METHOD table_create. + + DATA: lv_rc LIKE sy-subrc, + lv_obj_name TYPE tadir-obj_name, + ls_dd02v TYPE dd02v, + ls_dd09l TYPE dd09l, + lt_dd03p TYPE STANDARD TABLE OF dd03p WITH DEFAULT KEY. + + FIELD-SYMBOLS: LIKE LINE OF lt_dd03p. + + ls_dd02v-tabname = zcl_abapgit_persistence_db=>c_tabname. + ls_dd02v-ddlanguage = zif_abapgit_definitions=>gc_english. + ls_dd02v-tabclass = 'TRANSP'. + ls_dd02v-ddtext = c_text. + ls_dd02v-contflag = 'A'. + ls_dd02v-exclass = '1'. + + ls_dd09l-tabname = zcl_abapgit_persistence_db=>c_tabname. + ls_dd09l-as4local = 'A'. + ls_dd09l-tabkat = '1'. + ls_dd09l-tabart = 'APPL1'. + ls_dd09l-bufallow = 'N'. + + APPEND INITIAL LINE TO lt_dd03p ASSIGNING . + -tabname = zcl_abapgit_persistence_db=>c_tabname. + -fieldname = 'TYPE'. + -position = '0001'. + -keyflag = 'X'. + -datatype = 'CHAR'. + -leng = '000012'. + + APPEND INITIAL LINE TO lt_dd03p ASSIGNING . + -tabname = zcl_abapgit_persistence_db=>c_tabname. + -fieldname = 'VALUE'. + -position = '0002'. + -keyflag = 'X'. + -datatype = 'CHAR'. + -leng = '000012'. + + APPEND INITIAL LINE TO lt_dd03p ASSIGNING . + -tabname = zcl_abapgit_persistence_db=>c_tabname. + -fieldname = 'DATA_STR'. + -position = '0003'. + -datatype = 'STRG'. + + CALL FUNCTION 'DDIF_TABL_PUT' + EXPORTING + name = zcl_abapgit_persistence_db=>c_tabname + dd02v_wa = ls_dd02v + dd09l_wa = ls_dd09l + TABLES + dd03p_tab = lt_dd03p + EXCEPTIONS + tabl_not_found = 1 + name_inconsistent = 2 + tabl_inconsistent = 3 + put_failure = 4 + put_refused = 5 + OTHERS = 6. + IF sy-subrc <> 0. + zcx_abapgit_exception=>raise( 'migrate, error from DDIF_TABL_PUT' ). + ENDIF. + + lv_obj_name = zcl_abapgit_persistence_db=>c_tabname. + CALL FUNCTION 'TR_TADIR_INTERFACE' + EXPORTING + wi_tadir_pgmid = 'R3TR' + wi_tadir_object = 'TABL' + wi_tadir_obj_name = lv_obj_name + wi_set_genflag = abap_true + wi_test_modus = abap_false + wi_tadir_devclass = '$TMP' + EXCEPTIONS + OTHERS = 1. + IF sy-subrc <> 0. + zcx_abapgit_exception=>raise( 'migrate, error from TR_TADIR_INTERFACE' ). + ENDIF. + + CALL FUNCTION 'DDIF_TABL_ACTIVATE' + EXPORTING + name = zcl_abapgit_persistence_db=>c_tabname + auth_chk = abap_false + IMPORTING + rc = lv_rc + EXCEPTIONS + not_found = 1 + put_failure = 2 + OTHERS = 3. + IF sy-subrc <> 0 OR lv_rc <> 0. + zcx_abapgit_exception=>raise( 'migrate, error from DDIF_TABL_ACTIVATE' ). + ENDIF. + + ENDMETHOD. + + + METHOD table_exists. + + DATA: lv_tabname TYPE dd02l-tabname. + + SELECT SINGLE tabname FROM dd02l INTO lv_tabname + WHERE tabname = zcl_abapgit_persistence_db=>c_tabname. + rv_exists = boolc( sy-subrc = 0 ). + + ENDMETHOD. +ENDCLASS. diff --git a/src/persist/zcl_abapgit_persist_migrate.clas.xml b/src/persist/zcl_abapgit_persist_migrate.clas.xml new file mode 100644 index 000000000..ed15f76db --- /dev/null +++ b/src/persist/zcl_abapgit_persist_migrate.clas.xml @@ -0,0 +1,18 @@ + + + + + + ZCL_ABAPGIT_PERSIST_MIGRATE + 1 + E + Migration + 2 + 1 + X + X + X + + + + diff --git a/src/persist/zcl_abapgit_persist_settings.clas.abap b/src/persist/zcl_abapgit_persist_settings.clas.abap new file mode 100644 index 000000000..ea416392e --- /dev/null +++ b/src/persist/zcl_abapgit_persist_settings.clas.abap @@ -0,0 +1,84 @@ +CLASS zcl_abapgit_persist_settings DEFINITION + PUBLIC + CREATE PRIVATE . + + PUBLIC SECTION. + + METHODS modify + IMPORTING + !io_settings TYPE REF TO zcl_abapgit_settings + RAISING + zcx_abapgit_exception . + METHODS read + RETURNING + VALUE(ro_settings) TYPE REF TO zcl_abapgit_settings . + CLASS-METHODS get_instance + RETURNING + VALUE(ro_settings) TYPE REF TO zcl_abapgit_persist_settings . + PRIVATE SECTION. + + DATA mo_settings TYPE REF TO zcl_abapgit_settings . + CLASS-DATA go_persist TYPE REF TO zcl_abapgit_persist_settings . +ENDCLASS. + + + +CLASS ZCL_ABAPGIT_PERSIST_SETTINGS IMPLEMENTATION. + + + METHOD get_instance. + + IF go_persist IS NOT BOUND. + CREATE OBJECT go_persist. + ENDIF. + ro_settings = go_persist. + + ENDMETHOD. + + + METHOD modify. + + DATA: settings TYPE string. + settings = io_settings->get_settings_xml( ). + + zcl_abapgit_persistence_db=>get_instance( )->modify( + iv_type = zcl_abapgit_persistence_db=>c_type_settings + iv_value = '' + iv_data = settings ). + + " Settings have been modified: Update Buffered Settings + IF mo_settings IS BOUND. + mo_settings->set_xml_settings( settings ). + ENDIF. + + ENDMETHOD. + + + METHOD read. + + IF mo_settings IS BOUND. + " Return Buffered Settings + ro_settings = mo_settings. + RETURN. + ENDIF. + + " Settings have changed or have not yet been loaded + CREATE OBJECT ro_settings. + + TRY. + + ro_settings->set_xml_settings( + zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = zcl_abapgit_persistence_db=>c_type_settings + iv_value = '' ) ). + + CATCH zcx_abapgit_not_found zcx_abapgit_exception. + + ro_settings->set_defaults( ). + + ENDTRY. + + mo_settings = ro_settings. + + ENDMETHOD. +ENDCLASS. diff --git a/src/persist/zcl_abapgit_persist_settings.clas.xml b/src/persist/zcl_abapgit_persist_settings.clas.xml new file mode 100644 index 000000000..a79e19bc1 --- /dev/null +++ b/src/persist/zcl_abapgit_persist_settings.clas.xml @@ -0,0 +1,25 @@ + + + + + + ZCL_ABAPGIT_PERSIST_SETTINGS + 1 + E + Settings + 1 + X + X + X + + + + ZCL_ABAPGIT_PERSIST_SETTINGS + GO_PERSIST + E + Settings + + + + + diff --git a/src/persist/zcl_abapgit_persistence_db.clas.abap b/src/persist/zcl_abapgit_persistence_db.clas.abap index 1557606ba..ca2daa852 100644 --- a/src/persist/zcl_abapgit_persistence_db.clas.abap +++ b/src/persist/zcl_abapgit_persistence_db.clas.abap @@ -1,70 +1,93 @@ CLASS zcl_abapgit_persistence_db DEFINITION PUBLIC - CREATE PUBLIC . + CREATE PRIVATE . PUBLIC SECTION. - CONSTANTS: - c_tabname TYPE tabname VALUE 'ZABAPGIT', - c_lock TYPE viewname VALUE 'EZABAPGIT'. - TYPES: ty_type TYPE c LENGTH 12. - TYPES: ty_value TYPE c LENGTH 12. + TYPES: + ty_type TYPE c LENGTH 12 . + TYPES: + ty_value TYPE c LENGTH 12 . + TYPES: + BEGIN OF ty_content, + type TYPE ty_type, + value TYPE ty_value, + data_str TYPE string, + END OF ty_content . + TYPES: + tt_content TYPE SORTED TABLE OF ty_content WITH UNIQUE KEY type value . - TYPES: BEGIN OF ty_content, - type TYPE ty_type, - value TYPE ty_value, - data_str TYPE string, - END OF ty_content, - tt_content TYPE SORTED TABLE OF ty_content WITH UNIQUE KEY type value. - - CONSTANTS: - c_type_settings TYPE ty_type VALUE 'SETTINGS', - c_type_repo TYPE ty_type VALUE 'REPO', - c_type_background TYPE ty_type VALUE 'BACKGROUND', - c_type_user TYPE ty_type VALUE 'USER'. - - METHODS: - list_by_type - IMPORTING iv_type TYPE ty_type - RETURNING VALUE(rt_content) TYPE tt_content, - list - RETURNING VALUE(rt_content) TYPE tt_content, - add - IMPORTING iv_type TYPE ty_type - iv_value TYPE ty_content-value - iv_data TYPE ty_content-data_str - RAISING zcx_abapgit_exception, - delete - IMPORTING iv_type TYPE ty_type - iv_value TYPE ty_content-value - RAISING zcx_abapgit_exception, - update - IMPORTING iv_type TYPE ty_type - iv_value TYPE ty_content-value - iv_data TYPE ty_content-data_str - RAISING zcx_abapgit_exception, - modify - IMPORTING iv_type TYPE ty_type - iv_value TYPE ty_content-value - iv_data TYPE ty_content-data_str - RAISING zcx_abapgit_exception, - read - IMPORTING iv_type TYPE ty_type - iv_value TYPE ty_content-value - RETURNING VALUE(rv_data) TYPE ty_content-data_str - RAISING zcx_abapgit_not_found, - lock - IMPORTING iv_mode TYPE enqmode DEFAULT 'E' - iv_type TYPE ty_type - iv_value TYPE ty_content-value - RAISING zcx_abapgit_exception. + CONSTANTS c_tabname TYPE tabname VALUE 'ZABAPGIT' ##NO_TEXT. + CONSTANTS c_lock TYPE viewname VALUE 'EZABAPGIT' ##NO_TEXT. + CONSTANTS c_type_settings TYPE ty_type VALUE 'SETTINGS' ##NO_TEXT. + CONSTANTS c_type_repo TYPE ty_type VALUE 'REPO' ##NO_TEXT. + CONSTANTS c_type_background TYPE ty_type VALUE 'BACKGROUND' ##NO_TEXT. + CONSTANTS c_type_user TYPE ty_type VALUE 'USER' ##NO_TEXT. + CLASS-METHODS get_instance + RETURNING + VALUE(ro_db) TYPE REF TO zcl_abapgit_persistence_db . + METHODS add + IMPORTING + !iv_type TYPE ty_type + !iv_value TYPE ty_content-value + !iv_data TYPE ty_content-data_str + RAISING + zcx_abapgit_exception . + METHODS delete + IMPORTING + !iv_type TYPE ty_type + !iv_value TYPE ty_content-value + RAISING + zcx_abapgit_exception . + METHODS list + RETURNING + VALUE(rt_content) TYPE tt_content . + METHODS list_by_type + IMPORTING + !iv_type TYPE ty_type + RETURNING + VALUE(rt_content) TYPE tt_content . + METHODS lock + IMPORTING + !iv_mode TYPE enqmode DEFAULT 'E' + !iv_type TYPE ty_type + !iv_value TYPE ty_content-value + RAISING + zcx_abapgit_exception . + METHODS modify + IMPORTING + !iv_type TYPE ty_type + !iv_value TYPE ty_content-value + !iv_data TYPE ty_content-data_str + RAISING + zcx_abapgit_exception . + METHODS read + IMPORTING + !iv_type TYPE ty_type + !iv_value TYPE ty_content-value + RETURNING + VALUE(rv_data) TYPE ty_content-data_str + RAISING + zcx_abapgit_not_found . + METHODS update + IMPORTING + !iv_type TYPE ty_type + !iv_value TYPE ty_content-value + !iv_data TYPE ty_content-data_str + RAISING + zcx_abapgit_exception . PRIVATE SECTION. - METHODS: validate_and_unprettify_xml - IMPORTING iv_xml TYPE string - RETURNING VALUE(rv_xml) TYPE string - RAISING zcx_abapgit_exception. + CLASS-DATA mo_db TYPE REF TO zcl_abapgit_persistence_db . + + METHODS validate_and_unprettify_xml + IMPORTING + !iv_xml TYPE string + RETURNING + VALUE(rv_xml) TYPE string + RAISING + zcx_abapgit_exception . ENDCLASS. @@ -74,8 +97,6 @@ CLASS ZCL_ABAPGIT_PERSISTENCE_DB IMPLEMENTATION. METHOD add. -* todo, change instantiation back to private? make sure this class is a singleton? - DATA ls_table TYPE ty_content. ls_table-type = iv_type. @@ -103,6 +124,16 @@ CLASS ZCL_ABAPGIT_PERSISTENCE_DB IMPLEMENTATION. ENDMETHOD. + METHOD get_instance. + + IF mo_db IS NOT BOUND. + CREATE OBJECT mo_db. + ENDIF. + ro_db = mo_db. + + ENDMETHOD. + + METHOD list. SELECT * FROM (c_tabname) INTO TABLE rt_content. "#EC CI_SUBRC diff --git a/src/persist/zcl_abapgit_persistence_db.clas.xml b/src/persist/zcl_abapgit_persistence_db.clas.xml index a0c49aa65..bf36b5c26 100644 --- a/src/persist/zcl_abapgit_persistence_db.clas.xml +++ b/src/persist/zcl_abapgit_persistence_db.clas.xml @@ -7,12 +7,19 @@ 1 E Database persistence - 2 1 X X X + + + ZCL_ABAPGIT_PERSISTENCE_DB + MO_DB + E + Database persistence + + diff --git a/src/persist/zcl_abapgit_persistence_repo.clas.abap b/src/persist/zcl_abapgit_persistence_repo.clas.abap new file mode 100644 index 000000000..82ef1278b --- /dev/null +++ b/src/persist/zcl_abapgit_persistence_repo.clas.abap @@ -0,0 +1,444 @@ +CLASS zcl_abapgit_persistence_repo DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. + TYPES: BEGIN OF ty_local_checksum, + item TYPE zif_abapgit_definitions=>ty_item, + files TYPE zif_abapgit_definitions=>ty_file_signatures_tt, + END OF ty_local_checksum. + + TYPES: ty_local_checksum_tt TYPE STANDARD TABLE OF ty_local_checksum WITH DEFAULT KEY. + + TYPES: BEGIN OF ty_repo_xml, + url TYPE string, + branch_name TYPE string, + sha1 TYPE zif_abapgit_definitions=>ty_sha1, + package TYPE devclass, + offline TYPE sap_bool, + local_checksums TYPE ty_local_checksum_tt, + dot_abapgit TYPE zcl_abapgit_dot_abapgit=>ty_dot_abapgit, + head_branch TYPE string, " HEAD symref of the repo, master branch + write_protect TYPE sap_bool, " Deny destructive ops: pull, switch branch ... + ignore_subpackages TYPE sap_bool, + END OF ty_repo_xml. + + TYPES: BEGIN OF ty_repo, + key TYPE zcl_abapgit_persistence_db=>ty_value. + INCLUDE TYPE ty_repo_xml. + TYPES: END OF ty_repo. + TYPES: tt_repo TYPE STANDARD TABLE OF ty_repo WITH DEFAULT KEY. + TYPES: tt_repo_keys TYPE STANDARD TABLE OF ty_repo-key WITH DEFAULT KEY. + + METHODS constructor. + + METHODS list + RETURNING VALUE(rt_repos) TYPE tt_repo + RAISING zcx_abapgit_exception. + + METHODS update_sha1 + IMPORTING iv_key TYPE ty_repo-key + iv_branch_sha1 TYPE ty_repo_xml-sha1 + RAISING zcx_abapgit_exception. + + METHODS update_local_checksums + IMPORTING iv_key TYPE ty_repo-key + it_checksums TYPE ty_repo_xml-local_checksums + RAISING zcx_abapgit_exception. + + METHODS update_url + IMPORTING iv_key TYPE ty_repo-key + iv_url TYPE ty_repo_xml-url + RAISING zcx_abapgit_exception. + + METHODS update_branch_name + IMPORTING iv_key TYPE ty_repo-key + iv_branch_name TYPE ty_repo_xml-branch_name + RAISING zcx_abapgit_exception. + + METHODS update_head_branch + IMPORTING iv_key TYPE ty_repo-key + iv_head_branch TYPE ty_repo_xml-head_branch + RAISING zcx_abapgit_exception. + + METHODS update_offline + IMPORTING iv_key TYPE ty_repo-key + iv_offline TYPE ty_repo_xml-offline + RAISING zcx_abapgit_exception. + + METHODS update_dot_abapgit + IMPORTING iv_key TYPE ty_repo-key + is_dot_abapgit TYPE zcl_abapgit_dot_abapgit=>ty_dot_abapgit + RAISING zcx_abapgit_exception. + + METHODS add + IMPORTING iv_url TYPE string + iv_branch_name TYPE string + iv_branch TYPE zif_abapgit_definitions=>ty_sha1 OPTIONAL + iv_package TYPE devclass + iv_offline TYPE sap_bool DEFAULT abap_false + is_dot_abapgit TYPE zcl_abapgit_dot_abapgit=>ty_dot_abapgit + RETURNING VALUE(rv_key) TYPE ty_repo-key + RAISING zcx_abapgit_exception. + + METHODS delete + IMPORTING iv_key TYPE ty_repo-key + RAISING zcx_abapgit_exception. + + METHODS read + IMPORTING iv_key TYPE ty_repo-key + RETURNING VALUE(rs_repo) TYPE ty_repo + RAISING zcx_abapgit_exception + zcx_abapgit_not_found. + + METHODS lock + IMPORTING iv_mode TYPE enqmode + iv_key TYPE ty_repo-key + RAISING zcx_abapgit_exception. + + PRIVATE SECTION. + DATA: mo_db TYPE REF TO zcl_abapgit_persistence_db. + + METHODS from_xml + IMPORTING iv_repo_xml_string TYPE string + RETURNING VALUE(rs_repo) TYPE ty_repo_xml + RAISING zcx_abapgit_exception. + + METHODS to_xml + IMPORTING is_repo TYPE ty_repo + RETURNING VALUE(rv_repo_xml_string) TYPE string. + + METHODS get_next_id + RETURNING VALUE(rv_next_repo_id) TYPE zcl_abapgit_persistence_db=>ty_content-value + RAISING zcx_abapgit_exception. + +ENDCLASS. + + + +CLASS ZCL_ABAPGIT_PERSISTENCE_REPO IMPLEMENTATION. + + + METHOD add. + + DATA: ls_repo TYPE ty_repo, + lv_repo_as_xml TYPE string. + + + ls_repo-url = iv_url. + ls_repo-branch_name = iv_branch_name. + ls_repo-sha1 = iv_branch. + ls_repo-package = iv_package. + ls_repo-offline = iv_offline. + ls_repo-dot_abapgit = is_dot_abapgit. + + lv_repo_as_xml = to_xml( ls_repo ). + + rv_key = get_next_id( ). + + mo_db->add( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = rv_key + iv_data = lv_repo_as_xml ). + + ENDMETHOD. + + + METHOD constructor. + mo_db = zcl_abapgit_persistence_db=>get_instance( ). + ENDMETHOD. + + + METHOD delete. + + DATA: lo_background TYPE REF TO zcl_abapgit_persist_background. + + CREATE OBJECT lo_background. + lo_background->delete( iv_key ). + + mo_db->delete( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key ). + + ENDMETHOD. + + + METHOD from_xml. + + DATA: lv_xml TYPE string. + + lv_xml = iv_repo_xml_string. + +* fix downward compatibility + REPLACE ALL OCCURRENCES OF '<_--28C_TYPE_REPO_--29>' IN lv_xml WITH ''. + REPLACE ALL OCCURRENCES OF '' IN lv_xml WITH ''. + + CALL TRANSFORMATION id + OPTIONS value_handling = 'accept_data_loss' + SOURCE XML lv_xml + RESULT repo = rs_repo ##NO_TEXT. + + IF rs_repo IS INITIAL. + zcx_abapgit_exception=>raise( 'Inconsistent repo metadata' ). + ENDIF. + + ENDMETHOD. + + + METHOD get_next_id. + +* todo: Lock the complete persistence in order to prevent concurrent repo-creation +* however the current approach will most likely work in almost all cases + + DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content. + + FIELD-SYMBOLS: LIKE LINE OF lt_content. + + + rv_next_repo_id = 1. + + lt_content = mo_db->list_by_type( zcl_abapgit_persistence_db=>c_type_repo ). + LOOP AT lt_content ASSIGNING . + IF -value >= rv_next_repo_id. + rv_next_repo_id = -value + 1. + ENDIF. + ENDLOOP. + + CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' + EXPORTING + input = rv_next_repo_id + IMPORTING + output = rv_next_repo_id. + + ENDMETHOD. + + + METHOD list. + + DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, + ls_content LIKE LINE OF lt_content, + ls_repo LIKE LINE OF rt_repos. + + + lt_content = mo_db->list_by_type( zcl_abapgit_persistence_db=>c_type_repo ). + + LOOP AT lt_content INTO ls_content. + MOVE-CORRESPONDING from_xml( ls_content-data_str ) TO ls_repo. + ls_repo-key = ls_content-value. + INSERT ls_repo INTO TABLE rt_repos. + ENDLOOP. + + ENDMETHOD. + + + METHOD lock. + + mo_db->lock( iv_mode = iv_mode + iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key ). + + ENDMETHOD. + + + METHOD read. + + DATA lt_repo TYPE tt_repo. + + lt_repo = list( ). + + READ TABLE lt_repo INTO rs_repo WITH KEY key = iv_key. + IF sy-subrc <> 0. + RAISE EXCEPTION TYPE zcx_abapgit_not_found. + ENDIF. + + ENDMETHOD. + + + METHOD to_xml. + + DATA: ls_xml TYPE ty_repo_xml. + + + MOVE-CORRESPONDING is_repo TO ls_xml. + + CALL TRANSFORMATION id + SOURCE repo = ls_xml + RESULT XML rv_repo_xml_string. + ENDMETHOD. + + + METHOD update_branch_name. + + DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, + ls_content LIKE LINE OF lt_content, + ls_repo TYPE ty_repo. + + + ASSERT NOT iv_key IS INITIAL. + + TRY. + ls_repo = read( iv_key ). + CATCH zcx_abapgit_not_found. + zcx_abapgit_exception=>raise( 'key not found' ). + ENDTRY. + + ls_repo-branch_name = iv_branch_name. + ls_content-data_str = to_xml( ls_repo ). + + mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key + iv_data = ls_content-data_str ). + + ENDMETHOD. + + + METHOD update_dot_abapgit. + + DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, + ls_content LIKE LINE OF lt_content, + ls_repo TYPE ty_repo. + + + ASSERT NOT iv_key IS INITIAL. + + TRY. + ls_repo = read( iv_key ). + CATCH zcx_abapgit_not_found. + zcx_abapgit_exception=>raise( 'key not found' ). + ENDTRY. + + ls_repo-dot_abapgit = is_dot_abapgit. + ls_content-data_str = to_xml( ls_repo ). + + mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key + iv_data = ls_content-data_str ). + + ENDMETHOD. + + + METHOD update_head_branch. + + DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, + ls_content LIKE LINE OF lt_content, + ls_repo TYPE ty_repo. + + + ASSERT NOT iv_key IS INITIAL. + + TRY. + ls_repo = read( iv_key ). + CATCH zcx_abapgit_not_found. + zcx_abapgit_exception=>raise( 'key not found' ). + ENDTRY. + + ls_repo-head_branch = iv_head_branch. + ls_content-data_str = to_xml( ls_repo ). + + mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key + iv_data = ls_content-data_str ). + + ENDMETHOD. "update_head_branch + + + METHOD update_local_checksums. + + DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, + ls_content LIKE LINE OF lt_content, + ls_repo TYPE ty_repo. + + + ASSERT NOT iv_key IS INITIAL. + + TRY. + ls_repo = read( iv_key ). + CATCH zcx_abapgit_not_found. + zcx_abapgit_exception=>raise( 'key not found' ). + ENDTRY. + + ls_repo-local_checksums = it_checksums. + ls_content-data_str = to_xml( ls_repo ). + + mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key + iv_data = ls_content-data_str ). + + ENDMETHOD. + + + METHOD update_offline. + + DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, + ls_content LIKE LINE OF lt_content, + ls_repo TYPE ty_repo. + + ASSERT NOT iv_key IS INITIAL. + + TRY. + ls_repo = read( iv_key ). + CATCH zcx_abapgit_not_found. + zcx_abapgit_exception=>raise( 'key not found' ). + ENDTRY. + + ls_repo-offline = iv_offline. + ls_content-data_str = to_xml( ls_repo ). + + mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key + iv_data = ls_content-data_str ). + + ENDMETHOD. "update_offline + + + METHOD update_sha1. + + DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, + ls_content LIKE LINE OF lt_content, + ls_repo TYPE ty_repo. + + + ASSERT NOT iv_key IS INITIAL. + + TRY. + ls_repo = read( iv_key ). + CATCH zcx_abapgit_not_found. + zcx_abapgit_exception=>raise( 'key not found' ). + ENDTRY. + + ls_repo-sha1 = iv_branch_sha1. + ls_content-data_str = to_xml( ls_repo ). + + mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key + iv_data = ls_content-data_str ). + + ENDMETHOD. + + + METHOD update_url. + + DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, + ls_content LIKE LINE OF lt_content, + ls_repo TYPE ty_repo. + + + IF iv_url IS INITIAL. + zcx_abapgit_exception=>raise( 'update, url empty' ). + ENDIF. + + ASSERT NOT iv_key IS INITIAL. + + TRY. + ls_repo = read( iv_key ). + CATCH zcx_abapgit_not_found. + zcx_abapgit_exception=>raise( 'key not found' ). + ENDTRY. + + ls_repo-url = iv_url. + ls_content-data_str = to_xml( ls_repo ). + + mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo + iv_value = iv_key + iv_data = ls_content-data_str ). + + ENDMETHOD. +ENDCLASS. diff --git a/src/persist/zcl_abapgit_persistence_repo.clas.xml b/src/persist/zcl_abapgit_persistence_repo.clas.xml new file mode 100644 index 000000000..2b10c76ef --- /dev/null +++ b/src/persist/zcl_abapgit_persistence_repo.clas.xml @@ -0,0 +1,18 @@ + + + + + + ZCL_ABAPGIT_PERSISTENCE_REPO + 1 + E + Repo persistence + 2 + 1 + X + X + X + + + + diff --git a/src/persist/zcl_abapgit_persistence_user.clas.abap b/src/persist/zcl_abapgit_persistence_user.clas.abap new file mode 100644 index 000000000..3e19f8b3a --- /dev/null +++ b/src/persist/zcl_abapgit_persistence_user.clas.abap @@ -0,0 +1,554 @@ +CLASS zcl_abapgit_persistence_user DEFINITION + PUBLIC + CREATE PRIVATE . + + PUBLIC SECTION. + + TYPES tt_favorites TYPE zcl_abapgit_persistence_repo=>tt_repo_keys . + + CLASS-METHODS get_instance + IMPORTING + !iv_user TYPE xubname DEFAULT sy-uname + RETURNING + VALUE(ro_user) TYPE REF TO zcl_abapgit_persistence_user . + METHODS get_changes_only + RETURNING + VALUE(rv_changes_only) TYPE abap_bool + RAISING + zcx_abapgit_exception . + METHODS get_default_git_user_email + RETURNING + VALUE(rv_email) TYPE string + RAISING + zcx_abapgit_exception . + METHODS get_default_git_user_name + RETURNING + VALUE(rv_username) TYPE string + RAISING + zcx_abapgit_exception . + METHODS get_diff_unified + RETURNING + VALUE(rv_diff_unified) TYPE abap_bool + RAISING + zcx_abapgit_exception . + METHODS get_favorites + RETURNING + VALUE(rt_favorites) TYPE tt_favorites + RAISING + zcx_abapgit_exception . + METHODS get_hide_files + RETURNING + VALUE(rv_hide) TYPE abap_bool + RAISING + zcx_abapgit_exception . + METHODS get_repo_git_user_email + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + RETURNING + VALUE(rv_email) TYPE string + RAISING + zcx_abapgit_exception . + METHODS get_repo_git_user_name + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + RETURNING + VALUE(rv_username) TYPE string + RAISING + zcx_abapgit_exception . + METHODS get_repo_last_change_seen + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + RETURNING + VALUE(rv_version) TYPE string + RAISING + zcx_abapgit_exception . + METHODS get_repo_login + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + RETURNING + VALUE(rv_login) TYPE string + RAISING + zcx_abapgit_exception . + METHODS get_repo_show + RETURNING + VALUE(rv_key) TYPE zcl_abapgit_persistence_repo=>ty_repo-key + RAISING + zcx_abapgit_exception . + METHODS is_favorite_repo + IMPORTING + !iv_repo_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key + RETURNING + VALUE(rv_yes) TYPE abap_bool + RAISING + zcx_abapgit_exception . + METHODS set_default_git_user_email + IMPORTING + !iv_email TYPE string + RAISING + zcx_abapgit_exception . + METHODS set_default_git_user_name + IMPORTING + !iv_username TYPE string + RAISING + zcx_abapgit_exception . + METHODS set_repo_git_user_email + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + !iv_email TYPE string + RAISING + zcx_abapgit_exception . + METHODS set_repo_git_user_name + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + !iv_username TYPE string + RAISING + zcx_abapgit_exception . + METHODS set_repo_last_change_seen + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + !iv_version TYPE string + RAISING + zcx_abapgit_exception . + METHODS set_repo_login + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + !iv_login TYPE string + RAISING + zcx_abapgit_exception . + METHODS set_repo_show + IMPORTING + !iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key + RAISING + zcx_abapgit_exception . + METHODS toggle_changes_only + RETURNING + VALUE(rv_changes_only) TYPE abap_bool + RAISING + zcx_abapgit_exception . + METHODS toggle_diff_unified + RETURNING + VALUE(rv_diff_unified) TYPE abap_bool + RAISING + zcx_abapgit_exception . + METHODS toggle_favorite + IMPORTING + !iv_repo_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key + RAISING + zcx_abapgit_exception . + METHODS toggle_hide_files + RETURNING + VALUE(rv_hide) TYPE abap_bool + RAISING + zcx_abapgit_exception . + PRIVATE SECTION. + + TYPES: + BEGIN OF ty_repo_config, + url TYPE zcl_abapgit_persistence_repo=>ty_repo-url, + login TYPE string, + git_user TYPE zif_abapgit_definitions=>ty_git_user, + last_change_seen TYPE string, + END OF ty_repo_config . + TYPES: + ty_repo_config_tt TYPE STANDARD TABLE OF ty_repo_config WITH DEFAULT KEY . + TYPES: + BEGIN OF ty_user, + default_git_user TYPE zif_abapgit_definitions=>ty_git_user, + repo_show TYPE zcl_abapgit_persistence_repo=>ty_repo-key, + hide_files TYPE abap_bool, + changes_only TYPE abap_bool, + diff_unified TYPE abap_bool, + favorites TYPE tt_favorites, + repo_config TYPE ty_repo_config_tt, + END OF ty_user . + + DATA mv_user TYPE xubname . + CLASS-DATA go_current_user TYPE REF TO zcl_abapgit_persistence_user . + + METHODS constructor + IMPORTING + !iv_user TYPE xubname DEFAULT sy-uname . + METHODS from_xml + IMPORTING + !iv_xml TYPE string + RETURNING + VALUE(rs_user) TYPE ty_user + RAISING + zcx_abapgit_exception . + METHODS read + RETURNING + VALUE(rs_user) TYPE ty_user + RAISING + zcx_abapgit_exception . + METHODS read_repo_config + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + RETURNING + VALUE(rs_repo_config) TYPE ty_repo_config + RAISING + zcx_abapgit_exception . + METHODS to_xml + IMPORTING + !is_user TYPE ty_user + RETURNING + VALUE(rv_xml) TYPE string . + METHODS update + IMPORTING + !is_user TYPE ty_user + RAISING + zcx_abapgit_exception . + METHODS update_repo_config + IMPORTING + !iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + !is_repo_config TYPE ty_repo_config + RAISING + zcx_abapgit_exception . +ENDCLASS. + + + +CLASS ZCL_ABAPGIT_PERSISTENCE_USER IMPLEMENTATION. + + + METHOD constructor. + mv_user = iv_user. + ENDMETHOD. + + + METHOD from_xml. + + DATA: lv_xml TYPE string. + + lv_xml = iv_xml. + +* fix downward compatibility + REPLACE ALL OCCURRENCES OF '<_--28C_TYPE_USER_--29>' IN lv_xml WITH ''. + REPLACE ALL OCCURRENCES OF '' IN lv_xml WITH ''. + + CALL TRANSFORMATION id + OPTIONS value_handling = 'accept_data_loss' + SOURCE XML lv_xml + RESULT user = rs_user ##NO_TEXT. + ENDMETHOD. + + + METHOD get_changes_only. + + rv_changes_only = read( )-changes_only. + + ENDMETHOD. "get_changes_only + + + METHOD get_default_git_user_email. + + rv_email = read( )-default_git_user-email. + + ENDMETHOD. + + + METHOD get_default_git_user_name. + + rv_username = read( )-default_git_user-name. + + ENDMETHOD. + + + METHOD get_diff_unified. + + rv_diff_unified = read( )-diff_unified. + + ENDMETHOD. "get_diff_unified + + + METHOD get_favorites. + + rt_favorites = read( )-favorites. + + ENDMETHOD. "get_favorites + + + METHOD get_hide_files. + + rv_hide = read( )-hide_files. + + ENDMETHOD. "get_hide_files + + + METHOD get_instance. + + IF iv_user = sy-uname ##USER_OK. + IF go_current_user IS NOT BOUND. + CREATE OBJECT go_current_user. + ENDIF. + ro_user = go_current_user. + ELSE. + CREATE OBJECT ro_user + EXPORTING + iv_user = iv_user. + ENDIF. + + ENDMETHOD. + + + METHOD get_repo_git_user_email. + + rv_email = read_repo_config( iv_url )-git_user-email. + + ENDMETHOD. "get_repo_email + + + METHOD get_repo_git_user_name. + + rv_username = read_repo_config( iv_url )-git_user-name. + + ENDMETHOD. "get_repo_username + + + METHOD get_repo_last_change_seen. + + rv_version = read_repo_config( iv_url )-last_change_seen. + + ENDMETHOD. "get_last_change_seen + + + METHOD get_repo_login. + + rv_login = read_repo_config( iv_url )-login. + + ENDMETHOD. "get_repo_login + + + METHOD get_repo_show. + + rv_key = read( )-repo_show. + + ENDMETHOD. + + + METHOD is_favorite_repo. + + DATA: lt_favorites TYPE tt_favorites. + + lt_favorites = get_favorites( ). + + READ TABLE lt_favorites TRANSPORTING NO FIELDS + WITH KEY table_line = iv_repo_key. + + rv_yes = boolc( sy-subrc = 0 ). + + ENDMETHOD. " is_favorite_repo. + + + METHOD read. + + DATA: lv_xml TYPE string. + + TRY. + lv_xml = zcl_abapgit_persistence_db=>get_instance( )->read( + iv_type = zcl_abapgit_persistence_db=>c_type_user + iv_value = mv_user ). + CATCH zcx_abapgit_not_found. + RETURN. + ENDTRY. + + rs_user = from_xml( lv_xml ). + + ENDMETHOD. + + + METHOD read_repo_config. + DATA: lt_repo_config TYPE ty_repo_config_tt, + lv_key TYPE string. + + lv_key = to_lower( iv_url ). + lt_repo_config = read( )-repo_config. + READ TABLE lt_repo_config INTO rs_repo_config WITH KEY url = lv_key. + + ENDMETHOD. "read_repo_config + + + METHOD set_default_git_user_email. + + DATA: ls_user TYPE ty_user. + + + ls_user = read( ). + ls_user-default_git_user-email = iv_email. + update( ls_user ). + + ENDMETHOD. + + + METHOD set_default_git_user_name. + + DATA: ls_user TYPE ty_user. + + + ls_user = read( ). + + ls_user-default_git_user-name = iv_username. + + update( ls_user ). + + ENDMETHOD. + + + METHOD set_repo_git_user_email. + + DATA: ls_repo_config TYPE ty_repo_config. + + ls_repo_config = read_repo_config( iv_url ). + ls_repo_config-git_user-email = iv_email. + update_repo_config( iv_url = iv_url is_repo_config = ls_repo_config ). + + ENDMETHOD. "set_repo_email + + + METHOD set_repo_git_user_name. + + DATA: ls_repo_config TYPE ty_repo_config. + + ls_repo_config = read_repo_config( iv_url ). + ls_repo_config-git_user-name = iv_username. + update_repo_config( iv_url = iv_url is_repo_config = ls_repo_config ). + + ENDMETHOD. "set_repo_username + + + METHOD set_repo_last_change_seen. + + DATA: ls_repo_config TYPE ty_repo_config. + + ls_repo_config = read_repo_config( iv_url ). + ls_repo_config-last_change_seen = iv_version. + update_repo_config( iv_url = iv_url is_repo_config = ls_repo_config ). + + ENDMETHOD. "set_last_change_seen + + + METHOD set_repo_login. + + DATA: ls_repo_config TYPE ty_repo_config. + + ls_repo_config = read_repo_config( iv_url ). + ls_repo_config-login = iv_login. + update_repo_config( iv_url = iv_url is_repo_config = ls_repo_config ). + + ENDMETHOD. "set_repo_login + + + METHOD set_repo_show. + + DATA: ls_user TYPE ty_user. + + + ls_user = read( ). + ls_user-repo_show = iv_key. + update( ls_user ). + + COMMIT WORK AND WAIT. + + ENDMETHOD. + + + METHOD toggle_changes_only. + + DATA ls_user TYPE ty_user. + + ls_user = read( ). + ls_user-changes_only = boolc( ls_user-changes_only = abap_false ). + update( ls_user ). + + rv_changes_only = ls_user-changes_only. + + ENDMETHOD. "toggle_changes_only + + + METHOD toggle_diff_unified. + + DATA ls_user TYPE ty_user. + + ls_user = read( ). + ls_user-diff_unified = boolc( ls_user-diff_unified = abap_false ). + update( ls_user ). + + rv_diff_unified = ls_user-diff_unified. + + ENDMETHOD. "toggle_diff_unified + + + METHOD toggle_favorite. + + DATA: ls_user TYPE ty_user. + + ls_user = read( ). + + READ TABLE ls_user-favorites TRANSPORTING NO FIELDS + WITH KEY table_line = iv_repo_key. + + IF sy-subrc = 0. + DELETE ls_user-favorites INDEX sy-tabix. + ELSE. + APPEND iv_repo_key TO ls_user-favorites. + ENDIF. + + update( ls_user ). + + ENDMETHOD. " toggle_favorite. + + + METHOD toggle_hide_files. + + DATA ls_user TYPE ty_user. + + ls_user = read( ). + ls_user-hide_files = boolc( ls_user-hide_files = abap_false ). + update( ls_user ). + + rv_hide = ls_user-hide_files. + + ENDMETHOD. "toggle_hide_files + + + METHOD to_xml. + CALL TRANSFORMATION id + SOURCE user = is_user + RESULT XML rv_xml. + ENDMETHOD. + + + METHOD update. + + DATA: lv_xml TYPE string. + + lv_xml = to_xml( is_user ). + + zcl_abapgit_persistence_db=>get_instance( )->modify( + iv_type = zcl_abapgit_persistence_db=>c_type_user + iv_value = mv_user + iv_data = lv_xml ). + + ENDMETHOD. + + + METHOD update_repo_config. + DATA: ls_user TYPE ty_user, + lv_key TYPE string. + FIELD-SYMBOLS TYPE ty_repo_config. + + ls_user = read( ). + lv_key = to_lower( iv_url ). + + READ TABLE ls_user-repo_config ASSIGNING WITH KEY url = lv_key. + IF sy-subrc IS NOT INITIAL. + APPEND INITIAL LINE TO ls_user-repo_config ASSIGNING . + ENDIF. + = is_repo_config. + -url = lv_key. + + update( ls_user ). + + COMMIT WORK AND WAIT. + + ENDMETHOD. "update_repo_config +ENDCLASS. diff --git a/src/persist/zcl_abapgit_persistence_user.clas.xml b/src/persist/zcl_abapgit_persistence_user.clas.xml new file mode 100644 index 000000000..6e6a2029d --- /dev/null +++ b/src/persist/zcl_abapgit_persistence_user.clas.xml @@ -0,0 +1,25 @@ + + + + + + ZCL_ABAPGIT_PERSISTENCE_USER + 1 + E + User persistence + 1 + X + X + X + + + + ZCL_ABAPGIT_PERSISTENCE_USER + GO_CURRENT_USER + E + User persistence + + + + + diff --git a/src/zabapgit_2fa.prog.abap b/src/zabapgit_2fa.prog.abap index f922931b6..6ceeed262 100644 --- a/src/zabapgit_2fa.prog.abap +++ b/src/zabapgit_2fa.prog.abap @@ -570,7 +570,7 @@ CLASS lcl_2fa_github_auth IMPLEMENTATION. " Try to login to GitHub API with username, password and 2fa token - lo_settings = lcl_app=>settings( )->read( ). + lo_settings = zcl_abapgit_persist_settings=>get_instance( )->read( ). cl_http_client=>create_by_url( EXPORTING diff --git a/src/zabapgit_app.prog.abap b/src/zabapgit_app.prog.abap index 9c8b50b3b..697d626c3 100644 --- a/src/zabapgit_app.prog.abap +++ b/src/zabapgit_app.prog.abap @@ -3,9 +3,7 @@ *&---------------------------------------------------------------------* CLASS lcl_gui DEFINITION DEFERRED. -CLASS lcl_persistence_user DEFINITION DEFERRED. CLASS lcl_repo_srv DEFINITION DEFERRED. -CLASS lcl_persist_settings DEFINITION DEFERRED. CLASS lcl_proxy_configuration DEFINITION DEFERRED. *----------------------------------------------------------------------* @@ -18,29 +16,15 @@ CLASS lcl_app DEFINITION FINAL. RETURNING VALUE(ro_gui) TYPE REF TO lcl_gui RAISING zcx_abapgit_exception. - CLASS-METHODS user - IMPORTING iv_user TYPE xubname DEFAULT sy-uname - RETURNING VALUE(ro_user) TYPE REF TO lcl_persistence_user - RAISING zcx_abapgit_exception. - CLASS-METHODS repo_srv RETURNING VALUE(ro_repo_srv) TYPE REF TO lcl_repo_srv. - CLASS-METHODS db - RETURNING VALUE(ro_db) TYPE REF TO zcl_abapgit_persistence_db. - - CLASS-METHODS settings - RETURNING VALUE(ro_settings) TYPE REF TO lcl_persist_settings. - CLASS-METHODS proxy RETURNING VALUE(ro_proxy) TYPE REF TO lcl_proxy_configuration. PRIVATE SECTION. CLASS-DATA: go_gui TYPE REF TO lcl_gui, - go_current_user TYPE REF TO lcl_persistence_user, - go_db TYPE REF TO zcl_abapgit_persistence_db, go_repo_srv TYPE REF TO lcl_repo_srv, - go_settings TYPE REF TO lcl_persist_settings, go_proxy TYPE REF TO lcl_proxy_configuration. ENDCLASS. "lcl_app diff --git a/src/zabapgit_app_impl.prog.abap b/src/zabapgit_app_impl.prog.abap index 9d1c979cb..3e63422e4 100644 --- a/src/zabapgit_app_impl.prog.abap +++ b/src/zabapgit_app_impl.prog.abap @@ -16,21 +16,6 @@ CLASS lcl_app IMPLEMENTATION. ENDMETHOD. "gui - METHOD user. - - IF iv_user = sy-uname ##USER_OK. - IF go_current_user IS NOT BOUND. - CREATE OBJECT go_current_user. - ENDIF. - ro_user = go_current_user. - ELSE. - CREATE OBJECT ro_user - EXPORTING - iv_user = iv_user. - ENDIF. - - ENDMETHOD. "user - METHOD repo_srv. IF go_repo_srv IS NOT BOUND. @@ -40,22 +25,6 @@ CLASS lcl_app IMPLEMENTATION. ENDMETHOD. "repo_srv - METHOD db. - - IF go_db IS NOT BOUND. - CREATE OBJECT go_db. - ENDIF. - ro_db = go_db. - - ENDMETHOD. "repo_srv - - METHOD settings. - IF go_settings IS NOT BOUND. - CREATE OBJECT go_settings. - ENDIF. - ro_settings = go_settings. - ENDMETHOD. - METHOD proxy. IF go_proxy IS NOT BOUND. CREATE OBJECT go_proxy. diff --git a/src/zabapgit_background.prog.abap b/src/zabapgit_background.prog.abap index 55d6768b9..ab304fd82 100644 --- a/src/zabapgit_background.prog.abap +++ b/src/zabapgit_background.prog.abap @@ -16,11 +16,11 @@ CLASS lcl_background DEFINITION FINAL. RETURNING VALUE(rv_comment) TYPE string, push IMPORTING io_repo TYPE REF TO lcl_repo_online - is_settings TYPE lcl_persist_background=>ty_background + is_settings TYPE zcl_abapgit_persist_background=>ty_background RAISING zcx_abapgit_exception, push_fixed IMPORTING io_repo TYPE REF TO lcl_repo_online - is_settings TYPE lcl_persist_background=>ty_background + is_settings TYPE zcl_abapgit_persist_background=>ty_background RAISING zcx_abapgit_exception, push_auto IMPORTING io_repo TYPE REF TO lcl_repo_online @@ -38,10 +38,10 @@ CLASS lcl_background IMPLEMENTATION. ENDIF. CASE is_settings-amethod. - WHEN lcl_persist_background=>c_amethod-fixed. + WHEN zcl_abapgit_persist_background=>c_amethod-fixed. push_fixed( io_repo = io_repo is_settings = is_settings ). - WHEN lcl_persist_background=>c_amethod-auto. + WHEN zcl_abapgit_persist_background=>c_amethod-auto. push_auto( io_repo ). WHEN OTHERS. zcx_abapgit_exception=>raise( 'unknown push method' ). @@ -189,9 +189,9 @@ CLASS lcl_background IMPLEMENTATION. CONSTANTS: c_enq_type TYPE c LENGTH 12 VALUE 'BACKGROUND'. - DATA: lo_per TYPE REF TO lcl_persist_background, + DATA: lo_per TYPE REF TO zcl_abapgit_persist_background, lo_repo TYPE REF TO lcl_repo_online, - lt_list TYPE lcl_persist_background=>tt_background, + lt_list TYPE zcl_abapgit_persist_background=>tt_background, lv_repo_name TYPE string. FIELD-SYMBOLS: LIKE LINE OF lt_list. @@ -227,9 +227,9 @@ CLASS lcl_background IMPLEMENTATION. iv_password = -password ). CASE -method. - WHEN lcl_persist_background=>c_method-pull. + WHEN zcl_abapgit_persist_background=>c_method-pull. lo_repo->deserialize( ). - WHEN lcl_persist_background=>c_method-push. + WHEN zcl_abapgit_persist_background=>c_method-push. push( io_repo = lo_repo is_settings = ). WHEN OTHERS. diff --git a/src/zabapgit_gui_router.prog.abap b/src/zabapgit_gui_router.prog.abap index bc3b79133..27588e593 100644 --- a/src/zabapgit_gui_router.prog.abap +++ b/src/zabapgit_gui_router.prog.abap @@ -47,7 +47,7 @@ CLASS lcl_gui_router DEFINITION FINAL. RAISING zcx_abapgit_exception. METHODS get_page_background - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_page RAISING zcx_abapgit_exception. @@ -65,7 +65,7 @@ CLASS lcl_gui_router IMPLEMENTATION. METHOD on_event. DATA: lv_url TYPE string, - lv_key TYPE lcl_persistence_repo=>ty_repo-key, + lv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key, ls_db TYPE zcl_abapgit_persistence_db=>ty_content, ls_item TYPE zif_abapgit_definitions=>ty_item. @@ -106,7 +106,7 @@ CLASS lcl_gui_router IMPLEMENTATION. ei_page = get_page_playground( ). ev_state = zif_abapgit_definitions=>gc_event_state-new_page. WHEN zif_abapgit_definitions=>gc_action-go_tutorial. " Go to tutorial - lcl_app=>user( )->set_repo_show( '' ). " Clear show_id + zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( '' ). " Clear show_id ev_state = zif_abapgit_definitions=>gc_event_state-re_render. " Assume we are on main page " SAP GUI actions @@ -297,7 +297,7 @@ CLASS lcl_gui_router IMPLEMENTATION. DATA: lo_repo TYPE REF TO lcl_repo_online, lo_page TYPE REF TO lcl_gui_page_boverview, - lv_key TYPE lcl_persistence_repo=>ty_repo-key. + lv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key. lv_key = iv_getdata. @@ -317,7 +317,7 @@ CLASS lcl_gui_router IMPLEMENTATION. DATA: ls_file TYPE zif_abapgit_definitions=>ty_file, ls_object TYPE zif_abapgit_definitions=>ty_item, lo_page TYPE REF TO lcl_gui_page_diff, - lv_key TYPE lcl_persistence_repo=>ty_repo-key. + lv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key. lcl_html_action_utils=>file_obj_decode( EXPORTING iv_string = iv_getdata @@ -339,7 +339,7 @@ CLASS lcl_gui_router IMPLEMENTATION. METHOD get_page_stage. DATA: lo_repo TYPE REF TO lcl_repo_online, - lv_key TYPE lcl_persistence_repo=>ty_repo-key, + lv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key, lv_seed TYPE string, lo_stage_page TYPE REF TO lcl_gui_page_stage. diff --git a/src/zabapgit_html_action_utils.prog.abap b/src/zabapgit_html_action_utils.prog.abap index d5bbc2699..3bb356759 100644 --- a/src/zabapgit_html_action_utils.prog.abap +++ b/src/zabapgit_html_action_utils.prog.abap @@ -50,18 +50,18 @@ CLASS lcl_html_action_utils DEFINITION FINAL. RAISING zcx_abapgit_exception. CLASS-METHODS file_encode - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key ig_file TYPE any "assuming ty_file RETURNING VALUE(rv_string) TYPE string. CLASS-METHODS obj_encode - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key ig_object TYPE any "assuming ty_item RETURNING VALUE(rv_string) TYPE string. CLASS-METHODS file_obj_decode IMPORTING iv_string TYPE clike - EXPORTING ev_key TYPE lcl_persistence_repo=>ty_repo-key + EXPORTING ev_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key eg_file TYPE any "assuming ty_file eg_object TYPE any "assuming ty_item RAISING zcx_abapgit_exception. @@ -84,11 +84,11 @@ CLASS lcl_html_action_utils DEFINITION FINAL. CLASS-METHODS decode_bg_update IMPORTING iv_getdata TYPE clike - RETURNING VALUE(rs_fields) TYPE lcl_persist_background=>ty_background. + RETURNING VALUE(rs_fields) TYPE zcl_abapgit_persist_background=>ty_background. CLASS-METHODS stage_decode IMPORTING iv_getdata TYPE clike - EXPORTING ev_key TYPE lcl_persistence_repo=>ty_repo-key + EXPORTING ev_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key ev_seed TYPE string RAISING zcx_abapgit_exception. diff --git a/src/zabapgit_html_chunks.prog.abap b/src/zabapgit_html_chunks.prog.abap index 0af840694..fbf0d78d8 100644 --- a/src/zabapgit_html_chunks.prog.abap +++ b/src/zabapgit_html_chunks.prog.abap @@ -50,7 +50,7 @@ CLASS lcl_gui_chunk_lib IMPLEMENTATION. METHOD render_repo_top. DATA: lo_repo_online TYPE REF TO lcl_repo_online, - lo_pback TYPE REF TO lcl_persist_background, + lo_pback TYPE REF TO zcl_abapgit_persist_background, lv_hint TYPE string, lv_icon TYPE string. @@ -96,7 +96,7 @@ CLASS lcl_gui_chunk_lib IMPLEMENTATION. ro_html->add( '' ). " Fav - IF abap_true = lcl_app=>user( )->is_favorite_repo( io_repo->get_key( ) ). + IF abap_true = zcl_abapgit_persistence_user=>get_instance( )->is_favorite_repo( io_repo->get_key( ) ). lv_icon = 'star/blue' ##NO_TEXT. ELSE. lv_icon = 'star/grey' ##NO_TEXT. diff --git a/src/zabapgit_http.prog.abap b/src/zabapgit_http.prog.abap index 0f732f5cc..6c4c4d0fc 100644 --- a/src/zabapgit_http.prog.abap +++ b/src/zabapgit_http.prog.abap @@ -395,7 +395,7 @@ CLASS lcl_http IMPLEMENTATION. lo_digest TYPE REF TO zcl_abapgit_http_digest. - lv_default_user = lcl_app=>user( )->get_repo_login( iv_url ). + lv_default_user = zcl_abapgit_persistence_user=>get_instance( )->get_repo_login( iv_url ). lv_user = lv_default_user. lcl_password_dialog=>popup( @@ -410,8 +410,9 @@ CLASS lcl_http IMPLEMENTATION. ENDIF. IF lv_user <> lv_default_user. - lcl_app=>user( )->set_repo_login( iv_url = iv_url - iv_login = lv_user ). + zcl_abapgit_persistence_user=>get_instance( )->set_repo_login( + iv_url = iv_url + iv_login = lv_user ). ENDIF. " Offer two factor authentication if it is available and required diff --git a/src/zabapgit_migrations.prog.abap b/src/zabapgit_migrations.prog.abap index 6d4820c47..88e754535 100644 --- a/src/zabapgit_migrations.prog.abap +++ b/src/zabapgit_migrations.prog.abap @@ -21,7 +21,7 @@ CLASS lcl_migrations IMPLEMENTATION. METHOD run. " Migrate STDTEXT to TABLE - lcl_persist_migrate=>run( ). + zcl_abapgit_persist_migrate=>run( ). " Rebuild local file checksums rebuild_local_checksums_161112( ). diff --git a/src/zabapgit_news.prog.abap b/src/zabapgit_news.prog.abap index 44fc82597..66ce652ef 100644 --- a/src/zabapgit_news.prog.abap +++ b/src/zabapgit_news.prog.abap @@ -110,7 +110,7 @@ CLASS lcl_news IMPLEMENTATION. RETURN. ENDIF. - lv_last_seen = lcl_app=>user( )->get_repo_last_change_seen( lv_url ). + lv_last_seen = zcl_abapgit_persistence_user=>get_instance( )->get_repo_last_change_seen( lv_url ). TRY. " Find changelog @@ -131,7 +131,7 @@ CLASS lcl_news IMPLEMENTATION. ENDIF. IF ro_instance IS BOUND. - lcl_app=>user( )->set_repo_last_change_seen( + zcl_abapgit_persistence_user=>get_instance( )->set_repo_last_change_seen( iv_url = lv_url iv_version = ro_instance->latest_version( ) ). ENDIF. diff --git a/src/zabapgit_objects_impl.prog.abap b/src/zabapgit_objects_impl.prog.abap index d25312359..b3e955ed3 100644 --- a/src/zabapgit_objects_impl.prog.abap +++ b/src/zabapgit_objects_impl.prog.abap @@ -146,7 +146,7 @@ CLASS lcl_objects IMPLEMENTATION. lv_class_name = class_name( is_item ). ENDIF. - IF lcl_app=>settings( )->read( )->get_experimental_features( ) = abap_true + IF zcl_abapgit_persist_settings=>get_instance( )->read( )->get_experimental_features( ) = abap_true AND is_item-obj_type = 'CLAS'. lv_class_name = 'LCL_OBJECT_CLAS_NEW'. ENDIF. @@ -255,7 +255,7 @@ CLASS lcl_objects IMPLEMENTATION. li_obj = create_object( is_item = is_item iv_language = zif_abapgit_definitions=>gc_english ). - lv_adt_jump_enabled = lcl_app=>settings( )->read( )->get_adt_jump_enabled( ). + lv_adt_jump_enabled = zcl_abapgit_persist_settings=>get_instance( )->read( )->get_adt_jump_enabled( ). IF lv_adt_jump_enabled = abap_true. TRY. diff --git a/src/zabapgit_page_background.prog.abap b/src/zabapgit_page_background.prog.abap index b3c9690cf..33d2d0eb8 100644 --- a/src/zabapgit_page_background.prog.abap +++ b/src/zabapgit_page_background.prog.abap @@ -77,7 +77,7 @@ CLASS lcl_gui_page_bkg DEFINITION FINAL PUBLIC SECTION. METHODS: - constructor IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key, + constructor IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key, zif_abapgit_gui_page~on_event REDEFINITION. PROTECTED SECTION. @@ -85,7 +85,7 @@ CLASS lcl_gui_page_bkg DEFINITION FINAL PRIVATE SECTION. DATA: - mv_key TYPE lcl_persistence_repo=>ty_repo-key. + mv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key. METHODS: build_menu @@ -116,7 +116,7 @@ CLASS lcl_gui_page_bkg IMPLEMENTATION. METHOD zif_abapgit_gui_page~on_event. - DATA ls_bg_task TYPE lcl_persist_background=>ty_background. + DATA ls_bg_task TYPE zcl_abapgit_persist_background=>ty_background. CASE iv_action. WHEN zif_abapgit_definitions=>gc_action-bg_update. @@ -131,8 +131,8 @@ CLASS lcl_gui_page_bkg IMPLEMENTATION. METHOD render_data. DATA: lo_repo TYPE REF TO lcl_repo_online, - lo_per TYPE REF TO lcl_persist_background, - lt_per TYPE lcl_persist_background=>tt_background, + lo_per TYPE REF TO zcl_abapgit_persist_background, + lt_per TYPE zcl_abapgit_persist_background=>tt_background, ls_per LIKE LINE OF lt_per, lv_nothing TYPE string, lv_push TYPE string, @@ -163,16 +163,16 @@ CLASS lcl_gui_page_bkg IMPLEMENTATION. ENDIF. CASE ls_per-method. - WHEN lcl_persist_background=>c_method-push. + WHEN zcl_abapgit_persist_background=>c_method-push. lv_push = ' checked' ##NO_TEXT. - WHEN lcl_persist_background=>c_method-pull. + WHEN zcl_abapgit_persist_background=>c_method-pull. lv_pull = ' checked' ##NO_TEXT. WHEN OTHERS. lv_nothing = ' checked' ##NO_TEXT. ENDCASE. CASE ls_per-amethod. - WHEN lcl_persist_background=>c_amethod-auto. + WHEN zcl_abapgit_persist_background=>c_amethod-auto. lv_aauto = ' checked' ##NO_TEXT. WHEN OTHERS. lv_afixed = ' checked' ##NO_TEXT. diff --git a/src/zabapgit_page_commit.prog.abap b/src/zabapgit_page_commit.prog.abap index 5e523154c..a6b4c951c 100644 --- a/src/zabapgit_page_commit.prog.abap +++ b/src/zabapgit_page_commit.prog.abap @@ -157,7 +157,7 @@ CLASS lcl_gui_page_commit IMPLEMENTATION. CONSTANTS: lc_body_col_max TYPE i VALUE 150. - DATA: lo_user TYPE REF TO lcl_persistence_user. + DATA: lo_user TYPE REF TO zcl_abapgit_persistence_user. DATA: lv_user TYPE string. DATA: lv_email TYPE string. DATA: lv_s_param TYPE string. @@ -168,7 +168,7 @@ CLASS lcl_gui_page_commit IMPLEMENTATION. * commit messages should be max 50 characters * body should wrap at 72 characters - lo_user = lcl_app=>user( ). + lo_user = zcl_abapgit_persistence_user=>get_instance( ). lv_user = lo_user->get_repo_git_user_name( mo_repo->get_url( ) ). IF lv_user IS INITIAL. @@ -194,7 +194,7 @@ CLASS lcl_gui_page_commit IMPLEMENTATION. iv_label = 'committer e-mail' iv_value = lv_email ) ). - lo_settings = lcl_app=>settings( )->read( ). + lo_settings = zcl_abapgit_persist_settings=>get_instance( )->read( ). lv_s_param = lo_settings->get_commitmsg_comment_length( ). diff --git a/src/zabapgit_page_db.prog.abap b/src/zabapgit_page_db.prog.abap index 3c59b3735..4ba0aa6e2 100644 --- a/src/zabapgit_page_db.prog.abap +++ b/src/zabapgit_page_db.prog.abap @@ -46,7 +46,7 @@ CLASS lcl_gui_page_db_dis IMPLEMENTATION. lv_action TYPE string. TRY. - lv_data = lcl_app=>db( )->read( + lv_data = zcl_abapgit_persistence_db=>get_instance( )->read( iv_type = ms_key-type iv_value = ms_key-value ). CATCH zcx_abapgit_not_found ##NO_HANDLER. @@ -107,13 +107,13 @@ CLASS lcl_gui_page_db_edit IMPLEMENTATION. lo_toolbar TYPE REF TO zcl_abapgit_html_toolbar. TRY. - lv_data = lcl_app=>db( )->read( + lv_data = zcl_abapgit_persistence_db=>get_instance( )->read( iv_type = ms_key-type iv_value = ms_key-value ). CATCH zcx_abapgit_not_found ##NO_HANDLER. ENDTRY. - lcl_app=>db( )->lock( + zcl_abapgit_persistence_db=>get_instance( )->lock( iv_type = ms_key-type iv_value = ms_key-value ). @@ -183,7 +183,7 @@ CLASS lcl_gui_page_db IMPLEMENTATION. FIELD-SYMBOLS: LIKE LINE OF lt_data. - lt_data = lcl_app=>db( )->list( ). + lt_data = zcl_abapgit_persistence_db=>get_instance( )->list( ). CREATE OBJECT ro_html. diff --git a/src/zabapgit_page_diff.prog.abap b/src/zabapgit_page_diff.prog.abap index f7c8880ca..2cb4477de 100644 --- a/src/zabapgit_page_diff.prog.abap +++ b/src/zabapgit_page_diff.prog.abap @@ -27,7 +27,7 @@ CLASS lcl_gui_page_diff DEFINITION FINAL INHERITING FROM lcl_gui_page. METHODS: constructor - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL iv_supress_stage TYPE abap_bool DEFAULT abap_false @@ -47,7 +47,7 @@ CLASS lcl_gui_page_diff DEFINITION FINAL INHERITING FROM lcl_gui_page. DATA: mt_diff_files TYPE tt_file_diff, mt_delayed_lines TYPE zcl_abapgit_diff=>ty_diffs_tt, mv_unified TYPE abap_bool VALUE abap_true, - mv_repo_key TYPE lcl_persistence_repo=>ty_repo-key, + mv_repo_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key, mv_seed TYPE string. " Unique page id to bind JS sessionStorage METHODS render_diff @@ -101,7 +101,7 @@ CLASS lcl_gui_page_diff IMPLEMENTATION. super->constructor( ). ms_control-page_title = 'DIFF'. - mv_unified = lcl_app=>user( )->get_diff_unified( ). + mv_unified = zcl_abapgit_persistence_user=>get_instance( )->get_diff_unified( ). mv_repo_key = iv_key. GET TIME STAMP FIELD lv_ts. @@ -338,7 +338,7 @@ CLASS lcl_gui_page_diff IMPLEMENTATION. CASE iv_action. WHEN c_actions-toggle_unified. " Toggle file diplay - mv_unified = lcl_app=>user( )->toggle_diff_unified( ). + mv_unified = zcl_abapgit_persistence_user=>get_instance( )->toggle_diff_unified( ). ev_state = zif_abapgit_definitions=>gc_event_state-re_render. ENDCASE. diff --git a/src/zabapgit_page_main.prog.abap b/src/zabapgit_page_main.prog.abap index 4b8208448..d36f8f2ec 100644 --- a/src/zabapgit_page_main.prog.abap +++ b/src/zabapgit_page_main.prog.abap @@ -51,7 +51,7 @@ CLASS lcl_gui_page_main IMPLEMENTATION. METHOD zif_abapgit_gui_page~on_event. - DATA: lv_key TYPE lcl_persistence_repo=>ty_repo-key. + DATA: lv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key. IF NOT mo_repo_content IS INITIAL. @@ -74,7 +74,7 @@ CLASS lcl_gui_page_main IMPLEMENTATION. CASE iv_action. WHEN c_actions-show. " Change displayed repo - lcl_app=>user( )->set_repo_show( lv_key ). + zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( lv_key ). TRY. lcl_app=>repo_srv( )->get( lv_key )->refresh( ). CATCH zcx_abapgit_exception ##NO_HANDLER. @@ -150,14 +150,14 @@ CLASS lcl_gui_page_main IMPLEMENTATION. ENDTRY. lv_show_old = mv_show. - mv_show = lcl_app=>user( )->get_repo_show( ). " Get default repo from user cfg + mv_show = zcl_abapgit_persistence_user=>get_instance( )->get_repo_show( ). " Get default repo from user cfg IF mv_show IS NOT INITIAL. TRY. " verify the key exists lcl_app=>repo_srv( )->get( mv_show ). CATCH zcx_abapgit_exception. CLEAR mv_show. - lcl_app=>user( )->set_repo_show( mv_show ). + zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( mv_show ). ENDTRY. ENDIF. @@ -201,14 +201,14 @@ CLASS lcl_gui_page_main IMPLEMENTATION. METHOD render_toc. - DATA: lo_pback TYPE REF TO lcl_persist_background, + DATA: lo_pback TYPE REF TO zcl_abapgit_persist_background, lv_current TYPE abap_bool, - lv_key TYPE lcl_persistence_repo=>ty_repo-key, + lv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key, lv_icon TYPE string, lo_repo LIKE LINE OF it_repo_list, lo_favbar TYPE REF TO zcl_abapgit_html_toolbar, lo_allbar TYPE REF TO zcl_abapgit_html_toolbar, - lt_favorites TYPE lcl_persistence_user=>tt_favorites, + lt_favorites TYPE zcl_abapgit_persistence_user=>tt_favorites, lv_repo_title TYPE string. @@ -217,7 +217,7 @@ CLASS lcl_gui_page_main IMPLEMENTATION. CREATE OBJECT lo_allbar. CREATE OBJECT lo_pback. - lt_favorites = lcl_app=>user( )->get_favorites( ). + lt_favorites = zcl_abapgit_persistence_user=>get_instance( )->get_favorites( ). LOOP AT it_repo_list INTO lo_repo. lv_key = lo_repo->get_key( ). @@ -255,7 +255,7 @@ CLASS lcl_gui_page_main IMPLEMENTATION. " Cleanup orphan favorites (for removed repos) LOOP AT lt_favorites INTO lv_key. - lcl_app=>user( )->toggle_favorite( lv_key ). + zcl_abapgit_persistence_user=>get_instance( )->toggle_favorite( lv_key ). ENDLOOP. " Render HTML diff --git a/src/zabapgit_page_settings.prog.abap b/src/zabapgit_page_settings.prog.abap index f0485a7cf..5e8000b30 100644 --- a/src/zabapgit_page_settings.prog.abap +++ b/src/zabapgit_page_settings.prog.abap @@ -230,9 +230,9 @@ CLASS lcl_gui_page_settings IMPLEMENTATION. METHOD persist_settings. - DATA lo_settings_persistence TYPE REF TO lcl_persist_settings. + DATA lo_settings_persistence TYPE REF TO zcl_abapgit_persist_settings. - lo_settings_persistence = lcl_app=>settings( ). + lo_settings_persistence = zcl_abapgit_persist_settings=>get_instance( ). lo_settings_persistence->modify( mo_settings ). MESSAGE 'Settings succesfully saved' TYPE 'S'. @@ -258,9 +258,9 @@ CLASS lcl_gui_page_settings IMPLEMENTATION. METHOD read_settings. - DATA lo_settings_persistence TYPE REF TO lcl_persist_settings. + DATA lo_settings_persistence TYPE REF TO zcl_abapgit_persist_settings. - lo_settings_persistence = lcl_app=>settings( ). + lo_settings_persistence = zcl_abapgit_persist_settings=>get_instance( ). mo_settings = lo_settings_persistence->read( ). ENDMETHOD. diff --git a/src/zabapgit_persistence.prog.abap b/src/zabapgit_persistence.prog.abap index 6de9dbd59..d5186b828 100644 --- a/src/zabapgit_persistence.prog.abap +++ b/src/zabapgit_persistence.prog.abap @@ -2,1526 +2,4 @@ *& Include ZABAPGIT_PERSISTENCE *&---------------------------------------------------------------------* -CLASS lcl_persist_migrate DEFINITION FINAL. - - PUBLIC SECTION. - CLASS-METHODS: run RAISING zcx_abapgit_exception. - - PRIVATE SECTION. - CONSTANTS: - c_text TYPE string VALUE 'Generated by abapGit' ##NO_TEXT. - - CLASS-METHODS: - migrate_settings - RAISING zcx_abapgit_exception, - table_create - RAISING zcx_abapgit_exception, - table_exists - RETURNING VALUE(rv_exists) TYPE abap_bool, - lock_create - RAISING zcx_abapgit_exception, - lock_exists - RETURNING VALUE(rv_exists) TYPE abap_bool, - settings_exists - RETURNING VALUE(rv_exists) TYPE abap_bool. - -ENDCLASS. - -CLASS lcl_persistence_repo DEFINITION FINAL. - - PUBLIC SECTION. - TYPES: BEGIN OF ty_local_checksum, - item TYPE zif_abapgit_definitions=>ty_item, - files TYPE zif_abapgit_definitions=>ty_file_signatures_tt, - END OF ty_local_checksum. - - TYPES: ty_local_checksum_tt TYPE STANDARD TABLE OF ty_local_checksum WITH DEFAULT KEY. - - TYPES: BEGIN OF ty_repo_xml, - url TYPE string, - branch_name TYPE string, - sha1 TYPE zif_abapgit_definitions=>ty_sha1, - package TYPE devclass, - offline TYPE sap_bool, - local_checksums TYPE ty_local_checksum_tt, - dot_abapgit TYPE zcl_abapgit_dot_abapgit=>ty_dot_abapgit, - head_branch TYPE string, " HEAD symref of the repo, master branch - write_protect TYPE sap_bool, " Deny destructive ops: pull, switch branch ... - ignore_subpackages TYPE sap_bool, - END OF ty_repo_xml. - - TYPES: BEGIN OF ty_repo, - key TYPE zcl_abapgit_persistence_db=>ty_value. - INCLUDE TYPE ty_repo_xml. - TYPES: END OF ty_repo. - TYPES: tt_repo TYPE STANDARD TABLE OF ty_repo WITH DEFAULT KEY. - TYPES: tt_repo_keys TYPE STANDARD TABLE OF ty_repo-key WITH DEFAULT KEY. - - METHODS constructor. - - METHODS list - RETURNING VALUE(rt_repos) TYPE tt_repo - RAISING zcx_abapgit_exception. - - METHODS update_sha1 - IMPORTING iv_key TYPE ty_repo-key - iv_branch_sha1 TYPE ty_repo_xml-sha1 - RAISING zcx_abapgit_exception. - - METHODS update_local_checksums - IMPORTING iv_key TYPE ty_repo-key - it_checksums TYPE ty_repo_xml-local_checksums - RAISING zcx_abapgit_exception. - - METHODS update_url - IMPORTING iv_key TYPE ty_repo-key - iv_url TYPE ty_repo_xml-url - RAISING zcx_abapgit_exception. - - METHODS update_branch_name - IMPORTING iv_key TYPE ty_repo-key - iv_branch_name TYPE ty_repo_xml-branch_name - RAISING zcx_abapgit_exception. - - METHODS update_head_branch - IMPORTING iv_key TYPE ty_repo-key - iv_head_branch TYPE ty_repo_xml-head_branch - RAISING zcx_abapgit_exception. - - METHODS update_offline - IMPORTING iv_key TYPE ty_repo-key - iv_offline TYPE ty_repo_xml-offline - RAISING zcx_abapgit_exception. - - METHODS update_dot_abapgit - IMPORTING iv_key TYPE ty_repo-key - is_dot_abapgit TYPE zcl_abapgit_dot_abapgit=>ty_dot_abapgit - RAISING zcx_abapgit_exception. - - METHODS add - IMPORTING iv_url TYPE string - iv_branch_name TYPE string - iv_branch TYPE zif_abapgit_definitions=>ty_sha1 OPTIONAL - iv_package TYPE devclass - iv_offline TYPE sap_bool DEFAULT abap_false - is_dot_abapgit TYPE zcl_abapgit_dot_abapgit=>ty_dot_abapgit - RETURNING VALUE(rv_key) TYPE ty_repo-key - RAISING zcx_abapgit_exception. - - METHODS delete - IMPORTING iv_key TYPE ty_repo-key - RAISING zcx_abapgit_exception. - - METHODS read - IMPORTING iv_key TYPE ty_repo-key - RETURNING VALUE(rs_repo) TYPE ty_repo - RAISING zcx_abapgit_exception - zcx_abapgit_not_found. - - METHODS lock - IMPORTING iv_mode TYPE enqmode - iv_key TYPE ty_repo-key - RAISING zcx_abapgit_exception. - - PRIVATE SECTION. - DATA: mo_db TYPE REF TO zcl_abapgit_persistence_db. - - METHODS from_xml - IMPORTING iv_repo_xml_string TYPE string - RETURNING VALUE(rs_repo) TYPE ty_repo_xml - RAISING zcx_abapgit_exception. - - METHODS to_xml - IMPORTING is_repo TYPE ty_repo - RETURNING VALUE(rv_repo_xml_string) TYPE string. - - METHODS get_next_id - RETURNING VALUE(rv_next_repo_id) TYPE zcl_abapgit_persistence_db=>ty_content-value - RAISING zcx_abapgit_exception. - -ENDCLASS. - -CLASS lcl_persist_background DEFINITION FINAL. - - PUBLIC SECTION. - - CONSTANTS: BEGIN OF c_method, - nothing TYPE string VALUE 'nothing' ##NO_TEXT, - pull TYPE string VALUE 'pull' ##NO_TEXT, - push TYPE string VALUE 'push' ##NO_TEXT, - END OF c_method. - - CONSTANTS: BEGIN OF c_amethod, - fixed TYPE string VALUE 'fixed' ##NO_TEXT, - auto TYPE string VALUE 'auto' ##NO_TEXT, - END OF c_amethod. - - TYPES: BEGIN OF ty_xml, - method TYPE string, - username TYPE string, - password TYPE string, - amethod TYPE string, - aname TYPE string, - amail TYPE string, - END OF ty_xml. - - TYPES: BEGIN OF ty_background, - key TYPE zcl_abapgit_persistence_db=>ty_value. - INCLUDE TYPE ty_xml. - TYPES: END OF ty_background. - TYPES: tt_background TYPE STANDARD TABLE OF ty_background WITH DEFAULT KEY. - - METHODS constructor. - - METHODS list - RETURNING VALUE(rt_list) TYPE tt_background - RAISING zcx_abapgit_exception. - - METHODS modify - IMPORTING is_data TYPE ty_background - RAISING zcx_abapgit_exception. - - METHODS delete - IMPORTING iv_key TYPE ty_background-key - RAISING zcx_abapgit_exception. - - METHODS exists - IMPORTING iv_key TYPE ty_background-key - RETURNING VALUE(rv_yes) TYPE abap_bool - RAISING zcx_abapgit_exception. - - PRIVATE SECTION. - DATA: mo_db TYPE REF TO zcl_abapgit_persistence_db, - mt_jobs TYPE tt_background. - - METHODS from_xml - IMPORTING iv_string TYPE string - RETURNING VALUE(rs_xml) TYPE ty_xml - RAISING zcx_abapgit_exception. - - METHODS to_xml - IMPORTING is_background TYPE ty_background - RETURNING VALUE(rv_string) TYPE string. - -ENDCLASS. "lcl_persistence_background DEFINITION - - -CLASS lcl_persist_settings DEFINITION FINAL. - - PUBLIC SECTION. - METHODS modify - IMPORTING - io_settings TYPE REF TO zcl_abapgit_settings - RAISING - zcx_abapgit_exception. - METHODS read - RETURNING - VALUE(ro_settings) TYPE REF TO zcl_abapgit_settings. - - PRIVATE SECTION. - DATA: mo_settings TYPE REF TO zcl_abapgit_settings. - -ENDCLASS. - -CLASS lcl_persist_background IMPLEMENTATION. - - METHOD constructor. - mo_db = lcl_app=>db( ). - ENDMETHOD. - - METHOD list. - - DATA: lt_list TYPE zcl_abapgit_persistence_db=>tt_content, - ls_xml TYPE ty_xml. - - FIELD-SYMBOLS: LIKE LINE OF lt_list, - LIKE LINE OF rt_list. - - IF lines( mt_jobs ) > 0. - rt_list = mt_jobs. - RETURN. - ENDIF. - - - lt_list = mo_db->list_by_type( zcl_abapgit_persistence_db=>c_type_background ). - - LOOP AT lt_list ASSIGNING . - ls_xml = from_xml( -data_str ). - - APPEND INITIAL LINE TO rt_list ASSIGNING . - MOVE-CORRESPONDING ls_xml TO . - -key = -value. - ENDLOOP. - - mt_jobs = rt_list. - - ENDMETHOD. - - METHOD exists. - - list( ). " Ensure mt_jobs is populated - READ TABLE mt_jobs WITH KEY key = iv_key TRANSPORTING NO FIELDS. - rv_yes = boolc( sy-subrc = 0 ). - - ENDMETHOD. "exists - - METHOD modify. - - ASSERT NOT is_data-key IS INITIAL. - - mo_db->modify( - iv_type = zcl_abapgit_persistence_db=>c_type_background - iv_value = is_data-key - iv_data = to_xml( is_data ) ). - - DELETE mt_jobs WHERE key = is_data-key. - APPEND is_data TO mt_jobs. - - ENDMETHOD. - - METHOD delete. - - TRY. - mo_db->read( iv_type = zcl_abapgit_persistence_db=>c_type_background - iv_value = iv_key ). - CATCH zcx_abapgit_not_found. - RETURN. - ENDTRY. - - mo_db->delete( iv_type = zcl_abapgit_persistence_db=>c_type_background - iv_value = iv_key ). - - DELETE mt_jobs WHERE key = iv_key. - - ENDMETHOD. - - METHOD from_xml. - CALL TRANSFORMATION id - OPTIONS value_handling = 'accept_data_loss' - SOURCE XML iv_string - RESULT data = rs_xml ##NO_TEXT. - ENDMETHOD. - - METHOD to_xml. - DATA: ls_xml TYPE ty_xml. - - MOVE-CORRESPONDING is_background TO ls_xml. - - CALL TRANSFORMATION id - SOURCE data = ls_xml - RESULT XML rv_string. - ENDMETHOD. - -ENDCLASS. " lcl_persistence_background IMPLEMENTATION - -*----------------------------------------------------------------------* -* CLASS lcl_persistence_user DEFINITION -*----------------------------------------------------------------------* -CLASS lcl_persistence_user DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_app. - - PUBLIC SECTION. - - TYPES: tt_favorites TYPE lcl_persistence_repo=>tt_repo_keys. - - METHODS set_default_git_user_name - IMPORTING iv_username TYPE string - RAISING zcx_abapgit_exception. - - METHODS get_default_git_user_name - RETURNING VALUE(rv_username) TYPE string - RAISING zcx_abapgit_exception. - - METHODS set_default_git_user_email - IMPORTING iv_email TYPE string - RAISING zcx_abapgit_exception. - - METHODS get_default_git_user_email - RETURNING VALUE(rv_email) TYPE string - RAISING zcx_abapgit_exception. - - METHODS set_repo_show - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key - RAISING zcx_abapgit_exception. - - METHODS get_repo_show - RETURNING VALUE(rv_key) TYPE lcl_persistence_repo=>ty_repo-key - RAISING zcx_abapgit_exception. - - METHODS set_repo_git_user_name - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - iv_username TYPE string - RAISING zcx_abapgit_exception. - - METHODS get_repo_git_user_name - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - RETURNING VALUE(rv_username) TYPE string - RAISING zcx_abapgit_exception. - - METHODS set_repo_login - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - iv_login TYPE string - RAISING zcx_abapgit_exception. - - METHODS get_repo_login - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - RETURNING VALUE(rv_login) TYPE string - RAISING zcx_abapgit_exception. - - METHODS set_repo_git_user_email - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - iv_email TYPE string - RAISING zcx_abapgit_exception. - - METHODS get_repo_git_user_email - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - RETURNING VALUE(rv_email) TYPE string - RAISING zcx_abapgit_exception. - - METHODS set_repo_last_change_seen - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - iv_version TYPE string - RAISING zcx_abapgit_exception. - - METHODS get_repo_last_change_seen - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - RETURNING VALUE(rv_version) TYPE string - RAISING zcx_abapgit_exception. - - METHODS toggle_hide_files - RETURNING VALUE(rv_hide) TYPE abap_bool - RAISING zcx_abapgit_exception. - - METHODS get_hide_files - RETURNING VALUE(rv_hide) TYPE abap_bool - RAISING zcx_abapgit_exception. - - METHODS toggle_changes_only - RETURNING VALUE(rv_changes_only) TYPE abap_bool - RAISING zcx_abapgit_exception. - - METHODS get_changes_only - RETURNING VALUE(rv_changes_only) TYPE abap_bool - RAISING zcx_abapgit_exception. - - METHODS toggle_diff_unified - RETURNING VALUE(rv_diff_unified) TYPE abap_bool - RAISING zcx_abapgit_exception. - - METHODS get_diff_unified - RETURNING VALUE(rv_diff_unified) TYPE abap_bool - RAISING zcx_abapgit_exception. - - METHODS get_favorites - RETURNING VALUE(rt_favorites) TYPE tt_favorites - RAISING zcx_abapgit_exception. - - METHODS toggle_favorite - IMPORTING iv_repo_key TYPE lcl_persistence_repo=>ty_repo-key - RAISING zcx_abapgit_exception. - - METHODS is_favorite_repo - IMPORTING iv_repo_key TYPE lcl_persistence_repo=>ty_repo-key - RETURNING VALUE(rv_yes) TYPE abap_bool - RAISING zcx_abapgit_exception. - - PRIVATE SECTION. - DATA: mv_user TYPE xubname. - - TYPES: - BEGIN OF ty_repo_config, - url TYPE lcl_persistence_repo=>ty_repo-url, - login TYPE string, - git_user TYPE zif_abapgit_definitions=>ty_git_user, - last_change_seen TYPE string, - END OF ty_repo_config. - - TYPES: ty_repo_config_tt TYPE STANDARD TABLE OF ty_repo_config WITH DEFAULT KEY. - - TYPES: - BEGIN OF ty_user, - default_git_user TYPE zif_abapgit_definitions=>ty_git_user, - repo_show TYPE lcl_persistence_repo=>ty_repo-key, - hide_files TYPE abap_bool, - changes_only TYPE abap_bool, - diff_unified TYPE abap_bool, - favorites TYPE tt_favorites, - repo_config TYPE ty_repo_config_tt, - END OF ty_user. - - METHODS constructor - IMPORTING iv_user TYPE xubname DEFAULT sy-uname. - - METHODS from_xml - IMPORTING iv_xml TYPE string - RETURNING VALUE(rs_user) TYPE ty_user - RAISING zcx_abapgit_exception. - - METHODS to_xml - IMPORTING is_user TYPE ty_user - RETURNING VALUE(rv_xml) TYPE string. - - METHODS read - RETURNING VALUE(rs_user) TYPE ty_user - RAISING zcx_abapgit_exception. - - METHODS update - IMPORTING is_user TYPE ty_user - RAISING zcx_abapgit_exception. - - METHODS read_repo_config - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - RETURNING VALUE(rs_repo_config) TYPE ty_repo_config - RAISING zcx_abapgit_exception. - - METHODS update_repo_config - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - is_repo_config TYPE ty_repo_config - RAISING zcx_abapgit_exception. - -ENDCLASS. "lcl_persistence_user DEFINITION - -CLASS lcl_persistence_user IMPLEMENTATION. - - METHOD constructor. - mv_user = iv_user. - ENDMETHOD. - - METHOD from_xml. - - DATA: lv_xml TYPE string. - - lv_xml = iv_xml. - -* fix downward compatibility - REPLACE ALL OCCURRENCES OF '<_--28C_TYPE_USER_--29>' IN lv_xml WITH ''. - REPLACE ALL OCCURRENCES OF '' IN lv_xml WITH ''. - - CALL TRANSFORMATION id - OPTIONS value_handling = 'accept_data_loss' - SOURCE XML lv_xml - RESULT user = rs_user ##NO_TEXT. - ENDMETHOD. - - METHOD to_xml. - CALL TRANSFORMATION id - SOURCE user = is_user - RESULT XML rv_xml. - ENDMETHOD. - - METHOD read. - - DATA: lv_xml TYPE string. - - TRY. - lv_xml = lcl_app=>db( )->read( - iv_type = zcl_abapgit_persistence_db=>c_type_user - iv_value = mv_user ). - CATCH zcx_abapgit_not_found. - RETURN. - ENDTRY. - - rs_user = from_xml( lv_xml ). - - ENDMETHOD. - - METHOD set_repo_show. - - DATA: ls_user TYPE ty_user. - - - ls_user = read( ). - ls_user-repo_show = iv_key. - update( ls_user ). - - COMMIT WORK AND WAIT. - - ENDMETHOD. - - METHOD get_repo_show. - - rv_key = read( )-repo_show. - - ENDMETHOD. - - METHOD update. - - DATA: lv_xml TYPE string. - - lv_xml = to_xml( is_user ). - - lcl_app=>db( )->modify( - iv_type = zcl_abapgit_persistence_db=>c_type_user - iv_value = mv_user - iv_data = lv_xml ). - - ENDMETHOD. - - METHOD set_default_git_user_name. - - DATA: ls_user TYPE ty_user. - - - ls_user = read( ). - - ls_user-default_git_user-name = iv_username. - - update( ls_user ). - - ENDMETHOD. - - METHOD get_default_git_user_name. - - rv_username = read( )-default_git_user-name. - - ENDMETHOD. - - METHOD set_default_git_user_email. - - DATA: ls_user TYPE ty_user. - - - ls_user = read( ). - ls_user-default_git_user-email = iv_email. - update( ls_user ). - - ENDMETHOD. - - METHOD get_default_git_user_email. - - rv_email = read( )-default_git_user-email. - - ENDMETHOD. - - METHOD read_repo_config. - DATA: lt_repo_config TYPE ty_repo_config_tt, - lv_key TYPE string. - - lv_key = to_lower( iv_url ). - lt_repo_config = read( )-repo_config. - READ TABLE lt_repo_config INTO rs_repo_config WITH KEY url = lv_key. - - ENDMETHOD. "read_repo_config - - METHOD update_repo_config. - DATA: ls_user TYPE ty_user, - lv_key TYPE string. - FIELD-SYMBOLS TYPE ty_repo_config. - - ls_user = read( ). - lv_key = to_lower( iv_url ). - - READ TABLE ls_user-repo_config ASSIGNING WITH KEY url = lv_key. - IF sy-subrc IS NOT INITIAL. - APPEND INITIAL LINE TO ls_user-repo_config ASSIGNING . - ENDIF. - = is_repo_config. - -url = lv_key. - - update( ls_user ). - - COMMIT WORK AND WAIT. - - ENDMETHOD. "update_repo_config - - METHOD set_repo_git_user_name. - - DATA: ls_repo_config TYPE ty_repo_config. - - ls_repo_config = read_repo_config( iv_url ). - ls_repo_config-git_user-name = iv_username. - update_repo_config( iv_url = iv_url is_repo_config = ls_repo_config ). - - ENDMETHOD. "set_repo_username - - METHOD get_repo_git_user_name. - - rv_username = read_repo_config( iv_url )-git_user-name. - - ENDMETHOD. "get_repo_username - - METHOD set_repo_login. - - DATA: ls_repo_config TYPE ty_repo_config. - - ls_repo_config = read_repo_config( iv_url ). - ls_repo_config-login = iv_login. - update_repo_config( iv_url = iv_url is_repo_config = ls_repo_config ). - - ENDMETHOD. "set_repo_login - - METHOD get_repo_login. - - rv_login = read_repo_config( iv_url )-login. - - ENDMETHOD. "get_repo_login - - METHOD set_repo_git_user_email. - - DATA: ls_repo_config TYPE ty_repo_config. - - ls_repo_config = read_repo_config( iv_url ). - ls_repo_config-git_user-email = iv_email. - update_repo_config( iv_url = iv_url is_repo_config = ls_repo_config ). - - ENDMETHOD. "set_repo_email - - METHOD get_repo_git_user_email. - - rv_email = read_repo_config( iv_url )-git_user-email. - - ENDMETHOD. "get_repo_email - - METHOD set_repo_last_change_seen. - - DATA: ls_repo_config TYPE ty_repo_config. - - ls_repo_config = read_repo_config( iv_url ). - ls_repo_config-last_change_seen = iv_version. - update_repo_config( iv_url = iv_url is_repo_config = ls_repo_config ). - - ENDMETHOD. "set_last_change_seen - - METHOD get_repo_last_change_seen. - - rv_version = read_repo_config( iv_url )-last_change_seen. - - ENDMETHOD. "get_last_change_seen - - METHOD toggle_hide_files. - - DATA ls_user TYPE ty_user. - - ls_user = read( ). - ls_user-hide_files = boolc( ls_user-hide_files = abap_false ). - update( ls_user ). - - rv_hide = ls_user-hide_files. - - ENDMETHOD. "toggle_hide_files - - METHOD get_hide_files. - - rv_hide = read( )-hide_files. - - ENDMETHOD. "get_hide_files - - METHOD toggle_changes_only. - - DATA ls_user TYPE ty_user. - - ls_user = read( ). - ls_user-changes_only = boolc( ls_user-changes_only = abap_false ). - update( ls_user ). - - rv_changes_only = ls_user-changes_only. - - ENDMETHOD. "toggle_changes_only - - METHOD get_changes_only. - - rv_changes_only = read( )-changes_only. - - ENDMETHOD. "get_changes_only - - METHOD toggle_diff_unified. - - DATA ls_user TYPE ty_user. - - ls_user = read( ). - ls_user-diff_unified = boolc( ls_user-diff_unified = abap_false ). - update( ls_user ). - - rv_diff_unified = ls_user-diff_unified. - - ENDMETHOD. "toggle_diff_unified - - METHOD get_diff_unified. - - rv_diff_unified = read( )-diff_unified. - - ENDMETHOD. "get_diff_unified - - METHOD get_favorites. - - rt_favorites = read( )-favorites. - - ENDMETHOD. "get_favorites - - METHOD toggle_favorite. - - DATA: ls_user TYPE ty_user. - - ls_user = read( ). - - READ TABLE ls_user-favorites TRANSPORTING NO FIELDS - WITH KEY table_line = iv_repo_key. - - IF sy-subrc = 0. - DELETE ls_user-favorites INDEX sy-tabix. - ELSE. - APPEND iv_repo_key TO ls_user-favorites. - ENDIF. - - update( ls_user ). - - ENDMETHOD. " toggle_favorite. - - METHOD is_favorite_repo. - - DATA: lt_favorites TYPE tt_favorites. - - lt_favorites = get_favorites( ). - - READ TABLE lt_favorites TRANSPORTING NO FIELDS - WITH KEY table_line = iv_repo_key. - - rv_yes = boolc( sy-subrc = 0 ). - - ENDMETHOD. " is_favorite_repo. - -ENDCLASS. - -*----------------------------------------------------------------------* -* CLASS lcl_persistence_repo -*----------------------------------------------------------------------* - -CLASS lcl_persistence_repo IMPLEMENTATION. - - METHOD add. - - DATA: ls_repo TYPE ty_repo, - lv_repo_as_xml TYPE string. - - - ls_repo-url = iv_url. - ls_repo-branch_name = iv_branch_name. - ls_repo-sha1 = iv_branch. - ls_repo-package = iv_package. - ls_repo-offline = iv_offline. - ls_repo-dot_abapgit = is_dot_abapgit. - - lv_repo_as_xml = to_xml( ls_repo ). - - rv_key = get_next_id( ). - - mo_db->add( iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = rv_key - iv_data = lv_repo_as_xml ). - - ENDMETHOD. - - METHOD update_dot_abapgit. - - DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, - ls_content LIKE LINE OF lt_content, - ls_repo TYPE ty_repo. - - - ASSERT NOT iv_key IS INITIAL. - - TRY. - ls_repo = read( iv_key ). - CATCH zcx_abapgit_not_found. - zcx_abapgit_exception=>raise( 'key not found' ). - ENDTRY. - - ls_repo-dot_abapgit = is_dot_abapgit. - ls_content-data_str = to_xml( ls_repo ). - - mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = iv_key - iv_data = ls_content-data_str ). - - ENDMETHOD. - - METHOD delete. - - DATA: lo_background TYPE REF TO lcl_persist_background. - - CREATE OBJECT lo_background. - lo_background->delete( iv_key ). - - mo_db->delete( iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = iv_key ). - - ENDMETHOD. - - METHOD update_local_checksums. - - DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, - ls_content LIKE LINE OF lt_content, - ls_repo TYPE ty_repo. - - - ASSERT NOT iv_key IS INITIAL. - - TRY. - ls_repo = read( iv_key ). - CATCH zcx_abapgit_not_found. - zcx_abapgit_exception=>raise( 'key not found' ). - ENDTRY. - - ls_repo-local_checksums = it_checksums. - ls_content-data_str = to_xml( ls_repo ). - - mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = iv_key - iv_data = ls_content-data_str ). - - ENDMETHOD. - - METHOD update_url. - - DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, - ls_content LIKE LINE OF lt_content, - ls_repo TYPE ty_repo. - - - IF iv_url IS INITIAL. - zcx_abapgit_exception=>raise( 'update, url empty' ). - ENDIF. - - ASSERT NOT iv_key IS INITIAL. - - TRY. - ls_repo = read( iv_key ). - CATCH zcx_abapgit_not_found. - zcx_abapgit_exception=>raise( 'key not found' ). - ENDTRY. - - ls_repo-url = iv_url. - ls_content-data_str = to_xml( ls_repo ). - - mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = iv_key - iv_data = ls_content-data_str ). - - ENDMETHOD. - - METHOD update_branch_name. - - DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, - ls_content LIKE LINE OF lt_content, - ls_repo TYPE ty_repo. - - - ASSERT NOT iv_key IS INITIAL. - - TRY. - ls_repo = read( iv_key ). - CATCH zcx_abapgit_not_found. - zcx_abapgit_exception=>raise( 'key not found' ). - ENDTRY. - - ls_repo-branch_name = iv_branch_name. - ls_content-data_str = to_xml( ls_repo ). - - mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = iv_key - iv_data = ls_content-data_str ). - - ENDMETHOD. - - METHOD update_head_branch. - - DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, - ls_content LIKE LINE OF lt_content, - ls_repo TYPE ty_repo. - - - ASSERT NOT iv_key IS INITIAL. - - TRY. - ls_repo = read( iv_key ). - CATCH zcx_abapgit_not_found. - zcx_abapgit_exception=>raise( 'key not found' ). - ENDTRY. - - ls_repo-head_branch = iv_head_branch. - ls_content-data_str = to_xml( ls_repo ). - - mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = iv_key - iv_data = ls_content-data_str ). - - ENDMETHOD. "update_head_branch - - METHOD update_offline. - - DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, - ls_content LIKE LINE OF lt_content, - ls_repo TYPE ty_repo. - - ASSERT NOT iv_key IS INITIAL. - - TRY. - ls_repo = read( iv_key ). - CATCH zcx_abapgit_not_found. - zcx_abapgit_exception=>raise( 'key not found' ). - ENDTRY. - - ls_repo-offline = iv_offline. - ls_content-data_str = to_xml( ls_repo ). - - mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = iv_key - iv_data = ls_content-data_str ). - - ENDMETHOD. "update_offline - - METHOD update_sha1. - - DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, - ls_content LIKE LINE OF lt_content, - ls_repo TYPE ty_repo. - - - ASSERT NOT iv_key IS INITIAL. - - TRY. - ls_repo = read( iv_key ). - CATCH zcx_abapgit_not_found. - zcx_abapgit_exception=>raise( 'key not found' ). - ENDTRY. - - ls_repo-sha1 = iv_branch_sha1. - ls_content-data_str = to_xml( ls_repo ). - - mo_db->update( iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = iv_key - iv_data = ls_content-data_str ). - - ENDMETHOD. - - METHOD read. - - DATA lt_repo TYPE tt_repo. - - lt_repo = list( ). - - READ TABLE lt_repo INTO rs_repo WITH KEY key = iv_key. - IF sy-subrc <> 0. - RAISE EXCEPTION TYPE zcx_abapgit_not_found. - ENDIF. - - ENDMETHOD. - - METHOD get_next_id. - -* todo: Lock the complete persistence in order to prevent concurrent repo-creation -* however the current approach will most likely work in almost all cases - - DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content. - - FIELD-SYMBOLS: LIKE LINE OF lt_content. - - - rv_next_repo_id = 1. - - lt_content = mo_db->list_by_type( zcl_abapgit_persistence_db=>c_type_repo ). - LOOP AT lt_content ASSIGNING . - IF -value >= rv_next_repo_id. - rv_next_repo_id = -value + 1. - ENDIF. - ENDLOOP. - - CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' - EXPORTING - input = rv_next_repo_id - IMPORTING - output = rv_next_repo_id. - - ENDMETHOD. - - METHOD list. - - DATA: lt_content TYPE zcl_abapgit_persistence_db=>tt_content, - ls_content LIKE LINE OF lt_content, - ls_repo LIKE LINE OF rt_repos. - - - lt_content = mo_db->list_by_type( zcl_abapgit_persistence_db=>c_type_repo ). - - LOOP AT lt_content INTO ls_content. - MOVE-CORRESPONDING from_xml( ls_content-data_str ) TO ls_repo. - ls_repo-key = ls_content-value. - INSERT ls_repo INTO TABLE rt_repos. - ENDLOOP. - - ENDMETHOD. - - METHOD from_xml. - - DATA: lv_xml TYPE string. - - lv_xml = iv_repo_xml_string. - -* fix downward compatibility - REPLACE ALL OCCURRENCES OF '<_--28C_TYPE_REPO_--29>' IN lv_xml WITH ''. - REPLACE ALL OCCURRENCES OF '' IN lv_xml WITH ''. - - CALL TRANSFORMATION id - OPTIONS value_handling = 'accept_data_loss' - SOURCE XML lv_xml - RESULT repo = rs_repo ##NO_TEXT. - - IF rs_repo IS INITIAL. - zcx_abapgit_exception=>raise( 'Inconsistent repo metadata' ). - ENDIF. - - ENDMETHOD. - - METHOD to_xml. - - DATA: ls_xml TYPE ty_repo_xml. - - - MOVE-CORRESPONDING is_repo TO ls_xml. - - CALL TRANSFORMATION id - SOURCE repo = ls_xml - RESULT XML rv_repo_xml_string. - ENDMETHOD. - - METHOD constructor. - mo_db = lcl_app=>db( ). - ENDMETHOD. - - METHOD lock. - - mo_db->lock( iv_mode = iv_mode - iv_type = zcl_abapgit_persistence_db=>c_type_repo - iv_value = iv_key ). - - ENDMETHOD. - -ENDCLASS. - -CLASS lcl_persist_migrate IMPLEMENTATION. - - METHOD run. - - IF table_exists( ) = abap_false. - table_create( ). - ENDIF. - - IF lock_exists( ) = abap_false. - lock_create( ). - ENDIF. - - IF settings_exists( ) = abap_false. - migrate_settings( ). - ENDIF. - - ENDMETHOD. - - METHOD settings_exists. - - TRY. - lcl_app=>db( )->read( - iv_type = 'SETTINGS' - iv_value = '' ). - rv_exists = abap_true. - CATCH zcx_abapgit_not_found. - rv_exists = abap_false. - ENDTRY. - ENDMETHOD. - - METHOD migrate_settings. - - DATA: lr_settings TYPE REF TO zcl_abapgit_settings. - DATA: lr_persist_settings TYPE REF TO lcl_persist_settings. - DATA: lv_critical_tests_as_string TYPE string. - DATA: lv_critical_tests_as_boolean TYPE abap_bool. - DATA: lv_max_lines_as_string TYPE string. - DATA: lv_flag TYPE abap_bool. - DATA: lv_max_lines_as_integer TYPE i. - DATA: lv_s_param_value TYPE string. - DATA: lv_i_param_value TYPE i. - DATA: lv_adt_jump_enabled_as_string TYPE string. - DATA: lv_adt_jump_enabled_as_boolean TYPE abap_bool. - - - CREATE OBJECT lr_persist_settings. - CREATE OBJECT lr_settings. - lr_settings->set_defaults( ). - - TRY. - lr_settings->set_proxy_url( - lcl_app=>db( )->read( - iv_type = 'SETTINGS' - iv_value = 'PROXY_URL' ) ). - CATCH zcx_abapgit_not_found. - ENDTRY. - - TRY. - lr_settings->set_proxy_port( - lcl_app=>db( )->read( - iv_type = 'SETTINGS' - iv_value = 'PROXY_PORT' ) ). - CATCH zcx_abapgit_not_found. - ENDTRY. - - TRY. - lv_flag = lcl_app=>db( )->read( - iv_type = 'SETTINGS' - iv_value = 'PROXY_AUTH' ). - lr_settings->set_proxy_authentication( lv_flag ). - CATCH zcx_abapgit_not_found. - ENDTRY. - - TRY. - lv_critical_tests_as_string = lcl_app=>db( )->read( - iv_type = 'SETTINGS' - iv_value = 'CRIT_TESTS' ). - lv_critical_tests_as_boolean = lv_critical_tests_as_string. - lr_settings->set_run_critical_tests( lv_critical_tests_as_boolean ). - CATCH zcx_abapgit_not_found. - ENDTRY. - - TRY. - lv_max_lines_as_string = lcl_app=>db( )->read( - iv_type = 'SETTINGS' - iv_value = 'MAX_LINES' ). - lv_max_lines_as_integer = lv_max_lines_as_string. - lr_settings->set_max_lines( lv_max_lines_as_integer ). - CATCH zcx_abapgit_not_found cx_sy_conversion_no_number. - ENDTRY. - - TRY. - lv_adt_jump_enabled_as_string = lcl_app=>db( )->read( - iv_type = 'SETTINGS' - iv_value = 'ADT_JUMP' ). - lv_adt_jump_enabled_as_boolean = lv_adt_jump_enabled_as_string. - lr_settings->set_adt_jump_enanbled( lv_adt_jump_enabled_as_boolean ). - CATCH zcx_abapgit_not_found. - ENDTRY. - - TRY. - lv_s_param_value = lcl_app=>db( )->read( - iv_type = 'SETTINGS' - iv_value = 'COMMENT_LEN' ). - lv_i_param_value = lv_s_param_value. - lr_settings->set_commitmsg_comment_length( lv_i_param_value ). - CATCH zcx_abapgit_not_found cx_sy_conversion_no_number. - ENDTRY. - - TRY. - lv_s_param_value = lcl_app=>db( )->read( - iv_type = 'SETTINGS' - iv_value = 'BODY_SIZE' ). - lv_i_param_value = lv_s_param_value. - lr_settings->set_commitmsg_body_size( lv_i_param_value ). - CATCH zcx_abapgit_not_found cx_sy_conversion_no_number. - ENDTRY. - - lr_persist_settings->modify( io_settings = lr_settings ). - - TRY. - lcl_app=>db( )->delete( - iv_type = 'SETTINGS' - iv_value = 'PROXY_URL' ). - CATCH zcx_abapgit_exception. - ENDTRY. - - TRY. - lcl_app=>db( )->delete( - iv_type = 'SETTINGS' - iv_value = 'PROXY_PORT' ). - CATCH zcx_abapgit_exception. - ENDTRY. - - TRY. - lcl_app=>db( )->delete( - iv_type = 'SETTINGS' - iv_value = 'PROXY_AUTH' ). - CATCH zcx_abapgit_exception. - ENDTRY. - - TRY. - lcl_app=>db( )->delete( - iv_type = 'SETTINGS' - iv_value = 'CRIT_TESTS' ). - CATCH zcx_abapgit_exception. - ENDTRY. - - TRY. - lcl_app=>db( )->delete( - iv_type = 'SETTINGS' - iv_value = 'MAX_LINES' ). - CATCH zcx_abapgit_exception. - ENDTRY. - - TRY. - lcl_app=>db( )->delete( - iv_type = 'SETTINGS' - iv_value = 'ADT_JUMP' ). - CATCH zcx_abapgit_exception. - ENDTRY. - - TRY. - lcl_app=>db( )->delete( - iv_type = 'SETTINGS' - iv_value = 'COMMENT_LEN' ). - CATCH zcx_abapgit_exception. - ENDTRY. - - TRY. - lcl_app=>db( )->delete( - iv_type = 'SETTINGS' - iv_value = 'BODY_SIZE' ). - CATCH zcx_abapgit_exception. - ENDTRY. - - ENDMETHOD. - - METHOD lock_exists. - - DATA: lv_viewname TYPE dd25l-viewname. - - - SELECT SINGLE viewname FROM dd25l INTO lv_viewname - WHERE viewname = zcl_abapgit_persistence_db=>c_lock. - rv_exists = boolc( sy-subrc = 0 ). - - ENDMETHOD. - - METHOD lock_create. - - DATA: lv_obj_name TYPE tadir-obj_name, - ls_dd25v TYPE dd25v, - lt_dd26e TYPE STANDARD TABLE OF dd26e WITH DEFAULT KEY, - lt_dd27p TYPE STANDARD TABLE OF dd27p WITH DEFAULT KEY. - - FIELD-SYMBOLS: LIKE LINE OF lt_dd26e, - LIKE LINE OF lt_dd27p. - - - ls_dd25v-viewname = zcl_abapgit_persistence_db=>c_lock. - ls_dd25v-aggtype = 'E'. - ls_dd25v-roottab = zcl_abapgit_persistence_db=>c_tabname. - ls_dd25v-ddlanguage = zif_abapgit_definitions=>gc_english. - ls_dd25v-ddtext = c_text. - - APPEND INITIAL LINE TO lt_dd26e ASSIGNING . - -viewname = zcl_abapgit_persistence_db=>c_lock. - -tabname = zcl_abapgit_persistence_db=>c_tabname. - -tabpos = '0001'. - -fortabname = zcl_abapgit_persistence_db=>c_tabname. - -enqmode = 'E'. - - APPEND INITIAL LINE TO lt_dd27p ASSIGNING . - -viewname = zcl_abapgit_persistence_db=>c_lock. - -objpos = '0001'. - -viewfield = 'TYPE'. - -tabname = zcl_abapgit_persistence_db=>c_tabname. - -fieldname = 'TYPE'. - -keyflag = abap_true. - - APPEND INITIAL LINE TO lt_dd27p ASSIGNING . - -viewname = zcl_abapgit_persistence_db=>c_lock. - -objpos = '0002'. - -viewfield = 'VALUE'. - -tabname = zcl_abapgit_persistence_db=>c_tabname. - -fieldname = 'VALUE'. - -keyflag = abap_true. - - CALL FUNCTION 'DDIF_ENQU_PUT' - EXPORTING - name = zcl_abapgit_persistence_db=>c_lock - dd25v_wa = ls_dd25v - TABLES - dd26e_tab = lt_dd26e - dd27p_tab = lt_dd27p - EXCEPTIONS - enqu_not_found = 1 - name_inconsistent = 2 - enqu_inconsistent = 3 - put_failure = 4 - put_refused = 5 - OTHERS = 6. - IF sy-subrc <> 0. - zcx_abapgit_exception=>raise( 'migrate, error from DDIF_ENQU_PUT' ). - ENDIF. - - lv_obj_name = zcl_abapgit_persistence_db=>c_lock. - CALL FUNCTION 'TR_TADIR_INTERFACE' - EXPORTING - wi_tadir_pgmid = 'R3TR' - wi_tadir_object = 'ENQU' - wi_tadir_obj_name = lv_obj_name - wi_set_genflag = abap_true - wi_test_modus = abap_false - wi_tadir_devclass = '$TMP' - EXCEPTIONS - OTHERS = 1. - IF sy-subrc <> 0. - zcx_abapgit_exception=>raise( 'migrate, error from TR_TADIR_INTERFACE' ). - ENDIF. - - CALL FUNCTION 'DDIF_ENQU_ACTIVATE' - EXPORTING - name = zcl_abapgit_persistence_db=>c_lock - EXCEPTIONS - not_found = 1 - put_failure = 2 - OTHERS = 3. - IF sy-subrc <> 0. - zcx_abapgit_exception=>raise( 'migrate, error from DDIF_ENQU_ACTIVATE' ). - ENDIF. - - ENDMETHOD. - - METHOD table_exists. - - DATA: lv_tabname TYPE dd02l-tabname. - - SELECT SINGLE tabname FROM dd02l INTO lv_tabname - WHERE tabname = zcl_abapgit_persistence_db=>c_tabname. - rv_exists = boolc( sy-subrc = 0 ). - - ENDMETHOD. - - METHOD table_create. - - DATA: lv_rc LIKE sy-subrc, - lv_obj_name TYPE tadir-obj_name, - ls_dd02v TYPE dd02v, - ls_dd09l TYPE dd09l, - lt_dd03p TYPE STANDARD TABLE OF dd03p WITH DEFAULT KEY. - - FIELD-SYMBOLS: LIKE LINE OF lt_dd03p. - - ls_dd02v-tabname = zcl_abapgit_persistence_db=>c_tabname. - ls_dd02v-ddlanguage = zif_abapgit_definitions=>gc_english. - ls_dd02v-tabclass = 'TRANSP'. - ls_dd02v-ddtext = c_text. - ls_dd02v-contflag = 'A'. - ls_dd02v-exclass = '1'. - - ls_dd09l-tabname = zcl_abapgit_persistence_db=>c_tabname. - ls_dd09l-as4local = 'A'. - ls_dd09l-tabkat = '1'. - ls_dd09l-tabart = 'APPL1'. - ls_dd09l-bufallow = 'N'. - - APPEND INITIAL LINE TO lt_dd03p ASSIGNING . - -tabname = zcl_abapgit_persistence_db=>c_tabname. - -fieldname = 'TYPE'. - -position = '0001'. - -keyflag = 'X'. - -datatype = 'CHAR'. - -leng = '000012'. - - APPEND INITIAL LINE TO lt_dd03p ASSIGNING . - -tabname = zcl_abapgit_persistence_db=>c_tabname. - -fieldname = 'VALUE'. - -position = '0002'. - -keyflag = 'X'. - -datatype = 'CHAR'. - -leng = '000012'. - - APPEND INITIAL LINE TO lt_dd03p ASSIGNING . - -tabname = zcl_abapgit_persistence_db=>c_tabname. - -fieldname = 'DATA_STR'. - -position = '0003'. - -datatype = 'STRG'. - - CALL FUNCTION 'DDIF_TABL_PUT' - EXPORTING - name = zcl_abapgit_persistence_db=>c_tabname - dd02v_wa = ls_dd02v - dd09l_wa = ls_dd09l - TABLES - dd03p_tab = lt_dd03p - EXCEPTIONS - tabl_not_found = 1 - name_inconsistent = 2 - tabl_inconsistent = 3 - put_failure = 4 - put_refused = 5 - OTHERS = 6. - IF sy-subrc <> 0. - zcx_abapgit_exception=>raise( 'migrate, error from DDIF_TABL_PUT' ). - ENDIF. - - lv_obj_name = zcl_abapgit_persistence_db=>c_tabname. - CALL FUNCTION 'TR_TADIR_INTERFACE' - EXPORTING - wi_tadir_pgmid = 'R3TR' - wi_tadir_object = 'TABL' - wi_tadir_obj_name = lv_obj_name - wi_set_genflag = abap_true - wi_test_modus = abap_false - wi_tadir_devclass = '$TMP' - EXCEPTIONS - OTHERS = 1. - IF sy-subrc <> 0. - zcx_abapgit_exception=>raise( 'migrate, error from TR_TADIR_INTERFACE' ). - ENDIF. - - CALL FUNCTION 'DDIF_TABL_ACTIVATE' - EXPORTING - name = zcl_abapgit_persistence_db=>c_tabname - auth_chk = abap_false - IMPORTING - rc = lv_rc - EXCEPTIONS - not_found = 1 - put_failure = 2 - OTHERS = 3. - IF sy-subrc <> 0 OR lv_rc <> 0. - zcx_abapgit_exception=>raise( 'migrate, error from DDIF_TABL_ACTIVATE' ). - ENDIF. - - ENDMETHOD. - -ENDCLASS. - -CLASS lcl_persist_settings IMPLEMENTATION. - - METHOD modify. - - DATA: settings TYPE string. - settings = io_settings->get_settings_xml( ). - - lcl_app=>db( )->modify( - iv_type = zcl_abapgit_persistence_db=>c_type_settings - iv_value = '' - iv_data = settings ). - - " Settings have been modified: Update Buffered Settings - IF mo_settings IS BOUND. - mo_settings->set_xml_settings( settings ). - ENDIF. - - ENDMETHOD. - - METHOD read. - - IF mo_settings IS BOUND. - " Return Buffered Settings - ro_settings = mo_settings. - RETURN. - ENDIF. - - " Settings have changed or have not yet been loaded - CREATE OBJECT ro_settings. - - TRY. - - ro_settings->set_xml_settings( - lcl_app=>db( )->read( iv_type = zcl_abapgit_persistence_db=>c_type_settings - iv_value = '' ) ). - - CATCH zcx_abapgit_not_found zcx_abapgit_exception. - - ro_settings->set_defaults( ). - - ENDTRY. - - mo_settings = ro_settings. - - ENDMETHOD. - -ENDCLASS. +* todo, include to be deleted diff --git a/src/zabapgit_proxy.prog.abap b/src/zabapgit_proxy.prog.abap index 1788defd1..9cfd7cb3d 100644 --- a/src/zabapgit_proxy.prog.abap +++ b/src/zabapgit_proxy.prog.abap @@ -36,7 +36,7 @@ CLASS lcl_proxy_configuration IMPLEMENTATION. METHOD constructor. - mo_settings = lcl_app=>settings( )->read( ). + mo_settings = zcl_abapgit_persist_settings=>get_instance( )->read( ). mi_exit = lcl_exit=>get_instance( ). diff --git a/src/zabapgit_repo.prog.abap b/src/zabapgit_repo.prog.abap index 08b2635b0..8ba23f1a7 100644 --- a/src/zabapgit_repo.prog.abap +++ b/src/zabapgit_repo.prog.abap @@ -10,7 +10,7 @@ CLASS lcl_repo DEFINITION ABSTRACT FRIENDS lcl_repo_srv. PUBLIC SECTION. METHODS: constructor - IMPORTING is_data TYPE lcl_persistence_repo=>ty_repo, + IMPORTING is_data TYPE zcl_abapgit_persistence_repo=>ty_repo, get_key RETURNING VALUE(rv_key) TYPE zcl_abapgit_persistence_db=>ty_value, get_name @@ -22,14 +22,14 @@ CLASS lcl_repo DEFINITION ABSTRACT FRIENDS lcl_repo_srv. RETURNING VALUE(rt_files) TYPE zif_abapgit_definitions=>ty_files_item_tt RAISING zcx_abapgit_exception, get_local_checksums - RETURNING VALUE(rt_checksums) TYPE lcl_persistence_repo=>ty_local_checksum_tt, + RETURNING VALUE(rt_checksums) TYPE zcl_abapgit_persistence_repo=>ty_local_checksum_tt, get_local_checksums_per_file RETURNING VALUE(rt_checksums) TYPE zif_abapgit_definitions=>ty_file_signatures_tt, get_files_remote RETURNING VALUE(rt_files) TYPE zif_abapgit_definitions=>ty_files_tt RAISING zcx_abapgit_exception, get_package - RETURNING VALUE(rv_package) TYPE lcl_persistence_repo=>ty_repo-package, + RETURNING VALUE(rv_package) TYPE zcl_abapgit_persistence_repo=>ty_repo-package, get_master_language RETURNING VALUE(rv_language) TYPE spras, is_write_protected @@ -69,17 +69,17 @@ CLASS lcl_repo DEFINITION ABSTRACT FRIENDS lcl_repo_srv. mt_remote TYPE zif_abapgit_definitions=>ty_files_tt, mv_do_local_refresh TYPE abap_bool, mv_last_serialization TYPE timestamp, - ms_data TYPE lcl_persistence_repo=>ty_repo. + ms_data TYPE zcl_abapgit_persistence_repo=>ty_repo. METHODS: set IMPORTING iv_sha1 TYPE zif_abapgit_definitions=>ty_sha1 OPTIONAL - it_checksums TYPE lcl_persistence_repo=>ty_local_checksum_tt OPTIONAL - iv_url TYPE lcl_persistence_repo=>ty_repo-url OPTIONAL - iv_branch_name TYPE lcl_persistence_repo=>ty_repo-branch_name OPTIONAL - iv_head_branch TYPE lcl_persistence_repo=>ty_repo-head_branch OPTIONAL - iv_offline TYPE lcl_persistence_repo=>ty_repo-offline OPTIONAL - is_dot_abapgit TYPE lcl_persistence_repo=>ty_repo-dot_abapgit OPTIONAL + it_checksums TYPE zcl_abapgit_persistence_repo=>ty_local_checksum_tt OPTIONAL + iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url OPTIONAL + iv_branch_name TYPE zcl_abapgit_persistence_repo=>ty_repo-branch_name OPTIONAL + iv_head_branch TYPE zcl_abapgit_persistence_repo=>ty_repo-head_branch OPTIONAL + iv_offline TYPE zcl_abapgit_persistence_repo=>ty_repo-offline OPTIONAL + is_dot_abapgit TYPE zcl_abapgit_persistence_repo=>ty_repo-dot_abapgit OPTIONAL RAISING zcx_abapgit_exception. ENDCLASS. "lcl_repo DEFINITION @@ -93,31 +93,31 @@ CLASS lcl_repo_online DEFINITION INHERITING FROM lcl_repo FINAL. METHODS: refresh REDEFINITION, constructor - IMPORTING is_data TYPE lcl_persistence_repo=>ty_repo + IMPORTING is_data TYPE zcl_abapgit_persistence_repo=>ty_repo RAISING zcx_abapgit_exception, get_url - RETURNING VALUE(rv_url) TYPE lcl_persistence_repo=>ty_repo-url, + RETURNING VALUE(rv_url) TYPE zcl_abapgit_persistence_repo=>ty_repo-url, get_branch_name - RETURNING VALUE(rv_name) TYPE lcl_persistence_repo=>ty_repo-branch_name, + RETURNING VALUE(rv_name) TYPE zcl_abapgit_persistence_repo=>ty_repo-branch_name, get_head_branch_name - RETURNING VALUE(rv_name) TYPE lcl_persistence_repo=>ty_repo-head_branch, + RETURNING VALUE(rv_name) TYPE zcl_abapgit_persistence_repo=>ty_repo-head_branch, get_branches RETURNING VALUE(ro_branches) TYPE REF TO zcl_abapgit_git_branch_list RAISING zcx_abapgit_exception, set_url - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url + IMPORTING iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url RAISING zcx_abapgit_exception, set_branch_name - IMPORTING iv_branch_name TYPE lcl_persistence_repo=>ty_repo-branch_name + IMPORTING iv_branch_name TYPE zcl_abapgit_persistence_repo=>ty_repo-branch_name RAISING zcx_abapgit_exception, set_new_remote - IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url - iv_branch_name TYPE lcl_persistence_repo=>ty_repo-branch_name + IMPORTING iv_url TYPE zcl_abapgit_persistence_repo=>ty_repo-url + iv_branch_name TYPE zcl_abapgit_persistence_repo=>ty_repo-branch_name RAISING zcx_abapgit_exception, get_sha1_local - RETURNING VALUE(rv_sha1) TYPE lcl_persistence_repo=>ty_repo-sha1, + RETURNING VALUE(rv_sha1) TYPE zcl_abapgit_persistence_repo=>ty_repo-sha1, get_sha1_remote - RETURNING VALUE(rv_sha1) TYPE lcl_persistence_repo=>ty_repo-sha1 + RETURNING VALUE(rv_sha1) TYPE zcl_abapgit_persistence_repo=>ty_repo-sha1 RAISING zcx_abapgit_exception, get_files_remote REDEFINITION, get_objects @@ -230,7 +230,7 @@ CLASS lcl_repo_srv DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_app. METHODS constructor. DATA: mv_init TYPE abap_bool VALUE abap_false, - mo_persistence TYPE REF TO lcl_persistence_repo, + mo_persistence TYPE REF TO zcl_abapgit_persistence_repo, mt_list TYPE ty_repo_tt. METHODS is_sap_object_allowed diff --git a/src/zabapgit_repo_impl.prog.abap b/src/zabapgit_repo_impl.prog.abap index 6b54b81e3..73ce6dea7 100644 --- a/src/zabapgit_repo_impl.prog.abap +++ b/src/zabapgit_repo_impl.prog.abap @@ -261,7 +261,7 @@ CLASS lcl_repo_online IMPLEMENTATION. lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, ls_last_item TYPE zif_abapgit_definitions=>ty_item, lv_branch_equal TYPE abap_bool, - lt_checksums TYPE lcl_persistence_repo=>ty_local_checksum_tt. + lt_checksums TYPE zcl_abapgit_persistence_repo=>ty_local_checksum_tt. FIELD-SYMBOLS: LIKE LINE OF lt_checksums, LIKE LINE OF -files, @@ -330,7 +330,7 @@ CLASS lcl_repo_online IMPLEMENTATION. lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lt_remote TYPE zif_abapgit_definitions=>ty_files_tt, lt_status TYPE zif_abapgit_definitions=>ty_results_tt, - lv_package TYPE lcl_persistence_repo=>ty_repo-package. + lv_package TYPE zcl_abapgit_persistence_repo=>ty_repo-package. FIELD-SYMBOLS: TYPE zif_abapgit_definitions=>ty_result, TYPE zif_abapgit_definitions=>ty_tadir. @@ -404,7 +404,7 @@ CLASS lcl_repo IMPLEMENTATION. METHOD set. - DATA: lo_persistence TYPE REF TO lcl_persistence_repo. + DATA: lo_persistence TYPE REF TO zcl_abapgit_persistence_repo. ASSERT iv_sha1 IS SUPPLIED @@ -474,7 +474,7 @@ CLASS lcl_repo IMPLEMENTATION. " Push fills it from local files before pushing, deserialize from remote " If this is not true that there is an error somewhere but not here - DATA: lt_checksums TYPE lcl_persistence_repo=>ty_local_checksum_tt, + DATA: lt_checksums TYPE zcl_abapgit_persistence_repo=>ty_local_checksum_tt, lt_files_idx TYPE zif_abapgit_definitions=>ty_file_signatures_tt, lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lv_chks_row TYPE i, @@ -707,7 +707,7 @@ CLASS lcl_repo IMPLEMENTATION. METHOD delete. - DATA: lo_persistence TYPE REF TO lcl_persistence_repo. + DATA: lo_persistence TYPE REF TO zcl_abapgit_persistence_repo. CREATE OBJECT lo_persistence. @@ -775,7 +775,7 @@ CLASS lcl_repo IMPLEMENTATION. DATA: lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, ls_last_item TYPE zif_abapgit_definitions=>ty_item, - lt_checksums TYPE lcl_persistence_repo=>ty_local_checksum_tt. + lt_checksums TYPE zcl_abapgit_persistence_repo=>ty_local_checksum_tt. FIELD-SYMBOLS: LIKE LINE OF lt_checksums, LIKE LINE OF -files, @@ -852,7 +852,7 @@ CLASS lcl_repo_srv IMPLEMENTATION. METHOD refresh. - DATA: lt_list TYPE lcl_persistence_repo=>tt_repo, + DATA: lt_list TYPE zcl_abapgit_persistence_repo=>tt_repo, lo_online TYPE REF TO lcl_repo_online, lo_offline TYPE REF TO lcl_repo_offline. @@ -882,8 +882,8 @@ CLASS lcl_repo_srv IMPLEMENTATION. METHOD new_online. - DATA: ls_repo TYPE lcl_persistence_repo=>ty_repo, - lv_key TYPE lcl_persistence_repo=>ty_repo-key. + DATA: ls_repo TYPE zcl_abapgit_persistence_repo=>ty_repo, + lv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key. validate_package( iv_package ). @@ -910,8 +910,8 @@ CLASS lcl_repo_srv IMPLEMENTATION. METHOD new_offline. - DATA: ls_repo TYPE lcl_persistence_repo=>ty_repo, - lv_key TYPE lcl_persistence_repo=>ty_repo-key. + DATA: ls_repo TYPE zcl_abapgit_persistence_repo=>ty_repo, + lv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key. validate_package( iv_package ). @@ -958,7 +958,7 @@ CLASS lcl_repo_srv IMPLEMENTATION. METHOD validate_package. DATA: ls_devclass TYPE tdevc, - lt_repos TYPE lcl_persistence_repo=>tt_repo. + lt_repos TYPE zcl_abapgit_persistence_repo=>tt_repo. IF iv_package IS INITIAL. zcx_abapgit_exception=>raise( 'add, package empty' ). diff --git a/src/zabapgit_services_background.prog.abap b/src/zabapgit_services_background.prog.abap index 4138a0c6d..9cd0f5d56 100644 --- a/src/zabapgit_services_background.prog.abap +++ b/src/zabapgit_services_background.prog.abap @@ -7,7 +7,7 @@ CLASS lcl_services_bkg DEFINITION FINAL. PUBLIC SECTION. CLASS-METHODS update_task - IMPORTING is_bg_task TYPE lcl_persist_background=>ty_background + IMPORTING is_bg_task TYPE zcl_abapgit_persist_background=>ty_background RAISING zcx_abapgit_exception. ENDCLASS. "lcl_services_background @@ -16,11 +16,11 @@ CLASS lcl_services_bkg IMPLEMENTATION. METHOD update_task. - DATA lo_persistence TYPE REF TO lcl_persist_background. + DATA lo_persistence TYPE REF TO zcl_abapgit_persist_background. CREATE OBJECT lo_persistence. - IF is_bg_task-method = lcl_persist_background=>c_method-nothing. + IF is_bg_task-method = zcl_abapgit_persist_background=>c_method-nothing. lo_persistence->delete( is_bg_task-key ). ELSE. lo_persistence->modify( is_bg_task ). diff --git a/src/zabapgit_services_db.prog.abap b/src/zabapgit_services_db.prog.abap index fd4e8dd9c..bc6edf24c 100644 --- a/src/zabapgit_services_db.prog.abap +++ b/src/zabapgit_services_db.prog.abap @@ -38,7 +38,7 @@ CLASS lcl_services_db IMPLEMENTATION. RAISE EXCEPTION TYPE zcx_abapgit_cancel. ENDIF. - lcl_app=>db( )->delete( + zcl_abapgit_persistence_db=>get_instance( )->delete( iv_type = is_key-type iv_value = is_key-value ). @@ -50,7 +50,7 @@ CLASS lcl_services_db IMPLEMENTATION. ASSERT is_content-type IS NOT INITIAL. - lcl_app=>db( )->update( + zcl_abapgit_persistence_db=>get_instance( )->update( iv_type = is_content-type iv_value = is_content-value iv_data = is_content-data_str ). diff --git a/src/zabapgit_services_git.prog.abap b/src/zabapgit_services_git.prog.abap index c600200eb..042c51098 100644 --- a/src/zabapgit_services_git.prog.abap +++ b/src/zabapgit_services_git.prog.abap @@ -6,7 +6,7 @@ CLASS lcl_services_git DEFINITION FINAL. PUBLIC SECTION. TYPES: BEGIN OF ty_commit_fields, - repo_key TYPE lcl_persistence_repo=>ty_repo-key, + repo_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key, committer_name TYPE string, committer_email TYPE string, author_name TYPE string, @@ -16,35 +16,35 @@ CLASS lcl_services_git DEFINITION FINAL. END OF ty_commit_fields. CLASS-METHODS pull - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS reset - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS create_branch - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS switch_branch - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS delete_branch - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS create_tag - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS delete_tag - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS tag_overview - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS commit @@ -299,9 +299,9 @@ CLASS lcl_services_git IMPLEMENTATION. METHOD commit. DATA: ls_comment TYPE zif_abapgit_definitions=>ty_comment, - lo_user TYPE REF TO lcl_persistence_user. + lo_user TYPE REF TO zcl_abapgit_persistence_user. - lo_user = lcl_app=>user( ). + lo_user = zcl_abapgit_persistence_user=>get_instance( ). lo_user->set_repo_git_user_name( iv_url = io_repo->get_url( ) iv_username = is_commit-committer_name ). lo_user->set_repo_git_user_email( iv_url = io_repo->get_url( ) diff --git a/src/zabapgit_services_repo.prog.abap b/src/zabapgit_services_repo.prog.abap index f35b55479..6d1ab7711 100644 --- a/src/zabapgit_services_repo.prog.abap +++ b/src/zabapgit_services_repo.prog.abap @@ -9,38 +9,38 @@ CLASS lcl_services_repo DEFINITION FINAL. RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS refresh - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception. CLASS-METHODS remove - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS purge - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS new_offline RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS remote_attach - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS remote_detach - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS remote_change - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS refresh_local_checksums - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception zcx_abapgit_cancel. CLASS-METHODS toggle_favorite - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception. CLASS-METHODS open_se80 @@ -78,7 +78,7 @@ CLASS lcl_services_repo IMPLEMENTATION. lo_repo->status( ). " check for errors lo_repo->deserialize( ). - lcl_app=>user( )->set_repo_show( lo_repo->get_key( ) ). " Set default repo for user + zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( lo_repo->get_key( ) ). " Set default repo for user COMMIT WORK. @@ -184,7 +184,7 @@ CLASS lcl_services_repo IMPLEMENTATION. iv_url = ls_popup-url iv_package = ls_popup-package ). - lcl_app=>user( )->set_repo_show( lo_repo->get_key( ) ). " Set default repo for user + zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( lo_repo->get_key( ) ). " Set default repo for user toggle_favorite( lo_repo->get_key( ) ). COMMIT WORK. @@ -304,7 +304,7 @@ CLASS lcl_services_repo IMPLEMENTATION. METHOD toggle_favorite. - lcl_app=>user( )->toggle_favorite( iv_key ). + zcl_abapgit_persistence_user=>get_instance( )->toggle_favorite( iv_key ). ENDMETHOD. " toggle_favorite. diff --git a/src/zabapgit_transport.prog.abap b/src/zabapgit_transport.prog.abap index fa23149f8..a806b7120 100644 --- a/src/zabapgit_transport.prog.abap +++ b/src/zabapgit_transport.prog.abap @@ -32,7 +32,7 @@ CLASS lcl_transport IMPLEMENTATION. DATA: lt_requests TYPE trwbo_requests, lt_tadir TYPE scts_tadir, lv_package TYPE devclass, - ls_data TYPE lcl_persistence_repo=>ty_repo, + ls_data TYPE zcl_abapgit_persistence_repo=>ty_repo, lo_repo TYPE REF TO lcl_repo_offline, lt_trkorr TYPE trwbo_request_headers. diff --git a/src/zabapgit_unit_test.prog.abap b/src/zabapgit_unit_test.prog.abap index 09e419bde..56f8e9ae8 100644 --- a/src/zabapgit_unit_test.prog.abap +++ b/src/zabapgit_unit_test.prog.abap @@ -52,7 +52,8 @@ CLASS ltcl_critical_tests IMPLEMENTATION. METHOD check_run_permission. DATA: lo_settings TYPE REF TO zcl_abapgit_settings. - lo_settings = lcl_app=>settings( )->read( ). + + lo_settings = zcl_abapgit_persist_settings=>get_instance( )->read( ). "Objects will be created and deleted, do not run in customer system! "These tests may fail if you are locking the entries (e.g. the ZABAPGIT transaction is open) @@ -1375,7 +1376,7 @@ CLASS ltcl_persistence_settings DEFINITION FINAL FOR TESTING read_run_critical_tests FOR TESTING RAISING cx_static_check, read_not_found_critical_tests FOR TESTING RAISING cx_static_check. DATA: - mo_persistence_settings TYPE REF TO lcl_persist_settings, + mo_persistence_settings TYPE REF TO zcl_abapgit_persist_settings, mo_settings TYPE REF TO zcl_abapgit_settings. ENDCLASS. @@ -1386,7 +1387,7 @@ CLASS ltcl_persistence_settings IMPLEMENTATION. ENDMETHOD. METHOD setup. - CREATE OBJECT mo_persistence_settings. + mo_persistence_settings = zcl_abapgit_persist_settings=>get_instance( ). CREATE OBJECT mo_settings. clear_settings_database( ). ENDMETHOD. @@ -1398,7 +1399,7 @@ CLASS ltcl_persistence_settings IMPLEMENTATION. mo_persistence_settings->modify( mo_settings ). - lv_proxy_url = lcl_app=>db( )->read( + lv_proxy_url = zcl_abapgit_persistence_db=>get_instance( )->read( iv_type = 'SETTINGS' iv_value = 'PROXY_URL' ). @@ -1413,7 +1414,7 @@ CLASS ltcl_persistence_settings IMPLEMENTATION. mo_persistence_settings->modify( mo_settings ). - lv_proxy_port = lcl_app=>db( )->read( + lv_proxy_port = zcl_abapgit_persistence_db=>get_instance( )->read( iv_type = 'SETTINGS' iv_value = 'PROXY_PORT' ). @@ -1423,12 +1424,12 @@ CLASS ltcl_persistence_settings IMPLEMENTATION. ENDMETHOD. METHOD read_proxy_settings. - lcl_app=>db( )->modify( + zcl_abapgit_persistence_db=>get_instance( )->modify( iv_type = 'SETTINGS' iv_value = 'PROXY_URL' iv_data = 'A_URL' ). - lcl_app=>db( )->modify( + zcl_abapgit_persistence_db=>get_instance( )->modify( iv_type = 'SETTINGS' iv_value = 'PROXY_PORT' iv_data = '1000' ). @@ -1466,7 +1467,7 @@ CLASS ltcl_persistence_settings IMPLEMENTATION. mo_persistence_settings->modify( mo_settings ). - lv_run_critical_tests = lcl_app=>db( )->read( + lv_run_critical_tests = zcl_abapgit_persistence_db=>get_instance( )->read( iv_type = 'SETTINGS' iv_value = 'CRIT_TESTS' ). @@ -1476,7 +1477,7 @@ CLASS ltcl_persistence_settings IMPLEMENTATION. ENDMETHOD. METHOD read_run_critical_tests. - lcl_app=>db( )->modify( + zcl_abapgit_persistence_db=>get_instance( )->modify( iv_type = 'SETTINGS' iv_value = 'CRIT_TESTS' iv_data = 'X' ). @@ -1498,21 +1499,21 @@ CLASS ltcl_persistence_settings IMPLEMENTATION. METHOD clear_settings_database. TRY. - lcl_app=>db( )->delete( + zcl_abapgit_persistence_db=>get_instance( )->delete( iv_type = 'SETTINGS' iv_value = 'PROXY_URL' ). CATCH cx_static_check ##NO_HANDLER. "If entry didn't exist, that's okay ENDTRY. TRY. - lcl_app=>db( )->delete( + zcl_abapgit_persistence_db=>get_instance( )->delete( iv_type = 'SETTINGS' iv_value = 'PROXY_PORT' ). CATCH cx_static_check ##NO_HANDLER. "If entry didn't exist, that's okay ENDTRY. TRY. - lcl_app=>db( )->delete( + zcl_abapgit_persistence_db=>get_instance( )->delete( iv_type = 'SETTINGS' iv_value = 'CRIT_TESTS' ). CATCH cx_static_check ##NO_HANDLER. diff --git a/src/zabapgit_view_repo.prog.abap b/src/zabapgit_view_repo.prog.abap index 3ed4330fc..03cb7e781 100644 --- a/src/zabapgit_view_repo.prog.abap +++ b/src/zabapgit_view_repo.prog.abap @@ -18,7 +18,7 @@ CLASS lcl_gui_view_repo DEFINITION FINAL. END OF c_actions. METHODS constructor - IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key + IMPORTING iv_key TYPE zcl_abapgit_persistence_repo=>ty_repo-key RAISING zcx_abapgit_exception. PRIVATE SECTION. @@ -87,11 +87,11 @@ CLASS lcl_gui_view_repo IMPLEMENTATION. mo_repo = lcl_app=>repo_srv( )->get( iv_key ). mv_cur_dir = '/'. " Root - mv_hide_files = lcl_app=>user( )->get_hide_files( ). - mv_changes_only = lcl_app=>user( )->get_changes_only( ). + mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->get_hide_files( ). + mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->get_changes_only( ). " Read global settings to get max # of objects to be listed - lo_settings = lcl_app=>settings( )->read( ). + lo_settings = zcl_abapgit_persist_settings=>get_instance( )->read( ). mv_max_lines = lo_settings->get_max_lines( ). mv_max_setting = mv_max_lines. @@ -103,7 +103,7 @@ CLASS lcl_gui_view_repo IMPLEMENTATION. CASE iv_action. WHEN c_actions-toggle_hide_files. " Toggle file diplay - mv_hide_files = lcl_app=>user( )->toggle_hide_files( ). + mv_hide_files = zcl_abapgit_persistence_user=>get_instance( )->toggle_hide_files( ). ev_state = zif_abapgit_definitions=>gc_event_state-re_render. WHEN c_actions-change_dir. " Change dir lv_path = lcl_html_action_utils=>dir_decode( iv_getdata ). @@ -114,7 +114,7 @@ CLASS lcl_gui_view_repo IMPLEMENTATION. mv_cur_dir = '/'. " Root ev_state = zif_abapgit_definitions=>gc_event_state-re_render. WHEN c_actions-toggle_changes. " Toggle changes only view - mv_changes_only = lcl_app=>user( )->toggle_changes_only( ). + mv_changes_only = zcl_abapgit_persistence_user=>get_instance( )->toggle_changes_only( ). ev_state = zif_abapgit_definitions=>gc_event_state-re_render. WHEN c_actions-display_more. " Increase MAX lines limit mv_max_lines = mv_max_lines + mv_max_setting. diff --git a/src/zabapgit_zip.prog.abap b/src/zabapgit_zip.prog.abap index 26f5373c5..41419d816 100644 --- a/src/zabapgit_zip.prog.abap +++ b/src/zabapgit_zip.prog.abap @@ -385,7 +385,7 @@ CLASS lcl_zip IMPLEMENTATION. METHOD export_package. DATA: lo_repo TYPE REF TO lcl_repo_offline, - ls_data TYPE lcl_persistence_repo=>ty_repo. + ls_data TYPE zcl_abapgit_persistence_repo=>ty_repo. ls_data-key = 'DUMMY'.