Skip to content

Commit

Permalink
update (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
larshp authored Sep 30, 2023
1 parent 4ad3489 commit c9e2741
Show file tree
Hide file tree
Showing 19 changed files with 421 additions and 241 deletions.
33 changes: 22 additions & 11 deletions cloud/zcl_abapgit_abap_language_vers.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ CLASS ltcl_abap_language_version DEFINITION FOR TESTING RISK LEVEL HARMLESS
CONSTANTS c_cloud_package TYPE I_CustABAPObjDirectoryEntry-ABAPPackage VALUE 'TEST_LANGUAGE_VERSION_SCP'.

DATA:
mt_versions TYPE string_table,
mo_environment TYPE REF TO lcl_environment,
mi_persistency TYPE REF TO zif_abapgit_persist_settings,
mo_dot_abapgit TYPE REF TO zcl_abapgit_dot_abapgit,
mo_cut TYPE REF TO zcl_abapgit_abap_language_vers.
mt_versions TYPE string_table,
mv_has_cloud_package TYPE abap_bool,
mo_environment TYPE REF TO lcl_environment,
mi_persistency TYPE REF TO zif_abapgit_persist_settings,
mo_dot_abapgit TYPE REF TO zcl_abapgit_dot_abapgit,
mo_cut TYPE REF TO zcl_abapgit_abap_language_vers.

METHODS:
setup,
Expand Down Expand Up @@ -134,6 +135,8 @@ CLASS ltcl_abap_language_version IMPLEMENTATION.
APPEND zif_abapgit_dot_abapgit=>c_abap_language_version-standard TO mt_versions.
APPEND zif_abapgit_dot_abapgit=>c_abap_language_version-key_user TO mt_versions.
APPEND zif_abapgit_dot_abapgit=>c_abap_language_version-cloud_development TO mt_versions.

mv_has_cloud_package = zcl_abapgit_factory=>get_sap_package( c_cloud_package )->exists( ).
ENDMETHOD.

METHOD init.
Expand Down Expand Up @@ -257,6 +260,10 @@ CLASS ltcl_abap_language_version IMPLEMENTATION.
msg = |ABAP Language Version: { iv_version }, On-prem| ).

" Assume cloud platform
IF mv_has_cloud_package = abap_false.
RETURN.
ENDIF.

set_environment( abap_true ).

" source code
Expand Down Expand Up @@ -342,9 +349,11 @@ CLASS ltcl_abap_language_version IMPLEMENTATION.
act = mo_cut->is_import_allowed( '$TMP' ) " existing standard package
exp = iv_standard ).

cl_abap_unit_assert=>assert_equals(
act = mo_cut->is_import_allowed( c_cloud_package ) " existing cloud package
exp = iv_cloud ).
IF mv_has_cloud_package = abap_true.
cl_abap_unit_assert=>assert_equals(
act = mo_cut->is_import_allowed( c_cloud_package ) " existing cloud package
exp = iv_cloud ).
ENDIF.

cl_abap_unit_assert=>assert_equals(
act = mo_cut->is_import_allowed( 'Z_FOO_BAR' ) " non-existing package
Expand All @@ -357,9 +366,11 @@ CLASS ltcl_abap_language_version IMPLEMENTATION.
act = mo_cut->is_import_allowed( '$TMP' ) " existing standard package
exp = iv_standard ).

cl_abap_unit_assert=>assert_equals(
act = mo_cut->is_import_allowed( c_cloud_package ) " existing cloud package
exp = iv_cloud ).
IF mv_has_cloud_package = abap_true.
cl_abap_unit_assert=>assert_equals(
act = mo_cut->is_import_allowed( c_cloud_package ) " existing cloud package
exp = iv_cloud ).
ENDIF.

