use of org.irods.jargon.core.exception.JargonException 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.exception.JargonException 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;
}
use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.
the class GroupServiceImpl method getMemberList.
@Override
public String[] getMemberList(DataGridGroup group) throws DataGridConnectionRefusedException {
UserGroupAO userGroupAO = irodsServices.getGroupAO();
try {
List<User> groupMembers = userGroupAO.listUserGroupMembers(group.getGroupname());
String[] dataGridIds = new String[groupMembers.size()];
for (int i = 0; i < groupMembers.size(); i++) {
dataGridIds[i] = groupMembers.get(i).getId();
}
return dataGridIds;
} catch (JargonException e) {
logger.error("Could not get members list for group [" + group.getGroupname() + "]: ", e);
}
return new String[0];
}
use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.
the class GroupServiceImpl method updateReadPermissions.
@Override
public boolean updateReadPermissions(DataGridGroup group, Map<String, Boolean> addCollectionsToRead, Map<String, Boolean> removeCollectionsToRead) throws DataGridConnectionRefusedException {
CollectionAO collectionAO = irodsServices.getCollectionAO();
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
try {
for (String path : addCollectionsToRead.keySet()) {
if (collectionService.isCollection(path)) {
collectionAO.setAccessPermissionReadAsAdmin(group.getAdditionalInfo(), path, group.getGroupname(), addCollectionsToRead.get(path));
} else {
dataObjectAO.setAccessPermissionReadInAdminMode(group.getAdditionalInfo(), path, group.getGroupname());
}
}
for (String path : removeCollectionsToRead.keySet()) {
if (collectionService.isCollection(path)) {
collectionAO.removeAccessPermissionForUserAsAdmin(group.getAdditionalInfo(), path, group.getGroupname(), removeCollectionsToRead.get(path));
} else {
dataObjectAO.setAccessPermissionReadInAdminMode(group.getAdditionalInfo(), path, group.getGroupname());
}
}
return true;
} catch (JargonException | DataGridException e) {
logger.error("Could not set read permission:", e);
}
return false;
}
use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.
the class GroupBookmarkController method listGroupsByQueryPaginatedModel.
@RequestMapping(value = "/groupsBookmarksPaginated")
@ResponseBody
public String listGroupsByQueryPaginatedModel(final HttpServletRequest request) throws DataGridConnectionRefusedException {
int draw = Integer.parseInt(request.getParameter("draw"));
int start = Integer.parseInt(request.getParameter("start"));
int length = Integer.parseInt(request.getParameter("length"));
String searchString = request.getParameter("search[value]");
int orderColumn = Integer.parseInt(request.getParameter("order[0][column]"));
String orderDir = request.getParameter("order[0][dir]");
boolean onlyCollections = Boolean.parseBoolean(request.getParameter("onlyCollections"));
String currentUser = irodsServices.getCurrentUser();
String currentZone = irodsServices.getCurrentUserZone();
String[] orderBy = { "Dggb.name", "Dggb.path", "Dgg.groupname", "Dggb.createTs" };
List<DataGridGroupBookmark> groupBookmarks = null;
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> jsonResponse = new HashMap<String, Object>();
String jsonString = "";
try {
groupBookmarks = groupBookmarkService.getGroupsBookmarksPaginated(currentUser, currentZone, start, length, searchString, orderBy[orderColumn], orderDir, onlyCollections);
if ("".equals(searchString)) {
totalGroupBookmarks = groupBookmarkService.countTotalGroupBookmarks(currentUser, currentZone);
totalGroupBookmarksFiltered = totalGroupBookmarks;
} else {
totalGroupBookmarksFiltered = groupBookmarks.size();
}
} catch (JargonException e) {
logger.error("Could not get groups bookmarks for {}", currentUser);
groupBookmarks = new ArrayList<DataGridGroupBookmark>();
}
jsonResponse.put("draw", String.valueOf(draw));
jsonResponse.put("recordsTotal", String.valueOf(totalGroupBookmarks));
jsonResponse.put("recordsFiltered", String.valueOf(totalGroupBookmarksFiltered));
jsonResponse.put("data", groupBookmarks);
try {
jsonString = mapper.writeValueAsString(jsonResponse);
} catch (Exception e) {
logger.error("Could not parse hashmap in favorites to json", e.getMessage());
}
return jsonString;
}
Aggregations