Search in sources :

Example 1 with DataGridUserBookmark

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

the class UserBookmarkServiceImpl method findBookmarksForUserAsString.

@Override
public List<String> findBookmarksForUserAsString(DataGridUser user) {
    List<DataGridUserBookmark> bookmarks = userBookmarkDao.findByUser(user);
    List<String> strings = new ArrayList<String>();
    for (DataGridUserBookmark bookmark : bookmarks) {
        strings.add(bookmark.getPath());
    }
    return strings;
}
Also used : DataGridUserBookmark(com.emc.metalnx.core.domain.entity.DataGridUserBookmark) ArrayList(java.util.ArrayList)

Example 2 with DataGridUserBookmark

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

the class UserBookmarkDaoImpl method addByUserAndPath.

@Override
public Long addByUserAndPath(DataGridUser user, String path, boolean isCollection) {
    String parentPath = path.substring(0, path.lastIndexOf("/"));
    if (parentPath.isEmpty()) {
        parentPath = "/";
    }
    String fileName = path != null ? path : "";
    fileName = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length());
    DataGridUserBookmark bookmark = new DataGridUserBookmark();
    bookmark.setUser(user);
    bookmark.setPath(path);
    bookmark.setName(fileName);
    bookmark.setCreateTs(new Date());
    bookmark.setIsNotified(false);
    bookmark.setIsCollection(isCollection);
    return save(bookmark);
}
Also used : DataGridUserBookmark(com.emc.metalnx.core.domain.entity.DataGridUserBookmark) Date(java.util.Date)

Example 3 with DataGridUserBookmark

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

the class UserBookmarkDaoImpl method removeByPath.

@Override
public boolean removeByPath(String path) {
    logger.debug("Removing bookmarks by path: {} ", path);
    boolean removalSuccessful = false;
    try {
        List<DataGridUserBookmark> bookmarks = findBookmarksByPath(path);
        Iterator<DataGridUserBookmark> it = bookmarks.iterator();
        while (it.hasNext()) {
            DataGridUserBookmark 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 : DataGridUserBookmark(com.emc.metalnx.core.domain.entity.DataGridUserBookmark)

Example 4 with DataGridUserBookmark

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

the class UserBookmarkDaoImpl method removeByUserAndPath.

@Override
public boolean removeByUserAndPath(DataGridUser user, String path) {
    boolean operationResult = true;
    logger.info("Attempting to remove bookmark on {} from user {}", path, user.getUsername());
    try {
        DataGridUserBookmark bookmark = findByUserAndPath(user, path);
        delete(bookmark);
        logger.info("Successfully removed bookmark {} from user{}", path, user.getUsername());
    } catch (Exception e) {
        operationResult = false;
        logger.error("Could not remove bookmark on {} from user {}: {}", path, user.getUsername(), e.getMessage());
    }
    return operationResult;
}
Also used : DataGridUserBookmark(com.emc.metalnx.core.domain.entity.DataGridUserBookmark)

Example 5 with DataGridUserBookmark

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

the class UserBookmarkDaoImpl 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<DataGridUserBookmark> bookmarks = q.list();
        Iterator<DataGridUserBookmark> bookmarksIterator = bookmarks.iterator();
        while (bookmarksIterator.hasNext()) {
            DataGridUserBookmark 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 : DataGridUserBookmark(com.emc.metalnx.core.domain.entity.DataGridUserBookmark) Query(org.hibernate.Query)

Aggregations

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