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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations