-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Story/GECO-140: Adding deletion endpoint to the V2 API #114
Open
diya17
wants to merge
31
commits into
story/GECO-139
Choose a base branch
from
story/GECO-140
base: story/GECO-139
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
da57832
[GECO-140] Adding new delete document controller to the v2 API
diya17 7e07f0e
[GECO-140] Making changes to the controller endpoint response and add…
diya17 354661a
Merge branch 'story/GECO-139' into story/GECO-140
diya17 1dc8fcb
[GECO-140] : Addressing review comments
diya17 8fed293
[GECO-140] Changing the status for the deletion endpoint and adding a…
diya17 1235a6b
[GECO-140] Adding javadocs and test case changes
diya17 5b0ccf3
[GECO-140] Adding and fixing tests
diya17 6c4d733
Merge branch 'story/GECO-139' into story/GECO-140
diya17 6c74ab9
[GECO-140] Removing generateUnauthorizedUserResponse from userHelper
diya17 f9e9772
[GECO-140] Refactoring code and and testcases
diya17 617a099
Merge branch 'story/GECO-139' into story/GECO-140
diya17 e515ac6
[GECO-140] Making changes to check user access using citesphere
diya17 b1013f7
Merge branch 'story/GECO-139' into story/GECO-140
diya17 93f7d13
[GECO-140] Final changes after using citesphere connector
diya17 753ad10
[GECO-140] Changing Giles Deletion API and also saving Processing req…
diya17 5a472cd
[GECO-140] Changes to API and processing requests
diya17 bc32897
[GECO-140] Adding storage deletion request to orm.xml
diya17 0379d09
[GECO-140] Setting request status for storage deletion in processing …
diya17 ebcdfd1
[GECO-140] Deleting requests for document initial commit
diya17 1001a55
[GECO-140] Deleting requests
diya17 8b50bf9
[GECO-140] Modifying request client to use spring data and modifying …
diya17 4ea57f2
Merge branch 'story/GECO-139' into story/GECO-140
diya17 984f9f5
Fix path to jsp
jdamerow da5e90c
undo change
jdamerow 5403214
Merge branch 'story/GECO-139' into story/GECO-140
diya17 5fc31a9
Merge branch 'story/GECO-139' into story/GECO-140
diya17 0a37341
Merge branch 'develop' into story/GECO-140
diya17 bb4d6a2
Update delete document service
diya17 8e2d05e
[GECO-140] Update kafka
diya17 78f7f38
[GECO-140] : Update deletion completion
diya17 9736973
[GECO-140] Removing unused files
diya17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...co/src/main/java/edu/asu/diging/gilesecosystem/web/api/v2/V2DeleteDocumentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package edu.asu.diging.gilesecosystem.web.api.v2; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
import edu.asu.diging.gilesecosystem.web.core.model.IDocument; | ||
import edu.asu.diging.gilesecosystem.web.core.service.core.ITransactionalDocumentService; | ||
import edu.asu.diging.gilesecosystem.web.core.service.delete.IDeleteDocumentService; | ||
|
||
@Controller | ||
public class V2DeleteDocumentController { | ||
|
||
@Autowired | ||
private IDeleteDocumentService deleteDocumentService; | ||
|
||
@Autowired | ||
private ITransactionalDocumentService documentService; | ||
|
||
@RequestMapping(value = "/api/v2/resources/documents/{documentId}", method = RequestMethod.DELETE, produces = "application/json;charset=UTF-8") | ||
public ResponseEntity<String> deleteDocument(@PathVariable("documentId") String documentId) { | ||
IDocument document = documentService.getDocument(documentId); | ||
if (document == null) { | ||
return new ResponseEntity<String>(HttpStatus.NOT_FOUND); | ||
} | ||
deleteDocumentService.deleteDocument(document); | ||
return new ResponseEntity<String>(HttpStatus.ACCEPTED); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...rc/test/java/edu/asu/diging/gilesecosystem/web/api/v2/V2DeleteDocumentControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package edu.asu.diging.gilesecosystem.web.api.v2; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import edu.asu.diging.gilesecosystem.web.core.model.DocumentAccess; | ||
import edu.asu.diging.gilesecosystem.web.core.model.IDocument; | ||
import edu.asu.diging.gilesecosystem.web.core.model.impl.Document; | ||
import edu.asu.diging.gilesecosystem.web.core.service.core.ITransactionalDocumentService; | ||
import edu.asu.diging.gilesecosystem.web.core.service.delete.IDeleteDocumentService; | ||
|
||
public class V2DeleteDocumentControllerTest { | ||
|
||
@Mock | ||
private IDeleteDocumentService deleteDocumentService; | ||
|
||
@Mock | ||
private ITransactionalDocumentService documentService; | ||
|
||
@InjectMocks | ||
private V2DeleteDocumentController v2DeleteDocumentController; | ||
|
||
private String DOCUMENT_ID = "documentId"; | ||
private DocumentAccess access = DocumentAccess.PRIVATE; | ||
private String FILE_ID = "fileId"; | ||
private String UPLOAD_ID = "uploadId"; | ||
IDocument document; | ||
|
||
@Before | ||
public void setUp() { | ||
document = createDocument(); | ||
v2DeleteDocumentController = new V2DeleteDocumentController(); | ||
MockitoAnnotations.initMocks(this); | ||
} | ||
|
||
@Test | ||
public void test_deleteDocument_success() { | ||
Mockito.when(documentService.getDocument(DOCUMENT_ID)).thenReturn(document); | ||
ResponseEntity<String> response = v2DeleteDocumentController.deleteDocument(DOCUMENT_ID); | ||
Assert.assertEquals(HttpStatus.ACCEPTED, response.getStatusCode()); | ||
} | ||
|
||
@Test | ||
public void test_deleteDocument_notFound() { | ||
Mockito.when(documentService.getDocument(DOCUMENT_ID)).thenReturn(null); | ||
ResponseEntity<String> response = v2DeleteDocumentController.deleteDocument(DOCUMENT_ID); | ||
Assert.assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); | ||
} | ||
|
||
private Document createDocument() { | ||
Document document = new Document(); | ||
document.setId(DOCUMENT_ID); | ||
document.setAccess(access); | ||
document.setFileIds(Arrays.asList(FILE_ID)); | ||
document.setUploadId(UPLOAD_ID); | ||
document.setUploadedFileId(FILE_ID); | ||
return document; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that should return an ok status and a url to poll to get the status of the deletion process.