Author: tyrell
Date: Fri Dec 7 18:59:56 2007
New Revision: 10716
Log:
Integrating service deletion.
Modified:
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
trunk/mashup/java/modules/www/org/js/services.js
trunk/mashup/java/modules/www/org/mashup.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 7 18:59:56 2007
@@ -242,10 +242,10 @@
}
//Getting the html file
- File uiHtmlFile = new File(wwwDir,"index.htm");
+ File uiHtmlFile = new File(wwwDir, "index.htm");
if (!uiHtmlFile.exists()) {
- uiHtmlFile = new File(wwwDir,"index.html");
+ uiHtmlFile = new File(wwwDir, "index.html");
}
BufferedWriter out = new BufferedWriter(new
FileWriter(uiHtmlFile));
@@ -261,6 +261,55 @@
return Boolean.valueOf(success);
}
+ public Boolean deleteService(String serviceName) {
+ boolean success = false;
+
+ MessageContext currentMessageContext =
MessageContext.getCurrentMessageContext();
+ AxisConfiguration configuration =
+ currentMessageContext.getAxisService().getAxisConfiguration();
+
+ try {
+ AxisService mashupService = configuration.getService(serviceName);
+
+ Parameter serviceJSParameter = mashupService
+ .getParameter(JavaScriptEngineConstants.SERVICE_JS);
+ Parameter serviceResourcesDir =
+
mashupService.getParameter(JavaScriptEngineConstants.RESOURCES_FOLDER);
+
+ if (serviceJSParameter != null && serviceJSParameter.getValue() !=
null) {
+ File serviceJS = (File) serviceJSParameter.getValue();
+ File serviceReources = (File) serviceResourcesDir.getValue();
+ success = serviceJS.delete();
+
+ //On successful deletion of the service, deleting the
resources directory
+ if (success) {
+ success = deleteDir(serviceReources);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return Boolean.valueOf(success);
+ }
+
+
+ private static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+
+
public String createNewServiceSkeleton(String serviceName) {
String success = "An error occured, failed to create the service
skeleton.";
String decodedServiceName = "";
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 7 18:59:56 2007
@@ -343,7 +343,7 @@
};
/**
- *
+ * @description Saves the CustomUI of a JS Service
* @param {String} serviceName Name of the service
* @param {String} modifiedSource Ammended source code
* @param {callback} callBack User-defined callback function or object
@@ -363,6 +363,21 @@
};
/**
+ * @description Deletes a JS Service and its associated resources directory
+ * @param {String} serviceName Name of the Service
+ * @param {callback} callback User-defined callback function or object
+ */
+wso2.mashup.services.deleteService = function (serviceName, callback) {
+ var callURL = serverURL + "/" + "ServiceMetaDataLister" + "/" ;
+
+ var body_xml = '<req:deleteServiceOpRequest
xmlns:req="http://servicemetadatalister.coreservices.mashup.wso2.org/xsd">\n' +
+ ' <req:serviceName>' + serviceName + '</req:serviceName>\n'
+
+ ' </req:deleteServiceOpRequest>\n';
+
+ new wso2.wsf.WSRequest(callURL, "deleteService", body_xml, callback, "",
wso2.mashup.services.defaultErrHandler);
+};
+
+/**
* @description Method used to download a mashup from a remote server
* @method downloadService
* @public
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 7 18:59:56 2007
@@ -463,104 +463,111 @@
</td>
<td width="250" valign="top">
- <table width="100%" border="0" class="box" cellspacing="0" cellpadding="3">
- <tr>
- <th>Tasks</th>
- </tr>
- <!--Tasks will be available only to logged in users-->
- <% if (RegistryUtils.isLoggedIn(registry)) { %>
- <tr>
- <td>
- <ul>
- <!--Will be available only to users with Admin priviledges
OR who are Authors of the current Mashup-->
- <% if ((RegistryUtils.isAdminRole(registry)) ||
-
(author.equalsIgnoreCase(RegistryUtils.getCurrentUser(registry)))) { %>
- <li id="service-status">
- Service status not available
- </li>
- <li id="edit-service">
- Service editing is not available
- </li>
-
- <script type="text/javascript">
- //Getting the Current status of the service
- function handleServiceStartStopCallback() {
- var params = this.params;
- var serviceState = params[1];
-
- if (serviceState) {
-
document.getElementById("service-status").innerHTML =
- "Service started. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", false,
handleServiceStartStopCallback)'>Stop</a>]";
+<table width="100%" border="0" class="box" cellspacing="0" cellpadding="3">
+<tr>
+ <th>Tasks</th>
+</tr>
+<!--Tasks will be available only to logged in users-->
+<% if (RegistryUtils.isLoggedIn(registry)) { %>
+<tr>
+ <td>
+ <ul>
+ <!--Will be available only to users with Admin priviledges OR who
are Authors of the current Mashup-->
+ <% if ((RegistryUtils.isAdminRole(registry)) ||
+
(author.equalsIgnoreCase(RegistryUtils.getCurrentUser(registry)))) { %>
+ <li id="service-status">
+ Service status not available
+ </li>
+ <li id="edit-service">
+ Service editing is not available
+ </li>
+
+ <script type="text/javascript">
+ //Getting the Current status of the service
+ function handleServiceStartStopCallback() {
+ var params = this.params;
+ var serviceState = params[1];
+
+ if (serviceState) {
+ document.getElementById("service-status").innerHTML =
+ "Service started. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", false,
handleServiceStartStopCallback)'>Stop</a>]";
//Enabling service editing
-
document.getElementById("edit-service").innerHTML =
- '<a href="#"
onclick="wso2.mashup.services.getServiceDataForEditor(\'<%=mashup%>\',
wso2.mashup.populateServiceEditor);">Edit this service</a>';
+ document.getElementById("edit-service").innerHTML =
+ '<a href="#"
onclick="wso2.mashup.services.getServiceDataForEditor(\'<%=mashup%>\',
wso2.mashup.populateServiceEditor);">Edit this service</a>';
//Enabling service sharing
-
document.getElementById("share-mashup").innerHTML =
- ' <a href="#"
onclick="WSO2.MashupUtils.showMashupSharingDialog(\'<%=mashup%>\');">Share this
service</a>';
- } else {
-
document.getElementById("service-status").innerHTML =
- "Service stopped. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", true,
handleServiceStartStopCallback)'>Start</a>]";
+ document.getElementById("share-mashup").innerHTML =
+ ' <a href="#"
onclick="WSO2.MashupUtils.showMashupSharingDialog(\'<%=mashup%>\');">Share this
service</a>';
+ } else {
+ document.getElementById("service-status").innerHTML =
+ "Service stopped. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", true,
handleServiceStartStopCallback)'>Start</a>]";
//Disabling service editing
-
document.getElementById("edit-service").innerHTML =
- "Service editing is not available";
+ document.getElementById("edit-service").innerHTML =
+ "Service editing is not available";
//Disabling service sharing
-
document.getElementById("share-mashup").innerHTML =
- "Service sharing is not available"
- }
- }
-
- function listServiceDataCallback() {
- var xmlBodyContent =
this.req.responseXML.getElementsByTagName("return")[0];
- var serviceMashupObject =
WSO2.MashupUtils.generateMashupFromXml(xmlBodyContent);
-
- if (serviceMashupObject.getServiceStatus() ==
"true") {
-
document.getElementById("service-status").innerHTML =
- "Service started. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", false,
handleServiceStartStopCallback)'>Stop</a>]";
+ document.getElementById("share-mashup").innerHTML =
+ "Service sharing is not available"
+ }
+ }
+
+ function listServiceDataCallback() {
+ var xmlBodyContent =
this.req.responseXML.getElementsByTagName("return")[0];
+ var serviceMashupObject =
WSO2.MashupUtils.generateMashupFromXml(xmlBodyContent);
+
+ if (serviceMashupObject.getServiceStatus() == "true") {
+ document.getElementById("service-status").innerHTML =
+ "Service started. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", false,
handleServiceStartStopCallback)'>Stop</a>]";
//Enabling service editing
-
document.getElementById("edit-service").innerHTML =
- '<a href="#"
onclick="wso2.mashup.services.getServiceDataForEditor(\'<%=mashup%>\',
wso2.mashup.populateServiceEditor);">Edit this service</a>';
+ document.getElementById("edit-service").innerHTML =
+ '<a href="#"
onclick="wso2.mashup.services.getServiceDataForEditor(\'<%=mashup%>\',
wso2.mashup.populateServiceEditor);">Edit this service</a>';
//Enabling service sharing
-
document.getElementById("share-mashup").innerHTML =
- ' <a href="#"
onclick="WSO2.MashupUtils.showMashupSharingDialog(\'<%=mashup%>\');">Share this
service</a>';
- } else {
-
document.getElementById("service-status").innerHTML =
- "Service stopped. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", true,
handleServiceStartStopCallback)'>Start</a>]";
+ document.getElementById("share-mashup").innerHTML =
+ ' <a href="#"
onclick="WSO2.MashupUtils.showMashupSharingDialog(\'<%=mashup%>\');">Share this
service</a>';
+ } else {
+ document.getElementById("service-status").innerHTML =
+ "Service stopped. [<a href='#'
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", true,
handleServiceStartStopCallback)'>Start</a>]";
//Disabling service editing
-
document.getElementById("edit-service").innerHTML =
- "Service editing is not available";
+ document.getElementById("edit-service").innerHTML =
+ "Service editing is not available";
//Disabling service sharing
-
document.getElementById("share-mashup").innerHTML =
- "Service sharing is not available"
- }
- }
-
- wso2.mashup.services.listServiceData('<%=mashup%>',
listServiceDataCallback);
- </script>
- <%}%>
- <li>
- <a href="#"
onclick="WSO2.MashupUtils.showCreateMashupDialog();">Create a
- new service</a>
- </li>
- <li id="share-mashup">
- Service sharing is not available
- </li>
- <!--Will be available only to users with Admin priviledges
OR who are Authors of the current Mashup-->
- <% if ((RegistryUtils.isAdminRole(registry)) ||
-
(author.equalsIgnoreCase(RegistryUtils.getCurrentUser(registry)))) { %>
- <li>
- <a href="#">Delete this service</a>
- </li>
- <%}%>
- </ul>
- </td>
- </tr>
- <%} else {%>
- <tr>
- <td><a href="signin.jsp?bounceback=<%=thisPage%>">Sign in</a> to
perform tasks</td>
- </tr>
- <%}%>
- </table>
- <%@ include file="taskbar.jsp" %>
+ document.getElementById("share-mashup").innerHTML =
+ "Service sharing is not available"
+ }
+ }
+
+ wso2.mashup.services.listServiceData('<%=mashup%>',
listServiceDataCallback);
+ </script>
+ <%}%>
+ <li>
+ <a href="#"
onclick="WSO2.MashupUtils.showCreateMashupDialog();">Create a
+ new service</a>
+ </li>
+ <li id="share-mashup">
+ Service sharing is not available
+ </li>
+ <!--Will be available only to users with Admin priviledges OR who
are Authors of the current Mashup-->
+ <% if ((RegistryUtils.isAdminRole(registry)) ||
+
(author.equalsIgnoreCase(RegistryUtils.getCurrentUser(registry)))) { %>
+ <script type="text/javascript">
+ function deleteServiceCallback() {
+ window.location = "index.jsp";
+ }
+ </script>
+ <li>
+ <a href="#"
+
onclick="wso2.mashup.services.deleteService('<%=mashup%>',deleteServiceCallback);">Delete
+ this service</a>
+ </li>
+ <%}%>
+ </ul>
+ </td>
+</tr>
+<%} else {%>
+<tr>
+ <td><a href="signin.jsp?bounceback=<%=thisPage%>">Sign in</a> to perform
tasks</td>
+</tr>
+<%}%>
+</table>
+<%@ include file="taskbar.jsp" %>
</td>
</tr>
</table>
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev