@Test public void testSetTitle() throws Exception { SqlWorkspace sqlWorkspace = (SqlWorkspace) sqlWorkspaceRepository.add("test", testUser); assertEquals("test", sqlWorkspace.getDisplayTitle()); sqlWorkspaceRepository.setTitle(sqlWorkspace, "changed title", testUser); SqlWorkspace modifiedWorkspace = (SqlWorkspace) sqlWorkspaceRepository.findById(sqlWorkspace.getWorkspaceId(), testUser); assertEquals("changed title", modifiedWorkspace.getDisplayTitle()); }
@Override public void setTitle(Workspace workspace, String title, User user) { Session session = sessionManager.getSession(); if (!hasWritePermissions(workspace.getWorkspaceId(), user)) { throw new LumifyAccessDeniedException("user " + user.getUserId() + " does not have write access to workspace " + workspace.getWorkspaceId(), user, workspace.getWorkspaceId()); } Transaction transaction = null; try { transaction = session.beginTransaction(); ((SqlWorkspace) workspace).setDisplayTitle(title); session.update(workspace); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new RuntimeException(e); } }
SqlWorkspaceRepository extends WorkspaceRepository { @Override public void setTitle(Workspace workspace, String title, User user) { Session session = sessionManager.getSession(); if (!hasWritePermissions(workspace.getWorkspaceId(), user)) { throw new LumifyAccessDeniedException("user " + user.getUserId() + " does not have write access to workspace " + workspace.getWorkspaceId(), user, workspace.getWorkspaceId()); } Transaction transaction = null; try { transaction = session.beginTransaction(); ((SqlWorkspace) workspace).setDisplayTitle(title); session.update(workspace); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new RuntimeException(e); } } }
SqlWorkspaceRepository extends WorkspaceRepository { @Override public void setTitle(Workspace workspace, String title, User user) { Session session = sessionManager.getSession(); if (!hasWritePermissions(workspace.getWorkspaceId(), user)) { throw new LumifyAccessDeniedException("user " + user.getUserId() + " does not have write access to workspace " + workspace.getWorkspaceId(), user, workspace.getWorkspaceId()); } Transaction transaction = null; try { transaction = session.beginTransaction(); ((SqlWorkspace) workspace).setDisplayTitle(title); session.update(workspace); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new RuntimeException(e); } } @Inject  SqlWorkspaceRepository(final SqlUserRepository userRepository, final HibernateSessionManager sessionManager,
                                  final Graph graph); }
SqlWorkspaceRepository extends WorkspaceRepository { @Override public void setTitle(Workspace workspace, String title, User user) { Session session = sessionManager.getSession(); if (!hasWritePermissions(workspace.getWorkspaceId(), user)) { throw new LumifyAccessDeniedException("user " + user.getUserId() + " does not have write access to workspace " + workspace.getWorkspaceId(), user, workspace.getWorkspaceId()); } Transaction transaction = null; try { transaction = session.beginTransaction(); ((SqlWorkspace) workspace).setDisplayTitle(title); session.update(workspace); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new RuntimeException(e); } } @Inject  SqlWorkspaceRepository(final SqlUserRepository userRepository, final HibernateSessionManager sessionManager,
                                  final Graph graph); @Override void delete(Workspace workspace, User user); @Override Workspace findById(String workspaceId, boolean includeHidden, User user); @Override Workspace add(String workspaceId, String title, User user); @Override Iterable<Workspace> findAllForUser(User user); @Override void setTitle(Workspace workspace, String title, User user); @Override List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user); @Override List<WorkspaceEntity> findEntities(Workspace workspace, User user); @Override void softDeleteEntitiesFromWorkspace(Workspace workspace, List<String> entityIdsToDelete, User authUser); @Override void updateEntitiesOnWorkspace(Workspace workspace, Iterable<Update> updates, User user); @Override void deleteUserFromWorkspace(Workspace workspace, String userId, User user); @Override void updateUserOnWorkspace(Workspace workspace, String userId, WorkspaceAccess workspaceAccess, User user); @Override ClientApiWorkspaceDiff getDiff(Workspace workspace, User user, Locale locale, String timeZone); @Override boolean hasCommentPermissions(String workspaceId, User user); @Override boolean hasWritePermissions(String workspaceId, User user); @Override boolean hasReadPermissions(String workspaceId, User user); }
SqlWorkspaceRepository extends WorkspaceRepository { @Override public void setTitle(Workspace workspace, String title, User user) { Session session = sessionManager.getSession(); if (!hasWritePermissions(workspace.getWorkspaceId(), user)) { throw new LumifyAccessDeniedException("user " + user.getUserId() + " does not have write access to workspace " + workspace.getWorkspaceId(), user, workspace.getWorkspaceId()); } Transaction transaction = null; try { transaction = session.beginTransaction(); ((SqlWorkspace) workspace).setDisplayTitle(title); session.update(workspace); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new RuntimeException(e); } } @Inject  SqlWorkspaceRepository(final SqlUserRepository userRepository, final HibernateSessionManager sessionManager,
                                  final Graph graph); @Override void delete(Workspace workspace, User user); @Override Workspace findById(String workspaceId, boolean includeHidden, User user); @Override Workspace add(String workspaceId, String title, User user); @Override Iterable<Workspace> findAllForUser(User user); @Override void setTitle(Workspace workspace, String title, User user); @Override List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user); @Override List<WorkspaceEntity> findEntities(Workspace workspace, User user); @Override void softDeleteEntitiesFromWorkspace(Workspace workspace, List<String> entityIdsToDelete, User authUser); @Override void updateEntitiesOnWorkspace(Workspace workspace, Iterable<Update> updates, User user); @Override void deleteUserFromWorkspace(Workspace workspace, String userId, User user); @Override void updateUserOnWorkspace(Workspace workspace, String userId, WorkspaceAccess workspaceAccess, User user); @Override ClientApiWorkspaceDiff getDiff(Workspace workspace, User user, Locale locale, String timeZone); @Override boolean hasCommentPermissions(String workspaceId, User user); @Override boolean hasWritePermissions(String workspaceId, User user); @Override boolean hasReadPermissions(String workspaceId, User user);  }