Skip to content

Commit

Permalink
#194 - Support for Deep Linking of Documents
Browse files Browse the repository at this point in the history
  • Loading branch information
mfriesen committed Nov 28, 2023
1 parent afbfae0 commit 1c6e797
Show file tree
Hide file tree
Showing 29 changed files with 767 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public interface DocumentItem {
*/
String getContentType();

/**
* Get Deep Link Path.
*
* @return {@link String}
*/
String getDeepLinkPath();

/**
* Get Document Id.
*
Expand Down Expand Up @@ -163,6 +170,13 @@ public interface DocumentItem {
*/
void setContentType(String ct);

/**
* Deep Link Path.
*
* @param deepLinkPath {@link String}
*/
void setDeepLinkPath(String deepLinkPath);

/**
* Set Document ID.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class DocumentMapToDocument

/** Fields to Process. */
private static final List<String> FIELDS =
Arrays.asList("documentId", "path", "content", "contentType");
Arrays.asList("documentId", "path", "content", "contentType", "deepLinkPath");

@SuppressWarnings("unchecked")
private String getValue(final Object obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public String getContentType() {
return getString("contentType");
}

@Override
public String getDeepLinkPath() {
return getString("deepLinkPath");
}

@Override
public String getDocumentId() {
return getString("documentId");
Expand Down Expand Up @@ -164,6 +169,11 @@ public void setContentType(final String contentType) {
put("contentType", contentType);
}

@Override
public void setDeepLinkPath(final String deepLinkPath) {
put("deepLinkPath", deepLinkPath);
}

@Override
public void setDocumentId(final String documentId) {
put("documentId", documentId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
package com.formkiq.aws.dynamodb.objects;

import java.net.URI;
import java.net.URISyntaxException;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -119,8 +121,24 @@ public static String getExtension(final String filename) {
* @return {@link String}
*/
public static String getFilename(final String path) {
int pos = path.lastIndexOf("/");
String name = pos > -1 ? path.substring(pos + 1) : path;

String name = getUri(path);
int pos = name.lastIndexOf("/");
name = pos > -1 ? name.substring(pos + 1) : name;
return name;
}

private static String getUri(final String path) {

String name = null;

try {
URI u = new URI(path);
name = u.getPath();
} catch (URISyntaxException e) {
name = path;
}

return name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ void testFilename() {
assertEquals("test.txt", Strings.getFilename("/bleh/something/test.txt"));
assertEquals("test (something).txt",
Strings.getFilename("/bleh/something/test (something).txt"));
assertEquals("", Strings.getFilename("http://www.google.com"));
assertEquals("something.pdf", Strings.getFilename("http://www.google.com/asd/something.pdf"));
}

@Test
Expand Down
36 changes: 36 additions & 0 deletions docs/openapi/openapi-iam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3942,6 +3942,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -3987,6 +3990,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4164,6 +4170,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
tags:
type: array
description: List of document tags
Expand All @@ -4185,6 +4194,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
contentType:
type: string
description: Document media type
Expand Down Expand Up @@ -4367,6 +4379,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
contentType:
type: string
description: Document Content-Type
Expand All @@ -4392,6 +4407,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4529,6 +4547,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4558,6 +4579,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4668,6 +4692,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4729,6 +4756,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4996,6 +5026,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
tags:
type: array
description: List of document tags
Expand Down Expand Up @@ -5023,6 +5056,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
tags:
type: array
description: List of document tags
Expand Down
36 changes: 36 additions & 0 deletions docs/openapi/openapi-jwt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3942,6 +3942,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -3987,6 +3990,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4164,6 +4170,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
tags:
type: array
description: List of document tags
Expand All @@ -4185,6 +4194,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
contentType:
type: string
description: Document media type
Expand Down Expand Up @@ -4367,6 +4379,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
contentType:
type: string
description: Document Content-Type
Expand All @@ -4392,6 +4407,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4529,6 +4547,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4558,6 +4579,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4668,6 +4692,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4729,6 +4756,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
insertedDate:
type: string
description: Inserted Timestamp
Expand Down Expand Up @@ -4996,6 +5026,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
tags:
type: array
description: List of document tags
Expand Down Expand Up @@ -5023,6 +5056,9 @@
path:
type: string
description: Path or Name of document
deepLinkPath:
type: string
description: Path or Name of deep link
tags:
type: array
description: List of document tags
Expand Down
Loading

0 comments on commit 1c6e797

Please sign in to comment.