Commit c7c693bc authored by Bjoern Konieczek's avatar Bjoern Konieczek
Browse files

Adding Deletable Flag to Resources

parent 7e8d9e00
......@@ -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;
......
......@@ -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
......
......@@ -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 {
......
......@@ -159,6 +159,11 @@ public class CoreResource implements CoapResource {
return false;
}
@Override
public boolean isDeletable() {
return false;
}
public int getObserveSequenceNumber(){
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment