Hi Anjana/Chanika,

Did we decide to remove the services.xml support for the data services? I
noticed the below commit which made its way into DSS 3.2.1.

Thanks.

---------- Forwarded message ----------
From: <[email protected]>
Date: Thu, Aug 28, 2014 at 9:54 AM
Subject: [Commits] [Carbon-platform] svn commit r206697 - in
carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4:
. src/main/java/org/wso2/carbon/dataservices/core
To: [email protected]


Author: [email protected]
Date: Thu Aug 28 09:54:36 2014
New Revision: 206697
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=206697

Log:
Fixing DS-953

Modified:

 
carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/pom.xml

 
carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/src/main/java/org/wso2/carbon/dataservices/core/DBDeployer.java

Modified:
carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/pom.xml
URL:
http://wso2.org/svn/browse/wso2/carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/pom.xml?rev=206697&r1=206696&r2=206697&view=diff
==============================================================================
---
carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/pom.xml
  (original)
+++
carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/pom.xml
  Thu Aug 28 09:54:36 2014
@@ -127,7 +127,7 @@
         <dependency>
             <groupId>org.wso2.carbon</groupId>
             <artifactId>org.wso2.carbon.dataservices.common</artifactId>
-            <version>4.2.3</version>
+            <version>4.2.4</version>
         </dependency>
         <dependency>
             <groupId>org.wso2.carbon</groupId>

Modified:
carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/src/main/java/org/wso2/carbon/dataservices/core/DBDeployer.java
URL:
http://wso2.org/svn/browse/wso2/carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/src/main/java/org/wso2/carbon/dataservices/core/DBDeployer.java?rev=206697&r1=206696&r2=206697&view=diff
==============================================================================
---
carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/src/main/java/org/wso2/carbon/dataservices/core/DBDeployer.java
  (original)
+++
carbon/platform/branches/turing/components/data-services/org.wso2.carbon.dataservices.core/4.2.4/src/main/java/org/wso2/carbon/dataservices/core/DBDeployer.java
  Thu Aug 28 09:54:36 2014
@@ -18,6 +18,7 @@
  */
 package org.wso2.carbon.dataservices.core;

+import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.soap.SOAP11Constants;
@@ -35,8 +36,10 @@
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.wsdl.WSDLUtil;
+import org.apache.neethi.Policy;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.PolicyEngine;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
 import org.wso2.carbon.CarbonConstants;
 import org.wso2.carbon.base.MultitenantConstants;
@@ -56,6 +59,7 @@
 import org.wso2.carbon.ndatasource.common.DataSourceConstants;
 import org.wso2.carbon.ndatasource.common.DataSourceException;
 import org.wso2.carbon.ndatasource.core.DataSourceManager;
+import org.wso2.carbon.registry.core.Registry;
 import org.wso2.carbon.user.core.UserStoreException;
 import org.wso2.carbon.user.core.service.RealmService;
 import org.wso2.carbon.utils.CarbonUtils;
@@ -1070,34 +1074,17 @@
         * if so, the AxisService representing the data service is applied
the instructions from its
         * "services.xml".
         */
