Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moving bbsignup to mavne arch

  • Loading branch information...
commit 7779ed597e9f3791dcb440d4244af6e2e354e926 1 parent b865c90
Jared Williams authored
Showing with 473 additions and 993 deletions.
  1. +19 −7 BBSignup/WebContent/authenticate.jsp
  2. +0 −13 BBSignup/WebContent/cancel.jsp
  3. +0 −126 BBSignup/WebContent/css/nys.css
  4. +0 −46 BBSignup/WebContent/css/style.css
  5. +15 −15 BBSignup/WebContent/delete.jsp
  6. +29 −19 BBSignup/WebContent/footer.jsp
  7. +0 −39 BBSignup/WebContent/header.jsp
  8. BIN  BBSignup/WebContent/img/nys_favicon_0.ico
  9. +143 −44 BBSignup/WebContent/index.jsp
  10. +0 −87 BBSignup/WebContent/js.js
  11. +0 −92 BBSignup/WebContent/js/js.js
  12. +17 −5 BBSignup/WebContent/message.jsp
  13. +0 −22 BBSignup/WebContent/nfooter.jsp
  14. +16 −6 BBSignup/WebContent/notice.jsp
  15. +0 −126 BBSignup/WebContent/nys.css
  16. +91 −0 BBSignup/WebContent/process.jsp
  17. +16 −6 BBSignup/WebContent/style.css
  18. +28 −13 BBSignup/WebContent/unsubscribe.jsp
  19. +27 −14 BBSignup/WebContent/update.jsp
  20. +0 −133 BBSignup/src/bbsignup/model/OldSenator.java
  21. +26 −3 BBSignup/src/bbsignup/model/Senator.java
  22. +1 −12 BBSignup/src/bbsignup/model/User.java
  23. +10 −2 BBSignup/src/bbsignup/model/UserAuth.java
  24. +4 −64 BBSignup/src/bbsignup/src/Controller.java
  25. +0 −23 BBSignup/src/bbsignup/src/PMF.java
  26. +25 −71 BBSignup/src/collect/NYSenateServices.java
  27. +5 −5 BBSignup/src/servlets/MainServlet.java
  28. +1 −0  BBSignup/src/servlets/SenatorContext.java
