Skip to content

Commit

Permalink
Updated delete resource API request type from POST to DELETE (#668)
Browse files Browse the repository at this point in the history
Signed-off-by: shiv12095 <[email protected]>
  • Loading branch information
shiv12095 authored and aedelmann committed Jun 30, 2017
1 parent 93d74fb commit a76addb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 43 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.eclipse.vorto.devtool.projectrepository.file.ProjectRepositoryFileConstants;
import org.eclipse.vorto.devtool.projectrepository.model.ProjectResource;
import org.eclipse.vorto.devtool.projectrepository.model.Resource;
import org.eclipse.vorto.server.devtool.http.request.DeleteResourceRequest;
import org.eclipse.vorto.server.devtool.http.response.Response;
import org.eclipse.vorto.server.devtool.models.ModelResource;
import org.eclipse.vorto.server.devtool.service.IEditorSession;
Expand Down Expand Up @@ -177,18 +176,20 @@ public Resource openProject(
}

@ApiOperation(value = "Deletes a resource from the project")
@RequestMapping(value = "/{projectName}/delete", method = RequestMethod.POST)
public void deleteResource(@RequestBody DeleteResourceRequest deleteResourceRequest,
@RequestMapping(value = "/{projectName}/{resourceId:.+}", method = RequestMethod.DELETE)
public void deleteResource(
@ApiParam(value = "ProjectName", required = true) @PathVariable String projectName,
@ApiParam(value = "resourceId", required = true) @PathVariable String resourceId,
@ApiParam(value = "Request", required = true) final HttpServletRequest request) {

Objects.requireNonNull(projectName, "projectName must not be null");

Objects.requireNonNull(resourceId, "resourceId must not be null");

projectName = webUtils.getUserProjectName(projectName);
ResourceSet resourceSet = webUtils.getResourceSet(request);
devtoolReferenceLinker.removeResourceFromResourceSet(deleteResourceRequest.getResourceId(), resourceSet);
projectService.deleteResource(projectName, deleteResourceRequest.getResourceId());
webUtils.removeDeletedModelFromSessionAttributes(request, deleteResourceRequest.getResourceId());
devtoolReferenceLinker.removeResourceFromResourceSet(resourceId, resourceSet);
projectService.deleteResource(projectName, resourceId);
webUtils.removeDeletedModelFromSessionAttributes(request, resourceId);
}

@ApiOperation(value = "Deletes a resource from the project")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ define(["../../init/AppService"], function(services) {

function deleteProjectResource(params) {
var projectName = params.projectName;
var url = "./rest/project/" + projectName + "/delete";
return $http.post(url, params).then(httpCallSuccess).catch(httpCallFailure);
var resourceId = params.resourceId;
var url = "./rest/project/" + projectName + "/" + resourceId;
return $http.delete(url).then(httpCallSuccess).catch(httpCallFailure);
}

function httpCallSuccess(response) {
Expand Down

0 comments on commit a76addb

Please sign in to comment.