use of org.irods.jargon.core.pub.io.IRODSFile 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.io.IRODSFile 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.io.IRODSFile in project metalnx-web by irods-contrib.
the class TestDownloadWithTicket method uploadFileToIRODS.
private void uploadFileToIRODS(String path, File file) throws DataGridConnectionRefusedException, JargonException, IOException {
IRODSFile targetFile = irodsServices.getIRODSFileFactory().instanceIRODSFile(path, file.getName());
if (targetFile.exists()) {
return;
}
Stream2StreamAO streamAO = irodsServices.getStream2StreamAO();
InputStream inputStream = new FileInputStream(file);
streamAO.transferStreamToFileUsingIOStreams(inputStream, (File) targetFile, 0, BUFFER_SIZE);
inputStream.close();
targetFile.close();
}
use of org.irods.jargon.core.pub.io.IRODSFile in project metalnx-web by irods-contrib.
the class TestRuleDeploymentService method createRuleCacheColl.
/**
* Create the rule cache collection in the grid
* @throws DataGridConnectionRefusedException
* @throws JargonException
*/
private void createRuleCacheColl() throws DataGridConnectionRefusedException, JargonException {
IRODSFileFactory iff = irodsServices.getIRODSFileFactory();
IRODSFile ruleCacheColl = iff.instanceIRODSFile("/" + configService.getIrodsZone(), RULE_CACHE_DIR);
irodsServices.getIRODSFileSystemAO().mkdir(ruleCacheColl, false);
}
use of org.irods.jargon.core.pub.io.IRODSFile in project metalnx-web by irods-contrib.
the class PermissionsServiceImpl method setPermissionOnPath.
@Override
public boolean setPermissionOnPath(DataGridPermType permType, String uName, boolean recursive, boolean inAdminMode, String... paths) throws DataGridConnectionRefusedException {
logger.info("Setting {} permission on path {} for user/group {}", permType, paths, uName);
boolean operationResult = true;
for (String path : paths) {
try {
IRODSFile irodsFile = irodsServices.getIRODSFileFactory().instanceIRODSFile(path);
if (irodsFile.isDirectory()) {
operationResult = chmodCollection(permType, path, recursive, uName, inAdminMode);
} else {
operationResult = chmodDataObject(permType, path, uName, inAdminMode);
}
// If the permissions is NONE, remove all bookmarks associated to the group and the path
if (permType.equals(DataGridPermType.NONE)) {
DataGridGroup group = groupDao.findByGroupnameAndZone(uName, irodsServices.getCurrentUserZone());
if (group != null)
groupBookmarkDao.removeByGroupAndPath(group, path);
}
logger.info("Permission {} for user {} on path {} set successfully", permType, uName, paths);
} catch (JargonException e) {
logger.error("Could not set {} permission on path {} for user/group {}", permType, path, uName, e);
operationResult = false;
}
}
return operationResult;
}
Aggregations