View
26 BBSignup/WebContent/authenticate.jsp
@@ -1,7 +1,18 @@
-<%@ page language="java" import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"%>
-<jsp:include page="header.jsp" />
-<div id="main">
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"
+ import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
+ %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<link rel="stylesheet" type="text/css" media="screen" href="style.css"/>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>BillBuzz! Authentication</title>
+</head>
+<body>
<center>
+<br/>
<%
String email = request.getParameter("email");
@@ -13,7 +24,7 @@
if(c.authenticateUser(email,key) == true) {
%>
<div class="good" style="width:500px;">
- Success! Thanks for signing up. You'll start receiving BillBuzz updates within the next 24 hours.
+ Success! Thanks for signing up, you'll start receiving BillBuzz updates within the next 24 hours.
<br/><br/>
Redirecting to nysenate.gov in 10 seconds...
<meta http-equiv="Refresh" content="10; URL=http://www.nysenate.gov">
@@ -43,12 +54,13 @@
else {
%>
- <jsp:forward page="/" />
+ <jsp:forward page="index.jsp" />
<%
}
%>
+<%@ include file="footer.jsp" %>
</center>
-</div>
-<%@ include file="footer.jsp"%>
+</body>
+</html>
View
13 BBSignup/WebContent/cancel.jsp
@@ -1,13 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
-<%
- session.setAttribute("subs", null);
- session.setAttribute("fn", null);
- session.setAttribute("ln", null);
- session.setAttribute("e", null);
- session.setAttribute("oldemail", null);
- session.setAttribute("update", null);
-
-%>
-
-<jsp:forward page="/" />
View
126 BBSignup/WebContent/css/nys.css
@@ -1,126 +0,0 @@
-html,body,div,ul,li {
- margin: 0px;
- padding: 0px;
-}
-
-html,body {
- width: 100%;
-}
-
-.clear {
- clear: both;
-}
-
-body {
- color: #012849;
- /*font-family: Times New Roman, serif;*/
- font-family: helvetica, arial;
- font-size: 89.5%; /* 10px */
-
- background:url(http://www.nysenate.gov/sites/all/themes/nys/images/nyss_bg.png) top left repeat-x;
-}
-
-#page {
- width: 877px;
- margin: 0 auto;
- background: #E2DED5;
-}
-
-#header {
- background:
- url(http://www.nysenate.gov/sites/all/themes/nys/images/header.png)
- top left no-repeat;
- padding: 16px 0px 0px 0px;
- height: 77px;
-}
-
-#logo {
- width: 250px;
- height: 55px;
- margin-top: 16px 0px 0px 5px;
- border: 0px;
-}
-
-#welcome {
- color: white;
- font-weight: bold;
-}
-
-#nav_bar {
- color: white;
- background:
- url(http://www.nysenate.gov/sites/all/themes/nys/images/nyss_menu_bg.png)
- top left repeat-x;
- line-height: 30px;
- font-family: Helvetica, Arial, sans-serif;
-}
-
-#nav_bar a:link {
- color: white;
- font-weight: bold;
- text-decoration: none;
-}
-
-#nav_bar a:visited {
- color: white;
- font-weight: bold;
- text-decoration: none;
-}
-
-#nav_bar a:hover {
- text-decoration: underline;
-}
-
-#nav_bar a:focus {
-
-}
-
-#nav_bar a:active {
-
-}
-
-#nav_bar ul {
- display: inline;
- list-icon-style: none;
- padding-left: 10px;
-}
-
-#nav_bar li {
- display: inline;
-}
-
-.sep {
- padding: 0px 10px;
- display: inline;
-}
-
-#error {
- text-align: center;
- color: red;
-}
-
-.entity_button {
- display: inline;
-}
-
-.entity_title {
- display: inline;
- font-weight: bold;
-}
-
-
-#main {
- margin-top: 5px;
- margin: 20px;
- padding: 20px;
- padding-top: 5px;
- background: #ffffff
- url(http://www.nysenate.gov/sites/all/themes/nys/images/nyss_block_footer_bg.png)
- repeat-x bottom left;
-}
-
-h2 {
- font-family: arial, serif;
- text-transform: uppercase;
- text-align: left;
-}
View
46 BBSignup/WebContent/css/style.css
@@ -1,46 +0,0 @@
-
-.bad {
- color:black;
- border:1px solid #FF3300;
- margin:1em auto;
- border-collapse:collapse;
- background-color: #FECCBF;
-}
-
-.foot {
- border-collapse:collapse;
- font-size:85%;
- align:center;
-}
-
-.good {
- border-collapse:collapse;
- border:1px solid #009999;
- background-color: #BFFFFE;
-}
-
-.bb_main {
- border-collapse:collapse;
- border:1px solid #B2A100;
- background-color: #FEF9BF;
- width:800px;
- position:75px;
- left:15%;
-}
-
-A:visited {
- color: blue;
-}
-
-.notice
-{
- background-color:#ffffcc;
- color:#555;
- padding:3px;
- font-size:80%;
- border:1px solid #aaaaaa;
- text-align:center;
-
-}
-
-
View
30 BBSignup/WebContent/delete.jsp
@@ -1,9 +1,17 @@
-<%@ page language="java" import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"
+ import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
%>
-
-<jsp:include page="header.jsp" />
-<div id="main">
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<link rel="stylesheet" type="text/css" media="screen" href="style.css"/>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+</head>
+<body>
<center>
+<br/>
<%
String email = (String)request.getParameter("email");
String key = (String)request.getParameter("key");
@@ -19,15 +27,6 @@
</div>
<%
}
- else {
- %>
- <div class="bad" style="width:500px;">
- There was an error authenticating your request.
- <br/><br/>
- Please <a href="mailto:billbuzz@nysenate.gov">contact us</a> if you are having trouble.
- </div>
- <%
- }
}
@@ -45,6 +44,7 @@
%>
+<%@ include file="footer.jsp" %>
</center>
-</div>
-<%@ include file="footer.jsp"%>
+</body>
+</html>
View
48 BBSignup/WebContent/footer.jsp
@@ -1,20 +1,30 @@
- </div>
- <center><div class="foot">
- <table cellpadding=5>
- <tr>
- <td>
- <a href="index.jsp">BillBuzz Home</a>
-
- </td>
- <td align="center">
- </td>
- <td align = "right">
- <a href="http://www.nysenate.gov">NYSenate.gov</a>
- </td>
- </tr>
- </table>
- </div></center>
- </body>
-</html>
-
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"
+ import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
+ %>
+<br/><br/>
+<div class="foot">
+ <table>
+ <tr>
+ <td>Already Subscribed?</td>
+ <td><a href="update.jsp">Update</a> or </td>
+ <td><a href="unsubscribe.jsp">Unsubscribe</a></td>
+ </tr>
+ </table>
+ <table cellpadding=5>
+ <tr>
+ <td>
+ <a href="index.jsp">Home</a>
+
+ </td>
+ <td align="center">
+ <a href="http://www.nysenate.gov">NYSenate.gov</a>
+
+ </td>
+ <td align = "right">
+ <a href="mailto:billbuzz@nysenate.gov">Contact</a>
+ </td>
+ </tr>
+ </table>
+</div>
View
39 BBSignup/WebContent/header.jsp
@@ -1,39 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
-<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>NYSS BillBuzz</title>
- <link rel="shortcut icon" href="img/nys_favicon_0.ico" />
- <link rel="stylesheet" type="text/css" href="/BBSignup/css/style.css" />
- <link rel="stylesheet" type="text/css" href="/BBSignup/css/nys.css" />
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
- <script type="text/javascript" src="/BBSignup/js/js.js"></script>
- </head>
- <body>
- <div id="page">
- <div id="header">
- <a href="http://www.nysenate.gov">
- <img src="http://www.nysenate.gov/sites/all/themes/nys/images/nyss_logo.png" id="logo" />
- </a>
-
- </div>
-
- <div id="nav_bar">
- Already subscribed?
- <ul>
- <li><a href="update.jsp">Update</a></li>
- <li>or</li>
- <li><a href="unsubscribe.jsp">Unsubscribe</a></li>
- </ul>
- </div>
-
- <div class="notice">
- BillBuzz is currently in "beta" and may occasionally offer incorrect data.
- Please give us your feedback at
- <a href="http://www.nysenate.gov/contact">http://www.nysenate.gov/contact</a>.
- </div>
-
-
-
View
BIN  BBSignup/WebContent/img/nys_favicon_0.ico
Binary file not shown
View
187 BBSignup/WebContent/index.jsp
@@ -1,23 +1,120 @@
-<%@ page contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1" language="java" import="servlets.SenatorContext,java.util.*,bbsignup.src.*,bbsignup.model.Senator"%>
- <jsp:include page="header.jsp" />
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"
+ import="servlets.SenatorContext,java.util.*,bbsignup.src.*,bbsignup.model.Senator,javax.jdo.*"%>
<%
+
List<Senator> list = (List<Senator>)SenatorContext.getSenators(this.getServletContext());;
%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
+<script type="text/javascript"
+ src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
+<script type="text/javascript">
+
+function addError(message, msg) {
+ if(message == "") {
+ return msg;
+ }
+ else {
+ return message += "<br>" + msg;
+ }
+}
+ $(document).ready(
+ function() {
+ /*reset = function() {
+ $('.cb_').each(function() {
+ doCheck(this, $(this).attr('party'));
+ });
+ };*/
+
+ doCheck = function(curSelector, party) {
+ if (!$('#cb_all').is(':checked')) {
+ $('.senator').each(function(index) {
+ var parties = $($('.party').get(index)).html();
+
+ var check = $(this).children("INPUT[type='checkbox']");
+
+ var re = new RegExp('(\\(|\\- )' + party
+ + '(\\)| \\-)');
+ if (parties.match(re)) {
+ $(check).attr('checked',
+ $(curSelector).is(':checked'));
+ }
+ });
+ }
+ };
+
+ clearAll = function() {
+ $("INPUT[type='checkbox']").attr('checked', false);
+ };
+
+ $('#cb_all').change(
+ function() {
+ $("INPUT[type='checkbox']").attr('checked',
+ $('#cb_all').is(':checked'));
+ });
+
+ $('.cb_').change(function() {
+ doCheck(this, $(this).attr('party'));
+ //reset();
+ });
+
+ $('#process').click(function(event) {
+
+
+ message = "";
+ e1 = document.forms.senators.email1.value;
+ e2 = document.forms.senators.email2.value;
+ fn = document.forms.senators.firstname.value;
+ ln = document.forms.senators.lastname.value;
+
+ if(!fn){
+ message = addError(message, "Enter your first name");
+ }
+ if(!ln) {
+ message = addError(message, "Enter your last name");
+ }
+ if(e1 == null || e2 == null || e1 != e2) {
+ message = addError(message, "Your email addresses must match!");
+ }
+ else {
+ if(!e1.match(/.*?@.*?\..*?/)) {
+ message = addError(message, "Enter a valid email address");
+ }
+ }
+
+ if(message != "") {
+ $("#error").html(message);
+ $("#error").css({'display' : 'inherit'});
+ $('html,body').animate({
+ scrollTop:$("#error").offset().top}, 500);
+ return false;
+ }
+ else {
+ return true;
+
+ }
+
+ });
+
+ });
+
+</script>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Sign up for BillBuzz!</title>
+</head>
+<body>
+
<center>
-<div id="main">
<%
String update = (String) session.getAttribute("update");
String fn = (String) session.getAttribute("fn");
String ln = (String) session.getAttribute("ln");
String e1 = (String) session.getAttribute("e");
- String otherData = (String) session.getAttribute("otherData");
List<String> subs = (List<String>) session.getAttribute("subs");
-
- if(otherData == null) {
- otherData ="";
- }
-
if (update != null) {
if (update.equals("update")) {
@@ -27,9 +124,6 @@
<tr>
<td>Changes will be saved when you click Submit.</td>
</tr>
- <tr>
- <td align=center><a href="cancel.jsp">Click here to cancel your update</a></td>
- </tr>
</table>
</div>
<%
@@ -41,7 +135,6 @@
session.setAttribute("ln", null);
session.setAttribute("e", null);
session.setAttribute("update", null);
- session.setAttribute("subs", null);
}
if(subs != null && subs.size() == 0) {
%>
@@ -62,9 +155,11 @@
<form id="inputForm" name="senators" method="post"
action="subscribe">
+
+
<h2>What is BillBuzz?</h2>
-<div class="bb_main">
+<div class="main">
<table>
<tr>
<td>
@@ -86,9 +181,9 @@
</div>
<div id ="error" class="bad" style="font-size: 85%; width: 40%;display:none;"></div>
-<h2>Sign Up</h2>
+<h2 style="left: -385px">Sign Up</h2>
<p></p>
-<div class="bb_main"><br>
+<div class="main"><br>
<table>
<tr>
<td>First name</td>
@@ -117,24 +212,30 @@
<tr>
<td><input id="cb_all" name="cb_all" type="checkbox"></input></td>
<td>All</td>
+
<td><input class="cb_" party="D" type="checkbox"></input></td>
- <td>Democratic</td>
+ <td>Democrat</td>
+
<td><input class="cb_" party="R" type="checkbox"></input></td>
<td>Republican</td>
- </tr>
- <tr>
- <td><input class="cb_" party="IP" type="checkbox"></input></td>
- <td>Independence</td>
+
<td><input class="cb_" party="C" type="checkbox"></input></td>
<td>Conservative</td>
- <td><input class="cb_" party="WF" type="checkbox"></input></td>
- <td>Working Families</td>
-
+ </tr>
+ <td><input class="cb_" party="WF" type="checkbox"></input></td>
+ <td>Working Family</td>
+
+ <td><input class="cb_" party="IND" type="checkbox"></input></td>
+ <td>Independent</td>
+ <td><input class="cb_" party="IP" type="checkbox"></input></td>
+ <td>Independence Party</td>
+
+ <td><input class="cb_" party="I" type="checkbox"></input></td>
+ <td>Independent Party</td>
</tr>
</table>
<br />
-<div style="position:relative;right:-7px;">
<table cellpadding=3>
<%%>
<tr>
@@ -166,7 +267,7 @@
}
}
%>
- <div class="senator"><input class="sen_" type="checkbox"
+ <div class="senator"><input type="checkbox"
name="<%=s.getOpenLegName()%>"
<%=((tog == true) ? "checked=\"yes\"" : "")%>></input></div>
<%
@@ -175,7 +276,7 @@
</td>
<td><a target="_blank" href="<%=s.getUrl()%>"><%=s.getName()%></a>
- <div class="party" style="font-size: 75%;" pl="(<%=s.getParty().toUpperCase()%>)"></div>
+ <div class="party" style="font-size: 75%;">(<%=s.getParty().toUpperCase()%>)</div>
</td>
<%
@@ -186,27 +287,25 @@
<%%>
<tr></tr>
+ <tr></tr>
<tr>
- <td colspan=8>
- <p>Would you like to receive updates for data where the sponsor can't be determined?
- <select name="otherData">
- <option <%=otherData.equals("yes")?"SELECTED":"" %>>Yes</option>
- <option <%=otherData.equals("no")?"SELECTED":"" %>>No</option>
- </select>
- </p>
- </td>
<td></td>
<td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td><input type="button" name="clear" value="Clear Selection"
+ onClick="clearAll()"></input></td>
+ <td></td>
+ <td><input type="submit" id="process" name="submit"></input></td>
</tr>
-</table>
-<div style="position:right;right:250px;"><input type="button" name="clear" value="Clear Selection"
- onClick="clearAll()"></input>
- <input type="submit" id="process" name="submit" value="Sign up"></input></td><div>
-</div>
+</table>
</div>
</form>
-</div>
-</center>
-<%@ include file="footer.jsp"%>
+<%@ include file="footer.jsp"%></center>
+</body>
+</html>
View
87 BBSignup/WebContent/js.js
@@ -1,87 +0,0 @@
-function addError(message, msg) {
- if(message == "") {
- return msg;
- }
- else {
- return message += "<br>" + msg;
- }
-}
- $(document).ready(
- function() {
- /*reset = function() {
- $('.cb_').each(function() {
- doCheck(this, $(this).attr('party'));
- });
- };*/
-
- doCheck = function(curSelector, party) {
- if (!$('#cb_all').is(':checked')) {
- $('.senator').each(function(index) {
- var parties = $($('.party').get(index)).html();
-
- var check = $(this).children("INPUT[type='checkbox']");
-
- var re = new RegExp('(\\(|\\- )' + party
- + '(\\)| \\-)');
- if (parties.match(re)) {
- $(check).attr('checked',
- $(curSelector).is(':checked'));
- }
- });
- }
- };
-
- clearAll = function() {
- $("INPUT[type='checkbox']").attr('checked', false);
- };
-
- $('#cb_all').change(
- function() {
- $("INPUT[type='checkbox']").attr('checked',
- $('#cb_all').is(':checked'));
- });
-
- $('.cb_').change(function() {
- doCheck(this, $(this).attr('party'));
- //reset();
- });
-
- $('#process').click(function(event) {
-
-
- message = "";
- e1 = document.forms.senators.email1.value;
- e2 = document.forms.senators.email2.value;
- fn = document.forms.senators.firstname.value;
- ln = document.forms.senators.lastname.value;
-
- if(!fn){
- message = addError(message, "Enter your first name");
- }
- if(!ln) {
- message = addError(message, "Enter your last name");
- }
- if(e1 == null || e2 == null || e1 != e2) {
- message = addError(message, "Your email addresses must match!");
- }
- else {
- if(!e1.match(/.*?@.*?\..*?/)) {
- message = addError(message, "Enter a valid email address");
- }
- }
-
- if(message != "") {
- $("#error").html(message);
- $("#error").css({'display' : 'inherit'});
- $('html,body').animate({
- scrollTop:$("#error").offset().top}, 500);
- return false;
- }
- else {
- return true;
-
- }
-
- });
-
- });
View
92 BBSignup/WebContent/js/js.js
@@ -1,92 +0,0 @@
-function addError(message, msg) {
- if(message == "") {
- return msg;
- }
- else {
- return message += "<br>" + msg;
- }
-}
-$(document).ready(function() {
- reset = function() {
- $('.cb_').each(function() {
- if($(this).is(':checked')) {
- doCheck(this, $(this).attr('party'));
- }
- });
- };
-
- doCheck = function(curSelector, party) {
- if($('#cb_all').is(':checked') && !$(this).is(':checked')) {
- $('#cb_all').attr('checked',false);
- }
-
- $('.senator').each(function(index) {
- //var parties = $($('.party').get(index)).html();
- var parties = $($('.party').get(index)).attr('pl');
-
- var check = $(this).children("INPUT[type='checkbox']");
-
- var re = new RegExp('(\\(|\\- )' + party
- + '(\\)| \\-)');
- if (parties.match(re)) {
- $(check).attr('checked',
- $(curSelector).is(':checked'));
- }
- });
- };
-
- clearAll = function() {
- $("INPUT[type='checkbox']").attr('checked', false);
- };
-
- $('#cb_all').change(
- function() {
- $("INPUT[type='checkbox']").attr('checked',
- $('#cb_all').is(':checked'));
- });
-
- $('.cb_').change(function() {
- doCheck(this, $(this).attr('party'));
- reset();
- });
-
- $('.sen_').change(function() {
- if($('#cb_all').is(':checked') && !$(this).is(':checked')) {
- $('#cb_all').attr('checked',false);
- }
- });
-
- $('#process').click(function(event) {
- message = "";
- e1 = document.forms.senators.email1.value;
- e2 = document.forms.senators.email2.value;
- fn = document.forms.senators.firstname.value;
- ln = document.forms.senators.lastname.value;
-
- if(!fn){
- message = addError(message, "Enter your first name");
- }
- if(!ln) {
- message = addError(message, "Enter your last name");
- }
- if(e1 == null || e2 == null || e1 != e2) {
- message = addError(message, "Your email addresses must match!");
- }
- else {
- if(!e1.match(/.*?@.*?\..*?/)) {
- message = addError(message, "Enter a valid email address");
- }
- }
-
- if(message != "") {
- $("#error").html(message);
- $("#error").css({'display' : 'inherit'});
- $('html,body').animate({
- scrollTop:$("#error").offset().top}, 500);
- return false;
- }
- else {
- return true;
- }
- });
-});
View
22 BBSignup/WebContent/message.jsp
@@ -1,8 +1,18 @@
-<%@ page language="java" import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"
+ import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
%>
-<jsp:include page="header.jsp" />
-<div id="main">
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<link rel="stylesheet" type="text/css" media="screen" href="style.css"/>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>BillBuzz! Processing request...</title>
+</head>
+<body>
<center>
+<br/>
<%
String message = (String)session.getAttribute("message");
@@ -17,6 +27,8 @@
%>
+
+<%@ include file="footer.jsp" %>
</center>
-</div>
-<%@ include file="footer.jsp"%>
+</body>
+</html>
View
22 BBSignup/WebContent/nfooter.jsp
@@ -1,22 +0,0 @@
- </div>
- <center><div class="foot">
- <table cellpadding=5>
- <tr>
- <td>
- <a href="index.jsp">Home</a>
-
- </td>
- <td align="center">
- <a href="http://www.nysenate.gov">NYSenate.gov</a>
-
- </td>
- <td align = "right">
- <a href="mailto:billbuzz@nysenate.gov">Contact</a>
- </td>
- </tr>
- </table>
- </div></center>
- </body>
-</html>
-
-
View
22 BBSignup/WebContent/notice.jsp
@@ -1,7 +1,16 @@
-<%@ page language="java" import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"
+ import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
%>
-<jsp:include page="header.jsp" />
-<div id="main">
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<link rel="stylesheet" type="text/css" media="screen" href="style.css"/>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>BillBuzz! Notice</title>
+</head>
+<body>
<center>
<%
@@ -70,13 +79,14 @@
%>
- <jsp:forward page="/" />
+ <jsp:forward page="index.jsp" />
<%
}
%>
+<%@ include file="footer.jsp" %>
</center>
-</div>
-<%@ include file="footer.jsp"%>
+</body>
+</html>
View
126 BBSignup/WebContent/nys.css
@@ -1,126 +0,0 @@
-html,body,div,ul,li {
- margin: 0px;
- padding: 0px;
-}
-
-html,body {
- width: 100%;
-}
-
-.clear {
- clear: both;
-}
-
-body {
- color: #012849;
- /*font-family: Times New Roman, serif;*/
- font-family: helvetica, arial;
- font-size: 89.5%; /* 10px */
-
- background:url(http://www.nysenate.gov/sites/all/themes/nys/images/nyss_bg.png) top left repeat-x;
-}
-
-#page {
- width: 877px;
- margin: 0 auto;
- background: #E2DED5;
-}
-
-#header {
- background:
- url(http://www.nysenate.gov/sites/all/themes/nys/images/header.png)
- top left no-repeat;
- padding: 16px 0px 0px 0px;
- height: 77px;
-}
-
-#logo {
- width: 250px;
- height: 55px;
- margin-top: 16px 0px 0px 5px;
- border: 0px;
-}
-
-#welcome {
- color: white;
- font-weight: bold;
-}
-
-#nav_bar {
- color: white;
- background:
- url(http://www.nysenate.gov/sites/all/themes/nys/images/nyss_menu_bg.png)
- top left repeat-x;
- line-height: 30px;
- font-family: Helvetica, Arial, sans-serif;
-}
-
-#nav_bar a:link {
- color: white;
- font-weight: bold;
- text-decoration: none;
-}
-
-#nav_bar a:visited {
- color: white;
- font-weight: bold;
- text-decoration: none;
-}
-
-#nav_bar a:hover {
- text-decoration: underline;
-}
-
-#nav_bar a:focus {
-
-}
-
-#nav_bar a:active {
-
-}
-
-#nav_bar ul {
- display: inline;
- list-icon-style: none;
- padding-left: 10px;
-}
-
-#nav_bar li {
- display: inline;
-}
-
-.sep {
- padding: 0px 10px;
- display: inline;
-}
-
-#error {
- text-align: center;
- color: red;
-}
-
-.entity_button {
- display: inline;
-}
-
-.entity_title {
- display: inline;
- font-weight: bold;
-}
-
-
-#main {
- margin-top: 5px;
- margin: 20px;
- padding: 20px;
- padding-top: 5px;
- background: #ffffff
- url(http://www.nysenate.gov/sites/all/themes/nys/images/nyss_block_footer_bg.png)
- repeat-x bottom left;
-}
-
-h2 {
- font-family: arial, serif;
- text-transform: uppercase;
- text-align: left;
-}
View
91 BBSignup/WebContent/process.jsp
@@ -0,0 +1,91 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"
+ import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
+ %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<link rel="stylesheet" type="text/css" media="screen" href="style.css"/>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>BillBuzz! Processing request...</title>
+</head>
+<body>
+<center>
+<br/>
+<%
+ Object o = session.getAttribute("senators");
+ if(o != null) {
+
+ if(o instanceof List<?>) {
+
+ String update = (String)session.getAttribute("update");
+ String updateemail = (String)session.getAttribute("updateemail");
+
+ List<Senator> list = (List<Senator>)o;
+
+ Controller c = new Controller();
+
+
+ String[] r = request.getParameterValues("r");
+ String[] d = request.getParameterValues("d");
+
+ String s = c.handle(request.getParameter("firstname"),request.getParameter("lastname"),request.getParameter("email1"),
+ ((updateemail != null) ? updateemail : request.getParameter("email2")),r,d,list,
+ ((update != null && update.equals("true")) ? true : false));
+
+ if(s.equals("")) {
+ if(update != null && update.equals("true")) {
+ session.setAttribute("error",null);
+ session.setAttribute("update",null);
+ session.setAttribute("updateemail",null);
+ %>
+ <div class="good" style="width:500px;">
+ Your account has been successfully updated! Thanks for using BillBuzz.
+ <br/><br/>
+ Redirecting to nysenate.gov in 10 seconds...
+ <meta http-equiv="Refresh" content="10; URL=http://www.nysenate.gov">
+ </div>
+ <%
+ }
+ else {
+ //success
+ //send auth email
+ c.newUserEmail(request.getParameter("email1"));
+ %>
+ <div class="good" style="width:500px;">
+ Thanks for signing up, you should receive an email shortly to verify your request.
+ <br/><br/>
+ Redirecting to nysenate.gov in 10 seconds...
+ <meta http-equiv="Refresh" content="10; URL=http://www.nysenate.gov">
+ </div>
+ <%
+ }
+
+ }
+ else {
+
+ session.setAttribute("error", s);
+ session.setAttribute("fn",request.getParameter("firstname"));
+ session.setAttribute("ln",request.getParameter("lastname"));
+ session.setAttribute("e1",request.getParameter("email1"));
+ session.setAttribute("e2",request.getParameter("email2"));
+ session.setAttribute("subs", c.getSubFromArrays(r,d,list));
+ %>
+ <jsp:forward page="notice.jsp" />
+ <%
+ }
+ }
+ }
+ else {
+ %>
+
+ <jsp:forward page="index.jsp" />
+
+ <%
+ }
+%>
+<%@ include file="footer.jsp" %>
+</center>
+</body>
+</html>
View
22 BBSignup/WebContent/style.css
@@ -1,6 +1,14 @@
+body {
+ font-family: helvetica, arial;
+ font-size: 89.5%; /* 10px */
+ line-height: 1.4em; /* 15px */
+ color: #333;
+ background-color: #fff;
+ margin:16px;
+ margin-top:1px;
+}
.bad {
- color:black;
border:1px solid #FF3300;
margin:1em auto;
border-collapse:collapse;
@@ -10,7 +18,6 @@
.foot {
border-collapse:collapse;
font-size:85%;
- align:center;
}
.good {
@@ -19,7 +26,7 @@
background-color: #BFFFFE;
}
-.bb_main {
+.main {
border-collapse:collapse;
border:1px solid #B2A100;
background-color: #FEF9BF;
@@ -28,8 +35,11 @@
left:15%;
}
-A:visited {
- color: blue;
+h2 {
+ position:relative;
+ left:-355px;top:5px;
}
-
+A:visited {
+ color: blue;
+}
View
41 BBSignup/WebContent/unsubscribe.jsp
@@ -1,9 +1,18 @@
-<%@ page language="java"
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"
import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
%>
-<jsp:include page="header.jsp" />
-<div id="main">
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<link rel="stylesheet" type="text/css" media="screen" href="style.css"/>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>BillBuzz! Unsubscribe</title>
+</head>
+<body>
<center>
+<br/>
<%
String uemail = (String)request.getParameter("uemail");
@@ -41,20 +50,25 @@
<form name="unsub" method="post" action="">
<table>
<tr>
- <td colspan = 2 align=center>
- Please enter your email address:
+ <td colspan=2>
+ NOTE: This will remove your BillBuzz subscription. After you submit your<br/>
+ email address you will receive an email confirming this with a clickable link.
</td>
</tr>
<tr>
- <td colspan = 2 align=center>
+ <td>
+ Email
+ </td>
+ <td>
<input type="text" name="uemail"></input>
- <input type="submit" name="unsubscribe" value="Unsubscribe"></input>
</td>
</tr>
<tr>
- <td colspan=2>
- NOTE: This will remove your BillBuzz subscription. You will receive an email<br/>
- email address you will receive an email confirming this with a clickable link.
+ <td>
+
+ </td>
+ <td>
+ <input type="submit" name="unsubscribe" value="Unsubscribe"></input>
</td>
</tr>
</table>
@@ -63,6 +77,7 @@
<%
}
%>
-</div>
-</center>
-<%@ include file="footer.jsp"%>
+<%@ include file="footer.jsp" %>
+</center>
+</body>
+</html>
View
41 BBSignup/WebContent/update.jsp
@@ -1,9 +1,17 @@
-<%@ page language="java" import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"
+ import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
%>
-<jsp:include page="header.jsp" />
-<div id="main">
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<link rel="stylesheet" type="text/css" media="screen" href="style.css"/>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>BillBuzz! Update Your Subscription</title>
+</head>
<body>
<center>
+<br/>
<%
Controller c = new Controller();
String uemail = (String)request.getParameter("uemail");
@@ -22,9 +30,8 @@
session.setAttribute("e",u.getEmail());
session.setAttribute("subs", u.getSubscriptions());
session.setAttribute("oldemail", uemail);
- session.setAttribute("otherData",u.getOtherData()?"yes":"no");
%>
- <jsp:forward page="/" />
+ <jsp:forward page="index.jsp" />
<%
}
else {
@@ -63,20 +70,24 @@
<form name="update" method="post" action="">
<table>
<tr>
- <td colspan = 2 align=center>
- Please enter your email address:
+ <td colspan = 2>
+ NOTE: You will receive an email that will allow you to update your settings.<br/>
</td>
</tr>
<tr>
-
- <td colspan=2 align=center>
+ <td>
+ Email
+ </td>
+ <td>
<input type="text" name="uemail"></input>
- <input type="submit" name="updatesubmit" value="Update"></input>
</td>
</tr>
<tr>
- <td colspan = 2>
- NOTE: You will receive an email that will allow you to update your settings.<br/>
+ <td>
+
+ </td>
+ <td>
+ <input type="submit" name="updatesubmit" value="Update"></input>
</td>
</tr>
</table>
@@ -85,7 +96,9 @@
<%
}
%>
-</div>
+
+<%@ include file="footer.jsp" %>
</center>
-<%@ include file="footer.jsp"%>
+</body>
+</html>
View
133 BBSignup/src/bbsignup/model/OldSenator.java
@@ -1,133 +0,0 @@
-
-package bbsignup.model;
-
-import javax.jdo.annotations.PersistenceCapable;
-
-@PersistenceCapable
-public class OldSenator {
- String name;
- String url;
- String openLegName;
-
- boolean democrat;
- boolean republican;
- boolean conservative;
- boolean workingFamilies; //WF
- //boolean independentParty; //I
- boolean independenceParty; //IP
- //boolean independent; //ind
-
- public OldSenator() {
- democrat = false;
- republican = false;
- conservative = false;
- workingFamilies = false;
- independenceParty = false;
- }
-
- public OldSenator(Senator senator) {
- this.name = senator.name;
- this.url = senator.url;
- this.openLegName = senator.openLegName;
- this.democrat = senator.democrat;
- this.republican = senator.republican;
- this.conservative = senator.conservative;
- this.workingFamilies = senator.workingFamilies;
- this.independenceParty = senator.independenceParty;
- }
-
- public String getName() {
- return name;
- }
-
- public String getUrl() {
- return url;
- }
-
- public String getOpenLegName() {
- return openLegName;
- }
-
- public boolean isDemocrat() {
- return democrat;
- }
-
- public boolean isRepublican() {
- return republican;
- }
-
- public boolean isConservative() {
- return conservative;
- }
-
- public boolean isWorkingFamilies() {
- return workingFamilies;
- }
-
- public boolean isIndependenceParty() {
- return independenceParty;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public void setOpenLegName(String openLegName) {
- this.openLegName = openLegName;
- }
-
- public void setDemocrat(boolean democrat) {
- this.democrat = democrat;
- }
-
- public void setRepublican(boolean republican) {
- this.republican = republican;
- }
-
- public void setConservative(boolean conservative) {
- this.conservative = conservative;
- }
-
- public void setWorkingFamilies(boolean workingFamilies) {
- this.workingFamilies = workingFamilies;
- }
-
- public void setIndependenceParty(boolean independanceParty) {
- this.independenceParty = independanceParty;
- }
-
- public String getParty() {
-
- String ret = "";
- if(democrat) {
- ret = "d";
- }
- else if(republican) {
- ret = "r";
- }
- if(independenceParty) {
- ret = getPartyHelper(ret,"ip");
- }
- if(conservative) {
- ret = getPartyHelper(ret,"c");
- }
- if(workingFamilies) {
- ret = getPartyHelper(ret,"wf");
- }
-
- return ret;
- }
-
- public String getPartyHelper(String parties, String party) {
- if(parties.equals("")) {
- return party;
- }
- return parties + " - " + party;
- }
-
-
-}
View
29 BBSignup/src/bbsignup/model/Senator.java
@@ -1,4 +1,3 @@
-
package bbsignup.model;
import javax.jdo.annotations.PersistenceCapable;
@@ -13,16 +12,18 @@
boolean republican;
boolean conservative;
boolean workingFamilies; //WF
- //boolean independentParty; //I
+ boolean independentParty; //I
boolean independenceParty; //IP
- //boolean independent; //ind
+ boolean independent; //ind
public Senator() {
democrat = false;
republican = false;
conservative = false;
workingFamilies = false;
+ independentParty = false;
independenceParty = false;
+ independent = false;
}
public String getName() {
@@ -53,10 +54,18 @@ public boolean isWorkingFamilies() {
return workingFamilies;
}
+ public boolean isIndependentParty() {
+ return independentParty;
+ }
+
public boolean isIndependenceParty() {
return independenceParty;
}
+ public boolean isIndependent() {
+ return independent;
+ }
+
public void setName(String name) {
this.name = name;
}
@@ -85,10 +94,18 @@ public void setWorkingFamilies(boolean workingFamilies) {
this.workingFamilies = workingFamilies;
}
+ public void setIndependentParty(boolean independentParty) {
+ this.independentParty = independentParty;
+ }
+
public void setIndependenceParty(boolean independanceParty) {
this.independenceParty = independanceParty;
}
+ public void setIndependent(boolean independent) {
+ this.independent = independent;
+ }
+
public String getParty() {
String ret = "";
@@ -98,9 +115,15 @@ public String getParty() {
else if(republican) {
ret = "r";
}
+ if(independentParty) {
+ ret = getPartyHelper(ret,"i");
+ }
if(independenceParty) {
ret = getPartyHelper(ret,"ip");
}
+ if(independent) {
+ ret = getPartyHelper(ret,"ind");
+ }
if(conservative) {
ret = getPartyHelper(ret,"c");
}
View
13 BBSignup/src/bbsignup/model/User.java
@@ -31,10 +31,6 @@
@Column(name="auth")
private String auth;
- @Persistent
- @Column(name="other_data")
- private boolean otherData;
-
@Persistent(defaultFetchGroup="true")
@Column(name="subs")
@@ -44,13 +40,12 @@ public User() {
subscriptions = new ArrayList<String>();
}
- public User(String firstName, String lastName, String email, String auth, boolean otherData) {
+ public User(String firstName, String lastName, String email, String auth) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.auth = auth;
subscriptions = new ArrayList<String>();
- this.otherData = otherData;
}
@@ -69,9 +64,6 @@ public String getAuth() {
public List<String> getSubscriptions() {
return subscriptions;
}
- public boolean getOtherData() {
- return otherData;
- }
public void setFirstName(String firstName) {
this.firstName = firstName;
@@ -88,9 +80,6 @@ public void setAuth(String auth) {
public void setSubscriptions(List<String> subscriptions) {
this.subscriptions = subscriptions;
}
- public void setOtherData(boolean otherData) {
- this.otherData = otherData;
- }
public void addSubscription(String s) {
subscriptions.add(s);
View
12 BBSignup/src/bbsignup/model/UserAuth.java
@@ -1,8 +1,11 @@
package bbsignup.model;
+import java.io.IOException;
import java.util.Date;
+
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.PrimaryKey;
+
import org.jasypt.util.text.BasicTextEncryptor;
import bbsignup.src.Controller;
@@ -14,8 +17,13 @@
String email;
String hash;
- public static void main(String[] args) {
- System.out.println(new Controller().getUser("williams@nysenate.gov").getOtherData());
+ public static void main(String[] args) throws IOException {
+ String str = "";
+ Controller c = new Controller();
+ UserAuth ua = c.getUserAuth("williams@nysenate.gov");
+
+ System.out.println(ua.getHash());
+ System.out.println(ua.isHashCorrect(str));
}
public UserAuth() {
View
68 BBSignup/src/bbsignup/src/Controller.java
@@ -1,13 +1,9 @@
package bbsignup.src;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.jdo.PersistenceManager;
import javax.jdo.Transaction;
@@ -29,66 +25,10 @@
private static final String SMTP_ACCOUNT_PASS = Resource.get("pass");
public String WEBLINK = "http://billbuzz.nysenate.gov/";
+
- public static void main(String[] args) throws IOException {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String in = "";
-
- System.out.print("> ");
- while(!(in = br.readLine()).equals("exit")) {
-
- if(in.startsWith("add user")) {
- Pattern p = Pattern.compile("add user (.+?) (.+?) (.+?) (true|false)$");
- Matcher m = p.matcher(in);
- if(m.find()) {
- User u = new User(m.group(1), m.group(2), m.group(3),
- "y",m.group(4).equals("true")?true:false);
- u.addSubscription("all");
- PMF.persistObject(u);
- System.out.println("User " + m.group(3) + " added succesfully");
- }
- else {
- System.out.println("proper format is: add user <nfame> <lfame> <email>" +
- "<otherdata(true or false)>");
- }
- }
- else if(in.startsWith("delete user")) {
- Pattern p = Pattern.compile("delete user (.+)$");
- Matcher m = p.matcher(in);
- if(m.find()) {
- PMF.deleteObjectById(User.class, "email", m.group(1));
- System.out.println("User " + m.group(1) + " deleted");
- }
- else {
- System.out.println("proper format is: add user <nfame> <lfame> <email>");
- }
- }
- else if(in.startsWith("set other")) {
- PersistenceManager pm = PMF.getPersistenceManager();
- Transaction tx = pm.currentTransaction();
-
- try {
- tx.begin();
-
- List<User> users = (List<User>)PMF.getObjects(pm, User.class);
- for(User user:users) {
- user.setOtherData(true);
- }
-
- tx.commit();
- }
- finally {
- if(tx.isActive()){
- tx.rollback();
- }
- pm.close();
- }
- }
- System.out.print("> ");
- }
- }
- public Controller() {
+ public Controller() throws IOException {
}
@SuppressWarnings("unchecked")
@@ -128,7 +68,7 @@ public String tryDelete(String email) {
public boolean deleteUser(String email, String key) {
UserAuth ua = getUserAuth(email);
- if(ua != null && ua.getHash() != null && ua.isHashCorrect(key)) {
+ if(ua.isHashCorrect(key)) {
PMF.deleteObjects(new Class[] {User.class,UserAuth.class},
new String[] {"email","email"},
new String[] {email,email});
@@ -148,7 +88,7 @@ public UserAuth getUserAuth(String email) {
public void newUserEmail(String email, String hash) {
- String message = "Hello!<br/><br/>Thanks for signing up for BillBuzz. To finalize your subscription please click the following link:";
+ String message = "Hello!<br/><br/>Thanks for signing up for BillBuzz, to finalize your subscription please click the following link:";
message += "<br/><br/>" + WEBLINK + "authenticate.jsp?email=" + email + "&key=" + hash;
View
23 BBSignup/src/bbsignup/src/PMF.java
@@ -213,27 +213,4 @@ public static boolean deleteObjects(Class<?>[] clazz, String[] key, String[] id)
return true;
}
-
- public static void deleteObjects(Class<?> clazz) {
- PersistenceManager pm = getPersistenceManager();
- Transaction tx = pm.currentTransaction();
-
- try {
- tx.begin();
-
- Collection<?> objs = getObjects(pm, clazz);
-
- for(Object o:objs) {
- pm.deletePersistent(o);
- }
-
- tx.commit();
- }
- finally {
- if(tx.isActive()) {
- tx.rollback();
- }
- pm.close();
- }
- }
}
View
96 BBSignup/src/collect/NYSenateServices.java
@@ -10,7 +10,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import bbsignup.model.OldSenator;
import bbsignup.model.Senator;
import bbsignup.src.PMF;
@@ -18,76 +17,15 @@
public class NYSenateServices {
public static void index() throws Exception {
- List<Senator> newSenList = getSenators();
- List<Senator> prevSenList = (List<Senator>) PMF.getDetachedObjects(Senator.class);
- List<OldSenator> oldSenList = (List<OldSenator>) PMF.getDetachedObjects(OldSenator.class);
+ List<Senator> senators = getSenators();
- HashMap<String,Senator> newSenMap = getSenatorMap(newSenList);
- HashMap<String,Senator> prevSenMap = getSenatorMap(prevSenList);
- HashMap<String,OldSenator> oldSenMap = getOldSenatorMap(oldSenList);
-
- for(String name:prevSenMap.keySet()) {
- if(newSenMap.get(name) != null) {
- prevSenList.remove(prevSenMap.get(name));
- }
- else
- {
- if(oldSenMap.get(name) != null) {
- prevSenList.remove(prevSenMap.get(name));
- }
- }
- }
-
- for(Senator senator:prevSenList) {
- oldSenList.add(new OldSenator(senator));
- }
-
- PMF.deleteObjects(OldSenator.class);
- PMF.deleteObjects(Senator.class);
-
- for(Senator s:newSenList) {
+ for(Senator s:senators) {
PMF.persistObject(s);
}
- for(OldSenator os:oldSenList) {
- PMF.persistObject(os);
- }
-
-
- }
-
- public static HashMap<String,Senator> getSenatorMap(List<Senator> list) {
- HashMap<String,Senator> map = new HashMap<String,Senator>();
- for(Senator senator:list) {
- map.put(senator.getOpenLegName(), senator);
- }
- return map;
- }
-
- public static HashMap<String,OldSenator> getOldSenatorMap(List<OldSenator> list) {
- HashMap<String,OldSenator> map = new HashMap<String,OldSenator>();
- for(OldSenator senator:list) {
- map.put(senator.getOpenLegName(), senator);
- }
- return map;
}
public static void main(String[] args) throws Exception {
index();
-
- /*if(args.length == 0) {
- System.out.println("please indicate either 'index' or 'truncate'");
- }
- else {
- if(args[0].equals("index")) {
- index();
- }
- else if(args[0].equals("truncate")) {
- PMF.deleteObjects(Senator.class);
- }
- else {
- System.out.println("please indicate either 'index' or 'truncate'");
- }
- }*/
}
public static List<Senator> getSenators() throws Exception {
@@ -133,9 +71,15 @@ else if(args[0].equals("truncate")) {
else if(party.matches("R")) {
senator.setRepublican(true);
}
+ else if(party.matches("I")) {
+ senator.setIndependentParty(true);
+ }
else if(party.matches("IP")) {
senator.setIndependenceParty(true);
}
+ else if(party.matches("Ind")) {
+ senator.setIndependent(true);
+ }
else if(party.matches("WF")) {
senator.setWorkingFamilies(true);
}
@@ -158,12 +102,14 @@ else if(party.matches("C")) {
public static HashMap<String,String> getOpenLegSenators() throws IOException {
HashMap<String,String> ret = new HashMap<String,String>();
- URL url = new URL("http://open.nysenate.gov/legislation/senators");
+ URL url = new URL("http://open.nysenate.gov/legislation/senators/");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
-
+
+ Pattern lineP = Pattern.compile("<div class=\"views-field-field-senators-district-nid\">");
Pattern districtP = Pattern.compile("District (\\d+)");
- Pattern nameP = Pattern.compile("/sponsor/(.+?)\\?filter");
+ Pattern nameP = Pattern.compile("/legislation/sponsor/(\\w+)");
+ Matcher lineM = null;
Matcher districtM = null;
Matcher nameM = null;
@@ -172,15 +118,23 @@ else if(party.matches("C")) {
while((in = br.readLine()) != null) {
String d = null, n = null;
- districtM = districtP.matcher(in);
+ lineM = lineP.matcher(in);
- if(districtM.find()) {
- d = districtM.group(1);
+ if(lineM.find()) {
in = br.readLine();
-
+
+ districtM = districtP.matcher(in);
nameM = nameP.matcher(in);
+ if(districtM.find()) {
+ d = districtM.group(1);
+
+ if(districtM.group(1).equals("6")) {
+ n = "hannon";
+ }
+ }
+
if(nameM.find()) {
n = nameM.group(1);
}
View
10 BBSignup/src/servlets/MainServlet.java
@@ -24,7 +24,9 @@
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- // will store selected subscriptions
+
+
+ // will store selected subscriptions */
List<String> subs = new ArrayList<String>();
HttpSession session = request.getSession();
@@ -33,7 +35,6 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
String fname = null;
String lname = null;
String email = null;
- String otherData = null;
// if update exists in the session then the user already xists */
String update = (String)session.getAttribute("update");
@@ -41,8 +42,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
if(o != null) {
fname = (String)request.getParameter("firstname");
lname = (String)request.getParameter("lastname");
- email = (String)request.getParameter("email1");
- otherData = (String)request.getParameter("otherData");
+ email = (String)request.getParameter("email1");
/* this is a session variable stored from index.jsp, verifies
* that the user is following proper workflow */
@@ -82,7 +82,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
Controller c = new Controller();
String message = null;
- User u = new User(fname, lname, email, "n", (otherData.equals("yes") ? true:false));
+ User u = new User(fname, lname, email, "n");
u.setSubscriptions(subs);
if(update == null) {
View
1  BBSignup/src/servlets/SenatorContext.java
@@ -1,6 +1,7 @@
package servlets;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext;

0 comments on commit 7779ed5

Please sign in to comment.
Something went wrong with that request. Please try again.