Commit 3becdbad authored by yeonghun.nam's avatar yeonghun.nam Committed by Jee Hyeok Kim

[IOT-1556] Changes in cloud according to the stateless request/response model (group features)

The cloud implementation is revised, due to the protocol update to the stateless request/response model in the device-to-cloud communication.

- Group Management
  - Group creation implementation
  - add/update/delete properties
  - delete group
  - get group information

patch #6: POST /oic/acl/group/ response correction

Change-Id: I7db5836bff5b4cb33a7effa523f9388ff4240262
Signed-off-by: default avataryeonghun.nam <yeonghun.nam@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14333Reviewed-by: default avatarJee Hyeok Kim <jihyeok13.kim@samsung.com>
Tested-by: default avatarJee Hyeok Kim <jihyeok13.kim@samsung.com>
(cherry picked from commit 834187fe)
Reviewed-on: https://gerrit.iotivity.org/gerrit/14585Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent 9d686a6b
......@@ -29,7 +29,6 @@ import org.iotivity.cloud.accountserver.Constants;
import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
public class GroupTable {
// TODO add doxygen
private String gid = null;
private String gname = null;
private String owner = null;
......
......@@ -167,14 +167,20 @@ public class GroupBrokerManager {
}
storeGroupInfo(uid, gid, gname, parent);
return makePostResponse(gid, gname);
return makePostResponse(uid, gid, gname, parent);
}
private HashMap<String, Object> makePostResponse(String gid, String gname) {
private HashMap<String, Object> makePostResponse(String uid, String gid,
String gname, String parent) {
HashMap<String, Object> response = new HashMap<>();
response.put(Constants.KEYFIELD_GID, gid);
response.put(Constants.KEYFIELD_GROUP_NAME, gname);
response.put(Constants.KEYFIELD_GROUP_OWNER, uid);
response.put(Constants.KEYFIELD_GROUP_MEMBERS, Arrays.asList(uid));
if (parent != null) {
response.put(Constants.KEYFIELD_GROUP_PARENT, parent);
}
Log.d("Group post response : " + response.toString());
......
......@@ -156,17 +156,18 @@ public class GroupManager {
* member uuid list
*/
public void deleteMembersFromGroup(String gid, ArrayList<String> members) {
// delete devices owned by deleted members
GroupTable groupTable = getGroupTable(gid);
ArrayList<String> devices = groupTable.getDevices();
ArrayList<String> deletedDevices = new ArrayList<String>();
for (String device : devices) {
if (members.contains(findDeviceOwner(device))) {
deletedDevices.add(device);
if (devices != null) {
// delete devices owned by deleted members
ArrayList<String> deletedDevices = new ArrayList<String>();
for (String device : devices) {
if (members.contains(findDeviceOwner(device))) {
deletedDevices.add(device);
}
}
deleteDevicesFromGroup(gid, deletedDevices);
}
deleteDevicesFromGroup(gid, deletedDevices);
deleteProperties(gid, Constants.KEYFIELD_GROUP_MEMBERS, members);
deleteProperties(gid, Constants.KEYFIELD_GROUP_MASTERS, members);
}
......@@ -292,6 +293,9 @@ public class GroupManager {
public <T> ArrayList<T> getAddPropertyValues(String gid, String property,
ArrayList<T> values) {
GroupTable groupTable = getGroupTable(gid);
if (groupTable == null) {
throw new BadRequestException("group " + gid + " does not exist");
}
ArrayList<T> propertyValues = groupTable.getPropertyValue(property);
ArrayList<T> addedValues = new ArrayList<>();
for (int i = 0; i < values.size(); i++) {
......@@ -316,6 +320,9 @@ public class GroupManager {
public <T> ArrayList<T> getDeletePropertyValues(String gid, String property,
ArrayList<T> values) {
GroupTable groupTable = getGroupTable(gid);
if (groupTable == null) {
throw new BadRequestException("group " + gid + " does not exist");
}
ArrayList<T> propertyValues = groupTable.getPropertyValue(property);
ArrayList<T> deletedValues = new ArrayList<>();
for (int i = 0; i < propertyValues.size(); i++) {
......@@ -335,7 +342,7 @@ public class GroupManager {
* user uuid
*/
public void verifyGetRequestAuthz(String gid, String mid) {
verifyMemberExistanceInGroup(gid, mid);
verifyMemberExistenceInGroup(gid, mid);
}
/**
......@@ -368,8 +375,8 @@ public class GroupManager {
String parentGid = groupTable.getParent();
// delete subgroup ID of the parent group
if (parentGid != null && !parentGid.isEmpty()) {
ArrayList<Object> gidList = new ArrayList<Object>();
gidList.add(gid);
ArrayList<Object> gidList = new ArrayList<Object>(
Arrays.asList(gid));
deleteProperties(parentGid, Constants.KEYFIELD_GROUP_SUBGROUPS,
gidList);
}
......@@ -555,8 +562,11 @@ public class GroupManager {
}
}
private void verifyMemberExistanceInGroup(String gid, String mid) {
private void verifyMemberExistenceInGroup(String gid, String mid) {
GroupTable groupTable = getGroupTable(gid);
if (groupTable == null) {
throw new BadRequestException("group " + gid + " does not exist");
}
if (!groupTable.getMembers().contains(mid)) {
throw new BadRequestException("uid is not a member of the group");
}
......@@ -573,7 +583,7 @@ public class GroupManager {
case Constants.KEYFIELD_GROUP_DEVICES:
verifyDeviceOwner(mid,
(ArrayList<String>) properties.get(key));
verifyExistanceInParentGroup(gid, key,
verifyExistenceInParentGroup(gid, key,
(ArrayList<Object>) properties.get(key));
break;
case Constants.KEYFIELD_GROUP_RESOURCES:
......@@ -586,8 +596,8 @@ public class GroupManager {
verifyResourceOwner(mid,
(ArrayList<HashMap<String, Object>>) properties
.get(key));
verifyExistanceInParentGroup(gid, key,
filterResourceExistanceInParentGroupDeviceProperty(
verifyExistenceInParentGroup(gid, key,
filterResourceExistenceInParentGroupDeviceProperty(
gid,
(ArrayList<HashMap<String, Object>>) properties
.get(key)));
......@@ -596,7 +606,7 @@ public class GroupManager {
case Constants.KEYFIELD_GROUP_MASTERS:
// TODO verify if members are registered to the Account user
// DB
verifyExistanceInParentGroup(gid,
verifyExistenceInParentGroup(gid,
Constants.KEYFIELD_GROUP_MEMBERS,
(ArrayList<Object>) properties.get(key));
break;
......@@ -651,7 +661,7 @@ public class GroupManager {
throw new BadRequestException("cannot remove owner Id");
}
case Constants.KEYFIELD_GROUP_MASTERS:
verifyExistanceInParentGroup(gid, key,
verifyExistenceInParentGroup(gid, key,
(ArrayList<Object>) properties.get(key));
break;
default:
......@@ -661,7 +671,7 @@ public class GroupManager {
}
}
private ArrayList<HashMap<String, Object>> filterResourceExistanceInParentGroupDeviceProperty(
private ArrayList<HashMap<String, Object>> filterResourceExistenceInParentGroupDeviceProperty(
String gid, ArrayList<HashMap<String, Object>> resources) {
GroupTable parentGroupTable = getParentGroupTable(gid);
if (parentGroupTable == null) {
......@@ -690,7 +700,7 @@ public class GroupManager {
}
}
private <T> void verifyExistanceInParentGroup(String gid, String property,
private <T> void verifyExistenceInParentGroup(String gid, String property,
ArrayList<T> values) {
GroupTable parentGroupTable = getParentGroupTable(gid);
if (parentGroupTable == null) {
......@@ -701,11 +711,11 @@ public class GroupManager {
.getPropertyValue(property);
if (groupValues == null) {
throw new BadRequestException(
"verifying parent group existance failed");
"verifying parent group Existence failed");
}
if (!groupValues.containsAll(values)) {
throw new BadRequestException(
"verifying parent group existance failed");
"verifying parent group Existence failed");
}
}
......@@ -837,4 +847,4 @@ public class GroupManager {
property + " is not supported property in the group");
}
}
}
\ No newline at end of file
}
......@@ -89,10 +89,15 @@ public class GroupResource extends Resource {
HashMap<String, Object> parsedPayload = mCbor
.parsePayloadFromCbor(payload, HashMap.class);
checkPayloadException(Arrays.asList(Constants.REQ_UUID_ID),
checkQueryException(Arrays.asList(Constants.KEYFIELD_UID),
request.getUriQueryMap());
checkPayloadException(Arrays.asList(Constants.KEYFIELD_GROUP_MEMBERS),
parsedPayload);
String uid = parsedPayload.get(Constants.REQ_UUID_ID).toString();
// get user id
String uid = request.getUriQueryMap().get(Constants.KEYFIELD_UID)
.get(0);
if (uid == null || uid.isEmpty()) {
throw new BadRequestException(
......@@ -105,8 +110,8 @@ public class GroupResource extends Resource {
Constants.KEYFIELD_GROUP_PARENT);
if (parent != null) {
ArrayList<String> properties = new ArrayList<>();
properties.add(Constants.KEYFIELD_GROUP);
ArrayList<String> properties = new ArrayList<>(
Arrays.asList(Constants.KEYFIELD_GROUP));
GroupBrokerManager.getInstance().verifyAuthorization(uid, parent,
properties, UserOperation.ADD);
}
......@@ -128,11 +133,16 @@ public class GroupResource extends Resource {
IRequest request) {
HashMap<String, List<String>> queryMap = request.getUriQueryMap();
checkQueryException(Arrays.asList(Constants.REQ_UUID_ID), queryMap);
List<String> deviceList = queryMap.get(Constants.REQ_UUID_ID);
String uid = deviceList.get(0);
checkQueryException(Arrays.asList(Constants.REQ_UUID_ID,
Constants.KEYFIELD_GROUP_MEMBERS), queryMap);
String uid = queryMap.get(Constants.REQ_UUID_ID).get(0);
if (!uid.equals(
queryMap.get(Constants.KEYFIELD_GROUP_MEMBERS).get(0))) {
throw new BadRequestException(
Constants.REQ_UUID_ID + "query value should be equal to "
+ Constants.KEYFIELD_GROUP_MEMBERS + "query value");
}
switch (request.getObserve()) {
case SUBSCRIBE:
GroupBrokerManager.getInstance().addObserver(uid, srcDevice,
......@@ -186,13 +196,20 @@ public class GroupResource extends Resource {
HashMap<String, Object> payloadData = mCbor
.parsePayloadFromCbor(request.getPayload(), HashMap.class);
// check if the payload has the key "uid"
checkPayloadException(Constants.REQ_UUID_ID, payloadData);
// TODO to be deleted
if (payloadData.containsKey(Constants.KEYFIELD_UID)) {
throw new BadRequestException(
" uid key is not supported in the payload");
}
checkQueryException(Arrays.asList(Constants.KEYFIELD_UID),
request.getUriQueryMap());
// get "uid" value
String mid = (String) payloadData.get(Constants.REQ_UUID_ID);
// get user id
String uid = request.getUriQueryMap().get(Constants.KEYFIELD_UID)
.get(0);
if (mid == null || mid.isEmpty()) {
if (uid == null || uid.isEmpty()) {
throw new BadRequestException(
Constants.REQ_UUID_ID + " is null or empty");
}
......@@ -200,11 +217,10 @@ public class GroupResource extends Resource {
String gid = request.getUriPathSegments()
.get(getUriPathSegments().size());
payloadData.remove(Constants.REQ_UUID_ID);
// process POST oic/acl/group/<gid> to update group info
if (request.getUriQuery() == null) {
handlePostUpdateRequest(gid, mid, payloadData);
if (!request.getUriQueryMap()
.containsKey(Constants.REQ_GROUP_QUERY_OPERATION)) {
handlePostUpdateRequest(gid, uid, payloadData);
} else {
checkQueryException(Constants.REQ_GROUP_QUERY_OPERATION,
request.getUriQueryMap());
......@@ -214,10 +230,10 @@ public class GroupResource extends Resource {
switch (postOption) {
case Constants.REQ_GROUP_QUERY_ADD:
handlePostAddRequest(gid, mid, payloadData);
handlePostAddRequest(gid, uid, payloadData);
break;
case Constants.REQ_GROUP_QUERY_DELETE:
handlePostDeleteRequest(gid, mid, payloadData);
handlePostDeleteRequest(gid, uid, payloadData);
break;
default:
throw new PreconditionFailedException(
......@@ -378,13 +394,20 @@ public class GroupResource extends Resource {
private IResponse handleGroupGetRequest(IRequest request)
throws ServerException {
checkQueryException(Constants.REQ_UUID_ID, request.getUriQueryMap());
HashMap<String, List<String>> queryMap = request.getUriQueryMap();
HashMap<String, Object> responsePayload = null;
checkQueryException(Arrays.asList(Constants.REQ_UUID_ID,
Constants.KEYFIELD_GROUP_MEMBERS), queryMap);
String mid = request.getUriQueryMap().get(Constants.REQ_UUID_ID).get(0);
String uid = queryMap.get(Constants.REQ_UUID_ID).get(0);
if (!uid.equals(
queryMap.get(Constants.KEYFIELD_GROUP_MEMBERS).get(0))) {
throw new BadRequestException(
Constants.REQ_UUID_ID + "query value should be equal to "
+ Constants.KEYFIELD_GROUP_MEMBERS + "query value");
}
if (mid == null || mid.isEmpty()) {
if (uid == null || uid.isEmpty()) {
throw new BadRequestException(
Constants.REQ_UUID_ID + " is null or empty");
}
......@@ -392,7 +415,9 @@ public class GroupResource extends Resource {
String gid = request.getUriPathSegments()
.get(getUriPathSegments().size());
GroupManager.getInstance().verifyGetRequestAuthz(gid, mid);
GroupManager.getInstance().verifyGetRequestAuthz(gid, uid);
HashMap<String, Object> responsePayload = null;
switch (request.getObserve()) {
case NOTHING:
......@@ -413,12 +438,20 @@ public class GroupResource extends Resource {
private IResponse handleGroupDeleteRequest(IRequest request)
throws ServerException {
checkQueryException(Arrays.asList(Constants.REQ_UUID_ID),
request.getUriQueryMap());
HashMap<String, List<String>> queryMap = request.getUriQueryMap();
checkQueryException(Arrays.asList(Constants.REQ_UUID_ID,
Constants.KEYFIELD_GROUP_OWNER), queryMap);
String mid = request.getUriQueryMap().get(Constants.REQ_UUID_ID).get(0);
String uid = queryMap.get(Constants.REQ_UUID_ID).get(0);
if (!uid.equals(queryMap.get(Constants.KEYFIELD_GROUP_OWNER).get(0))) {
throw new BadRequestException(
Constants.REQ_UUID_ID + "query value should be equal to "
+ Constants.KEYFIELD_GROUP_OWNER
+ "query value to delete group");
}
if (mid == null || mid.isEmpty()) {
if (uid == null || uid.isEmpty()) {
throw new BadRequestException(
Constants.REQ_UUID_ID + " is null or empty");
}
......@@ -426,7 +459,7 @@ public class GroupResource extends Resource {
String gid = request.getUriPathSegments()
.get(getUriPathSegments().size());
GroupManager.getInstance().verifyDeleteRequestAuthz(gid, mid);
GroupManager.getInstance().verifyDeleteRequestAuthz(gid, uid);
String parent = GroupManager.getInstance().getGroupTable(gid)
.getParent();
......
......@@ -6,6 +6,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.concurrent.CountDownLatch;
......@@ -33,7 +34,8 @@ import org.mockito.stubbing.Answer;
public class GroupBrokerTest {
private String GROUP_URI = Constants.GROUP_FULL_URI;
private String UID_QUERY = "uid=";
private String UID_QUERY = Constants.KEYFIELD_UID
+ "=";
private String mGid1 = "g1";
private String mGid2 = "g2";
private String mGname1 = "myHome";
......@@ -91,6 +93,8 @@ public class GroupBrokerTest {
assertTrue(responseCodeCheck(mResponse, ResponseStatus.CHANGED));
assertTrue(checkProperty(mResponse, Constants.KEYFIELD_GID));
assertTrue(checkProperty(mResponse, Constants.KEYFIELD_GROUP_NAME));
assertTrue(checkProperty(mResponse, Constants.KEYFIELD_GROUP_OWNER));
assertTrue(checkProperty(mResponse, Constants.KEYFIELD_GROUP_MEMBERS));
assertTrue(mLatch.await(2L, SECONDS));
}
......@@ -103,6 +107,9 @@ public class GroupBrokerTest {
assertTrue(responseCodeCheck(mResponse, ResponseStatus.CHANGED));
assertTrue(checkProperty(mResponse, Constants.KEYFIELD_GID));
assertTrue(checkProperty(mResponse, Constants.KEYFIELD_GROUP_NAME));
assertTrue(checkProperty(mResponse, Constants.KEYFIELD_GROUP_OWNER));
assertTrue(checkProperty(mResponse, Constants.KEYFIELD_GROUP_MEMBERS));
assertTrue(checkProperty(mResponse, Constants.KEYFIELD_GROUP_PARENT));
assertTrue(mLatch.await(2L, SECONDS));
}
......@@ -116,7 +123,9 @@ public class GroupBrokerTest {
@Test
public void testGetGroupList() throws Exception {
getTestMethodName();
GroupBrokerManager.getInstance().createGroup(mUid1, mGid1, null, null);
sendCreateGroupRequest(mMockDevice, mUid1, mGname1, null);
String gid = getProperty(mResponse, Constants.KEYFIELD_GID).toString();
sendCreateGroupRequest(mMockDevice, mUid1, null, gid);
sendGetGroupResquest(mMockDevice, mUid1);
assertTrue(responseCodeCheck(mResponse, ResponseStatus.CONTENT));
}
......@@ -149,11 +158,14 @@ public class GroupBrokerTest {
String gname, String parent) {
IRequest request = null;
HashMap<String, Object> payloadData = new HashMap<String, Object>();
payloadData.put(Constants.REQ_UUID_ID, uid);
payloadData.put(Constants.KEYFIELD_GROUP_NAME, gname);
payloadData.put(Constants.KEYFIELD_GROUP_PARENT, parent);
payloadData.put(Constants.KEYFIELD_GROUP_MEMBERS,
new ArrayList<String>(Arrays.asList(uid)));
payloadData.put(Constants.KEYFIELD_OID, uid);
request = MessageBuilder.createRequest(RequestMethod.POST, GROUP_URI,
null, ContentFormat.APPLICATION_CBOR,
Constants.KEYFIELD_UID + "=" + uid,
ContentFormat.APPLICATION_CBOR,
mCbor.encodingPayloadToCbor(payloadData));
mGroupResource.onDefaultRequestReceived(device, request);
}
......@@ -161,7 +173,8 @@ public class GroupBrokerTest {
private void sendGetGroupResquest(CoapDevice device, String uid) {
IRequest request = null;
request = MessageBuilder.createRequest(RequestMethod.GET, GROUP_URI,
UID_QUERY + uid);
UID_QUERY + uid + ";" + Constants.KEYFIELD_GROUP_MEMBERS + "="
+ uid);
mGroupResource.onDefaultRequestReceived(device, request);
}
......@@ -169,7 +182,8 @@ public class GroupBrokerTest {
Observe obs) {
IRequest request = null;
request = MessageBuilder.createRequest(RequestMethod.GET, GROUP_URI,
UID_QUERY + uid);
UID_QUERY + uid + ";" + Constants.KEYFIELD_GROUP_MEMBERS + "="
+ uid);
((CoapRequest) request).setObserve(obs);
mGroupResource.onDefaultRequestReceived(device, request);
}
......
......@@ -398,6 +398,21 @@ public class GroupResourceTest {
assertTrue(mLatch.await(2L, SECONDS));
}
@Test(expected = ServerException.BadRequestException.class)
public void testGetNonExistongGroup() throws Exception {
getTestMethodName();
HashMap<String, Object> properties = new HashMap<>();
ArrayList<String> members = new ArrayList<>();
members.add(mUid2);
members.add(mUid3);
properties.put(Constants.KEYFIELD_GROUP_MEMBERS, members);
// add members to the parent group
GroupManager.getInstance().addMembersToGroup(mGid1, members);
getGroupInfo(mMockDevice, mGid1 + "notExist", mUid1);
assertTrue(methodCheck(mResponse, ResponseStatus.CONTENT));
assertTrue(mLatch.await(2L, SECONDS));
}
@Test(expected = ServerException.BadRequestException.class)
public void testGetGroupByNonExistingUser() throws Exception {
getTestMethodName();
......@@ -501,6 +516,15 @@ public class GroupResourceTest {
assertTrue(mLatch.await(2L, SECONDS));
}
@Test(expected = ServerException.BadRequestException.class)
public void testDeleteNonExistingGroup() throws Exception {
getTestMethodName();
setExampleGroup();
deleteGroup(mMockDevice, mGid1 + "notExist", mUid1);
assertTrue(methodCheck(mResponse, ResponseStatus.DELETED));
assertTrue(mLatch.await(2L, SECONDS));
}
@Test(expected = ServerException.BadRequestException.class)
public void testDeleteGroupByMaster() throws Exception {
getTestMethodName();
......@@ -601,6 +625,33 @@ public class GroupResourceTest {
assertTrue(mLatch.await(2L, SECONDS));
}
@Test(expected = ServerException.BadRequestException.class)
public void testUpdatePropertiesToNonExistingGroup() throws Exception {
getTestMethodName();
setExampleGroup();
HashMap<String, Object> properties = new HashMap<>();
ArrayList<HashMap<String, Object>> resources = new ArrayList<>();
// add resource 1
resources.add(makeResources("/di/" + mDi1 + "/a/switch/1",
Arrays.asList("core.switch"),
Arrays.asList("oic.if.baseline")));
properties.put(Constants.KEYFIELD_GROUP_RESOURCES, resources);
ArrayList<String> members = new ArrayList<>();
members.add(mUid1);
members.add(mUid2);
properties.put(Constants.KEYFIELD_GROUP_MEMBERS, members);
ArrayList<String> masters = new ArrayList<>();
masters.add(mUid3);
properties.put(Constants.KEYFIELD_GROUP_MASTERS, masters);
updateProperties(mMockDevice, mGid1 + "nonExists", mUid1, properties);
assertTrue(methodCheck(mResponse, ResponseStatus.CHANGED));
assertTrue(mLatch.await(2L, SECONDS));
}
private HashMap<String, Object> setExampleGroup() throws Exception {
HashMap<String, Object> properties = new HashMap<>();
ArrayList<HashMap<String, Object>> resources = new ArrayList<>();
......@@ -635,6 +686,7 @@ public class GroupResourceTest {
subgroupProperties.put(Constants.KEYFIELD_GROUP_RESOURCES,
subgroupResources);
addProperties(mMockDevice, mGid2, mUid1, subgroupProperties);
System.out.println("---------- set Example Group END");
return properties;
}
......@@ -642,7 +694,8 @@ public class GroupResourceTest {
throws Exception {
System.out.println("-----Get group, gid : " + gid);
IRequest request = MessageBuilder.createRequest(RequestMethod.DELETE,
GROUP_URI + "/" + gid, Constants.REQ_UUID_ID + "=" + uid);
GROUP_URI + "/" + gid, Constants.REQ_UUID_ID + "=" + uid + ";"
+ Constants.KEYFIELD_GROUP_OWNER + "=" + uid);
mGroupResource.onDefaultRequestReceived(device, request);
}
......@@ -686,17 +739,20 @@ public class GroupResourceTest {
throws Exception {
System.out.println("-----Get group, gid : " + gid);
IRequest request = MessageBuilder.createRequest(RequestMethod.GET,
GROUP_URI + "/" + gid, Constants.REQ_UUID_ID + "=" + uid);
GROUP_URI + "/" + gid, Constants.REQ_UUID_ID + "=" + uid + ";"
+ Constants.KEYFIELD_GROUP_MEMBERS + "=" + uid);
mGroupResource.onDefaultRequestReceived(device, request);
}
private void addProperties(CoapDevice device, String gid, String uid,
HashMap<String, Object> properties) throws Exception {
System.out.println("-----Add properties");
properties.put(Constants.REQ_UUID_ID, uid);
IRequest request = null;
request = MessageBuilder.createRequest(RequestMethod.POST,
GROUP_URI + "/" + gid, "op=" + Constants.REQ_GROUP_QUERY_ADD,
GROUP_URI + "/" + gid,
Constants.KEYFIELD_UID + "=" + uid + ";"
+ Constants.REQ_GROUP_QUERY_OPERATION + "="
+ Constants.REQ_GROUP_QUERY_ADD,
ContentFormat.APPLICATION_CBOR,
mCbor.encodingPayloadToCbor(properties));
mGroupResource.onDefaultRequestReceived(device, request);
......@@ -705,10 +761,10 @@ public class GroupResourceTest {
private void updateProperties(CoapDevice device, String gid, String uid,
HashMap<String, Object> properties) throws Exception {
System.out.println("-----Update properties");
properties.put(Constants.REQ_UUID_ID, uid);
IRequest request = null;
request = MessageBuilder.createRequest(RequestMethod.POST,
GROUP_URI + "/" + gid, null, ContentFormat.APPLICATION_CBOR,
GROUP_URI + "/" + gid, Constants.KEYFIELD_UID + "=" + uid,
ContentFormat.APPLICATION_CBOR,
mCbor.encodingPayloadToCbor(properties));
mGroupResource.onDefaultRequestReceived(device, request);
}
......@@ -716,10 +772,12 @@ public class GroupResourceTest {
private void deleteProperties(CoapDevice device, String gid, String uid,
HashMap<String, Object> properties) throws Exception {
System.out.println("-----Delete properties");
properties.put(Constants.REQ_UUID_ID, uid);
IRequest request = null;
request = MessageBuilder.createRequest(RequestMethod.POST,
GROUP_URI + "/" + gid, "op=" + Constants.REQ_GROUP_QUERY_DELETE,
GROUP_URI + "/" + gid,
Constants.KEYFIELD_UID + "=" + uid + ";"
+ Constants.REQ_GROUP_QUERY_OPERATION + "="
+ Constants.REQ_GROUP_QUERY_DELETE,
ContentFormat.APPLICATION_CBOR,
mCbor.encodingPayloadToCbor(properties));