Skip to content

Commit

Permalink
Resource delete
Browse files Browse the repository at this point in the history
  • Loading branch information
jodygarnett committed Mar 31, 2017
1 parent ff12e03 commit 9f6cd61
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Expand Up @@ -84,7 +84,6 @@ public TemplateController(@Qualifier("catalog") Catalog catalog) {
"/workspaces/{workspace}/coveragestores/{store}/coverages/{type}/templates/{template}",
}
)

public void templateDelete(
HttpServletResponse response,
@PathVariable(required = false) String workspace,
Expand All @@ -99,8 +98,8 @@ public void templateDelete(
if( resource.getType() != Type.RESOURCE ){
throw new ResourceNotFoundException("Template not found: '"+path+"'");
}
boolean deleted = resource.delete();
if (!deleted) {
boolean removed = resource.delete();
if (!removed) {
throw new RestException("Template '" + path + "' not removed", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
Expand Down
Expand Up @@ -49,6 +49,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand Down Expand Up @@ -212,8 +213,6 @@ public Object resourceGet(HttpServletRequest request, HttpServletResponse respon
}
/**
* Upload resource contents.
*
* @return All templates
*/
@PutMapping(consumes = {MediaType.ALL_VALUE})
@ResponseStatus(HttpStatus.CREATED)
Expand All @@ -228,6 +227,20 @@ public void resourcePut(HttpServletRequest request){
}
}

/**
* Delete resourc
*
* @return All templates
*/
@DeleteMapping
public void resourceDelete(HttpServletRequest request){
Resource resource = resource(request);
boolean removed = resource.delete();
if (!removed) {
throw new RestException("Resource '" + resource.path() + "' not removed", HttpStatus.INTERNAL_SERVER_ERROR);
}
}

/**
* Verifies mime type and use {@link RESTUtil
* @param directory
Expand Down

0 comments on commit 9f6cd61

Please sign in to comment.