Skip to content

Commit

Permalink
KAA-1337: Add REST API to retrieve a configuration of a specific user…
Browse files Browse the repository at this point in the history
… by its external id.
  • Loading branch information
Pyshankov committed Aug 17, 2016
1 parent 1f1511d commit aa704bb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
Expand Up @@ -59,6 +59,7 @@
import org.springframework.util.Base64Utils; import org.springframework.util.Base64Utils;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.client.RequestCallback; import org.springframework.web.client.RequestCallback;
import org.springframework.web.client.ResponseExtractor; import org.springframework.web.client.ResponseExtractor;


Expand Down Expand Up @@ -1060,4 +1061,9 @@ public void onCredentialsRevoked(String applicationToken, String credentialsId)
parameters.add("credentialsId", credentialsId); parameters.add("credentialsId", credentialsId);
this.restTemplate.postForLocation(restTemplate.getUrl() + "notifyRevoked", parameters); this.restTemplate.postForLocation(restTemplate.getUrl() + "notifyRevoked", parameters);
} }

public EndpointUserConfigurationDto findUserConfigurationByUserId(String externalUId, String appToken, Integer schemaVersion){
return restTemplate.getForObject(restTemplate.getUrl() + "configuration/{externalUId}/{appToken}/{schemaVersion}",
EndpointUserConfigurationDto.class, externalUId, appToken, schemaVersion);
}
} }
Expand Up @@ -130,8 +130,7 @@ public EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppToke
String appToken, String appToken,
Integer schemaVersion, Integer schemaVersion,
String tenantId) { String tenantId) {
return getDto( return getDto(endpointUserConfigurationDao.findByUserIdAndAppTokenAndSchemaVersion(
endpointUserConfigurationDao.findByUserIdAndAppTokenAndSchemaVersion(
endpointUserDao.findByExternalIdAndTenantId(externalUid, tenantId).getId(), endpointUserDao.findByExternalIdAndTenantId(externalUid, tenantId).getId(),
appToken, appToken,
schemaVersion)); schemaVersion));
Expand Down
Expand Up @@ -359,4 +359,28 @@ public void deleteConfigurationRecord(
configurationService.deleteConfigurationRecord(schemaId, endpointGroupId); configurationService.deleteConfigurationRecord(schemaId, endpointGroupId);
} }


/**
* Get configuration of specific endpoint user bu externalUId
*
* @param appToken the application token
* @param schemaVersion the schema version
* @param externalUId the external user id
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Get endpoint user configuration by external user id",
notes="Get endpoint user configuration by external user id." +
" Only user with TENANT_DEVELOPER and TENANT_USER roles is allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The specified url is not valid"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have neither TENANT_DEVELOPER nor TENANT_USER role"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configuration/{externalUId}/{appToken}/{schemaVersion}", method = RequestMethod.GET)
@ResponseBody
public EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(
@PathVariable String externalUId,
@PathVariable String appToken,
@PathVariable Integer schemaVersion) throws KaaAdminServiceException {
return configurationService.findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(externalUId,appToken,schemaVersion);
}
} }
Expand Up @@ -290,21 +290,4 @@ public List<UserDto> findAllTenantAdminsByTenantId(
return userService.findAllTenantAdminsByTenantId(tenantId); return userService.findAllTenantAdminsByTenantId(tenantId);
} }


@ApiOperation(value = "Get endpoint user configuration by external user id",
notes="Get endpoint user configuration by external user id." +
" Only user with TENANT_DEVELOPER and TENANT_USER roles is allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The specified url is not valid"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have neither TENANT_DEVELOPER nor TENANT_USER role"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configuration/{userId}/{appToken}/{schemaVersion}", method = RequestMethod.GET)
@ResponseBody
public EndpointUserConfigurationDto findUserConfigurationByUserId(
@PathVariable String userId,
@PathVariable String appToken,
@PathVariable Integer schemaVersion) throws KaaAdminServiceException {
return configurationService.findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(userId,appToken,schemaVersion);
}

} }
Expand Up @@ -1719,7 +1719,5 @@ CTLSchemaDto getCTLSchemaByFqnVersionTenantIdAndApplicationId(String fqn, int ve
*/ */
List<String> getCredentialsServiceNames() throws ControlServiceException; List<String> getCredentialsServiceNames() throws ControlServiceException;



EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(String userId, String appToken, Integer schemaVersion,String tenantId); EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(String userId, String appToken, Integer schemaVersion,String tenantId);

} }

0 comments on commit aa704bb

Please sign in to comment.