From 195bd9804056816bb761e20b04799fc05d75d737 Mon Sep 17 00:00:00 2001 From: kelvingoodson Date: Wed, 24 Feb 2010 11:20:43 +0000 Subject: try webapp variant of jira app git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@915751 13f79535-47bb-0310-9956-ffa450edef68 --- sandbox/kgoodson/jagg-webapp/build.xml | 79 ++++++ sandbox/kgoodson/jagg-webapp/pom.xml | 266 +++++++++++++++++++++ .../src/main/java/services/PlanView.java | 38 +++ .../src/main/java/services/PlanViewImpl.java | 252 +++++++++++++++++++ .../jagg-webapp/src/main/resources/JiraRSS.xsd | 99 ++++++++ .../src/main/resources/JiraSideband.xml | 65 +++++ .../src/main/resources/JiraSideband.xsd | 133 +++++++++++ .../jagg-webapp/src/main/resources/exampleJira.xml | 67 ++++++ .../jagg-webapp/src/main/resources/plan.composite | 42 ++++ .../jagg-webapp/src/main/resources/plan.html | 150 ++++++++++++ .../src/main/webapp/META-INF/sca-contribution.xml | 23 ++ .../jagg-webapp/src/main/webapp/WEB-INF/web.xml | 36 +++ 12 files changed, 1250 insertions(+) create mode 100644 sandbox/kgoodson/jagg-webapp/build.xml create mode 100644 sandbox/kgoodson/jagg-webapp/pom.xml create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/java/services/PlanView.java create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/java/services/PlanViewImpl.java create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/resources/JiraRSS.xsd create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/resources/JiraSideband.xml create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/resources/JiraSideband.xsd create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/resources/exampleJira.xml create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/resources/plan.composite create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/resources/plan.html create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sandbox/kgoodson/jagg-webapp/src/main/webapp/WEB-INF/web.xml (limited to 'sandbox/kgoodson/jagg-webapp') diff --git a/sandbox/kgoodson/jagg-webapp/build.xml b/sandbox/kgoodson/jagg-webapp/build.xml new file mode 100644 index 0000000000..e186df80e8 --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/build.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/jagg-webapp/pom.xml b/sandbox/kgoodson/jagg-webapp/pom.xml new file mode 100644 index 0000000000..69e7fca7cd --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/pom.xml @@ -0,0 +1,266 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-SNAPSHOT + ../pom.xml + + sample-jagg-webapp + Apache Tuscany SCA Sample JIRA Aggregator + war + + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + + org.codehaus.mojo + jaxb2-maven-plugin + 1.3 + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + generate-sources + + copy + + + + + javax.xml.bind + jaxb-api + 2.1 + jar + + + ${project.build.directory}/endorsed + false + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + -Djava.endorsed.dirs=target/endorsed + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + + add-source + generate-sources + + add-source + + + + target/jaxb-source + + + + + + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + 0.7.1 + + + generate-jaxb + generate-sources + + generate + + + + + com.example.ipo.jaxb + ${project.build.directory}/jaxb-source + ${basedir}/src/main/resources + + + JiraSideband.xsd + JiraRSS.xsd + + + + + + ${artifactId} + + + + + + org.apache.tuscany.sca + + tuscany-node-impl + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime-dojo + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-runtime + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-js-dojo + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-js-dojo + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + rome + rome + 1.0 + + + javax.xml.bind + jaxb-api + 2.0 + + + + com.sun.xml.bind + jaxb-impl + 2.0.3 + + + org.jvnet.jaxb2_commons + runtime + 0.4.1 + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-SNAPSHOT + runtime + + + + net.sourceforge.htmlunit + htmlunit + 2.6 + test + + + + org.jvnet.jaxb2_commons + testing + 0.4.1 + test + + + + + + + + diff --git a/sandbox/kgoodson/jagg-webapp/src/main/java/services/PlanView.java b/sandbox/kgoodson/jagg-webapp/src/main/java/services/PlanView.java new file mode 100644 index 0000000000..ffb68270da --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/java/services/PlanView.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.oasisopen.sca.annotation.Remotable; + +import com.example.ipo.jaxb.Plan; + + + + + +@Remotable +public interface PlanView { + + Plan get(); + 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-webapp/src/main/java/services/PlanViewImpl.java b/sandbox/kgoodson/jagg-webapp/src/main/java/services/PlanViewImpl.java new file mode 100644 index 0000000000..fad6f68b63 --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/java/services/PlanViewImpl.java @@ -0,0 +1,252 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +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.URL; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; + +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; + +import com.example.ipo.jaxb.Item; +import com.example.ipo.jaxb.JiraData; +import com.example.ipo.jaxb.Milestone; +import com.example.ipo.jaxb.Plan; +import com.example.ipo.jaxb.RSS; +import com.example.ipo.jaxb.WorkItem; + +public class PlanViewImpl implements PlanView { + + static String rssPrefix = "http://issues.apache.org/jira/si/jira.issueviews:issue-xml/"; + @Property + public String planFile = "src/main/resources/jiraSideBand.xml"; + + @Init + public void init() { + } + + private Plan getPlan() { + Plan p = null; + try { + p = readPlan(); + augmentPlan(p); + writePlan(p); + } catch (Exception e) { + e.printStackTrace(); + } + return p; + } + + + + private void augmentPlan(Plan plan) { + for(Milestone m : plan.getMilestone()) { + for (WorkItem wi: m.getWorkItem()) { + augmentWorkItem(wi); + + } + } + } + + private void augmentWorkItem(WorkItem wi) { + String jira = wi.getJira(); + if(jira != null) { + 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) 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> 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()); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + + } + } + } + + public Plan get() { + Plan p = getPlan(); + return p; + } + + public Plan getLite() { + Plan p = readPlan(); + return p; + } + + private Milestone getMS(Plan p, String id) { + + Milestone m = null; + for(Milestone mi : p.getMilestone()) { + if(id.equals(mi.getID())) { + m = mi; + break; + } + } + return m; + } + + public void postNewWorkItem(String msid, String jira) { + + Plan p = readPlan(); + Milestone m = getMS(p,msid); + WorkItem wi = new WorkItem(); + wi.setJira(jira); + augmentWorkItem(wi); + m.getWorkItem().add(wi); + writePlan(p); + } + + public void postNewMilestone(String msid) { + Plan p = readPlan(); + if(getMS(p, msid) == null) { + List 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); + + 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(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(); + if(!inputFile.exists()){ // start afresh + Plan newPlan = new Plan(); + writePlan(newPlan); + inputFile = new File(planFile).getAbsoluteFile(); + } + + p = (Plan)m.unmarshal(inputFile); + } catch(Exception e) { + throw new IllegalStateException("Failed to read plan file",e); + } + return p; + } +} \ No newline at end of file diff --git a/sandbox/kgoodson/jagg-webapp/src/main/resources/JiraRSS.xsd b/sandbox/kgoodson/jagg-webapp/src/main/resources/JiraRSS.xsd new file mode 100644 index 0000000000..4a2b066267 --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/resources/JiraRSS.xsd @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/jagg-webapp/src/main/resources/JiraSideband.xml b/sandbox/kgoodson/jagg-webapp/src/main/resources/JiraSideband.xml new file mode 100644 index 0000000000..2d60a3b83a --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/resources/JiraSideband.xml @@ -0,0 +1,65 @@ + + + https://issues.apache.org/jira/browse/ + + + TUSCANY-2850 + + Support binding.json-rpc for implementation.java's reference + Resolved + Luciano Resende + + + + TUSCANY-3395 + + Tidying up Contribution Scanner API + Resolved + Luciano Resende + + + + TUSCANY-3397 + + Add support for identifying the SCA Spec Version for contribution metadata + Resolved + Luciano Resende + + + + + + TUSCANY-3433 + + Import more of the basic itests from 1.x to 2.x + Open + Ramkumar Ramalingam + + + + TUSCANY-3409 + + Non-Simple Property Injected with XML Fails with NullPointerException + Resolved + Raymond Feng + + + + TUSCANY-3441 + + Improve mechanism for determining locality of endpoints to endpoint references + Open + Unassigned + + + + TUSCANY-3443 + + Devise a away to track and spi changes we make in 2.x + Open + Unassigned + + + + + diff --git a/sandbox/kgoodson/jagg-webapp/src/main/resources/JiraSideband.xsd b/sandbox/kgoodson/jagg-webapp/src/main/resources/JiraSideband.xsd new file mode 100644 index 0000000000..19b2beca32 --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/resources/JiraSideband.xsd @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + The milestone or deliverable name that we require this + function for + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A tuscany source code repository branch name or + repository version number + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/kgoodson/jagg-webapp/src/main/resources/exampleJira.xml b/sandbox/kgoodson/jagg-webapp/src/main/resources/exampleJira.xml new file mode 100644 index 0000000000..08dae93262 --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/resources/exampleJira.xml @@ -0,0 +1,67 @@ + + + ASF JIRA + https://issues.apache.org:443/jira + This file is an XML representation of an issue + en-uk + + 3.13.5 + 360 + 07-07-2009 + Enterprise + + + [TUSCANY-3397] Add support for identifying the + SCA Spec Version for contribution metadata + https://issues.apache.org:443/jira/browse/TUSCANY-3397 + Provide the same support we have for Composites, + for Contribution Metadata + + TUSCANY-3397 + Add support for identifying the SCA Spec Version for + contribution metadata + Bug + Major + Resolved + Fixed + Luciano Resende + Luciano Resende + Fri, 18 Dec 2009 17:31:07 +0000 (UTC) + Fri, 18 Dec 2009 17:58:58 +0000 (UTC) + Java-SCA-2.0 + Java-SCA-2.0 + Java SCA Core Runtime + + 0 + + + Fixed, you can now identify the spec version of the contribution + metadata based on the SCA Namespace being used, this means that, + for SCA 1.1, specVersion will return + http://docs.oasis-open.org/ns/opencsa/sca/200912 + + + + + + + Time in Status + + + + Resolution Date + + Fri, 18 Dec 2009 17:58:58 +0000 (UTC) + + + + + + diff --git a/sandbox/kgoodson/jagg-webapp/src/main/resources/plan.composite b/sandbox/kgoodson/jagg-webapp/src/main/resources/plan.composite new file mode 100644 index 0000000000..c6f837c0d2 --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/resources/plan.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + src/main/resources/jiraSideBand.xml + + + + + + + + diff --git a/sandbox/kgoodson/jagg-webapp/src/main/resources/plan.html b/sandbox/kgoodson/jagg-webapp/src/main/resources/plan.html new file mode 100644 index 0000000000..f064b47160 --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/resources/plan.html @@ -0,0 +1,150 @@ + + + +Plan + + + + + + + + +

Plan

+ + + + + +
+
+ + + + +
+
+
+ Add New Milestone +
+ +
+
+
+ + \ No newline at end of file diff --git a/sandbox/kgoodson/jagg-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sandbox/kgoodson/jagg-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..9d874181fe --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sandbox/kgoodson/jagg-webapp/src/main/webapp/WEB-INF/web.xml b/sandbox/kgoodson/jagg-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9c8eb81ae4 --- /dev/null +++ b/sandbox/kgoodson/jagg-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,36 @@ + + + + sample-jagg-secure-webapp + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + plan.html + + \ No newline at end of file -- cgit v1.2.3