use of org.irods.jargon.core.exception.FileNotFoundException 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.exception.FileNotFoundException in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getInheritanceOptionForCollection.
@Override
public boolean getInheritanceOptionForCollection(String collPath) throws DataGridConnectionRefusedException, JargonException {
logger.info("getInheritanceOptionForCollection()");
if (collPath == null || collPath.isEmpty()) {
throw new IllegalArgumentException("null or empty collPath");
}
logger.info("collPath:{}", collPath);
CollectionAO collectionAO = irodsServices.getCollectionAO();
try {
return collectionAO.isCollectionSetForPermissionInheritance(collPath);
} catch (FileNotFoundException e) {
logger.warn("Collection {} does not exist: {}", collPath, e.getMessage());
} catch (JargonException e) {
logger.error("Could not retrieve inheritance option value for", collPath, e.getMessage());
throw e;
}
return false;
}
use of org.irods.jargon.core.exception.FileNotFoundException in project metalnx-web by irods-contrib.
the class BrowseController method getCollBrowserView.
/**
* Finds all collections and data objects existing under a certain path
*
* @param model
* @param path
* path to get all directories and data objects from
* @return collections browser template that renders all items of certain path
* (parent)
* @throws DataGridConnectionRefusedException
* if Metalnx cannot connect to the grid.
*/
private String getCollBrowserView(final Model model, String path) throws JargonException, DataGridException {
logger.info("getCollBrowserView()");
logger.info("model:{}", model);
logger.info("path:{}", path);
logger.info("find collection by name:{}", path);
DataGridCollectionAndDataObject dataGridObj = null;
try {
dataGridObj = cs.findByName(path);
} catch (FileNotFoundException fnf) {
logger.warn("file not found for:{}", path);
// I don't have a path so use the user home
logger.info("no path, so using user home directory");
// TODO: refactor into something more elegant - mcc
model.addAttribute("invalidPath", path);
IRODSAccount irodsAccount = irodsServices.getCollectionAO().getIRODSAccount();
path = MiscIRODSUtils.buildIRODSUserHomeForAccountUsingDefaultScheme(irodsAccount);
}
if (path.endsWith("/") && path.compareTo("/") != 0) {
path = path.substring(0, path.length() - 1);
}
currentPath = path;
logger.info("currentPath:{}", currentPath);
DataGridUser user = loggedUserUtils.getLoggedDataGridUser();
if (zoneTrashPath == null || zoneTrashPath.isEmpty()) {
zoneTrashPath = String.format("/%s/trash", irodsServices.getCurrentUserZone());
}
// TODO: do I really need these permission path checks? I can let iRODS worry
// about permissions - mcc
CollectionOrDataObjectForm collectionForm = new CollectionOrDataObjectForm();
String permissionType = "none";
if (dataGridObj.isProxy()) {
logger.info("this is a proxy, so fake out the options");
collectionForm.setInheritOption(false);
permissionType = "read";
} else {
logger.info("this is not a proxy, so gather permission info");
permissionType = cs.getPermissionsForPath(path);
collectionForm.setInheritOption(cs.getInheritanceOptionForCollection(currentPath));
permissionsService.resolveMostPermissiveAccessForUser(dataGridObj, user);
}
logger.debug("permission options are set");
boolean isPermissionOwn = "own".equals(permissionType);
boolean isTrash = path.contains(zoneTrashPath) && (isPermissionOwn || user.isAdmin());
boolean inheritanceDisabled = !isPermissionOwn && collectionForm.getInheritOption();
model.addAttribute("collectionAndDataObject", dataGridObj);
model.addAttribute("isTrash", isTrash);
model.addAttribute("permissionType", permissionType);
model.addAttribute("currentPath", currentPath);
model.addAttribute("encodedCurrentPath", URLEncoder.encode(currentPath));
model.addAttribute("isCurrentPathCollection", cs.isCollection(path));
model.addAttribute("user", user);
model.addAttribute("trashColl", cs.getTrashForPath(currentPath));
model.addAttribute("collection", collectionForm);
model.addAttribute("inheritanceDisabled", inheritanceDisabled);
model.addAttribute("requestMapping", "/browse/add/action/");
model.addAttribute("parentPath", parentPath);
setBreadcrumbToModel(model, dataGridObj);
logger.info("forwarding to collections/collectionsBrowser");
return "collections/collectionsBrowser";
}
use of org.irods.jargon.core.exception.FileNotFoundException in project metalnx-web by irods-contrib.
the class BrowseController method getFileInfo.
/**
* Gets checksum, total number of replicas and where each replica lives in the
* data grid for a specific data object
*
* @param model
* @param path
* path to the data object to get checksum and replica information
* @return the template that shows the data object information
* @throws DataGridException
* @throws FileNotFoundException
*/
@RequestMapping(value = "/info/", method = RequestMethod.POST)
public String getFileInfo(final Model model, final String path) throws DataGridException, FileNotFoundException {
logger.info("CollectionController getInfoFile() starts :: " + path);
DataGridCollectionAndDataObject dataGridObj = null;
Map<DataGridCollectionAndDataObject, DataGridResource> replicasMap = null;
try {
dataGridObj = cs.findByName(path);
if (dataGridObj != null && !dataGridObj.isCollection()) {
replicasMap = cs.listReplicasByResource(path);
dataGridObj.setChecksum(cs.getChecksum(path));
dataGridObj.setNumberOfReplicas(cs.getTotalNumberOfReplsForDataObject(path));
dataGridObj.setReplicaNumber(String.valueOf(cs.getReplicationNumber(path)));
permissionsService.resolveMostPermissiveAccessForUser(dataGridObj, loggedUserUtils.getLoggedDataGridUser());
}
} catch (DataGridConnectionRefusedException e) {
logger.error("Could not connect to the data grid", e);
throw e;
} catch (DataGridException e) {
logger.error("Could not get file info for {}", path, e);
throw e;
} catch (FileNotFoundException e) {
logger.error("file does not exist for:{}", path, e);
throw e;
}
model.addAttribute("collectionAndDataObject", dataGridObj);
model.addAttribute("currentCollection", dataGridObj);
model.addAttribute("replicasMap", replicasMap);
model.addAttribute("infoFlag", true);
logger.info("CollectionController getInfoFile() ends !!");
return "collections/info :: infoView";
// return "collections/info";
}
use of org.irods.jargon.core.exception.FileNotFoundException in project metalnx-web by irods-contrib.
the class PermissionsController method getPermissionDetails.
/**
* Gives permission details related to a collection or file that is passed as a
* parameter
*
* @param model
* @param path
* @return
* @throws DataGridConnectionRefusedException
* @throws JargonException
* @throws FileNotFoundException
*/
@RequestMapping(value = "/getPermissionDetails/", method = RequestMethod.POST)
public String getPermissionDetails(final Model model, @RequestParam("path") final String path) throws DataGridConnectionRefusedException {
logger.debug("Getting permission info for {}", path);
DataGridCollectionAndDataObject obj = null;
List<DataGridFilePermission> permissions;
List<DataGridGroupPermission> groupPermissions;
List<DataGridUserPermission> userPermissions;
List<DataGridGroupBookmark> bookmarks;
List<DataGridUserBookmark> userBookmarks;
Set<String> groupsWithBookmarks;
Set<String> usersWithBookmarks;
boolean userCanModify = false;
boolean isCollection = false;
try {
loggedUser = luu.getLoggedDataGridUser();
permissions = ps.getPathPermissionDetails(path);
groupPermissions = ps.getGroupsWithPermissions(permissions);
userPermissions = ps.getUsersWithPermissions(permissions);
bookmarks = gBMS.findBookmarksOnPath(path);
userBookmarks = uBMS.findBookmarksOnPath(path);
userCanModify = loggedUser.isAdmin() || ps.canLoggedUserModifyPermissionOnPath(path);
groupsWithBookmarks = new HashSet<>();
for (DataGridGroupBookmark bookmark : bookmarks) {
groupsWithBookmarks.add(bookmark.getGroup().getGroupname());
}
usersWithBookmarks = new HashSet<>();
for (DataGridUserBookmark userBookmark : userBookmarks) {
usersWithBookmarks.add(userBookmark.getUser().getUsername());
}
obj = cs.findByName(path);
ps.resolveMostPermissiveAccessForUser(obj, loggedUser);
} catch (Exception e) {
logger.error("Could not get permission details {}: {}", path, e.getMessage());
groupPermissions = new ArrayList<>();
userPermissions = new ArrayList<>();
groupsWithBookmarks = new HashSet<>();
usersWithBookmarks = new HashSet<>();
}
model.addAttribute("usersWithBookmarks", usersWithBookmarks);
model.addAttribute("groupsWithBookmark", groupsWithBookmarks);
model.addAttribute("groupPermissions", groupPermissions);
model.addAttribute("userPermissions", userPermissions);
model.addAttribute("userCanModify", userCanModify);
model.addAttribute("permissions", PERMISSIONS);
model.addAttribute("permissionsWithoutNone", PERMISSIONS_WITHOUT_NONE);
model.addAttribute("collectionAndDataObject", obj);
model.addAttribute("isCollection", isCollection);
model.addAttribute("permissionOnCurrentPath", cs.getPermissionsForPath(path));
model.addAttribute("permissionFlag", true);
System.out.println("permissionOnCurrentPath =======" + cs.getPermissionsForPath(path));
System.out.println("------Permission Conroller - /getPermissionDetail/ ends------");
return "permissions/permissionDetails :: permissionDetails";
}
Aggregations