use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class FileOperationServiceImpl method computeChecksum.
@Override
public void computeChecksum(String path, String filename) throws DataGridChecksumException, DataGridConnectionRefusedException {
if (path == null || path.isEmpty() || filename == null || filename.isEmpty())
throw new DataGridChecksumException("Could not calculate checksum. File path is invalid.");
logger.info("Computing checksum for {} ({})", filename, path);
IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
IRODSFile file;
try {
file = irodsFileFactory.instanceIRODSFile(path, filename);
dataObjectAO.computeMD5ChecksumOnDataObject(file);
} catch (JargonException e) {
logger.error("Could not calculate checksum: {}", e.getMessage());
throw new DataGridChecksumException("Could not calculate checksum.");
}
}
use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class UserServiceImpl method updateReadPermissions.
@Override
public boolean updateReadPermissions(DataGridUser user, Map<String, Boolean> addCollectionsToRead, Map<String, Boolean> removeCollectionsToRead) throws DataGridConnectionRefusedException {
CollectionAO collectionAO = null;
DataObjectAO dataObjectAO = null;
IRODSFile irodsFile = null;
IRODSFileFactory irodsFileFactory = null;
boolean readPermissionsUpdated = false;
try {
collectionAO = irodsServices.getCollectionAO();
dataObjectAO = irodsServices.getDataObjectAO();
irodsFileFactory = irodsServices.getIRODSFileFactory();
for (String path : addCollectionsToRead.keySet()) {
irodsFile = irodsFileFactory.instanceIRODSFile(path);
if (irodsFile.isDirectory()) {
// applying read permissions on a collection (not recursively)
collectionAO.setAccessPermissionReadAsAdmin(user.getAdditionalInfo(), path, user.getUsername(), addCollectionsToRead.get(path));
} else {
// applying read permissions on a data object
dataObjectAO.setAccessPermissionReadInAdminMode(user.getAdditionalInfo(), path, user.getUsername());
}
}
removeAccessPermissionForUserAsAdmin(user, removeCollectionsToRead);
readPermissionsUpdated = true;
} catch (JargonException e) {
logger.error("Could not set read permission:", e);
}
return readPermissionsUpdated;
}
use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class UserServiceImpl method removeAccessPermissionForUserAsAdmin.
@Override
public void removeAccessPermissionForUserAsAdmin(DataGridUser user, Map<String, Boolean> paths) throws JargonException, DataGridConnectionRefusedException {
if (paths == null || paths.isEmpty()) {
return;
}
IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();
CollectionAO collectionAO = irodsServices.getCollectionAO();
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
IRODSFile irodsFile = null;
for (String path : paths.keySet()) {
irodsFile = irodsFileFactory.instanceIRODSFile(path);
if (irodsFile.isDirectory()) {
collectionAO.removeAccessPermissionForUserAsAdmin(user.getAdditionalInfo(), path, user.getUsername(), paths.get(path));
} else {
dataObjectAO.removeAccessPermissionsForUserInAdminMode(user.getAdditionalInfo(), path, user.getUsername());
}
}
}
use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class FilePropertyServiceImpl method populateVisibilityForCurrentUser.
private void populateVisibilityForCurrentUser(List<DataGridCollectionAndDataObject> objectList) throws DataGridConnectionRefusedException {
CollectionAO collectionAO = irodsServices.getCollectionAO();
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
String currentUser = getLoggedDataGridUser().getUsername();
for (DataGridCollectionAndDataObject obj : objectList) {
List<UserFilePermission> permissions = null;
try {
if (obj.isCollection()) {
permissions = collectionAO.listPermissionsForCollection(obj.getPath());
} else {
permissions = dataObjectAO.listPermissionsForDataObject(obj.getPath());
}
} catch (JargonException e) {
logger.error("Could not get permission list for object {}", obj.getPath(), e);
}
obj.setVisibleToCurrentUser(false);
if (permissions != null) {
for (UserFilePermission permission : permissions) {
if (permission.getUserName().compareTo(currentUser) == 0) {
obj.setVisibleToCurrentUser(true);
break;
}
}
}
}
}
use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class GroupServiceImpl method updateOwnership.
@Override
public boolean updateOwnership(DataGridGroup group, Map<String, Boolean> addCollectionsToOwn, Map<String, Boolean> removeCollectionsToOwn) throws DataGridConnectionRefusedException {
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
CollectionAO collectionAO = irodsServices.getCollectionAO();
try {
for (String path : addCollectionsToOwn.keySet()) {
if (collectionService.isCollection(path)) {
collectionAO.setAccessPermissionOwnAsAdmin(group.getAdditionalInfo(), path, group.getGroupname(), addCollectionsToOwn.get(path));
} else {
dataObjectAO.setAccessPermissionWriteInAdminMode(group.getAdditionalInfo(), path, group.getGroupname());
}
}
for (String path : removeCollectionsToOwn.keySet()) {
if (collectionService.isCollection(path)) {
collectionAO.removeAccessPermissionForUserAsAdmin(group.getAdditionalInfo(), path, group.getGroupname(), removeCollectionsToOwn.get(path));
} else {
dataObjectAO.removeAccessPermissionsForUserInAdminMode(group.getAdditionalInfo(), path, group.getGroupname());
}
}
return true;
} catch (JargonException | DataGridException e) {
logger.error("Could not set ownership:", e);
}
return false;
}
Aggregations