Author: ivol37 at gmail.com
Date: Wed Dec 29 09:27:43 2010
New Revision: 552
Log:
[AMDATU-80] Fixed the duplication of the the Path in the URL for REST services
by adding a servlet filter that dispatches requests internally. Also changed
prefix /rest/services to just /rest
Added:
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkServletFilter.java
Modified:
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerRegistryREST.java
trunk/amdatu-authentication/oauth-server/src/main/resources/jsp/authorize.jsp
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/jsp/UserAdminGadget.jsp
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin.js
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/bean/RoleBean.java
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/GroupsResource.java
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/RolesResource.java
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/UsersResource.java
trunk/amdatu-example/course-gadget/src/main/resources/jsp/CourseGadget.jsp
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseResource.java
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthProtectedResource.java
trunk/amdatu-example/oauth/src/main/resources/jsp/3leggedOAuthGadget.jspf
trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/dashboard.js
trunk/amdatu-opensocial/gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/GadgetManagementServiceImpl.java
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
trunk/amdatu-semanticweb/sparqlendpoint/src/main/resources/jsp/SPARQLEndpointGadget.jsp
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/osgi/Activator.java
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkRegistrationServiceImpl.java
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkRestServlet.java
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/RESTTestBase.java
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/OAuthServiceConsumerRegistryTest.java
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/UserAdminRESTTest.java
trunk/integration-tests/src/test/java/org/amdatu/test/integration/util/Login.java
Modified:
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerRegistryREST.java
==============================================================================
---
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerRegistryREST.java
(original)
+++
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerRegistryREST.java
Wed Dec 29 09:27:43 2010
@@ -46,7 +46,7 @@
* This class provides a REST interface on top of the oAuth service consumer
registry
* TODO: This REST API needs to be finalized by adding HTTP caching headers,
authorization checks and
* possibly additional methods.
- *
+ *
* @author ivol
*/
@Path("oauth/consumers")
@@ -54,7 +54,7 @@
// The oAuth service consumer registry
private volatile OAuthServiceConsumerRegistry m_registry;
private volatile LogService m_logService;
-
+
// HTTP caching policy for this REST interface
private static CacheControl m_cacheControl;
static {
@@ -65,7 +65,7 @@
public void start() {
m_logService.log(LogService.LOG_DEBUG, "OAuth Service Consumer
registry REST service started.");
}
-
+
/**
* This method can be used to check the availability of the OAuth Service
Consumer.
* @return The text "OAuth Service Consumer registry online"
@@ -74,12 +74,12 @@
@Produces({MediaType.TEXT_PLAIN})
public String status() {
return "OAuth Service Consumer registry online";
- }
+ }
/**
- * REST interface: GET
/rest/services/oauth/consumers/oauth/consumers/{consumerKey}
+ * REST interface: GET /rest/oauth/consumers/{consumerKey}
* Returns the requested consumer in application/xml or application/json
format.
- *
+ *
* @param consumerKey The key of the consumer to retrieve.
* @return The consumer matching the key in xml or json format
*/
@@ -107,9 +107,9 @@
}
/**
- * REST interface: PUT /rest/services/oauth/consumers/oauth/consumers
+ * REST interface: PUT /rest/oauth/consumers
* Adds a new consumer with the properties of the posted values in
application/xml or application/json format.
- *
+ *
* @return The http response object
*/
@PUT
@@ -128,9 +128,9 @@
}
/**
- * REST interface: PUT
/rest/services/oauth/consumers/oauth/consumers/{consumerKey}
+ * REST interface: PUT /rest/oauth/consumers/{consumerKey}
* Updates an existing consumer with the properties of the posted values
in application/xml or application/json format.
- *
+ *
* @param consumerKey The key of the consumer to update.
* @return The http response object
*/
@@ -151,9 +151,9 @@
}
/**
- * REST interface: PUT /rest/services/oauth/consumers/oauth/consumers
+ * REST interface: PUT /rest/oauth/consumers
* Adds a new consumer with the properties of the posted values in
application/xml or application/json format.
- *
+ *
* @return The http response object
*/
@DELETE
Modified:
trunk/amdatu-authentication/oauth-server/src/main/resources/jsp/authorize.jsp
==============================================================================
---
trunk/amdatu-authentication/oauth-server/src/main/resources/jsp/authorize.jsp
(original)
+++
trunk/amdatu-authentication/oauth-server/src/main/resources/jsp/authorize.jsp
Wed Dec 29 09:27:43 2010
@@ -3,9 +3,9 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="baseUrl"
value="http://${pageContext.request.serverName}:${pageContext.request.serverPort}"/>
-<c:set var="loginUrl"
value="${baseUrl}/rest/services/authorization/authorization/login"/>
-<c:set var="logoutUrl"
value="${baseUrl}/rest/services/authorization/authorization/logout"/>
-<c:set var="statusUrl"
value="${baseUrl}/rest/services/authorization/authorization/status"/>
+<c:set var="loginUrl" value="${baseUrl}/rest/authorization/login"/>
+<c:set var="logoutUrl" value="${baseUrl}/rest/authorization/logout"/>
+<c:set var="statusUrl" value="${baseUrl}/rest/authorization/status"/>
<%
String appDesc = (String)request.getAttribute("CONS_DESC");
@@ -23,17 +23,17 @@
<title>Amdatu OAuth Provider</title>
<script type="text/javascript"
src="/dashboard/static/js/lib/jquery-1.4.2.min.js"></script>
</head>
-
+
<body>
<h3>Access Request</h3>
<hr>
<p>
- <b><%=appDesc%></b> is requesting access to your amdatu.org account.
+ <b><%=appDesc%></b> is requesting access to your amdatu.org account.
Do you want to allow this application to access your account information?
</p>
<p>Before access can be granted you must login with your amdatu.org
account.</p>
<hr>
-
+
<div id="login" style="display:none;visibility:hidden">
<p>
<table width="95%">
@@ -50,11 +50,11 @@
</table>
</p>
</div>
-
+
<div id="grantaccess" style="display:none;visibility:hidden">
<div id="welcome_username"></div><br/>
Do you want to allow access to <%=appDesc%>?<br/><br/>
-
+
<form name="authorizeForm" action="/oauth-server/authorizetoken"
method="POST">
<input type="hidden" name="oauth_token" value="<%= token %>"/>
<input type="hidden" name="oauth_callback" value="<%= callback %>"/>
@@ -62,7 +62,7 @@
<input type="submit" name="Authorize" value="Grant access"/>
</form>
</div>
-
+
<div id="accessdenied" style="display:none;visibility:hidden">
<p>Access to <%=appDesc%> is denied.</p>
</div>
@@ -76,26 +76,26 @@
document.getElementById("grantaccess").style.visibility = "hidden";
document.getElementById("grantaccess").style.display = "none";
document.getElementById("accessdenied").style.visibility = "hidden";
- document.getElementById("accessdenied").style.display = "none";
+ document.getElementById("accessdenied").style.display = "none";
}
-
+
function showGrantAccess() {
document.getElementById("login").style.visibility = "hidden";
document.getElementById("login").style.display = "none";
document.getElementById("grantaccess").style.visibility = "";
document.getElementById("grantaccess").style.display = "";
document.getElementById("accessdenied").style.visibility = "hidden";
- document.getElementById("accessdenied").style.display = "none";
+ document.getElementById("accessdenied").style.display = "none";
}
-
+
function showAccessDenied() {
document.getElementById("login").style.visibility = "hidden";
document.getElementById("login").style.display = "none";
document.getElementById("grantaccess").style.visibility = "hidden";
document.getElementById("grantaccess").style.display = "none";
document.getElementById("accessdenied").style.visibility = "";
- document.getElementById("accessdenied").style.display = "";
- }
+ document.getElementById("accessdenied").style.display = "";
+ }
function getLoginStatus() {
var url = "${statusUrl}";
@@ -112,9 +112,9 @@
}
}
}
- );
+ );
}
-
+
function login() {
var postdata = {
username : document.getElementById('username').value,
@@ -141,9 +141,9 @@
}
}
}
- );
+ );
}
-
+
function logout() {
var postdata = {
username : document.getElementById('username').value,
@@ -158,19 +158,19 @@
dataType: "json",
async:true
}
- );
+ );
}
-
+
function denyAccess() {
logout();
showAccessDenied();
}
-
+
function handleLoginSuccessfull(username) {
showGrantAccess();
document.getElementById("welcome_username").innerHTML = "Welcome <b>" +
username + "</b>!";
}
-
+
function submitenter(field, e) {
var keycode;
if (window.event) {
@@ -187,7 +187,7 @@
} else {
return true;
}
- }
-
+ }
+
getLoginStatus();
</script>
Modified:
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp
==============================================================================
---
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp
(original)
+++
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp
Wed Dec 29 09:27:43 2010
@@ -2,7 +2,7 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="baseUrl"
value="http://${pageContext.request.serverName}:${pageContext.request.serverPort}"/>
-<c:set var="baseRestUrl"
value="${baseUrl}/rest/services/authorization/authorization"/>
+<c:set var="baseRestUrl" value="${baseUrl}/rest/authorization"/>
<c:set var="gadgetBaseUrl" value="${baseUrl}/gadget/login"/>
<?xml version="1.0" encoding="UTF-8" ?>
@@ -26,23 +26,23 @@
-->
<Module>
- <ModulePrefs
- title="Amdatu Login Gadget"
+ <ModulePrefs
+ title="Amdatu Login Gadget"
description="Provides login/logout functionality for Amdatu users"
author="Ivo Ladage-van Doorn"
screenshot="${gadgetBaseUrl}/static/images/login.png"
- icon="${gadgetBaseUrl}/static/images/login.png"
+ icon="${gadgetBaseUrl}/static/images/login.png"
height="400">
- <Require feature="osapi"/>
- <Require feature="dynamic-height"/>
+ <Require feature="osapi"/>
+ <Require feature="dynamic-height"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<link rel="stylesheet" href="/dashboard/static/css/dashboard.css">
-
+
<script type="text/javascript"
src="/dashboard/static/js/lib/jquery-1.4.2.min.js"></script>
<script type="text/javascript"
src="/dashboard/static/js/lib/jquery-ui-1.8.2.custom.min.js"></script>
-
+
<div id="login" style="display:none;visibility:hidden">
<p>
You are currently not logged in<br/><br/>
@@ -62,7 +62,7 @@
</p>
</div>
<div id="logout" style="display:none;visibility:hidden"></div>
-
+
<script type="text/javascript">
function showLoginBox() {
document.getElementById("login").style.visibility = "";
@@ -71,7 +71,7 @@
document.getElementById("logout").style.display = "none";
gadgets.window.adjustHeight();
}
-
+
function showLogoutBox(username) {
document.getElementById("login").style.visibility = "hidden";
document.getElementById("login").style.display = "none";
@@ -82,13 +82,13 @@
"<input type='submit' value='Logout' onclick='javascript:logout()'
/></p>";
gadgets.window.adjustHeight();
}
-
+
function login() {
var postdata = {
username : document.getElementById('username').value,
password : document.getElementById('password').value
};
-
+
var url = "${baseRestUrl}/login";
jQuery.ajax({
url: url,
@@ -109,15 +109,15 @@
}
}
}
- );
+ );
}
-
+
function logout() {
var postdata = {
username : document.getElementById('username').value,
password : document.getElementById('password').value
};
-
+
var url = "${baseRestUrl}/logout";
jQuery.ajax({
url: url,
@@ -135,9 +135,9 @@
}
}
}
- );
+ );
}
-
+
function getLoginStatus() {
var url = "${baseRestUrl}/status";
jQuery.ajax({
@@ -153,9 +153,9 @@
}
}
}
- );
+ );
}
-
+
function submitenter(field, e) {
var keycode;
if (window.event) {
@@ -165,7 +165,7 @@
} else {
return true;
}
-
+
if (keycode == 13) {
login();
return false;
@@ -173,7 +173,7 @@
return true;
}
}
-
+
getLoginStatus();
</script>
]]>
Modified:
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/jsp/UserAdminGadget.jsp
==============================================================================
---
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/jsp/UserAdminGadget.jsp
(original)
+++
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/jsp/UserAdminGadget.jsp
Wed Dec 29 09:27:43 2010
@@ -2,7 +2,7 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="baseUrl"
value="http://${pageContext.request.serverName}:${pageContext.request.serverPort}"/>
-<c:set var="restUrl" value="${baseUrl}/rest/services"/>
+<c:set var="restUrl" value="${baseUrl}/rest"/>
<c:set var="gadgetBaseUrl" value="${baseUrl}/gadget/useradmin"/>
<c:set var="imgBaseUrl" value="${baseUrl}/gadget/useradmin/static/images" />
@@ -11,17 +11,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
- <ModulePrefs
- title="Amdatu Role Admin Gadget"
+ <ModulePrefs
+ title="Amdatu Role Admin Gadget"
description="Role and Group management"
author="Ivo Ladage-van Doorn"
screenshot="${gadgetBaseUrl}/static/images/useradmin.png"
- icon="${gadgetBaseUrl}/static/images/useradmin.png"
+ icon="${gadgetBaseUrl}/static/images/useradmin.png"
height="400">
-
- <Require feature="osapi"/>
+
+ <Require feature="osapi"/>
<Require feature="dynamic-height"/>
-
+
<Locale messages="${gadgetBaseUrl}/static/labels/useradmin_ALL_ALL.xml" />
</ModulePrefs>
<Content type="html">
@@ -29,7 +29,7 @@
<link rel="stylesheet" href="/dashboard/static/css/dashboard.css">
<link rel="stylesheet" href="${cssBaseUrl}/useradmin.css">
<link rel="stylesheet" href="${cssBaseUrl}/tabs.css" type="text/css"
media="screen" />
-
+
<script type="text/javascript"
src="/dashboard/static/js/lib/jquery-1.4.2.min.js"></script>
<script type="text/javascript"
src="/dashboard/static/js/lib/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript"
src="${jsBaseUrl}/useradmin_rest.js"></script>
@@ -37,7 +37,7 @@
<script type="text/javascript" src="${jsBaseUrl}/select_role.js"></script>
<script type="text/javascript" src="${jsBaseUrl}/util.js"></script>
<script type="text/javascript" src="${jsBaseUrl}/useradmin.js"></script>
-
+
<p>
<div id="container">
<ul class="menu">
@@ -45,12 +45,12 @@
<li id="groups_tab">__MSG_groups__</li>
<li id="members_tab"
style="display:none;visibility:hidden">__MSG_members__</li>
</ul>
-
+
<span class="clear"></span>
-
+
<div class="content users_tab">
<div id="user"></div><br/>
-
+
<input type="button" value="__MSG_add_user__" id="add_user_button"
onclick="javascript:showNewRole();"/>
<fieldset id="user_details" style="display:none;visibility:hidden">
@@ -64,14 +64,14 @@
<input type="button" value="__MSG_cancel__"
onclick="javascript:showAddButton();"/>
<input type="hidden" id="user_method" value="update"/>
<div id="user_message"></div>
- </fieldset>
+ </fieldset>
</div>
-
+
<div class="content groups_tab">
<div id="group"></div><br/>
-
+
<input type="button" value="__MSG_add_group__" id="add_group_button"
onclick="javascript:showNewRole();"/>
-
+
<fieldset id="group_details" style="display:none;visibility:hidden">
<legend id="group_details_legend">__MSG_details__</legend>
<table width="95%">
@@ -86,14 +86,14 @@
</fieldset>
<br/>
</div>
-
+
<div class="content members_tab">
<div id="member"></div>
</div>
</div>
</p>
-
- <script type="text/javascript">
+
+ <script type="text/javascript">
var baseUrl ="${baseUrl}";
var restUrl = "${restUrl}";
var imgBaseUrl = "${imgBaseUrl}";
Modified:
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin.js
==============================================================================
---
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin.js
(original)
+++
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin.js
Wed Dec 29 09:27:43 2010
@@ -5,7 +5,7 @@
var addToBasicMembers;
var prefs = new gadgets.Prefs();
-
+
// Callback function invoked when roles have been loaded
function onRolesLoaded(response) {
if (response.rc == 200) {
@@ -32,7 +32,7 @@
} else {
currentGroupsUrl = currentUrl;
}
- }
+ }
}
var html = "";
@@ -46,7 +46,7 @@
nameLabel = prefs.getMsg('group_name');
}
html += "<table class='stripeMe'>";
- html += "<tr><th width='80%'>" + nameLabel + "</th><th width='20%'>" +
prefs.getMsg('delete') + "</th></tr>";
+ html += "<tr><th width='80%'>" + nameLabel + "</th><th width='20%'>" +
prefs.getMsg('delete') + "</th></tr>";
for (i=0; i<roles.length; i++) {
var role = roles[i];
var link = role["link"].href;
@@ -63,7 +63,7 @@
html += "<td><center>" + prefs.getMsg('results_nav_1') + " <b>" +
pageStartIndex + "-" + pageEndIndex + "</b> ";
html += prefs.getMsg('results_nav_2') + " <b>" + resultCount +
"</b></center></td>";
html += "<td>" + next + "</td>";
- html += "<td>" + end + "</td></table>";
+ html += "<td>" + end + "</td></table>";
var resultDiv;
if (currentView == "user") {
@@ -83,14 +83,14 @@
document.getElementById(currentView).innerHTML = html;
} else {
showError(prefs.getMsg('unexpected_error') + response.errors);
- }
+ }
gadgets.window.adjustHeight();
-}
+}
// Callback function invoked when one specific role details have been loaded
function onRoleLoaded(response) {
if (response.rc == 200) {
- var role = response.data["roles"];
+ var role = response.data["roles"];
document.getElementById(currentView + '_name').value = role["name"];
if (currentView == "user") {
var roles = ensureArray(role["impliedRoles"]);
@@ -123,7 +123,7 @@
showError(prefs.getMsg('accessdenied'));
} else {
showError(prefs.getMsg('unexpected_error') + response.errors);
- }
+ }
}
function renderMembers(members) {
@@ -147,7 +147,7 @@
showError(prefs.getMsg('accessdenied'));
} else {
showError(prefs.getMsg('unexpected_error') + response.errors);
- }
+ }
}
// Callback function invoked when the the role has been removed
@@ -162,7 +162,7 @@
showError(prefs.getMsg('accessdenied'));
} else {
alert(prefs.getMsg('unexpected_error') + response.errors);
- }
+ }
}
function onRoleAdded(response) {
@@ -177,14 +177,14 @@
showError(prefs.getMsg('accessdenied'));
} else {
showError(prefs.getMsg('unexpected_error') + response.errors);
- }
+ }
}
function onMemberAdded(response) {
if (response.rc == 200) {
// Role added successfully
showInfo(prefs.getMsg('member_added'));
- var url = escape(restUrl + "/groups/groups/" +
encodeURIComponent(selectedRole));
+ var url = escape(restUrl + "/groups/" + encodeURIComponent(selectedRole));
loadRole(url, onRoleLoaded);
gadgets.window.adjustHeight();
} else if (response.rc == 304) {
@@ -193,14 +193,14 @@
showError(prefs.getMsg('accessdenied'));
} else {
showError(prefs.getMsg('unexpected_error') + response.errors);
- }
+ }
}
function onMemberRemoved(response) {
if (response.rc == 200) {
// Member removed successfully
showInfo(prefs.getMsg('member_removed'));
- var url = escape(restUrl + "/groups/groups/" +
encodeURIComponent(selectedRole));
+ var url = escape(restUrl + "/groups/" + encodeURIComponent(selectedRole));
loadRole(url, onRoleLoaded);
gadgets.window.adjustHeight();
} else if (response.rc == 304) {
@@ -209,7 +209,7 @@
showError(prefs.getMsg('accessdenied'));
} else {
showError(prefs.getMsg('unexpected_error') + response.errors);
- }
+ }
}
function showAddMember(addToBasic) {
@@ -223,7 +223,7 @@
function confirmDeleteMember(role) {
var removeFromRole = encodeURIComponent(selectedRole);
var removeRole = encodeURIComponent(unescape(role));
- var url = baseUrl + "/rest/services/groups/groups/" + removeFromRole +
"/members/" + removeRole;
+ var url = baseUrl + "/rest/groups/" + removeFromRole + "/members/" +
removeRole;
deleteMember(url, onMemberRemoved);
}
@@ -231,7 +231,7 @@
var addToRole = encodeURIComponent(selectedRole);
var addRole = encodeURIComponent(unescape(role));
if (addToBasicMembers) {
- var url = baseUrl + "/rest/services/groups/groups/" + addToRole +
"/basicmembers/" + addRole;
+ var url = baseUrl + "/rest/groups/" + addToRole + "/basicmembers/" +
addRole;
} else {
// Sanity check: if you add a required member to Administrators, only this
role has permission
// for user amdin!
@@ -242,7 +242,7 @@
return;
}
}
- var url = baseUrl + "/rest/services/groups/groups/" + addToRole +
"/requiredmembers/" + addRole;
+ var url = baseUrl + "/rest/groups/" + addToRole + "/requiredmembers/" +
addRole;
}
addMember(url, onMemberAdded);
}
@@ -253,7 +253,7 @@
if (currentView == "user") {
var newpassword = document.getElementById('password').value
- var url = baseUrl + "/rest/services/users/users/" + name;
+ var url = baseUrl + "/rest/users/" + name;
if (method == "update") {
url += "/credentials/password";
updatePassword(url, onPasswordChanged, newpassword);
@@ -261,7 +261,7 @@
addRole(url, onRoleAdded);
}
} else {
- var url = baseUrl + "/rest/services/groups/groups/" + name;
+ var url = baseUrl + "/rest/groups/" + name;
addRole(url, onRoleAdded);
}
}
@@ -364,22 +364,22 @@
}
function switchToUsersView() {
- var url = restUrl + "/users/users?maxResults=5";
+ var url = restUrl + "/users?maxResults=5";
currentUrl = currentUsersUrl;
loadRoles(url, onRolesLoaded);
}
function switchToGroupsView() {
- var url = restUrl + "/groups/groups?maxResults=5";
+ var url = restUrl + "/groups?maxResults=5";
currentUrl = currentGroupsUrl;
loadRoles(url, onRolesLoaded);
}
function switchToMembersView() {
- var url = restUrl + "/roles/roles?maxResults=10";
+ var url = restUrl + "/roles?maxResults=10";
loadRoles(url, onRolesLoadedForSelection);
}
$(document).ready(function(){
- loadRoles(restUrl + "/users/users?maxResults=5", onRolesLoaded);
+ loadRoles(restUrl + "/users?maxResults=5", onRolesLoaded);
});
Modified:
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/bean/RoleBean.java
==============================================================================
---
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/bean/RoleBean.java
(original)
+++
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/bean/RoleBean.java
Wed Dec 29 09:27:43 2010
@@ -124,11 +124,11 @@
String name = role.getName();
roleBean.setName(name);
roleBean.setType(role.getType());
- String href = "/rest/services/";
+ String href = "/rest/";
if (role.getType() == Role.USER) {
String[] impliedRoles = userAdmin.getAuthorization((User)
role).getRoles();
roleBean.setImpliedRoles(impliedRoles);
- href += "users/users/" + name;
+ href += "users/" + name;
}
else {
if (loadMembers) {
@@ -150,7 +150,7 @@
}
roleBean.setBasicMembers(basicMembers);
}
- href += "groups/groups/" + name;
+ href += "groups/" + name;
}
// Use JAX-RS URI builder to properly encode the href
href = UriBuilder.fromPath(href).build().toString();
Modified:
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/GroupsResource.java
==============================================================================
---
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/GroupsResource.java
(original)
+++
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/GroupsResource.java
Wed Dec 29 09:27:43 2010
@@ -35,13 +35,13 @@
/**
* REST service for managing Groups based on the UserAdmin OSGi specification
(see chapter 107 of the Enterprise OSGi
* spec version 4.1). This REST service provides the following methods:
<code><pre>
- * GET /rest/services/groups/groups -> returns all users
- * GET /rest/services/groups/groups/{name} -> Returns the group with the
specified name
- * PUT /rest/services/groups/groups/{name} -> Creates a group with the
specified name
- * PUT /rest/services/groups/groups/{name}/basicmembers/{memberName} -> Adds a
member to the group
- * PUT /rest/services/groups/groups/{name}/requiredmembers/{memberName} ->
Adds a required member to the group
- * DELETE /rest/services/groups/groups/{name} -> Deletes the group with the
specified name
- * DELETE /rest/services/groups/groups/{name}/members/{memberName} -> Deletes
a member from group
+ * GET /rest/groups -> returns all users
+ * GET /rest/groups/{name} -> Returns the group with the specified name
+ * PUT /rest/groups/{name} -> Creates a group with the specified name
+ * PUT /rest/groups/{name}/basicmembers/{memberName} -> Adds a member to the
group
+ * PUT /rest/groups/{name}/requiredmembers/{memberName} -> Adds a required
member to the group
+ * DELETE /rest/groups/{name} -> Deletes the group with the specified name
+ * DELETE /rest/groups/{name}/members/{memberName} -> Deletes a member from
group
* </pre></code>
* @author ivol
*/
@@ -61,7 +61,7 @@
/**
* Returns all groups that match the specified filter options. This method
can be invoked by making the following
* REST call:<code><pre>
- * GET
/rest/services/groups/groups?filter={filter}&sortOrder={sortOrder}&startIndex={startIndex}&maxResults={maxResults}
+ * GET
/rest/groups?filter={filter}&sortOrder={sortOrder}&startIndex={startIndex}&maxResults={maxResults}
* </pre></code> For available path and query parameters, see below.
* @param filter Filter that the name of the group must match. A group
name is considered to match the specified
* filter if the filter equals the group name or the filter is
a substring of the group name.
@@ -104,7 +104,7 @@
/**
* Returns the group with the specified name. This method can be invoked
by making the following REST call:
* <code><pre>
- * GET /rest/services/groups/groups/{name}
+ * GET /rest/groups/{name}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the group to retrieve
* @return a 400 response in case the group was found and returned. It
returns this JSON string: <code><pre>
@@ -130,7 +130,7 @@
/**
* Creates the group with the specified name. This method can be invoked
by making the following REST call:
* <code><pre>
- * PUT /rest/services/groups/groups/{name}
+ * PUT /rest/groups/{name}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the group to create
* @return a 400 response in case the group was created.<br/>
@@ -150,7 +150,7 @@
/**
* Sets a credential for the group with the specified name. This method
can be invoked by making the following REST
* call: <code><pre>
- * PUT /rest/services/groups/groups/{name}/credentials/{key}
+ * PUT /rest/groups/{name}/credentials/{key}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the group to set the credential for
* @param key The key of the credential to set
@@ -172,7 +172,7 @@
/**
* Sets a property for the group with the specified name. This method can
be invoked by making the following REST
* call: <code><pre>
- * PUT /rest/services/groups/groups/{name}/properties/{key}
+ * PUT /rest/groups/{name}/properties/{key}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the group to set the property for
* @param key The key of the property to set
@@ -194,7 +194,7 @@
/**
* Adds a basic member to the group with the specified name. This method
can be invoked by making the following REST
* call: <code><pre>
- * PUT /rest/services/groups/groups/{name}/basicmembers/{memberName}
+ * PUT /rest/groups/{name}/basicmembers/{memberName}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the group to add the member to
* @param memberName Name of the basic member (User or Group) to add
@@ -216,7 +216,7 @@
/**
* Adds a required member to the group with the specified name. This
method can be invoked by making the following
* REST call: <code><pre>
- * PUT /rest/services/groups/groups/{name}/requiredmembers/{memberName}
+ * PUT /rest/groups/{name}/requiredmembers/{memberName}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the group to add the member to
* @param memberName Name of the required member (User or Group) to add
@@ -238,7 +238,7 @@
/**
* Removes the group with the specified name. This method can be invoked
by making the following REST call:
* <code><pre>
- * DELETE /rest/services/groups/groups/{name}
+ * DELETE /rest/groups/{name}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the group to delete
* @return a 400 response in case the group was deleted.<br/>
@@ -257,7 +257,7 @@
/**
* Removes the member (basic or required) from the group with the
specified names. This method can be invoked by
* making the following REST call: <code><pre>
- * DELETE /rest/services/groups/groups/{name}/members/{memberName}
+ * DELETE /rest/groups/{name}/members/{memberName}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the group to remove the member from
* @param memberName Name of the member (User or Group) to remove
@@ -302,6 +302,6 @@
}
protected String getBaseUrl() {
- return "/rest/services/groups/groups";
+ return "/rest/groups";
}
}
Modified:
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/RolesResource.java
==============================================================================
---
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/RolesResource.java
(original)
+++
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/RolesResource.java
Wed Dec 29 09:27:43 2010
@@ -44,7 +44,7 @@
/**
* Returns all users that match the specified filter options. This method
can be invoked by making the following
* REST call:<code><pre>
- * GET
/rest/services/users/users?filter={filter}&sortOrder={sortOrder}&startIndex={startIndex}&maxResults={maxResults}
+ * GET
/rest/users?filter={filter}&sortOrder={sortOrder}&startIndex={startIndex}&maxResults={maxResults}
* </pre></code> For available path and query parameters, see below.
* @param filter Filter that the name of the user must match. A user name
is considered to match the specified
* filter if the filter equals the user name or the filter is a
substring of the user name.
@@ -85,6 +85,6 @@
@Override
protected String getBaseUrl() {
- return "/rest/services/roles/roles";
+ return "/rest/roles";
}
}
Modified:
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/UsersResource.java
==============================================================================
---
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/UsersResource.java
(original)
+++
trunk/amdatu-authorization/useradmin-rest/src/main/java/org/amdatu/authorization/useradmin/rest/service/UsersResource.java
Wed Dec 29 09:27:43 2010
@@ -36,10 +36,10 @@
/**
* REST service for managing Users based on the UserAdmin OSGi specification
(see chapter 107 of the Enterprise OSGi
* spec version 4.1). This REST service provides the following methods:
<code><pre>
- * GET /rest/services/users/users -> returns all users
- * GET /rest/services/groups/groups/{name} -> Returns the group with the
specified name
- * PUT /rest/services/groups/groups/{name} -> Creates a group with the
specified name
- * DELETE /rest/services/groups/groups/{name} -> Deletes the group with the
specified name
+ * GET /rest/users -> returns all users
+ * GET /rest/groups/{name} -> Returns the group with the specified name
+ * PUT /rest/groups/{name} -> Creates a group with the specified name
+ * DELETE /rest/groups/{name} -> Deletes the group with the specified name
* </pre></code>
* @author ivol
*/
@@ -59,7 +59,7 @@
/**
* Returns all users that match the specified filter options. This method
can be invoked by making the following
* REST call:<code><pre>
- * GET
/rest/services/users/users?filter={filter}&sortOrder={sortOrder}&startIndex={startIndex}&maxResults={maxResults}
+ * GET
/rest/users?filter={filter}&sortOrder={sortOrder}&startIndex={startIndex}&maxResults={maxResults}
* </pre></code> For available path and query parameters, see below.
* @param filter Filter that the name of the user must match. A user name
is considered to match the specified
* filter if the filter equals the user name or the filter is a
substring of the user name.
@@ -101,7 +101,7 @@
/**
* Returns the user with the specified name. This method can be invoked by
making the following REST call:
* <code><pre>
- * GET /rest/services/users/users/{name}
+ * GET /rest/users/{name}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the user to retrieve
* @return a 400 response in case the user was found and returned. It
returns this JSON string: <code><pre>
@@ -125,7 +125,7 @@
/**
* Creates the user with the specified name. This method can be invoked by
making the following REST call:
* <code><pre>
- * PUT /rest/services/users/users/{name}
+ * PUT /rest/users/{name}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the user to create
* @return a 400 response in case the user was created.<br/>
@@ -145,7 +145,7 @@
/**
* Sets a credential for the user with the specified name. This method can
be invoked by making the following REST
* call: <code><pre>
- * PUT /rest/services/users/users/{name}/credentials/{key}
+ * PUT /rest/users/{name}/credentials/{key}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the user to set the credential for
* @param key The key of the credential to set
@@ -167,7 +167,7 @@
/**
* Sets a property for the user with the specified name. This method can
be invoked by making the following REST
* call: <code><pre>
- * PUT /rest/services/users/users/{name}/properties/{key}
+ * PUT /rest/users/{name}/properties/{key}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the user to set the property for
* @param key The key of the property to set
@@ -189,7 +189,7 @@
/**
* Removes the user with the specified name. This method can be invoked by
making the following REST call:
* <code><pre>
- * DELETE /rest/services/users/users/{name}
+ * DELETE /rest/users/{name}
* </pre></code> For available path and query parameters, see below.
* @param name Name of the user to delete
* @return a 400 response in case the user was deleted.<br/>
@@ -206,6 +206,6 @@
}
protected String getBaseUrl() {
- return "/rest/services/users/users";
+ return "/rest/users";
}
}
Modified:
trunk/amdatu-example/course-gadget/src/main/resources/jsp/CourseGadget.jsp
==============================================================================
--- trunk/amdatu-example/course-gadget/src/main/resources/jsp/CourseGadget.jsp
(original)
+++ trunk/amdatu-example/course-gadget/src/main/resources/jsp/CourseGadget.jsp
Wed Dec 29 09:27:43 2010
@@ -25,13 +25,13 @@
<c:set var="gadgetBaseUrl" value="${baseUrl}/examples/gadget/course"/>
<Module>
- <ModulePrefs
- title="Course Gadget"
- description="Displays a list of available courses for the current user"
+ <ModulePrefs
+ title="Course Gadget"
+ description="Displays a list of available courses for the current user"
author="Ivo Ladage-van Doorn"
screenshot="${gadgetBaseUrl}/static/images/course.gif"
icon="${gadgetBaseUrl}/static/images/course.gif">
-
+
<Require feature="opensocial-0.9"/>
<Require feature="osapi"/>
<Require feature="oauthpopup" />
@@ -42,7 +42,7 @@
<Access url="${baseUrl}/oauth-server/accesstoken" />
<Authorization url="${baseUrl}/oauth-server/authorizetoken" />
</Service>
- </OAuth>
+ </OAuth>
</ModulePrefs>
<Content type="html">
<![CDATA[
@@ -51,7 +51,7 @@
/**
* Request for course information.
*/
- function fetchData() {
+ function fetchData() {
// FIXME: this shoud have been osapi.http as defined in opensocial
spec 0.9+, but shindig does
// not (yet) implement it
var params = {};
@@ -60,14 +60,14 @@
params[gadgets.io.RequestParameters.AUTHORIZATION] =
gadgets.io.AuthorizationType.OAUTH;
params[gadgets.io.RequestParameters.OAUTH_SERVICE_NAME] = "Course
example gadget";
params[gadgets.io.RequestParameters.OAUTH_USE_TOKEN] = "if_available";
- var url = "${baseUrl}/rest/services/course/course?getCourses";
+ var url = "${baseUrl}/rest/course?getCourses";
gadgets.io.makeRequest(url, onLoadCourses, params);
}
-
+
function get(x) {
return document.getElementById(x);
}
-
+
function showOneSection(toshow) {
var sections = [ 'courses', 'approval', 'waiting' ];
for (var i=0; i < sections.length; ++i) {
@@ -93,7 +93,7 @@
var courseList = jsonData["courselist"];
var user = courseList["user"];
if (courseList && courseList["course"] &&
courseList["course"].length > 0) {
- var courses = courseList["course"];
+ var courses = courseList["course"];
var html = "<p>Overview of available courses for " + user +
":</p><ul>";
for (i=0; i<courses.length;i++) {
var course = courses[i];
@@ -111,14 +111,14 @@
}
document.getElementById('courses').innerHTML = html;
gadgets.window.adjustHeight();
-
+
};
gadgets.util.registerOnLoadHandler(fetchData);
</script>
-
+
<div id="courses"></div>
-
+
]]>
</Content>
</Module>
Modified:
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseResource.java
==============================================================================
---
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseResource.java
(original)
+++
trunk/amdatu-example/course-service/src/main/java/org/amdatu/example/course/service/service/CourseResource.java
Wed Dec 29 09:27:43 2010
@@ -51,7 +51,7 @@
/**
* REST resource that handles REST calls to retrieve information about
particular courses. Courses can be requested
- * using REST call:
http://localhost:3737/rest/services/course/course?getCourses
+ * using REST call: http://localhost:3737/rest/course?getCourses
* @author ivol
*/
@Path("course")
@@ -68,7 +68,7 @@
// Instance variables
private List<String> m_cachedUrls = new ArrayList<String>();
private Component m_httpContextComponent;
-
+
// HTTP caching policy for this REST interface
private static CacheControl m_cacheControl;
static {
Modified:
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthProtectedResource.java
==============================================================================
---
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthProtectedResource.java
(original)
+++
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthProtectedResource.java
Wed Dec 29 09:27:43 2010
@@ -40,10 +40,10 @@
import org.osgi.service.log.LogService;
/**
- * Full path to this resource becomes: /rest/services/resource/resource
- *
+ * Full path to this resource becomes: /rest/resource
+ *
* @author ivol
- *
+ *
*/
@Path("resource")
public class OAuthProtectedResource implements DummyInterface {
@@ -57,7 +57,7 @@
// Disable cache completely
CacheControl cc = new CacheControl();
cc.setNoCache(true);
-
+
try {
String response = "<p>oAuth validation successfull. OAuth
parameters received by service provider:<br/><br/>";
response += "<table><tr><th align=\"left\">parameter</th><th
align=\"left\">value</th></tr>";
Modified:
trunk/amdatu-example/oauth/src/main/resources/jsp/3leggedOAuthGadget.jspf
==============================================================================
--- trunk/amdatu-example/oauth/src/main/resources/jsp/3leggedOAuthGadget.jspf
(original)
+++ trunk/amdatu-example/oauth/src/main/resources/jsp/3leggedOAuthGadget.jspf
Wed Dec 29 09:27:43 2010
@@ -23,13 +23,13 @@
* under the License.
-->
<Module>
- <ModulePrefs
- title="3-legged OAuth Example Gadget"
+ <ModulePrefs
+ title="3-legged OAuth Example Gadget"
description="Displays information protected by 3-legged oAuth"
author="Ivo Ladage-van Doorn"
screenshot="/examples/oauth/static/img/oauth_logo.png"
icon="/examples/oauth/static/img/oauth_logo.png">
-
+
<Require feature="opensocial-0.9"/>
<Require feature="oauthpopup" />
<Require feature="dynamic-height"/>
@@ -39,12 +39,12 @@
<Access url="${baseUrl}/oauth-server/accesstoken" />
<Authorization url="${baseUrl}/oauth-server/authorizetoken" />
</Service>
- </OAuth>
+ </OAuth>
</ModulePrefs>
<Content type="html">
<![CDATA[
<link rel="stylesheet" href="/dashboard/static/css/dashboard.css">
-
+
<div id="main" style="display: none">
</div>
@@ -81,7 +81,7 @@
}
function fetchData() {
- var url = "${baseUrl}/rest/services/resource/resource";
+ var url = "${baseUrl}/rest/resource";
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] =
gadgets.io.ContentType.TEXT;
params[gadgets.io.RequestParameters.AUTHORIZATION] =
gadgets.io.AuthorizationType.OAUTH;
@@ -117,7 +117,7 @@
gadgets.util.registerOnLoadHandler(fetchData);
</script>
-
+
]]>
</Content>
</Module>
Modified:
trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/dashboard.js
==============================================================================
--- trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/dashboard.js
(original)
+++ trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/dashboard.js
Wed Dec 29 09:27:43 2010
@@ -21,12 +21,12 @@
layoutClass: 'layout',
loadingHtml: '<div class="loading"><img alt="Loading, please wait"
src="/dashboard/static/img/loading.gif" /><p>Loading</p></div>',
json_data : {
- url: "/rest/services/gadgetstore/gadgetstore/gadgets/mine"
+ url: "/rest/gadgetstore/gadgets/mine"
},
addWidgetSettings: {
- widgetDirectoryUrl:"/rest/services/gadgetstore/gadgetstore/categories"
+ widgetDirectoryUrl:"/rest/gadgetstore/categories"
},
- layouts :
+ layouts :
[
{ title: "Layout1",
id: "layout1",
@@ -53,17 +53,17 @@
image: "/dashboard/static/img/layout5.png",
classname: 'layout-aaa'
}
- ]
+ ]
}); // end dashboard call
-
+
var my = {};
my.widgets = dashboard.widgets;
/*
* Implement our own layoutmanager, because we have a different layout
- */
+ */
// FIXME: move this to another js file
my.LayoutManager = function() {
@@ -106,7 +106,7 @@
{serviceName: widget.id, specUrl: metadata.gadgeturl, width:
"100%", secureToken: metadata.securetoken, cssClassGadgetContent:""});
shindig.container.addGadget(gadget);
shindig.container.renderGadget(gadget);
-
+
// Override the RPC call set_title to set the title in our custom
titlebar
// instead of the hidden none
gadgets.rpc.register('set_title', function(newTitle) {
@@ -114,32 +114,32 @@
var parent = iframe.parent().parent().parent();
var titlebar = parent.find('.widgettitle');
titlebar.html(newTitle);
- });
+ });
};
};
- $('.widget').live('widgetShow',function(e, obj){
+ $('.widget').live('widgetShow',function(e, obj){
if (!obj.widget.loaded) {
obj.widget.loaded = true;
my.renderGadget(obj.widget);
}
});
- $('.widget').live('widgetDropped',function(e, obj){
+ $('.widget').live('widgetDropped',function(e, obj){
obj.widget.loaded = false;
obj.widget.refreshContent();
});
- $('.widget').live('widgetDeleted',function(e, obj){
- removeWidgetFromAppData(obj.widget, dashboard);
+ $('.widget').live('widgetDeleted',function(e, obj){
+ removeWidgetFromAppData(obj.widget, dashboard);
});
$('.widget').live('widgetOpenFullScreen',function(e,o) {
- o.widget.loaded = false;
+ o.widget.loaded = false;
o.widget.refreshContent();
});
- $('.widget').live('widgetCloseFullScreen',function(){
+ $('.widget').live('widgetCloseFullScreen',function(){
for(var item in dashboard.widgets) {
var widget = dashboard.widgets[item];
widget.loaded = false;
@@ -148,7 +148,7 @@
});
- dashboard.element.live('dashboardAddWidget',function(e, obj){
+ dashboard.element.live('dashboardAddWidget',function(e, obj){
addWidgetToAppData(obj.widget, startId++, dashboard);
});
Modified:
trunk/amdatu-opensocial/gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/GadgetManagementServiceImpl.java
==============================================================================
---
trunk/amdatu-opensocial/gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/GadgetManagementServiceImpl.java
(original)
+++
trunk/amdatu-opensocial/gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/GadgetManagementServiceImpl.java
Wed Dec 29 09:27:43 2010
@@ -181,8 +181,8 @@
/**
* Returns gadgets available in the gadget store. URL to this resource:
- * http://localhost:3737/rest/services/gadgetstore/gadgetstore/categories
- *
+ * http://localhost:3737/rest/gadgetstore/categories
+ *
* @return All available gadgets.
*/
@GET
@@ -198,7 +198,7 @@
json.put("id", category.getId());
json.put("title", category.getName());
json.put("amount", catCount.get(category.getId()));
- json.put("url",
"/rest/services/gadgetstore/gadgetstore/gadgets/all?category=" +
category.getId());
+ json.put("url", "/rest/gadgetstore/gadgets/all?category=" +
category.getId());
categories.add(json);
}
jsonObject.put("category", categories);
@@ -215,8 +215,8 @@
/**
* Returns gadgets available in the gadget store. URL to this resource:
- * http://localhost:3737/rest/services/gadgetstore/gadgetstore/gadgets/all
- *
+ * http://localhost:3737/rest/gadgetstore/gadgets/all
+ *
* @return All available gadgets.
*/
@GET
@@ -273,8 +273,8 @@
/**
* Returns gadgets registered for the current user. URL to this resource:
- * http://localhost:3737/rest/services/gadgetstore/gadgetstore/gadgets/mine
- *
+ * http://localhost:3737/rest/gadgetstore/gadgets/mine
+ *
* @return Gadgets registered for the current user.
*/
@SuppressWarnings("unchecked")
Modified:
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
==============================================================================
---
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
(original)
+++
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
Wed Dec 29 09:27:43 2010
@@ -56,7 +56,7 @@
/**
* This gadget provides a SPARQL endpoint exposed as a REST service. The
SPARQL endpoint can be used to execute SPARQL
* queries and retrieve the result as JSON object. To check if the SPARQL
endpoint is available a GET to the following
- * URL can be requested;
/rest/services/sparqlendpoint?executeSPARQLQuery&checkAvailability
+ * URL can be requested;
/rest/sparqlendpoint?executeSPARQLQuery&checkAvailability
* @author ivol
*/
@Path("sparqlendpoint")
Modified:
trunk/amdatu-semanticweb/sparqlendpoint/src/main/resources/jsp/SPARQLEndpointGadget.jsp
==============================================================================
---
trunk/amdatu-semanticweb/sparqlendpoint/src/main/resources/jsp/SPARQLEndpointGadget.jsp
(original)
+++
trunk/amdatu-semanticweb/sparqlendpoint/src/main/resources/jsp/SPARQLEndpointGadget.jsp
Wed Dec 29 09:27:43 2010
@@ -25,13 +25,13 @@
<c:set var="gadgetBaseUrl" value="${baseUrl}/gadget/sparqlendpoint"/>
<Module>
- <ModulePrefs
- title="SPARQL Endpoint Gadget"
- description="Provides a basic UI to run SPARQL queries and display the
results"
- author="Ivo Ladage-van Doorn"
- screenshot="${gadgetBaseUrl}/static/images/sparql.gif"
- icon="${gadgetBaseUrl}/static/images/sparql.gif" height="400">
- <Require feature="osapi"/>
+ <ModulePrefs
+ title="SPARQL Endpoint Gadget"
+ description="Provides a basic UI to run SPARQL queries and display the
results"
+ author="Ivo Ladage-van Doorn"
+ screenshot="${gadgetBaseUrl}/static/images/sparql.gif"
+ icon="${gadgetBaseUrl}/static/images/sparql.gif" height="400">
+ <Require feature="osapi"/>
<Require feature="dynamic-height"/>
</ModulePrefs>
<Content type="html">
@@ -43,7 +43,7 @@
var batchSize = 0;
var firstStartIndex = 0;
var lastStartIndex = 0;
-
+
function runQuery(queryParams) {
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] =
gadgets.io.ContentType.JSON;
@@ -53,17 +53,17 @@
};
params[gadgets.io.RequestParameters.POST_DATA] =
gadgets.io.encodeValues(postdata);
- var url =
"${baseUrl}/rest/services/sparqlendpoint/sparqlendpoint?executeSPARQLQuery";
+ var url = "${baseUrl}/rest/sparqlendpoint?executeSPARQLQuery";
if (queryParams) {
url += "&" + queryParams;
}
gadgets.io.makeRequest(url, onResults, params);
}
-
+
function first() {
runQuery("startIndex=" + firstStartIndex + "&endIndex=" +
(firstStartIndex + batchSize));
}
-
+
function previous() {
if (startIndex - batchSize < firstStartIndex) {
first();
@@ -71,7 +71,7 @@
runQuery("startIndex=" + (startIndex - batchSize) + "&endIndex=" +
(startIndex - 1));
}
}
-
+
function next() {
if (startIndex + batchSize > lastStartIndex) {
last();
@@ -79,11 +79,11 @@
runQuery("startIndex=" + (endIndex + 1) + "&endIndex=" + (endIndex +
batchSize));
}
}
-
+
function last() {
runQuery("startIndex=" + lastStartIndex + "&endIndex=" +
(lastStartIndex + batchSize));
}
-
+
function onResults(response) {
var jsonData = response.data;
startIndex = jsonData["startIndex"];
@@ -92,14 +92,14 @@
firstStartIndex = jsonData["firstStartIndex"];
lastStartIndex = jsonData["lastStartIndex"];
var resultCount = jsonData["resultCount"];
-
+
var html = "<p><center><table><tr>";
html += "<td><img src='/gadget/sparqlendpoint/static/images/first.gif'
onClick='javascript:first()'/></td>";
html += "<td><img
src='/gadget/sparqlendpoint/static/images/previous.gif'
onClick='javascript:previous()'/></td>";
html += "<td>Displaying results <b>" + startIndex + "-" + endIndex +
"<b> of <b>" + resultCount + "</b></td>";
html += "<td><img src='/gadget/sparqlendpoint/static/images/next.gif'
onClick='javascript:next()'/></td>";
html += "<td><img src='/gadget/sparqlendpoint/static/images/last.gif'
onClick='javascript:last()'/></td></table></center></p>";
-
+
// First add the table header
var rows = jsonData["row"];
if (rows) {
@@ -108,7 +108,7 @@
for (var key in rows[0]) {
html += "<th>" + key + "</th>";
}
- html += "</tr>";
+ html += "</tr>";
for (i=0; i<rows.length; i++) {
var row = rows[i];
@@ -121,17 +121,17 @@
}
html += "</table></div></p>";
} else {
-
+
}
-
+
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = html;
gadgets.window.adjustHeight();
-
+
}
</script>
-
+
<p>
<table width="95%">
<tr><td colspan="2"><textarea id="query" name="query" rows="5"
cols="87">SELECT ?subject ?predicate ?object WHERE {?subject ?predicate
?object}</textarea></td></tr>
@@ -142,7 +142,7 @@
</table>
</p>
<div id="result"></div>
-
+
]]>
</Content>
</Module>
Modified:
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/osgi/Activator.java
==============================================================================
---
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/osgi/Activator.java
(original)
+++
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/osgi/Activator.java
Wed Dec 29 09:27:43 2010
@@ -32,17 +32,18 @@
public class Activator extends DependencyActivatorBase {
// The resource identifier for this bundle. Resources are only considered
to be 'ours' when
// it is prefixed with this id.
- public final static String RESOURCE_ID = "rest/services";
-
+ public final static String RESOURCE_ID = "rest";
+
@Override
public void init(BundleContext context, DependencyManager manager) throws
Exception {
- // Create and register the gadget oAuth store service
+
+ // Create and register the wink registration service
manager.add(createComponent()
- .setImplementation(WinkRegistrationServiceImpl.class)
-
.add(createServiceDependency().setService(LogService.class).setRequired(true))
-
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
-
.add(createServiceDependency().setService("(objectclass=*)").setCallbacks("onAdded",
"onRemoved"))
-
.add(createServiceDependency().setService(HttpService.class).setRequired(true)));
+ .setImplementation(WinkRegistrationServiceImpl.class)
+
.add(createServiceDependency().setService(LogService.class).setRequired(true))
+
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
+
.add(createServiceDependency().setService("(objectclass=*)").setCallbacks("onAdded",
"onRemoved"))
+
.add(createServiceDependency().setService(HttpService.class).setRequired(true)));
}
@Override
Modified:
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkRegistrationServiceImpl.java
==============================================================================
---
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkRegistrationServiceImpl.java
(original)
+++
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkRegistrationServiceImpl.java
Wed Dec 29 09:27:43 2010
@@ -24,6 +24,7 @@
import java.util.Hashtable;
import java.util.List;
+import javax.servlet.Filter;
import javax.servlet.ServletException;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;
@@ -82,6 +83,8 @@
setRuntimeDelegate();
registerSpiService();
+ // Register REST dispatcher servlet
+
m_logService.log(LogService.LOG_INFO, getClass().getName() + " service
initialized");
}
@@ -120,7 +123,7 @@
// The nasty fix is to set some dummy RuntimeDelegate first, then set
the Wink RuntimeDelegateImpl
RuntimeDelegate.setInstance(new RuntimeDelegate() {
public <T> T createEndpoint(Application arg0, Class<T> arg1)
throws IllegalArgumentException,
- UnsupportedOperationException {
+ UnsupportedOperationException {
return null;
}
@@ -145,8 +148,8 @@
private void registerSpiService() {
m_spiComponent = m_dependencyManager.createComponent()
- .setInterface(JaxRsSpi.class.getName(), null)
- .setImplementation(new JaxRsSpi(){});
+ .setInterface(JaxRsSpi.class.getName(), null)
+ .setImplementation(new JaxRsSpi(){});
m_dependencyManager.add(m_spiComponent);
}
@@ -187,21 +190,18 @@
restPath = restPath.substring(1);
}
WinkRestServlet restServlet = new WinkRestServlet(restPath);
-
- // FIXME: the only problem with creating a REST servlet for
each REST resource
- // is that the REST resource path appears twice in the URL;
once to point to a
- // particular servlet instance and one for the resource. For
example a REST URL becomes:
- //
http://localhost/rest/services/sparqlendpoint/sparqlendpoint?executeSPARQLQuery
- // instead of
- //
http://localhost/rest/services/sparqlendpoint?executeSPARQLQuery
- // There seems to be no proper way to prevent this using
Apache Wink however.
String servletUrl = "/" + RESOURCE_ID + "/" + restPath;
m_httpService.registerServlet(servletUrl, restServlet,
initParams, m_httpContext);
String reqProcAttr = restPath;
RegistrationUtils.registerInstances(restServlet.getServletContext(),
reqProcAttr, service);
m_registeredServlets.add(servletUrl);
- m_logService.log(LogService.LOG_INFO, "Wink application
registered REST servlet '" + servletUrl
- + "'");
+ m_logService.log(LogService.LOG_DEBUG, "Wink application
registered REST servlet '" + servletUrl + "'");
+
+ // Register a Wink servlet filter to forward requests from
/rest/path to
+ // /rest/path/path
+ WinkServletFilter filter = new WinkServletFilter(servletUrl,
servletUrl + "/" + restPath);
+ registerFilter(servletUrl, filter);
+ m_logService.log(LogService.LOG_DEBUG, "Wink application
registered REST servlet filter on '" + servletUrl + "'");
}
catch (ServletException e) {
m_logService.log(LogService.LOG_ERROR, "Failed to register
servlet for REST service '"
@@ -221,7 +221,8 @@
if (m_registeredServlets.contains(servletUrl)) {
m_httpService.unregister(servletUrl);
m_registeredServlets.remove(servletUrl);
- m_logService.log(LogService.LOG_INFO, "Wink application
unregistered REST servlet '" + servletUrl
+
+ m_logService.log(LogService.LOG_DEBUG, "Wink application
unregistered REST servlet '" + servletUrl
+ "'");
}
}
@@ -232,6 +233,18 @@
}
public String getResourceId() {
- return RESOURCE_ID;
+ return RESOURCE_ID + "/resources";
+ }
+
+ public void registerFilter(String alias, Filter filter) {
+ Dictionary<String, String> filterProperties = new Hashtable<String,
String>();
+ // Map filter on /rest/path OR /rest/path?... OR /rest/path/...
+ filterProperties.put("pattern", alias + "(|\\?.*|/.*)");
+ filterProperties.put("service.ranking", "0");
+ filterProperties.put("contextId", alias);
+ m_dependencyManager.add(m_dependencyManager.createComponent()
+ .setImplementation(filter)
+ .setInterface(new String[] { Filter.class.getName() },
filterProperties)
+
.add(m_dependencyManager.createServiceDependency().setService(LogService.class).setRequired(true)));
}
}
Modified:
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkRestServlet.java
==============================================================================
---
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkRestServlet.java
(original)
+++
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkRestServlet.java
Wed Dec 29 09:27:43 2010
@@ -16,21 +16,22 @@
*/
package org.amdatu.web.rest.wink.service;
+import java.io.IOException;
+
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
import org.apache.wink.server.internal.RequestProcessor;
import org.apache.wink.server.internal.servlet.RestServlet;
/**
- * Override the default RestServlet since that implementation does not
unregister REST servlets well. It does
+ * Override the default RestServlet since that implementation does not
unregister REST servlets well. It does
* unregister the servlet but 'forgets' to remove the resources from the
ResourceRegistry. The ResourceRegistry is
* associated with the RequestProcessor which is associated with the servlet
context. Since the servlet context
- * is not changed when a REST servlet is unregistered/registerd, the request
processor instance is the same for
+ * is not changed when a REST servlet is unregistered/registerd, the request
processor instance is the same for
* all REST servlets and uneffected. This overridden implementation forces the
request processor to be tight to
* the servlet instance.
* @author ivol
@@ -44,7 +45,7 @@
// The servlet URL
private String m_servletUrl;
-
+
/**
* Constructor.
* @param servletUrl The URL which serves this servlet
@@ -53,37 +54,34 @@
super();
m_servletUrl = servletUrl;
}
-
- @Override
+
protected void service(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse)
- throws ServletException, IOException {
+ throws ServletException, IOException {
// The next line seems to do nothing, but it does. Without requesting
parameter names here, using both
- // @FormParam JAX-RS annotations in a REST resource as well as
getParameterNames() in the same @PUT
- // or @POST annotated method will not work (getParameterNames() will
return an empty map without the
+ // @FormParam JAX-RS annotations in a REST resource as well as
getParameterNames() in the same @PUT
+ // or @POST annotated method will not work (getParameterNames() will
return an empty map without the
// posted parameters). This is because the InputStream in that case is
read by the FormParam handler
// first, which does not write the read from parameters to the
parameter map. The other way around
// works fine; when the input stream has already been read and written
to the parameter map the
// FormParam handler binds the values from this map instead of reading
them from the input stream.
httpServletRequest.getParameterNames();
-
+
super.service(httpServletRequest, httpServletResponse);
}
-
- @Override
+
public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
// The next line seems to do nothing, but it does. Without requesting
parameter names here, using both
- // @FormParam JAX-RS annotations in a REST resource as well as
getParameterNames() in the same @PUT
- // or @POST annotated method will not work (getParameterNames() will
return an empty map without the
+ // @FormParam JAX-RS annotations in a REST resource as well as
getParameterNames() in the same @PUT
+ // or @POST annotated method will not work (getParameterNames() will
return an empty map without the
// posted parameters). This is because the InputStream in that case is
read by the FormParam handler
// first, which does not write the read from parameters to the
parameter map. The other way around
// works fine; when the input stream has already been read and written
to the parameter map the
// FormParam handler binds the values from this map instead of reading
them from the input stream.
request.getParameterNames();
-
+
super.service(request, response);
}
-
- @Override
+
protected RequestProcessor getRequestProcessor() {
if (!m_initialized) {
// Override this method to enforce creation of a new
requestprocessor whenever a servlet is created
@@ -94,7 +92,6 @@
}
}
- @Override
protected void storeRequestProcessorOnServletContext(RequestProcessor
requestProcessor) {
requestProcessor.storeRequestProcessorOnServletContext(getServletContext(),
m_servletUrl);
}
Added:
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkServletFilter.java
==============================================================================
--- (empty file)
+++
trunk/amdatu-web/rest-wink/src/main/java/org/amdatu/web/rest/wink/service/WinkServletFilter.java
Wed Dec 29 09:27:43 2010
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2010 Amdatu.org
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.amdatu.web.rest.wink.service;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * The Wink servlet filter has only one purpose; getting rid of the double
path occurrence in the URLs of the
+ * REST APIs. For example, if you have a REST service annotated with @Path
"users", the URL will become
+ * /rest/users/users. The reason for this is that using the Wink framework in
a OSGi container,
+ * each REST service must run in its own servlet (as Wink was not designed to
be used in OSGi). As the servlet
+ * path must be unique, the @Path annotation is used for this, so the Wink
REST servlet for the users REST service
+ * becomes /rest/users. Subsequently Wink appends the @Path annotation to this
URL such that it becomes
+ * /rest/users/users.
+ * The easitest way to fix this issue, without the need to override many Wink
classes, is to associate a servlet
+ * filter with /rest/users which just forwrds the request internally to
/rest/users/users. This
+ * is exactly what this filter does.
+ * @author ivol
+ *
+ */
+public class WinkServletFilter implements Filter {
+ // URL from which requests must be dispatched
+ private String m_dispatchFrom;
+
+ // Target of dispatched URLs
+ private String m_dispatchTo;
+
+ /**
+ * Instantiates a new Wink servlet filter with the purpose of removing the
double occurrence of the
+ * Path in the URL of the REST service.
+ * @param from The desired URL of the REST service
+ * @param to The actual URL of the REST services
+ */
+ public WinkServletFilter(String from, String to) {
+ m_dispatchFrom = from;
+ m_dispatchTo = to;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
+ String path = ((HttpServletRequest) request).getPathInfo();
+ if (path.startsWith(m_dispatchFrom)) {
+ String targetPath = path.replace(m_dispatchFrom, m_dispatchTo);
+ RequestDispatcher dispatcher =
request.getRequestDispatcher(targetPath);
+ dispatcher.forward(request, response);
+ } else {
+ chain.doFilter(request, response);
+ }
+ }
+
+ public void destroy() {
+ }
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+}
Modified:
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/RESTTestBase.java
==============================================================================
---
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/RESTTestBase.java
(original)
+++
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/RESTTestBase.java
Wed Dec 29 09:27:43 2010
@@ -64,6 +64,7 @@
return new Option[]{
provision(
felixHttpServiceJetty(),
+ felixHttpServiceWhiteboard(),
amdatuHttpContext(),
amdatuJaxRs(),
amdatuWink(),
@@ -104,7 +105,7 @@
protected String getBaseUrl() throws Exception {
if (m_baseUrl == null) {
- m_baseUrl = "http://" + ConfigProvider.HOSTNAME + ":" +
ConfigProvider.PORTNR + "/rest/services";
+ m_baseUrl = "http://" + ConfigProvider.HOSTNAME + ":" +
ConfigProvider.PORTNR + "/rest";
}
return m_baseUrl;
}
Modified:
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/OAuthServiceConsumerRegistryTest.java
==============================================================================
---
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/OAuthServiceConsumerRegistryTest.java
(original)
+++
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/OAuthServiceConsumerRegistryTest.java
Wed Dec 29 09:27:43 2010
@@ -38,10 +38,10 @@
@RunWith(JUnit4TestRunner.class)
public class OAuthServiceConsumerRegistryTest extends OAuthTestBase {
- private final static String CONSUMERS_REST_RESOURCE =
"/rest/services/oauth/consumers/oauth/consumers";
+ private final static String CONSUMERS_REST_RESOURCE =
"/rest/oauth/consumers";
private String m_baseUrl;
-
+
@Test
// Test the REST service that provides CRUD operations on the consumer
registry of the oAuth server
public void testRestService() throws Exception {
@@ -52,48 +52,48 @@
m_logService.log(LogService.LOG_DEBUG, "Waiting for '" + m_baseUrl +
CONSUMERS_REST_RESOURCE + "' to come available...");
waitForURL(m_baseUrl + CONSUMERS_REST_RESOURCE, HttpStatus.SC_OK);
m_logService.log(LogService.LOG_DEBUG, "URL available");
-
+
HttpClient httpClient = new HttpClient();
-
+
// First add a new consumer using the JSON format
OAuthTestConsumer consumer = new OAuthTestConsumer();
int statusCode = putConsumer(httpClient, "application/json", consumer,
false);
- Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on addConsumer",
+ Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on addConsumer",
statusCode == HttpStatus.SC_OK);
-
+
// Retrieve the new consumer in XML and JSON format
OAuthTestConsumer testConsumer = getConsumer(httpClient,
"application/json", consumer.getConsumerKey());
- Assert.assertTrue("Returned JSON consumer is incorrect: " +
testConsumer.toString(),
+ Assert.assertTrue("Returned JSON consumer is incorrect: " +
testConsumer.toString(),
consumer.equals(testConsumer));
testConsumer = getConsumer(httpClient, "application/xml",
consumer.getConsumerKey());
- Assert.assertTrue("Returned XML consumer is incorrect",
+ Assert.assertTrue("Returned XML consumer is incorrect",
consumer.equals(testConsumer));
-
+
// Now try to add another consumer using the Atom XML format, this
should result in a 304 since the consumer
// already exists
statusCode = putConsumer(httpClient, "application/json", consumer,
false);
- Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on addConsumer",
+ Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on addConsumer",
statusCode == HttpStatus.SC_NOT_MODIFIED);
-
+
// Now update the test consumer
consumer.setConsumerSecret("new " +
OAuthTestConsumer.DEFAULT_CONSUMER_SECRET);
consumer.setCallbackUrl("new " +
OAuthTestConsumer.DEFAULT_CALLBACK_URL);
consumer.setName("new " + OAuthTestConsumer.DEFAULT_CONSUMER_NAME);
statusCode = putConsumer(httpClient, "application/json", consumer,
true);
- Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on updateConsumer",
+ Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on updateConsumer",
statusCode == HttpStatus.SC_OK);
-
+
// And check if the update was handled properly
testConsumer = getConsumer(httpClient, "application/json",
consumer.getConsumerKey());
- Assert.assertTrue("Returned JSON consumer is incorrect: " +
testConsumer.toString(),
+ Assert.assertTrue("Returned JSON consumer is incorrect: " +
testConsumer.toString(),
consumer.equals(testConsumer));
testConsumer = getConsumer(httpClient, "application/xml",
consumer.getConsumerKey());
- Assert.assertTrue("Returned XML consumer is incorrect",
+ Assert.assertTrue("Returned XML consumer is incorrect",
consumer.equals(testConsumer));
-
+
// Now delete our test consumer
statusCode = deleteConsumer(httpClient, "application/json",
consumer.getConsumerKey());
- Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on deleteConsumer",
+ Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on deleteConsumer",
statusCode == HttpStatus.SC_OK);
}
@@ -104,7 +104,7 @@
// We want JSON!
getMethod.setRequestHeader("Accept", mimeType);
int statusCode = httpClient.executeMethod(getMethod);
- Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on getConsumer",
+ Assert.assertTrue("OAuth Service Consumer registry REST service
returns " + statusCode + " on getConsumer",
statusCode == HttpStatus.SC_OK);
String body = new String(getMethod.getResponseBody(), "UTF-8");
m_logService.log(LogService.LOG_DEBUG, "Returned content for
getConsumer in format " + mimeType + ": " + body);
@@ -121,7 +121,7 @@
getMethod.releaseConnection();
}
}
-
+
private int putConsumer(HttpClient httpClient, String mimeType,
OAuthTestConsumer consumer, boolean update) throws JSONException,
HttpException, IOException {
String url = m_baseUrl + CONSUMERS_REST_RESOURCE;
PutMethod method;
@@ -136,7 +136,7 @@
} else if ("application/json".equals(mimeType)) {
body = consumer.toJson().toString();
}
- m_logService.log(LogService.LOG_DEBUG, "Adding consumer for " +
mimeType + ", url=" + (update ? url + "/"
+ m_logService.log(LogService.LOG_DEBUG, "Adding consumer for " +
mimeType + ", url=" + (update ? url + "/"
+ consumer.getConsumerKey() : url) + ", input=" + body);
RequestEntity requestEntity = new StringRequestEntity(body, mimeType,
"UTF-8");
method.setRequestEntity(requestEntity);
@@ -151,7 +151,7 @@
method.releaseConnection();
}
}
-
+
private int deleteConsumer(HttpClient httpClient, String mimeType, String
consumerKey) throws JSONException, HttpException, IOException {
String url = m_baseUrl + CONSUMERS_REST_RESOURCE;
DeleteMethod method = new DeleteMethod(url + "/" + consumerKey);
Modified:
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/UserAdminRESTTest.java
==============================================================================
---
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/UserAdminRESTTest.java
(original)
+++
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/UserAdminRESTTest.java
Wed Dec 29 09:27:43 2010
@@ -56,10 +56,10 @@
@Test
public void testTheRest() throws Exception {
// Test the REST interface of the useradmin bundle. First wait before
it comes up
- waitForURL(getBaseUrl() + "/users/users/status", HttpStatus.SC_OK);
+ waitForURL(getBaseUrl() + "/users/status", HttpStatus.SC_OK);
// -1- First try to create a user and verify that a 401 error
(Unauthorized) is returned
- String url = "/users/users/" + ConfigProvider.TEST_USERNAME;
+ String url = "/users/" + ConfigProvider.TEST_USERNAME;
invokeRestApi(url, javax.ws.rs.HttpMethod.PUT,
HttpStatus.SC_UNAUTHORIZED);
// -2- Now login as Administrator
Modified:
trunk/integration-tests/src/test/java/org/amdatu/test/integration/util/Login.java
==============================================================================
---
trunk/integration-tests/src/test/java/org/amdatu/test/integration/util/Login.java
(original)
+++
trunk/integration-tests/src/test/java/org/amdatu/test/integration/util/Login.java
Wed Dec 29 09:27:43 2010
@@ -16,7 +16,7 @@
public class Login {
public static HeaderElement login(String username, String password) throws
HttpException, IOException {
- String loginUrl = "http://" + HOSTNAME + ":" + PORTNR +
"/rest/services/authorization/authorization/login";
+ String loginUrl = "http://" + HOSTNAME + ":" + PORTNR +
"/rest/authorization/login";
HttpClient httpClient = new HttpClient();
PostMethod postMethod = null;
try {