cl_abap_unit_assert=>assert_equals(
act = mo_cut->is_import_allowed( 'Z_FOO_BAR' ) " non-existing package
Expand Down
48 changes: 37 additions & 11 deletions cloud/zcl_abapgit_html_action_utils.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ TYPES tihttpnvp TYPE STANDARD TABLE OF ty WITH DEFAULT KEY.
!ig_field TYPE any
CHANGING
!ct_field TYPE tihttpnvp .

CLASS-METHODS fields_to_string
IMPORTING
!it_fields TYPE tihttpnvp
RETURNING
VALUE(rv_string) TYPE string.
ENDCLASS.


Expand Down Expand Up @@ -82,31 +88,52 @@ CLASS zcl_abapgit_html_action_utils IMPLEMENTATION.

METHOD dbkey_encode.

DATA: lt_fields TYPE tihttpnvp.
DATA lt_fields TYPE tihttpnvp.

add_field( EXPORTING iv_name = 'TYPE'
ig_field = is_key-type CHANGING ct_field = lt_fields ).
add_field( EXPORTING iv_name = 'VALUE'
ig_field = is_key-value CHANGING ct_field = lt_fields ).

rv_string = zcl_abapgit_http_utility=>fields_to_string( lt_fields ).
rv_string = fields_to_string( lt_fields ).

ENDMETHOD.


METHOD dir_encode.

DATA: lt_fields TYPE tihttpnvp.
DATA lt_fields TYPE tihttpnvp.
add_field( EXPORTING iv_name = 'PATH'
ig_field = iv_path CHANGING ct_field = lt_fields ).
rv_string = zcl_abapgit_http_utility=>fields_to_string( lt_fields ).
rv_string = fields_to_string( lt_fields ).

ENDMETHOD.


METHOD fields_to_string.

* There is no equivalent to cl_web_http_utility=>fields_to_string released in ABAP Cloud,
* see cl_web_http_utility

DATA lt_tab TYPE STANDARD TABLE OF string WITH DEFAULT KEY.
DATA lv_str TYPE string.
DATA ls_field LIKE LINE OF it_fields.

LOOP AT it_fields INTO ls_field.
ls_field-value = cl_web_http_utility=>escape_url( ls_field-value ).
lv_str = ls_field-name && '=' && ls_field-value.
APPEND lv_str TO lt_tab.
ENDLOOP.
rv_string = concat_lines_of(
table = lt_tab
sep = '&' ).

ENDMETHOD.


METHOD file_encode.

DATA: lt_fields TYPE tihttpnvp.
DATA lt_fields TYPE tihttpnvp.


add_field( EXPORTING iv_name = 'KEY'
Expand All @@ -116,14 +143,14 @@ CLASS zcl_abapgit_html_action_utils IMPLEMENTATION.
add_field( EXPORTING iv_name = 'FILENAME'
ig_field = ig_file CHANGING ct_field = lt_fields ).

rv_string = zcl_abapgit_http_utility=>fields_to_string( lt_fields ).
rv_string = fields_to_string( lt_fields ).

ENDMETHOD.


METHOD jump_encode.

DATA: lt_fields TYPE tihttpnvp.
DATA lt_fields TYPE tihttpnvp.


add_field( EXPORTING iv_name = 'TYPE'
Expand All @@ -136,14 +163,14 @@ CLASS zcl_abapgit_html_action_utils IMPLEMENTATION.
ig_field = iv_filename CHANGING ct_field = lt_fields ).
ENDIF.

rv_string = zcl_abapgit_http_utility=>fields_to_string( lt_fields ).
rv_string = fields_to_string( lt_fields ).

ENDMETHOD.


METHOD obj_encode.

DATA: lt_fields TYPE tihttpnvp.
DATA lt_fields TYPE tihttpnvp.


add_field( EXPORTING iv_name = 'KEY'
Expand All @@ -153,8 +180,7 @@ CLASS zcl_abapgit_html_action_utils IMPLEMENTATION.
add_field( EXPORTING iv_name = 'OBJ_NAME'
ig_field = ig_object CHANGING ct_field = lt_fields ).

rv_string = zcl_abapgit_http_utility=>fields_to_string( lt_fields ).
rv_string = fields_to_string( lt_fields ).

ENDMETHOD.

ENDCLASS.
1 change: 1 addition & 0 deletions cloud/zcl_abapgit_html_action_utils.clas.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
<WITH_UNIT_TESTS>X</WITH_UNIT_TESTS>
</VSEOCLASS>
</asx:values>
</asx:abap>
Expand Down
25 changes: 0 additions & 25 deletions cloud/zcl_abapgit_http_utility.clas.abap

This file was deleted.

16 changes: 0 additions & 16 deletions cloud/zcl_abapgit_http_utility.clas.xml

This file was deleted.

58 changes: 49 additions & 9 deletions cloud/zcl_abapgit_sap_namespace.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,59 @@ ENDCLASS.

CLASS zcl_abapgit_sap_namespace IMPLEMENTATION.


METHOD zif_abapgit_sap_namespace~exists.
rv_yes = abap_true.
DATA lv_editflag TYPE abap_bool.
DATA lo_obj TYPE REF TO object.
DATA lo_nsp TYPE REF TO object.
FIELD-SYMBOLS <lg_obj> TYPE any.
TRY.
SELECT SINGLE editflag FROM ('TRNSPACE') WHERE namespace = @iv_namespace INTO @lv_editflag.
rv_yes = boolc( sy-subrc = 0 ).
CATCH cx_sy_dynamic_osql_error.
ASSIGN ('XCO_CP_SYSTEM=>NAMESPACE') TO <lg_obj>.
lo_obj = <lg_obj>.
CALL METHOD lo_obj->('IF_XCO_CP_NAMESPACE_FACTORY~FOR')
EXPORTING
iv_value = iv_namespace
RECEIVING
ro_namespace = lo_nsp.
CALL METHOD lo_nsp->('IF_XCO_CP_NAMESPACE~EXISTS')
RECEIVING
rv_exists = rv_yes.
ENDTRY.
ENDMETHOD.


METHOD zif_abapgit_sap_namespace~is_editable.
DATA lv_editflag TYPE abap_bool.
DATA lo_obj TYPE REF TO object.
DATA lo_nsp TYPE REF TO object.
FIELD-SYMBOLS <lg_obj> TYPE any.
TRY.
SELECT SINGLE editflag FROM ('TRNSPACE') WHERE namespace = @iv_namespace INTO @lv_editflag.
rv_yes = boolc( sy-subrc = 0 AND lv_editflag = 'X' ).
CATCH cx_sy_dynamic_osql_error.
ASSIGN ('XCO_CP_SYSTEM=>NAMESPACE') TO <lg_obj>.
lo_obj = <lg_obj>.
CALL METHOD lo_obj->('IF_XCO_CP_NAMESPACE_FACTORY~FOR')
EXPORTING
iv_value = iv_namespace
RECEIVING
ro_namespace = lo_nsp.
CALL METHOD lo_nsp->('IF_XCO_CP_NAMESPACE~IS_CHANGEABLE')
RECEIVING
rv_exists = rv_yes.
ENDTRY.
ENDMETHOD.


METHOD zif_abapgit_sap_namespace~split_by_name.
* use this method instead of function module RS_NAME_SPLIT_NAMESPACE
DATA lv_regex TYPE string.
DATA lv_regex TYPE string.
DATA lv_object TYPE string.
DATA lv_length TYPE i.
DATA lr_ex TYPE REF TO cx_root.
DATA lr_ex TYPE REF TO cx_root.

lv_regex = '^\/[^\/]{1,8}\/'.

Expand All @@ -43,12 +86,9 @@ CLASS zcl_abapgit_sap_namespace IMPLEMENTATION.
ENDIF.

IF iv_allow_slash_in_name = abap_false AND rs_obj_namespace-obj_without_namespace CA '/'.
zcx_abapgit_exception=>raise( |Object without namespace { rs_obj_namespace-obj_without_namespace } contains a '/'| ).
zcx_abapgit_exception=>raise(
|Object without namespace { rs_obj_namespace-obj_without_namespace } contains a '/'| ).
ENDIF.
ENDMETHOD.

METHOD zif_abapgit_sap_namespace~is_editable.
rv_yes = abap_true.
ENDMETHOD.

ENDCLASS.
ENDCLASS.
Loading

0 comments on commit c9e2741

Please sign in to comment.