private IResponse handleGroupPostRequest(IRequest request)
throws ServerException {
+ if (request.getPayload() == null) {
+ throw new BadRequestException("payload is null");
+ }
HashMap<String, Object> payloadData = mCbor
.parsePayloadFromCbor(request.getPayload(), HashMap.class);
Constants.KEYFIELD_GROUP_MEMBERS), queryMap);
String uid = queryMap.get(Constants.REQ_UUID_ID).get(0);
+
+ if (uid == null || uid.isEmpty()) {
+ throw new BadRequestException(
+ Constants.REQ_UUID_ID + " is null or empty");
+ }
+
if (!uid.equals(
queryMap.get(Constants.KEYFIELD_GROUP_MEMBERS).get(0))) {
throw new BadRequestException(
+ Constants.KEYFIELD_GROUP_MEMBERS + "query value");
}
- if (uid == null || uid.isEmpty()) {
- throw new BadRequestException(
- Constants.REQ_UUID_ID + " is null or empty");
- }
-
String gid = request.getUriPathSegments()
.get(getUriPathSegments().size());
Constants.KEYFIELD_GROUP_OWNER), queryMap);
String uid = queryMap.get(Constants.REQ_UUID_ID).get(0);
+
+ if (uid == null || uid.isEmpty()) {
+ throw new BadRequestException(
+ Constants.REQ_UUID_ID + " is null or empty");
+ }
+
if (!uid.equals(queryMap.get(Constants.KEYFIELD_GROUP_OWNER).get(0))) {
throw new BadRequestException(
Constants.REQ_UUID_ID + "query value should be equal to "
+ "query value to delete group");
}
- if (uid == null || uid.isEmpty()) {
- throw new BadRequestException(
- Constants.REQ_UUID_ID + " is null or empty");
- }
-
String gid = request.getUriPathSegments()
.get(getUriPathSegments().size());
}
private IResponse handlePostRequest(IRequest request)
- throws ServerException {
+ throws ServerException {
+
+ if (request.getPayload() == null) {
+ throw new BadRequestException("payload is null");
+ }
- HashMap<String, Object> payloadData = mCbor
+ HashMap<String, Object> payloadData = mCbor
.parsePayloadFromCbor(request.getPayload(), HashMap.class);
- if (null !=request.getUriQueryMap()) {
- String aclid = request.getUriPathSegments().get(getUriPathSegments().size());
- String aceid = request.getUriQueryMap().get(Constants.REQ_ACE_ID).get(0);
- List<HashMap<String, Object>> aclist = (List<HashMap<String, Object>>) payloadData
+ if (null != request.getUriQueryMap()) {
+ String aclid = request.getUriPathSegments()
+ .get(getUriPathSegments().size());
+ String aceid = request.getUriQueryMap().get(Constants.REQ_ACE_ID)
+ .get(0);
+ List<HashMap<String, Object>> aclist = (List<HashMap<String, Object>>) payloadData
.get(Constants.REQ_ACL_LIST);
- mAclManager.updateACE(aclid, aceid, aclist.get(0));
- return MessageBuilder.createResponse(request, ResponseStatus.CHANGED);
+ mAclManager.updateACE(aclid, aceid, aclist.get(0));
+ return MessageBuilder.createResponse(request,
+ ResponseStatus.CHANGED);
+ } else if (!getUriPathSegments()
+ .containsAll(request.getUriPathSegments())) {
+ String aclid = request.getUriPathSegments()
+ .get(getUriPathSegments().size());
+
+ List<HashMap<String, Object>> aclist = null;
+ if (!payloadData.containsKey(Constants.REQ_ACL_LIST)) {
+ throw new BadRequestException("aclist not included in payload");
}
- else if (!getUriPathSegments().containsAll(request.getUriPathSegments())) {
- String aclid = request.getUriPathSegments().get(getUriPathSegments().size());
-
- List<HashMap<String, Object>> aclist = null;
- if (!payloadData.containsKey(Constants.REQ_ACL_LIST)) {
- throw new BadRequestException("aclist not included in payload");
- }
- aclist = (List<HashMap<String, Object>>) payloadData
+ aclist = (List<HashMap<String, Object>>) payloadData
.get(Constants.REQ_ACL_LIST);
- aclist= mAclManager.addAclACE(aclid, aclist);
- payloadData.put(Constants.REQ_ACL_LIST, aclist);
- return MessageBuilder.createResponse(request, ResponseStatus.CHANGED,
- ContentFormat.APPLICATION_CBOR,
- mCbor.encodingPayloadToCbor(payloadData));
- }
- throw new BadRequestException("uriPath is invalid");
+ aclist = mAclManager.addAclACE(aclid, aclist);
+ payloadData.put(Constants.REQ_ACL_LIST, aclist);
+ return MessageBuilder.createResponse(request,
+ ResponseStatus.CHANGED, ContentFormat.APPLICATION_CBOR,
+ mCbor.encodingPayloadToCbor(payloadData));
}
-
+ throw new BadRequestException("uriPath is invalid");
+ }
@SuppressWarnings("unchecked")
aclid = request.getUriPathSegments()
.get(getUriPathSegments().size());
- if (request.getUriQueryMap() == null)
- {
+ if (request.getUriQueryMap() == null) {
mAclManager.deleteAclAclist(aclid);
- }
- else if (request.getUriQueryMap()
+ } else if (request.getUriQueryMap()
.containsKey(Constants.REQ_ACE_ID)) {
- String aceid = request.getUriQueryMap().get(Constants.REQ_ACE_ID)
- .get(0);
+ String aceid = request.getUriQueryMap()
+ .get(Constants.REQ_ACE_ID).get(0);
mAclManager.deleteAclACE(aclid, aceid);
- }
- else {
+ } else {
throw new BadRequestException("uriPath is invalid");
}
}