diff options
Diffstat (limited to 'sandbox/kgoodson/jagg')
4 files changed, 204 insertions, 111 deletions
diff --git a/sandbox/kgoodson/jagg/src/main/java/services/PlanView.java b/sandbox/kgoodson/jagg/src/main/java/services/PlanView.java index 101e1d1e01..ffb68270da 100644 --- a/sandbox/kgoodson/jagg/src/main/java/services/PlanView.java +++ b/sandbox/kgoodson/jagg/src/main/java/services/PlanView.java @@ -31,6 +31,8 @@ import com.example.ipo.jaxb.Plan; public interface PlanView { Plan get(); - void post(String newMSName,String msChoice, String jira); + Plan getLite(); // don't go off to issue site - use cached properties + void postNewWorkItem(String msChoice, String jira); + void postNewMilestone(String newMSName); }
\ No newline at end of file diff --git a/sandbox/kgoodson/jagg/src/main/java/services/PlanViewImpl.java b/sandbox/kgoodson/jagg/src/main/java/services/PlanViewImpl.java index 79d835ecb2..56f3b56ca2 100644 --- a/sandbox/kgoodson/jagg/src/main/java/services/PlanViewImpl.java +++ b/sandbox/kgoodson/jagg/src/main/java/services/PlanViewImpl.java @@ -20,11 +20,16 @@ package services; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.sql.Date; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.List; import javax.xml.bind.JAXBContext; @@ -51,8 +56,9 @@ import com.sun.syndication.io.XmlReader; public class PlanViewImpl implements PlanView { - private com.example.ipo.jaxb.Plan _p = null; + // private com.example.ipo.jaxb.Plan _p = null; static String rssPrefix = "http://issues.apache.org/jira/si/jira.issueviews:issue-xml/"; + static String planFile="src/main/resources/jiraSideBand.xml"; // TUSCANY-1178/TUSCANY-1178.xml @Init @@ -60,95 +66,97 @@ public class PlanViewImpl implements PlanView { } private Plan getPlan() { - if (_p == null) { - - try { - JAXBContext jaxbContext = JAXBContext - .newInstance("com.example.ipo.jaxb"); - Unmarshaller m = jaxbContext.createUnmarshaller(); - File inputFile = new File("src/main/resources/jiraSideBand.xml") - .getAbsoluteFile(); - -// Reader r = new XMLReader() -// InputSource s = new InputSource(r); - _p = (Plan)m.unmarshal(inputFile); - augment_plan(_p); - } catch (Exception e) { - e.printStackTrace(); - } finally { - - } - + Plan p = null; + try { + p = readPlan(); + augmentPlan(p); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // FIXME } - return _p; - + return p; } - private void augment_plan(Plan plan) { + private void augmentPlan(Plan plan) { for(Milestone m : plan.getMilestone()) { for (WorkItem wi: m.getWorkItem()) { - String jira = wi.getJira(); - if(jira != null) { - String feed = rssPrefix += jira + "/" + jira + ".xml"; - JiraData jd = new JiraData(); - wi.setJiraData(jd); - jd.setID(jira); - - try { - JAXBContext jaxbContext = JAXBContext - .newInstance("com.example.ipo.jaxb"); - Unmarshaller m2 = jaxbContext.createUnmarshaller(); - InputStream is = null; - RSS j; - try{ - URL url = new URL("http://issues.apache.org/jira/si/jira.issueviews:issue-xml/"+jira+"/"+jira+".xml"); - is = url.openStream(); - j = ((JAXBElement<RSS>) m2.unmarshal(is)).getValue(); - } - finally { - if(is != null) is.close(); + augmentWorkItem(wi); + + } + } + } + + private void augmentWorkItem(WorkItem wi) { + String jira = wi.getJira(); + if(jira != null) { + String feed = rssPrefix += jira + "/" + jira + ".xml"; + JiraData jd = new JiraData(); + wi.setJiraData(jd); + jd.setID(jira); + + try { + JAXBContext jaxbContext = JAXBContext + .newInstance("com.example.ipo.jaxb"); + Unmarshaller m2 = jaxbContext.createUnmarshaller(); + InputStream is = null; + RSS jfeed = null; + try{ + URL url = new URL("http://issues.apache.org/jira/si/jira.issueviews:issue-xml/"+jira+"/"+jira+".xml"); + is = url.openStream(); + jfeed = ((JAXBElement<RSS>) m2.unmarshal(is)).getValue(); + } + catch (FileNotFoundException e) { + String note = wi.getNote(); + note += ": attempt to reference non-existent JIRA " + jira; + wi.setNote(note); + wi.setJira(null); + wi.setJiraData(null); + } + finally { + if(is != null) is.close(); + } + + if(jfeed != null) { + Item i = jfeed.getChannel().getItem(); + List<JAXBElement<?>> c = i.getContent(); + // TODO see if there's a better way to get this data out + for (JAXBElement<?> element : c) { + if("title".equals(element.getName().getLocalPart())) { + String jtitle = (String)element.getValue(); + jd.setTitle(jtitle.substring(jtitle.indexOf(']')+1, jtitle.length())); } - - Item i = j.getChannel().getItem(); - System.out.println(i.toString()); - List<JAXBElement<?>> c = i.getContent(); - // TODO see if there's a better way to get this data out - for (JAXBElement<?> element : c) { - if("title".equals(element.getName().getLocalPart())) { - String jtitle = (String)element.getValue(); - jd.setTitle(jtitle.substring(jtitle.indexOf(']')+1, jtitle.length())); - } - else if("status".equals(element.getName().getLocalPart())){ - jd.setStatus((String)element.getValue()); - } - else if("assignee".equals(element.getName().getLocalPart())) { - jd.setAssignedTo((String)element.getValue()); - } + else if("status".equals(element.getName().getLocalPart())){ + jd.setStatus((String)element.getValue()); } - } catch (Exception e) { - e.printStackTrace(); - } finally { - + else if("assignee".equals(element.getName().getLocalPart())) { + jd.setAssignedTo((String)element.getValue()); + } } } - - } + } catch (Exception e) { + e.printStackTrace(); + } finally { + + } } } public Plan get() { - com.example.ipo.jaxb.Plan modelplan = getPlan(); + Plan p = getPlan(); + return p; + } - // dto.Plan dtoplan = new dto.Plan(modelplan); - return modelplan; + public Plan getLite() { + Plan p = readPlan(); + return p; } - private Milestone getMS(String id) { + private Milestone getMS(Plan p, String id) { Milestone m = null; - Plan p = getPlan(); for(Milestone mi : p.getMilestone()) { if(id.equals(mi.getID())) { m = mi; @@ -158,47 +166,94 @@ public class PlanViewImpl implements PlanView { return m; } - public void post(String newMSName,String msChoice, String jira) { - - String msName = msChoice; - Plan p = getPlan(); - if(!"".equals(newMSName)) { - List<Milestone> mis = p.getMilestone(); - Milestone newm = new Milestone(); - newm.setID(newMSName); - mis.add(new Milestone()); - msName = newMSName; - } + public void postNewWorkItem(String msid, String jira) { - Milestone m = getMS(msName); + Plan p = readPlan(); + Milestone m = getMS(p,msid); WorkItem wi = new WorkItem(); wi.setJira(jira); + augmentWorkItem(wi); m.getWorkItem().add(wi); - - writePlan(); + writePlan(p); } - private void writePlan() + public void postNewMilestone(String msid) { + Plan p = readPlan(); + if(getMS(p, msid) == null) { + List<Milestone> mis = p.getMilestone(); + Milestone newm = new Milestone(); + newm.setID(msid); + mis.add(newm); + writePlan(p); + } + } + + + private void writePlan(Plan p) { + FileOutputStream fos = null; + String dbPath = null; + File existingFile = null; + File newFile= null; + String backupPath = null; + try { JAXBContext jaxbContext = JAXBContext .newInstance("com.example.ipo.jaxb"); Marshaller m = jaxbContext.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); - File oldInputFile = new File("src/main/resources/jiraSideBand.xml").getAbsoluteFile(); - String oldPath = oldInputFile.getAbsolutePath(); - oldInputFile.renameTo(new File(oldPath+".old")); - File outputFile = new File("src/main/resources/jiraSideBand.xml").getAbsoluteFile(); - FileOutputStream fos = new FileOutputStream(outputFile); + + existingFile = new File(planFile).getAbsoluteFile(); + dbPath = existingFile.getAbsolutePath(); + + + String tempPath = dbPath.substring(0,dbPath.indexOf(".xml"))+".tmp.xml"; + backupPath = dbPath.substring(0,dbPath.indexOf(".xml")); + DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); + String timestamp = df.format(Calendar.getInstance().getTime()); + backupPath+= timestamp; + backupPath+=".xml"; + + newFile = new File(tempPath).getAbsoluteFile(); + fos = new FileOutputStream(newFile); - m.marshal(getPlan(), fos); + m.marshal(p, fos); } catch (Exception e) { e.printStackTrace(); } finally { - + } + + + if(fos!=null) + try { + fos.close(); + + new File(dbPath).renameTo(new File(backupPath)); + newFile.renameTo(new File(dbPath)); + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } - + + private Plan readPlan() + { + Plan p = null; + try { + JAXBContext jaxbContext = JAXBContext + .newInstance("com.example.ipo.jaxb"); + Unmarshaller m = jaxbContext.createUnmarshaller(); + + File inputFile = new File(planFile).getAbsoluteFile(); + p = (Plan)m.unmarshal(inputFile); + } catch(Exception e) { + // FIXME + } + return p; + } }
\ No newline at end of file diff --git a/sandbox/kgoodson/jagg/src/main/resources/JiraSideband.xml b/sandbox/kgoodson/jagg/src/main/resources/JiraSideband.xml index d7a473763e..783e97810f 100644 --- a/sandbox/kgoodson/jagg/src/main/resources/JiraSideband.xml +++ b/sandbox/kgoodson/jagg/src/main/resources/JiraSideband.xml @@ -48,6 +48,30 @@ <assignedTo>Unassigned</assignedTo> </jiraData> </workItem> + <workItem> + <jira>TUSCANY-1256</jira> + <jiraData ID="TUSCANY-1256"> + <title> NullPointerException when component reference has target of composite reference</title> + <status>Resolved</status> + <assignedTo>Simon Nash</assignedTo> + </jiraData> + </workItem> + <workItem> + <jira>TUSCANY-1258</jira> + <jiraData ID="TUSCANY-1258"> + <title> WS services fail with: TransformationException: No wrapper handler is provided for databinding: null</title> + <status>Closed</status> + <assignedTo>Unassigned</assignedTo> + </jiraData> + </workItem> + <workItem> + <jira>TUSCANY-1129</jira> + <jiraData ID="TUSCANY-1129"> + <title> Multiple Inheritance Broken In Generator Templates</title> + <status>Open</status> + <assignedTo>Unassigned</assignedTo> + </jiraData> + </workItem> </milestone> <milestone ID="V8_M5I14b"> <workItem> @@ -74,6 +98,14 @@ <assignedTo>Unassigned</assignedTo> </jiraData> </workItem> + <workItem> + <jira>TUSCANY-1257</jira> + <jiraData ID="TUSCANY-1257"> + <title> DatabindingTestCase fails with java.lang.IllegalArgumentException</title> + <status>Resolved</status> + <assignedTo>Raymond Feng</assignedTo> + </jiraData> + </workItem> </milestone> <milestone ID="abcd"> <workItem> diff --git a/sandbox/kgoodson/jagg/src/main/resources/uiservices/plan.html b/sandbox/kgoodson/jagg/src/main/resources/uiservices/plan.html index a26049f958..2b33988c00 100644 --- a/sandbox/kgoodson/jagg/src/main/resources/uiservices/plan.html +++ b/sandbox/kgoodson/jagg/src/main/resources/uiservices/plan.html @@ -36,7 +36,10 @@ } ms = plan.milestone.list; var mscontent = "<table border=\"1\" align=\"left\">"; - var mschoice = '<select name="mschoice">'; + + + + var mschoice = 'Add new Work Item for JIRA: <input type="text" name="JIRA" value="TUSCANY-">in Milestone<select name="mschoice">'; for(var i=0; i<ms.length; i++) { mscontent += "<tr><th colspan=\"6\" align=\"left\">Milestone " + ms[i].ID + "</th></tr>"; mschoice+='<option>'+ms[i].ID+'</option>'; @@ -68,23 +71,12 @@ } mscontent += "</table><P>"; - mschoice += '</select>'; + mschoice += '</select><input type="button" onClick="addWorkItem()" value="Add Work Item">'; document.getElementById('milestones').innerHTML='<h2>' + mscontent; - - - var newmscontent = - '<form name="newWorkItemForm">'+ - '<div id="addWorkItem">'+ - 'Add new Work Item for JIRA: <input type="text" name="JIRA" value="TUSCANY-">'+ 'in Milestone '+mschoice+ - '<input type="button" onClick="addWorkItem()" value="Add"></div>'+ - '<br/><div id="addMilestone>">Add New Milestone <input name="newmsname" type=text/><input type="button" onClick="addMilestone()" value="Add Milestone">'+ - '</td></tr></div>'+ - '<tr><td><input type="button" name="refresh" value="Refresh Jira Data" onclick="refreshJiraData"/></td></tr>' - '</form>'; - document.getElementById('addPlanData').innerHTML=newmscontent; + document.getElementById('mschoice').innerHTML=mschoice; return; } @@ -106,7 +98,6 @@ function plan_postNewWorkItem_response() { - // refresh planView.getLite().addCallback(plan_getResponse); } @@ -136,8 +127,21 @@ <table> <tr><td><div id="milestones"></div></td></tr> - <tr><td><div id="addPlanData"></div></td></tr> - + <tr><td> + <form name="newWorkItemForm"> + <table> + <tr><td> + <div id=mschoice></div> + </td></tr> + <tr><td> + Add New Milestone <input name="newmsname" type=text/><input type="button" onClick="addMilestone()" value="Add Milestone"> + </td></tr> + <tr><td> + <input type="button" value="Refresh Jira Data" onclick="refreshJiraData()"/> + </td></tr> + </table> + </form> + </td></tr> </table> </body> </html>
\ No newline at end of file |