|
|
@ -114,12 +114,12 @@ public class VppApplicationManagerImpl implements VPPApplicationManager {
|
|
|
|
Gson gson = new Gson();
|
|
|
|
Gson gson = new Gson();
|
|
|
|
String userPayload = gson.toJson(wrapper);
|
|
|
|
String userPayload = gson.toJson(wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
ProxyResponse proxyResponse = callVPPBackend(USER_CREATE, userPayload, TOKEN, Constants.VPP.POST);
|
|
|
|
ProxyResponse proxyResponse = callVPPBackend(USER_CREATE, userPayload, getVppToken(), Constants.VPP.POST);
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.EVENT_ID)) {
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.EVENT_ID)) {
|
|
|
|
// Create user does not return any useful data. Its needed to call the backend again
|
|
|
|
// Create user does not return any useful data. Its needed to call the backend again
|
|
|
|
ProxyResponse getUserResponse = callVPPBackend(USER_GET + Constants.VPP.CLIENT_USER_ID_PARAM +
|
|
|
|
ProxyResponse getUserResponse = callVPPBackend(USER_GET + Constants.VPP.CLIENT_USER_ID_PARAM +
|
|
|
|
userDTO.getClientUserId(), userPayload, TOKEN, Constants.VPP.GET);
|
|
|
|
userDTO.getClientUserId(), userPayload, getVppToken(), Constants.VPP.GET);
|
|
|
|
if ((getUserResponse.getCode() == HttpStatus.SC_OK || getUserResponse.getCode() ==
|
|
|
|
if ((getUserResponse.getCode() == HttpStatus.SC_OK || getUserResponse.getCode() ==
|
|
|
|
HttpStatus.SC_CREATED) && getUserResponse.getData().contains(Constants.VPP.TOTAL_PAGES)) {
|
|
|
|
HttpStatus.SC_CREATED) && getUserResponse.getData().contains(Constants.VPP.TOTAL_PAGES)) {
|
|
|
|
VppItuneUserResponseWrapper vppItuneUserResponseWrapper = gson.fromJson
|
|
|
|
VppItuneUserResponseWrapper vppItuneUserResponseWrapper = gson.fromJson
|
|
|
@ -196,12 +196,13 @@ public class VppApplicationManagerImpl implements VPPApplicationManager {
|
|
|
|
Gson gson = new Gson();
|
|
|
|
Gson gson = new Gson();
|
|
|
|
String userPayload = gson.toJson(wrapper);
|
|
|
|
String userPayload = gson.toJson(wrapper);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ProxyResponse proxyResponse = callVPPBackend(USER_UPDATE, userPayload, TOKEN, Constants.VPP.POST);
|
|
|
|
ProxyResponse proxyResponse = callVPPBackend(USER_UPDATE, userPayload, getVppToken(), Constants.VPP.POST);
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.EVENT_ID)) {
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.EVENT_ID)) {
|
|
|
|
|
|
|
|
VppUserDTO currentUserDTO = getUserByDMUsername(userDTO.getDmUsername());
|
|
|
|
log.error("userDTO " + userDTO.toString());
|
|
|
|
if (currentUserDTO != null) {
|
|
|
|
|
|
|
|
userDTO.setId(currentUserDTO.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
if (vppApplicationDAO.updateVppUser(userDTO, tenantId) == null) {
|
|
|
|
if (vppApplicationDAO.updateVppUser(userDTO, tenantId) == null) {
|
|
|
@ -228,6 +229,7 @@ public class VppApplicationManagerImpl implements VPPApplicationManager {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
String msg = "Error while calling VPP backend to update";
|
|
|
|
String msg = "Error while calling VPP backend to update";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -239,7 +241,7 @@ public class VppApplicationManagerImpl implements VPPApplicationManager {
|
|
|
|
public void syncUsers(String clientId) throws ApplicationManagementException {
|
|
|
|
public void syncUsers(String clientId) throws ApplicationManagementException {
|
|
|
|
ProxyResponse proxyResponse = null;
|
|
|
|
ProxyResponse proxyResponse = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
proxyResponse = callVPPBackend(USER_GET, null, TOKEN, Constants
|
|
|
|
proxyResponse = callVPPBackend(USER_GET, null, getVppToken(), Constants
|
|
|
|
.VPP.GET);
|
|
|
|
.VPP.GET);
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.TOTAL_PAGES)) {
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.TOTAL_PAGES)) {
|
|
|
@ -266,7 +268,7 @@ public class VppApplicationManagerImpl implements VPPApplicationManager {
|
|
|
|
if (nextPageIndex > 0) { // Not the first page
|
|
|
|
if (nextPageIndex > 0) { // Not the first page
|
|
|
|
url += "?pageIndex=" + nextPageIndex;
|
|
|
|
url += "?pageIndex=" + nextPageIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
proxyResponse = callVPPBackend(url, null, TOKEN, Constants.VPP.GET);
|
|
|
|
proxyResponse = callVPPBackend(url, null, getVppToken(), Constants.VPP.GET);
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.TOTAL_PAGES)) {
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.TOTAL_PAGES)) {
|
|
|
|
Gson gson = new Gson();
|
|
|
|
Gson gson = new Gson();
|
|
|
@ -360,7 +362,7 @@ public class VppApplicationManagerImpl implements VPPApplicationManager {
|
|
|
|
private ItuneAppDTO lookupAsset(String packageName) throws ApplicationManagementException {
|
|
|
|
private ItuneAppDTO lookupAsset(String packageName) throws ApplicationManagementException {
|
|
|
|
String lookupURL = LOOKUP_API + packageName + LOOKUP_API_PREFIX;
|
|
|
|
String lookupURL = LOOKUP_API + packageName + LOOKUP_API_PREFIX;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ProxyResponse proxyResponse = callVPPBackend(lookupURL, null, TOKEN, Constants.VPP.GET);
|
|
|
|
ProxyResponse proxyResponse = callVPPBackend(lookupURL, null, getVppToken(), Constants.VPP.GET);
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.GET_APP_DATA_RESPONSE_START)) {
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.GET_APP_DATA_RESPONSE_START)) {
|
|
|
|
String responseData = proxyResponse.getData();
|
|
|
|
String responseData = proxyResponse.getData();
|
|
|
@ -467,12 +469,12 @@ public class VppApplicationManagerImpl implements VPPApplicationManager {
|
|
|
|
Gson gson = new Gson();
|
|
|
|
Gson gson = new Gson();
|
|
|
|
String payload = gson.toJson(vppAssociate);
|
|
|
|
String payload = gson.toJson(vppAssociate);
|
|
|
|
|
|
|
|
|
|
|
|
ProxyResponse proxyResponse = callVPPBackend(ASSIGNMENTS_POST, payload, TOKEN,
|
|
|
|
ProxyResponse proxyResponse = callVPPBackend(ASSIGNMENTS_POST, payload, getVppToken(),
|
|
|
|
Constants.VPP.POST);
|
|
|
|
Constants.VPP.POST);
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
if ((proxyResponse.getCode() == HttpStatus.SC_OK || proxyResponse.getCode() ==
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.EVENT_ID)) {
|
|
|
|
HttpStatus.SC_CREATED) && proxyResponse.getData().contains(Constants.VPP.EVENT_ID)) {
|
|
|
|
// Create assignment does not return any useful data. Its needed to call the backend again
|
|
|
|
// Create assignment does not return any useful data. Its needed to call the backend again
|
|
|
|
ProxyResponse getAssignmentResponse = callVPPBackend(ASSIGNMENTS_GET, null, TOKEN, Constants.VPP.GET);
|
|
|
|
ProxyResponse getAssignmentResponse = callVPPBackend(ASSIGNMENTS_GET, null, getVppToken(), Constants.VPP.GET);
|
|
|
|
if ((getAssignmentResponse.getCode() == HttpStatus.SC_OK || getAssignmentResponse.getCode() ==
|
|
|
|
if ((getAssignmentResponse.getCode() == HttpStatus.SC_OK || getAssignmentResponse.getCode() ==
|
|
|
|
HttpStatus.SC_CREATED) && getAssignmentResponse.getData().contains(Constants.VPP.TOTAL_PAGES)) {
|
|
|
|
HttpStatus.SC_CREATED) && getAssignmentResponse.getData().contains(Constants.VPP.TOTAL_PAGES)) {
|
|
|
|
// VppAssociateResponseWrapper vppAssociateResponseWrapper = gson.fromJson
|
|
|
|
// VppAssociateResponseWrapper vppAssociateResponseWrapper = gson.fromJson
|
|
|
|