Search in sources :

Example 6 with DataGridGroupBookmark

use of com.emc.metalnx.core.domain.entity.DataGridGroupBookmark in project metalnx-web by irods-contrib.

the class GroupBookmarkDaoImpl method removeByParentPath.

@Override
public boolean removeByParentPath(String parentPath) {
    logger.debug("Removing bookmarks by relative path: {} ", parentPath);
    boolean removalSuccessful = false;
    try {
        Query q = sessionFactory.getCurrentSession().createQuery("from DataGridUserBookmark where path LIKE :path");
        q.setString("path", parentPath + "%");
        List<DataGridGroupBookmark> bookmarks = q.list();
        Iterator<DataGridGroupBookmark> bookmarksIterator = bookmarks.iterator();
        while (bookmarksIterator.hasNext()) {
            DataGridGroupBookmark currBookmark = bookmarksIterator.next();
            logger.debug("Removing relative bookmark {} from database", currBookmark.getPath());
            delete(currBookmark);
        }
    } catch (Exception e) {
        logger.error("Could not relative paths on bookmarks for path {} ", parentPath);
    }
    return removalSuccessful;
}
Also used : Query(org.hibernate.Query) DataGridGroupBookmark(com.emc.metalnx.core.domain.entity.DataGridGroupBookmark)

Example 7 with DataGridGroupBookmark

use of com.emc.metalnx.core.domain.entity.DataGridGroupBookmark in project metalnx-web by irods-contrib.

the class GroupBookmarkDaoImpl method removeByGroupAndPath.

@Override
public boolean removeByGroupAndPath(DataGridGroup group, String path) {
    boolean madeModifications = false;
    boolean operationResult = true;
    logger.info("Attempting to remove bookmark on {} from group {}", path, group.getGroupname());
    try {
        Iterator<DataGridGroupBookmark> it = group.getGroupBookmarks().iterator();
        while (it.hasNext()) {
            DataGridGroupBookmark bk = it.next();
            if (bk.getPath().compareTo(path) == 0) {
                madeModifications = true;
                it.remove();
            }
        }
        if (madeModifications) {
            logger.debug("Attempting to merge group entity [{}]", group.getId());
            groupDao.merge(group);
            logger.info("Successfully removed bookmark {} from group{}", path, group.getGroupname());
        }
    } catch (Exception e) {
        operationResult = false;
        logger.error("Could not remove bookmark on {} from group {}", path, group.getGroupname(), e);
    }
    return operationResult;
}
Also used : DataGridGroupBookmark(com.emc.metalnx.core.domain.entity.DataGridGroupBookmark)

Example 8 with DataGridGroupBookmark

use of com.emc.metalnx.core.domain.entity.DataGridGroupBookmark in project metalnx-web by irods-contrib.

the class GroupBookmarkDaoImpl method removeByPath.

@Override
public boolean removeByPath(String path) {
    logger.debug("Removing bookmarks by path: {} ", path);
    boolean removalSuccessful = false;
    try {
        List<DataGridGroupBookmark> bookmarks = findBookmarksByPath(path);
        Iterator<DataGridGroupBookmark> it = bookmarks.iterator();
        while (it.hasNext()) {
            DataGridGroupBookmark bookmark = it.next();
            logger.debug("Removing bookmark {} from database", bookmark.getPath());
            delete(bookmark);
        }
        removalSuccessful = true;
    } catch (Exception e) {
        logger.error("Could not remove bookmark for path {} ", path);
    }
    return removalSuccessful;
}
Also used : DataGridGroupBookmark(com.emc.metalnx.core.domain.entity.DataGridGroupBookmark)

Aggregations

DataGridGroupBookmark (com.emc.metalnx.core.domain.entity.DataGridGroupBookmark)8 ArrayList (java.util.ArrayList)4 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)2 JargonException (org.irods.jargon.core.exception.JargonException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)1 DataGridFilePermission (com.emc.metalnx.core.domain.entity.DataGridFilePermission)1 DataGridGroupPermission (com.emc.metalnx.core.domain.entity.DataGridGroupPermission)1 DataGridUserBookmark (com.emc.metalnx.core.domain.entity.DataGridUserBookmark)1 DataGridUserPermission (com.emc.metalnx.core.domain.entity.DataGridUserPermission)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Query (org.hibernate.Query)1 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)1 UserAO (org.irods.jargon.core.pub.UserAO)1 User (org.irods.jargon.core.pub.domain.User)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1