Skip to content

Commit c177bb7

Browse files
authored
Merge pull request #1848 from UNC-Libraries/zip-files-development
Merge Zip files development into main
2 parents c722d36 + 2077a63 commit c177bb7

File tree

45 files changed

+1123
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1123
-346
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mvn -pl '!clamav-java' verify
8585
### Running JavaScript tests
8686
```
8787
# JavaScript Tests
88-
npm --prefix static/js/admin/vue-permissions-editor run test
88+
npm --prefix static/js/admin/vue-cdr-admin run test
8989
npm --prefix static/js/vue-cdr-access run test
9090
```
9191

auth-api/src/main/java/edu/unc/lib/boxc/auth/api/AccessPrincipalConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class AccessPrincipalConstants {
2323
public final static String PATRON_NAMESPACE = "unc:patron:";
2424
public final static String IP_PRINC_NAMESPACE = PATRON_NAMESPACE + "ipp:";
2525
public final static String ADMIN_ACCESS_PRINC = "admin_access";
26+
public final static String ON_CAMPUS_PRINC = "unc:patron:ipp:on_campus";
2627

2728
public final static Pattern PATRON_PRINC_PATTERN =
2829
Pattern.compile("(" + PUBLIC_PRINC
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package edu.unc.lib.boxc.operations.impl.download;
22

33
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
4+
import edu.unc.lib.boxc.auth.api.models.AccessGroupSet;
45
import edu.unc.lib.boxc.auth.api.models.AgentPrincipals;
56
import edu.unc.lib.boxc.auth.fcrepo.models.AgentPrincipalsImpl;
67

78
public class DownloadBulkRequest {
89
private String workPidString;
9-
@JsonDeserialize(as = AgentPrincipalsImpl.class)
10-
private AgentPrincipals agent;
10+
private AccessGroupSet principals;
1111

12-
public DownloadBulkRequest(String workPidString, AgentPrincipals agent) {
12+
public DownloadBulkRequest(String workPidString, AccessGroupSet principals) {
1313
this.workPidString = workPidString;
14-
this.agent = agent;
14+
this.principals = principals;
1515
}
1616

1717
public String getWorkPidString() {
@@ -22,11 +22,11 @@ public void setWorkPidString(String workPidString) {
2222
this.workPidString = workPidString;
2323
}
2424

25-
public AgentPrincipals getAgent() {
26-
return agent;
25+
public AccessGroupSet getPrincipals() {
26+
return principals;
2727
}
2828

29-
public void setAgent(AgentPrincipals agent) {
30-
this.agent = agent;
29+
public void setPrincipals(AccessGroupSet principals) {
30+
this.principals = principals;
3131
}
3232
}

operations/src/main/java/edu/unc/lib/boxc/operations/impl/download/DownloadBulkService.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import edu.unc.lib.boxc.auth.api.models.AccessGroupSet;
55
import edu.unc.lib.boxc.auth.api.services.AccessControlService;
66
import edu.unc.lib.boxc.fcrepo.exceptions.ServiceException;
7-
import edu.unc.lib.boxc.model.api.exceptions.NotFoundException;
87
import edu.unc.lib.boxc.model.api.objects.ContentObject;
98
import edu.unc.lib.boxc.model.api.objects.FileObject;
109
import edu.unc.lib.boxc.model.api.objects.RepositoryObjectLoader;
@@ -29,11 +28,12 @@ public class DownloadBulkService {
2928
private AccessControlService aclService;
3029
private RepositoryObjectLoader repoObjLoader;
3130
private Path basePath;
31+
private int fileLimit;
3232

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

6363
Map<String, Integer> duplicates = new HashMap<>();
64+
int count = 0;
6465
for (ContentObject memberObject : memberObjects ) {
66+
if (count == fileLimit) {
67+
break;
68+
}
69+
if (!(memberObject instanceof FileObject)) {
70+
continue;
71+
}
6572
var fileObject = (FileObject) memberObject;
6673
if (aclService.hasAccess(memberObject.getPid(), agentPrincipals, Permission.viewOriginal)) {
6774
var binObj = fileObject.getOriginalFile();
@@ -82,6 +89,7 @@ private void zipFiles(WorkObject workObject, AccessGroupSet agentPrincipals, Pat
8289

8390
IOUtils.copy(binaryStream, zipOut);
8491
}
92+
count++;
8593
}
8694
}
8795
}
@@ -111,4 +119,8 @@ public void setRepoObjLoader(RepositoryObjectLoader repoObjLoader) {
111119
public void setBasePath(Path basePath) {
112120
this.basePath = basePath;
113121
}
122+
123+
public void setFileLimit(int fileLimit) {
124+
this.fileLimit = fileLimit;
125+
}
114126
}

operations/src/test/java/edu/unc/lib/boxc/operations/impl/download/DownloadBulkServiceTest.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import edu.unc.lib.boxc.auth.api.models.AccessGroupSet;
66
import edu.unc.lib.boxc.auth.api.models.AgentPrincipals;
77
import edu.unc.lib.boxc.auth.api.services.AccessControlService;
8-
import edu.unc.lib.boxc.model.api.exceptions.NotFoundException;
98
import edu.unc.lib.boxc.model.api.exceptions.ObjectTypeMismatchException;
109
import edu.unc.lib.boxc.model.api.ids.PID;
1110
import edu.unc.lib.boxc.model.api.objects.BinaryObject;
1211
import edu.unc.lib.boxc.model.api.objects.FileObject;
1312
import edu.unc.lib.boxc.model.api.objects.RepositoryObjectLoader;
13+
import edu.unc.lib.boxc.model.api.objects.Tombstone;
1414
import edu.unc.lib.boxc.model.api.objects.WorkObject;
1515
import edu.unc.lib.boxc.model.fcrepo.ids.PIDs;
1616
import org.apache.commons.io.IOUtils;
@@ -64,6 +64,8 @@ public class DownloadBulkServiceTest {
6464
private WorkObject parentWork;
6565
@Mock
6666
private FileObject fileObject1, fileObject2;
67+
@Mock
68+
private Tombstone tombstone;
6769
@TempDir
6870
public Path zipStorageBasePath;
6971

@@ -75,10 +77,11 @@ public void init() throws Exception {
7577
service.setAclService(aclService);
7678
service.setRepoObjLoader(repoObjLoader);
7779
service.setBasePath(zipStorageBasePath);
80+
service.setFileLimit(5);
7881
parentPid = PIDs.get(PARENT_UUID);
7982
fileObject1Pid = PIDs.get(CHILD1_UUID);
8083
fileObject2Pid = PIDs.get(CHILD2_UUID);
81-
request = new DownloadBulkRequest(PARENT_UUID, mockAgent);
84+
request = new DownloadBulkRequest(PARENT_UUID, mockAccessSet);
8285

8386
when(mockAgent.getUsername()).thenReturn("user");
8487
when(mockAgent.getPrincipals()).thenReturn(mockAccessSet);
@@ -154,6 +157,31 @@ public void noOriginalFilesTest() throws IOException {
154157
assertZipFiles(List.of(), List.of());
155158
}
156159

160+
@Test
161+
public void tombstoneTest() throws IOException {
162+
when(repoObjLoader.getWorkObject(eq(parentPid))).thenReturn(parentWork);
163+
when(parentWork.getMembers()).thenReturn(List.of(tombstone));
164+
service.downloadBulk(request);
165+
// the zip file should be empty
166+
assertZipFiles(List.of(), List.of());
167+
}
168+
169+
@Test
170+
public void fileLimitTest() throws IOException {
171+
when(repoObjLoader.getWorkObject(any(PID.class))).thenReturn(parentWork);
172+
when(parentWork.getMembers()).thenReturn(List.of(fileObject1, fileObject2));
173+
makeBinaryObject(fileObject1, FILENAME1);
174+
makeBinaryObject(fileObject2, FILENAME2);
175+
when(aclService.hasAccess(eq(fileObject1Pid), any(),
176+
eq(Permission.viewOriginal))).thenReturn(true);
177+
when(aclService.hasAccess(eq(fileObject2Pid), any(),
178+
eq(Permission.viewOriginal))).thenReturn(true);
179+
service.setFileLimit(1);
180+
service.downloadBulk(request);
181+
// the zip file should have one entry
182+
assertZipFiles(List.of(FILENAME1), List.of("flower"));
183+
}
184+
157185
@Test
158186
public void successTest() throws IOException {
159187
when(repoObjLoader.getWorkObject(eq(parentPid))).thenReturn(parentWork);

static/css/cdrui_styles.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
.thumbnail {
5353
display: block;
5454
position:relative;
55-
float: left;
5655
margin: 0 0 20px 0;
5756
text-align: center;
5857
object-fit: contain;

static/css/sass/cdr_ui_styles.scss

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ $box-shadow: inset 3px 3px 10px -1px $box-shadow-color, 0px 16px 22px -15px $box
125125
*
126126
**/
127127
.search-query-text {
128-
margin: 40px 20px 40px 25px;
128+
margin: 40px 20px 20px 25px;
129129
font-size: 24px;
130130

131131
h2 {
@@ -147,13 +147,6 @@ form.search {
147147
}
148148
}
149149

150-
.browse-search {
151-
.button.is-focused,
152-
.button:focus {
153-
color: #363636;
154-
}
155-
}
156-
157150
a.search-result-num {
158151
background-color: $container-blue;
159152
color: white !important;
@@ -420,11 +413,7 @@ p.no-search-results {
420413

421414
#child-files_filter {
422415
margin-bottom: 25px;
423-
424-
label {
425-
float: right;
426-
width: 250px;
427-
}
416+
margin-top: -50px;
428417
}
429418

430419
.input::placeholder, .input {
@@ -439,14 +428,19 @@ img.data-thumb {
439428
max-width: 60px;
440429
}
441430

442-
.child-records {
443-
font-size: 16px;
444-
margin: 30px 50px 25px 50px;
431+
.file-list-header {
432+
margin: 30px 0 5px;
445433

446434
h3 {
447435
font-size: 16px;
448-
margin-bottom: 30px;
436+
margin: 0;
437+
padding: 0;
449438
}
439+
}
440+
441+
.child-records {
442+
font-size: 16px;
443+
overflow: visible;
450444

451445
.fa.default-img-icon {
452446
font-size: 32px;
@@ -459,14 +453,6 @@ img.data-thumb {
459453
}
460454
}
461455

462-
.is-icon {
463-
background-color: $container-blue;
464-
border: 1px solid $container-blue;
465-
border-radius: 5px;
466-
color: white;
467-
padding: 7px;
468-
}
469-
470456
.no-download {
471457
background-color: #B8B8B8;
472458
border-color: #B8B8B8;
@@ -614,7 +600,6 @@ img.data-thumb {
614600

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

619604
.collinfo {
620605
width: 100%;
@@ -719,7 +704,7 @@ table.dataTable {
719704
.actionlink {
720705
a.action {
721706
font-size: 16px;
722-
padding: 15px 15px 30px 15px;
707+
padding: 15px;
723708
}
724709
}
725710
}
@@ -729,7 +714,6 @@ table.dataTable {
729714
.restricted-access {
730715
border: 1px solid;
731716
border-radius: 5px;
732-
padding: 15px;
733717

734718
.button {
735719
text-align: left;
@@ -827,11 +811,6 @@ table.dataTable {
827811
margin-bottom: 10px;
828812
}
829813

830-
.button.is-focused,
831-
.button:focus {
832-
color: white;
833-
}
834-
835814
/* MODs display for work and file pages, plus modalMetadata.vue component */
836815
#mods_data_display {
837816
margin: auto;
@@ -905,6 +884,21 @@ table.dataTable {
905884
display: inline-flex;
906885
}
907886

887+
.button.is-link.is-hovered,
888+
.button.is-link:hover {
889+
background-color: #276cda;
890+
border-color: transparent;
891+
color: #fff;
892+
}
893+
894+
.navbar-link.is-active,
895+
.navbar-link:hover,
896+
a.navbar-item.is-active,
897+
a.navbar-item:hover {
898+
background-color: #fafafa;
899+
color: #3273dc;
900+
}
901+
908902
/*** End of Bulma overrides ***/
909903

910904
/* Following Bulma breakpoints */
@@ -1042,6 +1036,10 @@ table.dataTable {
10421036
}
10431037
}
10441038

1039+
#child-files_filter {
1040+
margin-top: -25px;
1041+
}
1042+
10451043
.dataTables_wrapper {
10461044
.dataTables_filter {
10471045
float: left !important;
@@ -1143,7 +1141,7 @@ iframe {
11431141

11441142
.clover-viewer {
11451143
margin: auto;
1146-
width: 90%;
1144+
width: 95%;
11471145
}
11481146

11491147
#information-toggle {

static/js/vue-cdr-access/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css">
5+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/versions/bulma-no-dark-mode.min.css">
66
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css">
77
<link rel="stylesheet" type="text/css" href="/static/css/cdr_access.css" />
88

0 commit comments

Comments
 (0)