| author | Sam Padgett | 2011-11-08 10:07:28 (EST) |
|---|---|---|
| committer | Michael Fiedler | 2011-11-08 10:07:28 (EST) |
| commit | ab7f2f8380f75d24d5bbbaaef9339ca974e25613 (patch) (side-by-side diff) | |
| tree | f33596cc5af4755e1e58924cec49114375ad49b3 | |
| download | org.eclipse.lyo.server-ab7f2f8380f75d24d5bbbaaef9339ca974e25613.zip org.eclipse.lyo.server-ab7f2f8380f75d24d5bbbaaef9339ca974e25613.tar.gz org.eclipse.lyo.server-ab7f2f8380f75d24d5bbbaaef9339ca974e25613.tar.bz2 | |
Bug360177 - Initial contribution of Bugzilla adapter
67 files changed, 5475 insertions, 0 deletions
diff --git a/org.eclipse.lyo.samples.bugzilla/.classpath b/org.eclipse.lyo.samples.bugzilla/.classpath new file mode 100644 index 0000000..4a6f187 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/.classpath @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" output="target/classes" path="src/main/java"/> + <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> + <classpathentry kind="src" output="target/test-classes" path="src/test/java"/> + <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> + <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> diff --git a/org.eclipse.lyo.samples.bugzilla/.project b/org.eclipse.lyo.samples.bugzilla/.project new file mode 100644 index 0000000..33be0dd --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/.project @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.lyo.samples.bugzilla</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + <dictionary> + <key>LaunchConfigHandle</key> + <value><project>/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.wst.common.project.facet.core.builder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.wst.validation.validationbuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.maven.ide.eclipse.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> + <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.maven.ide.eclipse.maven2Nature</nature> + <nature>org.eclipse.wst.common.project.facet.core.nature</nature> + <nature>org.eclipse.wst.jsdt.core.jsNature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.lyo.samples.bugzilla/README.txt b/org.eclipse.lyo.samples.bugzilla/README.txt new file mode 100644 index 0000000..1581156 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/README.txt @@ -0,0 +1,21 @@ +You must have Subversion and Maven command line tools installed to run this sample. You +must also have Bugzilla 3.4 (or 3.6). Consider using the ALMWorks Bugzilla 3.4 VMWare +image. + + http://almworks.com/vbs/download.html + +To install j2bugzilla, a Bugzilla Java API, into your local maven repository, + +svn checkout http://j2bugzilla.googlecode.com/svn/trunk/ j2bugzilla-read-only +cd j2bugzilla-read-only/JBugz +mvn install + +To run the Bugzilla adapter, edit src/main/resources/bugz.properties to point to your +Bugzilla server. Then from the project root directory, + +mvn install +mvn jetty:run + +The adapter will be running at + +http://localhost:8282/bugz/ diff --git a/org.eclipse.lyo.samples.bugzilla/about.html b/org.eclipse.lyo.samples.bugzilla/about.html new file mode 100644 index 0000000..b4e74aa --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/about.html @@ -0,0 +1,33 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>About</title> +</head> +<body lang="EN-US"> + <h2>About This Content</h2> + <p>October 26, 2011</p> + <h3>License</h3> + <p> + The Eclipse Foundation makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content + is provided to you under the terms and conditions of the Eclipse + Public License Version 1.0 ("EPL") and Eclipse Distribution + License Version 1.0 ("EDL"). A copy of the EPL is available + at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> + and a copy of the EDL is available at <a + href="http://www.eclipse.org/org/documents/edl-v10.php">http://www.eclipse.org/org/documents/edl-v10.php</a>. + For purposes of the EPL, "Program" will mean the Content. + </p> + <p>If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If no such + license exists, contact the Redistributor. Unless otherwise indicated + below, the terms and conditions of the EPL and EDL still apply to any + source code in the Content and such source code may be obtained at + <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p> +</body> +</html>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/license/edl-v10html b/org.eclipse.lyo.samples.bugzilla/license/edl-v10html new file mode 100644 index 0000000..5c8549b --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/license/edl-v10html @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>Eclipse Distribution License - Version 1.0</title> +<style type="text/css"> + body { + size: 8.5in 11.0in; + margin: 0.25in 0.5in 0.25in 0.5in; + tab-interval: 0.5in; + } + p { + margin-left: auto; + margin-top: 0.5em; + margin-bottom: 0.5em; + } + p.list { + margin-left: 0.5in; + margin-top: 0.05em; + margin-bottom: 0.05em; + } + </style> + +</head> + +<body lang="EN-US"> + +<p><b>Eclipse Distribution License - v 1.0</b></p> + +<p>Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. </p> + +<p>All rights reserved.</p> +<p>Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: +<ul><li>Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. </li> +<li>Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. </li> +<li>Neither the name of the Eclipse Foundation, Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. </li></ul> +</p> +<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE.</p> + +</body> + +</html> + diff --git a/org.eclipse.lyo.samples.bugzilla/license/epl-v10.html b/org.eclipse.lyo.samples.bugzilla/license/epl-v10.html new file mode 100644 index 0000000..b398acc --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/license/epl-v10.html @@ -0,0 +1,259 @@ +<!--?xml version="1.0" encoding="ISO-8859-1" ?--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"><head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Eclipse Public License - Version 1.0</title> +<style type="text/css"> + body { + size: 8.5in 11.0in; + margin: 0.25in 0.5in 0.25in 0.5in; + tab-interval: 0.5in; + } + p { + margin-left: auto; + margin-top: 0.5em; + margin-bottom: 0.5em; + } + p.list { + margin-left: 0.5in; + margin-top: 0.05em; + margin-bottom: 0.05em; + } + </style> + +</head> + +<body lang="EN-US"> + +<h2>Eclipse Public License - v 1.0</h2> + +<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR +DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS +AGREEMENT.</p> + +<p><b>1. DEFINITIONS</b></p> + +<p>"Contribution" means:</p> + +<p class="list">a) in the case of the initial Contributor, the initial +code and documentation distributed under this Agreement, and</p> +<p class="list">b) in the case of each subsequent Contributor:</p> +<p class="list">i) changes to the Program, and</p> +<p class="list">ii) additions to the Program;</p> +<p class="list">where such changes and/or additions to the Program +originate from and are distributed by that particular Contributor. A +Contribution 'originates' from a Contributor if it was added to the +Program by such Contributor itself or anyone acting on such +Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) +are not derivative works of the Program.</p> + +<p>"Contributor" means any person or entity that distributes +the Program.</p> + +<p>"Licensed Patents" mean patent claims licensable by a +Contributor which are necessarily infringed by the use or sale of its +Contribution alone or when combined with the Program.</p> + +<p>"Program" means the Contributions distributed in accordance +with this Agreement.</p> + +<p>"Recipient" means anyone who receives the Program under +this Agreement, including all Contributors.</p> + +<p><b>2. GRANT OF RIGHTS</b></p> + +<p class="list">a) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free copyright license to reproduce, prepare derivative works +of, publicly display, publicly perform, distribute and sublicense the +Contribution of such Contributor, if any, and such derivative works, in +source code and object code form.</p> + +<p class="list">b) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free patent license under Licensed Patents to make, use, sell, +offer to sell, import and otherwise transfer the Contribution of such +Contributor, if any, in source code and object code form. This patent +license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, +such addition of the Contribution causes such combination to be covered +by the Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder.</p> + +<p class="list">c) Recipient understands that although each Contributor +grants the licenses to its Contributions set forth herein, no assurances +are provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility to +secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow Recipient +to distribute the Program, it is Recipient's responsibility to acquire +that license before distributing the Program.</p> + +<p class="list">d) Each Contributor represents that to its knowledge it +has sufficient copyright rights in its Contribution, if any, to grant +the copyright license set forth in this Agreement.</p> + +<p><b>3. REQUIREMENTS</b></p> + +<p>A Contributor may choose to distribute the Program in object code +form under its own license agreement, provided that:</p> + +<p class="list">a) it complies with the terms and conditions of this +Agreement; and</p> + +<p class="list">b) its license agreement:</p> + +<p class="list">i) effectively disclaims on behalf of all Contributors +all warranties and conditions, express and implied, including warranties +or conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose;</p> + +<p class="list">ii) effectively excludes on behalf of all Contributors +all liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits;</p> + +<p class="list">iii) states that any provisions which differ from this +Agreement are offered by that Contributor alone and not by any other +party; and</p> + +<p class="list">iv) states that source code for the Program is available +from such Contributor, and informs licensees how to obtain it in a +reasonable manner on or through a medium customarily used for software +exchange.</p> + +<p>When the Program is made available in source code form:</p> + +<p class="list">a) it must be made available under this Agreement; and</p> + +<p class="list">b) a copy of this Agreement must be included with each +copy of the Program.</p> + +<p>Contributors may not remove or alter any copyright notices contained +within the Program.</p> + +<p>Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution.</p> + +<p><b>4. COMMERCIAL DISTRIBUTION</b></p> + +<p>Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use of +the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create +potential liability for other Contributors. Therefore, if a Contributor +includes the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and +indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") +arising from claims, lawsuits and other legal actions brought by a third +party against the Indemnified Contributor to the extent caused by the +acts or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In +order to qualify, an Indemnified Contributor must: a) promptly notify +the Commercial Contributor in writing of such claim, and b) allow the +Commercial Contributor to control, and cooperate with the Commercial +Contributor in, the defense and any related settlement negotiations. The +Indemnified Contributor may participate in any such claim at its own +expense.</p> + +<p>For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages.</p> + +<p><b>5. NO WARRANTY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS +OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, +ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable laws, +damage to or loss of data, programs or equipment, and unavailability or +interruption of operations.</p> + +<p><b>6. DISCLAIMER OF LIABILITY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT +NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p> + +<p><b>7. GENERAL</b></p> + +<p>If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further action +by the parties hereto, such provision shall be reformed to the minimum +extent necessary to make such provision valid and enforceable.</p> + +<p>If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the +date such litigation is filed.</p> + +<p>All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of time +after becoming aware of such noncompliance. If all Recipient's rights +under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.</p> + +<p>Everyone is permitted to copy and distribute copies of this +Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The +Agreement Steward reserves the right to publish new versions (including +revisions) of this Agreement from time to time. No one other than the +Agreement Steward has the right to modify this Agreement. The Eclipse +Foundation is the initial Agreement Steward. The Eclipse Foundation may +assign the responsibility to serve as the Agreement Steward to a +suitable separate entity. Each new version of the Agreement will be +given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the +Agreement under which it was received. In addition, after a new version +of the Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives no +rights or licenses to the intellectual property of any Contributor under +this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved.</p> + +<p>This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No party +to this Agreement will bring a legal action under this Agreement more +than one year after the cause of action arose. Each party waives its +rights to a jury trial in any resulting litigation.</p> + + + +</body></html>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/license/notice.html b/org.eclipse.lyo.samples.bugzilla/license/notice.html new file mode 100644 index 0000000..6569bbf --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/license/notice.html @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>Eclipse Foundation Software User Agreement</title> +</head> + +<body lang="EN-US"> +<h2>Eclipse Foundation Software User Agreement</h2> +<p>February 1, 2011</p> + +<h3>Usage Of Content</h3> + +<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p> + +<h3>Applicable Licenses</h3> + +<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. + For purposes of the EPL, "Program" will mean the Content.</p> + +<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code + repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").</p> + +<ul> + <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").</li> + <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".</li> + <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins + and/or Fragments associated with that Feature.</li> + <li>Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.</li> +</ul> + +<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and +Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module +including, but not limited to the following locations:</p> + +<ul> + <li>The top-level (root) directory</li> + <li>Plug-in and Fragment directories</li> + <li>Inside Plug-ins and Fragments packaged as JARs</li> + <li>Sub-directories of the directory named "src" of certain Plug-ins</li> + <li>Feature directories</li> +</ul> + +<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in +that directory.</p> + +<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p> + +<ul> + <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li> + <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li> + <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li> + <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li> + <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li> + <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li> +</ul> + +<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p> + + +<h3>Use of Provisioning Technology</h3> + +<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse + Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or + other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to + install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a + href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a> + ("Specification").</p> + +<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the + applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology + in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the + Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p> + +<ol> + <li>A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology + on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based + product.</li> + <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be + accessed and copied to the Target Machine.</li> + <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable + Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target + Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern + the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such + indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li> +</ol> + +<h3>Cryptography</h3> + +<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to + another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, + possession, or use, and re-export of encryption software, to see if this is permitted.</p> + +<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p> +</body> +</html> + diff --git a/org.eclipse.lyo.samples.bugzilla/pom.xml b/org.eclipse.lyo.samples.bugzilla/pom.xml new file mode 100644 index 0000000..9d11324 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/pom.xml @@ -0,0 +1,125 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.eclipse.lyo.server</groupId> + <artifactId>bugzillaadapter-complete</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>war</packaging> + + <name>bugzillaadapter-complete</name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <repositories> + <repository> + <id>Jenabean</id> + <url>http://jenabean.googlecode.com/svn/repo</url> + </repository> + </repositories> + + <dependencies> + + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-servlet_2.5_spec</artifactId> + <version>1.2</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>com.hp.hpl.jena</groupId> + <artifactId>jena</artifactId> + <version>2.6.4</version> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.1.1</version> + </dependency> + + <dependency> + <groupId>org.apache.xmlrpc</groupId> + <artifactId>xmlrpc-client</artifactId> + <version>3.1.3</version> + </dependency> + + <dependency> + <groupId>thewebsemantic</groupId> + <artifactId>jenabean</artifactId> + <version>1.0.6</version> + </dependency> + + <!-- + To install j2bugzilla in your local maven repository, + + svn checkout http://j2bugzilla.googlecode.com/svn/trunk/ j2bugzilla-read-only + cd j2bugzilla-read-only/JBugz + mvn install + + --> + <dependency> + <groupId>j2bugzilla</groupId> + <artifactId>j2bugzilla</artifactId> + <version>0.2</version> + </dependency> + + </dependencies> + + <build> + <finalName>bugz</finalName> + + <plugins> + + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <version>7.3.0.v20110203</version> + + <configuration> + <webAppConfig> + <contextPath>/bugz</contextPath> + </webAppConfig> + + <!-- Jetty config adds logging --> + <jettyConfig>${project.build.directory}/classes/jetty.xml</jettyConfig> + + <scanIntervalSeconds>10</scanIntervalSeconds> + + <systemProperties> + + <systemProperty> + <name>config.dir</name> + <value>${basedir}/src/test/resources</value> + </systemProperty> + + <systemProperty> + <name>jetty.logs</name> + <value>${basedir}/target</value> + </systemProperty> + + <systemProperty> + <name>jetty.port</name> + <value>8282</value> + </systemProperty> + + </systemProperties> + + </configuration> + </plugin> + + </plugins> + + </build> + +</project> diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/BugzillaInitializer.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/BugzillaInitializer.java new file mode 100644 index 0000000..94891c4 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/BugzillaInitializer.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.IOException; +import java.util.Properties; + +import jbugz.base.BugzillaConnector; +import jbugz.exceptions.BugzillaException; +import jbugz.exceptions.ConnectionException; +import jbugz.rpc.LogIn; + +public class BugzillaInitializer { + + private static String baseUri = null; + private static String bugzillaUri = null; + private static String username = null; + private static String password = null; + private static boolean provideHtml = true; + + static { + Properties props = new Properties(); + try { + props.load(BugzillaInitializer.class.getResourceAsStream("/bugz.properties")); + baseUri = props.getProperty("adapter_uri"); + bugzillaUri = props.getProperty("bugzilla_uri"); + username = props.getProperty("username"); + password = props.getProperty("password"); + if (props.getProperty("provideHtml") != null) { + provideHtml = Boolean.parseBoolean(props.getProperty("provideHtml")); + } + System.out.println("adapter_uri: " + baseUri); + System.out.println("bugzilla_uri: " + bugzillaUri); + System.out.println("username: " + username); + System.out.println("password: " + password); + System.out.println("provideHtml: " + provideHtml); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static BugzillaConnector getBugzillaConnector() throws ConnectionException, BugzillaException { + BugzillaConnector bc = new BugzillaConnector(); + bc.connectTo(bugzillaUri + "/xmlrpc.cgi"); + LogIn login = new LogIn(username, password); + bc.executeMethod(login); + return bc; + } + + public static String getBaseUri() { + return baseUri; + } + + public static void setBaseUri(String baseUri) { + BugzillaInitializer.baseUri = baseUri; + } + + public static String getBugzillaUri() { + return bugzillaUri; + } + + public static void setBugzillaUri(String bugzillaUri) { + BugzillaInitializer.bugzillaUri = bugzillaUri; + } + + public static String getUsername() { + return username; + } + + public static void setUsername(String username) { + BugzillaInitializer.username = username; + } + + public static String getPassword() { + return password; + } + + public static void setPassword(String password) { + BugzillaInitializer.password = password; + } + + public static boolean isProvideHtml() { + return provideHtml; + } + + public static void setProvideHtml(boolean aProvideHtml) { + provideHtml = aProvideHtml; + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCollectionService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCollectionService.java new file mode 100644 index 0000000..2d91cbd --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCollectionService.java @@ -0,0 +1,193 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import jbugz.base.Bug; +import jbugz.base.BugzillaConnector; +import jbugz.exceptions.BugzillaException; +import jbugz.exceptions.ConnectionException; +import jbugz.exceptions.InvalidDescriptionException; +import jbugz.rpc.ReportBug; + +import org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.ExtendedBugSearch; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetProducts; +import org.eclipse.lyo.samples.bugzilla.resources.BugzillaChangeRequest; +import org.eclipse.lyo.samples.bugzilla.resources.Person; +import org.eclipse.lyo.samples.bugzilla.utils.AcceptType; + +import thewebsemantic.RDF2Bean; + +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; + + +/** + * OSLC CM Change Request Service + */ +public class ChangeRequestCollectionService extends HttpServlet { + private static final long serialVersionUID = -5280734755943517104L; + + public ChangeRequestCollectionService() {} + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + String lang = null; + if (request.getContentType().startsWith("application/rdf+xml")) { + lang = "RDF/XML"; + } else if (request.getContentType().startsWith("text/turtle")) { + lang = "TURTLE"; + } else { + response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); + return; + } + + Collection<BugzillaChangeRequest> changeRequests = readChangeRequests( + request, lang); + if (changeRequests.isEmpty()) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + return; + } + + try { + createChangeRequests(response, changeRequests); + response.setHeader("OSLC-Core-Version", "2.0"); + response.setStatus(HttpServletResponse.SC_CREATED); + } catch (Exception e) { + throw new ServletException(e); + } + } + + private void createChangeRequests(HttpServletResponse response, + Collection<BugzillaChangeRequest> changeRequests) + throws ConnectionException, BugzillaException, InvalidDescriptionException { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + + for (BugzillaChangeRequest cr : changeRequests) { + ReportBug reportBug = new ReportBug(cr.toBug()); + bc.executeMethod(reportBug); + String bugUri = URLStrategy.getChangeRequestURL(reportBug + .getID()); + response.addHeader("Location", bugUri); + } + } + + private Collection<BugzillaChangeRequest> readChangeRequests( + HttpServletRequest request, String lang) throws IOException { + String dummyBase = BugzillaInitializer.getBaseUri() + "/changerequest"; + Model model = ModelFactory.createDefaultModel(); + model.read(request.getInputStream(), dummyBase, lang); + + RDF2Bean reader = new RDF2Bean(model); + reader.bind(BugzillaChangeRequest.class); + reader.bind(Person.class); + + return reader.load(BugzillaChangeRequest.class); + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + int page = 0; + int limit = 20; + + Product product = null; + try { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + + String pageString = request.getParameter("page"); + if (null != pageString) { + page = Integer.parseInt(pageString); + } + int productId = Integer.parseInt(request.getParameter("productId")); + + Integer[] productIds = { productId }; + + GetProducts getProducts = new GetProducts(productIds); + bc.executeMethod(getProducts); + List<Product> products = getProducts.getProducts(); + product = products.get(0); + + } catch (Exception e) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + + try { + final String dispatchTo; + if (AcceptType.willAccept("text/html", request) && BugzillaInitializer.isProvideHtml()) { + dispatchTo = "/cm/changerequest_collection_html.jsp"; + + } else if (AcceptType.willAccept("application/rdf+xml", request)) { + dispatchTo = "/cm/changerequest_collection_rdfxml.jsp"; + + } else { + response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); + return; + } + + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + ExtendedBugSearch bugSearch = new ExtendedBugSearch( + ExtendedBugSearch.ExtendedSearchLimiter.PRODUCT, + product.getName()); + + // request one extra to see if there's more + bugSearch.addQueryParam(ExtendedBugSearch.ExtendedSearchLimiter.LIMIT, (limit + 1) + ""); + bugSearch.addQueryParam(ExtendedBugSearch.ExtendedSearchLimiter.OFFSET, (page * limit) + ""); + bc.executeMethod(bugSearch); + List<Bug> results = bugSearch.getSearchResults(); + request.setAttribute("results", results); + + request.setAttribute("product", product); + request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri()); + request.setAttribute("queryUri", + URLStrategy.getChangeRequestCollectionURL(product.getId()) + + "&oslc.paging=true"); + + if (results.size() > limit) { + results.remove(results.size() - 1); // remove that one extra bug + request.setAttribute("nextPageUri", + URLStrategy.getChangeRequestCollectionURL(product.getId()) + + "&oslc.paging=true&page=" + (page + 1)); + } + + for (Bug bug : results) { + bug.getInternalState().put("oslc_uri", URLStrategy.getChangeRequestURL(bug.getID())); + } + + response.setHeader("OSLC-Core-Version", "2.0"); + final RequestDispatcher rd = request.getRequestDispatcher(dispatchTo); + rd.forward(request, response); + response.flushBuffer(); + + } catch (Throwable e) { + throw new ServletException(e); + } + } +} +
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCreatorService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCreatorService.java new file mode 100644 index 0000000..d5ec3de --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestCreatorService.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import jbugz.base.Bug; +import jbugz.base.BugzillaConnector; +import jbugz.rpc.ReportBug; + +import org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetLegalValues; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetProducts; +import org.eclipse.lyo.samples.bugzilla.utils.StringUtils; + + +/** + * GET returns Delegated UI and POST accepts form post of new bug data. + * Relies on new J2Bugzilla methods: GetProducts, GetAccessibleProducts and GetLegalValues. + */ +public class ChangeRequestCreatorService extends HttpServlet { + private static final long serialVersionUID = 7466374797163202313L; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + Product product = null; + try { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + + int productId = Integer.parseInt(request.getParameter("productId")); + Integer[] productIds = { productId }; + + GetProducts getProducts = new GetProducts(productIds); + bc.executeMethod(getProducts); + List<Product> products = getProducts.getProducts(); + product = products.get(0); + request.setAttribute("product", product); + + } catch (Exception e) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + + try { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + + GetLegalValues getComponentValues = + new GetLegalValues("component", product.getId()); + bc.executeMethod(getComponentValues); + List<String> components = Arrays.asList(getComponentValues.getValues()); + request.setAttribute("components", components); + + GetLegalValues getOsValues = new GetLegalValues("op_sys", -1); + bc.executeMethod(getOsValues); + List<String> operatingSystems = Arrays.asList(getOsValues.getValues()); + request.setAttribute("operatingSystems", operatingSystems); + + GetLegalValues getPlatformValues = new GetLegalValues("platform", -1); + bc.executeMethod(getPlatformValues); + List<String> platforms = Arrays.asList(getPlatformValues.getValues()); + request.setAttribute("platforms", platforms); + + GetLegalValues getVersionValues = new GetLegalValues("version", product.getId()); + bc.executeMethod(getVersionValues); + List<String> versions = Arrays.asList(getVersionValues.getValues()); + request.setAttribute("versions", versions); + + request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri()); + + RequestDispatcher rd = request.getRequestDispatcher("/cm/changerequest_creator.jsp"); + rd.forward(request, response); + + } catch (Exception e) { + throw new ServletException(e); + } + } + + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + System.err.println("CRCreator.doPOST - Accept: " + request.getHeader("Accept") + ", query="+request.getQueryString()); + + try { + + int productId = Integer.parseInt(request.getParameter("productId")); + Integer[] productIds = { productId }; + + String prefill = request.getParameter("prefill"); + + if (StringUtils.isEmpty(prefill) || "true".equals(prefill)) { + // TODO: Implement form prefill, just return same dialog URL in Location for now + response.setHeader("Location", URLStrategy.getDelegatedCreationURL(productId)); + response.setStatus(201); + return; + + } + + + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + GetProducts getProducts = new GetProducts(productIds); + bc.executeMethod(getProducts); + List<Product> products = getProducts.getProducts(); + + String summary = request.getParameter("summary"); + String component = request.getParameter("component"); + String version = request.getParameter("version"); + String op_sys = request.getParameter("op_sys"); + String platform = request.getParameter("platform"); + + Map<String, Object> bugState = new HashMap<String, Object>(); + + bugState.put("product", products.get(0).getName()); + bugState.put("component", component); + bugState.put("summary", summary); + bugState.put("version", version); + bugState.put("op_sys", op_sys); + bugState.put("platform", platform); + + System.err.println("Bug="+bugState); + + Bug bug = new Bug(bugState); + ReportBug reportBug = new ReportBug(bug); + bc.executeMethod(reportBug); + + // Send back to the form a small JSON response + response.setContentType("application/json"); + response.setStatus(201); // Created + PrintWriter out = response.getWriter(); + out.print("{\"title\": \"" + URLStrategy.getChangeRequestLinkLabel(reportBug.getID(), summary) + "\"," + + "\"resource\" : \"" + URLStrategy.getChangeRequestURL(reportBug.getID()) + "\"}"); + out.close(); + + } catch (Exception e) { + throw new ServletException(e); + } + } + + +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestSelectorService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestSelectorService.java new file mode 100644 index 0000000..4ca7591 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestSelectorService.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import jbugz.base.Bug; +import jbugz.base.BugzillaConnector; +import jbugz.rpc.BugSearch; + +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.ExtendedBugSearch; + + +/** + * Servlet implementation class ResourceFactory + */ +public class ChangeRequestSelectorService extends HttpServlet { + private static final long serialVersionUID = 6114613293834136389L; + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + int productId = Integer.parseInt(request.getParameter("productId")); + String terms = request.getParameter("terms"); + + request.setAttribute("productId", productId); + request.setAttribute("terms", terms); + request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri()); + + if (terms != null ) { + sendFilteredBugsReponse(productId, terms, request, response); + + } else { + try { + RequestDispatcher rd = request.getRequestDispatcher("/cm/changerequest_selector.jsp"); + rd.forward(request, response); + + } catch (Exception e) { + throw new ServletException(e); + } + } + } + + private void sendFilteredBugsReponse( + int productId, String terms, HttpServletRequest request, HttpServletResponse response) + throws ServletException { + try { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + ExtendedBugSearch bugSearch = new ExtendedBugSearch(BugSearch.SearchLimiter.SUMMARY, terms); + bc.executeMethod(bugSearch); + List<Bug> results = bugSearch.getSearchResults(); + request.setAttribute("results", results); + + RequestDispatcher rd = request.getRequestDispatcher("/cm/changerequest_filtered_json.jsp"); + rd.forward(request, response); + + } catch (Exception e) { + throw new ServletException(e); + } + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestService.java new file mode 100644 index 0000000..e1c993d --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ChangeRequestService.java @@ -0,0 +1,260 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import jbugz.base.Bug; +import jbugz.base.BugzillaConnector; +import jbugz.exceptions.BugzillaException; +import jbugz.exceptions.ConnectionException; +import jbugz.exceptions.InvalidDescriptionException; +import jbugz.rpc.CommentBug; + +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.ExtendedGetBug; +import org.eclipse.lyo.samples.bugzilla.resources.BugzillaChangeRequest; +import org.eclipse.lyo.samples.bugzilla.resources.Person; +import org.eclipse.lyo.samples.bugzilla.utils.AcceptType; + +import thewebsemantic.Bean2RDF; +import thewebsemantic.RDF2Bean; + +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.hp.hpl.jena.vocabulary.RDF; + + +/** + * OSLC CM Change Request Service + */ +public class ChangeRequestService extends HttpServlet { + private static final long serialVersionUID = -5280734755943517104L; + + private static final Map<String, String> PREFIXES = new HashMap<String, String>(); + static { + PREFIXES.put("oslc", "http://open-services.net/ns/core#"); + PREFIXES.put("oslc_cm", "http://open-services.net/ns/cm#"); + PREFIXES.put("dcterms", "http://purl.org/dc/terms/"); + PREFIXES.put("foaf", "http://xmlns.com/foaf/0.1/"); + PREFIXES.put("bugz", "http://www.bugzilla.org/rdf#"); + } + + public ChangeRequestService() {} + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + System.err.println("CR.doGET - Accept: " + request.getHeader("Accept") + ", query="+request.getQueryString()); + + int bugId = -1; + Bug bug = null; + try { + bugId = Integer.parseInt(request.getParameter("id")); + final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + final ExtendedGetBug getBug = new ExtendedGetBug(bugId); + bc.executeMethod(getBug); + bug = getBug.getBug(); + if (bug == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + } catch (ConnectionException e) { + e.printStackTrace(); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return; + } catch (BugzillaException e) { + e.printStackTrace(); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return; + } + + try { + final String dispatchTo; + final String preview = request.getParameter("preview"); + + if ("small".equals(preview)) { + dispatchTo = "/cm/changerequest_preview_small.jsp"; + + } else if ("large".equals(preview)) { + dispatchTo = "/cm/changerequest_preview_large.jsp"; + + } else if (AcceptType.willAccept("application/x-oslc-compact+xml", request)) { + dispatchTo = "/cm/changerequest_preview_desc.jsp"; + + } else if (AcceptType.willAccept("text/html", request) && BugzillaInitializer.isProvideHtml()) { + response.sendRedirect(BugzillaInitializer.getBugzillaUri() + "/show_bug.cgi?id=" + bugId); + return; + + } else if (AcceptType.willAccept("application/rdf+xml", request)) { + response.setHeader("OSLC-Core-Version", "2.0"); + response.setHeader("Content-Type", "application/rdf+xml"); + sendRdfResponse(response, bug, "RDF/XML"); + return; + + } else if (AcceptType.willAccept("text/turtle", request)) { + response.setHeader("OSLC-Core-Version", "2.0"); + response.setHeader("Content-Type", "text/turtle"); + sendRdfResponse(response, bug, "TURTLE"); + return; + + } else { + response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); + return; + } + + request.setAttribute("bugUri", URLStrategy.getChangeRequestURL(bug.getID())); + request.setAttribute("bug", bug); + request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri()); + + response.setHeader("OSLC-Core-Version", "2.0"); + final RequestDispatcher rd = request.getRequestDispatcher(dispatchTo); + rd.forward(request, response); + response.flushBuffer(); + + } catch (Throwable e) { + throw new ServletException(e); + } + } + + private void sendRdfResponse(HttpServletResponse response, Bug bug, + String lang) throws URISyntaxException, IOException { + Model m = ModelFactory.createDefaultModel(); + m.setNsPrefixes(PREFIXES); + Bean2RDF writer = new Bean2RDF(m); + writer.save(BugzillaChangeRequest.fromBug(bug)); + removeUnnecessaryStatements(m); + m.write(response.getOutputStream(), lang); + response.flushBuffer(); + } + + /** + * Remove some extra stuff Jenabean puts in the model that we don't want. + * + * @param model + * the model + */ + private void removeUnnecessaryStatements(Model model) { + model.removeAll(model.createResource("http://thewebsemantic.com/javaclass"), null, null); + model.removeAll(null, model.createProperty("http://thewebsemantic.com/javaclass"), null); + model.removeAll(null, RDF.type, model.createResource("http://www.w3.org/2000/01/rdf-schema#Class")); + } + + protected void doPut(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + System.err.println("CR.doPUT - Accept: " + request.getHeader("Accept") + + ", query=" + request.getQueryString()); + + if (!request.getContentType().startsWith("application/rdf+xml")) { + response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); + return; + } + + try { + BugzillaChangeRequest cr = readChangeRequest(request); + if (cr == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + + updateBug(request, cr); + response.setStatus(HttpServletResponse.SC_NO_CONTENT); + } catch (Exception e) { + throw new ServletException(e); + } + } + + private void updateBug(HttpServletRequest request, BugzillaChangeRequest cr) + throws ConnectionException, BugzillaException, + InvalidDescriptionException { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + // No built in field to hold external links. Just add the new link as a comment for now. + String comment = getLinksComment(cr); + if (comment.length() != 0) { + CommentBug bugzillaMethod = new CommentBug(Integer.parseInt(cr.getIdentifier()), comment); + bc.executeMethod(bugzillaMethod); + } + } + + public void addLinkComment(StringBuffer buffer, String linkType, + Collection<URI> links) { + if (links != null && !links.isEmpty()) { + buffer.append(linkType); + buffer.append(":\n\n"); + for (URI link : links) { + buffer.append(link.toString()); + buffer.append("\n"); + } + } + } + + private String getLinksComment(BugzillaChangeRequest cr) { + StringBuffer b = new StringBuffer(); + + addLinkComment(b, "Affected by Defect", cr.getAffectedByDefect()); + addLinkComment(b, "Affects Plan Item", cr.getAffectsPlanItem()); + addLinkComment(b, "Affects Requirement", cr.getAffectsRequirement()); + addLinkComment(b, "Affects Test Result", cr.getAffectsTestResult()); + addLinkComment(b, "Blocks Test Execution Record", cr.getBlocksTestExecutionRecord()); + addLinkComment(b, "Implements Requirement", cr.getImplementsRequirement()); + addLinkComment(b, "Related Change Request", cr.getRelatedChangeRequest()); + addLinkComment(b, "Related Test Execution Record", cr.getRelatedTestExecutionRecord()); + addLinkComment(b, "Related Test Plane", cr.getRelatedTestPlan()); + addLinkComment(b, "Related Test Script", cr.getRelatedTestScript()); + addLinkComment(b, "Tested by Test Case", cr.getTestedByTestCase()); + addLinkComment(b, "Tracks Change Set", cr.getTracksChangeSet()); + addLinkComment(b, "Tracks Requirement", cr.getTracksRequirement()); + + return b.toString(); + } + + private BugzillaChangeRequest readChangeRequest(HttpServletRequest request) + throws URISyntaxException, IOException { + String bugURI = getFullRequestURL(request); + Model model = ModelFactory.createOntologyModel(); + model.read(request.getInputStream(), bugURI); + + RDF2Bean reader = new RDF2Bean(model); + reader.bind(BugzillaChangeRequest.class); + reader.bind(Person.class); + + return reader.load(BugzillaChangeRequest.class, + new URI(bugURI)); + } + + private String getFullRequestURL(HttpServletRequest request) { + StringBuffer url = request.getRequestURL(); + String queryString = request.getQueryString(); + if (queryString != null) { + url.append("?"); + url.append(queryString); + } + + return url.toString(); + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ConsumerKeyService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ConsumerKeyService.java new file mode 100644 index 0000000..6f4dcda --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ConsumerKeyService.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class ConsumerKeyService extends HttpServlet { + + @Override + public void init(ServletConfig config) throws ServletException { + super.init(config); + } + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + + returnConsumerKey(request, response); + } + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + returnConsumerKey(request, response); + } + + private void returnConsumerKey(HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + // TODO: Properly handle consumer key requests from JTS + response.setContentType("application/json"); + PrintWriter out = response.getWriter(); + out.print("{\"key\":\"rtc\"}"); + out.close(); + } + + private static final long serialVersionUID = -7611240899575174568L; + +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/CreationShapeService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/CreationShapeService.java new file mode 100644 index 0000000..167dd27 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/CreationShapeService.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import jbugz.base.BugzillaConnector; + +import org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetAccessibleProducts; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetLegalValues; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetProducts; +import org.eclipse.lyo.samples.bugzilla.utils.AcceptType; + + +/** + * OSLC CM Change Request Service + */ +public class CreationShapeService extends HttpServlet { + private static final long serialVersionUID = -5280734755943517104L; + + public CreationShapeService() {} + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + try { + int productId = Integer.parseInt(request.getParameter("productId")); + Integer[] productIds = { productId }; + + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + GetProducts getProducts = new GetProducts(productIds); + bc.executeMethod(getProducts); + List<Product> products = getProducts.getProducts(); + request.setAttribute("product", products.get(0)); + + } catch (Exception e) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + + try { + final String dispatchTo; + if (AcceptType.willAccept("application/rdf+xml", request)) { + dispatchTo = "/cm/resourceshape_creation_rdfxml.jsp"; + + } else { + response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); + return; + } + + final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri()); + + GetAccessibleProducts getProductIds = new GetAccessibleProducts(); + bc.executeMethod(getProductIds); + Integer[] productIds = getProductIds.getIds(); + + GetProducts getProducts = new GetProducts(productIds); + bc.executeMethod(getProducts); + Product product = getProducts.getProducts().get(0); + request.setAttribute("product", product); + + GetLegalValues getComponentValues = + new GetLegalValues("component", product.getId()); + bc.executeMethod(getComponentValues); + List<String> components = Arrays.asList(getComponentValues.getValues()); + request.setAttribute("components", components); + + GetLegalValues getOsValues = new GetLegalValues("op_sys", -1); + bc.executeMethod(getOsValues); + List<String> operatingSystems = Arrays.asList(getOsValues.getValues()); + request.setAttribute("operatingSystems", operatingSystems); + + GetLegalValues getPlatformValues = new GetLegalValues("platform", -1); + bc.executeMethod(getPlatformValues); + List<String> platforms = Arrays.asList(getPlatformValues.getValues()); + request.setAttribute("platforms", platforms); + + GetLegalValues getVersionValues = new GetLegalValues("version", product.getId()); + bc.executeMethod(getVersionValues); + List<String> versions = Arrays.asList(getVersionValues.getValues()); + request.setAttribute("versions", versions); + + response.setHeader("OSLC-Core-Version", "2.0"); + final RequestDispatcher rd = request.getRequestDispatcher(dispatchTo); + rd.forward(request, response); + response.flushBuffer(); + + } catch (Throwable e) { + throw new ServletException(e); + } + } +} +
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/QueryShapeService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/QueryShapeService.java new file mode 100644 index 0000000..1f7b7ec --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/QueryShapeService.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import jbugz.base.BugzillaConnector; + +import org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetAccessibleProducts; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetLegalValues; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetProducts; +import org.eclipse.lyo.samples.bugzilla.utils.AcceptType; + + +/** + * OSLC CM Change Request Service + */ +public class QueryShapeService extends HttpServlet { + private static final long serialVersionUID = -5280734755943517104L; + + public QueryShapeService() {} + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet( + HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + try { + int productId = Integer.parseInt(request.getParameter("productId")); + Integer[] productIds = { productId }; + + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + GetProducts getProducts = new GetProducts(productIds); + bc.executeMethod(getProducts); + List<Product> products = getProducts.getProducts(); + request.setAttribute("product", products.get(0)); + + } catch (Exception e) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + + try { + final String dispatchTo; + if (AcceptType.willAccept("application/rdf+xml", request)) { + if ("changerequest".equals(request.getParameter("shape"))) { + dispatchTo = "/cm/resourceshape_query_cr_rdfxml.jsp"; + } else { + dispatchTo = "/cm/resourceshape_query_rdfxml.jsp"; + } + } else { + response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); + return; + } + + final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri()); + + GetAccessibleProducts getProductIds = new GetAccessibleProducts(); + bc.executeMethod(getProductIds); + Integer[] productIds = getProductIds.getIds(); + + GetProducts getProducts = new GetProducts(productIds); + bc.executeMethod(getProducts); + Product product = getProducts.getProducts().get(0); + request.setAttribute("product", product); + + GetLegalValues getComponentValues = + new GetLegalValues("component", product.getId()); + bc.executeMethod(getComponentValues); + List<String> components = Arrays.asList(getComponentValues.getValues()); + request.setAttribute("components", components); + + GetLegalValues getOsValues = new GetLegalValues("op_sys", -1); + bc.executeMethod(getOsValues); + List<String> operatingSystems = Arrays.asList(getOsValues.getValues()); + request.setAttribute("operatingSystems", operatingSystems); + + GetLegalValues getPlatformValues = new GetLegalValues("platform", -1); + bc.executeMethod(getPlatformValues); + List<String> platforms = Arrays.asList(getPlatformValues.getValues()); + request.setAttribute("platforms", platforms); + + GetLegalValues getVersionValues = new GetLegalValues("version", product.getId()); + bc.executeMethod(getVersionValues); + List<String> versions = Arrays.asList(getVersionValues.getValues()); + request.setAttribute("versions", versions); + + response.setHeader("OSLC-Core-Version", "2.0"); + final RequestDispatcher rd = request.getRequestDispatcher(dispatchTo); + rd.forward(request, response); + response.flushBuffer(); + + } catch (Throwable e) { + throw new ServletException(e); + } + } +} +
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/RootServicesService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/RootServicesService.java new file mode 100644 index 0000000..05ff150 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/RootServicesService.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * Jazz Root Services Service, see:
+ * https://jazz.net/wiki/bin/view/Main/RootServicesSpec
+ * https://jazz.net/wiki/bin/view/Main/RootServicesSpecAddendum2
+ */
+public class RootServicesService extends HttpServlet {
+
+ private static final long serialVersionUID = -8125286361811879744L;
+
+ /**
+ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ System.err.println("RootServices.doGET - Accept: " + request.getHeader("Accept"));
+ request.setAttribute("baseUri", BugzillaInitializer.getBaseUri());
+
+ final RequestDispatcher rd = request.getRequestDispatcher("/cm/rootservices_rdfxml.jsp");
+ rd.forward(request, response);
+ response.flushBuffer();
+ }
+}
+
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderCatalogService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderCatalogService.java new file mode 100644 index 0000000..f0e9145 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderCatalogService.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import jbugz.base.BugzillaConnector; + +import org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetAccessibleProducts; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetProducts; +import org.eclipse.lyo.samples.bugzilla.utils.AcceptType; + +/** + * OSLC CM Change Request Service + */ +public class ServiceProviderCatalogService extends HttpServlet { + + private static final long serialVersionUID = -5280734755943517104L; + + public ServiceProviderCatalogService() { + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + try { + System.err.println("SPC.doGET Accept: " + request.getHeader("Accept")); + final String dispatchTo; + if (AcceptType.willAccept("text/html", request) && BugzillaInitializer.isProvideHtml()) { + dispatchTo = "/cm/serviceprovidercatalog_html.jsp"; + + } else if (AcceptType.willAccept("application/rdf+xml", request) || + AcceptType.willAccept("application/xml", request)) { + dispatchTo = "/cm/serviceprovidercatalog_rdfxml.jsp"; + + } else { + response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); + return; + } + + final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri()); + + GetAccessibleProducts getProductIds = new GetAccessibleProducts(); + bc.executeMethod(getProductIds); + Integer[] productIds = getProductIds.getIds(); + + GetProducts getProducts = new GetProducts(productIds); + bc.executeMethod(getProducts); + List<Product> products = getProducts.getProducts(); + request.setAttribute("products", products); + + response.setHeader("OSLC-Core-Version", "2.0"); + final RequestDispatcher rd = request.getRequestDispatcher(dispatchTo); + rd.forward(request, response); + response.flushBuffer(); + + } catch (Throwable e) { + throw new ServletException(e); + } + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderService.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderService.java new file mode 100644 index 0000000..81f9ac0 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/ServiceProviderService.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import jbugz.base.BugzillaConnector;
+
+import org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product;
+import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetAccessibleProducts;
+import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetProducts;
+import org.eclipse.lyo.samples.bugzilla.utils.AcceptType;
+import org.eclipse.lyo.samples.bugzilla.utils.StringUtils;
+
+
+/**
+ * OSLC CM Change Request Service
+ */
+public class ServiceProviderService extends HttpServlet {
+ private static final long serialVersionUID = -5280734755943517104L;
+
+ public ServiceProviderService() {}
+
+ /**
+ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ System.err.println("SP.doGET - Accept: " + request.getHeader("Accept"));
+
+ try {
+ int productId = Integer.parseInt(request.getParameter("productId"));
+ Integer[] productIds = { productId };
+
+ BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ GetProducts getProducts = new GetProducts(productIds);
+ bc.executeMethod(getProducts);
+ List<Product> products = getProducts.getProducts();
+ request.setAttribute("product", products.get(0));
+
+ } catch (Exception e) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+
+ try {
+ final String dispatchTo;
+ String accept = request.getHeader("Accept");
+
+ if (StringUtils.isEmpty(accept) || AcceptType.willAccept("application/rdf+xml", request)
+ || AcceptType.willAccept("application/xml", request)) {
+ dispatchTo = "/cm/serviceprovider_rdfxml.jsp";
+
+ } else if (AcceptType.willAccept("text/html", request)) {
+ dispatchTo = "/cm/serviceprovider_html.jsp";
+ } else {
+ response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
+ return;
+ }
+
+ final BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector();
+ request.setAttribute("baseUri", BugzillaInitializer.getBaseUri());
+ request.setAttribute("bugzillaUri", BugzillaInitializer.getBugzillaUri());
+
+ GetAccessibleProducts getProductIds = new GetAccessibleProducts();
+ bc.executeMethod(getProductIds);
+ Integer[] productIds = getProductIds.getIds();
+
+ GetProducts getProducts = new GetProducts(productIds);
+ bc.executeMethod(getProducts);
+ List<Product> products = getProducts.getProducts();
+ request.setAttribute("products", products);
+
+ final RequestDispatcher rd = request.getRequestDispatcher(dispatchTo);
+ rd.forward(request, response);
+ response.flushBuffer();
+
+ } catch (Throwable e) {
+ throw new ServletException(e);
+ }
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ // TODO Auto-generated method stub
+ System.err.println("ServiceProvider POST");
+ }
+
+ @Override
+ protected void doPut(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ // TODO Auto-generated method stub
+ System.err.println("ServiceProvider PUTT");
+ }
+}
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/URLStrategy.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/URLStrategy.java new file mode 100644 index 0000000..78ce2c2 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/URLStrategy.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.lyo.samples.bugzilla; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +/** + * Centralized URL creation + */ +public class URLStrategy { + private static String baseUri = BugzillaInitializer.getBaseUri(); + private static String bugzillaUri = BugzillaInitializer.getBugzillaUri(); + + public static String getChangeRequestURL(int id) { + return baseUri + "/changerequest?id=" + id; + } + + /** One URL for both creation, retrieval and query */ + public static String getChangeRequestCollectionURL(int productId) { + return baseUri + "/changerequests?productId=" + productId; + } + + public static String getServiceProviderCatalogURL() { + return baseUri + "/catalog"; + } + + public static String getServiceProviderURL(int productId) { + return baseUri + "/provider?productId=" + productId; + } + + public static String getDelegatedCreationURL(int productId) { + return baseUri + "/creator?productId=" + productId; + } + + public static String getDelegatedSelectionURL(int productId) { + return baseUri + "/selector?productId=" + productId; + } + + public static String getCreationShapeURL(int productId) { + return baseUri + "/creationshape?productId=" + productId; + } + + public static String getQueryShapeURL(int productId) { + return baseUri + "/queryshape?productId=" + productId; + } + + public static String getQueryChangeRequestShapeURL(int productId) { + return baseUri + "/queryshape?productId=" + productId + "&shape=changerequest"; + } + + public static String getPersonURL(String email) + throws UnsupportedEncodingException { + return baseUri + "/person?mbox=" + URLEncoder.encode(email, "UTF-8"); + } + + public static String getBugzillaBugURL(int id) { + return BugzillaInitializer.getBugzillaUri() + "/show_bug.cgi?id=" + id; + } + + public static String getIconURL() { + return bugzillaUri + "/images/favicon.ico"; + } + + /** + * Defines what label to use for Bug URLs in: delegated dialog responses and UI preview + * @param bugId + * @param summary + * @return A formated one-liner combining bug id and summary + */ + public static String getChangeRequestLinkLabel(int bugId, String summary) { + return "Bug " + bugId + ": " + summary; + } + + +} + diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/base/Product.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/base/Product.java new file mode 100644 index 0000000..c24a70c --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/base/Product.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.jbugzx.base; + +import java.util.Map; + +public class Product { + private Map<String, Object> internalState; + + public Product(Map<String, Object> state) { + internalState = state; + } + + public Map<String, Object> getInternalState() { + return internalState; + } + + public int getId() { + return (Integer)internalState.get("id"); + } + + public String getName() { + return (String)internalState.get("name"); + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedBugSearch.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedBugSearch.java new file mode 100644 index 0000000..3792a15 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedBugSearch.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.jbugzx.rpc; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import jbugz.base.Bug; +import jbugz.exceptions.InvalidDescriptionException; +import jbugz.rpc.BugSearch; + +/** + * Adds additional search limiters to those provided by j2bugzilla and fixes a + * bug reading the version property. + * + * @author Samuel Padgett <spadgett@us.ibm.com> + */ +public class ExtendedBugSearch extends BugSearch { + private Map<Object, Object> hash = new HashMap<Object, Object>(); + + /** + * Private logging instance + */ + private static final Log LOG = LogFactory.getLog(ExtendedBugSearch.class); + + public enum ExtendedSearchLimiter { + /** + * The maximum number of bugs to return. + */ + LIMIT("limit"), + + /** + * An offset into bugs returned by search. + */ + OFFSET("offset"), + + /** + * The product affected by this bug. + */ + PRODUCT("product"); + + private final String name; + + /** + * Creates a new {@link ExtendedSearchLimiter} with the designated name + * + * @param name + * The name Bugzilla expects for this search limiter + */ + ExtendedSearchLimiter(String name) { + this.name = name; + } + + /** + * Get the name Bugzilla expects for this search limiter + * + * @return A <code>String</code> representing the search limiter + */ + String getName() { + return this.name; + } + } + + public ExtendedBugSearch(BugSearch.SearchLimiter limit, String query) { + super(limit, query); + } + + public ExtendedBugSearch(ExtendedSearchLimiter limit, String query) { + // We have to add a bogus search limiter and remove it since + // the only consutrctor for the parent class takes a + // BugSearch.SearchLimiter. Instead of subclassing BugSearch, + // we should submit a patch back to j2bugzilla that adds + // additional limiters. + super(BugSearch.SearchLimiter.STATUS, "bogus"); + getParameterMap().clear(); + addQueryParam(limit, query); + } + + /** + * Add an additional search limit to the {@Link BugSearch} + * + * @param limit + * What dimension to search {@link Bug}s by in the Bugzilla + * installation + * @param query + * What to match fields against + */ + public void addQueryParam(ExtendedSearchLimiter limit, Object query) { + getParameterMap().put(limit.getName(), query); + } + + /** + * Returns the {@link Bug}s found by the query as a <code>List</code> + * @return a {@link List} of {@link Bug}s that match the query and limit + */ + public List<Bug> getSearchResults() { + List<Bug> results = new ArrayList<Bug>(); + /* + * The following is messy, but necessary due to how the returned XML document nests + * Maps. + */ + if(hash.containsKey("bugs")) { + Object[] bugs = (Object[])hash.get("bugs"); + for(Object o : bugs) { + @SuppressWarnings("unchecked") + Map<String, Object> bugMap = (HashMap<String, Object>)o; + // Work around a bug in j2bugzilla where version isn't correctly recognized. + Map<?, ?> internals = (Map<?, ?>) bugMap.get("internals"); + bugMap.put("version", internals.get("version")); + try { + results.add(new Bug(bugMap)); + } catch (InvalidDescriptionException e) { + LOG.debug("A bug retrieved via search was invalid", e); + } + } + } + return results; + } + + @Override + public void setResultMap(Map<Object, Object> hash) { + this.hash = hash; + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedGetBug.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedGetBug.java new file mode 100644 index 0000000..64beb7e --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/ExtendedGetBug.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.jbugzx.rpc; + +import java.util.HashMap; +import java.util.Map; + +import jbugz.base.Bug; +import jbugz.exceptions.InvalidDescriptionException; +import jbugz.rpc.GetBug; + +/** + * Allows users to retrieve a specific bug for which the ID is already known. + * Extends {@link GetBug} to work around problems with specific Bugzilla + * versions. + * + * @author Samuel Padgett <spadgett@us.ibm.com> + */ +public class ExtendedGetBug extends GetBug { + private Map<Object, Object> hash = new HashMap<Object, Object>(); + + /** + * Creates a new {@link ExtendedGetBug} object to retrieve the {@code Bug} + * specified by the ID parameter + * + * @param id + * An {@code int} representing the ID of an existing bug in the + * installation connected to + */ + public ExtendedGetBug(int id) { + super(id); + } + + @Override + public void setResultMap(Map<Object, Object> hash) { + this.hash = hash; + super.setResultMap(hash); + } + + /** + * Retrieves the {@link jbugz.base.Bug} corresponding to the given ID + * + * @return A {@code Bug} matching the ID, or null if the returned hash does + * not contain a match + */ + public Bug getBug() { + Object[] bugs = (Object[]) hash.get("bugs"); + if (bugs != null) { + for (Object o : bugs) { + @SuppressWarnings("unchecked") + Map<String, Object> bugMap = (HashMap<String, Object>) o; + // Work around a bug in j2bugzilla where version isn't correctly + // recognized. + Map<?, ?> internals = (Map<?, ?>) bugMap.get("internals"); + bugMap.put("version", internals.get("version")); + try { + return new Bug(bugMap); + } catch (InvalidDescriptionException e) { + throw new RuntimeException(e); + } + } + } + + return null; + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/GetAccessibleProducts.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/GetAccessibleProducts.java new file mode 100644 index 0000000..c48749b --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/GetAccessibleProducts.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.jbugzx.rpc; + +import java.util.HashMap; +import java.util.Map; + +import jbugz.base.BugzillaMethod; + +public class GetAccessibleProducts implements BugzillaMethod { + + /** + * The method Bugzilla will execute via XML-RPC + */ + private static final String METHOD_NAME = "Product.get_accessible_products"; + + private Map<Object, Object> params = new HashMap<Object, Object>(); + private Map<Object, Object> hash = new HashMap<Object, Object>(); + + public GetAccessibleProducts() {} + + public Integer[] getIds() { + if (hash.containsKey("ids")) { + Object[] ids = (Object[])hash.get("ids"); + Integer[] ints = new Integer[ids.length]; + System.arraycopy(ids, 0, ints, 0, ids.length); + return ints; + } else { + return new Integer[0]; + } + } + + @Override + public void setResultMap(Map<Object, Object> hash) { + this.hash = hash; + } + + @Override + public Map<Object, Object> getParameterMap() { + return params; + } + + @Override + public String getMethodName() { + return METHOD_NAME; + } + +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/GetLegalValues.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/GetLegalValues.java new file mode 100644 index 0000000..bd61c63 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/GetLegalValues.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.jbugzx.rpc; + +import java.util.HashMap; +import java.util.Map; + +import jbugz.base.BugzillaMethod; + +public class GetLegalValues implements BugzillaMethod { + + /** + * The method Bugzilla will execute via XML-RPC + */ + private static final String METHOD_NAME = "Bug.legal_values"; + + private Map<Object, Object> params = new HashMap<Object, Object>(); + private Map<Object, Object> hash = new HashMap<Object, Object>(); + + public GetLegalValues(String field, int productId) { + params.put("field", field); + if (productId != -1) params.put("product_id", productId); + } + + public String[] getValues() { + if (hash.containsKey("values")) { + Object[] values = (Object[])hash.get("values"); + String[] strings = new String[values.length]; + System.arraycopy(values, 0, strings, 0, values.length); + return strings; + } else { + return new String[0]; + } + } + + @Override + public void setResultMap(Map<Object, Object> hash) { + this.hash = hash; + } + + @Override + public Map<Object, Object> getParameterMap() { + return params; + } + + @Override + public String getMethodName() { + return METHOD_NAME; + } + +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/GetProducts.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/GetProducts.java new file mode 100644 index 0000000..0df8afd --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/jbugzx/rpc/GetProducts.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.jbugzx.rpc; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jbugz.base.BugzillaMethod; + +import org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product; + +public class GetProducts implements BugzillaMethod { + + /** + * The method Bugzilla will execute via XML-RPC + */ + private static final String METHOD_NAME = "Product.get"; + + private Map<Object, Object> params = new HashMap<Object, Object>(); + private Map<Object, Object> hash = new HashMap<Object, Object>(); + + public GetProducts(Integer[] ids) { + params.put("ids", ids); + } + + @SuppressWarnings("unchecked") + public List<Product> getProducts() { + List<Product> products = new ArrayList<Product>(); + if (hash.containsKey("products")) { + Object[] values = (Object[])hash.get("products"); + for (Object hashmap : values) { + products.add(new Product((Map<String, Object>)hashmap)); + } + } + return products; + } + + @Override + public void setResultMap(Map<Object, Object> hash) { + this.hash = hash; + } + + @Override + public Map<Object, Object> getParameterMap() { + return params; + } + + @Override + public String getMethodName() { + return METHOD_NAME; + } + +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/BugzillaChangeRequest.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/BugzillaChangeRequest.java new file mode 100644 index 0000000..4d7f540 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/BugzillaChangeRequest.java @@ -0,0 +1,243 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.resources;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import jbugz.base.Bug;
+import jbugz.base.Bug.Priority;
+import jbugz.base.Bug.Status;
+import jbugz.exceptions.BugzillaException;
+import jbugz.exceptions.ConnectionException;
+import jbugz.exceptions.InvalidDescriptionException;
+
+import org.eclipse.lyo.samples.bugzilla.URLStrategy;
+
+import thewebsemantic.Namespace;
+import thewebsemantic.RdfProperty;
+import thewebsemantic.RdfType;
+
+/**
+ * An OSLC-CM ChangeRequest with some Bugzilla-specific properties.
+ *
+ * @author Samuel Padgett <spadgett@us.ibm.com>
+ *
+ */
+@Namespace("http://open-services.net/ns/cm#")
+@RdfType("ChangeRequest")
+public class BugzillaChangeRequest extends ChangeRequest {
+ @RdfProperty("http://www.bugzilla.org/rdf#product")
+ private String product = null;
+
+ @RdfProperty("http://www.bugzilla.org/rdf#component")
+ private String component = null;
+
+ @RdfProperty("http://www.bugzilla.org/rdf#version")
+ private String version = null;
+
+ @RdfProperty("http://www.bugzilla.org/rdf#priority")
+ private String priority = null;
+
+ @RdfProperty("http://www.bugzilla.org/rdf#platform")
+ private String platform = null;
+
+ @RdfProperty("http://www.bugzilla.org/rdf#opsys")
+ private String operatingSystem = null;
+
+ /**
+ * Converts a {@link Bug} to an OSLC-CM ChangeRequest.
+ *
+ * @param bug
+ * the bug
+ * @return the ChangeRequest to be serialized
+ * @throws URISyntaxException
+ * on errors setting the bug URI
+ * @throws UnsupportedEncodingException
+ */
+ public static BugzillaChangeRequest fromBug(Bug bug)
+ throws URISyntaxException, UnsupportedEncodingException {
+ BugzillaChangeRequest cr = new BugzillaChangeRequest();
+ cr.setIdentifier(bug.getID());
+ cr.setTitle(bug.getSummary());
+ cr.setStatus(bug.getStatus());
+
+ Object assignedTo = bug.getInternalState().get("assigned_to");
+ if (assignedTo != null) {
+ Person contributor = new Person();
+ String email = assignedTo.toString();
+ contributor.setUri(new URI(URLStrategy.getPersonURL(email)));
+ contributor.setEmail(email);
+ cr.setContributor(contributor);
+ }
+
+ Date createdDate = (Date) bug.getInternalState().get("creation_time");
+ Calendar createdCal = Calendar.getInstance();
+ createdCal.setTime(createdDate);
+ cr.setCreated(createdCal);
+
+ Date modifiedDate = (Date) bug.getInternalState().get("last_change_time");
+ Calendar modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+ cr.setModified(modifiedCal);
+
+ cr.setProduct(bug.getProduct());
+ cr.setComponent(bug.getComponent()); + + // Work around a bug in j2bugzilla. Bug.getVersion() results in a class cast exception. + Object version = bug.getInternalState().get("version"); + if (version != null) {
+ cr.setVersion(version.toString()); + }
+
+ try {
+ cr.setPriority(bug.getPriority());
+ } catch (NumberFormatException e) {
+ // Do nothing, priority is not set.
+ }
+
+ Map<?, ?> internals = (Map<?, ?>) bug.getInternalState().get("internals");
+ cr.setPlatform((String) internals.get("rep_platform"));
+ cr.setOperatingSystem((String) internals.get("op_sys"));
+
+ return cr;
+ }
+
+ /**
+ * Creates a {@link Bug} from an OSLC-CM ChangeRequest.
+ *
+ * @param bug the bug
+ * @return the ChangeRequest to be serialized
+ * @throws BugzillaException
+ * @throws ConnectionException
+ * @throws InvalidDescriptionException
+ * @throws URISyntaxException on errors setting the bug URI
+ */
+ public Bug toBug() throws ConnectionException, BugzillaException, InvalidDescriptionException {
+ Map<String, Object> bugState = new HashMap<String, Object>();
+ fillInBugState(bugState);
+
+ return new Bug(bugState);
+ }
+
+ /**
+ * Updates {@link Bug} state from an OSLC-CM ChangeRequest.
+ *
+ * @param bug the bug
+ * @return the ChangeRequest to be serialized
+ * @throws BugzillaException
+ * @throws ConnectionException
+ * @throws URISyntaxException on errors setting the bug URI
+ */
+ public void toBug(Bug bug) throws ConnectionException, BugzillaException {
+ fillInBugState(bug.getInternalState());
+ }
+
+ private void fillInBugState(Map<String, Object> bugState) {
+ if (identifier != null)
+ bugState.put("id", new Integer(identifier));
+ if (product != null)
+ bugState.put("product", product);
+ if (title != null)
+ bugState.put("summary", title);
+ if (description != null)
+ bugState.put("description", description);
+ if (version != null)
+ bugState.put("version", version);
+ if (component != null)
+ bugState.put("component", component);
+ if (platform != null)
+ bugState.put("platform", platform);
+ if (operatingSystem != null)
+ bugState.put("op_sys", operatingSystem);
+ if (status != null)
+ bugState.put("status", status);
+ }
+
+ public void setIdentifier(int identifier) throws URISyntaxException {
+ setIdentifier(Integer.toString(identifier));
+ setUri(new URI(URLStrategy.getChangeRequestURL(identifier)));
+ }
+
+ public String getProduct() {
+ return product;
+ }
+
+ public void setProduct(String product) {
+ this.product = product;
+ }
+
+ public String getComponent() {
+ return component;
+ }
+
+ public void setComponent(String component) {
+ this.component = component;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getPriority() {
+ return priority;
+ }
+
+ public void setPriority(String priority) {
+ this.priority = priority;
+ }
+
+ public void setPriority(Priority priority) {
+ if (priority == null) {
+ setPriority((String) null);
+ } else {
+ setPriority(priority.toString());
+ }
+ }
+
+ public String getPlatform() {
+ return platform;
+ }
+
+ public void setPlatform(String platform) {
+ this.platform = platform;
+ }
+
+ public String getOperatingSystem() {
+ return operatingSystem;
+ }
+
+ public void setOperatingSystem(String operatingSystem) {
+ this.operatingSystem = operatingSystem;
+ }
+
+ public void setStatus(Status status) {
+ if (status != null) {
+ setStatus(status.toString());
+ } else {
+ setStatus((String) null);
+ }
+ }
+}
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/ChangeRequest.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/ChangeRequest.java new file mode 100644 index 0000000..aab13db --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/ChangeRequest.java @@ -0,0 +1,233 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.resources;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+
+import thewebsemantic.Namespace;
+import thewebsemantic.RdfProperty;
+
+/**
+ * An OSLC-CM ChangeRequest.
+ *
+ * @author Samuel Padgett <spadgett@us.ibm.com>
+ * @see <a href="http://open-services.net/bin/view/Main/CmSpecificationV2?sortcol=table;up=#Resource_ChangeRequest">OSLC-CM 2.0 Specification, Resource ChangeRequest</a>
+ */
+@Namespace("http://open-services.net/ns/cm#")
+public class ChangeRequest extends OslcResource {
+ @RdfProperty("http://open-services.net/ns/cm#shortTitle")
+ protected String shortTitle = null;
+
+ @RdfProperty("http://purl.org/dc/terms/identifier")
+ protected String identifier = null;
+
+ @RdfProperty("http://purl.org/dc/terms/type")
+ protected String type = null;
+
+ @RdfProperty("http://purl.org/dc/terms/creator")
+ protected Person creator = null;
+
+ @RdfProperty("http://purl.org/dc/terms/contributor")
+ protected Person contributor = null;
+
+ @RdfProperty("http://purl.org/dc/terms/subject")
+ protected String subject = null;
+
+ @RdfProperty("http://purl.org/dc/terms/created")
+ protected Calendar created = null;
+
+ @RdfProperty("http://purl.org/dc/terms/modified")
+ protected Calendar modified = null;
+
+ @RdfProperty("http://open-services.net/ns/cm#status")
+ protected String status = null;
+
+ /*
+ * Links
+ */
+ @RdfProperty("http://open-services.net/ns/cm#relatedChangeRequest")
+ private Collection<URI> relatedChangeRequest = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#affectsPlanItem")
+ private Collection<URI> affectsPlanItem = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#affectedByDefect")
+ private Collection<URI> affectedByDefect = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#tracksRequirement")
+ private Collection<URI> tracksRequirement = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#implementsRequirement")
+ private Collection<URI> implementsRequirement = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#affectsRequirement")
+ private Collection<URI> affectsRequirement = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#testedByTestCase")
+ private Collection<URI> testedByTestCase = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#affectsTestResult")
+ private Collection<URI> affectsTestResult = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#blocksTestExecutionRecord")
+ private Collection<URI> blocksTestExecutionRecord = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#relatedTestExecutionRecord")
+ private Collection<URI> relatedTestExecutionRecord = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#relatedTestCase")
+ private Collection<URI> relatedTestCase = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#relatedTestPlan")
+ private Collection<URI> relatedTestPlan = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#relatedTestScript")
+ private Collection<URI> relatedTestScript = new ArrayList<URI>();
+
+ @RdfProperty("http://open-services.net/ns/cm#tracksChangeSet")
+ private Collection<URI> tracksChangeSet = new ArrayList<URI>();
+
+ public String getShortTitle() {
+ return shortTitle;
+ }
+
+ public void setShortTitle(String shortTitle) {
+ this.shortTitle = shortTitle;
+ }
+
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Person getCreator() {
+ return creator;
+ }
+
+ public void setCreator(Person creator) {
+ this.creator = creator;
+ }
+
+ public Person getContributor() {
+ return contributor;
+ }
+
+ public void setContributor(Person contributor) {
+ this.contributor = contributor;
+ }
+
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(String subject) {
+ this.subject = subject;
+ }
+
+ public Calendar getCreated() {
+ return created;
+ }
+
+ public void setCreated(Calendar created) {
+ this.created = created;
+ }
+
+ public Calendar getModified() {
+ return modified;
+ }
+
+ public void setModified(Calendar modified) {
+ this.modified = modified;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public Collection<URI> getRelatedChangeRequest() {
+ return relatedChangeRequest;
+ }
+
+ public Collection<URI> getAffectsPlanItem() {
+ return affectsPlanItem;
+ }
+
+ public Collection<URI> getAffectedByDefect() {
+ return affectedByDefect;
+ }
+
+ public Collection<URI> getTracksRequirement() {
+ return tracksRequirement;
+ }
+
+ public Collection<URI> getImplementsRequirement() {
+ return implementsRequirement;
+ }
+
+ public Collection<URI> getAffectsRequirement() {
+ return affectsRequirement;
+ }
+
+ public Collection<URI> getTestedByTestCase() {
+ return testedByTestCase;
+ }
+
+ public Collection<URI> getAffectsTestResult() {
+ return affectsTestResult;
+ }
+
+ public Collection<URI> getBlocksTestExecutionRecord() {
+ return blocksTestExecutionRecord;
+ }
+
+ public Collection<URI> getRelatedTestExecutionRecord() {
+ return relatedTestExecutionRecord;
+ }
+
+ public Collection<URI> getRelatedTestCase() {
+ return relatedTestCase;
+ }
+
+ public Collection<URI> getRelatedTestPlan() {
+ return relatedTestPlan;
+ }
+
+ public Collection<URI> getRelatedTestScript() {
+ return relatedTestScript;
+ }
+
+ public Collection<URI> getTracksChangeSet() {
+ return tracksChangeSet;
+ }
+}
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/OslcResource.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/OslcResource.java new file mode 100644 index 0000000..24e4d77 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/OslcResource.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +
+package org.eclipse.lyo.samples.bugzilla.resources;
+
+import java.net.URI;
+
+import thewebsemantic.Id;
+import thewebsemantic.RdfProperty;
+
+/**
+ * Some common properties for OSLC resources.
+ *
+ * @author Samuel Padgett <spadgett@us.ibm.com>
+ * @see <a href="http://open-services.net/bin/view/Main/OSLCCoreSpecAppendixA">OSLC Core 2.0 Specification: Common Properties</a>
+ */
+public abstract class OslcResource {
+ @Id
+ protected URI uri = null;
+ @RdfProperty("http://purl.org/dc/terms/title")
+ protected String title = null;
+ @RdfProperty("http://purl.org/dc/terms/description")
+ protected String description = null;
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/Person.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/Person.java new file mode 100644 index 0000000..076de46 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/Person.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +
+package org.eclipse.lyo.samples.bugzilla.resources;
+
+import java.net.URI;
+
+import thewebsemantic.Id;
+import thewebsemantic.Namespace;
+import thewebsemantic.RdfProperty;
+
+/**
+ * A FOAF Person.
+ *
+ * @author Samuel Padgett <spadgett@us.ibm.com>
+ * @see <a href="http://xmlns.com/foaf/spec/">FOAF Vocabulary Specification</a>
+ */
+@Namespace("http://xmlns.com/foaf/0.1/")
+public class Person {
+ private URI uri = null;
+ private String name = null;
+ @RdfProperty("http://xmlns.com/foaf/0.1/mbox")
+ private String email = null;
+
+ @Id
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+}
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/ServiceProviderCatalog.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/ServiceProviderCatalog.java new file mode 100644 index 0000000..76da95b --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/resources/ServiceProviderCatalog.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +
+package org.eclipse.lyo.samples.bugzilla.resources;
+
+import thewebsemantic.Namespace;
+
+/**
+ * An OSLC Service Provider Catalog.
+ *
+ * @author Samuel Padgett <spadgett@us.ibm.com>
+ * @see <a href="http://open-services.net/bin/view/Main/OslcCoreSpecification?sortcol=table;up=#Service_Provider_Resources">Service Provider Resources</a>
+ */
+@Namespace("http://open-services.net/ns/core#")
+public class ServiceProviderCatalog extends OslcResource {
+
+}
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/utils/AcceptType.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/utils/AcceptType.java new file mode 100644 index 0000000..fbe9d11 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/utils/AcceptType.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.utils; + +import java.util.Enumeration; + +import javax.servlet.http.HttpServletRequest; + +public class AcceptType implements Comparable<AcceptType> { + public String type; + public int weight; + public AcceptType(String typeExp) { + int pos = typeExp.indexOf(';'); + if( pos > 0 ) { + this.type = typeExp.substring(0,pos).trim(); + String qualifier = typeExp.substring(pos+1); + if( qualifier.startsWith("q=") ) { + try{ + float w = Float.parseFloat(qualifier.substring(2)) * 1000; + this.weight = (int) w; + }catch( NumberFormatException e ) { + this.weight = 1000; + } + } else { + this.weight = 1000; + } + + } else { + this.type = typeExp; + this.weight = new Integer(1000); + } + } + + public static boolean willAccept(String contentType, Enumeration<?> acceptHds) { + while(acceptHds.hasMoreElements()) { + String acceptHdr = (String) acceptHds.nextElement(); + // split up the individual content types + String[] hdrs = acceptHdr.split(","); + for (String acctHdrVal : hdrs) { + AcceptType acceptType = new AcceptType( acctHdrVal); + if( acceptType.equals(contentType) ) return true; + } + } + return false; + } + + public static boolean willAccept(String contentType, HttpServletRequest req) { + Enumeration<?> acceptHds = req.getHeaders("Accept"); + while(acceptHds.hasMoreElements()) { + String acceptHdr = (String) acceptHds.nextElement(); + // split up the individual content types + String[] qVals = acceptHdr.split(";"); + String[] hdrs = qVals[0].split(","); + for (String acctHdrVal : hdrs) { + AcceptType acceptType = new AcceptType( acctHdrVal); + if( acceptType.equals(contentType) ) return true; + } + } + return false; + } + + @Override + public int compareTo(AcceptType other) { + return ((AcceptType)other).weight - weight; + } + + @Override + public boolean equals(Object obj) { + if (this.type.length() == 0) return false; + if( obj instanceof AcceptType ) { + AcceptType otherAcceptType = (AcceptType) obj; + // now we need to sort out wildcards + String[] otc = otherAcceptType.type.split("/"); + String[] ttc = this.type.split("/"); + boolean seg1 = compareSegment(otc[0], ttc[0]); + boolean seg2 = compareSegment(otc[1], ttc[1]); + return seg1 && seg2; + } else if (obj != null && obj instanceof String ) { + String str = (String)obj; + if (str.length() == 0) return false; + String[] otc = str.split("/"); + String[] ttc = this.type.split("/"); + boolean seg1 = compareSegment(otc[0], ttc[0]); + boolean seg2 = compareSegment(otc[1], ttc[1]); + return seg1 && seg2; + } + return false; + } + + public boolean compareSegment(String s1, String s2 ) { + if( s1.equals("*") || s2.equals("*") ) { + return true; + } + return s1.equals(s2); + } +}
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/utils/StringUtils.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/utils/StringUtils.java new file mode 100644 index 0000000..8e99f95 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/utils/StringUtils.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.StringTokenizer; + +public class StringUtils { + + private static final String LS = System.getProperty("line.separator"); + + public static String streamToString(InputStream is) throws IOException { + StringBuffer sb = new StringBuffer(); + BufferedReader in = new BufferedReader(new InputStreamReader(is)); + String line; + while ((line = in.readLine()) != null) { + sb.append(line); + sb.append(LS); + } + return sb.toString(); + } + + public static String forHtml(String expr) { + // convert each line to a paragraph + StringTokenizer st = new StringTokenizer(expr, "\n"); //$NON-NLS-1$ + StringBuffer sb = new StringBuffer(); + while( st.hasMoreTokens() ){ + sb.append(XmlUtils.encode(st.nextToken()) + "<br/>"); //$NON-NLS-1$ + } + return sb.toString(); + } + + public static String rfc2822(Date date ) { + String pattern = "EEE, dd MMM yyyy HH:mm:ss Z"; //$NON-NLS-1$ + SimpleDateFormat format = new SimpleDateFormat(pattern); + return format.format(date); + } + + public static Date rfc2822(String dateStr) throws ParseException { + String pattern = "EEE, dd MMM yyyy HH:mm:ss Z"; //$NON-NLS-1$ + SimpleDateFormat format = new SimpleDateFormat(pattern); + return format.parse(dateStr); + } + + @SuppressWarnings("nls") + public static String stringEscape(String title) { + return title.replaceAll("\\\\", "\\\\\\\\"); + } + + public static boolean isEmpty(String s) { + return s == null || s.length() == 0; + } + +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/utils/XmlUtils.java b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/utils/XmlUtils.java new file mode 100644 index 0000000..e9f45f8 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/java/org/eclipse/lyo/samples/bugzilla/utils/XmlUtils.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.utils; + +import java.io.StringWriter; + +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.w3c.dom.Document; + +public class XmlUtils { + + @SuppressWarnings("nls") + public static String encode(String exp) { + if( exp != null ) { + String encoded = exp.replaceAll("&", "&"); + encoded = encoded.replaceAll(">", ">"); + encoded = encoded.replaceAll("<", "<"); + encoded = encoded.replaceAll("\"", """); + encoded = encoded.replaceAll("'", "'"); + return encoded; + } + return ""; + } + + public static String prettyPrint( Document doc ) { + TransformerFactory tfactory = TransformerFactory.newInstance(); + Transformer serializer; + StringWriter writer = new StringWriter(); + try { + serializer = tfactory.newTransformer(); + //Setup indenting to "pretty print" + serializer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$ + + serializer.transform(new DOMSource(doc), new StreamResult(writer)); + return writer.toString(); + } catch (TransformerException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/resources/bugz.properties b/org.eclipse.lyo.samples.bugzilla/src/main/resources/bugz.properties new file mode 100644 index 0000000..72aced6 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/resources/bugz.properties @@ -0,0 +1,20 @@ +############################################################################### +# Copyright (c) 2011 IBM Corporation. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# and Eclipse Distribution License v. 1.0 which accompanies this distribution. +# +# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html +# and the Eclipse Distribution License is available at +# http://www.eclipse.org/org/documents/edl-v10.php. +# +# Contributors: +# +# IBM Corporation - initial API and implementation +############################################################################### +adapter_uri=http://localhost:8282/bugz +bugzilla_uri=http://oslc1.rtp.raleigh.ibm.com/bugzilla +username=nina@oslc1.rtp.raleigh.ibm.com +password=ninanina +provideHtml=true diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/resources/jetty.xml b/org.eclipse.lyo.samples.bugzilla/src/main/resources/jetty.xml new file mode 100644 index 0000000..ab989ec --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/resources/jetty.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> + +<Configure id="Server" class="org.eclipse.jetty.server.Server"> + + <!-- see also: http://download.eclipse.org/jetty/stable-7/apidocs/ --> + + <!-- Configure a log --> + + <New id="ServerLog" class="java.io.PrintStream"> + <Arg> + <New class="org.eclipse.jetty.util.RolloverFileOutputStream"> + <Arg><SystemProperty name="jetty.logs" default="." />/yyyy_mm_dd.stderrout.log</Arg> + <Arg type="boolean">false</Arg> + <Arg type="int">90</Arg> + <Arg><Call class="java.util.TimeZone" name="getTimeZone"><Arg>GMT</Arg></Call></Arg> + <Get id="ServerLogName" name="datedFilename"/> + </New> + </Arg> + </New> + <Call class="org.eclipse.jetty.util.log.Log" name="info"><Arg>Redirecting stderr/stdout to <Ref id="ServerLogName"/></Arg></Call> + <Call class="java.lang.System" name="setErr"><Arg><Ref id="ServerLog"/></Arg></Call> + <Call class="java.lang.System" name="setOut"><Arg><Ref id="ServerLog"/></Arg></Call> + +</Configure> diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/META-INF/MANIFEST.MF b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/WEB-INF/web.xml b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..a355852 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> + <display-name>OSLC Bugzilla Adapter</display-name> + <servlet> + <servlet-name>ServiceProviderCatalogService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.ServiceProviderCatalogService</servlet-class> + </servlet> + <servlet> + <servlet-name>ServiceProviderService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.ServiceProviderService</servlet-class> + </servlet> + <servlet> + <servlet-name>ChangeRequestService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.ChangeRequestService</servlet-class> + </servlet> + <servlet> + <servlet-name>ChangeRequestCollectionService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.ChangeRequestCollectionService</servlet-class> + </servlet> + <servlet> + <servlet-name>ChangeRequestCreatorService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.ChangeRequestCreatorService</servlet-class> + </servlet> + <servlet> + <servlet-name>ChangeRequestSelectorService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.ChangeRequestSelectorService</servlet-class> + </servlet> + <servlet> + <servlet-name>CreationShapeService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.CreationShapeService</servlet-class> + </servlet> + <servlet> + <servlet-name>QueryShapeService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.QueryShapeService</servlet-class> + </servlet> + <servlet> + <servlet-name>RootServicesService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.RootServicesService</servlet-class> + </servlet> + <servlet> + <servlet-name>ConsumerKeyService</servlet-name> + <servlet-class>org.eclipse.lyo.samples.bugzilla.ConsumerKeyService</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>ServiceProviderCatalogService</servlet-name> + <url-pattern>/catalog</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>ServiceProviderService</servlet-name> + <url-pattern>/provider</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>ChangeRequestCollectionService</servlet-name> + <url-pattern>/changerequests</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>ChangeRequestService</servlet-name> + <url-pattern>/changerequest</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>ChangeRequestCreatorService</servlet-name> + <url-pattern>/creator</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>ChangeRequestSelectorService</servlet-name> + <url-pattern>/selector</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>CreationShapeService</servlet-name> + <url-pattern>/creationshape</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>QueryShapeService</servlet-name> + <url-pattern>/queryshape</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>RootServicesService</servlet-name> + <url-pattern>/rootservices</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>ConsumerKeyService</servlet-name> + <url-pattern>/consumer_key</url-pattern> + </servlet-mapping> +</web-app>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/bugzilla.gif b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/bugzilla.gif Binary files differnew file mode 100644 index 0000000..16973a4 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/bugzilla.gif diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/bugzilla.js b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/bugzilla.js new file mode 100644 index 0000000..3c0f8f9 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/bugzilla.js @@ -0,0 +1,135 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +function search(baseUrl){ + var ie = window.navigator.userAgent.indexOf("MSIE"); + list = document.getElementById("results"); + list.options.length = 0; + xmlhttp = new XMLHttpRequest(); + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState==4 && xmlhttp.status==200) { + // populate results + txt = xmlhttp.responseText; + resp = eval('(' + txt + ')'); + for( i=0; i<resp.results.length; i=i+1 ) { + var item=document.createElement('option'); + item.text = resp.results[i].title; + item.value = resp.results[i].resource; + if (ie > 0) { + list.add(item); + } else { + list.add(item, null); + } + } + } + }; + terms = document.getElementById("searchTerms").value; + xmlhttp.open("GET", baseUrl + "&terms=" + escape(terms), true); + xmlhttp.setRequestHeader("Connection","close"); + xmlhttp.send(); +} + +function create(baseUrl){ + var ie = window.navigator.userAgent.indexOf("MSIE"); + var form = document.getElementById("bugz_form"); + xmlhttp = new XMLHttpRequest(); + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState==4 && (xmlhttp.status==201)) { + txt = xmlhttp.responseText; + resp = eval('(' + txt + ')'); + // Send response to listener + sendResponse(resp.title, resp.resource); + } + }; + var postData=baseUrl+"&prefill=false"; + if (form.component) { + postData += "&component="+form.component.value; + } + if (form.summary) { + postData += "&summary="+form.summary.value; + } + if (form.version) { + postData += "&version="+form.version.value; + } + if (form.op_sys) { + postData += "&op_sys="+form.op_sys.value; + } + if (form.platform) { + postData += "&platform="+form.platform.value; + } + xmlhttp.open("POST", postData, true); + xmlhttp.setRequestHeader("Content-type","application/x-www-from-urlencoded"); + xmlhttp.setRequestHeader("Connection","close"); + xmlhttp.send(postData); +} + +function select(){ + list = document.getElementById("results"); + if( list.length>0 && list.selectedIndex >= 0 ) { + option = list.options[list.selectedIndex]; + sendResponse(option.text, option.value); + } +} + +function sendResponse(label, url) { + var oslcResponse = 'oslc-response:{ "oslc:results": [ ' + + ' { "oslc:label" : "' + label + '", "rdf:resource" : "' + url + '"} ' + + ' ] }'; + + if (window.location.hash == '#oslc-core-windowName-1.0') { + // Window Name protocol in use + respondWithWindowName(oslcResponse); + } else if (window.location.hash == '#oslc-core-postMessage-1.0') { + // Post Message protocol in use + respondWithPostMessage(oslcResponse); + } +} + +function sendCancelResponse() { + var oslcResponse = 'oslc-response:{ "oslc:results": [ ]}'; + + if (window.location.hash == '#oslc-core-windowName-1.0') { + // Window Name protocol in use + respondWithWindowName(oslcResponse); + } else if (window.location.hash == '#oslc-core-postMessage-1.0') { + // Post Message protocol in use + respondWithPostMessage(oslcResponse); + } +} + + +function respondWithWindowName(/*string*/ response) { + // Step #2: read the return URL + var returnURL = window.name; + + // Step #4: send the response via the window.name variable + window.name = response; + + // Step #5: indicate that user has responded + window.location.href = returnURL; + +} + +function respondWithPostMessage(/*string*/ response) { + if( window.parent != null ) { + window.parent.postMessage(response, "*"); + } else { + window.postMessage(response, "*"); + } +} + +function cancel(){ + sendCancelResponse(); +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_collection_html.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_collection_html.jsp new file mode 100644 index 0000000..0a1421d --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_collection_html.jsp @@ -0,0 +1,88 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@page import="org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product"%> +<%@ page contentType="text/html" language="java" %> +<%@ page import="jbugz.base.*" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.jbugzx.base.*" %> +<%@ page import="java.util.List" %> +<% + List<Bug> bugs = (List<Bug>)request.getAttribute("results"); + String bugzillaUri = (String) request.getAttribute("bugzillaUri"); + String queryUri = (String)request.getAttribute("queryUri"); + String nextPageUri = (String)request.getAttribute("nextPageUri"); + Product product = (Product)request.getAttribute("product"); +%> +<html> + <head> + <title>Bugzilla OSLC Adapter: Service Provider for <%= product.getName() + "(" + product.getId() + ")" %></title> + <link href="<%= bugzillaUri %>/skins/standard/global.css" rel="stylesheet" type="text/css"> + <link href="<%= bugzillaUri %>/skins/standard/index.css" rel="stylesheet" type="text/css"> + <link href="<%= bugzillaUri %>/skins/standard/global.css" rel="alternate stylesheet" title="Classic" type="text/css"> + <link href="<%= bugzillaUri %>/skins/standard/index.css" rel="alternate stylesheet" title="Classic" type="text/css"> + <link href="<%= bugzillaUri %>/skins/contrib/Dusk/global.css" rel="stylesheet" title="Dusk" type="text/css"> + <link href="<%= bugzillaUri %>/skins/contrib/Dusk/index.css" rel="stylesheet" title="Dusk" type="text/css"> + <link href="<%= bugzillaUri %>/skins/custom/global.css" rel="stylesheet" type="text/css"> + <link href="<%= bugzillaUri %>/skins/custom/index.css" rel="stylesheet" type="text/css"> + <link rel="shortcut icon" href="<%= bugzillaUri %>/images/favicon.ico"> + </head> + <body onload=""> + + <div id="header"> + <div id="banner"></div> + <table border="0" cellspacing="0" cellpadding="0" id="titles"> + <tr> + <td id="title"> + <p> + Bugzilla OSLC Adapter: Service Provider + </p> + </td> + <td id="information"> + <p class="header_addl_info"> + version 0.1 + </p> + </td> + </tr> + </table> + </div> + + <div id="bugzilla-body"> + <div id="page-index"> + + <img src="bugzilla.gif" alt="icon" width="80" height="80" /> + + <h1>Query Results</h1> + + <% for (Bug bug : bugs) { %> + <p>Summary: <%= bug.getSummary() %><br /><a href="<%= bug.getInternalState().get("oslc_uri") %>"> + <%= bug.getInternalState().get("oslc_uri") %></a></p> + <% } %> + <% if (nextPageUri != null) { %><a href="<%= nextPageUri %>">Next Page</a><% } %> + + </div> + </div> + + <div id="footer"> + <div class="intro"></div> + <div class="outro"> + <div style="margin: 0 1em 1em 1em; line-height: 1.6em; text-align: left"> + <b>OSLC Tools Adapter Server 0.1</b> brought to you by the <a href="http://open-services.net">OSLC Community</a><br /> + </div> + </div> + </div> + </body> +</html> + diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_collection_rdfxml.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_collection_rdfxml.jsp new file mode 100644 index 0000000..4ab7600 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_collection_rdfxml.jsp @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="application/rdf+xml" language="java" %> +<%@ page import="jbugz.base.Bug" %> +<%@ page import="java.util.List" %> +<% + List<Bug> bugs = (List<Bug>)request.getAttribute("results"); + String queryUri = (String)request.getAttribute("queryUri"); + String nextPageUri = (String)request.getAttribute("nextPageUri"); +%> +<rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:dcterms="http://purl.org/dc/terms/" + xmlns:foaf="http://http://xmlns.com/foaf/0.1/" + xmlns:oslc="http://open-services.net/ns/core#" + xmlns:oslc_cm="http://open-services.net/ns/cm#" + xmlns:bugz="http://www.bugzilla.org/rdf#" + > + + <oslc:ResponseInfo rdf:about="<%= queryUri %>"> + <dcterms:title>Query Results</dcterms:title> + <% if (nextPageUri != null) { %><oslc:nextPage><%= nextPageUri %></oslc:nextPage><% } %> + </oslc:ResponseInfo> + + <bugz:QueryResponse rdf:about="<%= queryUri %>"> + + <% for (Bug bug : bugs) { %> + <rdfs:member> + <oslc_cm:ChangeRequest rdf:about="<%= bug.getInternalState().get("oslc_uri") %>"> + <rdf:type rdf:resource="http://open-services.net/ns/cm#ChangeRequest" /> + <dcterms:title><%= bug.getSummary() %></dcterms:title> + <dcterms:identifier><%= bug.getID() %></dcterms:identifier> + <dcterms:contributor> + <foaf:Person> + <foaf:name><%= bug.getInternalState().get("assigned_to") %></foaf:name> + </foaf:Person> + </dcterms:contributor> + <oslc_cm:status><%= bug.getStatus() %></oslc_cm:status> + <dcterms:modified><%= bug.getInternalState().get("last_change_time") %></dcterms:modified> + <dcterms:created><%= bug.getInternalState().get("creation_time") %></dcterms:created> + <bugz:product><%= bug.getProduct() %></bugz:product> + <bugz:component><%= bug.getComponent() %></bugz:component> + </oslc_cm:ChangeRequest> + </rdfs:member> + <% } %> + + </bugz:QueryResponse> + +</rdf:RDF> + diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_created.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_created.jsp new file mode 100644 index 0000000..17b0597 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_created.jsp @@ -0,0 +1,39 @@ +<html> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page import="java.net.*,java.util.*,java.text.SimpleDateFormat" %> +<%@ page import="jbugz.base.Bug" %> +<% +Bug bug = (Bug)request.getAttribute("bug"); +String bugUri = (String)request.getAttribute("bugUri"); +String title = bug.getSummary(); +%> +<head> +<script type="text/javascript"> + // Step #2: read the return URL + var returnURL = window.name; + + // Step #4: send the response via the window.name variable + var response = "oslc-response:{\"oslc:results\" \: [{ \"oslc:label\" : \"<%= title %>\", \"rdf:resource\" : \"<%= bugUri %>\"}]}"; + window.name = response; + + // Step #5: indicate that user has responded + window.location.href = returnURL; +</script> +</head> +<body> +</body> +</html> diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_creator.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_creator.jsp new file mode 100644 index 0000000..132c890 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_creator.jsp @@ -0,0 +1,109 @@ +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@page import="org.eclipse.lyo.samples.bugzilla.URLStrategy"%> +<%@ page import="java.util.List" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product" %> +<% + String bugzillaUri = (String) request.getAttribute("bugzillaUri"); + Product product = (Product)request.getAttribute("product"); + List<String> operatingSystems = (List<String>)request.getAttribute("operatingSystems"); + List<String> components = (List<String>)request.getAttribute("components"); + List<String> platforms = (List<String>)request.getAttribute("platforms"); + List<String> versions = (List<String>)request.getAttribute("versions"); +%> +<html> +<head> +<title>Bugzilla OSLC Adapter: Resource Creator</title> +<link href="<%= bugzillaUri %>/skins/standard/global.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/index.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/global.css" rel="alternate stylesheet" title="Classic" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/index.css" rel="alternate stylesheet" title="Classic" type="text/css"> +<link href="<%= bugzillaUri %>/skins/contrib/Dusk/global.css" rel="stylesheet" title="Dusk" type="text/css"> +<link href="<%= bugzillaUri %>/skins/contrib/Dusk/index.css" rel="stylesheet" title="Dusk" type="text/css"> +<link href="<%= bugzillaUri %>/skins/custom/global.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/custom/index.css" rel="stylesheet" type="text/css"> +<link rel="shortcut icon" href="<%= bugzillaUri %>/images/favicon.ico"> +<script type="text/javascript" src="bugzilla.js"></script> +</head> +<body> + <form id="bugz_form"> + + Summary: (required)<br /> + <input name="summary" type="text" style="width: 400px" id="summary" /> + <br /> + <input name="product" type="hidden" value="<%= product.getName() %>" /> + + <table> + + <tr> + <td>Component: </td> + <td> + <select name="component"> + <% for (String c : components) { %> + <option value="<%= c %>"><%= c %></option> + <% } %> + </select> + </td> + </tr> + + <tr> + <td>Version: </td> + <td> + <select name="version"> + <% for (String v : versions) { %> + <option value="<%= v %>"><%= v %></option> + <% } %> + </select> + </td> + </tr> + + <tr> + <td>Operating System: </td> + <td> + <select name="op_sys"> + <% for (String os : operatingSystems) { %> + <option value="<%= os %>"><%= os %></option> + <% } %> + </select> + </td> + </tr> + + <tr> + <td>Platform: </td> + <td> + <select name="platform"> + <% for (String p : platforms) { %> + <option value="<%= p %>"><%= p %></option> + <% } %> + </select> + </td> + </tr> + + <tr> + <td></td> + <td> + </td> + </tr> + </table> + + </form> + + <button type="submit" onclick="javascript: create( '<%= URLStrategy.getDelegatedCreationURL(product.getId()) %>' )">Create</button> + <button type="button" onclick="javascript: cancel()">Cancel</button> + +</body> +</html> + diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_filtered_json.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_filtered_json.jsp new file mode 100644 index 0000000..16620fc --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_filtered_json.jsp @@ -0,0 +1,32 @@ +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="application/json" language="java" %> +<%@page import="org.eclipse.lyo.samples.bugzilla.URLStrategy"%> +<%@ page import="java.net.*,java.util.*" %> +<%@ page import="jbugz.base.Bug" %> +{ +<% +List<Bug> results = (List<Bug>)request.getAttribute("results"); +%> +results: [ +<% int i = 0; for (Bug b : results) { %> + <% if (i > 0) { %>,<% } %> + { "title" : "<%= URLStrategy.getChangeRequestLinkLabel(b.getID(), b.getSummary()) %>", + "resource" : "<%= URLStrategy.getChangeRequestURL(b.getID()) %>" + } +<% i++; } %> +] +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_preview_desc.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_preview_desc.jsp new file mode 100644 index 0000000..af4ce49 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_preview_desc.jsp @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="application/x-oslc-compact+xml" language="java" %> +<%@ page import="jbugz.base.Bug" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.URLStrategy"%> +<% +Bug bug = (Bug)request.getAttribute("bug"); +String baseUri = (String)request.getAttribute("baseUri"); +String bugUri = (String)request.getAttribute("bugUri"); +%> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dcterms="http://purl.org/dc/terms/" + xmlns:oslc="http://open-services.net/ns/core#"> + + <oslc:Compact rdf:about="<%= bugUri %>"> + <dcterms:title><%= URLStrategy.getChangeRequestLinkLabel(bug.getID(), bug.getSummary()) %></dcterms:title> + <oslc:shortTitle><%= "Bug"+bug.getID() %></oslc:shortTitle> + <oslc:icon rdf:resource="<%= URLStrategy.getIconURL() %>" /> + + <oslc:smallPreview> + <oslc:Preview> + <oslc:document rdf:resource="<%= URLStrategy.getChangeRequestURL(bug.getID()) + "&preview=small" %>" /> + <oslc:hintWidth>500px</oslc:hintWidth> + <oslc:hintHeight>160px</oslc:hintHeight> + </oslc:Preview> + </oslc:smallPreview> + + <oslc:largePreview> + <oslc:Preview> + <oslc:document rdf:resource="<%= URLStrategy.getChangeRequestURL(bug.getID()) + "&preview=large" %>" /> + <oslc:hintWidth>500px</oslc:hintWidth> + <oslc:hintHeight>500px</oslc:hintHeight> + </oslc:Preview> + </oslc:largePreview> + + </oslc:Compact> + +</rdf:RDF>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_preview_large.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_preview_large.jsp new file mode 100644 index 0000000..53dd0e6 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_preview_large.jsp @@ -0,0 +1,59 @@ +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="text/html" language="java" %> +<%@ page import="java.net.*,java.util.*" %> +<%@ page import="java.net.*,java.util.*,java.text.SimpleDateFormat" %> +<%@ page import="jbugz.base.Bug" %> +<% +Bug bug = (Bug)request.getAttribute("bug"); +String bugzillaUri = (String) request.getAttribute("bugzillaUri"); +String bugUri = (String)request.getAttribute("bugUri"); + +String title = bug.getSummary(); +Date createdDate = (Date)bug.getInternalState().get("creation_time"); +SimpleDateFormat formatter = new SimpleDateFormat(); +String created = formatter.format(createdDate); +Date modifiedDate = (Date)bug.getInternalState().get("last_change_time"); +String modified = formatter.format(modifiedDate); +String identifier = bug.getID()+""; +String description = "None"; +String assignee = (String)bug.getInternalState().get("assigned_to"); +%> +<html> +<head> +<title>Change Request: <%=title %> (<%=identifier %>)</title> +<link href="<%= bugzillaUri %>/skins/standard/global.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/index.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/global.css" rel="alternate stylesheet" title="Classic" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/index.css" rel="alternate stylesheet" title="Classic" type="text/css"> +<link href="<%= bugzillaUri %>/skins/contrib/Dusk/global.css" rel="stylesheet" title="Dusk" type="text/css"> +<link href="<%= bugzillaUri %>/skins/contrib/Dusk/index.css" rel="stylesheet" title="Dusk" type="text/css"> +<link href="<%= bugzillaUri %>/skins/custom/global.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/custom/index.css" rel="stylesheet" type="text/css"> +<link rel="shortcut icon" href="<%= bugzillaUri %>/images/favicon.ico"> +</head> +<body> +Large Compact Preview<hr/> +URI: <%= bugUri %><br/> +Title: <%= title %><br/> +Description: <%= title %><br/> +Identifier: <%= identifier %><br/> +Description: <%= description %><br/> +Created: <%= created %><br/> +Assignee: <%= assignee %><br/> +Last Modified: <%= modified %><br/> +</body> +</html>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_preview_small.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_preview_small.jsp new file mode 100644 index 0000000..dfe26be --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_preview_small.jsp @@ -0,0 +1,72 @@ +<!-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation + --> +<%@ page contentType="text/html" language="java" %> +<%@ page import="java.net.*,java.util.*,java.text.SimpleDateFormat" %> +<%@ page import="jbugz.base.Bug" %> +<% +Bug bug = (Bug)request.getAttribute("bug"); +String bugzillaUri = (String) request.getAttribute("bugzillaUri"); +String bugUri = (String)request.getAttribute("bugUri"); + +String title = bug.getSummary(); +Date createdDate = (Date)bug.getInternalState().get("creation_time"); +SimpleDateFormat formatter = new SimpleDateFormat(); +String created = formatter.format(createdDate); +Date modifiedDate = (Date)bug.getInternalState().get("last_change_time"); +String modified = formatter.format(modifiedDate); +String identifier = bug.getID()+""; +String description = "None"; +String assignee = (String)bug.getInternalState().get("assigned_to"); +%> +<html> +<head> +<title>Change Request: <%=title %> (<%=identifier %>)</title> +<link href="<%= bugzillaUri %>/skins/standard/global.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/index.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/global.css" rel="alternate stylesheet" title="Classic" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/index.css" rel="alternate stylesheet" title="Classic" type="text/css"> +<link href="<%= bugzillaUri %>/skins/contrib/Dusk/global.css" rel="stylesheet" title="Dusk" type="text/css"> +<link href="<%= bugzillaUri %>/skins/contrib/Dusk/index.css" rel="stylesheet" title="Dusk" type="text/css"> +<link href="<%= bugzillaUri %>/skins/custom/global.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/custom/index.css" rel="stylesheet" type="text/css"> +<link rel="shortcut icon" href="<%= bugzillaUri %>/images/favicon.ico"> +</head> +<body> +<b>Bugzilla Bug #<%= bug.getID() %></b> +<table> + <tr> + <td>Summary:</td> + <td><%= title %></td> + </tr> + <tr> + <td>Identifier:</td> + <td><%= identifier %></td> + </tr> + <tr> + <td>URI:</td> + <td><%= bugUri %></td> + </tr> + <tr> + <td>Created:</td> + <td><%= created %></td> + </tr> + <tr> + <td>Modified:</td> + <td><%= modified %></td> + </tr> +</table> +</body> +</html>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_rdfxml.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_rdfxml.jsp new file mode 100644 index 0000000..f29dc6c --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_rdfxml.jsp @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="application/x-oslc-compact+xml" language="java"%> +<%@ page import="jbugz.base.Bug" %> +<% + Bug bug = (Bug) request.getAttribute("bug"); + String bugUri = (String) request.getAttribute("bugUri"); +%> +<rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dcterms="http://purl.org/dc/terms/" + xmlns:oslc="http://open-services.net/ns/core#" + xmlns:oslc_cm="http://open-services.net/ns/cm#" + xmlns:bugz="http://www.bugzilla.org/rdf#" + xmlns:foaf="http://http://xmlns.com/foaf/0.1/"> + + <oslc_cm:ChangeRequest rdf:about="<%= bugUri %>"> + <rdf:type rdf:resource="http://open-services.net/ns/cm#ChangeRequest" /> + + <dcterms:title><%= bug.getSummary() %></dcterms:title> + <dcterms:identifier><%= bug.getID() %></dcterms:identifier> + <dcterms:contributor> + <foaf:Person> + <foaf:name><%= bug.getInternalState().get("assigned_to") %></foaf:name> + </foaf:Person> + </dcterms:contributor> + + <oslc_cm:status><%= bug.getStatus() %></oslc_cm:status> + + <dcterms:modified><%= bug.getInternalState().get("last_change_time") %></dcterms:modified> + <dcterms:created><%= bug.getInternalState().get("creation_time") %></dcterms:created> + + <bugz:product><%= bug.getProduct() %></bugz:product> + <bugz:component><%= bug.getComponent() %></bugz:component> + <bugz:version><%= bug.getVersion() %></bugz:version> + <bugz:priority><%= bug.getPriority().name() %></bugz:priority> +<%-- <bugz:platform><%= bug.getPlatform() %></bugz:platform> + <bugz:opsys><%= bug.getOpsys() %></bugz:opsys> + --%> + </oslc_cm:ChangeRequest> + +</rdf:RDF> + diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_selector.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_selector.jsp new file mode 100644 index 0000000..8e2924b --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/changerequest_selector.jsp @@ -0,0 +1,52 @@ +<%@ page import="jbugz.base.BugzillaConnector" %> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page import="jbugz.rpc.*" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.URLStrategy"%> +<% +int productId= (Integer)request.getAttribute("productId"); +String bugzillaUri = (String) request.getAttribute("bugzillaUri"); +%> +<html> +<head> +<title>Bugzilla OSLC Adapter: Resource Selector</title> +<link href="<%= bugzillaUri %>/skins/standard/global.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/index.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/global.css" rel="alternate stylesheet" title="Classic" type="text/css"> +<link href="<%= bugzillaUri %>/skins/standard/index.css" rel="alternate stylesheet" title="Classic" type="text/css"> +<link href="<%= bugzillaUri %>/skins/contrib/Dusk/global.css" rel="stylesheet" title="Dusk" type="text/css"> +<link href="<%= bugzillaUri %>/skins/contrib/Dusk/index.css" rel="stylesheet" title="Dusk" type="text/css"> +<link href="<%= bugzillaUri %>/skins/custom/global.css" rel="stylesheet" type="text/css"> +<link href="<%= bugzillaUri %>/skins/custom/index.css" rel="stylesheet" type="text/css"> +<link rel="shortcut icon" href="<%= bugzillaUri %>/images/favicon.ico"> + +<script type="text/javascript" src="bugzilla.js"></script> + +</head> +<body> + + <input type="text" style="width: 200px" id="searchTerms" /> + <button type="button" onclick="search( '<%= URLStrategy.getDelegatedSelectionURL(productId) %>' )">Search</button> + <br/><b>Change Requests</b><br/> + + <table> + <tr><td><select id="results" size="10" style="width: 300px"></select></td></tr> + <tr><td><button type="button" onclick="javascript: select();">OK</button> + <button type="button" onclick="javascript: cancel()">Cancel</button></td></tr> + </table> + +</body> +</html>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/resourceshape_creation_rdfxml.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/resourceshape_creation_rdfxml.jsp new file mode 100644 index 0000000..36ae5a7 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/resourceshape_creation_rdfxml.jsp @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8"?> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="application/x-oslc-compact+xml" language="java"%> +<%@ page import="java.util.List" %> +<%@ page import="jbugz.base.Bug"%> +<% + String bugzillaUri = (String) request.getAttribute("bugzillaUri"); + List<String> operatingSystems = (List<String>)request.getAttribute("operatingSystems"); + List<String> components = (List<String>)request.getAttribute("components"); + List<String> platforms = (List<String>)request.getAttribute("platforms"); + List<String> versions = (List<String>)request.getAttribute("versions"); +%> +<oslc:ResourceShape xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/terms/" + xmlns:oslc="http://open-services.net/ns/core#" + xmlns:oslc_cm="http://open-services.net/ns/cm#" + rdf:about="http://example.com/resource/ChangeRequestShape4Reporting"> + + <oslc:describes rdf:resource="http://open-services.net/ns/cm#ChangeRequest" /> + + <dc:title>Resource Shape for Change Request Creation</dc:title> + + <oslc:property> + <oslc:Property> + <oslc:name>title</oslc:name> + <oslc:propertyDefinition rdf:resource="http://purl.org/dc/terms/title" /> + <oslc:valueType rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:name>version</oslc:name> + <oslc:propertyDefinition rdf:resource="http://www.bugzilla.org/rdf#version" /> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + <% for (String v : versions) { %><oslc:allowedValue><%= v %></oslc:allowedValue> + <% } %> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:name>component</oslc:name> + <oslc:propertyDefinition rdf:resource="http://www.bugzilla.org/rdf#version" /> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + <% for (String c : components) { %><oslc:allowedValue><%= c %></oslc:allowedValue> + <% } %> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:name>platform</oslc:name> + <oslc:propertyDefinition rdf:resource="http://www.bugzilla.org/rdf#platform" /> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + <% for (String p : platforms) { %><oslc:allowedValue><%= p %></oslc:allowedValue> + <% } %> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:name>opsys</oslc:name> + <oslc:propertyDefinition rdf:resource="http://www.bugzilla.org/rdf#opsys" /> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + <% for (String o : operatingSystems) { %><oslc:allowedValue><%= o %></oslc:allowedValue> + <% } %> + </oslc:Property> + </oslc:property> + +</oslc:ResourceShape> diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/resourceshape_query_cr_rdfxml.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/resourceshape_query_cr_rdfxml.jsp new file mode 100644 index 0000000..433557d --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/resourceshape_query_cr_rdfxml.jsp @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="UTF-8"?> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="application/x-oslc-compact+xml" language="java"%> +<%@ page import="java.util.List" %> +<%@ page import="jbugz.base.Bug"%> +<% + String bugzillaUri = (String) request.getAttribute("bugzillaUri"); + List<String> operatingSystems = (List<String>) request.getAttribute("operatingSystems"); + List<String> components = (List<String>) request.getAttribute("components"); + List<String> platforms = (List<String>) request.getAttribute("platforms"); + List<String> versions = (List<String>) request.getAttribute("versions"); +%> +<oslc:ResourceShape xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/terms/" + xmlns:oslc="http://open-services.net/ns/core#" + xmlns:oslc_cm="http://open-services.net/ns/cm#" + rdf:about="http://example.com/resource/ChangeRequestShape4Reporting"> + + <oslc:describes rdf:resource="http://open-services.net/ns/cm#ChangeRequest" /> + + <dc:title>Resource Shape for Change Request Creation</dc:title> + + <oslc:property> + <oslc:Property> + <oslc:name>title</oslc:name> + <oslc:propertyDefinition rdf:resource="http://purl.org/dc/terms/title" /> + <oslc:valueType rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:name>version</oslc:name> + <oslc:propertyDefinition rdf:resource="http://www.bugzilla.org/rdf#version" /> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + <% for (String v : versions) {%><oslc:allowedValue><%= v%></oslc:allowedValue> + <% }%> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:name>component</oslc:name> + <oslc:propertyDefinition rdf:resource="http://www.bugzilla.org/rdf#version" /> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + <% for (String c : components) {%><oslc:allowedValue><%= c%></oslc:allowedValue> + <% }%> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:name>platform</oslc:name> + <oslc:propertyDefinition rdf:resource="http://www.bugzilla.org/rdf#platform" /> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + <% for (String p : platforms) {%><oslc:allowedValue><%= p%></oslc:allowedValue> + <% }%> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:name>opsys</oslc:name> + <oslc:propertyDefinition rdf:resource="http://www.bugzilla.org/rdf#opsys" /> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one" /> + <% for (String o : operatingSystems) {%><oslc:allowedValue><%= o%></oslc:allowedValue> + <% }%> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:propertyDefinition rdf:resource="http://purl.org/dc/terms/identifier"/> + <oslc:name>dcterms:identifier</oslc:name> + <dcterms:title xml:lang="en">Identifier</dcterms:title> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string"/> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one"/> + <oslc:readOnly rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</oslc:readOnly> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:propertyDefinition rdf:resource="http://purl.org/dc/terms/contributor"/> + <oslc:name>dcterms:contributor</oslc:name> + <dcterms:title xml:lang="en">Contributor</dcterms:title> + <oslc:valueType rdf:resource="http://open-services.net/ns/core#Resource"/> + <oslc:range rdf:resource="http://xmlns.com/foaf/0.1/Person"/> + <oslc:representation rdf:resource="http://open-service.net/ns/core#Inline"/> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one"/> + <oslc:readOnly rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</oslc:readOnly> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:propertyDefinition rdf:resource="http://open-services.net/ns/cm#status"/> + <oslc:name>oslc_cm:status</oslc:name> + <dcterms:title xml:lang="en">Identifier</dcterms:title> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#string"/> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one"/> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:propertyDefinition rdf:resource="http://purl.org/dc/terms/created"/> + <oslc:name>dcterms:created</oslc:name> + <dcterms:title xml:lang="en">Date Created</dcterms:title> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime"/> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one"/> + <oslc:readOnly rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</oslc:readOnly> + </oslc:Property> + </oslc:property> + + <oslc:property> + <oslc:Property> + <oslc:propertyDefinition rdf:resource="http://purl.org/dc/terms/modified"/> + <oslc:name>dcterms:modified</oslc:name> + <dcterms:title xml:lang="en">Date Modified</dcterms:title> + <oslc:valueType rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime"/> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Exactly-one"/> + <oslc:readOnly rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</oslc:readOnly> + </oslc:Property> + </oslc:property> + +</oslc:ResourceShape> diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/resourceshape_query_rdfxml.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/resourceshape_query_rdfxml.jsp new file mode 100644 index 0000000..5f1e71e --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/resourceshape_query_rdfxml.jsp @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="application/x-oslc-compact+xml" language="java"%> +<%@ page import="java.util.List" %> +<%@ page import="jbugz.base.Bug"%> +<%@ page import="org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.URLStrategy"%> +<% + String bugzillaUri = (String) request.getAttribute("bugzillaUri"); + Product product = (Product)request.getAttribute("product"); + List<String> operatingSystems = (List<String>)request.getAttribute("operatingSystems"); + List<String> components = (List<String>)request.getAttribute("components"); + List<String> platforms = (List<String>)request.getAttribute("platforms"); + List<String> versions = (List<String>)request.getAttribute("versions"); +%> +<oslc:ResourceShape xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/terms/" + xmlns:oslc="http://open-services.net/ns/core#" + rdf:about="http://example.com/resource/ChangeRequestShape4Reporting"> + + <oslc:describes rdf:resource="http://www.bugzilla.org/rdf#QueryResponse" /> + + <dc:title>Resource Shape for Query</dc:title> + + <oslc:property> + <oslc:Property> + <oslc:name>member</oslc:name> + <oslc:propertyDefinition rdf:resource="http://www.w3.org/2000/01/rdf-schema#member" /> + <oslc:valueType rdf:resource="http://open-services.net/ns/core#AnyResource" /> + <oslc:valueShape rdf:resource="<%= URLStrategy.getQueryChangeRequestShapeURL(product.getId()) %>" /> + <oslc:occurs rdf:resource="http://open-services.net/ns/core#Zero-or-many" /> + <oslc:isMemberProperty>true</oslc:isMemberProperty> + </oslc:Property> + </oslc:property> + +</oslc:ResourceShape> diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/rootservices_rdfxml.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/rootservices_rdfxml.jsp new file mode 100644 index 0000000..265c6a1 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/rootservices_rdfxml.jsp @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<%--
+ Copyright (c) 2011 IBM Corporation.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ and Eclipse Distribution License v. 1.0 which accompanies this distribution.
+
+ The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ and the Eclipse Distribution License is available at
+ http://www.eclipse.org/org/documents/edl-v10.php.
+
+ Contributors:
+
+ IBM Corporation - initial API and implementation
+--%>
+<%@ page contentType="application/rdf+xml" language="java"%>
+<%
+String baseUri = (String) request.getAttribute("baseUri");
+%>
+<!-- Jazz Root Services, see:
+ https://jazz.net/wiki/bin/view/Main/RootServicesSpec
+ https://jazz.net/wiki/bin/view/Main/RootServicesSpecAddendum2
+ -->
+<rdf:Description rdf:about="<%= baseUri + "/rootservices" %>"
+ xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/"
+ xmlns:dcterms="http://purl.org/dc/terms/"
+ xmlns:jfs="http://jazz.net/xmlns/prod/jazz/jfs/1.0/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+
+ <dcterms:title>OSLC-CM Adapter/Bugzilla Jazz Root Services</dcterms:title>
+ <oslc_cm:cmServiceProviders rdf:resource="<%= baseUri + "/catalog" %>" />
+ <jfs:oauthAccessTokenUrl rdf:resource="<%= baseUri + "/access_token" %>" />
+ <jfs:oauthRealmName>Bugzilla</jfs:oauthRealmName>
+ <jfs:oauthDomain><%= baseUri %></jfs:oauthDomain>
+ <jfs:oauthUserAuthorizationUrl rdf:resource="<%= baseUri + "/authorize" %>" />
+ <jfs:oauthRequestConsumerKeyUrl rdf:resource="<%= baseUri + "/consumer_key" %>" />
+</rdf:Description>
diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovider_html.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovider_html.jsp new file mode 100644 index 0000000..2df6a52 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovider_html.jsp @@ -0,0 +1,119 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="text/html" language="java" %> +<%@ page import="java.util.List" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.URLStrategy"%> +<% +String bugzillaUri = (String) request.getAttribute("bugzillaUri"); +Product product = (Product)request.getAttribute("product"); +%> +<html> + <head> + <title>Bugzilla OSLC Adapter: Service Provider for <%= product.getName() + "(" + product.getId() + ")" %></title> + <link href="<%= bugzillaUri %>/skins/standard/global.css" rel="stylesheet" type="text/css"> + <link href="<%= bugzillaUri %>/skins/standard/index.css" rel="stylesheet" type="text/css"> + <link href="<%= bugzillaUri %>/skins/standard/global.css" rel="alternate stylesheet" title="Classic" type="text/css"> + <link href="<%= bugzillaUri %>/skins/standard/index.css" rel="alternate stylesheet" title="Classic" type="text/css"> + <link href="<%= bugzillaUri %>/skins/contrib/Dusk/global.css" rel="stylesheet" title="Dusk" type="text/css"> + <link href="<%= bugzillaUri %>/skins/contrib/Dusk/index.css" rel="stylesheet" title="Dusk" type="text/css"> + <link href="<%= bugzillaUri %>/skins/custom/global.css" rel="stylesheet" type="text/css"> + <link href="<%= bugzillaUri %>/skins/custom/index.css" rel="stylesheet" type="text/css"> + <link rel="shortcut icon" href="<%= bugzillaUri %>/images/favicon.ico"> + </head> + <body onload=""> + + <div id="header"> + <div id="banner"></div> + <table border="0" cellspacing="0" cellpadding="0" id="titles"> + <tr> + <td id="title"> + <p> + Bugzilla OSLC Adapter: Service Provider + </p> + </td> + <td id="information"> + <p class="header_addl_info"> + version 0.1 + </p> + </td> + </tr> + </table> + </div> + + <div id="bugzilla-body"> + <div id="page-index"> + + <img src="bugzilla.gif" alt="icon" width="80" height="80" /> + + <h1>Service Provider for <%= product.getName() + "(" + product.getId() + ")" %></h1> + + <p>Enables navigation to OSLC-CM Resource Creator and Selector Dialogs</p> + + <table> + <tr> + <td><b>This document</b>:</td> + <td><a href="<%= URLStrategy.getServiceProviderURL(product.getId()) %>"> + <%= URLStrategy.getServiceProviderURL(product.getId()) %></a></td> + </tr> + <tr> + <td><b>Bugzilla</b>:</td> + <td><a href="<%= bugzillaUri %>"><%= bugzillaUri %></a></td> + </tr> + <tr> + <td><b>Adapter Publisher</b>:</td> + <td>OSLC Tools Project</td> + </tr> + <tr> + <td><b>Adapter Identity</b>:</td> + <td>org.eclipse.lyo.samples.bugzilla.test</td> + </tr> + </table> + + <h2>OSLC-CM Resource Selector Dialog</h2> + <p><a href="<%= URLStrategy.getDelegatedSelectionURL(product.getId()) %>"> + <%= URLStrategy.getDelegatedSelectionURL(product.getId()) %></a></p> + + <h2>OSLC-CM Resource Creator Dialog</h2> + <p><a href="<%= URLStrategy.getDelegatedCreationURL(product.getId()) %>"> + <%= URLStrategy.getDelegatedCreationURL(product.getId()) %></a></p> + + <h2>OSLC-CM Resource Creation Factory and Resource Shape</h2> + <p><a href="<%= URLStrategy.getChangeRequestCollectionURL(product.getId()) %>"> + <%= URLStrategy.getChangeRequestCollectionURL(product.getId()) %></a></p> + <p><a href="<%= URLStrategy.getCreationShapeURL(product.getId()) %>"> + <%= URLStrategy.getCreationShapeURL(product.getId()) %></a></p> + + <h2>OSLC-CM Resource Query Capability and Resource Shape</h2> + <p><a href="<%= URLStrategy.getChangeRequestCollectionURL(product.getId()) %>"> + <%= URLStrategy.getChangeRequestCollectionURL(product.getId()) %></a></p> + <p><a href="<%= URLStrategy.getQueryShapeURL(product.getId()) %>"> + <%= URLStrategy.getQueryShapeURL(product.getId()) %></a></p> + + </div> + </div> + + <div id="footer"> + <div class="intro"></div> + <div class="outro"> + <div style="margin: 0 1em 1em 1em; line-height: 1.6em; text-align: left"> + <b>OSLC Tools Adapter Server 0.1</b> brought to you by the <a href="http://open-services.net">OSLC Community</a><br> + </div> + </div> + </div> + </body> +</html>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovider_rdfxml.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovider_rdfxml.jsp new file mode 100644 index 0000000..aa06323 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovider_rdfxml.jsp @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="UTF-8"?> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="application/rdf+xml" language="java"%> +<%@ page import="java.util.List" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.URLStrategy"%> +<% +String bugzillaUri = (String) request.getAttribute("bugzillaUri"); +Product product = (Product)request.getAttribute("product"); +response.setHeader("OSLC-Core-Version", "2.0"); +%> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dcterms="http://purl.org/dc/terms/" + xmlns:oslc="http://open-services.net/ns/core#"> + + <oslc:ServiceProvider rdf:about="<%= URLStrategy.getServiceProviderURL(product.getId()) %>"> + <dcterms:title>OSLC-CM Adapter/Bugzilla Service Provider: + Product <%= product.getName() + "(" + product.getId() + ")" %></dcterms:title> + <dcterms:description> + Enables navigation to OSLC-CM Resource Creator and Selector Dialogs + </dcterms:description> + + <dcterms:publisher> + <oslc:Publisher> + <dcterms:title>OSLC Tools Project</dcterms:title> + <dcterms:identifier>org.eclipse.lyo.samples.bugzilla.test</dcterms:identifier> + <oslc:icon rdf:resource="<%= bugzillaUri %>/images/favicon.ico" /> + </oslc:Publisher> + </dcterms:publisher> + + <oslc:service> + <oslc:Service> + <oslc:domain rdf:resource="http://open-services.net/ns/cm#" /> + <oslc:selectionDialog> + <oslc:Dialog> + <dcterms:title>Bugzilla Bug Picker</dcterms:title> + <oslc:label>Bugs</oslc:label> + <oslc:dialog rdf:resource="<%= URLStrategy.getDelegatedSelectionURL(product.getId()) %>" /> + <oslc:hintHeight>300px</oslc:hintHeight> + <oslc:hintWidth>350px</oslc:hintWidth> + <oslc:resourceType rdf:resource="http://open-services.net/ns/cm#ChangeRequest" /> + <oslc:usage rdf:resource="http://open-services.net/ns/core#default" /> + </oslc:Dialog> + </oslc:selectionDialog> + + <oslc:creationDialog> + <oslc:Dialog> + <dcterms:title>Bugzilla Bug Creator</dcterms:title> + <oslc:label>Bugs</oslc:label> + <oslc:dialog rdf:resource="<%= URLStrategy.getDelegatedCreationURL(product.getId()) %>" /> + <oslc:hintHeight>240px</oslc:hintHeight> + <oslc:hintWidth>420px</oslc:hintWidth> + <oslc:resourceType rdf:resource="http://open-services.net/ns/cm#ChangeRequest" /> + <oslc:usage rdf:resource="http://open-services.net/ns/core#default" /> + </oslc:Dialog> + </oslc:creationDialog> + + <oslc:creationFactory> + <oslc:CreationFactory> + <dcterms:title>OSLC-CM Creation Factory</dcterms:title> + <oslc:label>CreationFactory</oslc:label> + <oslc:creation + rdf:resource="<%= URLStrategy.getChangeRequestCollectionURL(product.getId()) %>" /> + <oslc:resourceShape + rdf:resource="<%= URLStrategy.getCreationShapeURL(product.getId()) %>" /> + <oslc:resourceType + rdf:resource="http://open-services.net/ns/cm#ChangeRequest" /> + <oslc:usage + rdf:resource="http://open-services.net/ns/core#default" /> + </oslc:CreationFactory> + </oslc:creationFactory> + + <oslc:queryCapability> + <oslc:QueryCapability> + <dcterms:title>OSLC-CM Query Capability</dcterms:title> + <oslc:label>QueryCapability</oslc:label> + <oslc:queryBase + rdf:resource="<%= URLStrategy.getChangeRequestCollectionURL(product.getId()) %>" /> + <oslc:resourceShape + rdf:resource="<%= URLStrategy.getQueryShapeURL(product.getId()) %>" /> + <oslc:resourceType + rdf:resource="http://open-services.net/ns/cm#ChangeRequest" /> + <oslc:usage + rdf:resource="http://open-services.net/ns/core#default" /> + </oslc:QueryCapability> + </oslc:queryCapability> + + </oslc:Service> + </oslc:service> + + <oslc:prefixDefinition> + <oslc:PrefixDefinition> + <oslc:prefix>oslc</oslc:prefix> + <oslc:prefixBase rdf:resource="http://open-services.net/ns/core#" /> + </oslc:PrefixDefinition> + </oslc:prefixDefinition> + + <oslc:prefixDefinition> + <oslc:PrefixDefinition> + <oslc:prefix>oslc_cm</oslc:prefix> + <oslc:prefixBase rdf:resource="http://open-services.net/ns/cm#" /> + </oslc:PrefixDefinition> + </oslc:prefixDefinition> + + <oslc:prefixDefinition> + <oslc:PrefixDefinition> + <oslc:prefix>rdf</oslc:prefix> + <oslc:prefixBase rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#" /> + </oslc:PrefixDefinition> + </oslc:prefixDefinition> + + <oslc:prefixDefinition> + <oslc:PrefixDefinition> + <oslc:prefix>dcterms</oslc:prefix> + <oslc:prefixBase rdf:resource="http://purl.org/dc/terms/" /> + </oslc:PrefixDefinition> + </oslc:prefixDefinition> + + <oslc:prefixDefinition> + <oslc:PrefixDefinition> + <oslc:prefix>rdfs</oslc:prefix> + <oslc:prefixBase rdf:resource="http://www.w3.org/2000/01/rdf-schema#" /> + </oslc:PrefixDefinition> + </oslc:prefixDefinition> + + <oslc:prefixDefinition> + <oslc:PrefixDefinition> + <oslc:prefix>foaf</oslc:prefix> + <oslc:prefixBase rdf:resource="http://http://xmlns.com/foaf/0.1/" /> + </oslc:PrefixDefinition> + </oslc:prefixDefinition> + + <oslc:prefixDefinition> + <oslc:PrefixDefinition> + <oslc:prefix>bugz</oslc:prefix> + <oslc:prefixBase rdf:resource="http://www.bugzilla.org/rdf#" /> + </oslc:PrefixDefinition> + </oslc:prefixDefinition> + + </oslc:ServiceProvider> + +</rdf:RDF> diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovidercatalog_html.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovidercatalog_html.jsp new file mode 100644 index 0000000..c48d5ef --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovidercatalog_html.jsp @@ -0,0 +1,108 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="text/html" language="java"%> +<%@ page import="java.util.List" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.URLStrategy"%> +<% +String bugzillaUri = (String) request.getAttribute("bugzillaUri"); +List<Product> products = (List<Product>)request.getAttribute("products"); +%> +<html> + <head> + <title>Bugzilla OSLC Adapter: Service Provider Catalog</title> + <link href="<%= bugzillaUri %>/skins/standard/global.css" rel="stylesheet" type="text/css"> + <link href="<%= bugzillaUri %>/skins/standard/index.css" rel="stylesheet" type="text/css"> + <link href="<%= bugzillaUri %>/skins/standard/global.css" rel="alternate stylesheet" title="Classic" type="text/css"> + <link href="<%= bugzillaUri %>/skins/standard/index.css" rel="alternate stylesheet" title="Classic" type="text/css"> + <link href="<%= bugzillaUri %>/skins/contrib/Dusk/global.css" rel="stylesheet" title="Dusk" type="text/css"> + <link href="<%= bugzillaUri %>/skins/contrib/Dusk/index.css" rel="stylesheet" title="Dusk" type="text/css"> + <link href="<%= bugzillaUri %>/skins/custom/global.css" rel="stylesheet" type="text/css"> + <link href="<%= bugzillaUri %>/skins/custom/index.css" rel="stylesheet" type="text/css"> + <link rel="shortcut icon" href="<%= bugzillaUri %>/images/favicon.ico"> + </head> + <body onload=""> + + <div id="header"> + <div id="banner"></div> + <table border="0" cellspacing="0" cellpadding="0" id="titles"> + <tr> + <td id="title"> + <p> + Bugzilla OSLC Adapter: Service Provider Catalog + </p> + </td> + <td id="information"> + <p class="header_addl_info"> + version 0.1 + </p> + </td> + </tr> + </table> + </div> + + <div id="bugzilla-body"> + <div id="page-index"> + + <img src="bugzilla.gif" alt="icon" width="80" height="80" /> + + <h1>Service Provider Catalog</h1> + + <p>Enables navigation to Service Provider for each Product against which bugs may be reported.</p> + + <table> + <tr> + <td><b>This document</b>:</td> + <td><a href="<%= URLStrategy.getServiceProviderCatalogURL() %>"> + <%= URLStrategy.getServiceProviderCatalogURL() %> + </a></td> + </tr> + <tr> + <td><b>Bugzilla</b>:</td> + <td><a href="<%= bugzillaUri %>"><%= bugzillaUri %></a></td> + </tr> + <tr> + <td><b>Adapter Publisher</b>:</td> + <td>OSLC Tools Project</td> + </tr> + <tr> + <td><b>Adapter Identity</b>:</td> + <td>org.eclipse.lyo.samples.bugzilla.test</td> + </tr> + </table> + + <h2>Service Providers</h2> + + <% for (Product p : products) { %> + <h3>Service Provider for Product <%= p.getName() %></h3> + <p><a href="<%= URLStrategy.getServiceProviderURL(p.getId()) %>"> + <%= URLStrategy.getServiceProviderURL(p.getId()) %></a></p> + <% } %> + + </div> + </div> + + <div id="footer"> + <div class="intro"></div> + <div class="outro"> + <div style="margin: 0 1em 1em 1em; line-height: 1.6em; text-align: left"> + <b>OSLC Tools Adapter Server 0.1</b> brought to you by the <a href="http://open-services.net">OSLC Community</a><br> + </div> + </div> + </div> + </body> +</html> diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovidercatalog_rdfxml.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovidercatalog_rdfxml.jsp new file mode 100644 index 0000000..6ac22dc --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/cm/serviceprovidercatalog_rdfxml.jsp @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8"?> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<%@ page contentType="application/rdf+xml" language="java"%> +<%@ page import="java.util.List" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product" %> +<%@ page import="org.eclipse.lyo.samples.bugzilla.URLStrategy"%> +<% +String bugzillaUri = (String) request.getAttribute("bugzillaUri"); +List<Product> products = (List<Product>)request.getAttribute("products"); +response.setHeader("OSLC-Core-Version", "2.0"); +%> +<rdf:RDF + xmlns:oslc="http://open-services.net/ns/core#" + xmlns:dcterms="http://purl.org/dc/terms/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + + <oslc:ServiceProviderCatalog rdf:about="<%= URLStrategy.getServiceProviderCatalogURL() %>"> + <dcterms:title>OSLC-CM Adapter/Bugzilla Service Provider Catalog</dcterms:title> + <dcterms:description> + Enables navigation to Service Provider for each Product against which bugs may be reported. + </dcterms:description> + <oslc:domain rdf:resource="http://open-services.net/ns/cm#" /> + + <dcterms:publisher> + <oslc:Publisher> + <dcterms:title>OSLC Tools Project</dcterms:title> + <dcterms:identifier>org.eclipse.lyo.samples.bugzilla.test</dcterms:identifier> + <oslc:icon rdf:resource="<%= bugzillaUri %>/images/favicon.ico" /> + </oslc:Publisher> + </dcterms:publisher> + + <% for (Product p : products) { %> + <oslc:serviceProvider> + <oslc:ServiceProvider rdf:about="<%= URLStrategy.getServiceProviderURL(p.getId()) %>"> + <dcterms:title><%= p.getName() %></dcterms:title> + <oslc:details rdf:resource="<%= URLStrategy.getServiceProviderURL(p.getId()) %>" /> + </oslc:ServiceProvider> + </oslc:serviceProvider> + <% } %> + + <%-- + <oslc:oauthConfiguration> + <oslc:OAuthConfiguration> + <oslc:oauthRequestTokenURI rdf:resource="http://example.com/bugs/oauth-request-token" /> + <oslc:authorizationURI rdf:resource="http://example.com/bugs/oauth-authorization" /> + <oslc:oauthAccessTokenURI rdf:resource="http://example.com/bugs/oauth-access-token" /> + </oslc:OAuthConfiguration> + </oslc:oauthConfiguration> + --%> + + </oslc:ServiceProviderCatalog> +</rdf:RDF>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/index.jsp b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/index.jsp new file mode 100644 index 0000000..e73f5a5 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/index.jsp @@ -0,0 +1,20 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%-- + Copyright (c) 2011 IBM Corporation. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + and Eclipse Distribution License v. 1.0 which accompanies this distribution. + + The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + Contributors: + + IBM Corporation - initial API and implementation +--%> +<% +final RequestDispatcher rd = request.getRequestDispatcher("/catalog"); +rd.forward(request, response); +%>
\ No newline at end of file diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/oslc.png b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/oslc.png Binary files differnew file mode 100644 index 0000000..81015ab --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/oslc.png diff --git a/org.eclipse.lyo.samples.bugzilla/src/main/webapp/oslcLg.png b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/oslcLg.png Binary files differnew file mode 100644 index 0000000..3185789 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/main/webapp/oslcLg.png diff --git a/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/SanityCheck.java b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/SanityCheck.java new file mode 100644 index 0000000..49e140d --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/SanityCheck.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.test; + +import java.net.HttpURLConnection; +import java.net.URL; + +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; + + +public class SanityCheck { // extends TestCase { + + public void testParsing() throws Exception { + parse("http://localhost:8282/bugz/catalog"); + parse("http://localhost:8282/bugz/provider?productId=2"); + parse("http://localhost:8282/bugz/changerequests?productId=2"); + parse("http://localhost:8282/bugz/changerequest?id=6"); + parse("http://localhost:8282/bugz/creationshape?productId=2"); + parse("http://localhost:8282/bugz/queryshape?productId=2"); + } + + public void parse(String urlstr) throws Exception { + URL url = new URL(urlstr); + HttpURLConnection conn = (HttpURLConnection)url.openConnection(); + conn.setRequestProperty("Accept", "application/rdf+xml"); + Model model = ModelFactory.createDefaultModel(); + model.read(conn.getInputStream(), urlstr); + //Resource resource = model.getResource(urlstr); + System.out.println("OK - " + urlstr); + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestAcceptType.java b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestAcceptType.java new file mode 100644 index 0000000..86a5068 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestAcceptType.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.test; + +import java.util.Vector; + +import org.eclipse.lyo.samples.bugzilla.utils.AcceptType; + + +import junit.framework.TestCase; + + +public class TestAcceptType extends TestCase { + + public void testAcceptStrings() { + + Vector<String> accept1 = new Vector<String>(); + accept1.add("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); + assertTrue( AcceptType.willAccept("text/html", accept1.elements())); + + Vector<String> accept2 = new Vector<String>(); + accept2.add("application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"); + assertTrue( AcceptType.willAccept("text/html", accept2.elements())); + + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestBean.java b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestBean.java new file mode 100644 index 0000000..ccd89af --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestBean.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.test;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.lyo.samples.bugzilla.resources.BugzillaChangeRequest;
+import org.eclipse.lyo.samples.bugzilla.resources.Person;
+
+import thewebsemantic.Bean2RDF;
+import junit.framework.TestCase;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+
+public class TestBean extends TestCase {
+ public void testBugzillaChangeRequestBean() throws URISyntaxException {
+ BugzillaChangeRequest cr = createChangeRequest();
+
+ Model m = ModelFactory.createOntologyModel();
+ Bean2RDF writer = new Bean2RDF(m);
+ writer.save(cr);
+
+ m.write(System.out);
+ }
+
+ private BugzillaChangeRequest createChangeRequest()
+ throws URISyntaxException {
+ BugzillaChangeRequest cr = new BugzillaChangeRequest();
+ cr.setUri(new URI("http://localhost:8282/bugz/24"));
+ cr.setTitle("New Bug: " + System.currentTimeMillis());
+
+ Person nina = new Person();
+ nina.setName("Nina Example");
+ nina.setEmail("nina@example.com");
+
+ cr.setContributor(nina);
+ cr.setProduct("FakePortal");
+ cr.setComponent("Datastore");
+ cr.setVersion("1.0");
+ cr.setOperatingSystem("Mac OS");
+ cr.setPlatform("Macintosh");
+
+ return cr;
+ }
+}
diff --git a/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestConnection.java b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestConnection.java new file mode 100644 index 0000000..26399d7 --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestConnection.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.test; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jbugz.base.Bug; +import jbugz.base.BugzillaConnector; +import jbugz.rpc.ReportBug; +import junit.framework.TestCase; + +import org.eclipse.lyo.samples.bugzilla.BugzillaInitializer; +import org.eclipse.lyo.samples.bugzilla.jbugzx.base.Product; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.ExtendedBugSearch; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetAccessibleProducts; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetLegalValues; +import org.eclipse.lyo.samples.bugzilla.jbugzx.rpc.GetProducts; + + +public class TestConnection extends TestCase { + + public void testConnection() { + + try { + BugzillaInitializer.getBugzillaConnector(); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + public void testReportBug() { + + try { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + + Map<String, Object> bugState = new HashMap<String, Object>(); + bugState.put("product", "FakePortal"); + bugState.put("component", "Datastore"); + bugState.put("summary", "New Bug: " + System.currentTimeMillis()); + bugState.put("version", "1.0"); + bugState.put("op_sys", "Mac OS"); + bugState.put("platform", "Macintosh"); + Bug bug = new Bug(bugState); + ReportBug reportBug = new ReportBug(bug); + + bc.executeMethod(reportBug); + + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + public void testGetLegalValues() { + + Integer[] productIds = null; + try { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + GetAccessibleProducts gap = new GetAccessibleProducts(); + bc.executeMethod(gap); + productIds = gap.getIds(); + assertTrue(productIds.length > 0); + + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + + try { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + GetProducts gps = new GetProducts(productIds); + bc.executeMethod(gps); + List<Product> products = gps.getProducts(); + assertTrue(products.size() > 0); + + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + + try { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + GetLegalValues glv = new GetLegalValues("op_sys", -1); + bc.executeMethod(glv); + String[] values = glv.getValues(); + assertTrue(values.length > 0); + + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + public void testSearchBugs() { + + try { + BugzillaConnector bc = BugzillaInitializer.getBugzillaConnector(); + + ExtendedBugSearch search = new ExtendedBugSearch(ExtendedBugSearch.ExtendedSearchLimiter.PRODUCT, "FakePortal"); + bc.executeMethod(search); + + System.out.println("Search returned = " + search.getSearchResults().size()); + + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestParser.java b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestParser.java new file mode 100644 index 0000000..2324fde --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/test/java/org/eclipse/lyo/samples/bugzilla/test/TestParser.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2011 IBM Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v. 1.0 which accompanies this distribution. + * + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.lyo.samples.bugzilla.test; + +import junit.framework.TestCase; + +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.hp.hpl.jena.rdf.model.Property; +import com.hp.hpl.jena.rdf.model.Resource; +import com.hp.hpl.jena.rdf.model.Statement; + + +public class TestParser extends TestCase { + + public void testParsing() { + + Model model = ModelFactory.createDefaultModel(); + model.read(this.getClass().getResourceAsStream("/bug2.xml"), ""); + Resource resource = model.getResource(""); + + Property titleProp = model.getProperty("http://purl.org/dc/terms/title"); + Statement title = model.getProperty(resource, titleProp); + System.err.println("Title = " + title.getString()); + + Property productProp = model.getProperty("http://www.bugzilla.org/rdf#product"); + Statement product = model.getProperty(resource, productProp); + System.err.println("Product = " + product.getString()); + + Property componentProp = model.getProperty("http://www.bugzilla.org/rdf#component"); + Statement component = model.getProperty(resource, componentProp); + System.err.println("Component = " + component.getString()); + + } +} diff --git a/org.eclipse.lyo.samples.bugzilla/src/test/resources/bug2.xml b/org.eclipse.lyo.samples.bugzilla/src/test/resources/bug2.xml new file mode 100644 index 0000000..e5206ce --- a/dev/null +++ b/org.eclipse.lyo.samples.bugzilla/src/test/resources/bug2.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dcterms="http://purl.org/dc/terms/" + xmlns:oslc="http://open-services.net/ns/core#" + xmlns:oslc_cm="http://open-services.net/ns/cm#" + xmlns:bugz="http://www.bugzilla.org/rdf#" + xmlns:foaf="http://http://xmlns.com/foaf/0.1/"> + + <oslc_cm:ChangeRequest rdf:about=""> + <rdf:type rdf:resource="http://open-services.net/ns/cm#ChangeRequest" /> + <dcterms:title>First Bug!</dcterms:title> + <dcterms:contributor> + <foaf:Person> + <foaf:name>nina@example.com</foaf:name> + </foaf:Person> + </dcterms:contributor> + <bugz:product>FakePortal</bugz:product> + <bugz:component>Datastore</bugz:component> + </oslc_cm:ChangeRequest> + +</rdf:RDF>
\ No newline at end of file |

