8484import ca .nrc .cadc .net .HttpPost ;
8585import ca .nrc .cadc .net .HttpTransfer ;
8686import ca .nrc .cadc .net .HttpUpload ;
87+ import ca .nrc .cadc .net .ResourceNotFoundException ;
8788import ca .nrc .cadc .util .Base64 ;
8889import ca .nrc .cadc .util .StringUtil ;
8990import java .io .ByteArrayInputStream ;
@@ -560,7 +561,13 @@ private void updatePermissions(Node doiNode, Status current, Status updated) thr
560561 updateNodePermissions (doiNode , readGroups , writeGroups );
561562
562563 // update doi metadata file and data folder permissions
563- updateDOIPermissions (doiSuffix , readGroups , writeGroups );
564+ String dataPath = String .format ("%s/data" , doiSuffix );
565+ VOSURI dataURI = getVOSURI (dataPath );
566+ ContainerNode dataNode = vospaceDoiClient .getContainerNode (dataPath );
567+ updateDOIPermissions (doiSuffix , dataURI , dataNode , readGroups , writeGroups );
568+
569+ // give the publisher group read permission to files in the data folder
570+ updateDataFilePermissions (dataURI , dataNode , readGroups );
564571 } else {
565572 throw new IllegalArgumentException ("Invalid status change: 'in progress' -> 'review ready'" );
566573 }
@@ -605,7 +612,13 @@ private void updatePermissions(Node doiNode, Status current, Status updated) thr
605612 updateNodePermissions (doiNode , readGroups , writeGroups );
606613
607614 // update doi data folder permissions
608- updateDOIPermissions (doiSuffix , readGroups , writeGroups );
615+ String dataPath = String .format ("%s/data" , doiSuffix );
616+ VOSURI dataURI = getVOSURI (dataPath );
617+ ContainerNode dataNode = vospaceDoiClient .getContainerNode (dataPath );
618+ updateDOIPermissions (doiSuffix , dataURI , dataNode , readGroups , writeGroups );
619+
620+ // remove publisher group read permission for files in the data folder
621+ updateDataFilePermissions (dataURI , dataNode , readGroups );
609622 } else {
610623 String message = String .format ("Status change denied: '%s' -> '%s'" , current , updated );
611624 throw new IllegalArgumentException (message );
@@ -646,7 +659,7 @@ private void updateNodePermissions(Node doiNode, Set<GroupURI> readGroups, Set<G
646659 doiNode .isPublic = false ;
647660 }
648661
649- private void updateDOIPermissions (String doiSuffix , Set <GroupURI > readGroups , Set <GroupURI > writeGroups ) throws Exception {
662+ private void updateDOIPermissions (String doiSuffix , VOSURI dataURI , ContainerNode dataNode , Set <GroupURI > readGroups , Set <GroupURI > writeGroups ) throws Exception {
650663 // update metadata file permissions
651664 String metadataFilename = getDoiFilename (doiSuffix );
652665 String metadataPath = String .format ("%s/%s" , doiSuffix , metadataFilename );
@@ -656,11 +669,17 @@ private void updateDOIPermissions(String doiSuffix, Set<GroupURI> readGroups, Se
656669 vospaceDoiClient .getVOSpaceClient ().setNode (metadataVOSURI , metadataNode );
657670
658671 // update data folder permissions
659- String dataPath = String .format ("%s/data" , doiSuffix );
660- VOSURI dataURI = getVOSURI (dataPath );
661- ContainerNode dataFolderNode = vospaceDoiClient .getContainerNode (dataPath );
662- updateNodePermissions (dataFolderNode , readGroups , writeGroups );
663- vospaceDoiClient .getVOSpaceClient ().setNode (dataURI , dataFolderNode );
672+ updateNodePermissions (dataNode , readGroups , writeGroups );
673+ vospaceDoiClient .getVOSpaceClient ().setNode (dataURI , dataNode );
674+ }
675+
676+ private void updateDataFilePermissions (VOSURI dataURI , ContainerNode dataNode , Set <GroupURI > readGroups )
677+ throws IOException , ResourceNotFoundException , InterruptedException {
678+ dataNode .getReadOnlyGroup ().clear ();
679+ dataNode .getReadOnlyGroup ().addAll (readGroups );
680+ RecursiveSetNode setNode = vospaceDoiClient .getVOSpaceClient ().createRecursiveSetNode (dataURI , dataNode );
681+ setNode .setMonitor (true );
682+ setNode .run ();
664683 }
665684
666685 private Map <URI , String > getNodeProperties (JSONObject nodeData ) {
0 commit comments