Author: keith
Date: Tue Mar 25 01:17:11 2008
New Revision: 15065

Log:

Fixing ?download for dataservices



Modified:
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor/DownloadProcessor.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupArchiveManupulator.java

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor/DownloadProcessor.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor/DownloadProcessor.java
  (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/requestprocessor/DownloadProcessor.java
  Tue Mar 25 01:17:11 2008
@@ -46,11 +46,8 @@
 
             if (axisService.isActive()) {
 
-                String serviceType =
-                        (String) 
axisService.getParameterValue(ServerConstants.SERVICE_TYPE);
-
                 // We can show source only if this service is a javascript 
service
-                if (MashupConstants.MASHUP_JS_SERVICE.equals(serviceType)) {
+                if (MashupUtils.isMashupService(serviceName)) {
 
                     response.setContentType("application/zip;charset=UTF-8");
                     response.setHeader("Content-disposition",

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
      Tue Mar 25 01:17:11 2008
@@ -37,6 +37,7 @@
 import org.wso2.mashup.MashupFault;
 import org.wso2.utils.ArchiveManipulator;
 import org.wso2.wsas.ServerConstants;
+import org.wso2.ws.dataservice.DBConstants;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
@@ -96,16 +97,32 @@
 
     public void createMashupArchive(AxisService mashupService, 
ConfigurationContext configCtx,
                                     OutputStream outputStream) throws 
MashupFault {
-        File serviceJS;
+        File serviceFile;
         File serviceResourceFolder = null;
-        // Get the service js file for the given service
-        Parameter serviceJSParameter = mashupService
-                .getParameter(JavaScriptEngineConstants.SERVICE_JS);
-        if (serviceJSParameter != null && serviceJSParameter.getValue() != 
null) {
-            serviceJS = (File) serviceJSParameter.getValue();
+
+        String serviceType =
+                (String) 
mashupService.getParameterValue(ServerConstants.SERVICE_TYPE);
+        if (MashupConstants.MASHUP_JS_SERVICE.equals(serviceType)) {
+            // Get the service js file for the given service
+            Parameter serviceJSParameter = mashupService
+                    .getParameter(JavaScriptEngineConstants.SERVICE_JS);
+            Object value = serviceJSParameter.getValue();
+            if (serviceJSParameter != null && value != null) {
+                serviceFile = (File) value;
+            } else {
+                throw new MashupFault("Service you are trying to share is not 
a Mashup Service.");
+            }
         } else {
-            throw new MashupFault("Service you are trying to share is not a 
Mashup Service.");
+            Parameter serviceJSParameter = mashupService
+                    .getParameter(DBConstants.DB_SERVICE_CONFIG_FILE);
+            String value = (String) serviceJSParameter.getValue();
+            if (serviceJSParameter != null && value != null) {
+                serviceFile = new File(value);
+            } else {
+                throw new MashupFault("Service you are trying to share is not 
a Mashup Service.");
+            }
         }
+
         // Access the resources folder for the service
         Parameter serviceResourceFolderParameter = mashupService
                 .getParameter(JavaScriptEngineConstants.RESOURCES_FOLDER);
@@ -113,14 +130,14 @@
             serviceResourceFolder = (File) 
serviceResourceFolderParameter.getValue();
         }
 
-        if (serviceJS != null && serviceResourceFolder != null) {
+        if (serviceFile != null && serviceResourceFolder != null) {
             try {
                 // Creating a FileDataSource
                 ZipOutputStream zos = new ZipOutputStream(outputStream);
                 // write the service js file & the contents of the
                 // service.resources folder to the outstream of the data source
 
-                createMashupArchive(zos, serviceJS, serviceResourceFolder);
+                createMashupArchive(zos, serviceFile, serviceResourceFolder);
                 return;
             } catch (IOException e) {
                 throw new MashupFault(e);
@@ -346,7 +363,7 @@
                         try {
 
                             //Authenticating the user
-                            boolean authenticated = false;
+                            boolean authenticated;
                             try {
                                 authenticated = 
MashupUtils.authenticateUser(username, password);
                             } catch (AuthenticatorException e) {
@@ -376,6 +393,7 @@
      * @param fileName          -
      *                          filename of the service js file (to validate 
whether a file
      *                          with same name exists)
+     * @param username          - The username
      * @param dataHandler       -
      *                          archived mashup service Js & the resources
      * @param axisConfiguration - Axis Configuration
@@ -417,7 +435,7 @@
         //get a listing of the directory content
         String[] dirList = zipDir.list();
         byte[] readBuffer = new byte[40960];
-        int bytesIn = 0;
+        int bytesIn;
         //loop through dirList, and zip the files
         for (int i = 0; i < dirList.length; i++) {
             String dir = dirList[i];

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to