use of com.emc.metalnx.core.domain.entity.DataGridUserFavorite in project metalnx-web by irods-contrib.
the class FavoriteDaoImpl method removeByPath.
@Override
public boolean removeByPath(String path) {
logger.debug("Removing favorite by path: {} ", path);
boolean removalSuccessful = false;
try {
List<DataGridUserFavorite> favorites = findFavoritesByPath(path);
Iterator<DataGridUserFavorite> it = favorites.iterator();
while (it.hasNext()) {
DataGridUserFavorite favorite = it.next();
logger.debug("Removing favorite {} from database", favorite.getPath());
delete(favorite);
}
removalSuccessful = true;
} catch (Exception e) {
logger.error("Could not remove favorite for path {} ", path);
}
return removalSuccessful;
}
use of com.emc.metalnx.core.domain.entity.DataGridUserFavorite in project metalnx-web by irods-contrib.
the class FavoriteDaoImpl method removeByUserAndPath.
@Override
public boolean removeByUserAndPath(DataGridUser user, String path) {
boolean operationResult = true;
logger.info("Attempting to remove favorite on {} from user {}", path, user.getUsername());
try {
DataGridUserFavorite favorite = findByUserAndPath(user, path);
delete(favorite);
logger.info("Successfully removed favorite {} from user{}", path, user.getUsername());
} catch (Exception e) {
operationResult = false;
logger.error("Could not remove favorite on {} from user {}: {}", path, user.getUsername(), e.getMessage());
}
return operationResult;
}
use of com.emc.metalnx.core.domain.entity.DataGridUserFavorite in project metalnx-web by irods-contrib.
the class FavoriteDaoImpl 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.substring(path.lastIndexOf("/") + 1, path.length()) : "";
DataGridUserFavorite favorite = new DataGridUserFavorite();
favorite.setUser(user);
favorite.setPath(path);
favorite.setPathHash(path.hashCode());
favorite.setName(fileName);
favorite.setCreateTs(new Date());
favorite.setIsCollection(isCollection);
return save(favorite);
}
use of com.emc.metalnx.core.domain.entity.DataGridUserFavorite in project metalnx-web by irods-contrib.
the class FavoriteDaoImpl method findByUserAndPath.
@Override
public DataGridUserFavorite findByUserAndPath(DataGridUser user, String path) {
if (user == null || path == null || path.isEmpty())
return null;
Query q = sessionFactory.getCurrentSession().createQuery("from DataGridUserFavorite where user_id = :user_id and path = :path");
q.setLong("user_id", user.getId());
q.setString("path", path);
return (DataGridUserFavorite) q.uniqueResult();
}
Aggregations