[Carbon-dev] svn commit r31256 - in branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main: java/org/wso2/carbon/dataservices/admin resources/META-INF
sumedha at wso2.com
sumedha at wso2.com
Sun Feb 22 20:02:16 PST 2009
Author: sumedha
Date: Sun Feb 22 20:02:15 2009
New Revision: 31256
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=31256
Log:
BE,FE seperation
Modified:
branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/java/org/wso2/carbon/dataservices/admin/DataServiceAdmin.java
branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/resources/META-INF/services.xml
Modified: branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/java/org/wso2/carbon/dataservices/admin/DataServiceAdmin.java
URL: http://wso2.org/svn/browse/wso2/branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/java/org/wso2/carbon/dataservices/admin/DataServiceAdmin.java?rev=31256&r1=31255&r2=31256&view=diff
==============================================================================
--- branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/java/org/wso2/carbon/dataservices/admin/DataServiceAdmin.java (original)
+++ branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/java/org/wso2/carbon/dataservices/admin/DataServiceAdmin.java Sun Feb 22 20:02:15 2009
@@ -75,6 +75,7 @@
* @return DataServiceInfo; Instance of DataServiceInfo
* @throws org.apache.axis2.AxisFault will be thrown
*/
+ /*
public DataServiceInfo getDSMetaData(String init) throws AxisFault {
if (init == null || init.length() == 0) {
//Call for new one DS.
@@ -115,6 +116,7 @@
return dataServiceInfo;
}
}
+ */
/**
* Returns data service content as a String
@@ -150,6 +152,7 @@
* @return OMElement
* @throws AxisFault will be thrown
*/
+ /*
public OMElement getDataServiceContents(String serviceId) throws AxisFault {
String fileContent = getDataServiceContentAsString(serviceId);
OMElement returnEle;
@@ -166,6 +169,7 @@
}
return returnEle;
}
+ */
/**
* Saves a modified <data/> DS configuration
@@ -173,6 +177,7 @@
* @param dataWrapper wrapps the <data/> element
* @throws AxisFault will be thrown
*/
+ /*
public void saveDataServiceContents(OMElement dataWrapper) throws AxisFault {
String serviceId;
OMElement configEle = dataWrapper.getFirstChildWithName(new QName("data"));
@@ -270,13 +275,69 @@
}
}
+*/
/**
- * Returns list of known database server jdbc urls and driver class names from server.xml
- * TODO: Sumedha fix this, so the drivers can be obtained from a configuration file, rather
- * TODO: server.xml. As core is a component, this shoulbe taken from either WSO2 regisrty etc.
- *
- * @return DBServerData array
- */
+ * saves a data service
+ *
+ * @param serviceName - name of the service
+ * @param serviceContents - contents of the data service
+ */
+ public void saveDataService(String serviceName, String serviceContents) throws AxisFault {
+ String dataServiceFilePath;
+ AxisService axisService = getAxisConfig().getService(serviceName);
+ if (axisService == null) {
+ // New service
+ String axis2RepoDirectory = getAxisConfig().getRepository().getPath();
+ ConfigurationContext configCtx = getConfigContext();
+ String repoDirectory = (String) configCtx.getProperty(DBConstants.DB_SERVICE_REPO);
+ String fileExtension = (String) configCtx.getProperty(DBConstants.DB_SERVICE_EXTENSION);
+
+ String dataServiceDirectory = axis2RepoDirectory + File.separator + repoDirectory;
+ dataServiceFilePath = dataServiceDirectory + File.separator + serviceName + "."
+ + fileExtension;
+
+ // create the directory, if it does not exist
+ File directory = new File(dataServiceDirectory);
+ directory.mkdirs();
+
+ File file = new File(dataServiceFilePath);
+ try {
+ file.createNewFile();
+ } catch (IOException e) {
+ throw new AxisFault(
+ "Error while creating the file for the new service configuration "
+ + serviceName, e);
+ }
+ } else {
+ dataServiceFilePath = (String) axisService.getParameter(
+ DBConstants.DB_SERVICE_CONFIG_FILE).getValue();
+ }
+
+ // Save contents to .dbs file
+ BufferedWriter out;
+ try {
+ out = new BufferedWriter(new FileWriter(dataServiceFilePath));
+ out.write(serviceContents);
+ out.close();
+ XMLPrettyPrinter.prettify(new File(dataServiceFilePath));
+
+ } catch (IOException e) {
+ log.error("Error while saving " + serviceName, e);
+ throw new AxisFault(
+ "Error occurred while writing the contents for the service config file for the new service "
+ + serviceName, e);
+ }
+ }
+
+
+ /**
+ * Returns list of known database server jdbc urls and driver class names
+ * from server.xml TODO: Sumedha fix this, so the drivers can be obtained
+ * from a configuration file, rather TODO: server.xml. As core is a
+ * component, this shoulbe taken from either WSO2 regisrty etc.
+ *
+ * @return DBServerData array
+ */
public DBServerData[] getDatabaseUrlDriverList() throws XMLStreamException {
ArrayList databaseServers = new ArrayList();
DBServerData databaseServerData;
Modified: branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/resources/META-INF/services.xml
URL: http://wso2.org/svn/browse/wso2/branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/resources/META-INF/services.xml?rev=31256&r1=31255&r2=31256&view=diff
==============================================================================
--- branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/resources/META-INF/services.xml (original)
+++ branches/carbon/1.5.1/trunk/carbon-components/data-services/org.wso2.carbon.dataservices.core/src/main/resources/META-INF/services.xml Sun Feb 22 20:02:15 2009
@@ -16,7 +16,7 @@
~ limitations under the License.
-->
<serviceGroup>
- <service name="DataServiceAdmin" scope="transportsession">
+ <service name="DataServiceAdmin">
<schema schemaNamespace="http://org.apache.axis2/xsd" elementFormDefaultQualified="false"/>
<transports>
<transport>https</transport>
@@ -25,7 +25,10 @@
This service will help to create/modify a data service.
</description>
<parameter name="ServiceClass">org.wso2.carbon.dataservices.admin.DataServiceAdmin</parameter>
+ <parameter name="enableMTOM" locked="false">true</parameter>
</service>
+
+
<!-- Admin service for .dbs file uploader -->
<service name="DataServiceFileUploader">
<transports>
@@ -36,7 +39,9 @@
</parameter>
<parameter name="enableMTOM" locked="false">true</parameter>
<operation name="uploadService"></operation>
- </service>
+ </service>
+
+
<parameter name="AuthorizationAction" locked="true">manage-configuration</parameter>
<parameter name="adminService" locked="ture">true</parameter>
</serviceGroup>
More information about the Carbon-dev
mailing list