Skip to content

Commit cd8cece

Browse files
committed
Update camel-case mapping + write-request
1 parent 147ce08 commit cd8cece

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

src/zcl_pacote.clas.abap

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ CLASS zcl_pacote DEFINITION
118118
RAISING
119119
zcx_error.
120120

121+
CLASS-METHODS write_request
122+
IMPORTING
123+
!write TYPE abap_bool
124+
RETURNING
125+
VALUE(result) TYPE string.
126+
121127
ENDCLASS.
122128

123129

@@ -246,7 +252,7 @@ CLASS zcl_pacote IMPLEMENTATION.
246252
attachment-tarball-content_type = ajson->get( '/_attachments/' && attachment-key && '/content_type' ).
247253
attachment-tarball-data = ajson->get( '/_attachments/' && attachment-key && '/data' ).
248254
attachment-tarball-length = ajson->get_integer( '/_attachments/' && attachment-key && '/length' ).
249-
INSERT attachment INTO TABLE packument-__attachments.
255+
INSERT attachment INTO TABLE packument-_attachments.
250256
ENDLOOP.
251257

252258
LOOP AT ajson->members( '/versions' ) INTO version-key.
@@ -255,6 +261,10 @@ CLASS zcl_pacote IMPLEMENTATION.
255261
INSERT version INTO TABLE packument-versions.
256262
ENDLOOP.
257263

264+
" TODO: Do we need this?
265+
packument-_id = ajson->get( '/_id' ).
266+
packument-_rev = ajson->get( '/_rev' ).
267+
258268
" TODO: validation of packument
259269

260270
result = sort_packument( packument ).
@@ -316,7 +326,7 @@ CLASS zcl_pacote IMPLEMENTATION.
316326
ENDLOOP.
317327

318328
ajson->setx( '/_attachments:{ }' ).
319-
LOOP AT packument-__attachments INTO DATA(attachment).
329+
LOOP AT packument-_attachments INTO DATA(attachment).
320330
ajson->set(
321331
iv_path = '_attachments/' && attachment-key && '/content_type'
322332
iv_val = attachment-tarball-content_type ).
@@ -449,12 +459,21 @@ CLASS zcl_pacote IMPLEMENTATION.
449459
SORT result-maintainers BY name.
450460
SORT result-users BY name.
451461
SORT result-versions BY key.
452-
SORT result-__attachments BY key.
462+
SORT result-_attachments BY key.
453463
SORT result-keywords.
454464

455465
ENDMETHOD.
456466

457467

468+
METHOD write_request.
469+
470+
IF write = abap_true.
471+
result = '?write=true'.
472+
ENDIF.
473+
474+
ENDMETHOD.
475+
476+
458477
METHOD zif_pacote~delete.
459478

460479
db_persist->delete( pacote-key ).
@@ -508,7 +527,7 @@ CLASS zcl_pacote IMPLEMENTATION.
508527
METHOD zif_pacote~manifest.
509528

510529
result = request(
511-
url = |{ registry }/{ pacote-name }/{ version }|
530+
url = |{ registry }/{ pacote-name }/{ version }{ write_request( write ) }|
512531
abbreviated = abbreviated )->cdata( ).
513532

514533
check_result( result ).
@@ -518,7 +537,7 @@ CLASS zcl_pacote IMPLEMENTATION.
518537

519538
METHOD zif_pacote~packument.
520539

521-
result = request( |{ registry }/{ pacote-name }| )->cdata( ).
540+
result = request( |{ registry }/{ pacote-name }{ write_request( write ) }| )->cdata( ).
522541

523542
check_result( result ).
524543
zif_pacote~set_json( result ).
@@ -557,8 +576,13 @@ CLASS zcl_pacote IMPLEMENTATION.
557576

558577
METHOD zif_pacote~tarball.
559578

560-
" TODO: Error check (HTTP status)
561-
result = request( filename )->data( ).
579+
DATA(response) = request( filename ).
580+
581+
IF response->is_ok( ) = abap_false.
582+
check_result( response->cdata( ) ).
583+
ELSE.
584+
result = response->data( ).
585+
ENDIF.
562586

563587
ENDMETHOD.
564588
ENDCLASS.

src/zif_pacote.intf.abap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,15 @@ INTERFACE zif_pacote PUBLIC.
7272
IMPORTING
7373
version TYPE string
7474
abbreviated TYPE abap_bool DEFAULT abap_false
75+
write TYPE abap_bool DEFAULT abap_false
7576
RETURNING
7677
VALUE(result) TYPE string
7778
RAISING
7879
zcx_error.
7980

8081
METHODS packument
82+
IMPORTING
83+
write TYPE abap_bool DEFAULT abap_false
8184
RETURNING
8285
VALUE(result) TYPE string
8386
RAISING

0 commit comments

Comments
 (0)