Author: keith
Date: Mon Mar 24 22:39:13 2008
New Revision: 15050

Log:

Adding data services support. Now we can have .dbs files under the user 
directories. This is just the basic support it does not show up in the UI as 
yet.
Will refractor the code after initial commit



Added:
   trunk/mashup/java/modules/core/src/org/wso2/mashup/deployers/
   trunk/mashup/java/modules/core/src/org/wso2/mashup/deployers/DBDeployer.java
Modified:
   trunk/mashup/java/modules/core/conf/axis2.xml
   trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
   
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java

Modified: trunk/mashup/java/modules/core/conf/axis2.xml
==============================================================================
--- trunk/mashup/java/modules/core/conf/axis2.xml       (original)
+++ trunk/mashup/java/modules/core/conf/axis2.xml       Mon Mar 24 22:39:13 2008
@@ -121,6 +121,7 @@
 
     <!-- Deployer for the JavaScript services -->
     <deployer extension=".js" directory="scripts/system" 
class="org.wso2.mashup.deployer.JSDeployer" />
+    <deployer extension=".dbs" directory="scripts/system" 
class="org.wso2.mashup.deployers.DBDeployer" />
 
     <!-- ================================================= -->
     <!-- Message Receivers -->

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
Mon Mar 24 22:39:13 2008
@@ -69,6 +69,7 @@
 
     public static final String USER_REGISTRY = "user_registry";
     public static final String MASHUP_MEDIA_TYPE = "wso2_mashup";
+    public static final String DATA_SERVICE_MEDIA_TYPE = "wso2_data_service";
     public static final String EVERYONE_ROLE = "everyone";
     public static final String CONTENT_MD5 = "content_md5";
 

Added: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/deployers/DBDeployer.java
==============================================================================
--- (empty file)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/deployers/DBDeployer.java    
    Mon Mar 24 22:39:13 2008
