Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Varun Sharma
2016-07-18 14:37:13 +0530
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1853b3f3598f7e3137dce58c1a2d6043b312822d
1853b3f3
1 parent
c553c954
Cherry pick ONOS-4835 fix
Change-Id: I82ecb542dad4430d55af0fc684f8d13d6e45b45e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
18 deletions
web/api/src/main/java/org/onosproject/rest/resources/GroupsWebResource.java
web/api/src/main/resources/definitions/Groups.json
web/api/src/main/resources/definitions/GroupsPost.json
web/api/src/test/java/org/onosproject/rest/resources/GroupsResourceTest.java
web/api/src/main/java/org/onosproject/rest/resources/GroupsWebResource.java
View file @
1853b3f
...
...
@@ -44,6 +44,7 @@ import javax.ws.rs.core.UriInfo;
import
java.io.IOException
;
import
java.io.InputStream
;
import
org.onlab.util.HexString
;
import
static
org
.
onlab
.
util
.
Tools
.
nullIsNotFound
;
/**
...
...
@@ -115,7 +116,12 @@ public class GroupsWebResource extends AbstractWebResource {
public
Response
getGroupByDeviceIdAndAppCookie
(
@PathParam
(
"deviceId"
)
String
deviceId
,
@PathParam
(
"appCookie"
)
String
appCookie
)
{
final
DeviceId
deviceIdInstance
=
DeviceId
.
deviceId
(
deviceId
);
final
GroupKey
appCookieInstance
=
new
DefaultGroupKey
(
appCookie
.
getBytes
());
if
(!
appCookie
.
startsWith
(
"0x"
))
{
throw
new
IllegalArgumentException
(
"APP_COOKIE must be a hex string starts with 0x"
);
}
final
GroupKey
appCookieInstance
=
new
DefaultGroupKey
(
HexString
.
fromHexString
(
appCookie
.
split
(
"0x"
)[
1
],
""
));
Group
group
=
nullIsNotFound
(
groupService
.
getGroup
(
deviceIdInstance
,
appCookieInstance
),
GROUP_NOT_FOUND
);
...
...
@@ -179,7 +185,12 @@ public class GroupsWebResource extends AbstractWebResource {
public
Response
deleteGroupByDeviceIdAndAppCookie
(
@PathParam
(
"deviceId"
)
String
deviceId
,
@PathParam
(
"appCookie"
)
String
appCookie
)
{
DeviceId
deviceIdInstance
=
DeviceId
.
deviceId
(
deviceId
);
GroupKey
appCookieInstance
=
new
DefaultGroupKey
(
appCookie
.
getBytes
());
if
(!
appCookie
.
startsWith
(
"0x"
))
{
throw
new
IllegalArgumentException
(
"APP_COOKIE must be a hex string starts with 0x"
);
}
GroupKey
appCookieInstance
=
new
DefaultGroupKey
(
HexString
.
fromHexString
(
appCookie
.
split
(
"0x"
)[
1
],
""
));
groupService
.
removeGroup
(
deviceIdInstance
,
appCookieInstance
,
null
);
return
Response
.
noContent
().
build
();
...
...
web/api/src/main/resources/definitions/Groups.json
View file @
1853b3f
...
...
@@ -67,6 +67,11 @@
"description"
:
"types of the group"
,
"example"
:
"ALL"
},
"deviceId"
:
{
"type"
:
"string"
,
"description"
:
"device identifier"
,
"example"
:
"of:0000000000000003"
},
"appId"
:
{
"type"
:
"string"
,
"description"
:
"application identifier"
,
...
...
@@ -154,4 +159,4 @@
}
}
}
}
\ No newline at end of file
}
...
...
web/api/src/main/resources/definitions/GroupsPost.json
View file @
1853b3f
...
...
@@ -3,7 +3,6 @@
"title"
:
"group"
,
"required"
:
[
"type"
,
"deviceId"
,
"appCookie"
,
"groupId"
,
"buckets"
...
...
@@ -13,10 +12,6 @@
"type"
:
"string"
,
"example"
:
"ALL"
},
"deviceId"
:
{
"type"
:
"string"
,
"example"
:
"of:0000000000000001"
},
"appCookie"
:
{
"type"
:
"string"
,
"description"
:
"application cookie. Arbitrary length byte array represented in hex string"
,
...
...
@@ -82,4 +77,4 @@
}
}
}
}
\ No newline at end of file
}
...
...
web/api/src/test/java/org/onosproject/rest/resources/GroupsResourceTest.java
View file @
1853b3f
...
...
@@ -95,14 +95,14 @@ public class GroupsResourceTest extends ResourceTest {
final
Device
device2
=
new
DefaultDevice
(
null
,
deviceId2
,
Device
.
Type
.
OTHER
,
""
,
""
,
""
,
""
,
null
);
final
MockGroup
group1
=
new
MockGroup
(
deviceId1
,
1
,
"111"
,
1
);
final
MockGroup
group2
=
new
MockGroup
(
deviceId1
,
2
,
"222"
,
2
);
final
MockGroup
group1
=
new
MockGroup
(
deviceId1
,
1
,
"
0x
111"
,
1
);
final
MockGroup
group2
=
new
MockGroup
(
deviceId1
,
2
,
"
0x
222"
,
2
);
final
MockGroup
group3
=
new
MockGroup
(
deviceId2
,
3
,
"333"
,
3
);
final
MockGroup
group4
=
new
MockGroup
(
deviceId2
,
4
,
"444"
,
4
);
final
MockGroup
group3
=
new
MockGroup
(
deviceId2
,
3
,
"
0x
333"
,
3
);
final
MockGroup
group4
=
new
MockGroup
(
deviceId2
,
4
,
"
0x
444"
,
4
);
final
MockGroup
group5
=
new
MockGroup
(
deviceId3
,
5
,
"555"
,
5
);
final
MockGroup
group6
=
new
MockGroup
(
deviceId3
,
6
,
"666"
,
6
);
final
MockGroup
group5
=
new
MockGroup
(
deviceId3
,
5
,
"
0x
555"
,
5
);
final
MockGroup
group6
=
new
MockGroup
(
deviceId3
,
6
,
"
0x
666"
,
6
);
/**
* Mock class for a group.
...
...
@@ -462,7 +462,7 @@ public class GroupsResourceTest extends ResourceTest {
.
andReturn
(
group5
).
anyTimes
();
replay
(
mockGroupService
);
final
WebTarget
wt
=
target
();
final
String
response
=
wt
.
path
(
"groups/"
+
deviceId3
+
"/"
+
"111"
)
final
String
response
=
wt
.
path
(
"groups/"
+
deviceId3
+
"/"
+
"
0x
111"
)
.
request
().
get
(
String
.
class
);
final
JsonObject
result
=
Json
.
parse
(
response
).
asObject
();
assertThat
(
result
,
notNullValue
());
...
...
@@ -484,7 +484,7 @@ public class GroupsResourceTest extends ResourceTest {
.
andReturn
(
null
).
anyTimes
();
replay
(
mockGroupService
);
final
WebTarget
wt
=
target
();
final
Response
response
=
wt
.
path
(
"groups/"
+
deviceId3
+
"/"
+
"222"
).
request
().
get
();
final
Response
response
=
wt
.
path
(
"groups/"
+
deviceId3
+
"/"
+
"
0x
222"
).
request
().
get
();
assertEquals
(
404
,
response
.
getStatus
());
}
...
...
@@ -522,7 +522,7 @@ public class GroupsResourceTest extends ResourceTest {
WebTarget
wt
=
target
();
String
location
=
"/groups/1/111"
;
String
location
=
"/groups/1/
0x
111"
;
Response
deleteResponse
=
wt
.
path
(
location
)
.
request
(
MediaType
.
APPLICATION_JSON_TYPE
)
...
...
Please
register
or
login
to post a comment