aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Terry2013-03-06 14:40:55 (EST)
committerDavid Terry2013-03-06 14:40:55 (EST)
commitfbb21645e72f0ce177be8440022a6ce355d6eceb (patch)
tree7571010b5a2c3fd036aee3a61401c434c7f7912c
parentc6d8d4e09b23cc5602338c2f3ad4bf8e3632eb1d (diff)
downloadorg.eclipse.lyo.rio-fbb21645e72f0ce177be8440022a6ce355d6eceb.zip
org.eclipse.lyo.rio-fbb21645e72f0ce177be8440022a6ce355d6eceb.tar.gz
org.eclipse.lyo.rio-fbb21645e72f0ce177be8440022a6ce355d6eceb.tar.bz2
Bug 402577 - Initial contribution of SDK, tests suites and RIO for OSLCrefs/changes/06/10906/1
Tracked Resource Set and ACP Specifications Change-Id: Ie44cdcf6caeca170367589768ef1e8ecb8e30a57 Signed-off-by: David Terry <dgterry@us.ibm.com>
-rw-r--r--org.eclipse.lyo.rio.trs/.classpath27
-rw-r--r--org.eclipse.lyo.rio.trs/.project23
-rw-r--r--org.eclipse.lyo.rio.trs/Launch TRS Reference App.launch21
-rw-r--r--org.eclipse.lyo.rio.trs/about.html33
-rw-r--r--org.eclipse.lyo.rio.trs/jetty.xml45
-rw-r--r--org.eclipse.lyo.rio.trs/license/edl-v10.html60
-rw-r--r--org.eclipse.lyo.rio.trs/license/epl-v10.html259
-rw-r--r--org.eclipse.lyo.rio.trs/license/notice.html109
-rw-r--r--org.eclipse.lyo.rio.trs/pom.xml140
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/log4j.properties24
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/ChangeRequest.java912
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Constants.java52
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Severity.java27
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Type.java52
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/package-info.java29
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/BaseResource.java106
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/ChangeRequestResource.java424
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/ServiceProviderSingleton.java39
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/TRSResource.java164
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/BaseGeneric.java121
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/ChangeLogGeneric.java88
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/TRSGeneric.java101
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/Persistence.java299
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSUtil.java175
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSUtilHelper.java280
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/resources/build.properties11
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/ChangeReq_creator.jsp71
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/ChangeReq_modify.jsp71
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/CutOffEvent_modify.jsp55
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/TestApp.js156
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/providers21
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/resources11
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/web.xml56
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/changerequest_collection_html.jsp54
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/index.html35
35 files changed, 4151 insertions, 0 deletions
diff --git a/org.eclipse.lyo.rio.trs/.classpath b/org.eclipse.lyo.rio.trs/.classpath
new file mode 100644
index 0000000..e0ee9d6
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/.classpath
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.lyo.rio.trs/.project b/org.eclipse.lyo.rio.trs/.project
new file mode 100644
index 0000000..9f7a432
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.lyo.rio.trs</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</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.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.lyo.rio.trs/Launch TRS Reference App.launch b/org.eclipse.lyo.rio.trs/Launch TRS Reference App.launch
new file mode 100644
index 0000000..fa064aa
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/Launch TRS Reference App.launch
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?><launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
+<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
+<stringAttribute key="M2_GOALS" value="jetty:run -X"/>
+<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
+<booleanAttribute key="M2_OFFLINE" value="false"/>
+<stringAttribute key="M2_PROFILES" value=""/>
+<listAttribute key="M2_PROPERTIES"/>
+<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
+<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
+<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
+<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
+<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.m2e.launching.MavenSourceLocator"/>
+<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&amp;lt;workspace/&amp;gt;&quot; typeId=&quot;org.eclipse.debug.core.containerType.workspace&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&amp;lt;default/&amp;gt;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;"/>
+<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="UTF-8"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:MaxPermSize=256m -Dderby.system.home=${project_loc} -Dorg.eclipse.lyo.oslc4j.disableRelativeURIs=false"/>
+<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc}"/>
+</launchConfiguration> \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/about.html b/org.eclipse.lyo.rio.trs/about.html
new file mode 100644
index 0000000..e0fbbb2
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/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>13 December, 2011</p>
+ <h3>License</h3>
+ <p>
+ The Eclipse Foundation makes available all content in this plug-in
+ (&quot;Content&quot;). Unless otherwise indicated below, the Content
+ is provided to you under the terms and conditions of the Eclipse
+ Public License Version 1.0 (&quot;EPL&quot;) and Eclipse Distribution
+ License Version 1.0 (&quot;EDL&quot;). 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, &quot;Program&quot; 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
+ (&quot;Redistributor&quot;) 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.rio.trs/jetty.xml b/org.eclipse.lyo.rio.trs/jetty.xml
new file mode 100644
index 0000000..6aff2db
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/jetty.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+
+<!-- Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA). -->
+<!-- © Copyright IBM Corporation 2012. All Rights Reserved. -->
+<!-- U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. -->
+
+
+<!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/ -->
+
+ <!-- set up the port for Server -->
+ <Set name="connectors">
+ <Array type="org.eclipse.jetty.server.Connector">
+ <Item>
+ <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
+ <Set name="port"><SystemProperty name="jetty.port" default="8082"/></Set>
+ <Get id="PortUsed" name="port"/>
+ </New>
+ </Item>
+ </Array>
+ </Set>
+
+
+ <!-- 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="org.eclipse.jetty.util.log.Log" name="info"><Arg>Application launched at http://localhost:<Ref id="PortUsed"/>/<SystemProperty name="jetty.context"/>/index.html</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.rio.trs/license/edl-v10.html b/org.eclipse.lyo.rio.trs/license/edl-v10.html
new file mode 100644
index 0000000..26b0770
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/license/edl-v10.html
@@ -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.rio.trs/license/epl-v10.html b/org.eclipse.lyo.rio.trs/license/epl-v10.html
new file mode 100644
index 0000000..1107453
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/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.rio.trs/license/notice.html b/org.eclipse.lyo.rio.trs/license/notice.html
new file mode 100644
index 0000000..80720cd
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/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>13 December, 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 &quot;CONTENT&quot;). 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
+ (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Repository&quot;) in software modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</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 (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
+ <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</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 &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; 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 (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; 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 &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
+Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). 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 &quot;src&quot; 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 (&quot;Feature Update License&quot;) 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 &quot;license&quot; property of files named &quot;feature.properties&quot; 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 (&quot;Provisioning Technology&quot;) for the purpose of allowing users to install software, documentation, information and/or
+ other materials (collectively &quot;Installable Software&quot;). 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>
+ (&quot;Specification&quot;).</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 (&quot;Provisioning Process&quot;) in which a user may execute the Provisioning Technology
+ on a machine (&quot;Target Machine&quot;) 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 (&quot;Installable Software Agreement&quot;) 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.rio.trs/pom.xml b/org.eclipse.lyo.rio.trs/pom.xml
new file mode 100644
index 0000000..8b7ce93
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/pom.xml
@@ -0,0 +1,140 @@
+<!-- Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA). -->
+<!-- © Copyright IBM Corporation 2012. All Rights Reserved. -->
+<!-- U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. -->
+
+<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.rio</groupId>
+ <version>0.5.0-SNAPSHOT</version>
+ <name>TRS Reference Application</name>
+ <artifactId>org.eclipse.lyo.rio.trs</artifactId>
+ <description>Reference Application demonstrating a Tracked Resource Set integration utilizing the TRS toolkit.</description>
+ <packaging>war</packaging>
+
+ <repositories>
+ <repository>
+ <id>integration.sdk</id>
+ <url>http://gearbox-build.rtp.raleigh.ibm.com:8081/nexus/content/repositories/integration.sdk/</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.lyo</groupId>
+ <artifactId>org.eclipse.lyo.core.utils</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_2.5_spec</artifactId>
+ <version>1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.lyo</groupId>
+ <artifactId>oslc-trs</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
+ <timestamp>${maven.build.timestamp}</timestamp>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+
+ <outputDirectory>target/classes</outputDirectory>
+
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include> **/*.properties</include>
+ <include> **/*.index</include>
+ <include> **/resources</include>
+ <include> **/providers</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <!-- no default value -->
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>true</attach>
+ </configuration>
+ </plugin>
+
+ <!-- ********************************************** -->
+ <!-- Compiler Plugin -->
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <!-- Jetty 7 plugin See also: http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin -->
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>7.3.0.v20110203</version>
+
+ <configuration>
+ <systemProperties>
+ <systemProperty>
+ <name>jetty.logs</name>
+ <value>${basedir}/target</value>
+ </systemProperty>
+ <systemProperty>
+ <name>jetty.context</name>
+ <value>${project.artifactId}</value>
+ </systemProperty>
+ <!--<systemProperty>
+ <name>jetty.port</name>
+ <value>8085</value>
+ </systemProperty>-->
+ </systemProperties>
+ <webAppConfig>
+ <contextPath>/${project.artifactId}</contextPath>
+ </webAppConfig>
+
+ <!-- Jetty config adds logging -->
+ <jettyConfig>${basedir}/jetty.xml</jettyConfig>
+
+ <!-- enable hot deploy -->
+ <reload>automatic</reload>
+ <scanIntervalSeconds>5</scanIntervalSeconds>
+ <scanTargets>
+ <scanTarget>src/main/webapp</scanTarget>
+ </scanTargets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/log4j.properties b/org.eclipse.lyo.rio.trs/src/main/java/log4j.properties
new file mode 100644
index 0000000..2b04c9f
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/log4j.properties
@@ -0,0 +1,24 @@
+###############################################################################
+#
+# Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA).
+# Copyright IBM Corporation 2012. All Rights Reserved.
+# U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+#
+###############################################################################
+# Root logger option
+log4j.rootLogger=INFO, stdout, fileappender
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+log4j.appender.fileappender=org.apache.log4j.RollingFileAppender
+log4j.appender.fileappender.File=${catalina.base}/logs/hpqm.log
+log4j.appender.fileappender.layout=org.apache.log4j.PatternLayout
+log4j.appender.fileappender.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+log4j.logger.org.apache.wink.common = DEBUG, stdout, fileappender
+log4j.logger.org.apache.wink.server = DEBUG, stdout, fileappender
+log4j.logger.com.ibm.jlip.sdk = DEBUG, stdout, fileappender \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/ChangeRequest.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/ChangeRequest.java
new file mode 100644
index 0000000..36e5ed0
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/ChangeRequest.java
@@ -0,0 +1,912 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.cm;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.lyo.oslc4j.core.annotation.OslcAllowedValue;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcDescription;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcName;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcRange;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcReadOnly;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcResourceShape;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcTitle;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcValueType;
+import org.eclipse.lyo.oslc4j.core.model.AbstractResource;
+import org.eclipse.lyo.oslc4j.core.model.Link;
+import org.eclipse.lyo.oslc4j.core.model.Occurs;
+import org.eclipse.lyo.oslc4j.core.model.OslcConstants;
+import org.eclipse.lyo.oslc4j.core.model.ValueType;
+
+@OslcNamespace(Constants.CHANGE_MANAGEMENT_NAMESPACE)
+@OslcResourceShape(title = "Change Request Resource Shape", describes = Constants.TYPE_CHANGE_REQUEST)
+public final class ChangeRequest
+ extends AbstractResource
+{
+ private final Set<Link> affectedByDefects = new HashSet<Link>();
+ private final Set<Link> affectsPlanItems = new HashSet<Link>();
+ private final Set<Link> affectsRequirements = new HashSet<Link>();
+ private final Set<Link> affectsTestResults = new HashSet<Link>();
+ private final Set<Link> blocksTestExecutionRecords = new HashSet<Link>();
+ private final Set<URI> contributors = new TreeSet<URI>();
+ private final Set<URI> creators = new TreeSet<URI>();
+ private final Set<Type> dctermsTypes = new TreeSet<Type>();
+ private final Set<Link> implementsRequirements = new HashSet<Link>();
+ private final Set<Link> relatedChangeRequests = new HashSet<Link>();
+ private final Set<Link> relatedResources = new HashSet<Link>(); // TODO - Extension to point to any other OSLC resource(s).
+ private final Set<Link> relatedTestCases = new HashSet<Link>();
+ private final Set<Link> relatedTestExecutionRecords = new HashSet<Link>();
+ private final Set<Link> relatedTestPlans = new HashSet<Link>();
+ private final Set<Link> relatedTestScripts = new HashSet<Link>();
+ private final Set<String> subjects = new TreeSet<String>();
+ private final Set<Link> testedByTestCases = new HashSet<Link>();
+ private final Set<Link> tracksChangeSets = new HashSet<Link>();
+ private final Set<Link> tracksRequirements = new HashSet<Link>();
+ private final Set<URI> rdfTypes = new TreeSet<URI>();
+
+ private URI accessControl;
+ private Boolean approved;
+ private Boolean closed;
+ private Date closeDate;
+ private Date created;
+ private String description;
+ private URI discussedBy;
+ private Boolean fixed;
+ private String filedAgainst;
+ private String identifier;
+ private Boolean inProgress;
+ private URI instanceShape;
+ private Date modified;
+ private Boolean reviewed;
+ private URI serviceProvider;
+ private Severity severity = Severity.Unclassified; // TODO - Added severity for demo
+ private String shortTitle;
+ private String status;
+ private String title;
+ private Boolean verified;
+
+ public ChangeRequest()
+ throws URISyntaxException
+ {
+ super();
+
+ rdfTypes.add(new URI(Constants.TYPE_CHANGE_REQUEST));
+ }
+
+ public ChangeRequest(final URI about)
+ throws URISyntaxException
+ {
+ super(about);
+
+ rdfTypes.add(new URI(Constants.TYPE_CHANGE_REQUEST));
+ }
+
+ public void addAffectedByDefect(final Link affectedByDefect)
+ {
+ this.affectedByDefects.add(affectedByDefect);
+ }
+
+ public void addAffectsPlanItem(final Link affectsPlanItem)
+ {
+ this.affectsPlanItems.add(affectsPlanItem);
+ }
+
+ public void addAffectsRequirement(final Link affectsRequirement)
+ {
+ this.affectsRequirements.add(affectsRequirement);
+ }
+
+ public void addAffectsTestResult(final Link affectsTestResult)
+ {
+ this.affectsTestResults.add(affectsTestResult);
+ }
+
+ public void addBlocksTestExecutionRecord(final Link blocksTestExecutionRecord)
+ {
+ this.blocksTestExecutionRecords.add(blocksTestExecutionRecord);
+ }
+
+ public void addContributor(final URI contributor)
+ {
+ this.contributors.add(contributor);
+ }
+
+ public void addCreator(final URI creator)
+ {
+ this.creators.add(creator);
+ }
+
+ public void addDctermsType(final String dctermsType)
+ {
+ this.dctermsTypes.add(Type.fromString(dctermsType));
+ }
+
+ public void addImplementsRequirement(final Link implementsRequirement)
+ {
+ this.implementsRequirements.add(implementsRequirement);
+ }
+
+ public void addRdfType(final URI rdfType)
+ {
+ this.rdfTypes.add(rdfType);
+ }
+
+ public void addRelatedChangeRequest(final Link relatedChangeRequest)
+ {
+ this.relatedChangeRequests.add(relatedChangeRequest);
+ }
+
+ public void addRelatedResource(final Link relatedResource)
+ {
+ this.relatedResources.add(relatedResource);
+ }
+
+ public void addRelatedTestCase(final Link relatedTestCase)
+ {
+ this.relatedTestCases.add(relatedTestCase);
+ }
+
+ public void addRelatedTestExecutionRecord(final Link relatedTestExecutionRecord)
+ {
+ this.relatedTestExecutionRecords.add(relatedTestExecutionRecord);
+ }
+
+ public void addRelatedTestPlan(final Link relatedTestPlan)
+ {
+ this.relatedTestPlans.add(relatedTestPlan);
+ }
+
+ public void addRelatedTestScript(final Link relatedTestScript)
+ {
+ this.relatedTestScripts.add(relatedTestScript);
+ }
+
+ public void addSubject(final String subject)
+ {
+ this.subjects.add(subject);
+ }
+
+ public void addTestedByTestCase(final Link testedByTestCase)
+ {
+ this.testedByTestCases.add(testedByTestCase);
+ }
+
+ public void addTracksChangeSet(final Link tracksChangeSet)
+ {
+ this.tracksChangeSets.add(tracksChangeSet);
+ }
+
+ public void addTracksRequirement(final Link tracksRequirement)
+ {
+ this.tracksRequirements.add(tracksRequirement);
+ }
+
+ @OslcDescription("Change request is affected by a reported defect.")
+ @OslcName("affectedByDefect")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "affectedByDefect")
+ @OslcRange(Constants.TYPE_CHANGE_REQUEST)
+ @OslcReadOnly(false)
+ @OslcTitle("Affected By Defects")
+ public Link[] getAffectedByDefects()
+ {
+ return affectedByDefects.toArray(new Link[affectedByDefects.size()]);
+ }
+
+ @OslcDescription("Change request affects a plan item. ")
+ @OslcName("affectsPlanItem")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "affectsPlanItem")
+ @OslcRange(Constants.TYPE_CHANGE_REQUEST)
+ @OslcReadOnly(false)
+ @OslcTitle("Affects Plan Items")
+ public Link[] getAffectsPlanItems()
+ {
+ return affectsPlanItems.toArray(new Link[affectsPlanItems.size()]);
+ }
+
+ @OslcDescription("Change request affecting a Requirement.")
+ @OslcName("affectsRequirement")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "affectsRequirement")
+ @OslcRange(Constants.TYPE_REQUIREMENT)
+ @OslcReadOnly(false)
+ @OslcTitle("Affects Requirements")
+ public Link[] getAffectsRequirements()
+ {
+ return affectsRequirements.toArray(new Link[affectsRequirements.size()]);
+ }
+
+ @OslcDescription("Associated QM resource that is affected by this Change Request.")
+ @OslcName("affectsTestResult")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "affectsTestResult")
+ @OslcRange(Constants.TYPE_TEST_RESULT)
+ @OslcReadOnly(false)
+ @OslcTitle("Affects Test Results")
+ public Link[] getAffectsTestResults()
+ {
+ return affectsTestResults.toArray(new Link[affectsTestResults.size()]);
+ }
+
+ @OslcDescription("Associated QM resource that is blocked by this Change Request.")
+ @OslcName("blocksTestExecutionRecord")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "blocksTestExecutionRecord")
+ @OslcRange(Constants.TYPE_TEST_EXECUTION_RECORD)
+ @OslcReadOnly(false)
+ @OslcTitle("Blocks Test Execution Records")
+ public Link[] getBlocksTestExecutionRecords()
+ {
+ return blocksTestExecutionRecords.toArray(new Link[blocksTestExecutionRecords.size()]);
+ }
+
+ @OslcDescription("The date at which no further activity or work is intended to be conducted. ")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "closeDate")
+ @OslcReadOnly
+ @OslcTitle("Close Date")
+ public Date getCloseDate()
+ {
+ return closeDate;
+ }
+
+ @OslcDescription("The person(s) who are responsible for the work needed to complete the change request.")
+ @OslcName("contributor")
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "contributor")
+ @OslcRange(Constants.TYPE_PERSON)
+ @OslcTitle("Contributors")
+ public URI[] getContributors()
+ {
+ return contributors.toArray(new URI[contributors.size()]);
+ }
+
+ @OslcDescription("Timestamp of resource creation.")
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "created")
+ @OslcReadOnly
+ @OslcTitle("Created")
+ public Date getCreated()
+ {
+ return created;
+ }
+
+ @OslcDescription("Creator or creators of resource.")
+ @OslcName("creator")
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "creator")
+ @OslcRange(Constants.TYPE_PERSON)
+ @OslcTitle("Creators")
+ public URI[] getCreators()
+ {
+ return creators.toArray(new URI[creators.size()]);
+ }
+
+ @OslcAllowedValue({"Defect", "Task", "Story", "Bug Report", "Feature Request"})
+ @OslcDescription("A short string representation for the type, example 'Defect'.")
+ @OslcName("type")
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "type")
+ @OslcTitle("Types")
+ public String[] getDctermsTypes()
+ {
+ final String[] result = new String[dctermsTypes.size()];
+
+ int index = 0;
+
+ for (final Type type : dctermsTypes)
+ {
+ result[index++] = type.toString();
+ }
+
+ return result;
+ }
+
+ @OslcDescription("Descriptive text (reference: Dublin Core) about resource represented as rich text in XHTML content.")
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "description")
+ @OslcTitle("Description")
+ @OslcValueType(ValueType.XMLLiteral)
+ public String getDescription()
+ {
+ return description;
+ }
+
+ @OslcDescription("A series of notes and comments about this change request.")
+ @OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "discussedBy")
+ @OslcRange(Constants.TYPE_DISCUSSION)
+ @OslcTitle("Discussed By")
+ public URI getDiscussedBy()
+ {
+ return discussedBy;
+ }
+
+ /**
+ * Here we are overriding the dcterms:accessRights field to capture which
+ * user can view which change requests. In our story this field corresponds
+ * to the "filedAgainst" field in the UI.
+ *
+ * @return
+ */
+ @OslcDescription("The type of user allowed to access this change request.")
+ @OslcName("accessRights")
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "accessRights")
+ @OslcTitle("Access Rights")
+ @OslcValueType(ValueType.XMLLiteral)
+ public String getFiledAgainst()
+ {
+ return filedAgainst;
+ }
+
+ @OslcDescription("A unique identifier for a resource. Assigned by the service provider when a resource is created. Not intended for end-user display.")
+ @OslcOccurs(Occurs.ExactlyOne)
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "identifier")
+ @OslcReadOnly
+ @OslcTitle("Identifier")
+ public String getIdentifier()
+ {
+ return identifier;
+ }
+
+ @OslcDescription("Implements associated Requirement.")
+ @OslcName("implementsRequirement")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "implementsRequirement")
+ @OslcRange(Constants.TYPE_REQUIREMENT)
+ @OslcReadOnly(false)
+ @OslcTitle("Implements Requirements")
+ public Link[] getImplementsRequirements()
+ {
+ return implementsRequirements.toArray(new Link[implementsRequirements.size()]);
+ }
+
+ @OslcDescription("Resource Shape that provides hints as to resource property value-types and allowed values. ")
+ @OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "instanceShape")
+ @OslcRange(OslcConstants.TYPE_RESOURCE_SHAPE)
+ @OslcTitle("Instance Shape")
+ public URI getInstanceShape()
+ {
+ return instanceShape;
+ }
+
+ @OslcDescription("Timestamp last latest resource modification.")
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "modified")
+ @OslcReadOnly
+ @OslcTitle("Modified")
+ public Date getModified()
+ {
+ return modified;
+ }
+
+ @OslcDescription("The resource type URIs.")
+ @OslcName("type")
+ @OslcPropertyDefinition(OslcConstants.RDF_NAMESPACE + "type")
+ @OslcTitle("Types")
+ public URI[] getRdfTypes()
+ {
+ return rdfTypes.toArray(new URI[rdfTypes.size()]);
+ }
+
+ @OslcDescription("This relationship is loosely coupled and has no specific meaning.")
+ @OslcName("relatedChangeRequest")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "relatedChangeRequest")
+ @OslcRange(Constants.TYPE_CHANGE_REQUEST)
+ @OslcReadOnly(false)
+ @OslcTitle("Related Change Requests")
+ public Link[] getRelatedChangeRequests()
+ {
+ return relatedChangeRequests.toArray(new Link[relatedChangeRequests.size()]);
+ }
+
+ @OslcDescription("Related OSLC resources of any type.")
+ @OslcName("relatedResource")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "relatedResource")
+ @OslcTitle("Related Resources")
+ public Link[] getRelatedResources()
+ {
+ return relatedResources.toArray(new Link[relatedResources.size()]);
+ }
+
+ @OslcDescription("Related QM test case resource.")
+ @OslcName("relatedTestCase")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "relatedTestCase")
+ @OslcRange(Constants.TYPE_TEST_CASE)
+ @OslcReadOnly(false)
+ @OslcTitle("Related Test Cases")
+ public Link[] getRelatedTestCases()
+ {
+ return relatedTestCases.toArray(new Link[relatedTestCases.size()]);
+ }
+
+ @OslcDescription("Related to a QM test execution resource.")
+ @OslcName("relatedTestExecutionRecord")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "relatedTestExecutionRecord")
+ @OslcRange(Constants.TYPE_TEST_EXECUTION_RECORD)
+ @OslcReadOnly(false)
+ @OslcTitle("Related Test Execution Records")
+ public Link[] getRelatedTestExecutionRecords()
+ {
+ return relatedTestExecutionRecords.toArray(new Link[relatedTestExecutionRecords.size()]);
+ }
+
+ @OslcDescription("Related QM test plan resource.")
+ @OslcName("relatedTestPlan")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "relatedTestPlan")
+ @OslcRange(Constants.TYPE_TEST_PLAN)
+ @OslcReadOnly(false)
+ @OslcTitle("Related Test Plans")
+ public Link[] getRelatedTestPlans()
+ {
+ return relatedTestPlans.toArray(new Link[relatedTestPlans.size()]);
+ }
+
+ @OslcDescription("Related QM test script resource.")
+ @OslcName("relatedTestScript")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "relatedTestScript")
+ @OslcRange(Constants.TYPE_TEST_SCRIPT)
+ @OslcReadOnly(false)
+ @OslcTitle("Related Test Scripts")
+ public Link[] getRelatedTestScripts()
+ {
+ return relatedTestScripts.toArray(new Link[relatedTestScripts.size()]);
+ }
+
+ @OslcDescription("The scope of a resource is a URI for the resource's OSLC Service Provider.")
+ @OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "serviceProvider")
+ @OslcRange(OslcConstants.TYPE_SERVICE_PROVIDER)
+ @OslcTitle("Service Provider")
+ public URI getServiceProvider()
+ {
+ return serviceProvider;
+ }
+
+ @OslcAllowedValue({"Unclassified", "Minor", "Normal", "Major", "Critical", "Blocker"})
+ @OslcDescription("Severity of change request.")
+ @OslcOccurs(Occurs.ExactlyOne)
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "severity")
+ @OslcTitle("Severity")
+ public String getSeverity()
+ {
+ return severity.toString();
+ }
+
+ @OslcDescription("Short name identifying a resource, often used as an abbreviated identifier for presentation to end-users.")
+ @OslcPropertyDefinition(OslcConstants.OSLC_CORE_NAMESPACE + "shortTitle")
+ @OslcTitle("Short Title")
+ @OslcValueType(ValueType.XMLLiteral)
+ public String getShortTitle()
+ {
+ return shortTitle;
+ }
+
+ @OslcDescription("Used to indicate the status of the change request based on values defined by the service provider. Most often a read-only property. Some possible values may include: 'Submitted', 'Done', 'InProgress', etc.")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "status")
+ @OslcTitle("Status")
+ public String getStatus()
+ {
+ return status;
+ }
+
+ @OslcDescription("Tag or keyword for a resource. Each occurrence of a dcterms:subject property denotes an additional tag for the resource.")
+ @OslcName("subject")
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "subject")
+ @OslcReadOnly(false)
+ @OslcTitle("Subjects")
+ public String[] getSubjects()
+ {
+ return subjects.toArray(new String[subjects.size()]);
+ }
+
+ @OslcDescription("Test case by which this change request is tested.")
+ @OslcName("testedByTestCase")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "testedByTestCase")
+ @OslcRange(Constants.TYPE_TEST_CASE)
+ @OslcReadOnly(false)
+ @OslcTitle("Tested by Test Cases")
+ public Link[] getTestedByTestCases()
+ {
+ return testedByTestCases.toArray(new Link[testedByTestCases.size()]);
+ }
+
+ @OslcDescription("Title (reference: Dublin Core) or often a single line summary of the resource represented as rich text in XHTML content.")
+ @OslcOccurs(Occurs.ExactlyOne)
+ @OslcPropertyDefinition(OslcConstants.DCTERMS_NAMESPACE + "title")
+ @OslcTitle("Title")
+ @OslcValueType(ValueType.XMLLiteral)
+ public String getTitle()
+ {
+ return title;
+ }
+
+ @OslcDescription("Tracks SCM change set resource.")
+ @OslcName("tracksChangeSet")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "tracksChangeSet")
+ @OslcRange(Constants.TYPE_CHANGE_SET)
+ @OslcReadOnly(false)
+ @OslcTitle("Tracks Change Sets")
+ public Link[] getTracksChangeSets()
+ {
+ return tracksChangeSets.toArray(new Link[tracksChangeSets.size()]);
+ }
+
+ @OslcDescription("Tracks the associated Requirement or Requirement ChangeSet resources.")
+ @OslcName("tracksRequirement")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "tracksRequirement")
+ @OslcRange(Constants.TYPE_REQUIREMENT)
+ @OslcReadOnly(false)
+ @OslcTitle("Tracks Requirements")
+ public Link[] getTracksRequirements()
+ {
+ return tracksRequirements.toArray(new Link[tracksRequirements.size()]);
+ }
+
+ @OslcDescription("Whether or not the Change Request has been approved.")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "approved")
+ @OslcReadOnly
+ @OslcTitle("Approved")
+ public Boolean isApproved()
+ {
+ return approved;
+ }
+
+ @OslcDescription("Whether or not the Change Request is completely done, no further fixes or fix verification is needed.")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "closed")
+ @OslcReadOnly
+ @OslcTitle("Closed")
+ public Boolean isClosed()
+ {
+ return closed;
+ }
+
+ @OslcDescription("Whether or not the Change Request has been fixed.")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "fixed")
+ @OslcReadOnly
+ @OslcTitle("Fixed")
+ public Boolean isFixed()
+ {
+ return fixed;
+ }
+
+ @OslcDescription("Whether or not the Change Request in a state indicating that active work is occurring. If oslc_cm:inprogress is true, then oslc_cm:fixed and oslc_cm:closed must also be false.")
+ @OslcName("inprogress")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "inprogress")
+ @OslcReadOnly
+ @OslcTitle("In Progress")
+ public Boolean isInProgress()
+ {
+ return inProgress;
+ }
+
+ @OslcDescription("Whether or not the Change Request has been reviewed.")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "reviewed")
+ @OslcReadOnly
+ @OslcTitle("Reviewed")
+ public Boolean isReviewed()
+ {
+ return reviewed;
+ }
+
+ @OslcDescription("Whether or not the resolution or fix of the Change Request has been verified.")
+ @OslcPropertyDefinition(Constants.CHANGE_MANAGEMENT_NAMESPACE + "verified")
+ @OslcReadOnly
+ @OslcTitle("Verified")
+ public Boolean isVerified()
+ {
+ return verified;
+ }
+
+ public void setAccessControl(URI accessControl)
+ {
+ this.accessControl = accessControl;
+ }
+
+ public void setAffectedByDefects(final Link[] affectedByDefects)
+ {
+ this.affectedByDefects.clear();
+
+ if (affectedByDefects != null)
+ {
+ this.affectedByDefects.addAll(Arrays.asList(affectedByDefects));
+ }
+ }
+
+ public void setAffectsPlanItems(final Link[] affectsPlanItems)
+ {
+ this.affectsPlanItems.clear();
+
+ if (affectsPlanItems != null)
+ {
+ this.affectsPlanItems.addAll(Arrays.asList(affectsPlanItems));
+ }
+ }
+
+ public void setAffectsRequirements(final Link[] affectsRequirements)
+ {
+ this.affectsRequirements.clear();
+
+ if (affectsRequirements != null)
+ {
+ this.affectsRequirements.addAll(Arrays.asList(affectsRequirements));
+ }
+ }
+
+ public void setAffectsTestResults(final Link[] affectsTestResults)
+ {
+ this.affectsTestResults.clear();
+
+ if (affectsTestResults != null)
+ {
+ this.affectsTestResults.addAll(Arrays.asList(affectsTestResults));
+ }
+ }
+
+ public void setApproved(final Boolean approved)
+ {
+ this.approved = approved;
+ }
+
+ public void setBlocksTestExecutionRecords(final Link[] blocksTestExecutionRecords)
+ {
+ this.blocksTestExecutionRecords.clear();
+
+ if (blocksTestExecutionRecords != null)
+ {
+ this.blocksTestExecutionRecords.addAll(Arrays.asList(blocksTestExecutionRecords));
+ }
+ }
+
+ public void setClosed(final Boolean closed)
+ {
+ this.closed = closed;
+ }
+
+ public void setCloseDate(final Date closeDate)
+ {
+ this.closeDate = closeDate;
+ }
+
+ public void setContributors(final URI[] contributors)
+ {
+ this.contributors.clear();
+
+ if (contributors != null)
+ {
+ this.contributors.addAll(Arrays.asList(contributors));
+ }
+ }
+
+ public void setCreated(final Date created)
+ {
+ this.created = created;
+ }
+
+ public void setCreators(final URI[] creators)
+ {
+ this.creators.clear();
+
+ if (creators != null)
+ {
+ this.creators.addAll(Arrays.asList(creators));
+ }
+ }
+
+ public void setDctermsTypes(final String[] dctermsTypes)
+ {
+ this.dctermsTypes.clear();
+
+ if (dctermsTypes != null)
+ {
+ for (final String type : dctermsTypes)
+ {
+ this.dctermsTypes.add(Type.fromString(type));
+ }
+ }
+ }
+
+ public void setDescription(final String description)
+ {
+ this.description = description;
+ }
+
+ public void setDiscussedBy(final URI discussedBy)
+ {
+ this.discussedBy = discussedBy;
+ }
+
+ public void setFiledAgainst(final String filedAgainst)
+ {
+ this.filedAgainst = filedAgainst;
+ }
+
+ public void setFixed(final Boolean fixed)
+ {
+ this.fixed = fixed;
+ }
+
+ public void setIdentifier(final String identifier)
+ {
+ this.identifier = identifier;
+ }
+
+ public void setImplementsRequirements(final Link[] implementsRequirements)
+ {
+ this.implementsRequirements.clear();
+
+ if (implementsRequirements != null)
+ {
+ this.implementsRequirements.addAll(Arrays.asList(implementsRequirements));
+ }
+ }
+
+ public void setInProgress(final Boolean inProgress)
+ {
+ this.inProgress = inProgress;
+ }
+
+ public void setInstanceShape(final URI instanceShape)
+ {
+ this.instanceShape = instanceShape;
+ }
+
+ public void setModified(final Date modified)
+ {
+ this.modified = modified;
+ }
+
+ public void setRdfTypes(final URI[] rdfTypes)
+ {
+ this.rdfTypes.clear();
+
+ if (rdfTypes != null)
+ {
+ this.rdfTypes.addAll(Arrays.asList(rdfTypes));
+ }
+ }
+
+ public void setRelatedChangeRequests(final Link[] relatedChangeRequests)
+ {
+ this.relatedChangeRequests.clear();
+
+ if (relatedChangeRequests != null)
+ {
+ this.relatedChangeRequests.addAll(Arrays.asList(relatedChangeRequests));
+ }
+ }
+
+ public void setRelatedResources(final Link[] relatedResources)
+ {
+ this.relatedResources.clear();
+
+ if (relatedResources != null)
+ {
+ this.relatedResources.addAll(Arrays.asList(relatedResources));
+ }
+ }
+
+ public void setRelatedTestCases(final Link[] relatedTestCases)
+ {
+ this.relatedTestCases.clear();
+
+ if (relatedTestCases != null)
+ {
+ this.relatedTestCases.addAll(Arrays.asList(relatedTestCases));
+ }
+ }
+
+ public void setRelatedTestExecutionRecords(final Link[] relatedTestExecutionRecords)
+ {
+ this.relatedTestExecutionRecords.clear();
+
+ if (relatedTestExecutionRecords != null)
+ {
+ this.relatedTestExecutionRecords.addAll(Arrays.asList(relatedTestExecutionRecords));
+ }
+ }
+
+ public void setRelatedTestPlans(final Link[] relatedTestPlans)
+ {
+ this.relatedTestPlans.clear();
+
+ if (relatedTestPlans != null)
+ {
+ this.relatedTestPlans.addAll(Arrays.asList(relatedTestPlans));
+ }
+ }
+
+ public void setRelatedTestScripts(final Link[] relatedTestScripts)
+ {
+ this.relatedTestScripts.clear();
+
+ if (relatedTestScripts != null)
+ {
+ this.relatedTestScripts.addAll(Arrays.asList(relatedTestScripts));
+ }
+ }
+
+ public void setReviewed(final Boolean reviewed)
+ {
+ this.reviewed = reviewed;
+ }
+
+ public void setServiceProvider(final URI serviceProvider)
+ {
+ this.serviceProvider = serviceProvider;
+ }
+
+ public void setSeverity(final String severity)
+ {
+ this.severity = Severity.valueOf(severity);
+ }
+
+ public void setShortTitle(final String shortTitle)
+ {
+ this.shortTitle = shortTitle;
+ }
+
+ public void setStatus(final String status)
+ {
+ this.status = status;
+ }
+
+ public void setSubjects(final String[] subjects)
+ {
+ this.subjects.clear();
+
+ if (subjects != null)
+ {
+ this.subjects.addAll(Arrays.asList(subjects));
+ }
+ }
+
+ public void setTestedByTestCases(final Link[] testedByTestCases)
+ {
+ this.testedByTestCases.clear();
+
+ if (testedByTestCases != null)
+ {
+ this.testedByTestCases.addAll(Arrays.asList(testedByTestCases));
+ }
+ }
+
+ public void setTitle(final String title)
+ {
+ this.title = title;
+ }
+
+ public void setTracksChangeSets(final Link[] tracksChangeSets)
+ {
+ this.tracksChangeSets.clear();
+
+ if (tracksChangeSets != null)
+ {
+ this.tracksChangeSets.addAll(Arrays.asList(tracksChangeSets));
+ }
+ }
+
+ public void setTracksRequirements(final Link[] tracksRequirements)
+ {
+ this.tracksRequirements.clear();
+
+ if (tracksRequirements != null)
+ {
+ this.tracksRequirements.addAll(Arrays.asList(tracksRequirements));
+ }
+ }
+
+ public void setVerified(final Boolean verified)
+ {
+ this.verified = verified;
+ }
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Constants.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Constants.java
new file mode 100644
index 0000000..f792a71
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Constants.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.cm;
+
+import org.eclipse.lyo.oslc4j.core.model.OslcConstants;
+
+public interface Constants
+{
+ public static String CHANGE_MANAGEMENT_DOMAIN = "http://open-services.net/ns/cm#";
+ public static String CHANGE_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/cm#";
+ public static String CHANGE_MANAGEMENT_NAMESPACE_PREFIX = "oslc_cm";
+ public static String FOAF_NAMESPACE = "http://xmlns.com/foaf/0.1/";
+ public static String FOAF_NAMESPACE_PREFIX = "foaf";
+ public static String QUALITY_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/qm#";
+ public static String QUALITY_MANAGEMENT_PREFIX = "oslc_qm";
+ public static String REQUIREMENTS_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/rm#";
+ public static String REQUIREMENTS_MANAGEMENT_PREFIX = "oslc_rm";
+ public static String SOFTWARE_CONFIGURATION_MANAGEMENT_NAMESPACE = "http://open-services.net/ns/scm#";
+ public static String SOFTWARE_CONFIGURATION_MANAGEMENT_PREFIX = "oslc_scm";
+
+
+ public static String TYPE_CHANGE_REQUEST = CHANGE_MANAGEMENT_NAMESPACE + "ChangeRequest";
+ public static String TYPE_CHANGE_SET = SOFTWARE_CONFIGURATION_MANAGEMENT_NAMESPACE + "ChangeSet";
+ public static String TYPE_DISCUSSION = OslcConstants.OSLC_CORE_NAMESPACE + "Discussion";
+ public static String TYPE_PERSON = FOAF_NAMESPACE + "Person";
+ public static String TYPE_REQUIREMENT = REQUIREMENTS_MANAGEMENT_NAMESPACE + "Requirement";
+ public static String TYPE_TEST_CASE = QUALITY_MANAGEMENT_NAMESPACE + "TestCase";
+ public static String TYPE_TEST_EXECUTION_RECORD = QUALITY_MANAGEMENT_NAMESPACE + "TestExecutionRecord";
+ public static String TYPE_TEST_PLAN = QUALITY_MANAGEMENT_NAMESPACE + "TestPlan";
+ public static String TYPE_TEST_RESULT = QUALITY_MANAGEMENT_NAMESPACE + "TestResult";
+ public static String TYPE_TEST_SCRIPT = QUALITY_MANAGEMENT_NAMESPACE + "TestScript";
+
+ public static String PATH_CHANGE_REQUEST = "changeRequest";
+
+ public static String USAGE_LIST = CHANGE_MANAGEMENT_NAMESPACE + "list";
+
+ public static String PATH_FLAT_FILE = "C:/temp/changeRequests.xml";
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Severity.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Severity.java
new file mode 100644
index 0000000..2a6b270
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Severity.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.cm;
+
+public enum Severity
+{
+ Unclassified,
+ Minor,
+ Normal,
+ Major,
+ Critical,
+ Blocker
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Type.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Type.java
new file mode 100644
index 0000000..e676d44
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/Type.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.cm;
+
+public enum Type
+{
+ Defect("Defect"),
+ Task("Task"),
+ Story("Story"),
+ Bug_Report("Bug Report"),
+ Feature_Request("Feature Request");
+
+ private String value;
+
+ Type(final String value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+
+ public static Type fromString(final String string)
+ {
+ final Type[] values = Type.values();
+ for (final Type value : values)
+ {
+ if (value.value.equals(string))
+ {
+ return value;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/package-info.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/package-info.java
new file mode 100644
index 0000000..17c30e0
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/cm/package-info.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+@OslcSchema ({
+ @OslcNamespaceDefinition(prefix = Constants.CHANGE_MANAGEMENT_NAMESPACE_PREFIX, namespaceURI = Constants.CHANGE_MANAGEMENT_NAMESPACE),
+ @OslcNamespaceDefinition(prefix = Constants.FOAF_NAMESPACE_PREFIX, namespaceURI = Constants.FOAF_NAMESPACE),
+ @OslcNamespaceDefinition(prefix = Constants.QUALITY_MANAGEMENT_PREFIX, namespaceURI = Constants.QUALITY_MANAGEMENT_NAMESPACE),
+ @OslcNamespaceDefinition(prefix = Constants.REQUIREMENTS_MANAGEMENT_PREFIX, namespaceURI = Constants.REQUIREMENTS_MANAGEMENT_NAMESPACE),
+ @OslcNamespaceDefinition(prefix = Constants.SOFTWARE_CONFIGURATION_MANAGEMENT_PREFIX, namespaceURI = Constants.SOFTWARE_CONFIGURATION_MANAGEMENT_NAMESPACE)
+ })
+
+package org.eclipse.lyo.rio.trs.cm;
+
+import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespaceDefinition;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcSchema;
+
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/BaseResource.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/BaseResource.java
new file mode 100644
index 0000000..e3f1e81
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/BaseResource.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.resources;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.wink.common.annotations.Workspace;
+import org.eclipse.lyo.core.trs.Base;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcService;
+import org.eclipse.lyo.rio.trs.util.TRSUtil;
+import org.eclipse.lyo.core.trs.TRSConstants;
+
+/**
+ * RESTful service endpoints for returning the Base of a Tracked Resource Set in pages.
+ *
+ * The Base of a Tracked Resource Set is an RDF container where each member references
+ * a Resource that was in the Resource Set at the time the Base was computed. HTTP GET on
+ * a Base URI returns an RDF container with the following structure:
+ *
+ # Resource: http://cm1.example.com/baseResources
+ @prefix trs: <http://jazz.net/ns/trs#> .
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+ <http://cm1.example.com/baseResources>
+ trs:cutoffEvent
+ <urn:urn-3:cm1.example.com:2010-10-27T17:39:31.000Z:101> ;
+ rdfs:member <http://cm1.example.com/bugs/1> ;
+ rdfs:member <http://cm1.example.com/bugs/2> ;
+ rdfs:member <http://cm1.example.com/bugs/3> ;
+ ...
+ rdfs:member <http://cm1.example.com/bugs/199> ;
+ rdfs:member <http://cm1.example.com/bugs/200> .
+
+ *
+ */
+@Path("/trs/"+TRSConstants.TRS_TERM_BASE)
+@OslcService(TRSConstants.TRS_BASE)
+@Workspace(workspaceTitle = "Tracked Resource Set", collectionTitle = "Base")
+public class BaseResource {
+ @Context
+ protected UriInfo uriInfo;
+
+
+ /**
+ * getBase() on the root URI performs a redirect to page 1 in this implementation to represent
+ * paged Base resources of the Tracked Resource Set
+ */
+ @GET
+ @Produces({ "application/rdf+xml", MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public List<Base> getBase() throws URISyntaxException{
+
+ URI requestURI = uriInfo.getRequestUri();
+ boolean endsWithSlash = requestURI.getPath().endsWith("/");
+
+ throw new WebApplicationException(Response.temporaryRedirect(requestURI.resolve((endsWithSlash ? "" : "base/") + "1")).build());
+ }
+
+ /**
+ * getBasePage() is called with a page parameter and returns the page of Base resources at the
+ * specified page.
+ */
+ @GET
+ @Path("{page}")
+ @Produces({ "application/rdf+xml", MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public List<Base> getBasePage(@PathParam("page")Long page) throws URISyntaxException{
+ TRSUtil.updateTRSResourceURI(uriInfo.getBaseUri());
+
+ // from uri find out which Inner container to access...
+ URI requestURI = uriInfo.getRequestUri();
+
+ if (TRSUtil.getTrsBase(requestURI).isEmpty() || !TRSUtil.getTrsBase(requestURI).containsKey(page))
+ throw new WebApplicationException(Status.NOT_FOUND);
+
+ List<Base> results = new ArrayList<Base>();
+ results.add(TRSUtil.getTrsBase(requestURI).get(page));
+ return results;
+ }
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/ChangeRequestResource.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/ChangeRequestResource.java
new file mode 100644
index 0000000..58234f9
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/ChangeRequestResource.java
@@ -0,0 +1,424 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.resources;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Date;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.wink.common.annotations.Workspace;
+import org.eclipse.lyo.core.trs.TRSConstants;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcCreationFactory;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcDialog;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcDialogs;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcQueryCapability;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcService;
+import org.eclipse.lyo.oslc4j.core.model.OslcConstants;
+import org.eclipse.lyo.oslc4j.core.model.OslcMediaType;
+import org.eclipse.lyo.oslc4j.core.model.ResponseInfoArray;
+import org.eclipse.lyo.rio.trs.cm.ChangeRequest;
+import org.eclipse.lyo.rio.trs.cm.Constants;
+import org.eclipse.lyo.rio.trs.util.Persistence;
+import org.eclipse.lyo.rio.trs.util.TRSUtil;
+
+@OslcService(Constants.CHANGE_MANAGEMENT_DOMAIN)
+@Path("changeRequests")
+@Workspace(workspaceTitle = "Change Management", collectionTitle = "Change Request")
+public class ChangeRequestResource
+{
+ @Context ServletContext servletContext;
+
+ // Handle the HTML request from browser.
+ @POST
+ @Path("creator")
+ @Consumes({ MediaType.APPLICATION_FORM_URLENCODED})
+ public void createHtmlChangeRequest( @FormParam ("title") String title,
+ @FormParam ("description") String description,
+ @FormParam ("filedAgainst") String filedAgainst)
+ {
+
+ try {
+ URI baseURI = uriInfo.getBaseUri();
+
+ // Initialize the base before adding / deleting any resource.
+ TRSUtil.initialize(baseURI);
+
+ ChangeRequest cr = Persistence.createChangeRequest(description,
+ title, filedAgainst);
+
+ ChangeRequest changeRequest = Persistence.persistChangeRequest(baseURI, cr);
+
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ // Send back to the form a small JSON response.
+ httpServletResponse.setContentType("application/json");
+ httpServletResponse.setStatus(Status.CREATED.getStatusCode());
+ httpServletResponse.addHeader("Location", changeRequest.getAbout().toString());
+
+ PrintWriter out = httpServletResponse.getWriter();
+ out.print("{\"title\": \"" + title + "\"," +
+ "\"ID\" : \"" + changeRequest.getIdentifier() + "\"}");
+ out.close();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new WebApplicationException(e);
+ }
+
+ }
+
+ @PUT
+ @Consumes({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.APPLICATION_JSON})
+ @Path("{changeRequestId}")
+ public void updateChangeRequest(@HeaderParam("If-Match") final String eTagHeader,
+ @PathParam("changeRequestId") final String changeRequestId,
+ final ChangeRequest changeRequest)
+ {
+ final ChangeRequest originalChangeRequest = Persistence.getChangeRequest(changeRequestId);
+
+ if (originalChangeRequest != null)
+ {
+ final String originalETag = getETagFromChangeRequest(originalChangeRequest);
+
+ //no eTag or eTag unchanged
+ if ((eTagHeader == null) ||
+ (originalETag.equals(eTagHeader)))
+ {
+ changeRequest.setModified(new Date());
+ changeRequest.setServiceProvider(ServiceProviderSingleton.getServiceProviderURI());
+ Persistence.updateChangeRequest(changeRequestId, changeRequest);
+
+ // TRS - Insert the modification event to the change log
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_MODIFICATION, changeRequest.getAbout());
+
+ String eTag = getETagFromChangeRequest(changeRequest);
+ httpServletResponse.setContentType("application/json");
+ httpServletResponse.setStatus(Status.OK.getStatusCode());
+ httpServletResponse.addHeader("ETag", eTag);
+
+ PrintWriter out;
+ try {
+ out = httpServletResponse.getWriter();
+
+ out.print("{\"title\": \"" + changeRequest.getTitle() + "\"," +
+ "\"ID\" : \"" + changeRequest.getIdentifier() + "\"}");
+ out.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ throw new WebApplicationException(Status.PRECONDITION_FAILED);
+ }
+ }
+ else
+ {
+ throw new WebApplicationException(Status.NOT_FOUND);
+ }
+ }
+
+
+ @Context protected UriInfo uriInfo;
+ @Context private HttpServletRequest httpServletRequest;
+ @Context private HttpServletResponse httpServletResponse;
+
+ public ChangeRequestResource()
+ {
+ super();
+ }
+
+ @OslcDialogs(
+ {
+ @OslcDialog
+ (
+ title = "Change Request Selection Dialog",
+ label = "Change Request Selection Dialog",
+ uri = "/changeRequests/creator",
+ hintWidth = "1000px",
+ hintHeight = "600px",
+ resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
+ usages = {OslcConstants.OSLC_USAGE_DEFAULT}
+ ),
+ @OslcDialog
+ (
+ title = "Change Request List Dialog",
+ label = "Change Request List Dialog",
+ uri = "UI/changeRequests/list.jsp",
+ hintWidth = "1000px",
+ hintHeight = "600px",
+ resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
+ usages = {Constants.USAGE_LIST}
+ )
+ })
+ @OslcQueryCapability
+ (
+ title = "Change Request Query Capability",
+ label = "Change Request Catalog Query",
+ resourceShape = OslcConstants.PATH_RESOURCE_SHAPES + "/" + Constants.PATH_CHANGE_REQUEST,
+ resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
+ usages = {OslcConstants.OSLC_USAGE_DEFAULT}
+ )
+ @GET
+ @Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.APPLICATION_JSON})
+ public ResponseInfoArray<ChangeRequest> getChangeRequests(@QueryParam("oslc.where") final String where, @QueryParam("pageNo")final int pageNo, @Context HttpServletRequest request)
+ {
+
+ int totalResults = Persistence.getTotalChangeRequests();
+ final ChangeRequest[] changeRequests = Persistence.getChangeRequests(pageNo);
+ URI nextPage = null;
+
+ if(totalResults > pageNo*Persistence.PAGE_SIZE+Persistence.PAGE_SIZE ){
+ URI requestURI = uriInfo.getRequestUri();
+ nextPage = UriBuilder.fromUri(requestURI).replaceQueryParam("pageNo", pageNo+1).build(new Object[0]);
+ }
+
+ return new ResponseInfoArray<ChangeRequest>(changeRequests,
+ null,
+ totalResults,
+ nextPage);
+ }
+
+ @GET
+ @Produces({ MediaType.TEXT_HTML })
+ public void getHtmlCollection(@QueryParam("pageNo")final int pageNo) throws ServletException, IOException
+ {
+ try
+ {
+ int totalResults = Persistence.getTotalChangeRequests();
+ final ChangeRequest[] changeRequests = Persistence.getChangeRequests(pageNo);
+ URI nextPage = null;
+
+ if(totalResults > pageNo*Persistence.PAGE_SIZE+Persistence.PAGE_SIZE){
+ URI requestURI = uriInfo.getRequestUri();
+ nextPage = UriBuilder.fromUri(requestURI).replaceQueryParam("pageNo", pageNo+1).build(new Object[0]);
+ httpServletRequest.setAttribute("nextPageUri", nextPage.toString());
+ httpServletRequest.setAttribute("currentPageUri", requestURI.toString());
+ }
+
+ ResponseInfoArray<ChangeRequest> results = new ResponseInfoArray<ChangeRequest>(changeRequests,
+ null,
+ totalResults,
+ nextPage);
+ httpServletRequest.setAttribute("results", results);
+
+
+ RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/changerequest_collection_html.jsp");
+ rd.forward(httpServletRequest, httpServletResponse);
+ }catch (Exception e) {
+ throw new WebApplicationException(Status.NOT_FOUND);
+ }
+ }
+
+ @GET
+ @Path("{changeRequestId}")
+ @Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.APPLICATION_JSON})
+ public Response getChangeRequest(@PathParam("changeRequestId") final String changeRequestId)
+ {
+ final ChangeRequest changeRequest = Persistence.getChangeRequest(changeRequestId);
+
+ if (changeRequest != null)
+ {
+ changeRequest.setServiceProvider(ServiceProviderSingleton.getServiceProviderURI());
+
+ String eTag = getETagFromChangeRequest(changeRequest);
+ Response response = Response.ok(changeRequest).header("ETag", eTag).build();
+
+ return response;
+ }
+
+ throw new WebApplicationException(Status.NOT_FOUND);
+ }
+
+ // to allow modifications of a CR Prop through HTML.
+ @GET
+ @Path("{changeRequestId}")
+ @Produces({ MediaType.TEXT_HTML })
+ public void getChangeRequest_html(@PathParam("changeRequestId") final int changeRequestId)
+ {
+ try {
+ httpServletRequest.setAttribute("modifyUri", uriInfo.getAbsolutePath().toString());
+ httpServletRequest.setAttribute("changeRequestId", changeRequestId );
+ RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/ChangeReq_modify.jsp");
+ rd.forward(httpServletRequest, httpServletResponse);
+ }
+ catch (Exception e) {
+ throw new WebApplicationException(e);
+ }
+ }
+
+ @OslcCreationFactory
+ (
+ title = "Change Request Creation Factory",
+ label = "Change Request Creation",
+ resourceShapes = {OslcConstants.PATH_RESOURCE_SHAPES + "/" + Constants.PATH_CHANGE_REQUEST},
+ resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
+ usages = {OslcConstants.OSLC_USAGE_DEFAULT}
+ )
+ @POST
+ @Consumes({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.APPLICATION_JSON})
+ @Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.APPLICATION_JSON})
+ public Response addChangeRequest(ChangeRequest changeRequest)
+ throws URISyntaxException
+ {
+ URI basePath = uriInfo.getBaseUri();
+
+
+ changeRequest.setServiceProvider(ServiceProviderSingleton.getServiceProviderURI());
+
+ final Date date = new Date();
+
+ changeRequest.setCreated(date);
+ changeRequest.setModified(date);
+
+ changeRequest = Persistence.persistChangeRequest(basePath, changeRequest);
+ String eTag = getETagFromChangeRequest(changeRequest);
+
+ return Response.created(changeRequest.getAbout()).entity(changeRequest).header("ETag", eTag).build();
+ }
+
+ @DELETE
+ @Path("{changeRequestId}")
+ public Response deleteChangeRequest(@PathParam("changeRequestId") final String changeRequestId)
+ {
+ URI baseURI = uriInfo.getBaseUri();
+ // Initialize the base before adding / deleting any resource.
+ TRSUtil.initialize(baseURI);
+
+ final ChangeRequest changeRequest = Persistence.deleteChangeRequest(changeRequestId);
+
+ if (changeRequest != null)
+ {
+ // TRS - Insert the deletion event to the change log
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_DELETION, changeRequest.getAbout());
+
+ return Response.ok().build();
+
+ }
+
+ throw new WebApplicationException(Status.NOT_FOUND);
+ }
+
+ private static String getETagFromChangeRequest(final ChangeRequest changeRequest)
+ {
+ return Long.toString(changeRequest.getModified().getTime());
+ }
+
+ @GET
+ @Path("/populate")
+ @Produces(MediaType.TEXT_PLAIN)
+ public String populate()
+ throws URISyntaxException
+ {
+ URI baseURI = uriInfo.getBaseUri();
+
+ // Initialize the base before adding / deleting any resource.
+ TRSUtil.initialize(baseURI);
+
+ ChangeRequest changeRequest = null;
+ changeRequest = Persistence.persistChangeRequest(baseURI, Persistence.createChangeRequest("Unable to execute Apache Tomcat due to missing Java runtime environment (JRE).",
+ "Apache Tomcat requires JRE", "Server"));
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ changeRequest = Persistence.persistChangeRequest(baseURI, Persistence.createChangeRequest("Operating system password required to be alphanumeric with at least eight characters.",
+ "Password complexity rules", "Server"));
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ changeRequest = Persistence.persistChangeRequest(baseURI, Persistence.createChangeRequest("Misspelling in error message in XYZZY product.",
+ "Error message mispelling", "Client"));
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ changeRequest = Persistence.persistChangeRequest(baseURI, Persistence.createChangeRequest("Unable to execute Apache Tomcat due to missing Java runtime environment (JRE).",
+ "Integer et elementum est. Maecenas bibendum fermentum pharetra.", "Server"));
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ changeRequest = Persistence.persistChangeRequest(baseURI, Persistence.createChangeRequest("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sed pharetra lectus..",
+ "Password complexity rules", "Client"));
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ changeRequest = Persistence.persistChangeRequest(baseURI, Persistence.createChangeRequest("Vestibulum volutpat, est vehicula tincidunt tincidunt, tortor ipsum consequat ante, sit amet ultricies elit dui ac massa. Nulla facilisi..",
+ "Fusce dapibus imperdiet porta.", "Server"));
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ changeRequest = Persistence.persistChangeRequest(baseURI, Persistence.createChangeRequest("Nunc aliquet scelerisque leo, eu molestie enim fermentum nec. Nulla lectus dui, dictum non sodales quis, dictum sed ante. Proin quam nulla, euismod ac facilisis eu, rhoncus vel quam. Donec ac ligula ante. Nulla egestas quam sit amet neque placerat quis iaculis risus tincidunt. Mauris a sapien nulla.",
+ "Suspendisse lobortis nisi nisl, et imperdiet nisl.", "Client"));
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ changeRequest = Persistence.persistChangeRequest(baseURI, Persistence.createChangeRequest("Ut felis risus, blandit eu tristique sed, vulputate non ligula. Donec interdum mi sed odio bibendum eget placerat mi tempus. Pellentesque id erat mauris.",
+ "Duis placerat scelerisque purus sed tincidunt.", "Server"));
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ changeRequest = Persistence.persistChangeRequest(baseURI, Persistence.createChangeRequest("Etiam lacinia cursus risus at iaculis. Nunc metus nisi, lobortis vitae consequat nec, hendrerit nec augue.",
+ "Donec sit amet felis purus.", "Client"));
+ TRSUtil.insertEventTypeToChangeLog(TRSConstants.TRS_TYPE_CREATION, changeRequest.getAbout());
+
+ return "Success!";
+ }
+
+ /**
+ * OSLC delegated creation dialog for a single change request
+ *
+ * Forwards to changerequest_creator.jsp to build the html form
+ *
+ * productId param not req it's specific to bugzilla
+ * @throws IOException
+ * @throws ServletException
+ */
+
+ @GET
+ @Path("creator")
+ @Consumes({MediaType.WILDCARD})
+ public void changeRequestCreator() throws IOException, ServletException
+ {
+ try {
+ httpServletRequest.setAttribute("creatorUri", uriInfo.getAbsolutePath().toString());
+ RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/ChangeReq_creator.jsp");
+ rd.forward(httpServletRequest, httpServletResponse);
+
+ } catch (Exception e) {
+ throw new WebApplicationException(e);
+ }
+
+ }
+
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/ServiceProviderSingleton.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/ServiceProviderSingleton.java
new file mode 100644
index 0000000..7c4cef6
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/ServiceProviderSingleton.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.resources;
+
+import java.net.URI;
+
+public class ServiceProviderSingleton
+{
+ private static URI serviceProviderURISingleton;
+
+ private ServiceProviderSingleton()
+ {
+ super();
+ }
+
+ public static synchronized URI getServiceProviderURI()
+ {
+ return serviceProviderURISingleton;
+ }
+
+ static synchronized void setServiceProviderURI(final URI serviceProviderURI)
+ {
+ serviceProviderURISingleton = serviceProviderURI;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/TRSResource.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/TRSResource.java
new file mode 100644
index 0000000..e9809ca
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/TRSResource.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.resources;
+
+import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.wink.common.annotations.Workspace;
+import org.eclipse.lyo.core.trs.AbstractChangeLog;
+import org.eclipse.lyo.core.trs.ChangeEvent;
+import org.eclipse.lyo.core.trs.EmptyChangeLog;
+import org.eclipse.lyo.core.trs.TRSConstants;
+import org.eclipse.lyo.core.trs.TrackedResourceSet;
+import org.eclipse.lyo.oslc4j.core.annotation.OslcService;
+import org.eclipse.lyo.rio.trs.util.TRSUtil;
+
+/**
+ * RESTful service endpoints for returning the Tracked Resource Set and the Change Log at a given
+ * page.
+ *
+ * An HTTP GET on a Tracked Resource Set URI returns a representation structured as follows
+ * (note: for exposition, the example snippets show the RDF information content using Turtle;
+ * the actual representation of these resources "on the wire" may vary):
+
+ # Resource: http://cm1.example.com/trackedResourceSet
+ @prefix trs: <http://jazz.net/ns/trs#> .
+
+ <http://cm1.example.com/trackedResourceSet>
+ a trs:TrackedResourceSet ;
+ trs:base <http://cm1.example.com/baseResources> ;
+ trs:changeLog [
+ a trs:ChangeLog ;
+ trs:changes ( ... ) .
+ ] .
+
+ *
+ */
+@Path("/trs")
+@OslcService(TRSConstants.TRS_TYPE_TRACKED_RESOURCE_SET)
+@Workspace(workspaceTitle = "Tracked Resource Set", collectionTitle = "TRS")
+
+public class TRSResource {
+ @Context
+ protected UriInfo uriInfo;
+ @Context private HttpServletRequest httpServletRequest;
+ @Context private HttpServletResponse httpServletResponse;
+
+ /**
+ * getTrackedResourceSet() returns the Tracked Resource Set with the most recent
+ * page of the Change Log or EmptyChangeLog if no change logs pages exist
+ */
+ @GET
+ @Produces({ "application/rdf+xml", MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public TrackedResourceSet getTrackedResourceSet() throws URISyntaxException{
+ // from uri find out which Inner container to access...
+ URI requestURI = uriInfo.getRequestUri();
+
+ AbstractChangeLog changeLog = TRSUtil.getTrsChangelogMap(requestURI).isEmpty() ? new EmptyChangeLog() : TRSUtil.getCurrentChangelog(requestURI);
+
+ TrackedResourceSet set = new TrackedResourceSet();
+
+ set.setAbout(requestURI);
+
+ // Now set the uri for obtaining the Base of the Tracked Resource Set
+ URI requestBase = uriInfo.getBaseUri();
+ URI base = requestBase.resolve("trs/"+TRSConstants.TRS_TERM_BASE+"/");
+
+ set.setBase(base);
+ set.setChangeLog(changeLog);
+
+ return set;
+ }
+
+ /**
+ * getChangeLog() returns the current changelog...
+ */
+ @GET
+ @Path("changelog")
+ @Produces({ "application/rdf+xml", MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public AbstractChangeLog getChangeLog() throws URISyntaxException{
+ // from uri find out which Inner container to access...
+ URI requestURI = uriInfo.getRequestUri();
+
+ AbstractChangeLog changeLog = TRSUtil.getCurrentChangelog(requestURI);
+ return changeLog;
+ }
+
+ /**
+ * getChangeLogPage() returns the Change Log at the given page number
+ *
+ */
+ @GET
+ @Path("changelog/{page}")
+ @Produces({ "application/rdf+xml", MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public AbstractChangeLog getChangeLogPage(@PathParam("page") final Long page) throws URISyntaxException{
+ // from uri find out which Inner container to access...
+ URI requestURI = uriInfo.getRequestUri();
+
+ if (!TRSUtil.getTrsChangelogMap(requestURI).isEmpty() && !TRSUtil.getTrsChangelogMap(requestURI).containsKey(page))
+ throw new WebApplicationException(Status.NOT_FOUND);
+
+ AbstractChangeLog changeLog = TRSUtil.getTrsChangelogMap(requestURI).isEmpty() ? new EmptyChangeLog() : TRSUtil.getTrsChangelogMap(requestURI).get(page);
+
+ return changeLog;
+ }
+
+
+ @POST
+ @Path("ModifyCutOff")
+ @Consumes({ MediaType.APPLICATION_FORM_URLENCODED})
+ public void modifyCutOffEventhtml ( @FormParam ("event") String event )
+ {
+
+ try {
+ ChangeEvent ce = TRSUtil.getChangeEvent((event));
+ if (ce != null) {
+ TRSUtil.modifyCutoffEvent(ce);
+ }
+
+ // Send back to the form a small JSON response.
+ httpServletResponse.setContentType("application/json");
+ httpServletResponse.setStatus(Status.OK.getStatusCode());
+
+ PrintWriter out = httpServletResponse.getWriter();
+ out.print("{\"event\": \"" + event + "\"}");
+ out.close();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new WebApplicationException(e);
+ }
+
+ }
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/BaseGeneric.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/BaseGeneric.java
new file mode 100644
index 0000000..08b5a0c
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/BaseGeneric.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Mukherjee Biswarup - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.servlet;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.lyo.core.trs.Base;
+import org.eclipse.lyo.core.utils.marshallers.OSLC4JContext;
+import org.eclipse.lyo.core.utils.marshallers.OSLC4JMarshaller;
+import org.eclipse.lyo.rio.trs.util.TRSUtil;
+
+/**
+ * RESTful service endpoints for returning the Base of a Tracked Resource Set in pages.
+ * This is a servlet based generic implementation.
+ *
+ * The Base of a Tracked Resource Set is an RDF container where each member references
+ * a Resource that was in the Resource Set at the time the Base was computed. HTTP GET on
+ * a Base URI returns an RDF container with the following structure:
+ *
+ # Resource: http://cm1.example.com/baseResources
+ @prefix trs: <http://jazz.net/ns/trs#> .
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+ <http://cm1.example.com/baseResources>
+ trs:cutoffEvent
+ <urn:urn-3:cm1.example.com:2010-10-27T17:39:31.000Z:101> ;
+ rdfs:member <http://cm1.example.com/bugs/1> ;
+ rdfs:member <http://cm1.example.com/bugs/2> ;
+ rdfs:member <http://cm1.example.com/bugs/3> ;
+ ...
+ rdfs:member <http://cm1.example.com/bugs/199> ;
+ rdfs:member <http://cm1.example.com/bugs/200> .
+
+ *
+ */
+
+public class BaseGeneric extends HttpServlet {
+
+ public BaseGeneric() {
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("application/rdf+xml");
+ String path = null;
+
+ path = request.getPathInfo();
+ if ( path != null){
+ boolean endsWithSlash = path.endsWith("/");
+ // find the page number
+ Long page = (long) 0;
+ String [] arrofStr;
+ arrofStr = path.split("/");
+ if (arrofStr.length > 1){
+ page = (long) Integer.parseInt(arrofStr[1]);
+ }
+
+ if (page == 0){
+ // redirect it to first page.
+ response.sendRedirect(request.getRequestURL().toString() + ((endsWithSlash ? "" : "/") + "1"));
+ }
+ else
+ {
+ // handle the page.
+ URI requestBase;
+ Object[] oArray;
+ try {
+ requestBase = new URI(request.getRequestURL().toString());
+ TRSUtil.updateTRSResourceURI(requestBase);
+
+ if (TRSUtil.getTrsBase(requestBase).isEmpty() || !TRSUtil.getTrsBase(requestBase).containsKey(page))
+ throw new WebApplicationException(Status.NOT_FOUND);
+
+ List<Base> results = new ArrayList<Base>();
+ results.add(TRSUtil.getTrsBase(requestBase).get(page));
+ // return results;
+ OSLC4JContext context = OSLC4JContext.newInstance();
+ OSLC4JMarshaller marshaller = context.createMarshaller();
+ marshaller.setMediaType(MediaType.APPLICATION_XML_TYPE);
+ ServletOutputStream outputStream = response.getOutputStream();
+ oArray = results.toArray();
+ marshaller.marshal(oArray, outputStream);
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+ else
+ {
+ // redirects it to first page.
+ response.sendRedirect(request.getRequestURL().toString() + "/1");
+ }
+ }
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/ChangeLogGeneric.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/ChangeLogGeneric.java
new file mode 100644
index 0000000..3023c77
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/ChangeLogGeneric.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Mukherjee Biswarup - Initial implementation
+ *******************************************************************************/
+package org.eclipse.lyo.rio.trs.servlet;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.lyo.core.trs.AbstractChangeLog;
+import org.eclipse.lyo.core.trs.EmptyChangeLog;
+import org.eclipse.lyo.core.utils.marshallers.OSLC4JContext;
+import org.eclipse.lyo.core.utils.marshallers.OSLC4JMarshaller;
+import org.eclipse.lyo.rio.trs.util.TRSUtil;
+
+/**
+ * RESTful service endpoints for returning the Change Log at a given
+ * page. This is a servlet based generic implementation.
+ *
+ */
+public class ChangeLogGeneric extends HttpServlet {
+
+ public ChangeLogGeneric() {
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("application/rdf+xml");
+ AbstractChangeLog changeLog = null;
+ Object[] oArray = new Object[1];
+
+ String path = null;
+ URI requestBase;
+ try {
+ requestBase = new URI(request.getRequestURL().toString());
+
+ path = request.getPathInfo();
+ if ( path != null){
+ // find the page number
+ Long page = (long) 0;
+ String [] arrofStr;
+ arrofStr = path.split("/");
+ if (arrofStr.length > 1){
+ page = (long) Integer.parseInt(arrofStr[1]);
+ }
+
+ if (!TRSUtil.getTrsChangelogMap(requestBase).isEmpty() && !TRSUtil.getTrsChangelogMap(requestBase).containsKey(page))
+ throw new WebApplicationException(Status.NOT_FOUND);
+
+ changeLog = TRSUtil.getTrsChangelogMap(requestBase).isEmpty() ? new EmptyChangeLog() : TRSUtil.getTrsChangelogMap(requestBase).get(page);
+ }
+ else
+ {
+ changeLog = TRSUtil.getTrsChangelogMap(requestBase).isEmpty() ? new EmptyChangeLog() : TRSUtil.getCurrentChangelog(requestBase);
+ }
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+
+ OSLC4JContext context = OSLC4JContext.newInstance();
+ OSLC4JMarshaller marshaller = context.createMarshaller();
+ marshaller.setMediaType(MediaType.APPLICATION_XML_TYPE);
+ ServletOutputStream outputStream = response.getOutputStream();
+ oArray[0] = changeLog;
+ marshaller.marshal(oArray, outputStream);
+ }
+
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/TRSGeneric.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/TRSGeneric.java
new file mode 100644
index 0000000..31f0d0a
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/servlet/TRSGeneric.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Mukherjee Biswarup - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.servlet;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import org.eclipse.lyo.core.trs.AbstractChangeLog;
+import org.eclipse.lyo.core.trs.EmptyChangeLog;
+import org.eclipse.lyo.core.trs.TRSConstants;
+import org.eclipse.lyo.core.trs.TrackedResourceSet;
+import org.eclipse.lyo.core.utils.marshallers.OSLC4JContext;
+import org.eclipse.lyo.core.utils.marshallers.OSLC4JMarshaller;
+import org.eclipse.lyo.rio.trs.util.TRSUtil;
+/**
+ * RESTful service endpoints for returning the Tracked Resource Set at a given
+ * page. This is a servlet based generic implementation.
+ *
+ * An HTTP GET on a Tracked Resource Set URI returns a representation structured as follows
+ * (note: for exposition, the example snippets show the RDF information content using Turtle;
+ * the actual representation of these resources "on the wire" may vary):
+
+ # Resource: http://cm1.example.com/trackedResourceSet
+ @prefix trs: <http://jazz.net/ns/trs#> .
+
+ <http://cm1.example.com/trackedResourceSet>
+ a trs:TrackedResourceSet ;
+ trs:base <http://cm1.example.com/baseResources> ;
+ trs:changeLog [
+ a trs:ChangeLog ;
+ trs:changes ( ... ) .
+ ] .
+
+ *
+ */
+// The servlet class to handle request for /restx/trs/*. Implementation TRS through Servlet.
+public class TRSGeneric extends HttpServlet {
+
+ public TRSGeneric() {
+ super();
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ response.setContentType("application/rdf+xml");
+
+ Object[] oArray = new Object[1];
+ TrackedResourceSet set = new TrackedResourceSet();
+
+ URI requestURI;
+ try {
+ requestURI = new URI(request.getRequestURL().toString());
+ set.setAbout(requestURI);
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // Now set the uri for obtaining the Base of the Tracked Resource Set
+ URI requestBase;
+ try {
+ requestBase = new URI(request.getRequestURL().toString());
+ AbstractChangeLog changeLog = TRSUtil.getTrsChangelogMap(requestBase).isEmpty() ? new EmptyChangeLog() : TRSUtil.getCurrentChangelog(requestBase);
+ URI base = requestBase.resolve("trs/"+TRSConstants.TRS_TERM_BASE+"/");
+ set.setBase(base);
+ set.setChangeLog(changeLog);
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ OSLC4JContext context = OSLC4JContext.newInstance();
+ OSLC4JMarshaller marshaller = context.createMarshaller();
+ marshaller.setMediaType(MediaType.APPLICATION_XML_TYPE);
+ ServletOutputStream outputStream = response.getOutputStream();
+ oArray[0] = set;
+ marshaller.marshal(oArray, outputStream);
+ }
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/Persistence.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/Persistence.java
new file mode 100644
index 0000000..b5ab989
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/Persistence.java
@@ -0,0 +1,299 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.TreeMap;
+
+import javax.ws.rs.WebApplicationException;
+import javax.xml.datatype.DatatypeConfigurationException;
+
+import org.eclipse.lyo.oslc4j.core.exception.OslcCoreApplicationException;
+import org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper;
+import org.eclipse.lyo.core.utils.marshallers.OSLC4JContext;
+import org.eclipse.lyo.core.utils.marshallers.OSLC4JMarshaller;
+import org.eclipse.lyo.rio.trs.cm.ChangeRequest;
+import org.eclipse.lyo.rio.trs.cm.Constants;
+import org.eclipse.lyo.rio.trs.cm.Type;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.util.FileUtils;
+
+public class Persistence {
+ private final static TreeMap<Long, ChangeRequest> CHANGE_REQUESTS_MAP = new TreeMap<Long, ChangeRequest>();
+ private static boolean CHANGE_REQUESTS_LOADED = false;
+ private static long MAX_IDENTIFIER;
+
+ public static int PAGE_SIZE = 3;
+ private Persistence() {
+ super();
+ }
+
+ private static boolean fileload(final String fileName)
+ throws DatatypeConfigurationException, FileNotFoundException,
+ IllegalAccessException, IllegalArgumentException,
+ InstantiationException, InvocationTargetException,
+ OslcCoreApplicationException, URISyntaxException,
+ SecurityException, NoSuchMethodException {
+
+ final File file = new File(fileName);
+
+ if ((file.exists()) && (file.isFile()) && (file.canRead())) {
+ final Model model = ModelFactory.createDefaultModel();
+
+ model.read(new FileInputStream(file), null, FileUtils.langXMLAbbrev);
+
+ final Object[] resources = JenaModelHelper.fromJenaModel(model,
+ ChangeRequest.class);
+
+ synchronized (CHANGE_REQUESTS_MAP) {
+ CHANGE_REQUESTS_MAP.clear();
+
+ if (resources != null) {
+ for (final Object resource : resources) {
+ if (resource instanceof ChangeRequest) {
+ final ChangeRequest changeRequest = (ChangeRequest) resource;
+
+ final String identifier = changeRequest
+ .getIdentifier();
+
+ final long longIdentifier = Long
+ .parseLong(identifier);
+
+ MAX_IDENTIFIER = Math.max(longIdentifier,
+ MAX_IDENTIFIER);
+
+ CHANGE_REQUESTS_MAP
+ .put(Long.valueOf(longIdentifier),
+ changeRequest);
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+ else {
+ //ChangeRequestResource
+ }
+
+ return false;
+ }
+
+ private static void save(final String fileName) {
+
+ final ChangeRequest[] changeRequests = getAllChangeRequests();
+ OSLC4JContext context = OSLC4JContext.newInstance();
+ OSLC4JMarshaller marshaller = context.createMarshaller();
+ try {
+ marshaller.marshal(changeRequests, new FileOutputStream(fileName));
+ } catch (WebApplicationException e) {
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static long getNextIdentifier() {
+ synchronized (CHANGE_REQUESTS_MAP) {
+ if (!CHANGE_REQUESTS_LOADED)
+ initialize();
+ return ++MAX_IDENTIFIER;
+ }
+ }
+
+ public static int getTotalChangeRequests(){
+ synchronized (CHANGE_REQUESTS_MAP) {
+ if (!CHANGE_REQUESTS_LOADED)
+ initialize();
+ return CHANGE_REQUESTS_MAP.size();
+ }
+ }
+
+ public static ChangeRequest[] getChangeRequests(final int page) {
+ synchronized (CHANGE_REQUESTS_MAP) {
+ int startIndex = page * PAGE_SIZE;
+ int total = getTotalChangeRequests();
+ int numResults = PAGE_SIZE;
+ ChangeRequest[] ret = null;
+
+ if(total == 0) ret = new ChangeRequest[0];
+ else if(startIndex >= total) throw new ArrayIndexOutOfBoundsException();
+ else{
+ if(total-startIndex < PAGE_SIZE) numResults = total-startIndex;
+ ChangeRequest[] requests = CHANGE_REQUESTS_MAP.values().toArray(
+ new ChangeRequest[CHANGE_REQUESTS_MAP.size()]);
+ ret = new ChangeRequest[numResults];
+ System.arraycopy(requests, startIndex, ret, 0, numResults);
+ }
+ return ret;
+ }
+ }
+
+ public static void initialize() {
+ try {
+ CHANGE_REQUESTS_LOADED = true;
+
+ fileload(Constants.PATH_FLAT_FILE);
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (DatatypeConfigurationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (OslcCoreApplicationException e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static ChangeRequest[] getAllChangeRequests() {
+ synchronized (CHANGE_REQUESTS_MAP) {
+ ChangeRequest[] ret = null;
+
+ if(CHANGE_REQUESTS_MAP.size() == 0 && !CHANGE_REQUESTS_LOADED){
+ initialize();
+ }
+ // if still empty then return empty array
+ if(CHANGE_REQUESTS_MAP.size() == 0){
+ ret = new ChangeRequest[0];
+ }
+ else{
+ ChangeRequest[] requests = CHANGE_REQUESTS_MAP.values().toArray(
+ new ChangeRequest[CHANGE_REQUESTS_MAP.size()]);
+ ret = new ChangeRequest[CHANGE_REQUESTS_MAP.size()];
+ System.arraycopy(requests, 0, ret, 0, CHANGE_REQUESTS_MAP.size());
+ }
+ return ret;
+ }
+ }
+
+ public static ChangeRequest getChangeRequest(final String identifier) {
+ synchronized (CHANGE_REQUESTS_MAP) {
+ if (!CHANGE_REQUESTS_LOADED)
+ initialize();
+
+ return CHANGE_REQUESTS_MAP.get(Long.valueOf(identifier));
+ }
+ }
+
+ public static ChangeRequest createChangeRequest(final String description,
+ final String title, final String filedAgainst)
+ throws URISyntaxException {
+ final ChangeRequest changeRequest = new ChangeRequest();
+
+ changeRequest.setApproved(Boolean.FALSE);
+ changeRequest.setClosed(Boolean.FALSE);
+ changeRequest.addDctermsType(Type.Defect.toString());
+ changeRequest.setDescription(description);
+ changeRequest.setFiledAgainst(filedAgainst);
+ changeRequest.setFixed(Boolean.FALSE);
+ changeRequest.setInProgress(Boolean.FALSE);
+ changeRequest.setReviewed(Boolean.FALSE);
+ changeRequest.setShortTitle(title);
+ changeRequest.setStatus("Submitted");
+ changeRequest.setTitle(title);
+ changeRequest.setVerified(Boolean.FALSE);
+
+ return changeRequest;
+ }
+
+ public static ChangeRequest persistChangeRequest(final URI basePath,
+ final ChangeRequest changeRequest) throws URISyntaxException {
+ final long identifier = Persistence.getNextIdentifier();
+
+ final URI about = basePath.resolve("./changeRequests/" + identifier);
+
+ changeRequest.setAbout(about);
+ changeRequest.setIdentifier(String.valueOf(identifier));
+ // changeRequest.setServiceProvider(serviceProviderURI);
+
+ final Date date = new Date();
+
+ changeRequest.setCreated(date);
+ changeRequest.setModified(date);
+
+ Persistence.addChangeRequest(changeRequest);
+
+ return changeRequest;
+ }
+
+ private static void addChangeRequest(final ChangeRequest changeRequest) {
+ synchronized (CHANGE_REQUESTS_MAP) {
+ CHANGE_REQUESTS_MAP.put(
+ Long.valueOf(changeRequest.getIdentifier()), changeRequest);
+
+ // save out to file here
+ save(Constants.PATH_FLAT_FILE);
+ }
+ }
+
+ public static ChangeRequest updateChangeRequest(final String identifier,
+ final ChangeRequest changeRequest) {
+ final Long longIdentifier = Long.valueOf(identifier);
+
+ synchronized (CHANGE_REQUESTS_MAP) {
+ final ChangeRequest existingChangeRequest = CHANGE_REQUESTS_MAP
+ .get(longIdentifier);
+
+ if (existingChangeRequest != null) {
+ CHANGE_REQUESTS_MAP.put(longIdentifier, changeRequest);
+
+ // save out to file here
+ save(Constants.PATH_FLAT_FILE);
+
+ return changeRequest;
+ }
+ }
+
+ return null;
+ }
+
+ public static ChangeRequest deleteChangeRequest(final String identifier) {
+ synchronized (CHANGE_REQUESTS_MAP) {
+ ChangeRequest result = CHANGE_REQUESTS_MAP.remove(Long.valueOf(identifier));
+
+ // this means we successfully removed something with the given identifier
+ if (result != null) {
+ // save out to file here
+ save(Constants.PATH_FLAT_FILE);
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSUtil.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSUtil.java
new file mode 100644
index 0000000..d35796a
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSUtil.java
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.util;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TreeMap;
+
+import org.eclipse.lyo.core.trs.AbstractChangeLog;
+import org.eclipse.lyo.core.trs.Base;
+import org.eclipse.lyo.core.trs.ChangeEvent;
+import org.eclipse.lyo.core.trs.ChangeLog;
+import org.eclipse.lyo.core.trs.Creation;
+import org.eclipse.lyo.core.trs.Deletion;
+import org.eclipse.lyo.core.trs.Modification;
+import org.eclipse.lyo.core.trs.TRSConstants;
+
+public class TRSUtil {
+
+ /**
+ * insertEventTypeToChangeLog - Insert an event corresponding to the trsEvent for the resource
+ * located at
+ * @param trsEvent - One of TRS_TYPE_CREATION, TRS_TYPE_MODIFICATION or TRS_TYPE_DELETION
+ * @param resource - URI of the resource that has undergone the change identified by trsEvent
+ */
+ public static void insertEventTypeToChangeLog(String trsEvent, URI resource) {
+ ChangeEvent event = null;
+ // increment the event number to maintain event order
+ int eventNumber = (TRSUtil.LATEST_EVENT != null) ? TRSUtil.LATEST_EVENT.getOrder() + 1 : 0;
+
+ if (trsEvent.equals(TRSConstants.TRS_TYPE_CREATION)) {
+ event = new Creation(getCurrentTimeStampURN(), resource, eventNumber);
+ }
+ else if (trsEvent.equals(TRSConstants.TRS_TYPE_MODIFICATION)) {
+ event = new Modification(getCurrentTimeStampURN(), resource, eventNumber);
+ }
+ else if (trsEvent.equals(TRSConstants.TRS_TYPE_DELETION)) {
+ event = new Deletion(getCurrentTimeStampURN(), resource, eventNumber);
+ }
+ // add the event to each inner container helper obj representing JAXRS and generic implementation.
+ for (int i = 0 ; i <innerHelpr.length; i++ )
+ innerHelpr[i].insertEventToPagedChangeLog(event, resource);
+
+ }
+
+ // if required, this routine will update the URI
+ // and prime the base resources
+ public static void initialize(URI baseURI) {
+ updateTRSResourceURI(baseURI);
+ // initialize each inner container helper obj representing JAXRS and generic implementation.
+ for (int i = 0 ; i <innerHelpr.length; i++ )
+ innerHelpr[i].initialize();
+
+ }
+ private static boolean IsGenericImplDesired(URI inURI){
+ String sUri = inURI.getPath();
+ if (sUri.contains(TRS_GENERIC_MARKER))
+ return true;
+ else
+ return false;
+ }
+
+ public static TreeMap<Long, Base> getTrsBase(URI inURI) {
+ if (!TRS_URI_INITIALIZED) {
+ initialize(inURI);
+ }
+ // from uri find out which Inner container to access...
+ if(!IsGenericImplDesired(inURI))
+ return innerHelpr[0].getTrsBaseInner();
+ else
+ return innerHelpr[1].getTrsBaseInner();
+ }
+
+ public static void updateTRSResourceURI(URI resource) {
+ if (!TRS_URI_INITIALIZED) {
+ String sPath = resource.getPath();
+ String sContext = null;
+
+ // need to access the context (refapps_xxx) from URI as we are using it to support multiple TRS apps.
+ String[] subParts = sPath.split("/");
+ if (subParts.length > 1)
+ sContext = subParts[1];
+
+ TRS_URI_INITIALIZED = true;
+ // initialize both inner container helper obj representing JAXRS and generic implementation.
+ for (int i = 0 ; i <innerHelpr.length; i++ ){
+ innerHelpr[i] = new TRSUtilHelper();
+ URI trs_Uri;
+ if (i == 0){
+ trs_Uri = resource.resolve("/" + sContext + TRS_URI_PATH);
+ }
+ else{
+ trs_Uri = resource.resolve("/" + sContext + TRS_URI_PATH2);
+ }
+ innerHelpr[i].set_TRS_URI(trs_Uri);
+ }
+ }
+ }
+
+ public static TreeMap<Long, ChangeLog> getTrsChangelogMap(URI inURI) {
+ if (!TRS_URI_INITIALIZED) {
+ initialize(inURI);
+ }
+ // from uri find out which Inner container to access...
+ if(!IsGenericImplDesired(inURI))
+ return innerHelpr[0].getTrsChangelogMapInner();
+ else
+ return innerHelpr[1].getTrsChangelogMapInner();
+ }
+
+ public static AbstractChangeLog getCurrentChangelog(URI inURI) {
+ if (!TRS_URI_INITIALIZED) {
+ initialize(inURI);
+ }
+ // from uri find out which Inner container to access...
+ if(!IsGenericImplDesired(inURI))
+ return innerHelpr[0].getCurrentChangeLogInner();
+ else
+ return innerHelpr[1].getCurrentChangeLogInner();
+ }
+
+ public static final int PAGE_SIZE = 3;
+ public final static String TRS_URI_PATH = "/rest/trs/";
+ public final static String TRS_URI_PATH2 = "/restx/trs/";
+ public final static String TRS_GENERIC_MARKER = "/restx/";
+
+ // inner container helper obj representing JAXRS and generic implementation.
+ private static TRSUtilHelper[] innerHelpr = new TRSUtilHelper[2];
+ public static boolean TRS_URI_INITIALIZED = false;
+
+ private static URI getCurrentTimeStampURN() {
+ URI timestampURI = null;
+ try {
+ timestampURI = new URI("urn:urn-3:cm1.example.com:" + getCurrentTimeStamp());
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ return timestampURI;
+ }
+
+ private static String getCurrentTimeStamp() {
+ Date currDate = new Date();
+ SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss.SS");
+ String currDateStr = dateFormatGmt.format(currDate);
+ return currDateStr;
+ }
+
+ public static void modifyCutoffEvent(ChangeEvent inCutOffEvent) {
+ for (int i = 0 ; i <innerHelpr.length; i++ )
+ innerHelpr[i].modifyCutoffEventInner(inCutOffEvent);
+ }
+
+ public static ChangeEvent getChangeEvent (String uriAbout) {
+ // since the same set of event is kept in both the helper's changelog; access the first helper.
+ return innerHelpr[0].getChangeEventInner(uriAbout);
+ }
+ public static ChangeEvent LATEST_EVENT;
+
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSUtilHelper.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSUtilHelper.java
new file mode 100644
index 0000000..6d93fe6
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSUtilHelper.java
@@ -0,0 +1,280 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *
+ * Ernest Mah - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.lyo.rio.trs.util;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.TreeMap;
+
+import org.eclipse.lyo.core.trs.AbstractChangeLog;
+import org.eclipse.lyo.core.trs.Base;
+import org.eclipse.lyo.core.trs.ChangeEvent;
+import org.eclipse.lyo.core.trs.ChangeLog;
+import org.eclipse.lyo.core.trs.Creation;
+import org.eclipse.lyo.core.trs.Deletion;
+import org.eclipse.lyo.core.trs.EmptyChangeLog;
+import org.eclipse.lyo.core.trs.TRSConstants;
+import org.eclipse.lyo.oslc4j.core.model.AbstractResource;
+import org.eclipse.lyo.rio.trs.cm.ChangeRequest;
+
+public class TRSUtilHelper {
+
+ private final TreeMap<Long, Base> trs_base_map = new TreeMap<Long, Base>();
+ private final TreeMap<Long, ChangeLog> trs_changelog_map = new TreeMap<Long, ChangeLog>();
+ private URI trs_uri = null;
+ private int trs_curr_changelog_size = 0;
+ private Long trs_curr_changelog_page = -1L;
+ private ChangeLog trs_curr_changelog = null;
+ private AbstractResource trs_prev_changelog = null;
+ private ChangeEvent last_cut_off_event = null;
+ public boolean trs_base_initialized = false;
+
+ public AbstractChangeLog getCurrentChangeLogInner(){
+ AbstractChangeLog changeLog = getTrsChangelogMapInner().isEmpty() ? new EmptyChangeLog() : trs_curr_changelog;
+ return changeLog;
+ }
+
+ public URI get_TRS_URI()
+ {
+ return trs_uri;
+ }
+
+ public void set_TRS_URI(URI inUri)
+ {
+ trs_uri = inUri;
+ }
+
+ private Base createNewBase() {
+ Base newBase = new Base();
+ newBase.setAbout(getBaseResourceURI(null));
+ try {
+ newBase.setCutoffEvent(new URI(TRSConstants.RDF_NIL));
+ newBase.setNextPage(new URI(TRSConstants.RDF_NIL));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ return newBase;
+ }
+
+ public void initialize() {
+ synchronized (trs_base_map) {
+ trs_base_initialized = true;
+
+ // initialize TRS Base
+ ChangeRequest[] changeRequests = Persistence.getAllChangeRequests();
+ int currentPageSize = 0;
+ Long currentPageNumber = 1L;
+ Base currentBase = null;
+
+ if (changeRequests.length == 0) {
+ currentBase = createNewBase();
+ getTrsBaseMapInner().put(currentPageNumber, currentBase);
+ return;
+ }
+
+ // inventory of all CR resources
+ for (ChangeRequest changeRequest : changeRequests) {
+ // Create a new base entry
+ if (currentPageSize == 0) {
+ if (currentBase != null)
+ currentBase.setNextPage(getBaseResourceURI(currentPageNumber));
+ currentBase = createNewBase();
+ getTrsBaseMapInner().put(currentPageNumber, currentBase);
+ }
+
+ // add resource into TRS base
+ currentBase.getMembers().add(changeRequest.getAbout());
+ currentPageSize++;
+
+ // Have we reached the page boundary?
+ if (currentPageSize == TRSUtil.PAGE_SIZE) {
+ currentPageSize = 0;
+ currentPageNumber++;
+ }
+ }
+ }
+ }
+ public TreeMap<Long, Base> getTrsBaseInner() {
+ if (!trs_base_initialized) {
+ initialize();
+ }
+ return getTrsBaseMapInner();
+ }
+
+ private TreeMap<Long, Base> getTrsBaseMapInner() {
+ return trs_base_map;
+ }
+
+ public TreeMap<Long, ChangeLog> getTrsChangelogMapInner() {
+ return trs_changelog_map;
+ }
+
+ private URI getBaseResourceURI(Long pageNumber) {
+ if (pageNumber == null)
+ return trs_uri.resolve("./" + TRSConstants.TRS_TERM_BASE+"/");
+ else
+ return trs_uri.resolve("./" + TRSConstants.TRS_TERM_BASE+"/"+pageNumber);
+ }
+
+ public void insertEventToPagedChangeLog(ChangeEvent event, URI resource) {
+ synchronized (trs_changelog_map) {
+ TRSUtil.updateTRSResourceURI(resource);
+
+ // Create a new base entry
+ if (trs_curr_changelog_size == 0) {
+ trs_curr_changelog_page++;
+
+ trs_prev_changelog = trs_curr_changelog;
+ trs_curr_changelog = new ChangeLog();
+ getTrsChangelogMapInner().put(trs_curr_changelog_page, trs_curr_changelog);
+ trs_curr_changelog.setAbout(getTRSResourceURI("changelog"));
+
+ if (trs_curr_changelog_page > 0) {
+ URI previousURI = getTRSResourceURI("changelog/"+Long.toString(trs_curr_changelog_page-1));
+ trs_curr_changelog.setPrevious(previousURI);
+ trs_prev_changelog.setAbout(previousURI);
+ }
+ }
+
+ // add resource into current changelog
+ trs_curr_changelog.getChanges().add(0, event);
+ trs_curr_changelog_size++;
+ TRSUtil.LATEST_EVENT = event;
+
+ // Have we reached the page boundary?
+ if (trs_curr_changelog_size == Persistence.PAGE_SIZE) {
+ trs_curr_changelog_size = 0;
+ }
+ }
+ }
+
+ private URI getTRSResourceURI(String path) {
+ if (path == null)
+ return trs_uri;
+ else
+ return trs_uri.resolve(path);
+ }
+
+ public void setCutOffEventInner(ChangeEvent cutOffEvent) {
+ Collection<Base> baseValues = getTrsBaseMapInner().values();
+ for (Base base : baseValues) {
+ base.setCutoffEvent(cutOffEvent.getAbout());
+ }
+ }
+
+ public void modifyCutoffEventInner(ChangeEvent inCutOffEvent) {
+ synchronized (trs_changelog_map) {
+ List<ChangeEvent> ListofEvents2Compact = new ArrayList<ChangeEvent>();
+ boolean bNewCutOffFound = false;
+
+ // 1. Iterate change log entries if inCutOffEvent is found
+ for (long page = trs_curr_changelog_page; page >= 0 ; page-- ) {
+ ChangeLog aChangeLog = getTrsChangelogMapInner().get((long) page);
+ List<ChangeEvent> aListofevents = aChangeLog.getChanges();
+ for(ChangeEvent e : aListofevents) {
+ if (last_cut_off_event != null) {
+ if (e.equals(last_cut_off_event)) {
+ break;
+ }
+ }
+
+ if (bNewCutOffFound == false) {
+ if (e.equals(inCutOffEvent)) {
+ bNewCutOffFound = true;
+ ListofEvents2Compact.add(e);
+ }
+ }
+ else {
+ // 1.a. Start adding each entry into ActionList till
+ // CurrentCutoffevent or end of list of Changelog is found.
+ ListofEvents2Compact.add(e);
+ }
+ }
+ }
+ // set last cutoff event for next iteration.
+ last_cut_off_event = inCutOffEvent;
+
+ // 1.b. take action for each entry in the ActionList in reverse order i.e. oldest change event first.
+ for (int ii = ListofEvents2Compact.size()-1; ii >= 0; ii--) {
+ ChangeEvent e2 = ListofEvents2Compact.get(ii);
+ modifyBase(e2);
+ }
+ // 2. Set the cutOffEvent
+ setCutOffEventInner(inCutOffEvent);
+ }
+ }
+
+ private void modifyBase(ChangeEvent e) {
+ synchronized (trs_base_map) {
+ Collection<Base> baseValues = getTrsBaseMapInner().values();
+ // if Creation then add resource to base(last page).
+ if (e.getClass().equals(Creation.class)) {
+
+ int index = 0;
+ int size = baseValues.size();
+ Base currentBase = null;
+ for (Base base : baseValues) {
+ if (index == (baseValues.size()-1)) {
+ // get the last base page
+ currentBase = base;
+ }
+ index++;
+ }
+
+ // add the resource corresponding to the current event to the base
+ if (currentBase != null) {
+ currentBase.getMembers().add(e.getChanged());
+ }
+ }
+ // for modification do nothing.
+
+ // for deletion we need to delete the resource from the base page (where it's currently exists).
+ if (e.getClass().equals(Deletion.class)) {
+ for (Base base : baseValues) {
+ List<URI> resources = base.getMembers();
+ for (URI uriRes : resources) {
+ // if we get the match delete the resource and exit.
+ if (uriRes.equals(e.getChanged())) {
+ base.getMembers().remove(e.getChanged());
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public ChangeEvent getChangeEventInner (String uriAbout) {
+ ChangeEvent result = null;
+
+ for (int page = 0; page <= trs_curr_changelog_page; page++) {
+ ChangeLog aChangeLog = getTrsChangelogMapInner().get((long) page);
+ List<ChangeEvent> aListofevents = aChangeLog.getChanges();
+ for(ChangeEvent e: aListofevents) {
+ if (uriAbout.equals(e.getAbout().toString())) {
+ result = e;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/resources/build.properties b/org.eclipse.lyo.rio.trs/src/main/resources/build.properties
new file mode 100644
index 0000000..aefa78d
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/resources/build.properties
@@ -0,0 +1,11 @@
+###############################################################################
+#
+# Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA).
+# Copyright IBM Corporation 2012. All Rights Reserved.
+# U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+#
+###############################################################################
+
+build.version=${pom.version}
+build.timestamp=${timestamp}
+build.java.version=${java.version}
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/ChangeReq_creator.jsp b/org.eclipse.lyo.rio.trs/src/main/webapp/ChangeReq_creator.jsp
new file mode 100644
index 0000000..08e9041
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/ChangeReq_creator.jsp
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+
+<%--
+ Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA).
+ © Copyright IBM Corporation 2012, 2013. All Rights Reserved.
+ U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ --%>
+
+ <%@ page contentType="text/html" language="java" pageEncoding="UTF-8" %>
+ <%
+ String creatorUri = (String) request.getAttribute("creatorUri");
+ String scriptPath = (String) request.getContextPath()+"/TestApp.js";
+ %>
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+<title>Test App OSLC Adapter: Resource Creator</title>
+ <script type="text/javascript" src= '<%= scriptPath %>' ></script>
+</head>
+<body>
+<body style="padding: 10px;">
+ <div id="changereq-body">
+ <form id="Create" method="POST" class="enter_CR_form">
+ <table style="clear: both;">
+
+ <tr>
+ <th class="field_label required">Title:</th>
+ <td><input name="title" class="required text_input"
+ type="text" style="width: 400px" id="title" required autofocus></td>
+ </tr>
+
+ <tr>
+ <th class="field_label">Description:</th>
+ <td><textarea style="width: 400px; height: 150px;"
+ id="description" name="description"></textarea></td>
+ </tr>
+
+ <tr>
+ <th class="field_label">Filed Against:</th>
+ <td>
+ <select name="filedAgainst">
+ <option value="Server">Server</option>
+ <option value="Client">Client</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td></td>
+ <td>
+ <input type="button"
+ value="Submit Bug"
+ onclick="javascript: create( '<%= creatorUri %>' )">
+ <input type="button" value="Cancel" onclick="javascript: cancel()">
+ </td>
+ </tr>
+
+
+ </table>
+ </form>
+
+ <div style="clear: both;">
+ <p></p>
+ </div>
+ <div id="status"></div>
+
+ </div>
+</body>
+</html>
+ \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/ChangeReq_modify.jsp b/org.eclipse.lyo.rio.trs/src/main/webapp/ChangeReq_modify.jsp
new file mode 100644
index 0000000..7ae6e4e
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/ChangeReq_modify.jsp
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+
+<%--
+ Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA).
+ © Copyright IBM Corporation 2012, 2013. All Rights Reserved.
+ U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ --%>
+
+ <%@ page contentType="text/html" language="java" pageEncoding="UTF-8" %>
+ <%@ page import="java.io.Console"%>
+ <%@ page import="org.eclipse.lyo.rio.trs.cm.Severity" %>
+ <%@ page import="org.eclipse.lyo.rio.trs.cm.ChangeRequest" %>
+ <%@ page import="org.eclipse.lyo.rio.trs.util.Persistence" %>
+ <%
+ String modifyUri = (String) request.getAttribute("modifyUri");
+ String scriptPath = (String) request.getContextPath()+"/TestApp.js";
+ %>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+<title>Test App OSLC Adapter: Resource Modifier</title>
+<script type="text/javascript" src='<%= scriptPath %>'>
+</script>
+</head>
+<body style="padding: 10px;" onload="javascript:loadCR( '<%= modifyUri %>' )">
+<div id="changereq-body">
+ <form id="Modify" class="enter_CR_form">
+ <table style="clear: both;">
+
+ <tr>
+ <th class="field_label required">Title:</th>
+ <td><input name="title" class="required text_input"
+ type="text" style="width: 400px" id="title" required autofocus></td>
+ </tr>
+
+ <tr>
+ <th class="field_label">Description:</th>
+ <td><textarea style="width: 400px; height: 150px;"
+ id="description" name="description"></textarea></td>
+ </tr>
+
+ <tr>
+ <th class="field_label">Filed Against:</th>
+ <td>
+ <select name="filedAgainst">
+ <option value="Server">Server</option>
+ <option value="Client">Client</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td></td>
+ <td>
+ <input type="button"
+ value="Modify Bug"
+ onclick="javascript:modify( '<%= modifyUri %>' )">
+
+ </td>
+ </tr>
+
+ </table>
+ </form>
+ <div style="clear: both;">
+ <p></p>
+ </div>
+ <div id="status"></div>
+ </div>
+</body>
+</html>
+ \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/CutOffEvent_modify.jsp b/org.eclipse.lyo.rio.trs/src/main/webapp/CutOffEvent_modify.jsp
new file mode 100644
index 0000000..515883a
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/CutOffEvent_modify.jsp
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+
+<%--
+ Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA).
+ © Copyright IBM Corporation 2012. All Rights Reserved.
+ U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ --%>
+
+ <%@ page contentType="text/html" language="java" pageEncoding="UTF-8" %>
+ <%
+ String modifyCutOffUri = request.getContextPath() + "/rest/trs/ModifyCutOff";
+ String scriptPath = (String) request.getContextPath()+"/TestApp.js";
+ %>
+
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+<title>Reference App OSLC Adapter: Modify CutOff Event</title>
+ <script type="text/javascript" src='<%= scriptPath %>'></script>
+</head>
+<body>
+<body style="padding: 10px;">
+ <div id="changereq-body">
+ <form id="ModifyCutOff" method="POST" class="enter_CutOff_form">
+ <table style="clear: both;">
+
+ <tr>
+ <th class="field_label required">CutOff Event:</th>
+ <td><input name="CutOffEvent" class="required text_input"
+ type="text" style="width: 400px" id="event" required autofocus></td>
+ </tr>
+
+ <tr>
+ <td></td>
+ <td>
+ <input type="button"
+ value="Modify CutOff Event"
+ onclick="javascript: ModifyCutOff( '<%= modifyCutOffUri %>' )">
+ <input type="button" value="Cancel" onclick="javascript: cancel()">
+ </td>
+ </tr>
+
+
+ </table>
+ </form>
+ <div id="hint">Provide URL(rdf:about) of the Change Event from <a href="/org.eclipse.lyo.rio.trs/rest/trs/">Change Log</a> to be set as new Cutoff event. </div>
+ <div style="clear: both;">
+ <p></p>
+ </div>
+ <div id="status"></div>
+
+ </div>
+</body>
+</html> \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/TestApp.js b/org.eclipse.lyo.rio.trs/src/main/webapp/TestApp.js
new file mode 100644
index 0000000..1b77794
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/TestApp.js
@@ -0,0 +1,156 @@
+/*******************************************************************************
+* Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA).
+* © Copyright IBM Corporation 2012, 2013. All Rights Reserved.
+* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *******************************************************************************/
+
+function create(baseUrl){
+
+ var form = document.getElementById("Create");
+ xmlhttp = new XMLHttpRequest();
+ xmlhttp.onreadystatechange = function() {
+ if (xmlhttp.readyState==4 && (xmlhttp.status==201)) {
+ txt = xmlhttp.responseText;
+ resp = eval('(' + txt + ')');
+ // provide a status message.
+ var oStatus = document.getElementById("status");
+ if (oStatus.hasChildNodes()){
+ oStatus.removeChild(oStatus.childNodes[0]);
+ }
+ oStatus.appendChild(document.createTextNode("Change Request " + resp.ID + " : " + resp.title + " has been created successfully." ));
+ }
+ };
+ var postData="";
+
+ if (form.title) {
+ postData += "&title="+encodeURIComponent(form.title.value);
+ }
+ if (form.description) {
+ postData += "&description="+encodeURIComponent(form.description.value);
+ }
+
+ postData += "&filedAgainst="+encodeURIComponent(form.filedAgainst.value);
+
+ xmlhttp.open("POST", baseUrl, true);
+ xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
+ xmlhttp.setRequestHeader("Content-length",postData.length);
+ xmlhttp.send(postData);
+}
+
+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 respondWithPostMessage(/*string*/ response) {
+ if( window.parent != null ) {
+ window.parent.postMessage(response, "*");
+ } else {
+ window.postMessage(response, "*");
+ }
+}
+
+function cancel(){
+ sendCancelResponse();
+}
+
+var o_CR = {};
+function loadCR(baseUrl){
+ var form = document.getElementById("Modify");
+ xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("GET", baseUrl, true);
+ xmlhttp.setRequestHeader("Accept", "application/json");
+ xmlhttp.onreadystatechange = function() {
+ if (xmlhttp.readyState==4 && (xmlhttp.status==200)) {
+ o_CR = JSON.parse(xmlhttp.responseText);
+ form.title.value = o_CR["dcterms:title"];
+ form.description.value = o_CR["dcterms:description"];
+ if (o_CR["dcterms:accessRights"] == "Server") {
+ form.filedAgainst.selectedIndex = 0;
+ } else {
+ form.filedAgainst.selectedIndex = 1;
+ }
+ }
+ };
+ xmlhttp.send(null);
+}
+function modify(baseUrl){
+ var form = document.getElementById("Modify");
+
+ if ((o_CR["dcterms:description"] !== form.description.value) || (o_CR["dcterms:title"] !== form.title.value)
+ || (o_CR["dcterms:accessRights"] !== form.filedAgainst.value))
+ {
+ o_CR["dcterms:description"] = form.description.value;
+ o_CR["dcterms:title"] = form.title.value;
+ o_CR["dcterms:accessRights"] = form.filedAgainst.value;
+
+ var jsonString = JSON.stringify(o_CR);
+ xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("PUT", baseUrl, true);
+ xmlhttp.setRequestHeader("Content-type", "application/json");
+ xmlhttp.setRequestHeader("Content-length", jsonString.length);
+ xmlhttp.onreadystatechange = function() {
+ if (xmlhttp.readyState==4 && (xmlhttp.status==200)) {
+ txt = xmlhttp.responseText;
+ resp = eval('(' + txt + ')');
+ // provide a status message.
+ var oStatus = document.getElementById("status");
+ if (oStatus.hasChildNodes()){
+ oStatus.removeChild(oStatus.childNodes[0]);
+ }
+ oStatus.appendChild(document.createTextNode("Change Request " + resp.ID + " : " + resp.title + " has been modified successfully." ));
+ }
+ };
+ xmlhttp.send(jsonString);
+ }
+}
+
+function ModifyCutOff(baseUrl){
+
+ var form = document.getElementById("ModifyCutOff");
+ xmlhttp = new XMLHttpRequest();
+ xmlhttp.onreadystatechange = function() {
+ if (xmlhttp.readyState==4 && (xmlhttp.status==200)) {
+ txt = xmlhttp.responseText;
+ resp = eval('(' + txt + ')');
+ // provide a status message.
+ var oStatus = document.getElementById("status");
+ if (oStatus.hasChildNodes()){
+ oStatus.removeChild(oStatus.childNodes[0]);
+ }
+ oStatus.appendChild(document.createTextNode("Cut Off Event set at " + resp.event ));
+ }
+ };
+ var postData="";
+
+ if (form.event) {
+ postData += "&event="+encodeURIComponent(form.event.value);
+ }
+
+ xmlhttp.open("POST", baseUrl, true);
+ xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
+ xmlhttp.setRequestHeader("Content-length",postData.length);
+ xmlhttp.send(postData);
+}
+
+function deleteResource(resUrl, currentUrl){
+ xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("DELETE", resUrl, true);
+ xmlhttp.send();
+ xmlhttp.onreadystatechange = function() {
+ if (xmlhttp.readyState==4 && (xmlhttp.status==200)) {
+ var oNode = document.getElementById(resUrl);
+
+ if (oNode.parentNode) {
+ oNode.parentNode.removeChild(oNode);
+ }
+ }
+ }
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/providers b/org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/providers
new file mode 100644
index 0000000..e117bc2
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/providers
@@ -0,0 +1,21 @@
+###############################################################################
+#
+# Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA).
+# © Copyright IBM Corporation 2012. All Rights Reserved.
+# U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+#
+###############################################################################
+
+#Providers
+
+# RDF/XML
+org.eclipse.lyo.oslc4j.provider.jena.OslcRdfXmlProvider
+org.eclipse.lyo.oslc4j.provider.jena.OslcCompactRdfProvider
+org.eclipse.lyo.oslc4j.provider.jena.OslcSimpleRdfXmlArrayProvider
+org.eclipse.lyo.oslc4j.provider.jena.OslcSimpleRdfXmlCollectionProvider
+
+# JSON
+org.eclipse.lyo.oslc4j.provider.json4j.OslcCompactJsonProvider
+org.eclipse.lyo.oslc4j.provider.json4j.OslcRdfJsonArrayProvider
+org.eclipse.lyo.oslc4j.provider.json4j.OslcRdfJsonCollectionProvider
+org.eclipse.lyo.oslc4j.provider.json4j.OslcRdfJsonProvider
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/resources b/org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/resources
new file mode 100644
index 0000000..fe090da
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/resources
@@ -0,0 +1,11 @@
+###############################################################################
+#
+# Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA).
+# © Copyright IBM Corporation 2012, 2013. All Rights Reserved.
+# U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+#
+###############################################################################
+#Resources
+org.eclipse.lyo.rio.trs.resources.BaseResource
+org.eclipse.lyo.rio.trs.resources.TRSResource
+org.eclipse.lyo.rio.trs.resources.ChangeRequestResource \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/web.xml b/org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..080baa0
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA). -->
+<!-- © Copyright IBM Corporation 2012. All Rights Reserved. -->
+<!-- U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. -->
+
+<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>TRS Test App</display-name>
+
+ <servlet>
+ <servlet-name>JAX-RS Services</servlet-name>
+ <servlet-class>
+ org.apache.wink.server.internal.servlet.RestServlet
+ </servlet-class>
+ <init-param>
+ <param-name>applicationConfigLocation</param-name>
+ <param-value>/WEB-INF/providers;/WEB-INF/resources</param-value>
+ </init-param>
+ </servlet>
+
+ <servlet>
+ <servlet-name>Generic TRS</servlet-name>
+ <servlet-class>
+ org.eclipse.lyo.rio.trs.servlet.TRSGeneric
+ </servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>Generic Base</servlet-name>
+ <servlet-class>
+ org.eclipse.lyo.rio.trs.servlet.BaseGeneric
+ </servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>Generic ChangeLog</servlet-name>
+ <servlet-class>
+ org.eclipse.lyo.rio.trs.servlet.ChangeLogGeneric
+ </servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>JAX-RS Services</servlet-name>
+ <url-pattern>/rest/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Generic Base</servlet-name>
+ <url-pattern>/restx/trs/base/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Generic TRS</servlet-name>
+ <url-pattern>/restx/trs/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Generic ChangeLog</servlet-name>
+ <url-pattern>/restx/trs/changelog/*</url-pattern>
+ </servlet-mapping>
+
+</web-app> \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/changerequest_collection_html.jsp b/org.eclipse.lyo.rio.trs/src/main/webapp/changerequest_collection_html.jsp
new file mode 100644
index 0000000..c546ece
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/changerequest_collection_html.jsp
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+
+<%--
+ Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA).
+ © Copyright IBM Corporation 2012, 2013. All Rights Reserved.
+ U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ --%>
+
+<%@page contentType="text/html" language="java" pageEncoding="UTF-8" %>
+<%@page import="org.eclipse.lyo.rio.trs.cm.ChangeRequest"%>
+<%@page import="org.eclipse.lyo.oslc4j.core.model.ResponseInfoArray;" %>
+
+<%
+ ResponseInfoArray<ChangeRequest> changeRequests = (ResponseInfoArray<ChangeRequest>) request.getAttribute("results");
+ Object[] arrCRO = changeRequests.array();
+ String nextPageUri = (String)request.getAttribute("nextPageUri");
+ String currentPageUri = (String)request.getAttribute("currentPageUri");
+ String scriptPath = (String) request.getContextPath()+"/TestApp.js";
+%>
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+ <script type="text/javascript" src='<%= scriptPath %>'>
+ </script>
+ </head>
+ <body onload="">
+
+ <div id="jlip_test-body">
+ <div id="page-index">
+
+ <h1>Query Results</h1>
+
+ <% for (int i = 0; i < arrCRO.length; i++) { %>
+ <% ChangeRequest changeRequest = (ChangeRequest) arrCRO[i]; %>
+ <div id='<%= changeRequest.getAbout() %>'>
+ <p>Summary: <%= changeRequest.getTitle() %><br /><a href="<%= changeRequest.getAbout() %>">
+ <%= changeRequest.getAbout() %></a>
+ <input type="button"
+ value="Delete"
+ onclick="javascript:deleteResource( '<%= changeRequest.getAbout() %>','<%= currentPageUri %>' )">
+ </p>
+ </div>
+ <% } %>
+ <% if (nextPageUri != null) { %><a href="<%= nextPageUri %>">Next Page</a><% } %>
+
+ </div>
+ </div>
+
+
+ <%-- --%>
+
+ </body>
+</html>
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/index.html b/org.eclipse.lyo.rio.trs/src/main/webapp/index.html
new file mode 100644
index 0000000..cbee785
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/index.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+
+<!-- Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA). -->
+<!-- © Copyright IBM Corporation 2012. All Rights Reserved. -->
+<!-- U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. -->
+<!-- -->
+
+<html>
+<body>
+<font face="Arial">
+<h1>TRS Reference Application</h1>
+
+<p>Here are the REST resource endpoints for the base resource and the tracked resource set:</p>
+<ul>
+ <li><a href="rest/trs/base">Base Resources</a></li>
+ <li><a href="rest/trs">Tracked Resource Set</a></li>
+
+ <li><a href="restx/trs/base">Generic Base Resources</a></li>
+ <li><a href="restx/trs">Generic Tracked Resource Set</a></li>
+ <li>EXPERIMENTAL - <a href="CutOffEvent_modify.jsp">Modify Cutoff Event</a></li>
+</ul>
+<br>
+<p>Here are actions you can run for Change Request resources:</p>
+<ul>
+ <li><a href="rest/changeRequests/creator">Create Change Request</a></li>
+ <li><a href="rest/changeRequests">View Change Requests</a></li>
+ <li><a href="rest/changeRequests/populate">Populate Test Data</a> - kick off creation of some sample Change Requests</li>
+</ul>
+
+
+
+<p>View TRS Reference Application <a href="rest">REST Services document</a></p>
+</font>
+</body>
+</html> \ No newline at end of file