All files / output zcl_abapgit_web.clas.mjs

24.11% Statements 34/141
100% Branches 2/2
5.26% Functions 1/19
24.11% Lines 34/141

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 1411x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                       1x       1x     1x                                                                     1x     1x         1x     1x                                   1x     1x                                                             1x 1x 1x 1x 1x 1x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_web.clas.abap
class zcl_abapgit_web {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_WEB';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"GO_VIEWER": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTML_VIEWER_WEB", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTML_VIEWER_WEB"});}, "visibility": "O", "is_constant": " ", "is_class": "X"},
  "GO_GUI": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_GUI", RTTIName: "\\CLASS=ZCL_ABAPGIT_GUI"});}, "visibility": "O", "is_constant": " ", "is_class": "X"},
  "GI_REQUEST": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_REQUEST", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_REQUEST"});}, "visibility": "O", "is_constant": " ", "is_class": "X"},
  "GI_RESPONSE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_RESPONSE"});}, "visibility": "O", "is_constant": " ", "is_class": "X"},
  "C_BASE": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "O", "is_constant": "X", "is_class": "X"}};
  static METHODS = {"SAPEVENT": {"visibility": "O", "parameters": {}},
  "REDIRECT": {"visibility": "O", "parameters": {}},
  "SEARCH_ASSET": {"visibility": "O", "parameters": {"RV_FOUND": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}}},
  "HANDLE": {"visibility": "U", "parameters": {"II_REQUEST": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_REQUEST", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_REQUEST"});}, "is_optional": " "}, "II_RESPONSE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_RESPONSE"});}, "is_optional": " "}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
    this.go_viewer = zcl_abapgit_web.go_viewer;
    this.go_gui = zcl_abapgit_web.go_gui;
    this.gi_request = zcl_abapgit_web.gi_request;
    this.gi_response = zcl_abapgit_web.gi_response;
    this.c_base = zcl_abapgit_web.c_base;
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async handle(INPUT) {
    return zcl_abapgit_web.handle(INPUT);
  }
  static async handle(INPUT) {
    let ii_request = INPUT?.ii_request;
    if (ii_request?.getQualifiedName === undefined || ii_request.getQualifiedName() !== "ZIF_ABAPGIT_WEB_REQUEST") { ii_request = undefined; }
    if (ii_request === undefined) { ii_request = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_REQUEST", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_REQUEST"}).set(INPUT.ii_request); }
    let ii_response = INPUT?.ii_response;
    if (ii_response?.getQualifiedName === undefined || ii_response.getQualifiedName() !== "ZIF_ABAPGIT_WEB_RESPONSE") { ii_response = undefined; }
    if (ii_response === undefined) { ii_response = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_RESPONSE"}).set(INPUT.ii_response); }
    let lv_found = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let lv_path = new abap.types.String({qualifiedName: "STRING"});
    zcl_abapgit_web.gi_request.set(ii_request);
    zcl_abapgit_web.gi_response.set(ii_response);
    if (abap.compare.initial(zcl_abapgit_web.go_viewer)) {
      await abap.Classes['ZCL_ABAPGIT_WEB_SETUP'].setup();
      zcl_abapgit_web.go_viewer.set(await (new abap.Classes['ZCL_ABAPGIT_HTML_VIEWER_WEB']()).constructor_({ii_request: ii_request, ii_response: ii_response}));
      await abap.Classes['ZCL_ABAPGIT_UI_CORE_INJECTOR'].set_html_viewer({ii_html_viewer: zcl_abapgit_web.go_viewer});
      zcl_abapgit_web.go_gui.set((await abap.Classes['ZCL_ABAPGIT_UI_FACTORY'].get_gui()));
    }
    lv_found.set((await this.search_asset()));
    if (abap.compare.eq(lv_found, abap.builtin.abap_true)) {
      return;
    }
    lv_path.set((await abap.Classes['CL_HTTP_UTILITY'].if_http_utility$unescape_url({escaped: (await ii_request.get().zif_abapgit_web_request$get_header_field({iv_name: abap.CharacterFactory.get(5, '~path')}))})));
    if (abap.compare.eq(lv_path, abap.CharacterFactory.get(13, '/sap/zabapgit'))) {
      await this.redirect();
    } else if (abap.compare.eq(lv_path, zcl_abapgit_web.c_base)) {
      await zcl_abapgit_web.go_gui.get().go_home({iv_action: abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_action.get().go_home});
    } else if (abap.compare.eq(lv_path, new abap.types.String().set(`${abap.templateFormatting(zcl_abapgit_web.c_base)}css/bundle.css`))) {
      await zcl_abapgit_web.go_viewer.get().zif_abapgit_html_viewer$show_url({iv_url: new abap.types.String().set(`css/bundle.css`)});
    } else if (abap.compare.cp(lv_path, new abap.types.String().set(`${abap.templateFormatting(zcl_abapgit_web.c_base)}sapevent:+*`))) {
      await this.sapevent();
    } else {
      await ii_response.get().zif_abapgit_web_response$set_content_type({iv_type: abap.CharacterFactory.get(9, 'text/html')});
      await ii_response.get().zif_abapgit_web_response$set_cdata({iv_data: abap.operators.concat(abap.CharacterFactory.get(29, 'handle_request, unknown path '),lv_path)});
    }
  }
  async redirect() {
    return zcl_abapgit_web.redirect();
  }
  static async redirect() {
    let lv_html = new abap.types.String({qualifiedName: "STRING"});
    lv_html.set(abap.operators.concat(new abap.types.String().set(`<!DOCTYPE html>\n`),abap.operators.concat(new abap.types.String().set(`<html>\n`),abap.operators.concat(new abap.types.String().set(`   <head>\n`),abap.operators.concat(new abap.types.String().set(`      <title>HTML Meta Tag</title>\n`),abap.operators.concat(new abap.types.String().set(`      <meta http-equiv = "refresh" content = "0; url = ${abap.templateFormatting(zcl_abapgit_web.c_base)}" />\n`),abap.operators.concat(new abap.types.String().set(`   </head>\n`),abap.operators.concat(new abap.types.String().set(`   <body>\n`),abap.operators.concat(new abap.types.String().set(`      <p>Redirecting</p>\n`),abap.operators.concat(new abap.types.String().set(`   </body>\n`),new abap.types.String().set(`</html>`)))))))))));
    await zcl_abapgit_web.gi_response.get().zif_abapgit_web_response$set_cdata({iv_data: lv_html});
  }
  async sapevent() {
    return zcl_abapgit_web.sapevent();
  }
  static async sapevent() {
    let lv_action = new abap.types.Character(100, {});
    let lv_getdata = new abap.types.Character(100, {});
    let lv_method = new abap.types.String({qualifiedName: "STRING"});
    let lv_body = new abap.types.String({qualifiedName: "STRING"});
    let lv_value = new abap.types.String({qualifiedName: "STRING"});
    let lt_postdata = abap.types.TableFactory.construct(new abap.types.Character(256, {"qualifiedName":"zif_abapgit_html_viewer=>ty_char256"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "zif_abapgit_html_viewer=>ty_post_data");
    lv_value.set((await zcl_abapgit_web.gi_request.get().zif_abapgit_web_request$get_header_field({iv_name: abap.CharacterFactory.get(12, '~request_uri')})));
    abap.statements.replace({target: lv_value, all: false, with: abap.CharacterFactory.get(1, ''), of: zcl_abapgit_web.c_base});
    abap.statements.find(lv_value, {regex: abap.CharacterFactory.get(18, '^sapevent:([\\w-]+)'), submatches: [lv_action]});
    abap.statements.find(lv_value, {regex: abap.CharacterFactory.get(13, '\\?([\\w=&%.]+)'), submatches: [lv_getdata]});
    lv_method.set((await zcl_abapgit_web.gi_request.get().zif_abapgit_web_request$get_method()));
    if (abap.compare.eq(lv_method, abap.CharacterFactory.get(4, 'POST'))) {
      lv_body.set((await zcl_abapgit_web.gi_request.get().zif_abapgit_web_request$get_cdata()));
      await abap.Classes['ZCL_ABAPGIT_CONVERT'].string_to_tab({iv_str: lv_body, et_tab: lt_postdata});
    }
    await zcl_abapgit_web.go_gui.get().on_event({action: lv_action, getdata: lv_getdata, postdata: lt_postdata});
  }
  async search_asset() {
    return zcl_abapgit_web.search_asset();
  }
  static async search_asset() {
    let rv_found = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let ls_asset = new abap.types.Structure({
    "url": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_GUI_ASSET_MANAGER=>TY_WEB_ASSET-URL"}),
    "type": new abap.types.Character(50, {"qualifiedName":"zif_abapgit_gui_asset_manager=>ty_web_asset-type"}),
    "subtype": new abap.types.Character(50, {"qualifiedName":"zif_abapgit_gui_asset_manager=>ty_web_asset-subtype"}),
    "content": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_GUI_ASSET_MANAGER=>TY_WEB_ASSET-CONTENT"}),
    "is_cacheable": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"})}, "zif_abapgit_gui_asset_manager=>ty_web_asset", undefined, {}, {});
    let lv_search = new abap.types.String({qualifiedName: "STRING"});
    let lv_path = new abap.types.String({qualifiedName: "STRING"});
    let li_assets = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_GUI_ASSET_MANAGER", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_GUI_ASSET_MANAGER"});
    lv_path.set((await abap.Classes['CL_HTTP_UTILITY'].if_http_utility$unescape_url({escaped: (await zcl_abapgit_web.gi_request.get().zif_abapgit_web_request$get_header_field({iv_name: abap.CharacterFactory.get(5, '~path')}))})));
    li_assets.set((await abap.Classes['ZCL_ABAPGIT_UI_FACTORY'].get_asset_manager()));
    if (abap.compare.cp(lv_path, new abap.types.String().set(`${abap.templateFormatting(zcl_abapgit_web.c_base)}+*`))) {
      lv_search.set(lv_path);
      abap.statements.replace({target: lv_search, all: false, with: abap.CharacterFactory.get(1, ''), of: zcl_abapgit_web.c_base});
      try {
        ls_asset.set((await li_assets.get().zif_abapgit_gui_asset_manager$get_asset({iv_url: lv_search})));
        await zcl_abapgit_web.gi_response.get().zif_abapgit_web_response$set_content_type({iv_type: new abap.types.String().set(`${abap.templateFormatting(ls_asset.get().type)}/${abap.templateFormatting(ls_asset.get().subtype)}`)});
        await zcl_abapgit_web.gi_response.get().zif_abapgit_web_response$set_xdata({iv_data: ls_asset.get().content});
        rv_found.set(abap.builtin.abap_true);
      } catch (e) {
        if ((abap.Classes['ZCX_ABAPGIT_EXCEPTION'] && e instanceof abap.Classes['ZCX_ABAPGIT_EXCEPTION'])) {
          rv_found.set(abap.builtin.abap_false);
        } else {
          throw e;
        }
      }
    }
    return rv_found;
  }
}
abap.Classes['ZCL_ABAPGIT_WEB'] = zcl_abapgit_web;
zcl_abapgit_web.go_viewer = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTML_VIEWER_WEB", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTML_VIEWER_WEB"});
zcl_abapgit_web.go_gui = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_GUI", RTTIName: "\\CLASS=ZCL_ABAPGIT_GUI"});
zcl_abapgit_web.gi_request = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_REQUEST", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_REQUEST"});
zcl_abapgit_web.gi_response = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_RESPONSE"});
zcl_abapgit_web.c_base = new abap.types.String({qualifiedName: "STRING"});
zcl_abapgit_web.c_base.set('/sap/zabapgit/');
export {zcl_abapgit_web};