rv_is_jam_configured = abap_true.
O código abaixo pode ser encontrado no arquivo ContainerAdapter, explicado no final.
//set user image
if (oUser.isJamActive && oUser.isJamActive()) {
OData.read('/sap/bc/ui2/smi/rest_tunnel/Jam/api/v1/OData/Self?$format=json',
function (oResponseData) {
var sJamUserId = oResponseData.results.Id,
sJamUserImageUrl = "/sap/bc/ui2/smi/rest_tunnel/Jam/api/v1/OData/Members('" + sJamUserId + "')/ProfilePhoto/$value";
oUser.setImage(sJamUserImageUrl);
},
function (message) {
jQuery.sap.log.error("Could not recieve JAM user data");
});
}
DATA:
lvz_json_content TYPE string.
IF abap_true = me->handle_xsrf_token( server = server ).
RETURN.
ENDIF.
DATA(lvz_path_info) = server->request->get_header_field( '~path_info' ).
me->parse_path_info( EXPORTING iv_path_info = lvz_path_info
IMPORTING ev_service_provider = DATA(lvz_serv_provider)
ev_resource_path = DATA(lvz_resource_path) ).
"Parte 1 - retorna o ID do usuário
IF lvz_resource_path CS 'api/v1/OData/Self'.
"Retorna em formarto JON. Exemplo { "d" : { "results" : { "Id" : "MY_USERNAME" } } }
lvz_json_content = '{' && |"d":| && '{' && |"results":| && '{' && |"Id": "{ sy-uname }"| && '} } }'.
server->response->set_cdata( data = lvz_json_content ).
server->response->set_content_type( 'application/json; charset=UTF-8' ).
server->response->set_status( code = 200 reason = 'OK' ).
RETURN.
"Parte 2 - Com o ID do usuário, retorna a imagem
ELSEIF lvz_resource_path CS 'api/v1/OData/Members'.
DATA(loz_mr_api) = cl_mime_repository_api=>if_mr_api~get_api( ).
CALL METHOD loz_mr_api->get
EXPORTING
i_url = '/SAP/PUBLIC/ZUser/userphoto'
i_check_authority = ' '
IMPORTING
e_content = DATA(lvz_mime_content)
e_mime_type = DATA(lvz_mime_type)
EXCEPTIONS
parameter_missing = 1
error_occured = 2
not_found = 3
permission_failure = 4
OTHERS = 5.
IF sy-subrc EQ 0.
server->response->set_content_type( lvz_mime_type ).
server->response->set_data( data = lvz_mime_content ).
server->response->set_status( code = 200 reason = 'OK' ).
ELSE.
server->response->set_status( code = 500 reason = 'MIME: Error occured' ).
ENDIF.
RETURN.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |