Skip to content
Permalink
Browse files

Added client check to add the ability to run abapGit in production/QA…

… environments (#2668)

* Added client check 

Check if repository objects are modifiable in client. If not make write_protected setting active for all repos and make this setting disabled in repo setting page.

* fix abaplint errors

fix for abaplint errors

* code changes as suggested in review

1) Remove zcl_abapgit_client_check class
2) Add is_repo_object_changes_allowed method to zcl_abapgit_environment class

* Delete zcl_abapgit_client_check class

Delete zcl_abapgit_client_check class
  • Loading branch information...
Srinu3366 authored and larshp committed May 15, 2019
1 parent 76c91e0 commit d1c5e332d4d6fdeb78c68994d734c9ec59a3385b
@@ -187,6 +187,10 @@ CLASS ZCL_ABAPGIT_PERSISTENCE_REPO IMPLEMENTATION.

LOOP AT lt_content INTO ls_content.
MOVE-CORRESPONDING from_xml( ls_content-data_str ) TO ls_repo.
IF ls_repo-local_settings-write_protected = abap_false AND
zcl_abapgit_environment=>is_repo_object_changes_allowed( ) = abap_false.
ls_repo-local_settings-write_protected = abap_true.
ENDIF.
ls_repo-key = ls_content-value.
INSERT ls_repo INTO TABLE rt_repos.
ENDLOOP.
@@ -190,7 +190,11 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_REPO_SETT IMPLEMENTATION.

CLEAR lv_checked.
IF ls_settings-write_protected = abap_true.
lv_checked = | checked|.
IF zcl_abapgit_environment=>is_repo_object_changes_allowed( ) = abap_true.
lv_checked = | checked|.
ELSE.
lv_checked = | checked disabled|.
ENDIF.
ENDIF.
io_html->add( |Write protected <input name="write_protected" type="checkbox"{ lv_checked }><br>| ).

@@ -10,16 +10,6 @@ FORM run.
DATA: lx_exception TYPE REF TO zcx_abapgit_exception,
lv_ind TYPE t000-ccnocliind.


SELECT SINGLE ccnocliind FROM t000 INTO lv_ind
WHERE mandt = sy-mandt.
IF sy-subrc = 0
AND lv_ind <> ' '
AND lv_ind <> '1'. " check changes allowed
WRITE: / 'Wrong client, changes to repository objects not allowed'. "#EC NOTEXT
RETURN.
ENDIF.

TRY.
zcl_abapgit_migrations=>run( ).
PERFORM open_gui.
@@ -6,38 +6,25 @@ CLASS zcl_abapgit_environment DEFINITION

CLASS-METHODS is_sap_cloud_platform
RETURNING
VALUE(rv_cloud) TYPE abap_bool .
VALUE(rv_cloud) TYPE abap_bool.

CLASS-METHODS is_merged
RETURNING
VALUE(rv_is_merged) TYPE abap_bool .
VALUE(rv_is_merged) TYPE abap_bool.

CLASS-METHODS is_repo_object_changes_allowed
RETURNING VALUE(rv_allowed) TYPE abap_bool.
PROTECTED SECTION.

CLASS-DATA gv_cloud TYPE abap_bool VALUE abap_undefined ##NO_TEXT.
CLASS-DATA gv_is_merged TYPE abap_bool VALUE abap_undefined ##NO_TEXT.
CLASS-DATA gv_client_modifiable TYPE abap_bool VALUE abap_undefined.
PRIVATE SECTION.
ENDCLASS.



CLASS zcl_abapgit_environment IMPLEMENTATION.


METHOD is_sap_cloud_platform.

IF gv_cloud = abap_undefined.
TRY.
CALL METHOD ('CL_COS_UTILITIES')=>('IS_SAP_CLOUD_PLATFORM')
RECEIVING
rv_is_sap_cloud_platform = gv_cloud.
CATCH cx_sy_dyn_call_illegal_method.
gv_cloud = abap_false.
ENDTRY.
ENDIF.

rv_cloud = gv_cloud.

ENDMETHOD.
CLASS ZCL_ABAPGIT_ENVIRONMENT IMPLEMENTATION.


METHOD is_merged.
@@ -59,4 +46,37 @@ CLASS zcl_abapgit_environment IMPLEMENTATION.

ENDMETHOD.


METHOD is_repo_object_changes_allowed.
DATA lv_ind TYPE t000-ccnocliind.

IF gv_client_modifiable = abap_undefined.
SELECT SINGLE ccnocliind FROM t000 INTO lv_ind
WHERE mandt = sy-mandt.
IF sy-subrc = 0
AND ( lv_ind = ' ' OR lv_ind = '1' ). "check changes allowed
gv_client_modifiable = abap_true.
ELSE.
gv_client_modifiable = abap_false.
ENDIF.
ENDIF.
rv_allowed = gv_client_modifiable.
ENDMETHOD.


METHOD is_sap_cloud_platform.

IF gv_cloud = abap_undefined.
TRY.
CALL METHOD ('CL_COS_UTILITIES')=>('IS_SAP_CLOUD_PLATFORM')
RECEIVING
rv_is_sap_cloud_platform = gv_cloud.
CATCH cx_sy_dyn_call_illegal_method.
gv_cloud = abap_false.
ENDTRY.
ENDIF.

rv_cloud = gv_cloud.

ENDMETHOD.
ENDCLASS.

0 comments on commit d1c5e33

Please sign in to comment.
You can’t perform that action at this time.