summaryrefslogtreecommitdiffstats
path: root/portal-BE/src/main/java/org/onap/portal/restTemplates/AAFTemplate.java
blob: 420307da855386ffd2b1a4f9a8a8ec9afba8016c (plain)
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
package org.onap.portal.restTemplates;

import org.onap.portal.utils.EPCommonSystemProperties;
import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class AAFTemplate {

    private final RestTemplate template = new RestTemplate();

    public ResponseEntity<String> addPortalAdminInAAF(HttpEntity<String> addUserRole){
        return template.exchange(
            SystemProperties.getProperty(
                EPCommonSystemProperties.EXTERNAL_CENTRAL_ACCESS_URL)
                + "userRole",
            HttpMethod.POST, addUserRole, String.class);
    }

    public void deletePortalAdminFromAAF(final String name, final String extRole, final HttpEntity<String> addUserRole){
        template.exchange(
            SystemProperties.getProperty(
                EPCommonSystemProperties.EXTERNAL_CENTRAL_ACCESS_URL)
                + "userRole/" + name + "/" + extRole,
            HttpMethod.DELETE, addUserRole, String.class);
    }
}