use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.
the class TemplateController method importXMLFile.
@RequestMapping(value = "/import/", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public String importXMLFile(final Model model, final HttpServletRequest request, final RedirectAttributes redirect) {
String responseString = "ok";
if (request instanceof MultipartHttpServletRequest) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
List<MultipartFile> multipartFiles = multipartRequest.getFiles("file");
String prefix = multipartRequest.getParameter("prefix");
String suffix = multipartRequest.getParameter("suffix");
try {
String username = loggedUserUtils.getLoggedDataGridUser().getUsername();
boolean result = templateService.importXmlMetadataTemplate(multipartFiles.get(0).getInputStream(), username, prefix, suffix);
if (!result) {
responseString = "partial";
}
} catch (JAXBException | IOException | DataGridException e) {
logger.error("Could not import metadata templates", e);
responseString = "error";
}
}
return responseString;
}
use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.
the class PreviewPreparationController method getPreview.
/**
* Responds the preview/ request
*
* @param model
* @return the collection management template
* @throws DataGridConnectionRefusedException
* @throws JargonException
* @throws DataGridException
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String getPreview(final Model model, @RequestParam("path") final String path, RedirectAttributes redirectAttributes) throws DataGridException {
logger.info("prepareForPreview for {} ::" + path);
String mimeType = null;
boolean permission = previewService.getPermission(path);
if (permission) {
try {
IRODSAccount irodsAccount = irodsServices.getUserAO().getIRODSAccount();
DataTypeResolutionService dataTypeResolutionService = dataTypeResolutionServiceFactory.instanceDataTypeResolutionService(irodsAccount);
logger.info("dataTypeResolutionService created from factory:{}", dataTypeResolutionService);
logger.info("doing quick check for mime type");
mimeType = dataTypeResolutionService.quickMimeType(path);
logger.info("mimetype:{}", mimeType);
redirectAttributes.addAttribute("path", path);
redirectAttributes.addAttribute("mimeType", mimeType);
return "redirect:/preview/templateByMimeType";
} catch (JargonException e) {
logger.error("Could not retrieve data from path: {}", path, e);
throw new DataGridException(e.getMessage());
} catch (Exception e) {
logger.error("general exception generating preview", e);
throw new DataGridException(e.getLocalizedMessage());
}
} else {
return "collections/preview :: noPermission";
}
}
use of com.emc.metalnx.core.domain.exceptions.DataGridException 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 com.emc.metalnx.core.domain.exceptions.DataGridException 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 com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.
the class CollectionController method indexViaUrl.
/**
* Responds the collections/ request
*
* @param model
* @return the collection management template
* @throws JargonException
* @throws DataGridException
*/
@RequestMapping(method = RequestMethod.GET)
public String indexViaUrl(final Model model, final HttpServletRequest request, @RequestParam("path") final Optional<String> path, @ModelAttribute("requestHeader") String requestHeader) {
logger.info("indexViaUrl()");
String myPath = path.orElse("");
logger.info("dp Header requestHeader is :: " + requestHeader);
try {
if (myPath.isEmpty()) {
model.addAttribute("topnavHeader", headerService.getheader("collections"));
logger.info("no path, go to home dir");
myPath = cs.getHomeDirectyForCurrentUser();
} else {
logger.info("path provided...go to:{}", path);
// TODO: do I need to worry about decoding, versus configure
myPath = URLDecoder.decode(myPath);
// in filter? - MCC
// see
// https://stackoverflow.com/questions/25944964/where-and-how-to-decode-pathvariable
}
logger.info("myPath:{}" + myPath);
DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
String uiMode = (String) request.getSession().getAttribute("uiMode");
sourcePaths = MiscIRODSUtils.breakIRODSPathIntoComponents(myPath);
CollectionAndPath collectionAndPath = MiscIRODSUtils.separateCollectionAndPathFromGivenAbsolutePath(myPath);
this.parentPath = collectionAndPath.getCollectionParent();
this.currentPath = myPath;
if (uiMode == null || uiMode.isEmpty()) {
boolean isUserAdmin = loggedUser != null && loggedUser.isAdmin();
uiMode = isUserAdmin ? UI_ADMIN_MODE : UI_USER_MODE;
}
if (cs.isDataObject(myPath)) {
logger.info("redirect to info page");
StringBuilder sb = new StringBuilder();
sb.append("redirect:/collectionInfo?path=");
sb.append(URLEncoder.encode(myPath));
return sb.toString();
}
logger.info("is collection...continue to collection management");
if (uiMode.equals(UI_USER_MODE)) {
model.addAttribute("homePath", cs.getHomeDirectyForCurrentUser());
model.addAttribute("publicPath", cs.getHomeDirectyForPublic());
}
model.addAttribute("uiMode", uiMode);
model.addAttribute("currentPath", currentPath);
model.addAttribute("encodedCurrentPath", URLEncoder.encode(currentPath));
model.addAttribute("parentPath", parentPath);
model.addAttribute("resources", resourceService.findAll());
model.addAttribute("overwriteFileOption", loggedUser != null && loggedUser.isForceFileOverwriting());
} catch (JargonException | DataGridException e) {
logger.error("error establishing collection location", e);
model.addAttribute("unexpectedError", true);
}
logger.info("displaying collections/collectionManagement");
return "collections/collectionManagement";
}
Aggregations