@@ -0,0 +1,301 @@
+package org.wso2.mashup.deployers;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.deployment.DeploymentErrorMsgs;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.DescriptionBuilder;
+import org.apache.axis2.deployment.repository.util.DeploymentFileData;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.i18n.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.javascript.rhino.JavaScriptEngineConstants;
+import org.wso2.mashup.MashupConstants;
+import org.wso2.mashup.MashupFault;
+import org.wso2.mashup.utils.MashupUtils;
+import org.wso2.mashup.webapp.utils.RegistryUtils;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.ResourceImpl;
+import org.wso2.registry.jdbc.JDBCRegistry;
+import org.wso2.registry.secure.SecureRegistry;
+import org.wso2.registry.users.AccessControlAdmin;
+import org.wso2.registry.users.UserRealm;
+import org.wso2.registry.users.UserStoreException;
+import org.wso2.registry.users.accesscontrol.AccessControlConstants;
+import org.wso2.ws.dataservice.DBConstants;
+import org.wso2.ws.dataservice.DBMessageReceiver;
+import org.wso2.ws.dataservice.beans.Config;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/*
+ * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+public class DBDeployer extends org.wso2.ws.dataservice.DBDeployer {
+
+    private static final Log log = LogFactory.getLog(DBDeployer.class);
+//    private AxisConfiguration axisConfig;
+//    private ConfigurationContext configCtx;
+    private AxisService axisService = null;
+
+    public void init(ConfigurationContext configCtx) {
+        this.configCtx = configCtx;
+        axisConfig = this.configCtx.getAxisConfiguration();
+    }
+
+    public void deploy(DeploymentFileData deploymentFileData) {
+        StringWriter errorWriter = new StringWriter();
+        String serviceStatus = "";
+        try {
+            
deploymentFileData.setClassLoader(axisConfig.getServiceClassLoader());
+            AxisServiceGroup serviceGroup = new AxisServiceGroup(axisConfig);
+            
serviceGroup.setServiceGroupClassLoader(deploymentFileData.getClassLoader());
+            ArrayList serviceList = processService(deploymentFileData, 
serviceGroup,
+                                                   configCtx);
+            if (serviceList != null) {
+                DeploymentEngine.addServiceGroup(serviceGroup, serviceList, 
deploymentFileData
+                        .getFile().toURL(), deploymentFileData, axisConfig);
+
+                log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS, 
deploymentFileData
+                        .getName()));
+            }
+            MashupUtils.notifyMonitor("Deployment Success", 
deploymentFileData.getName() +
+                    " deployed successfully", 3);
+        } catch (DeploymentException deploymentException) {
+            log.error(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE, 
deploymentFileData
+                    .getName(), deploymentException.getMessage()), 
deploymentException);
+            PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
+            deploymentException.printStackTrace(error_ptintWriter);
+            serviceStatus = "Error:\n" + errorWriter.toString();
+            MashupUtils.notifyMonitor("Deployment Error", 
deploymentFileData.getName() +
+                    " deployment failed", 1);
+//            throw deploymentException;
+        } catch (Throwable t) {
+            // Even though catching Throwable is not recomended, we do not want
+            // the server to fail on errors like NoClassDefFoundError
+            if (log.isInfoEnabled()) {
+                StringWriter sw = new StringWriter();
+                PrintWriter pw = new PrintWriter(sw);
+                t.printStackTrace(pw);
+                
log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE,
+                                             deploymentFileData.getName(),
+                                             sw.getBuffer().toString()));
+            }
+            PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
+            t.printStackTrace(error_ptintWriter);
+            serviceStatus = "Error:\n" + errorWriter.toString();
+            MashupUtils.notifyMonitor("Error", deploymentFileData.getName() +
+                    " deployment unsuccessful", 0);
+//            throw new DeploymentException(t);
+        } finally {
+            if (serviceStatus.startsWith("Error:")) {
+                
axisConfig.getFaultyServices().put(deploymentFileData.getFile().getAbsolutePath(),
+                                                   serviceStatus);
+                try {
+                    populateRegistry(deploymentFileData,
+                                     "This Service is Faulty. Reason : " + 
serviceStatus,
+                                     DescriptionBuilder.getShortFileName(
+                                             deploymentFileData.getName()),
+                                     true);
+                } catch (DeploymentException e) {
+                    e.printStackTrace();  //To change body of catch statement 
use File | Settings | File Templates.
+                }
+
+            }
+        }
+    }
+
+    private ArrayList processService(DeploymentFileData currentFile,
+                                     AxisServiceGroup axisServiceGroup,
+                                     ConfigurationContext configCtx)
+            throws AxisFault {
+        axisService = createDBService(currentFile.getAbsolutePath(),
+                                      configCtx.getAxisConfiguration());
+        String name = axisService.getName();
+        MashupUtils.validateName(name, "ServiceName");
+
+        UserRealm realm = (UserRealm) 
configCtx.getAxisConfiguration().getParameterValue(
+                RegistryConstants.REGISTRY_REALM);
+        // Infer the username (The owner of this service)
+        File file = currentFile.getFile();
+        String username = inferUserName(file, realm, name);
+
+        //create a service group per service.
+        // ServiceGroup name and axisservice name will be of the form 
username-serviceName
+        // Use the js filename as the service group name.
+        String fileName = currentFile.getName();
+        axisServiceGroup.setServiceGroupName(username + 
MashupConstants.SEPARATOR_CHAR +
+                fileName.substring(0, fileName.indexOf(".")));
+        axisService.setName(username + MashupConstants.SEPARATOR_CHAR + name);
+
+        axisService.setParent(axisServiceGroup);
+        axisService.setClassLoader(axisConfig.getServiceClassLoader());
+        ArrayList serviceList = new ArrayList();
+        serviceList.add(axisService);
+
+        // Creating the service.resources dir
+        // For more details see 
http://www.wso2.org/wiki/display/mashup/scripts+folder+structure+and+deployment
+        File parentDir = file.getParentFile();
+        String shortFileName = 
DescriptionBuilder.getShortFileName(currentFile.getName());
+        File resourcesDir = new File(parentDir, shortFileName + ".resources");
+        resourcesDir.mkdir();
+
+        // creating _private folder in the resources folder to keep private 
stuff
+        File privatedir = new File(resourcesDir, 
MashupConstants.MASHUP_PRIVATE_FOLDER_NAME);
+        privatedir.mkdir();
+        // Add a reference to the resources folder, as this is quite usefull 
in the runtime
+        Parameter resourceFolderParameter = new Parameter(
+                JavaScriptEngineConstants.RESOURCES_FOLDER, resourcesDir);
+        axisService.addParameter(resourceFolderParameter);
+        return serviceList;
+    }
+
+    private String inferUserName(File file, UserRealm realm, String 
serviceName)
+            throws MashupFault {
+        String username = file.getParentFile().getName();
+        try {
+            if (!realm.getUserStoreAdmin().isExistingUser(username)) {
+                throw new MashupFault("No user with the username " + username +
+                        " exists in the system. Cannot deploy " + serviceName);
+            }
+        } catch (UserStoreException e) {
+            throw new MashupFault(e);
+        }
+        return username;
+    }
+
+    private String populateRegistry(DeploymentFileData currentFile, String 
documentation,
+                                    String name, boolean faulty)
+            throws DeploymentException {
+
+        try {
+            UserRealm realm = (UserRealm) 
configCtx.getAxisConfiguration().getParameterValue(
+                    RegistryConstants.REGISTRY_REALM);
+            File file = currentFile.getFile();
+
+            // Infer the username (The owner of this service)
+            String username = inferUserName(file, realm, name);
+
+            // Assembling the path for this service
+            String path1 = "/mashups/" + username + "/" + name;
+
+            // Get the realm and the registry
+            JDBCRegistry registry =
+                    (JDBCRegistry) 
configCtx.getAxisConfiguration().getParameterValue(
+                            RegistryConstants.REGISTRY);
+            SecureRegistry secureRegistry =
+                    RegistryUtils.createSecureRegistry(username, registry, 
realm);
+
+            ResourceImpl resource1;
+
+            //todo: Workaround to figure out whether the resource is deleted. 
Remove when registry implements undelete/rollback.
+            boolean resourceExists = false;
+            try {
+                secureRegistry.get(path1);
+                resourceExists = true;
+            } catch (RegistryException e) {
+                //just swallowing the exception
+            }
+
+            if (resourceExists) {
+                //Getting the existing latest version from the registry
+                resource1 = (ResourceImpl) secureRegistry.get(path1);
+
+                String regMD5 = "";
+                try {
+                    regMD5 = 
resource1.getProperty(MashupConstants.CONTENT_MD5);
+                } catch (Exception e) {
+                    log.warn(e);
+                }
+
+                String fileMD5 = MashupUtils.calculateFileMD5(file);
+
+                if (!regMD5.equals(fileMD5)) {
+                    // The content of the service has changed, updating the 
registry
+                    addToRegistry(currentFile, documentation, faulty, file, 
username, path1,
+                                  secureRegistry);
+                }
+
+            } else {
+                // A brand new service, adding to the registry
+                addToRegistry(currentFile, documentation, faulty, file, 
username, path1,
+                              secureRegistry);
+            }
+
+            AccessControlAdmin ac = realm.getAccessControlAdmin();
+            ac.authorizeUser(username, path1, AccessControlConstants.EDIT);
+            ac.authorizeUser(username, path1, AccessControlConstants.DELETE);
+
+            return path1;
+        } catch (RegistryException e) {
+            throw new DeploymentException(e);
+        } catch (IOException e) {
+            throw new DeploymentException(e);
+        } catch (UserStoreException e) {
+            throw new DeploymentException(e);
+        }
+    }
+
+    private void addToRegistry(DeploymentFileData currentFile, String 
documentation, boolean faulty,
+                               File file, String username, String path1,
+                               SecureRegistry secureRegistry)
+            throws IOException, RegistryException {
+        ResourceImpl resource1;// create a content resource
+        resource1 = new ResourceImpl();
+
+        resource1.setAuthorUserName(username);
+        FileInputStream fis = new FileInputStream(file);
+        FileChannel fc = fis.getChannel();
+        byte[] data =
+                new byte[(int) (fc.size())];   // fc.size returns the size of 
the file which backs the channel
+        ByteBuffer bb = ByteBuffer.wrap(data);
+        fc.read(bb);
+        resource1.setContent(data);
+        resource1.setDescription(documentation);
+        resource1.setMediaType(MashupConstants.DATA_SERVICE_MEDIA_TYPE);
+        if (faulty) {
+            resource1.setProperty(MashupConstants.FAULTY_MASHUP, "true");
+        }
+
+        //Setting the service js file path and resources directory path
+        resource1.setProperty(DBConstants.DB_SERVICE_CONFIG_FILE, 
file.getAbsolutePath());
+
+        //Setting the MD5 of the content
+        resource1.setProperty(MashupConstants.CONTENT_MD5, 
MashupUtils.calculateFileMD5(file));
+
+        File resourcesDir = new File(currentFile.getFile().getParent(), 
DescriptionBuilder
+                .getShortFileName(currentFile.getName()) + ".resources");
+        resource1.setProperty(JavaScriptEngineConstants.RESOURCES_FOLDER,
+                              resourcesDir.getAbsolutePath());
+
+        // store it in a non existence path
+        secureRegistry.put(path1, resource1);
+    }
+
+}

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
   (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
   Mon Mar 24 22:39:13 2008
@@ -82,6 +82,7 @@
                                 .getConfigurator();
                 ArrayList arrayList = new ArrayList(1);
                 arrayList.add("js");
+                arrayList.add("dbs");
                 HashMap map = 
deploymentEngine.getDirectoryToExtensionMappingMap();
                 HashMap newMap = (HashMap) map.clone();
                 newMap.put("scripts/" + username, arrayList);

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
  (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
  Mon Mar 24 22:39:13 2008
@@ -585,8 +585,9 @@
             if (configContext != null) {
                 DeploymentEngine deploymentEngine =
                         (DeploymentEngine) 
configContext.getAxisConfiguration().getConfigurator();
-                ArrayList arrayList = new ArrayList(1);
+                ArrayList arrayList = new ArrayList(2);
                 arrayList.add("js");
+                arrayList.add("dbs");
                 HashMap map = 
deploymentEngine.getDirectoryToExtensionMappingMap();
                 HashMap newMap = (HashMap) map.clone();
                 newMap.put("scripts/" + userName, arrayList);

Modified: 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
==============================================================================
--- 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
   (original)
+++ 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
   Mon Mar 24 22:39:13 2008
@@ -859,9 +859,9 @@
                 addQuery(
                         registry,
                         MashupConstants.ALL_MASHUPS_QUERY_PATH,
-                        "SELECT PATH FROM ARTIFACTS WHERE STATE=100 AND 
MEDIA_TYPE='" +
+                        "SELECT PATH FROM ARTIFACTS WHERE STATE=100 AND 
(MEDIA_TYPE='" +
                                 MashupConstants
-                                        .MASHUP_MEDIA_TYPE + "' ORDER BY 
LAST_UPDATED_TIME DESC",
+                                        .MASHUP_MEDIA_TYPE + "' OR 
MEDIA_TYPE='wso2_data_service') ORDER BY LAST_UPDATED_TIME DESC",
                         RegistryConstants.RESOURCES_RESULT_TYPE
                 );
 
@@ -869,9 +869,9 @@
                 addQuery(
                         registry,
                         MashupConstants.MY_MASHUPS_QUERY_PATH,
-                        "SELECT PATH FROM ARTIFACTS WHERE STATE=100 AND 
AUTHOR=? AND MEDIA_TYPE='" +
-                                MashupConstants.MASHUP_MEDIA_TYPE +
-                                "' ORDER BY LAST_UPDATED_TIME DESC",
+                        "SELECT PATH FROM ARTIFACTS WHERE STATE=100 AND 
AUTHOR=? AND (MEDIA_TYPE='" +
+                                MashupConstants
+                                        .MASHUP_MEDIA_TYPE + "' OR 
MEDIA_TYPE='wso2_data_service') ORDER BY LAST_UPDATED_TIME DESC",
                         RegistryConstants.RESOURCES_RESULT_TYPE
                 );
 
@@ -879,9 +879,9 @@
                 addQuery(
                         registry,
                         MashupConstants.TOP_MASHUPS_QUERY_PATH,
-                        "SELECT A.PATH FROM ARTIFACTS A, RATINGS R WHERE 
A.STATE=100 AND A.AID=R.AID AND A.MEDIA_TYPE='" +
-                                MashupConstants.MASHUP_MEDIA_TYPE +
-                                "' GROUP BY A.PATH HAVING AVG(R.RATING) >= 4.0 
ORDER BY AVG(R.RATING) DESC",
+                        "SELECT A.PATH FROM ARTIFACTS A, RATINGS R WHERE 
A.STATE=100 AND A.AID=R.AID AND (A.MEDIA_TYPE='" +
+                                MashupConstants
+                                        .MASHUP_MEDIA_TYPE + "' OR 
A.MEDIA_TYPE='wso2_data_service') GROUP BY A.PATH HAVING AVG(R.RATING) >= 4.0 
ORDER BY AVG(R.RATING) DESC",
                         RegistryConstants.RESOURCES_RESULT_TYPE
                 );
 
@@ -889,9 +889,9 @@
                 addQuery(
                         registry,
                         MashupConstants.MY_TOP_MASHUPS_QUERY_PATH,
-                        "SELECT A.PATH FROM ARTIFACTS A, RATINGS R WHERE 
A.STATE=100 AND A.AID=R.AID AND A.AUTHOR=? AND A.MEDIA_TYPE='" +
-                                MashupConstants.MASHUP_MEDIA_TYPE +
-                                "' GROUP BY A.PATH HAVING AVG(R.RATING) >= 4.0 
ORDER BY AVG(R.RATING) DESC",
+                        "SELECT A.PATH FROM ARTIFACTS A, RATINGS R WHERE 
A.STATE=100 AND A.AID=R.AID AND A.AUTHOR=? AND (A.MEDIA_TYPE='" +
+                                MashupConstants
+                                        .MASHUP_MEDIA_TYPE + "' OR 
A.MEDIA_TYPE='wso2_data_service') GROUP BY A.PATH HAVING AVG(R.RATING) >= 4.0 
ORDER BY AVG(R.RATING) DESC",
                         RegistryConstants.RESOURCES_RESULT_TYPE
                 );
 
@@ -915,8 +915,9 @@
                 addQuery(
                         registry,
                         MashupConstants.USER_TAGS_QUERY_PATH,
-                        "SELECT A.PATH FROM ARTIFACTS A, TAGS T WHERE 
A.STATE=100 AND A.PATH=? AND T.TAG_NAME=? AND T.AID=A.AID AND T.USER_ID=? AND 
A.MEDIA_TYPE='" +
-                                MashupConstants.MASHUP_MEDIA_TYPE + "'",
+                        "SELECT A.PATH FROM ARTIFACTS A, TAGS T WHERE 
A.STATE=100 AND A.PATH=? AND T.TAG_NAME=? AND T.AID=A.AID AND T.USER_ID=? AND 
(A.MEDIA_TYPE='" +
+                                MashupConstants
+                                        .MASHUP_MEDIA_TYPE + "' OR 
A.MEDIA_TYPE='wso2_data_service')",
                         RegistryConstants.RESOURCES_RESULT_TYPE
                 );
 
@@ -925,8 +926,9 @@
                 addQuery(
                         registry,
                         MashupConstants.CUSTOM_QUERY_PATH,
-                        "SELECT DISTINCT A.PATH FROM ARTIFACTS A, TAGS T WHERE 
A.STATE=100 AND (A.PATH LIKE ? OR A.DESCRIPTION LIKE ? OR (T.TAG_NAME=? AND 
T.AID=A.AID)) AND A.MEDIA_TYPE='" +
-                                MashupConstants.MASHUP_MEDIA_TYPE + "'",
+                        "SELECT DISTINCT A.PATH FROM ARTIFACTS A, TAGS T WHERE 
A.STATE=100 AND (A.PATH LIKE ? OR A.DESCRIPTION LIKE ? OR (T.TAG_NAME=? AND 
T.AID=A.AID)) AND (A.MEDIA_TYPE='" +
+                                MashupConstants
+                                        .MASHUP_MEDIA_TYPE + "' OR 
A.MEDIA_TYPE='wso2_data_service')",
                         RegistryConstants.RESOURCES_RESULT_TYPE
                 );
 
@@ -935,8 +937,9 @@
                 addQuery(
                         registry,
                         MashupConstants.MY_CUSTOM_QUERY_PATH,
-                        "SELECT DISTINCT A.PATH FROM ARTIFACTS A, TAGS T WHERE 
A.STATE=100 AND (A.PATH LIKE ? OR A.DESCRIPTION LIKE ? OR (T.TAG_NAME=? AND 
T.AID=A.AID)) AND A.AUTHOR=? AND A.MEDIA_TYPE='" +
-                                MashupConstants.MASHUP_MEDIA_TYPE + "'",
+                        "SELECT DISTINCT A.PATH FROM ARTIFACTS A, TAGS T WHERE 
A.STATE=100 AND (A.PATH LIKE ? OR A.DESCRIPTION LIKE ? OR (T.TAG_NAME=? AND 
T.AID=A.AID)) AND A.AUTHOR=? AND (A.MEDIA_TYPE='" +
+                                MashupConstants
+                                        .MASHUP_MEDIA_TYPE + "' OR 
A.MEDIA_TYPE='wso2_data_service')",
                         RegistryConstants.RESOURCES_RESULT_TYPE
                 );
 
@@ -944,8 +947,9 @@
                 addQuery(
                         registry,
                         MashupConstants.COMMENTS_QUERY_PATH,
-                        "SELECT C.CM_ID FROM COMMENTS C, ARTIFACTS A WHERE 
C.COMMENT_TEXT LIKE ? AND C.AID=A.AID AND A.STATE=100 AND A.MEDIA_TYPE='" +
-                                MashupConstants.MASHUP_MEDIA_TYPE + "'",
+                        "SELECT C.CM_ID FROM COMMENTS C, ARTIFACTS A WHERE 
C.COMMENT_TEXT LIKE ? AND C.AID=A.AID AND A.STATE=100 AND (A.MEDIA_TYPE='" +
+                                MashupConstants
+                                        .MASHUP_MEDIA_TYPE + "' OR 
A.MEDIA_TYPE='wso2_data_service')",
                         RegistryConstants.COMMENTS_RESULT_TYPE
                 );
 
@@ -953,8 +957,9 @@
                 addQuery(
                         registry,
                         MashupConstants.MY_COMMENTS_QUERY_PATH,
-                        "SELECT C.CM_ID FROM COMMENTS C, ARTIFACTS A WHERE 
C.COMMENT_TEXT LIKE ? AND C.USER_ID=? AND C.AID=A.AID AND A.STATE=100 AND 
A.MEDIA_TYPE='" +
-                                MashupConstants.MASHUP_MEDIA_TYPE + "'",
+                        "SELECT C.CM_ID FROM COMMENTS C, ARTIFACTS A WHERE 
C.COMMENT_TEXT LIKE ? AND C.USER_ID=? AND C.AID=A.AID AND A.STATE=100 AND 
(A.MEDIA_TYPE='" +
+                                MashupConstants
+                                        .MASHUP_MEDIA_TYPE + "' OR 
A.MEDIA_TYPE='wso2_data_service')",
                         RegistryConstants.COMMENTS_RESULT_TYPE
                 );
 
@@ -962,8 +967,9 @@
                 addQuery(
                         registry,
                         MashupConstants.USERS_COMMENTS_QUERY_PATH,
-                        "SELECT C.CM_ID FROM COMMENTS C, ARTIFACTS A WHERE 
C.USER_ID=? AND C.AID=A.AID AND A.STATE=100 AND A.MEDIA_TYPE='" +
-                                MashupConstants.MASHUP_MEDIA_TYPE + "'",
+                        "SELECT C.CM_ID FROM COMMENTS C, ARTIFACTS A WHERE 
C.USER_ID=? AND C.AID=A.AID AND A.STATE=100 AND (A.MEDIA_TYPE='" +
+                                MashupConstants
+                                        .MASHUP_MEDIA_TYPE + "' OR 
A.MEDIA_TYPE='wso2_data_service')",
                         RegistryConstants.COMMENTS_RESULT_TYPE
                 );
 

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

Reply via email to