Author: tyrell
Date: Fri Dec 14 08:17:47 2007
New Revision: 11139
Log:
Fixing mashup skeleton generation and mashup deletion, broken due to user
provisioning.
Modified:
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
trunk/mashup/java/modules/www/org/js/mashup-utils.js
trunk/mashup/java/modules/www/org/js/services.js
trunk/mashup/java/modules/www/org/mashup.jsp
trunk/mashup/java/modules/www/org/user.jsp
Modified:
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
==============================================================================
---
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
(original)
+++
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
Fri Dec 14 08:17:47 2007
@@ -126,7 +126,7 @@
Resource mashup = registry.get((String) myRegistryPath.getValue());
mashup.setDescription(documentation);
- registry.put((String) myRegistryPath.getValue(),mashup);
+ registry.put((String) myRegistryPath.getValue(), mashup);
success = true;
@@ -329,7 +329,7 @@
}
- public String createNewServiceSkeleton(String serviceName) {
+ public String createNewServiceSkeleton(String serviceName, String
userName) {
String success = "An error occured, failed to create the service
skeleton.";
String decodedServiceName = "";
boolean serviceNameValidated = false;
@@ -351,7 +351,18 @@
if (repository != null) {
try {
File repo = new File(repository.getFile());
- File scriptsFolder = new File(repo, "scripts");
+ File scriptsFolder;
+ if (userName != null) {
+ scriptsFolder = new File(repo, "scripts/" + userName);
+ } else {
+ //Keeping this for backward compatibility todo: remove
after migration
+ scriptsFolder = new File(repo, "scripts");
+ }
+
+ //Creating the folder if necessary
+ if(!scriptsFolder.exists()){
+ scriptsFolder.mkdirs();
+ }
//Creating the new service js file
File newService = new File(scriptsFolder,
decodedServiceName + ".js");
Modified: trunk/mashup/java/modules/www/org/js/mashup-utils.js
==============================================================================
--- trunk/mashup/java/modules/www/org/js/mashup-utils.js (original)
+++ trunk/mashup/java/modules/www/org/js/mashup-utils.js Fri Dec 14
08:17:47 2007
@@ -306,7 +306,7 @@
* @description Displays the dialog to create a new mashup.
* @method showCreateMashupDialog
*/
-WSO2.MashupUtils.showCreateMashupDialog = function() {
+WSO2.MashupUtils.showCreateMashupDialog = function(userName) {
//Showing a dialog to get the new Mashup's name
var parent = document.createElement("div");
@@ -393,7 +393,7 @@
labelElement.innerHTML = "";
labelElement.appendChild(document.createTextNode("Contacting
backend services. Please wait..."));
- wso2.mashup.services.createMashupSkeleton(mashupName,
submitServiceCallback, labelElement);
+ wso2.mashup.services.createMashupSkeleton(mashupName,
userName, submitServiceCallback, labelElement);
mashupCreationDialog.cancel();
clearDom();
}
Modified: trunk/mashup/java/modules/www/org/js/services.js
==============================================================================
--- trunk/mashup/java/modules/www/org/js/services.js (original)
+++ trunk/mashup/java/modules/www/org/js/services.js Fri Dec 14 08:17:47 2007
@@ -262,12 +262,13 @@
* @param {callback} callBack User-defined callback function or object
* @param {callback} params Parameters to be set in the callback
*/
-wso2.mashup.services.createMashupSkeleton = function (newServiceName,
callback, params) {
+wso2.mashup.services.createMashupSkeleton = function (newServiceName,
userName, callback, params) {
var callURL = serverURL + "/" + "ServiceMetaDataLister" + "/" ;
var body_xml = '<req:createNewServiceSkeletonRequest
xmlns:req="http://servicemetadatalister.coreservices.mashup.wso2.org/xsd">\n' +
' <req:serviceName>' + newServiceName +
'</req:serviceName>\n' +
+ ' <req:userName>' + userName + '</req:userName>\n' +
' </req:createNewServiceSkeletonRequest>\n';
new wso2.wsf.WSRequest(callURL, "createNewServiceSkeleton", body_xml,
callback, params, wso2.mashup.services.defaultErrHandler);
Modified: trunk/mashup/java/modules/www/org/mashup.jsp
==============================================================================
--- trunk/mashup/java/modules/www/org/mashup.jsp (original)
+++ trunk/mashup/java/modules/www/org/mashup.jsp Fri Dec 14 08:17:47 2007
@@ -71,8 +71,9 @@
String authorFullName = RegistryUtils.getFullName(request, author);
String description = resource.getDescription();
+ //This is the service name understood by WSAS and should be used in all
calls to WSAS services
String mashupServiceName = author + "-" + mashup;
-
+
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
@@ -330,11 +331,17 @@
wso2.mashup.services.listServiceData('<%=mashupServiceName%>',
listServiceDataCallback);
</script>
-<%}%>
+<%
+ }
+
+ //Users must be logged in to create mashups
+ if (RegistryUtils.isLoggedIn(registry)) {
+%>
<li>
- <a href="#" onclick="WSO2.MashupUtils.showCreateMashupDialog();">Create a
+ <a href="#"
onclick="WSO2.MashupUtils.showCreateMashupDialog('<%=RegistryUtils.getCurrentUser(registry)%>');">Create
a
new service</a>
</li>
+<%}%>
<li id="share-mashup">
Service sharing is not available
</li>
@@ -350,7 +357,7 @@
var confirmation = confirm("You are about to permanently delete the
'<%=mashupServiceName%>' service. Are you sure?")
if (confirmation) {
- wso2.mashup.services.deleteService('<%=mashup%>',
deleteServiceCallback);
+ wso2.mashup.services.deleteService('<%=mashupServiceName%>',
deleteServiceCallback);
}
}
</script>
@@ -441,21 +448,21 @@
<script type="text/javascript">
function customUiCallback() {
document.getElementById("custom_ui_link").innerHTML =
- 'View the <a href="/services/<%=author%>/<%= mashup
%>/">HTML Interface</a> to the service'
+ 'View the <a href="/services/<%=author%>/<%= mashup
%>/" target="_blank">HTML Interface</a> to the service'
}
isCustomUiAvailable('/services/<%=author%>/<%= mashup %>',
customUiCallback);
</script>
- <li><a href="/services/<%=author%>/<%= mashup %>?tryit"
title="?tryit">Try</a> the
+ <li><a href="/services/<%=author%>/<%= mashup %>?tryit"
title="?tryit" target="_blank">Try</a> the
service
</li>
- <li>Read <a href="/services/<%=author%>/<%= mashup %>?doc"
title="?doc">API
+ <li>Read <a href="/services/<%=author%>/<%= mashup %>?doc"
title="?doc" target="_blank">API
documentation</a>
</li>
<li>View the <a
href="/services/<%=author%>/<%= mashup
%>?source&content-type=text/plain"
- title="?source">source code</a></li>
+ title="?source" target="_blank">source code</a></li>
</ul>
</div>
Modified: trunk/mashup/java/modules/www/org/user.jsp
==============================================================================
--- trunk/mashup/java/modules/www/org/user.jsp (original)
+++ trunk/mashup/java/modules/www/org/user.jsp Fri Dec 14 08:17:47 2007
@@ -205,7 +205,7 @@
<!--Will only be available for logged in users-->
<% if (RegistryUtils.isLoggedIn(registry)) { %>
<li>
- <a href="#"
onclick="WSO2.MashupUtils.showCreateMashupDialog();">Create a
+ <a href="#"
onclick="WSO2.MashupUtils.showCreateMashupDialog('<%=RegistryUtils.getCurrentUser(registry)%>');">Create
a
new service</a>
</li>
<li>
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev