Author: tyrell
Date: Sun Jan 13 10:42:09 2008
New Revision: 12170
Log:
Adding ui source code saving.
Modified:
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
trunk/mashup/java/modules/www/editor.jsp
trunk/mashup/java/modules/www/js/services.js
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
Sun Jan 13 10:42:09 2008
@@ -238,7 +238,7 @@
ConfigurationContext configContext = serverManager.configContext;
File serviceJs = new
File(configContext.getRealPath(configContext.getContextRoot()) +
- "/scripts/" + path + ".js");
+ "/scripts/" + path + ".js");
//Writing the file with the source provided
BufferedWriter out = new BufferedWriter(new FileWriter(serviceJs));
@@ -254,41 +254,45 @@
return Boolean.valueOf(success);
}
- public Boolean saveUiSource(String serviceName, String modifiedSource) {
+ public Boolean saveUiSource(String path, String modifiedSource) {
boolean success = false;
- MessageContext currentMessageContext =
MessageContext.getCurrentMessageContext();
- AxisConfiguration configuration =
- currentMessageContext.getAxisService().getAxisConfiguration();
-
-
try {
- AxisService mashupService = configuration.getService(serviceName);
- Parameter resourcesFolderParameter = mashupService
- .getParameter(JavaScriptEngineConstants.RESOURCES_FOLDER);
+ //Extracting the real path from the registry path provided
+ String[] pathContents = path.split("/");
+ path = "";
+ for (int x = 2; x < pathContents.length; x++) {
+ path = path + "/" + pathContents[x];
+ }
- if (resourcesFolderParameter != null &&
resourcesFolderParameter.getValue() != null) {
- File wwwDir = new File(
- resourcesFolderParameter.getValue() + "/www");
+ String serviceName = pathContents[pathContents.length - 1];
- if (!wwwDir.exists()) {
- wwwDir.mkdirs();
- }
+ ServerManager serverManager = ServerManager.getInstance();
+ ConfigurationContext configContext = serverManager.configContext;
- //Getting the html file
- File uiHtmlFile = new File(wwwDir, "index.htm");
+ File wwwDir =
+ new
File(configContext.getRealPath(configContext.getContextRoot()) +
+ "/scripts/" + path + ".resources/www");
- if (!uiHtmlFile.exists()) {
- uiHtmlFile = new File(wwwDir, "index.html");
- }
+ if (!wwwDir.exists()) {
+ wwwDir.mkdirs();
+ }
- BufferedWriter out = new BufferedWriter(new
FileWriter(uiHtmlFile));
- out.write(modifiedSource);
- out.flush();
- out.close();
- success = true;
+ //Getting the html file
+ File uiHtmlFile = new File(wwwDir, "index.htm");
+
+ if (!uiHtmlFile.exists()) {
+ uiHtmlFile = new File(wwwDir, "index.html");
}
+
+ //Writing the file with the source provided
+ BufferedWriter out = new BufferedWriter(new
FileWriter(uiHtmlFile));
+ out.write(modifiedSource);
+ out.flush();
+ out.close();
+ success = true;
+
} catch (Exception e) {
e.printStackTrace();
}
Modified: trunk/mashup/java/modules/www/editor.jsp
==============================================================================
--- trunk/mashup/java/modules/www/editor.jsp (original)
+++ trunk/mashup/java/modules/www/editor.jsp Sun Jan 13 10:42:09 2008
@@ -132,86 +132,112 @@
type="text/javascript">userLoggedOn =
<%=RegistryUtils.isLoggedIn(registry) %>;</script>
<script language="JavaScript" type="text/javascript">
- var panels = new Array('mashup_code', 'ui_code');
- var selectedTab = null;
- function showPanel(tab, name)
+var panels = new Array('mashup_code', 'ui_code');
+var selectedTab = null;
+function showPanel(tab, name)
+{
+ if (selectedTab)
{
- if (selectedTab)
- {
- selectedTab.style.backgroundColor = '';
- selectedTab.style.paddingTop = '';
- selectedTab.style.marginTop = '4px';
- }
- selectedTab = tab;
- selectedTab.style.backgroundColor = 'white';
- selectedTab.style.paddingTop = '6px';
- selectedTab.style.marginTop = '0px';
- for (var i = 0; i < panels.length; i++)
- {
- document.getElementById(panels[i]).style.display =
- (name == panels[i]) ? 'block' : 'none';
- }
- return false;
+ selectedTab.style.backgroundColor = '';
+ selectedTab.style.paddingTop = '';
+ selectedTab.style.marginTop = '4px';
}
-
- function init() {
- try {
- showPanel(document.getElementById('tab1'), 'mashup_code');
- } catch(e) {
- }
+ selectedTab = tab;
+ selectedTab.style.backgroundColor = 'white';
+ selectedTab.style.paddingTop = '6px';
+ selectedTab.style.marginTop = '0px';
+ for (var i = 0; i < panels.length; i++)
+ {
+ document.getElementById(panels[i]).style.display =
+ (name == panels[i]) ? 'block' : 'none';
}
+ return false;
+}
- function saveServiceSourceCallback() {
- var lblInfo = document.getElementById("source_save_status");
+function init() {
+ try {
+ showPanel(document.getElementById('tab1'), 'mashup_code');
+ } catch(e) {
+ }
+}
- var saveSuccess;
+function saveSourceCallback() {
- var browser = WSRequest.util._getBrowser();
- if (browser == "ie" || browser == "ie7") {
- saveSuccess =
-
this.req.responseXML.getElementsByTagName("ns:return")[0].firstChild.nodeValue;
- } else {
- saveSuccess =
-
this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue;
- }
+ var lblInfo = document.getElementById(this.params);
- var currentTime = new Date();
- var hours = currentTime.getHours();
- var minutes = currentTime.getMinutes();
- var month = currentTime.getMonth() + 1;
- var day = currentTime.getDate();
- var year = currentTime.getFullYear();
-
- if (minutes < 10)
- minutes = "0" + minutes;
-
- var timeStamp = "at " + hours + ":" + minutes;
-
- if (hours > 11) {
- timeStamp = timeStamp + " PM";
- } else {
- timeStamp = timeStamp + " AM";
- }
+ var saveSuccess;
- timeStamp = timeStamp + " on " + month + "/" + day + "/" + year;
+ var browser = WSRequest.util._getBrowser();
+ if (browser == "ie" || browser == "ie7") {
+ saveSuccess =
+
this.req.responseXML.getElementsByTagName("ns:return")[0].firstChild.nodeValue;
+ } else {
+ saveSuccess =
+
this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue;
+ }
- if (saveSuccess == "true") {
- lblInfo.innerHTML = "";
- lblInfo.innerHTML =
- "<font color=green>Your source edits were successfully updated " +
timeStamp +
- "</font>";
- } else {
- lblInfo.innerHTML = "";
- lblInfo.innerHTML =
- "<font color=red>Failed to update source edits " + timeStamp +
"</font>";
- }
+ var currentTime = new Date();
+ var hours = currentTime.getHours();
+ var minutes = currentTime.getMinutes();
+ var month = currentTime.getMonth() + 1;
+ var day = currentTime.getDate();
+ var year = currentTime.getFullYear();
+
+ if (minutes < 10)
+ minutes = "0" + minutes;
+
+ var timeStamp = "at " + hours + ":" + minutes;
+
+ if (hours > 11) {
+ timeStamp = timeStamp + " PM";
+ } else {
+ timeStamp = timeStamp + " AM";
}
- function saveServiceSource(newSource) {
- wso2.mashup.services.saveServiceSource('<%=mashup%>', newSource,
saveServiceSourceCallback, "");
+ timeStamp = timeStamp + " on " + month + "/" + day + "/" + year;
+
+ if (saveSuccess == "true") {
+ lblInfo.innerHTML = "";
+ lblInfo.innerHTML =
+ "<font color=green>Your source edits were successfully updated " +
timeStamp +
+ "</font>";
+ } else {
+ lblInfo.innerHTML = "";
+ lblInfo.innerHTML =
+ "<font color=red>Failed to update source edits " + timeStamp +
"</font>";
}
+}
+
+function saveServiceSource(newSource) {
+<%
+if(action.equalsIgnoreCase("edit")){
+%>
+ wso2.mashup.services.saveServiceSource('<%=mashup%>', newSource,
saveSourceCallback, "source_save_status");
+<%
+}else if(action.equalsIgnoreCase("new")){
+%>
+ wso2.mashup.services.saveServiceSource('<%="/mashups/" + currentUser + "/"
+ mashup%>', newSource, saveSourceCallback, "source_save_status");
+<%
+}
+%>
+}
+
+function saveUiSource(newSource) {
+<%
+ if(action.equalsIgnoreCase("edit")){
+%>
+ wso2.mashup.services.saveUiSource('<%=mashup%>', newSource,
saveSourceCallback, "ui_save_status");
+<%
+}else if(action.equalsIgnoreCase("new")){
+%>
+ wso2.mashup.services.saveUiSource('<%="/mashups/" + currentUser + "/" +
mashup%>', newSource, saveSourceCallback, "ui_save_status");
+<%
+}
+%>
+}
+
</script>
</head>
<body onload="init();">
@@ -288,7 +314,8 @@
</textarea>
<br>
- <div style="padding-top: 10px;"><label id="source_save_status"
style="float: left;">Tip: You can use the button on
+ <div style="padding-top: 10px;"><label id="source_save_status"
style="float: left;">Tip: You can
+ use the button on
the right to save changes.</label> <input type="button"
value="Save mashup code"
onclick="saveServiceSource(mashup_code_text.getCode());"
@@ -396,8 +423,17 @@
}
%>
<textarea id="ui_code_text" rows="" cols="" class="codepress html"
- style="width: 100%; height: 100%;"><%=uiSource%>
+ style="width: 100%; height: 95%;"><%=uiSource%>
</textarea>
+<br>
+
+<div style="padding-top: 10px;"><label id="ui_save_status" style="float:
left;">Tip: You can
+ use the button on
+ the right to save changes.</label> <input type="button"
+ value="Save custom ui code"
+
onclick="saveUiSource(ui_code_text.getCode());"
+ style="float: right;"/>
+</div>
</div>
</div>
<%
Modified: trunk/mashup/java/modules/www/js/services.js
==============================================================================
--- trunk/mashup/java/modules/www/js/services.js (original)
+++ trunk/mashup/java/modules/www/js/services.js Sun Jan 13 10:42:09 2008
@@ -347,18 +347,18 @@
/**
* @description Saves the CustomUI of a JS Service
- * @param {String} serviceName Name of the service
+ * @param {String} path Path of the service
* @param {String} modifiedSource Ammended source code
* @param {callback} callBack User-defined callback function or object
* @param {callback} params Parameters to be set in the callback
*/
-wso2.mashup.services.saveUiSource = function (serviceName, modifiedSource,
callback, params) {
+wso2.mashup.services.saveUiSource = function (path, modifiedSource, callback,
params) {
var callURL = serverURL + "/" + "ServiceMetaDataLister" + "/" ;
var serviceSource = "<![CDATA[" + modifiedSource + "]]>";
var body_xml = '<req:saveUiSourceOpRequest
xmlns:req="http://servicemetadatalister.coreservices.mashup.wso2.org/xsd">\n' +
- ' <req:serviceName>' + serviceName + '</req:serviceName>\n'
+
+ ' <req:path>' + path + '</req:path>\n' +
' <req:modifiedSource>' + serviceSource +
'</req:modifiedSource>\n' +
' </req:saveUiSourceOpRequest>\n';
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev