src/main/java/org/edgegallery/appstore/application/external/mecm/MecmService.java
public String deleteServer(String userId, String packageId, String token) {
        if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(packageId) || StringUtils.isEmpty(token)) {
            LOGGER.error("UserId or packageId or token is empty.");
            return "UserId or packageId or token is empty";
        }
        HttpHeaders headers = new HttpHeaders();
        headers.set(Consts.ACCESS_TOKEN_STR, token);
        HttpEntity<String> request = new HttpEntity<>(headers);

        String url = northUrl.concat(String.format(MECM_DELETE_PACKAGE, userId, packageId));
        LOGGER.info("The url is :{}", url);
        try {
            ResponseEntity<String> response = REST_TEMPLATE.exchange(url, HttpMethod.DELETE, request, String.class);
            if (!HttpStatus.OK.equals(response.getStatusCode())) {
                LOGGER.error("Failed to get response within Delete Server Interface.");
                return "Failed";
            }
            JsonObject jsonBody = new JsonParser().parse(Objects.requireNonNull(response.getBody())).getAsJsonObject();
            JsonArray jsonData = jsonBody.get("data").getAsJsonArray();
            if (jsonData.size() > 0) {
                return jsonData.get(0).getAsJsonObject().get("message").getAsString();
            }
        } catch (RestClientException | NullPointerException e) {
            LOGGER.error("Failed to get response within Delete Server Interface, exception {}", e.getMessage());
        }
        return null;
    }
/**
     * upload package to mecm-apm.
     *
     * @param userId user id
     * @param packageId appstore package id
     * @param token access token
     * @return delete server success or not
     */
upload package to mecm-apm.
@param userId user id
@param packageId appstore package id
@param token access token
@return delete server success or not
upload package to mecm - apm . @param userId user id @param packageId appstore package id @param token access token @return delete server success or not
public String deleteServer(String userId, String packageId, String token) {
        if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(packageId) || StringUtils.isEmpty(token)) {
            LOGGER.error("UserId or packageId or token is empty.");
            return "UserId or packageId or token is empty";
        }
        HttpHeaders headers = new HttpHeaders();
        headers.set(Consts.ACCESS_TOKEN_STR, token);
        HttpEntity<String> request = new HttpEntity<>(headers);
        String url = northUrl.concat(String.format(MECM_DELETE_PACKAGE, userId, packageId));
        LOGGER.info("The url is :{}", url);
        try {
            ResponseEntity<String> response = REST_TEMPLATE.exchange(url, HttpMethod.DELETE, request, String.class);
            if (!HttpStatus.OK.equals(response.getStatusCode())) {
                LOGGER.error("Failed to get response within Delete Server Interface.");
                return "Failed";
            }
            JsonObject jsonBody = new JsonParser().parse(Objects.requireNonNull(response.getBody())).getAsJsonObject();
            JsonArray jsonData = jsonBody.get("data").getAsJsonArray();
            if (jsonData.size() > 0) {
                return jsonData.get(0).getAsJsonObject().get("message").getAsString();
            }
        } catch (RestClientException | NullPointerException e) {
            LOGGER.error("Failed to get response within Delete Server Interface, exception {}", e.getMessage());
        }
        return null;
    }
public String deleteServer ( String userId , String packageId , String token ) { if ( StringUtils . isEmpty ( userId ) || StringUtils . isEmpty ( packageId ) || StringUtils . isEmpty ( token ) ) { LOGGER . error ( "UserId or packageId or token is empty." ) ; return "UserId or packageId or token is empty" ; } HttpHeaders headers = new HttpHeaders ( ) ; headers . set ( Consts . ACCESS_TOKEN_STR , token ) ; HttpEntity < String > request = new HttpEntity < > ( headers ) ; String url = northUrl . concat ( String . format ( MECM_DELETE_PACKAGE , userId , packageId ) ) ; LOGGER . info ( "The url is :{}" , url ) ; try { ResponseEntity < String > response = REST_TEMPLATE . exchange ( url , HttpMethod . DELETE , request , String . class ) ; if ( ! HttpStatus . OK . equals ( response . getStatusCode ( ) ) ) { LOGGER . error ( "Failed to get response within Delete Server Interface." ) ; return "Failed" ; } JsonObject jsonBody = new JsonParser ( ) . parse ( Objects . requireNonNull ( response . getBody ( ) ) ) . getAsJsonObject ( ) ; JsonArray jsonData = jsonBody . get ( "data" ) . getAsJsonArray ( ) ; if ( jsonData . size ( ) > 0 ) { return jsonData . get ( 0 ) . getAsJsonObject ( ) . get ( "message" ) . getAsString ( ) ; } } catch ( RestClientException | NullPointerException e ) { LOGGER . error ( "Failed to get response within Delete Server Interface, exception {}" , e . getMessage ( ) ) ; } return null ; }
upload package to mecm-apm.
upload package to mecm - apm .