Skip to content
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
wants to merge 31 commits into
base: story/GECO-139
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Mar 10, 2023
7e07f0e
[GECO-140] Making changes to the controller endpoint response and add…
diya17 Mar 16, 2023
354661a
Merge branch 'story/GECO-139' into story/GECO-140
diya17 May 26, 2023
1dc8fcb
[GECO-140] : Addressing review comments
diya17 May 27, 2023
8fed293
[GECO-140] Changing the status for the deletion endpoint and adding a…
diya17 May 30, 2023
1235a6b
[GECO-140] Adding javadocs and test case changes
diya17 May 30, 2023
5b0ccf3
[GECO-140] Adding and fixing tests
diya17 Jun 1, 2023
6c4d733
Merge branch 'story/GECO-139' into story/GECO-140
diya17 Jun 15, 2023
6c74ab9
[GECO-140] Removing generateUnauthorizedUserResponse from userHelper
diya17 Jun 15, 2023
f9e9772
[GECO-140] Refactoring code and and testcases
diya17 Jun 23, 2023
617a099
Merge branch 'story/GECO-139' into story/GECO-140
diya17 Jun 26, 2023
e515ac6
[GECO-140] Making changes to check user access using citesphere
diya17 Jun 30, 2023
b1013f7
Merge branch 'story/GECO-139' into story/GECO-140
diya17 Jun 30, 2023
93f7d13
[GECO-140] Final changes after using citesphere connector
diya17 Jul 3, 2023
753ad10
[GECO-140] Changing Giles Deletion API and also saving Processing req…
diya17 Jul 25, 2023
5a472cd
[GECO-140] Changes to API and processing requests
diya17 Jul 28, 2023
bc32897
[GECO-140] Adding storage deletion request to orm.xml
diya17 Aug 1, 2023
0379d09
[GECO-140] Setting request status for storage deletion in processing …
diya17 Aug 1, 2023
ebcdfd1
[GECO-140] Deleting requests for document initial commit
diya17 Aug 2, 2023
1001a55
[GECO-140] Deleting requests
diya17 Aug 4, 2023
8b50bf9
[GECO-140] Modifying request client to use spring data and modifying …
diya17 Aug 7, 2023
4ea57f2
Merge branch 'story/GECO-139' into story/GECO-140
diya17 Sep 22, 2023
984f9f5
Fix path to jsp
jdamerow Mar 29, 2024
da5e90c
undo change
jdamerow Mar 29, 2024
5403214
Merge branch 'story/GECO-139' into story/GECO-140
diya17 Apr 10, 2024
5fc31a9
Merge branch 'story/GECO-139' into story/GECO-140
diya17 Apr 10, 2024
0a37341
Merge branch 'develop' into story/GECO-140
diya17 Apr 10, 2024
bb4d6a2
Update delete document service
diya17 Apr 12, 2024
8e2d05e
[GECO-140] Update kafka
diya17 Apr 12, 2024
78f7f38
[GECO-140] : Update deletion completion
diya17 Apr 12, 2024
9736973
[GECO-140] Removing unused files
diya17 Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

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.

}
}
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;
}
}