Author: tyrell
Date: Wed Feb 27 09:43:45 2008
New Revision: 14272
Log:
Fixing MASHUP-608
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
trunk/mashup/java/modules/coreservices/servicesharinghelper/src/org/wso2/mashup/coreservices/servicesharinghelper/ServiceSharingHelper.java
trunk/mashup/java/modules/coreservices/sharingservice/src/org/wso2/mashup/share/service/MashupSharingService.java
trunk/mashup/java/modules/www/js/mashup-utils.js
trunk/mashup/java/modules/www/js/services.js
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
==============================================================================
---
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
(original)
+++
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java
Wed Feb 27 09:43:45 2008
@@ -143,7 +143,7 @@
*/
public void uploadMashupService(String destinationServerAddress,
DataHandler dataHandler,
ConfigurationContext configCtx, String
serviceJsFileName,
- String mashupServiceName, String username,
String password)
+ String mashupServiceName, String username,
String password, String overwriteExisting)
throws AxisFault {
if (destinationServerAddress.startsWith("http://")) {
@@ -174,7 +174,7 @@
// parameters to the service ServiceName string, service file name,
// dataHandler of the bundled archive
Object[] opAddEntryArgs =
- new Object[] {mashupServiceName, username,
password,serviceJsFileName, dataHandler};
+ new Object[] {mashupServiceName, username,
password,serviceJsFileName, dataHandler, overwriteExisting};
try {
serviceClient.invokeRobust(opAddEntry, opAddEntryArgs);
} catch (AxisFault axisFault) {
@@ -332,8 +332,9 @@
// Checking whether a file with the same name exists
File file = new File(scriptsFolder, fileName);
if (file.exists()) {
- throw new MashupFault("A Service JavaScript file with the same
name already " +
- "exists in the remote Mashup Server.");
+ /*throw new MashupFault("A Service JavaScript file with the
same name already " +
+ "exists in the remote Mashup Server."); */
+ file.delete();
}
MashupArchiveManupulator archiveManupulator = new
MashupArchiveManupulator();
// Extract the uploaded mashup archive to the scripts folder.
Modified:
trunk/mashup/java/modules/coreservices/servicesharinghelper/src/org/wso2/mashup/coreservices/servicesharinghelper/ServiceSharingHelper.java
==============================================================================
---
trunk/mashup/java/modules/coreservices/servicesharinghelper/src/org/wso2/mashup/coreservices/servicesharinghelper/ServiceSharingHelper.java
(original)
+++
trunk/mashup/java/modules/coreservices/servicesharinghelper/src/org/wso2/mashup/coreservices/servicesharinghelper/ServiceSharingHelper.java
Wed Feb 27 09:43:45 2008
@@ -48,7 +48,7 @@
private static final Log log = LogFactory.getLog(GlobalAdmin.class);
public Boolean shareService(String serviceName, String username, String
password,
- String destinationServerAddress)
+ String destinationServerAddress, String
overwriteExisting)
throws IOException {
boolean success;
@@ -82,7 +82,7 @@
serviceName.substring(serviceName.indexOf(MashupConstants.SEPARATOR_CHAR) + 1);
masshupArchiveManupulator.uploadMashupService(destinationServerAddress,
dataHandler,
configContext,
serviceJS.getName(),
- shortServiceName,
username, password);
+ shortServiceName,
username, password, overwriteExisting);
log
.info("Shared Service \'" + serviceName + "' to the
destination server"
+ destinationServerAddress + " at " +
date.format(currentTime) + "from "
Modified:
trunk/mashup/java/modules/coreservices/sharingservice/src/org/wso2/mashup/share/service/MashupSharingService.java
==============================================================================
---
trunk/mashup/java/modules/coreservices/sharingservice/src/org/wso2/mashup/share/service/MashupSharingService.java
(original)
+++
trunk/mashup/java/modules/coreservices/sharingservice/src/org/wso2/mashup/share/service/MashupSharingService.java
Wed Feb 27 09:43:45 2008
@@ -54,7 +54,7 @@
* @throws IOException - Thrown in case the service cannot be found
*/
public void shareMashup(String serviceName, String username, String
password, String fileName,
- DataHandler dataHandler)
+ DataHandler dataHandler, String overwriteExisting)
throws IOException {
if (dataHandler == null) {
throw new MashupFault("Cannot read the uploaded Mashup Service.");
@@ -62,7 +62,7 @@
MessageContext messageContext =
MessageContext.getCurrentMessageContext();
AxisConfiguration axisConfiguration =
messageContext.getConfigurationContext()
.getAxisConfiguration();
- if (axisConfiguration.getService(username +
MashupConstants.SEPARATOR_CHAR + serviceName) != null) {
+ if ((axisConfiguration.getService(username +
MashupConstants.SEPARATOR_CHAR + serviceName) != null) &&
(!overwriteExisting.equals("true"))) {
throw new AxisFault(
"A Service with a same name already exists in the remote
Mashup Server.");
}
Modified: trunk/mashup/java/modules/www/js/mashup-utils.js
==============================================================================
--- trunk/mashup/java/modules/www/js/mashup-utils.js (original)
+++ trunk/mashup/java/modules/www/js/mashup-utils.js Wed Feb 27 09:43:45 2008
@@ -82,7 +82,8 @@
mashupEprs = xmlDataContent.getElementsByTagName("eprs");
mashupOperartions = xmlDataContent.getElementsByTagName("operations");
mashupStatus =
xmlDataContent.getElementsByTagName("active")[0].firstChild.nodeValue;
- mashupServiceType =
xmlDataContent.getElementsByTagName("serviceType")[0].firstChild.nodeValue;
+ mashupServiceType =
+
xmlDataContent.getElementsByTagName("serviceType")[0].firstChild.nodeValue;
}
@@ -162,6 +163,7 @@
'<tr><td nowrap height="25"><b>Destination Server
Address: </b></td><td><input name="txtDestAddress" type="text"
id="txtDestAddress" value="https://mooshup.com" size="50"/></td></tr>' +
'<tr><td nowrap height="25"><b>Destination Server
Username: </b></td><td><input name="txtDestUsername" type="text"
id="txtDestUsername" size="50"/></td></tr>' +
'<tr><td nowrap height="25"><b>Destination Server
Password: </b></td><td><input name="txtDestPassword" type="password"
id="txtDestPassword" size="50"/></td></tr>' +
+ '<tr><td nowrap height="25"><b>Overwrite if the
service already exists? </b></td><td><input name="chkOverwrite" type="checkbox"
id="chkOverwrite"/></td></tr>' +
'<tr><td nowrap height="30" valign="bottom"><input
type="button" id="cmdShare" value="Share"
onclick="WSO2.MashupUtils.shareService(\'' +
serviceName + '\');"/></td></tr>' +
'</table>' +
@@ -226,10 +228,15 @@
var destAddress = document.getElementById("txtDestAddress").value;
var destUsername = document.getElementById("txtDestUsername").value;
var destPassword = document.getElementById("txtDestPassword").value;
+ var overwriteExisting = "false";
+ if (document.getElementById("chkOverwrite").checked) {
+ overwriteExisting = "true";
+ }
+
if (WSO2.MashupUtils.isUrl(destAddress)) {
labelElement.innerHTML = "Contacting backend services. Please wait...";
- wso2.mashup.services.shareService(serviceName, destAddress,
destUsername, destPassword, submitServiceCallback, labelElement,
submitServiceError);
+ wso2.mashup.services.shareService(serviceName, destAddress,
destUsername, destPassword, overwriteExisting, submitServiceCallback,
labelElement, submitServiceError);
}
else {
labelElement.innerHTML = "Please enter a valid server address here
...";
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 Wed Feb 27 09:43:45 2008
@@ -286,7 +286,7 @@
* @param {callback} params Parameters to be set in the callback
*/
wso2.mashup.services.shareService =
-function (serviceName, destinationAddress, username, password, callback,
params, errorCallback) {
+function (serviceName, destinationAddress, username, password,
overwriteExisting, callback, params, errorCallback) {
var callURL = serverURL + "/" + "ServiceSharingHelper" + "/" ;
@@ -296,6 +296,8 @@
' <req:password>' + password + '</req:password>\n' +
' <req:destinationServerAddress>' + destinationAddress +
'</req:destinationServerAddress>\n' +
+ ' <req:overwriteExisting>' + overwriteExisting +
+ '</req:overwriteExisting>\n' +
' </req:shareServiceRequest>\n';
new wso2.wsf.WSRequest(callURL, "shareService", body_xml, callback,
params, errorCallback);
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev