unshared accounting added
This commit is contained in:
parent
4802a0542e
commit
2dc02aa194
|
@ -172,7 +172,7 @@ public class AccountingHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public void createUnshareFolder(String title, Session ses, Node sharedNode, boolean saveHistory ) {
|
||||
public void createUnshareFolder(String title, String user, Session ses, Node sharedNode, boolean saveHistory ) {
|
||||
try {
|
||||
|
||||
if (!sharedNode.hasNode(NodeProperty.ACCOUNTING.toString())){
|
||||
|
@ -180,8 +180,8 @@ public class AccountingHandler {
|
|||
}
|
||||
|
||||
Node accountingNodeParent = sharedNode.getNode(NodeProperty.ACCOUNTING.toString());
|
||||
Node accountingNode = accountingNodeParent.addNode(UUID.randomUUID().toString(),AccountingEntryType.SHARE.getNodeTypeDefinition());
|
||||
accountingNode.setProperty(USER, AuthorizationProvider.instance.get().getClient().getId());
|
||||
Node accountingNode = accountingNodeParent.addNode(UUID.randomUUID().toString(),AccountingEntryType.UNSHARE.getNodeTypeDefinition());
|
||||
accountingNode.setProperty(USER, user);
|
||||
accountingNode.setProperty(DATE, Calendar.getInstance());
|
||||
accountingNode.setProperty(ITEM_NAME, title);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.gcube.common.storagehub.model.items.FolderItem;
|
|||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.items.SharedFolder;
|
||||
import org.gcube.common.storagehub.model.types.ItemAction;
|
||||
import org.gcube.common.storagehub.model.types.NodeProperty;
|
||||
import org.gcube.data.access.storagehub.AuthorizationChecker;
|
||||
import org.gcube.data.access.storagehub.Utils;
|
||||
import org.gcube.data.access.storagehub.accounting.AccountingHandler;
|
||||
|
@ -122,6 +123,11 @@ public class UnshareHandler {
|
|||
log.debug("copying {} to {}", itemToCopyNode.getPath(), unsharedNode.getPath());
|
||||
ses.move(itemToCopyNode.getPath(), String.format("%s/%s",unsharedNode.getPath(), itemToCopyNode.getName()));
|
||||
}
|
||||
|
||||
ses.move(sharedItemNode.getNode(NodeProperty.ACCOUNTING.toString()).getPath(), String.format("%s/%s",unsharedNode.getPath(), NodeProperty.ACCOUNTING.toString()));
|
||||
|
||||
accountingHandler.createUnshareFolder(sharedItemNode.getProperty(NodeProperty.TITLE.toString()).getString(), "ALL", ses, unsharedNode, false);
|
||||
|
||||
ses.save();
|
||||
}finally {
|
||||
ses.getWorkspace().getLockManager().unlock(sharedItemNode.getPath());
|
||||
|
@ -164,6 +170,9 @@ public class UnshareHandler {
|
|||
|
||||
log.debug("removed Access control entry for user {}",login);
|
||||
Node sharedItemNode = ses.getNodeByIdentifier(item.getId());
|
||||
|
||||
accountingHandler.createUnshareFolder(sharedItemNode.getProperty(NodeProperty.TITLE.toString()).getString(), login, ses, sharedItemNode, false);
|
||||
|
||||
Node usersNode = sharedItemNode.getNode(NodeConstants.USERS_NAME);
|
||||
usersNode.remove();
|
||||
Node newUsersNode = sharedItemNode.addNode(NodeConstants.USERS_NAME);
|
||||
|
@ -176,6 +185,7 @@ public class UnshareHandler {
|
|||
|
||||
acm.setPolicy(sharedFolderNode.getPath(), acls);
|
||||
|
||||
|
||||
ses.save();
|
||||
|
||||
return parentId;
|
||||
|
@ -226,6 +236,10 @@ public class UnshareHandler {
|
|||
|
||||
acm.setPolicy(sharedFolderNode.getPath(), acls);
|
||||
|
||||
for (String user: usersToUnshare) {
|
||||
accountingHandler.createUnshareFolder(sharedItemNode.getProperty(NodeProperty.TITLE.toString()).getString(), user, ses, sharedItemNode, false);
|
||||
}
|
||||
|
||||
ses.save();
|
||||
|
||||
return item.getId();
|
||||
|
@ -242,7 +256,6 @@ public class UnshareHandler {
|
|||
Node parentNode = ses.getNodeByIdentifier(parentDirectoryId);
|
||||
Node userNode = ses.getNode(String.format("%s/%s",parentNode.getPath(), directoryName));
|
||||
userNode.removeShare();
|
||||
accountingHandler.createUnshareFolder(directoryName, ses, parentNode, false);
|
||||
log.debug("directory removed for user {}",user);
|
||||
return parentDirectoryId;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue