@Override public boolean equals(Object o) { return (o instanceof UserProfile && id != null) ? id.equals(((UserProfile)o).getId()) : this == o; } @Override public int hashCode() { return (id != null) ? id.hashCode() : super.hashCode(); }
@Override public boolean equals(Object o) { return (o instanceof UserProfile && id != null) ? id.equals(((UserProfile)o).getId()) : this == o; } @Override public int hashCode() { return (id != null) ? id.hashCode() : super.hashCode(); }
@Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, userProfile.getId()); stm.setInt(2, bag.getSavedBagId()); return stm.executeUpdate(); } }
@Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, userProfile.getId()); stm.setInt(2, bag.getSavedBagId()); return stm.executeUpdate(); } }
@Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, bag.getId()); stm.setInt(2, sharedWith.getId()); return stm.executeUpdate(); } });
@Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, bag.getSavedBagId()); stm.setInt(2, sharedWith.getId()); return stm.executeUpdate(); } });
@Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, bag.getSavedBagId()); stm.setInt(2, sharedWith.getId()); return stm.executeUpdate(); } });
@Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, bag.getId()); stm.setInt(2, sharedWith.getId()); return stm.executeUpdate(); } });
/** * Constructor with the actual objects we are trying to link. * @param bag The SavedBag we are trying to share * @param up The UserProfile we are trying to share this with. */ public UserAlreadyShareBagException(SavedBag bag, UserProfile up) { super(String.format("This bag (%s:%d) is already shared with this user (%s:%d)", bag.getName(), bag.getId(), up.getUsername(), up.getId())); } }
/** * Constructor with the actual objects we are trying to link. * @param bag The SavedBag we are trying to share * @param up The UserProfile we are trying to share this with. */ public UserAlreadyShareBagException(SavedBag bag, UserProfile up) { super(String.format("This bag (%s:%d) is already shared with this user (%s:%d)", bag.getName(), bag.getId(), up.getUsername(), up.getId())); } }
throw new RuntimeException(format(UNSHARING_ERROR_MSG, bag.getName(), bag.getSavedBagId(), userProfile.getUsername(), userProfile.getId()), e);
profile.setUserId(userProfile.getId()); } catch (ObjectStoreException e) { throw new RuntimeException(e);
throw new RuntimeException(format(UNSHARING_ERROR_MSG, bag.getName(), bag.getSavedBagId(), userProfile.getUsername(), userProfile.getId()), e);
profile.setUserId(userProfile.getId()); } catch (ObjectStoreException e) { throw new RuntimeException(e);
private void storeShare(final InterMineBag bag, final UserProfile sharedWith) throws UserAlreadyShareBagException { final String userName = sharedWith.getUsername(); try { uosw.performUnsafeOperation(STORE_SHARE_SQL, new SQLOperation<Integer>() { @Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, bag.getSavedBagId()); stm.setInt(2, sharedWith.getId()); return stm.executeUpdate(); } }); } catch (SQLException e) { throw new UserAlreadyShareBagException("Error sharing the " + " the bag : " + bag.getSavedBagId() + " with the user " + sharedWith.getId(), e); } informProfileOfChange(userName, new CreationEvent(bag)); }
/** * Creates a profile in the userprofile database. * * @param profile a Profile object */ public synchronized void createProfile(Profile profile) { UserProfile userProfile = new UserProfile(); userProfile.setUsername(profile.getUsername()); userProfile.setLocalAccount(profile.isLocal()); if (profile.isLocal() && profile.getPassword() != null) { userProfile.setPassword(PasswordHasher.hashPassword(profile.getPassword())); } userProfile.setSuperuser(profile.isSuperUser); try { uosw.store(userProfile); profile.setUserId(userProfile.getId()); for (InterMineBag bag : profile.getSavedBags().values()) { bag.setProfileId(userProfile.getId()); } } catch (ObjectStoreException e) { throw new RuntimeException(e); } saveProfile(profile); }
private void storeShare(final InterMineBag bag, final UserProfile sharedWith) throws UserAlreadyShareBagException { final String userName = sharedWith.getUsername(); try { uosw.performUnsafeOperation(STORE_SHARE_SQL, new SQLOperation<Integer>() { @Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, bag.getSavedBagId()); stm.setInt(2, sharedWith.getId()); return stm.executeUpdate(); } }); } catch (SQLException e) { throw new UserAlreadyShareBagException("Error sharing the " + " the bag : " + bag.getSavedBagId() + " with the user " + sharedWith.getId(), e); } informProfileOfChange(userName, new CreationEvent(bag)); }
/** * Creates a profile in the userprofile database. * * @param profile a Profile object */ public synchronized void createProfile(Profile profile) { UserProfile userProfile = new UserProfile(); userProfile.setUsername(profile.getUsername()); userProfile.setLocalAccount(profile.isLocal()); if (profile.isLocal() && profile.getPassword() != null) { userProfile.setPassword(PasswordHasher.hashPassword(profile.getPassword())); } userProfile.setSuperuser(profile.isSuperUser); try { uosw.store(userProfile); profile.setUserId(userProfile.getId()); for (InterMineBag bag : profile.getSavedBags().values()) { bag.setProfileId(userProfile.getId()); } } catch (ObjectStoreException e) { throw new RuntimeException(e); } saveProfile(profile); }
/** * Creates a profile in the userprofile database without adding bag. * Method used by the ProfileReadXml. * * @param profile a Profile object */ public synchronized void createProfileWithoutBags(Profile profile) { UserProfile userProfile = new UserProfile(); userProfile.setUsername(profile.getUsername()); if (profile.getPassword() != null) { userProfile.setPassword(PasswordHasher.hashPassword(profile.getPassword())); } userProfile.setSuperuser(profile.isSuperUser); try { uosw.store(userProfile); profile.setUserId(userProfile.getId()); } catch (ObjectStoreException e) { throw new RuntimeException(e); } saveProfile(profile); }
/** * Creates a profile in the userprofile database without adding bag. * Method used by the ProfileReadXml. * * @param profile a Profile object */ public synchronized void createProfileWithoutBags(Profile profile) { UserProfile userProfile = new UserProfile(); userProfile.setUsername(profile.getUsername()); if (profile.getPassword() != null) { userProfile.setPassword(PasswordHasher.hashPassword(profile.getPassword())); } userProfile.setSuperuser(profile.isSuperUser); try { uosw.store(userProfile); profile.setUserId(userProfile.getId()); } catch (ObjectStoreException e) { throw new RuntimeException(e); } saveProfile(profile); }