Updated a few missing checks for this.
Update api name, add properties to be more forgiving for lock type
Change-Id: I4743110bdc654e4346052bd0e045270fd4925417
Issue-ID: MUSIC-398
Signed-off-by: Nelson, Thomas (arthurdent3) <nelson24@att.com>
public Response toResponse(Exception exception) {
if(exception instanceof UnrecognizedPropertyException) {
return Response.status(Response.Status.BAD_REQUEST).
public Response toResponse(Exception exception) {
if(exception instanceof UnrecognizedPropertyException) {
return Response.status(Response.Status.BAD_REQUEST).
- entity(new JsonResponse(ResultType.FAILURE).setError("Unknown field :"+((UnrecognizedPropertyException) exception).getUnrecognizedPropertyName()).toMap()).
- build();
- }
- else if(exception instanceof EOFException) {
+ entity(new JsonResponse(ResultType.FAILURE).setError("Unknown field :"+((UnrecognizedPropertyException) exception).getUnrecognizedPropertyName()).toMap()).
+ build();
+ } else if(exception instanceof EOFException) {
return Response.status(Response.Status.BAD_REQUEST).
return Response.status(Response.Status.BAD_REQUEST).
- entity(new JsonResponse(ResultType.FAILURE).setError("Request body cannot be empty").toMap()).
- build();
- }
- else {
+ entity(new JsonResponse(ResultType.FAILURE).setError("Request body cannot be empty").toMap()).
+ build();
+ } else if(exception instanceof NullPointerException) {
+ return Response.status(Response.Status.BAD_REQUEST).
+ entity(new JsonResponse(ResultType.FAILURE).setError("NullPointerException - Please check to make sure all inputs are valid.").toMap()).
+ build();
+ } else {
return Response.status(Response.Status.BAD_REQUEST).
return Response.status(Response.Status.BAD_REQUEST).
- entity(new JsonResponse(ResultType.FAILURE).setError(exception.getMessage()).toMap()).
- build();
+ entity(new JsonResponse(ResultType.FAILURE).setError(exception.getMessage()).toMap()).
+ build();
@ApiParam(value = "Major Version",required = true) @PathParam("version") String version,
@ApiParam(value = "Minor Version",required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
@ApiParam(value = "Major Version",required = true) @PathParam("version") String version,
@ApiParam(value = "Minor Version",required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
- @ApiParam(value = "AID", required = false) @HeaderParam("aid") String aid,
+ @ApiParam(value = "AID", required = false, hidden = true) @HeaderParam("aid") String aid,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
- @ApiParam(value = "Application namespace",required = true) @HeaderParam(NS) String ns,
+ @ApiParam(value = "Application namespace",required = false, hidden = true) @HeaderParam(NS) String ns,
JsonKeySpace kspObject,
@ApiParam(value = "Keyspace Name",required = true) @PathParam("name") String keyspaceName) {
try {
JsonKeySpace kspObject,
@ApiParam(value = "Keyspace Name",required = true) @PathParam("name") String keyspaceName) {
try {
@ApiParam(value = "Major Version",required = true) @PathParam("version") String version,
@ApiParam(value = "Minor Version",required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
@ApiParam(value = "Major Version",required = true) @PathParam("version") String version,
@ApiParam(value = "Minor Version",required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
- @ApiParam(value = "AID", required = false) @HeaderParam("aid") String aid,
+ @ApiParam(value = "AID", required = false, hidden = true) @HeaderParam("aid") String aid,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
- @ApiParam(value = "Application namespace",required = true) @HeaderParam(NS) String ns,
+ @ApiParam(value = "Application namespace",required = false, hidden = true) @HeaderParam(NS) String ns,
@ApiParam(value = "Keyspace Name",required = true) @PathParam("name") String keyspaceName) throws Exception {
try {
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
@ApiParam(value = "Keyspace Name",required = true) @PathParam("name") String keyspaceName) throws Exception {
try {
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
@ApiParam(value = "Major Version",required = true) @PathParam("version") String version,
@ApiParam(value = "Minor Version",required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
@ApiParam(value = "Major Version",required = true) @PathParam("version") String version,
@ApiParam(value = "Minor Version",required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
- @ApiParam(value = "AID", required = false) @HeaderParam("aid") String aid,
- @ApiParam(value = "Application namespace",required = true) @HeaderParam(NS) String ns,
+ @ApiParam(value = "AID", required = false,hidden = true) @HeaderParam("aid") String aid,
+ @ApiParam(value = "Application namespace",required = false, hidden = true) @HeaderParam(NS) String ns,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonTable tableObj,
@ApiParam(value = "Keyspace Name",required = true) @PathParam("keyspace") String keyspace,
@ApiParam(value = "Table Name",required = true) @PathParam("tablename") String tablename) throws Exception {
try {
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonTable tableObj,
@ApiParam(value = "Keyspace Name",required = true) @PathParam("keyspace") String keyspace,
@ApiParam(value = "Table Name",required = true) @PathParam("tablename") String tablename) throws Exception {
try {
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
+ if ( null == tableObj ) {
+ return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
+ .setError(ResultType.BODYMISSING.getResult()).toMap()).build();
+ }
if(keyspace == null || keyspace.isEmpty() || tablename == null || tablename.isEmpty()){
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
.setError("One or more path parameters are not set, please check and try again."
if(keyspace == null || keyspace.isEmpty() || tablename == null || tablename.isEmpty()){
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
.setError("One or more path parameters are not set, please check and try again."
@ApiParam(value = "Major Version",required = true) @PathParam("version") String version,
@ApiParam(value = "Minor Version",required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
@ApiParam(value = "Major Version",required = true) @PathParam("version") String version,
@ApiParam(value = "Minor Version",required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
- @ApiParam(value = "AID", required = false) @HeaderParam("aid") String aid,
- @ApiParam(value = "Application namespace",required = true) @HeaderParam(NS) String ns,
+ @ApiParam(value = "AID", required = false, hidden = true) @HeaderParam("aid") String aid,
+ @ApiParam(value = "Application namespace",required = false, hidden = true) @HeaderParam(NS) String ns,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonInsert insObj,
@ApiParam(value = "Keyspace Name",
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonInsert insObj,
@ApiParam(value = "Keyspace Name",
required = true) @PathParam("tablename") String tablename) {
try {
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
required = true) @PathParam("tablename") String tablename) {
try {
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
- if((keyspace == null || keyspace.isEmpty()) || (tablename == null || tablename.isEmpty())){
+ if ( null == insObj ) {
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
- .setError("one or more path parameters are not set, please check and try again")
- .toMap()).build();
+ .setError(ResultType.BODYMISSING.getResult()).toMap()).build();
+ }
+ if((keyspace == null || keyspace.isEmpty()) || (tablename == null || tablename.isEmpty())){
+ return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
+ .setError("one or more path parameters are not set, please check and try again")
+ .toMap()).build();
}
EELFLoggerDelegate.mdcPut("keyspace","(" + keyspace + ")");
PreparedQueryObject queryObject = new PreparedQueryObject();
}
EELFLoggerDelegate.mdcPut("keyspace","(" + keyspace + ")");
PreparedQueryObject queryObject = new PreparedQueryObject();
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
- @ApiParam(value = "AID", required = false) @HeaderParam("aid") String aid,
+ @ApiParam(value = "AID", required = false, hidden = true) @HeaderParam("aid") String aid,
@ApiParam(value = "Application namespace",
@ApiParam(value = "Application namespace",
- required = true) @HeaderParam(NS) String ns,
+ required = false, hidden = true) @HeaderParam(NS) String ns,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonUpdate updateObj,
@ApiParam(value = "Keyspace Name",
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonUpdate updateObj,
@ApiParam(value = "Keyspace Name",
@Context UriInfo info) throws MusicQueryException, MusicServiceException {
try {
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
@Context UriInfo info) throws MusicQueryException, MusicServiceException {
try {
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
+ if ( null == updateObj ) {
+ return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
+ .setError(ResultType.BODYMISSING.getResult()).toMap()).build();
+ }
if((keyspace == null || keyspace.isEmpty()) || (tablename == null || tablename.isEmpty())){
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
.setError("one or more path parameters are not set, please check and try again")
if((keyspace == null || keyspace.isEmpty()) || (tablename == null || tablename.isEmpty())){
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
.setError("one or more path parameters are not set, please check and try again")
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
- @ApiParam(value = "AID", required = false) @HeaderParam("aid") String aid,
+ @ApiParam(value = "AID", required = false, hidden = true) @HeaderParam("aid") String aid,
@ApiParam(value = "Application namespace",
@ApiParam(value = "Application namespace",
- required = true) @HeaderParam(NS) String ns,
+ required = false, hidden = true) @HeaderParam(NS) String ns,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonDelete delObj,
@ApiParam(value = "Keyspace Name",
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonDelete delObj,
@ApiParam(value = "Keyspace Name",
}
EELFLoggerDelegate.mdcPut("keyspace", "( "+keyspace+" ) ");
if(delObj == null) {
}
EELFLoggerDelegate.mdcPut("keyspace", "( "+keyspace+" ) ");
if(delObj == null) {
- logger.error(EELFLoggerDelegate.errorLogger,"Required HTTP Request body is missing.", AppMessages.MISSINGDATA ,ErrorSeverity.WARN, ErrorTypes.DATAERROR);
- return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("Required HTTP Request body is missing.").toMap()).build();
+ logger.error(EELFLoggerDelegate.errorLogger,ResultType.BODYMISSING.getResult(), AppMessages.MISSINGDATA ,ErrorSeverity.WARN, ErrorTypes.DATAERROR);
+ return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ResultType.BODYMISSING.getResult()).toMap()).build();
}
PreparedQueryObject queryObject = new PreparedQueryObject();
StringBuilder columnString = new StringBuilder();
}
PreparedQueryObject queryObject = new PreparedQueryObject();
StringBuilder columnString = new StringBuilder();
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
- @ApiParam(value = "AID", required = false) @HeaderParam("aid") String aid,
+ @ApiParam(value = "AID", required = false,hidden = true) @HeaderParam("aid") String aid,
@ApiParam(value = "Application namespace",
@ApiParam(value = "Application namespace",
- required = true) @HeaderParam(NS) String ns,
+ required = false, hidden = true) @HeaderParam(NS) String ns,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
@ApiParam(value = "Keyspace Name",
required = true) @PathParam("keyspace") String keyspace,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
@ApiParam(value = "Keyspace Name",
required = true) @PathParam("keyspace") String keyspace,
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
- @ApiParam(value = "AID", required = false) @HeaderParam("aid") String aid,
+ @ApiParam(value = "AID", required = false, hidden = true) @HeaderParam("aid") String aid,
@ApiParam(value = "Application namespace",
@ApiParam(value = "Application namespace",
- required = true) @HeaderParam(NS) String ns,
+ required = false, hidden = true) @HeaderParam(NS) String ns,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonInsert selObj,
@ApiParam(value = "Keyspace Name",
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonInsert selObj,
@ApiParam(value = "Keyspace Name",
.setError("one or more path parameters are not set, please check and try again")
.toMap()).build();
}
.setError("one or more path parameters are not set, please check and try again")
.toMap()).build();
}
+ if(selObj == null) {
+ logger.error(EELFLoggerDelegate.errorLogger,ResultType.BODYMISSING.getResult(), AppMessages.MISSINGDATA ,ErrorSeverity.WARN, ErrorTypes.DATAERROR);
+ return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ResultType.BODYMISSING.getResult()).toMap()).build();
+ }
+
EELFLoggerDelegate.mdcPut("keyspace", "( "+keyspace+" ) ");
String lockId = selObj.getConsistencyInfo().get("lockId");
PreparedQueryObject queryObject = new PreparedQueryObject();
EELFLoggerDelegate.mdcPut("keyspace", "( "+keyspace+" ) ");
String lockId = selObj.getConsistencyInfo().get("lockId");
PreparedQueryObject queryObject = new PreparedQueryObject();
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
required = false) @HeaderParam(XMINORVERSION) String minorVersion,
@ApiParam(value = "Patch Version",
required = false) @HeaderParam(XPATCHVERSION) String patchVersion,
- @ApiParam(value = "AID", required = false) @HeaderParam("aid") String aid,
+ @ApiParam(value = "AID", required = false, hidden = true) @HeaderParam("aid") String aid,
@ApiParam(value = "Application namespace",
@ApiParam(value = "Application namespace",
- required = true) @HeaderParam(NS) String ns,
+ required = false,hidden = true) @HeaderParam(NS) String ns,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
@ApiParam(value = "Keyspace Name",
required = true) @PathParam("keyspace") String keyspace,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
@ApiParam(value = "Keyspace Name",
required = true) @PathParam("keyspace") String keyspace,
- @Path("/getCurrentLockHolders/{lockname}")
+ @Path("/holders/{lockname}")
@ApiOperation(value = "Get Lock Holders",
notes = "Gets the current Lock Holders",
response = Map.class)
@ApiOperation(value = "Get Lock Holders",
notes = "Gets the current Lock Holders",
response = Map.class)
String who = MusicCore.whoseTurnIsIt(lockName);
ResultType status = ResultType.SUCCESS;
String error = "";
String who = MusicCore.whoseTurnIsIt(lockName);
ResultType status = ResultType.SUCCESS;
String error = "";
status = ResultType.FAILURE;
error = "There was a problem getting the lock holder";
logger.error(EELFLoggerDelegate.errorLogger,"There was a problem getting the lock holder", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
status = ResultType.FAILURE;
error = "There was a problem getting the lock holder";
logger.error(EELFLoggerDelegate.errorLogger,"There was a problem getting the lock holder", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
server.ssl.key-store-provider=SUN
server.ssl.key-store-type=JKS
httpPort=8081
server.ssl.key-store-provider=SUN
server.ssl.key-store-type=JKS
httpPort=8081
+spring.jackson.mapper.ACCEPT_CASE_INSENSITIVE_ENUMS=true