public ResetPassword create(ResetPassword resetPassword) {
    return persistenceService.process(
        new ProcessFunc<ResetPassword, ResetPassword>(resetPassword) {
          @Override
          public ResetPassword process() {
            try {
              delete(input.getHandle(), conn);

              PreparedStatement insert =
                  conn.prepareStatement(
                      "INSERT INTO reset_password (handle, nonce, created) VALUES (?,?,?)");

              input.setCreated(new Date());
              insert.setString(1, input.getHandle());
              insert.setString(2, input.getNonce());
              insert.setTimestamp(3, new Timestamp(input.getCreated().getTime()));

              insert.execute();
            } catch (SQLException e) {
              throw new GeneralException(e);
            }

            return input;
          }
        });
  }
示例#2
0
  public List<Integer> getProfileIdsForOrganization(int organizationId) {
    return persistenceService.process(
        new RetrieveFunc<List<Integer>>(organizationId) {
          @Override
          protected List<Integer> retrieveConcrete() throws SQLException {
            PreparedStatement select =
                conn.prepareStatement(
                    "SELECT id FROM profile WHERE organization=? ORDER BY id DESC");
            select.setInt(1, input);

            ResultSet result = select.executeQuery();

            List<Integer> ids = new ArrayList<Integer>();
            while (result.next()) {
              ids.add(result.getInt(1));
            }

            return ids;
          }
        });
  }
  public ResetPassword getByCode(String code) {
    return persistenceService.process(
        new ProcessFunc<String, ResetPassword>(code) {
          @Override
          public ResetPassword process() {
            try {
              String query = "SELECT handle, created FROM reset_password WHERE nonce=?";

              PreparedStatement statement = conn.prepareStatement(query);
              statement.setString(1, input);

              ResultSet rs = statement.executeQuery();

              if (rs.next()) {
                return new ResetPassword(rs.getString(1), input, rs.getTimestamp(2));
              } else {
                return null;
              }
            } catch (SQLException e) {
              throw new GeneralException(e);
            }
          }
        });
  }
示例#4
0
 public void delete(int id) {
   persistenceService.process(new DeleteProfileByIdFunc(id));
 }
示例#5
0
 public Profile createProfile(Profile profile) {
   return persistenceService.process(new CreateProfileFunc(profile, this));
 }
示例#6
0
  public ProfileSummary create(Profile profile) {
    Profile savedProfile = persistenceService.process(new CreateProfileFunc(profile, this));

    return getProfileSummary(savedProfile.getId());
  }
示例#7
0
 public ProfileSummary getProfileByOrganization(int organizationId, int userId) {
   return persistenceService.process(
       new RetrieveProfileForOrganizationFunc(organizationId, userId));
 }
示例#8
0
 public ProfileSummary getProfileSummary(Integer profileId, Connection conn) {
   return persistenceService.process(conn, new RetrieveProfileSummaryFunc(profileId));
 }
示例#9
0
 public ProfileSummary getProfileSummary(Integer profileId) {
   return persistenceService.process(new RetrieveProfileSummaryFunc(profileId));
 }
示例#10
0
 @Override
 public Profile get(int id, Connection connection) {
   return persistenceService.process(connection, new RetrieveProfileFunc(id));
 }
示例#11
0
 @Override
 public Profile get(int id) {
   return persistenceService.process(new RetrieveProfileFunc(id));
 }
示例#12
0
 public Profile update(Profile profile) {
   return persistenceService.process(new UpdateProfileFunc(profile));
 }
 public void delete(String handle, Connection conn) {
   persistenceService.process(conn, deleteFunc(handle));
 }
 public void delete(String handle) {
   persistenceService.process(deleteFunc(handle));
 }