* -       private AxisService handleServicesXML(String dbsPath,
AxisServiceGroup axisServiceGroup,*
-                       AxisService axisService) throws DataServiceFault {
+       private AxisService handleTransports(DeploymentFileData file,
AxisService axisService) throws DataServiceFault {
                try {
-                       String serviceXMLPath = dbsPath.substring(0,
dbsPath.length() - 4) +
-
 DBConstants.DBS_SERVICES_XML_SUFFIX;
-                       File servicesXMLFile = new File(serviceXMLPath);
-                       if (servicesXMLFile.exists()) {
-                               XMLStreamReader parser =
DBUtils.getXMLInputFactory().createXMLStreamReader(
-                                               new
FileInputStream(servicesXMLFile));
-                               StAXOMBuilder builder = new
StAXOMBuilder(parser);
-                               OMElement documentElement =
builder.getDocumentElement();
-                               if
(documentElement.getLocalName().equals(DBConstants.AXIS2_SERVICE_GROUP)) {
-                                       HashMap<String, AxisService>
wsdlServices = new HashMap<String, AxisService>();
-
 wsdlServices.put(axisService.getName(), axisService);
-                                       ServiceGroupBuilder sgb = new
ServiceGroupBuilder(documentElement,
-                                                       wsdlServices,
this.getConfigContext());
-                                       axisService =
sgb.populateServiceGroup(axisServiceGroup).get(0);
-                               } else if
(documentElement.getLocalName().equals(DBConstants.AXIS2_SERVICE)) {
-                                       ServiceBuilder sb = new
ServiceBuilder(this.getConfigContext(),
-                                                       axisService);
-                                       axisService =
sb.populateService(documentElement);
-                               } else {
-                                       throw new
DataServiceFault("services xml file: " + serviceXMLPath +
-                                                       " is not valid,
cannot find the 'service' or 'serviceGroup' element");
-                               }
-                       }
+            StAXOMBuilder builder = new StAXOMBuilder(new
FileInputStream(file.getFile().getAbsoluteFile()));
+            OMElement documentElement =  builder.getDocumentElement();
+            OMAttribute transports = documentElement.getAttribute(new
QName(DBSFields.TRANSPORTS));
+            if (transports != null) {
+                String [] transportArr =
transports.getAttributeValue().split(" ");
+
axisService.setExposedTransports(Arrays.asList(transportArr));
+            }
                } catch (Exception e) {
-                       throw new DataServiceFault(e, "Error in processing
services.xml");
+                       throw new DataServiceFault(e, "Error in processing
transports info");
                }
                return axisService;
        }
@@ -1113,10 +1100,33 @@
                axisService.setParent(axisServiceGroup);

axisService.setClassLoader(axisConfig.getServiceClassLoader());
         /* handle services.xml, if exists */
-               this.handleServicesXML(currentFile.getAbsolutePath(),
axisServiceGroup, axisService);
+               this.handleTransports(currentFile, axisService);
+        this.handleSecurityProxy(currentFile, axisService);
                return axisService;
        }

+    private AxisService handleSecurityProxy(DeploymentFileData file,
AxisService axisService) throws DataServiceFault{
+        try {
+            StAXOMBuilder builder = new StAXOMBuilder(new
FileInputStream(file.getFile().getAbsoluteFile()));
+            OMElement documentElement =  builder.getDocumentElement();
+            OMElement policyElement=
documentElement.getFirstChildWithName(new QName(DBSFields.POLICY));
+            if (policyElement != null) {
+                String policyKey = policyElement.getAttributeValue(new
QName(DBSFields.POLICY_KEY));
+                Policy policy = PolicyEngine.getPolicy(
+                        DBUtils.getInputStreamFromPath(policyKey));
+                axisService.getPolicySubject().attachPolicy(policy);
+            }
+            OMElement enableSecElement=
documentElement.getFirstChildWithName(new QName(DBSFields.ENABLESEC));
+            if (enableSecElement != null) {
+
axisService.engageModule(this.configCtx.getAxisConfiguration().getModule(
+                        DBConstants.SECURITY_MODULE_NAME),
this.configCtx.getAxisConfiguration());
+            }
+        }catch (Exception e) {
+            throw new DataServiceFault(e, "Error in processing security
policy");
+        }
+        return axisService;
+    }
+
     @SuppressWarnings("unchecked")
        private void secureVaultResolve(OMElement dbsElement) {
        String secretAliasAttr = dbsElement.getAttributeValue(new
QName(DataSourceConstants.SECURE_VAULT_NS,
_______________________________________________
Commits mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commits



-- 

*Kasun Gajasinghe*Senior Software Engineer, WSO2 Inc.
email: kasung AT spamfree wso2.com
linked-in: http://lk.linkedin.com/in/gajasinghe
blog: http://kasunbg.org
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to