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

Merge Zip files development into main #1848

Merged
merged 26 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3906df1
Bxc 4673 zip file controller (#1786)
sharonluong Aug 20, 2024
1b6d998
BXC-4684 add download zip button (#1788)
sharonluong Aug 20, 2024
694ecb3
Merge branch 'main' into zip-files-development
sharonluong Sep 11, 2024
34a10c7
Merge branch 'main' into zip-files-development
sharonluong Sep 19, 2024
07e7107
Merge branch 'main' into zip-files-development-merge1
bbpennel Oct 10, 2024
a6f0249
Merge pull request #1811 from UNC-Libraries/zip-files-development-merge1
sharonluong Oct 10, 2024
e63dbef
BXC-4736 handle non file member objects (#1819)
sharonluong Oct 16, 2024
c6410d7
Move zip download button (#1816)
lfarrell Oct 21, 2024
18db8be
Add a total file size warning to work level zip download (#1822)
lfarrell Oct 22, 2024
7818823
Merge branch 'main' into zip-files-development
bbpennel Oct 29, 2024
addae76
Merge branch 'main' into zip-files-development
bbpennel Oct 31, 2024
597f5b0
Add a jump to download button (#1827)
lfarrell Nov 1, 2024
00066d1
Bxc 4771 upper file limit (#1835)
sharonluong Nov 19, 2024
5c7ac30
BXC-4771 simplify loop (#1836)
sharonluong Nov 19, 2024
3984c4e
BXC-4796 - Limit bulk download access (#1838)
bbpennel Nov 27, 2024
c5815a9
BXC-4794 - Too many files for bulk download (#1841)
bbpennel Dec 2, 2024
79ab08a
Merge branch 'main' into zip-files-development
bbpennel Dec 2, 2024
978ded0
Fix merge of changes in restricted content into object actions
bbpennel Dec 2, 2024
3426837
Fixed bug when format field not present on brief record, which is alw…
bbpennel Dec 3, 2024
0a6b4c9
Only allow view button on files
bbpennel Dec 3, 2024
e46e61e
Fixes to spacing of restricted content sections
bbpennel Dec 3, 2024
a3f2ff2
Merge main into Zip files development (#1845)
bbpennel Dec 3, 2024
6691fdc
Revert "Merge main into Zip files development (#1845)"
bbpennel Dec 3, 2024
69f3fa8
Merge pull request #1846 from UNC-Libraries/revert-1845-zip-files-dev…
bbpennel Dec 3, 2024
a09ea1f
Merge pull request #1847 from UNC-Libraries/zip-files-development-merge
bbpennel Dec 3, 2024
2077a63
Re-delete deleted files. Fix click event bubble issue with download b…
bbpennel Dec 4, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mvn -pl '!clamav-java' verify
### Running JavaScript tests
```
# JavaScript Tests
npm --prefix static/js/admin/vue-permissions-editor run test
npm --prefix static/js/admin/vue-cdr-admin run test
npm --prefix static/js/vue-cdr-access run test
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class AccessPrincipalConstants {
public final static String PATRON_NAMESPACE = "unc:patron:";
public final static String IP_PRINC_NAMESPACE = PATRON_NAMESPACE + "ipp:";
public final static String ADMIN_ACCESS_PRINC = "admin_access";
public final static String ON_CAMPUS_PRINC = "unc:patron:ipp:on_campus";

public final static Pattern PATRON_PRINC_PATTERN =
Pattern.compile("(" + PUBLIC_PRINC
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package edu.unc.lib.boxc.operations.impl.download;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import edu.unc.lib.boxc.auth.api.models.AccessGroupSet;
import edu.unc.lib.boxc.auth.api.models.AgentPrincipals;
import edu.unc.lib.boxc.auth.fcrepo.models.AgentPrincipalsImpl;

public class DownloadBulkRequest {
private String workPidString;
@JsonDeserialize(as = AgentPrincipalsImpl.class)
private AgentPrincipals agent;
private AccessGroupSet principals;

public DownloadBulkRequest(String workPidString, AgentPrincipals agent) {
public DownloadBulkRequest(String workPidString, AccessGroupSet principals) {
this.workPidString = workPidString;
this.agent = agent;
this.principals = principals;
}

public String getWorkPidString() {
Expand All @@ -22,11 +22,11 @@ public void setWorkPidString(String workPidString) {
this.workPidString = workPidString;
}

public AgentPrincipals getAgent() {
return agent;
public AccessGroupSet getPrincipals() {
return principals;
}

public void setAgent(AgentPrincipals agent) {
this.agent = agent;
public void setPrincipals(AccessGroupSet principals) {
this.principals = principals;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import edu.unc.lib.boxc.auth.api.models.AccessGroupSet;
import edu.unc.lib.boxc.auth.api.services.AccessControlService;
import edu.unc.lib.boxc.fcrepo.exceptions.ServiceException;
import edu.unc.lib.boxc.model.api.exceptions.NotFoundException;
import edu.unc.lib.boxc.model.api.objects.ContentObject;
import edu.unc.lib.boxc.model.api.objects.FileObject;
import edu.unc.lib.boxc.model.api.objects.RepositoryObjectLoader;
Expand All @@ -29,11 +28,12 @@ public class DownloadBulkService {
private AccessControlService aclService;
private RepositoryObjectLoader repoObjLoader;
private Path basePath;
private int fileLimit;

public Path downloadBulk(DownloadBulkRequest request) {
var pidString = request.getWorkPidString();
var workPid = PIDs.get(pidString);
var agentPrincipals = request.getAgent().getPrincipals();
var agentPrincipals = request.getPrincipals();
aclService.assertHasAccess(
"User does not have permissions to view the Work for download",
workPid, agentPrincipals, Permission.viewOriginal);
Expand Down Expand Up @@ -61,7 +61,14 @@ private void zipFiles(WorkObject workObject, AccessGroupSet agentPrincipals, Pat
}

Map<String, Integer> duplicates = new HashMap<>();
int count = 0;
for (ContentObject memberObject : memberObjects ) {
if (count == fileLimit) {
break;
}
if (!(memberObject instanceof FileObject)) {
continue;
}
var fileObject = (FileObject) memberObject;
if (aclService.hasAccess(memberObject.getPid(), agentPrincipals, Permission.viewOriginal)) {
var binObj = fileObject.getOriginalFile();
Expand All @@ -82,6 +89,7 @@ private void zipFiles(WorkObject workObject, AccessGroupSet agentPrincipals, Pat

IOUtils.copy(binaryStream, zipOut);
}
count++;
}
}
}
Expand Down Expand Up @@ -111,4 +119,8 @@ public void setRepoObjLoader(RepositoryObjectLoader repoObjLoader) {
public void setBasePath(Path basePath) {
this.basePath = basePath;
}

public void setFileLimit(int fileLimit) {
this.fileLimit = fileLimit;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import edu.unc.lib.boxc.auth.api.models.AccessGroupSet;
import edu.unc.lib.boxc.auth.api.models.AgentPrincipals;
import edu.unc.lib.boxc.auth.api.services.AccessControlService;
import edu.unc.lib.boxc.model.api.exceptions.NotFoundException;
import edu.unc.lib.boxc.model.api.exceptions.ObjectTypeMismatchException;
import edu.unc.lib.boxc.model.api.ids.PID;
import edu.unc.lib.boxc.model.api.objects.BinaryObject;
import edu.unc.lib.boxc.model.api.objects.FileObject;
import edu.unc.lib.boxc.model.api.objects.RepositoryObjectLoader;
import edu.unc.lib.boxc.model.api.objects.Tombstone;
import edu.unc.lib.boxc.model.api.objects.WorkObject;
import edu.unc.lib.boxc.model.fcrepo.ids.PIDs;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -64,6 +64,8 @@ public class DownloadBulkServiceTest {
private WorkObject parentWork;
@Mock
private FileObject fileObject1, fileObject2;
@Mock
private Tombstone tombstone;
@TempDir
public Path zipStorageBasePath;

Expand All @@ -75,10 +77,11 @@ public void init() throws Exception {
service.setAclService(aclService);
service.setRepoObjLoader(repoObjLoader);
service.setBasePath(zipStorageBasePath);
service.setFileLimit(5);
parentPid = PIDs.get(PARENT_UUID);
fileObject1Pid = PIDs.get(CHILD1_UUID);
fileObject2Pid = PIDs.get(CHILD2_UUID);
request = new DownloadBulkRequest(PARENT_UUID, mockAgent);
request = new DownloadBulkRequest(PARENT_UUID, mockAccessSet);

when(mockAgent.getUsername()).thenReturn("user");
when(mockAgent.getPrincipals()).thenReturn(mockAccessSet);
Expand Down Expand Up @@ -154,6 +157,31 @@ public void noOriginalFilesTest() throws IOException {
assertZipFiles(List.of(), List.of());
}

@Test
public void tombstoneTest() throws IOException {
when(repoObjLoader.getWorkObject(eq(parentPid))).thenReturn(parentWork);
when(parentWork.getMembers()).thenReturn(List.of(tombstone));
service.downloadBulk(request);
// the zip file should be empty
assertZipFiles(List.of(), List.of());
}

@Test
public void fileLimitTest() throws IOException {
when(repoObjLoader.getWorkObject(any(PID.class))).thenReturn(parentWork);
when(parentWork.getMembers()).thenReturn(List.of(fileObject1, fileObject2));
makeBinaryObject(fileObject1, FILENAME1);
makeBinaryObject(fileObject2, FILENAME2);
when(aclService.hasAccess(eq(fileObject1Pid), any(),
eq(Permission.viewOriginal))).thenReturn(true);
when(aclService.hasAccess(eq(fileObject2Pid), any(),
eq(Permission.viewOriginal))).thenReturn(true);
service.setFileLimit(1);
service.downloadBulk(request);
// the zip file should have one entry
assertZipFiles(List.of(FILENAME1), List.of("flower"));
}

@Test
public void successTest() throws IOException {
when(repoObjLoader.getWorkObject(eq(parentPid))).thenReturn(parentWork);
Expand Down
1 change: 0 additions & 1 deletion static/css/cdrui_styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
.thumbnail {
display: block;
position:relative;
float: left;
margin: 0 0 20px 0;
text-align: center;
object-fit: contain;
Expand Down
66 changes: 32 additions & 34 deletions static/css/sass/cdr_ui_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ $box-shadow: inset 3px 3px 10px -1px $box-shadow-color, 0px 16px 22px -15px $box
*
**/
.search-query-text {
margin: 40px 20px 40px 25px;
margin: 40px 20px 20px 25px;
font-size: 24px;

h2 {
Expand All @@ -147,13 +147,6 @@ form.search {
}
}

.browse-search {
.button.is-focused,
.button:focus {
color: #363636;
}
}

a.search-result-num {
background-color: $container-blue;
color: white !important;
Expand Down Expand Up @@ -420,11 +413,7 @@ p.no-search-results {

#child-files_filter {
margin-bottom: 25px;

label {
float: right;
width: 250px;
}
margin-top: -50px;
}

.input::placeholder, .input {
Expand All @@ -439,14 +428,19 @@ img.data-thumb {
max-width: 60px;
}

.child-records {
font-size: 16px;
margin: 30px 50px 25px 50px;
.file-list-header {
margin: 30px 0 5px;

h3 {
font-size: 16px;
margin-bottom: 30px;
margin: 0;
padding: 0;
}
}

.child-records {
font-size: 16px;
overflow: visible;

.fa.default-img-icon {
font-size: 32px;
Expand All @@ -459,14 +453,6 @@ img.data-thumb {
}
}

.is-icon {
background-color: $container-blue;
border: 1px solid $container-blue;
border-radius: 5px;
color: white;
padding: 7px;
}

.no-download {
background-color: #B8B8B8;
border-color: #B8B8B8;
Expand Down Expand Up @@ -614,7 +600,6 @@ img.data-thumb {

.full_record_top {
border-bottom: 1px solid $light-gray;
padding-bottom: 25px;

.collinfo {
width: 100%;
Expand Down Expand Up @@ -719,7 +704,7 @@ table.dataTable {
.actionlink {
a.action {
font-size: 16px;
padding: 15px 15px 30px 15px;
padding: 15px;
}
}
}
Expand All @@ -729,7 +714,6 @@ table.dataTable {
.restricted-access {
border: 1px solid;
border-radius: 5px;
padding: 15px;

.button {
text-align: left;
Expand Down Expand Up @@ -827,11 +811,6 @@ table.dataTable {
margin-bottom: 10px;
}

.button.is-focused,
.button:focus {
color: white;
}

/* MODs display for work and file pages, plus modalMetadata.vue component */
#mods_data_display {
margin: auto;
Expand Down Expand Up @@ -905,6 +884,21 @@ table.dataTable {
display: inline-flex;
}

.button.is-link.is-hovered,
.button.is-link:hover {
background-color: #276cda;
border-color: transparent;
color: #fff;
}

.navbar-link.is-active,
.navbar-link:hover,
a.navbar-item.is-active,
a.navbar-item:hover {
background-color: #fafafa;
color: #3273dc;
}

/*** End of Bulma overrides ***/

/* Following Bulma breakpoints */
Expand Down Expand Up @@ -1042,6 +1036,10 @@ table.dataTable {
}
}

#child-files_filter {
margin-top: -25px;
}

.dataTables_wrapper {
.dataTables_filter {
float: left !important;
Expand Down Expand Up @@ -1143,7 +1141,7 @@ iframe {

.clover-viewer {
margin: auto;
width: 90%;
width: 95%;
}

#information-toggle {
Expand Down
2 changes: 1 addition & 1 deletion static/js/vue-cdr-access/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/versions/bulma-no-dark-mode.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css">
<link rel="stylesheet" type="text/css" href="/static/css/cdr_access.css" />

Expand Down
Loading
Loading