Skip to content

Commit

Permalink
#251 - Add default content type for Google Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mfriesen committed Jul 30, 2024
1 parent 10f5416 commit b711ead
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2134,8 +2134,15 @@ private void updateCurrentChecksumFromPrevious(final DocumentItem document,

private void updateDeepLinkPath(final Map<String, AttributeValue> pkvalues,
final DocumentItem document) {

if (!isEmpty(document.getDeepLinkPath())) {
addS(pkvalues, "deepLinkPath", document.getDeepLinkPath());

if (document.getDeepLinkPath().startsWith("https://docs.google.com/document")
&& isEmpty(document.getContentType())) {
document.setContentType("application/vnd.google-apps.document");
}

} else {
addS(pkvalues, "deepLinkPath", "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,13 @@ public void testPost09() throws ApiException {
/**
* Save new File with invaliddocumentId.
*
* @throws ApiException ApiException
*/
@Test
public void testPost10() throws ApiException {
public void testPost10() {
// given
for (String siteId : Arrays.asList(null, UUID.randomUUID().toString())) {

String documentId = "casaljdalsdjat" + UUID.randomUUID().toString();
String documentId = "casaljdalsdjat" + UUID.randomUUID();
setBearerToken(siteId);

AddDocumentRequest req = new AddDocumentRequest().documentId(documentId).content("dummy data")
Expand All @@ -446,6 +445,40 @@ public void testPost10() throws ApiException {
}
}

/**
* Save google drive deep link.
*
*/
@Test
public void testPost11() throws ApiException {
// given
for (String siteId : Arrays.asList("default", UUID.randomUUID().toString())) {

setBearerToken(siteId);

String deepLink = "https://docs.google.com/document/d/1tyOQ3yUL9dtpbuMOt7s/edit?usp=sharing";

AddDocumentRequest req = new AddDocumentRequest().deepLinkPath(deepLink);

// when
String documentId = this.documentsApi.addDocument(req, null, null).getDocumentId();

// then
GetDocumentResponse doc = this.documentsApi.getDocument(documentId, siteId, null);
assertEquals("application/vnd.google-apps.document", doc.getContentType());

// given
req.setContentType("application/pdf");

// when
documentId = this.documentsApi.addDocument(req, null, null).getDocumentId();

// then
doc = this.documentsApi.getDocument(documentId, siteId, null);
assertEquals("application/pdf", doc.getContentType());
}
}

/**
* Test Publish no published document.
*
Expand Down

0 comments on commit b711ead

Please sign in to comment.