Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
WS4D
jCoAP
Commits
c7c693bc
Commit
c7c693bc
authored
Sep 01, 2015
by
Bjoern Konieczek
Browse files
Adding Deletable Flag to Resources
parent
7e8d9e00
Changes
4
Hide whitespace changes
Inline
Side-by-side
ws4d-jcoap/src/org/ws4d/coap/rest/BasicCoapResource.java
View file @
c7c693bc
...
...
@@ -42,6 +42,7 @@ public class BasicCoapResource implements CoapResource {
String
resourceType
=
null
;
HashMap
<
CoapChannel
,
CoapRequest
>
observer
=
new
HashMap
<
CoapChannel
,
CoapRequest
>();
boolean
observable
=
false
;
boolean
deletable
=
false
;
/** MUST NOT be greater than 0xFFFF (2 byte integer) */
int
observeSequenceNumber
=
0
;
...
...
@@ -200,7 +201,15 @@ public class BasicCoapResource implements CoapResource {
public
int
getObserveSequenceNumber
()
{
return
observeSequenceNumber
;
}
public
boolean
isDeletable
()
{
return
deletable
;
}
public
void
setDeletable
(
boolean
deletable
)
{
this
.
deletable
=
deletable
;
}
@Override
public
long
expires
()
{
return
expires
;
...
...
ws4d-jcoap/src/org/ws4d/coap/rest/CoapResource.java
View file @
c7c693bc
...
...
@@ -52,6 +52,11 @@ public interface CoapResource extends Resource {
* @return true, if the resource is observable.
*/
public
boolean
isObservable
();
/**
* @return true, if the resource is deletable.
*/
public
boolean
isDeletable
();
/**
* if the resource is observable
...
...
ws4d-jcoap/src/org/ws4d/coap/rest/CoapResourceServer.java
View file @
c7c693bc
...
...
@@ -41,6 +41,7 @@ import org.ws4d.coap.messages.CoapResponseCode;
/**
* @author Christian Lerche <christian.lerche@uni-rostock.de>
* @author Björn Konieczek <bjoern.konieczek@uni-rostock.de>
*/
public
class
CoapResourceServer
implements
CoapServer
,
ResourceServer
{
private
int
port
=
0
;
...
...
@@ -231,7 +232,7 @@ public class CoapResourceServer implements CoapServer, ResourceServer {
case
DELETE:
/* CoAP: "A 2.02 (Deleted) response SHOULD be sent on
success or in case the resource did not exist before the request.*/
if
(
resource
!=
coreResource
)
{
if
(
resource
.
isDeletable
()
)
{
deleteResource
(
targetPath
);
response
=
channel
.
createResponse
(
request
,
CoapResponseCode
.
Deleted_202
);
}
else
{
...
...
ws4d-jcoap/src/org/ws4d/coap/rest/CoreResource.java
View file @
c7c693bc
...
...
@@ -159,6 +159,11 @@ public class CoreResource implements CoapResource {
return
false
;
}
@Override
public
boolean
isDeletable
()
{
return
false
;
}
public
int
getObserveSequenceNumber
(){
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment