use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.
the class MetadataController method getMetadata.
@RequestMapping(value = "/getMetadata/", method = RequestMethod.POST)
public String getMetadata(final Model model, final String path) throws DataGridConnectionRefusedException, FileNotFoundException {
logger.info("MetadataController getMetadata() starts !!");
List<DataGridMetadata> metadataList = metadataService.findMetadataValuesByPath(path);
DataGridCollectionAndDataObject dgColObj = null;
try {
dgColObj = collectionService.findByName(path);
permissionsService.resolveMostPermissiveAccessForUser(dgColObj, loggedUserUtils.getLoggedDataGridUser());
} catch (DataGridException e) {
logger.error("Could not retrieve collection/dataobject from path: {}", path);
}
model.addAttribute("permissionOnCurrentPath", collectionService.getPermissionsForPath(path));
model.addAttribute("dataGridMetadataList", metadataList);
model.addAttribute("currentPath", path);
model.addAttribute("collectionAndDataObject", dgColObj);
model.addAttribute("metadataFlag", true);
logger.info("MetadataController getMetadata() ends !!");
return "metadata/metadataTable :: metadataTable";
}
use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.
the class BrowseController method setBreadcrumbToModel.
/*
* **************************************************************************
* **************************** PRIVATE METHODS *****************************
* **************************************************************************
*/
/**
* Creates the breadcrumb based on a given path.
*
* @param model
* Model attribute to set variables to be used in the view
* @param path
* path that will be displayed in the breadcrumb
* @throws DataGridException
*/
private void setBreadcrumbToModel(final Model model, final String path) throws DataGridException {
DataGridCollectionAndDataObject obj;
try {
obj = cs.findByName(path);
} catch (FileNotFoundException e) {
obj = new DataGridCollectionAndDataObject();
obj.setPath(path);
obj.setCollection(false);
obj.setParentPath(path.substring(0, path.lastIndexOf("/") + 1));
obj.setName(path.substring(path.lastIndexOf("/") + 1, path.length()));
logger.error("Could not find DataGridCollectionAndDataObject by path: {}", e.getMessage());
} catch (DataGridException e) {
logger.error("unable to find path for breadcrumb", e);
throw e;
}
setBreadcrumbToModel(model, obj);
}
use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.
the class BrowseController method addCollection.
/**
* Performs the action of actually creating a collection in iRODS
*
* @param model
* @param collection
* @return if the creation of collection was successful, it returns the
* collection management template, and returns the add collection
* template, otherwise.
* @throws DataGridConnectionRefusedException
*/
@RequestMapping(value = "add/action", method = RequestMethod.POST)
public String addCollection(final Model model, @ModelAttribute final CollectionOrDataObjectForm collection, final RedirectAttributes redirectAttributes) throws DataGridConnectionRefusedException {
logger.info("addCollection()");
logger.info("collection:{}", collection);
logger.info("redirectAttributes:{}", redirectAttributes);
DataGridCollectionAndDataObject newCollection = new DataGridCollectionAndDataObject(currentPath + '/' + collection.getCollectionName(), collection.getCollectionName(), currentPath, true);
logger.info("newCollection:{}", newCollection);
newCollection.setParentPath(currentPath);
newCollection.setCreatedAt(new Date());
newCollection.setModifiedAt(newCollection.getCreatedAt());
newCollection.setInheritanceOption(collection.getInheritOption());
boolean creationSucessful;
try {
creationSucessful = cs.createCollection(newCollection);
logger.info("creationSuccessful?:{}", creationSucessful);
if (creationSucessful) {
redirectAttributes.addFlashAttribute("collectionAddedSuccessfully", collection.getCollectionName());
}
} catch (DataGridConnectionRefusedException e) {
throw e;
} catch (DataGridException e) {
logger.error("Could not create collection/data object (lack of permission): ", e.getMessage());
redirectAttributes.addFlashAttribute("missingPermissionError", true);
}
return "redirect:/collections?path=" + URLEncoder.encode(currentPath);
}
use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.
the class CollectionController method index.
/**
* Legacy index method used in other controllers, eventually factor out TODO:
* factor this out and make explicit via urls etc - mcc
*
* @param model
* @param request
* @return
*/
public String index(final Model model, final HttpServletRequest request) {
logger.info("index()");
try {
sourcePaths.clear();
if (!cs.isPathValid(currentPath)) {
currentPath = cs.getHomeDirectyForCurrentUser();
parentPath = currentPath;
} else if (cs.isDataObject(currentPath)) {
parentPath = currentPath.substring(0, currentPath.lastIndexOf("/") + 1);
}
DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
String uiMode = (String) request.getSession().getAttribute("uiMode");
if (uiMode == null || uiMode.isEmpty()) {
boolean isUserAdmin = loggedUser != null && loggedUser.isAdmin();
uiMode = isUserAdmin ? UI_ADMIN_MODE : UI_USER_MODE;
}
if (uiMode.equals(UI_USER_MODE)) {
model.addAttribute("homePath", cs.getHomeDirectyForCurrentUser());
model.addAttribute("publicPath", cs.getHomeDirectyForPublic());
}
model.addAttribute("cameFromFilePropertiesSearch", cameFromFilePropertiesSearch);
model.addAttribute("cameFromMetadataSearch", cameFromMetadataSearch);
model.addAttribute("cameFromBookmarks", cameFromBookmarks);
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());
cameFromMetadataSearch = false;
cameFromFilePropertiesSearch = false;
cameFromBookmarks = false;
} catch (DataGridException | JargonException e) {
logger.error("Could not respond to request for collections: {}", e);
model.addAttribute("unexpectedError", true);
}
logger.info("returning to collections/collectionManagement");
return "collections/collectionManagement";
}
use of com.emc.metalnx.core.domain.exceptions.DataGridException in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method findByName.
@Override
public DataGridCollectionAndDataObject findByName(String path) throws FileNotFoundException, DataGridException {
logger.info("findByName()");
if (path == null || path.isEmpty()) {
logger.info("Could not find collection or data object by name: path is null");
return null;
}
logger.info("Find collection or data object by name: {}", path);
CollectionAndDataObjectListAndSearchAO objectsAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
DataGridCollectionAndDataObject dataGridCollectionAndDataObject;
try {
CollectionAndDataObjectListingEntry entry = objectsAO.getCollectionAndDataObjectListingEntryAtGivenAbsolutePathWithHeuristicPathGuessing(path);
dataGridCollectionAndDataObject = this.mapListingEntryToDataGridCollectionAndDataObject(entry);
} catch (FileNotFoundException fnf) {
logger.warn("file not found for path:{}", path);
throw fnf;
} catch (JargonException e) {
logger.debug("error finding collection/data object by name: {}", path);
throw new DataGridException("Could not find path " + path);
}
return dataGridCollectionAndDataObject;
}
Aggregations