use of org.irods.jargon.core.pub.domain.Collection in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getPermissionsForPath.
@Override
public String getPermissionsForPath(String path) throws DataGridConnectionRefusedException {
logger.info("getPermissionsForPath()");
FilePermissionEnum filePermissionEnum = null;
String permissionType = "none";
try {
String user = irodsServices.getCurrentUser();
String zone = irodsServices.getCurrentUserZone();
Object obj = irodsServices.getCollectionAndDataObjectListAndSearchAO().getFullObjectForType(path);
if (obj instanceof Collection) {
CollectionAO collectionAO = irodsServices.getCollectionAO();
filePermissionEnum = collectionAO.getPermissionForCollection(path, user, zone);
} else {
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
filePermissionEnum = dataObjectAO.getPermissionForDataObject(path, user, zone);
}
if (filePermissionEnum != null) {
permissionType = filePermissionEnum.toString().toLowerCase();
}
} catch (FileNotFoundException e) {
logger.error("Could not find path: {}", e.getMessage());
} catch (JargonException e) {
logger.error("Could not get permission for path: {}", e.getMessage());
}
return permissionType;
}
use of org.irods.jargon.core.pub.domain.Collection in project metalnx-web by irods-contrib.
the class PermissionsServiceImpl method getFilePermissionListForObject.
/**
* Gets the list of file permissions on the requested object for a particular user. The object
* can be a collection as a single data object.
*
* @param path the path to the object
* @param username user name to get the permissions on the given path. If no user name is required,
* an empty String or null should be provided
* @return list of {@link UserFilePermission}
* @throws FileNotFoundException
* @throws JargonException
* @throws DataGridConnectionRefusedException
*/
private List<UserFilePermission> getFilePermissionListForObject(String path, String username) throws DataGridConnectionRefusedException, JargonException {
Object obj = irodsServices.getCollectionAndDataObjectListAndSearchAO().getFullObjectForType(path);
List<UserFilePermission> filePermissionList = new ArrayList<UserFilePermission>();
List<UserFilePermission> dataGridfilePermissionList = null;
// If the object is a collection
if (obj instanceof Collection) {
logger.debug("Getting permission info for collection {}", path);
dataGridfilePermissionList = irodsServices.getCollectionAO().listPermissionsForCollection(path);
} else // If the object is a data object
{
logger.debug("Getting permission info for data object {}", path);
dataGridfilePermissionList = irodsServices.getDataObjectAO().listPermissionsForDataObject(path);
}
// as the parameter
if (username != null && !username.isEmpty()) {
for (UserFilePermission userFilePermission : dataGridfilePermissionList) {
if (userFilePermission.getUserName().equalsIgnoreCase(username)) {
filePermissionList.add(userFilePermission);
}
}
} else {
filePermissionList = dataGridfilePermissionList;
}
return filePermissionList;
}
Aggregations