Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

restSQL 0.7.1 release adds table aliasing

  • Loading branch information...
commit 35585f62b7713e82e59b34e152db0e68fc915535 1 parent a190fb5
restSQL restsql authored
18 README.txt
... ... @@ -1,4 +1,4 @@
1   -README.txt (15-Sep-2011)
  1 +README.txt (23-Oct-2011)
2 2
3 3 restSQL Deployment Guide
4 4
@@ -160,14 +160,24 @@ web.xml: Change the restSQL WEB-INF/web.xml. The LifecycleManager needs to know
160 160
161 161 The default deployment descriptor (web.xml) contains login config (authentication method) and security constraints (authorization declarations). See the restSQL SDK's /restsql-sdk/default/xml/web.xml for the default deployment descriptor.
162 162
163   -Disabling Security: To disable authentication/authorization, simply remove or comment out the security-constraint and login-config elements in the web.xml.
  163 +Disabling Authentication and Authorization: To disable authentication/authorization, simply remove or comment out the security-constraint and login-config elements in the web.xml.
164 164
165   -Enabling Security: You may use the default security constraints and login config or change it to conform to your specific roles, realm and other requirements. More information on Web Application Security using deployment descriptors is available at http://java.sun.com/javaee/6/docs/tutorial/doc/bncbe.html. Or consult your container's documentation. Authentication mechanisms (credential management, user to role assigment) are typically container-specific/proprietary. You will also need to configure a privileges properties file and reference it in the restsql properties file. See the SDK's Security configuration for instructions.
  165 +Enabling Authentication and Authorization: You may use the default security constraints and login config or change it to conform to your specific roles, realm and other requirements. More information on Web Application Security using deployment descriptors is available at http://java.sun.com/javaee/6/docs/tutorial/doc/bncbe.html. Or consult your container's documentation. Authentication mechanisms (credential management, user to role assigment) are typically container-specific/proprietary. You will also need to configure a privileges properties file and reference it in the restsql properties file. See the SDK's Security configuration for instructions.
166 166
167 167 Naming: You may deploy this as a single file or exploded war to your JEE container. Rename it to restsql.war or webapps/restsql if you want the path to be http://yourhost:port/restsql. Containers generally use the war file name instead of the web.xml's id to name the web app. Additionally, the SDK's HTTP API Explorer will work without any customization.
168 168
169 169 Deploy: Copy your exploded war or war to your container's webapps dir and restart the container, or deploy the webapp in your preferred style. All third party dependencies are included in the war distribution in the WEB-INF/lib.
170 170
  171 +Java Security Manager: If Java Security is enabled in your container, permissions must be added to your container's policy file. restSQL requires:
  172 + * read/write access (java.util.PropertyPermission) to the following system properties: org.restsql.properties, org.apache.commons.logging.Log and either log4j.configuration for log4j logging or java.util.logging.config.file for Java Native logging
  173 + * read access (java.io.FilePermission) to the various properties files, and SQL Resources and triggers directories
  174 +
  175 +However, restsql uses other libraries (jersey, jdbc, logging) which need some unknown combination of access permissions. The only configuration that has been demonstrated to work is to grant all permissions to restsql. For example for Tomcat, add this to the end of the ${TOMCAT_HOME}/conf/catalina.policy file:
  176 +
  177 + grant codeBase "file:${catalina.base}/webapps/restsql/-" {
  178 + permission java.security.AllPermission;
  179 + };
  180 +
171 181
172 182 -------------------------------------------------------------------------------
173 183 Installing restSQL JAR mode
@@ -184,7 +194,7 @@ Additionally one of the following jdbc drivers is necessary for databases with b
184 194 * mysql-connector-java-#.jar (tested with MySQL version 5.5)
185 195 * postgresql-#.jdbc4.jar (tested with PostgreSQL version 9.0)
186 196
187   -Enabling Security: restSQL will authorize SQL Resource operations. Your app will authenticate users and associate users with roles. You must provide a priviliges properties file and reference it in the restsql.properties. Your app will call restSQL's Authorizer and provide a SecurityContextimplementation. See the SDK's Security configuration for more instructions.
  197 +Enabling Authentication and Authorization: restSQL will authorize SQL Resource operations. Your app will authenticate users and associate users with roles. You must provide a priviliges properties file and reference it in the restsql.properties. Your app will call restSQL's Authorizer and provide a SecurityContextimplementation. See the SDK's Security configuration for more instructions.
188 198
189 199
190 200 -------------------------------------------------------------------------------
14 WebContent/WEB-INF/web.xml
@@ -43,7 +43,19 @@
43 43 <param-value>/restsql/eclipse-workspace/restsql-test/src/resources/properties/restsql-mysql.properties</param-value>
44 44 </context-param>
45 45
46   - <!-- Remove security-constraints and login-config for no authentication/authorization -->
  46 + <!-- Remove security-roles, security-constraints and login-config for no authentication/authorization -->
  47 + <security-role>
  48 + <role-name>all</role-name>
  49 + </security-role>
  50 + <security-role>
  51 + <role-name>limited</role-name>
  52 + </security-role>
  53 + <security-role>
  54 + <role-name>readonly</role-name>
  55 + </security-role>
  56 + <security-role>
  57 + <role-name>admin</role-name>
  58 + </security-role>
47 59 <security-constraint>
48 60 <web-resource-collection>
49 61 <web-resource-name>SQL Resources</web-resource-name>
2  build.properties
... ... @@ -1,5 +1,5 @@
1 1 # restsql build.properties
2   -build.version=0.7
  2 +build.version=0.7.1
3 3
4 4 compile.classpath=lib/servlet-api.jar;lib/jersey-server-1.5.jar;lib/jsr311-api-1.1.1.jar;lib/commons-logging-1.1.1.jar;../restsql/lib/postgresql-9.0-801.jdbc4.jar
5 5
2  build.xml
@@ -88,7 +88,7 @@
88 88 <mkdir dir="obj/war/WEB-INF/lib" />
89 89 <copy todir="obj/war/WEB-INF/lib">
90 90 <path>
91   - <fileset dir="lib" includes="*.jar" excludes="jaxb-*.jar" />
  91 + <fileset dir="lib" includes="*.jar" excludes="jaxb-*.jar,servlet-api.jar" />
92 92 </path>
93 93 </copy>
94 94
12 src/org/restsql/core/Factory.java
@@ -23,9 +23,13 @@
23 23
24 24 /** Returns connection. */
25 25 public static Connection getConnection(final String defaultDatabase) throws SQLException {
26   - final ConnectionFactory connectionFactory = (ConnectionFactory) getInstance(
27   - Config.KEY_CONNECTION_FACTORY, Config.DEFAULT_CONNECTION_FACTORY);
28   - return connectionFactory.getConnection(defaultDatabase);
  26 + return getConnectionFactory().getConnection(defaultDatabase);
  27 + }
  28 +
  29 + /** Return connection factory. Useful for destroying it on app unload. */
  30 + public static ConnectionFactory getConnectionFactory() {
  31 + return (ConnectionFactory) getInstance(Config.KEY_CONNECTION_FACTORY,
  32 + Config.DEFAULT_CONNECTION_FACTORY);
29 33 }
30 34
31 35 /** Returns request object. */
@@ -140,6 +144,8 @@ public static SqlResourceMetaData getSqlResourceMetaData(final SqlResourceDefini
140 144 /** Creates JDBC connection objects. */
141 145 public interface ConnectionFactory {
142 146 public Connection getConnection(String defaultDatabase) throws SQLException;
  147 +
  148 + public void destroy() throws SQLException;
143 149 }
144 150
145 151 /** Creates request objects. */
4 src/org/restsql/core/SqlResource.java
@@ -76,7 +76,7 @@
76 76 * @throws SqlResourceException if a database access error occurs
77 77 * @return list of rows, where each row is a map of name-value pairs
78 78 */
79   - public List<Map<String, Object>> readCollection(Request request)
  79 + public List<Map<String, Object>> readAsCollection(Request request)
80 80 throws SqlResourceException;
81 81
82 82 /**
@@ -86,7 +86,7 @@
86 86 * @throws SqlResourceException if a database access error occurs
87 87 * @return list of rows, where each row is a map of name-value pairs
88 88 */
89   - public String readXml(Request request) throws SqlResourceException;
  89 + public String readAsXml(Request request) throws SqlResourceException;
90 90
91 91 /**
92 92 * Executes insert, update or delete.
3  src/org/restsql/core/TableMetaData.java
@@ -29,6 +29,9 @@
29 29 */
30 30 public String getQualifiedTableName();
31 31
  32 + /** Returns table alias. */
  33 + public String getTableAlias();
  34 +
32 35 /** Returns table name. */
33 36 public String getTableName();
34 37
6 src/org/restsql/core/impl/AbstractSqlResourceMetaData.java
@@ -361,12 +361,18 @@ private void buildTablesAndColumns(final ResultSet resultSet) throws SQLExceptio
361 361 switch (tableRole) {
362 362 case Parent:
363 363 parentTable = table;
  364 + if (definition.getParentAlias() != null) {
  365 + table.setTableAlias(definition.getParentAlias());
  366 + }
364 367 // fall through
365 368 case ParentExtension:
366 369 parentPlusExtTables.add(table);
367 370 break;
368 371 case Child:
369 372 childTable = table;
  373 + if (definition.getChildAlias() != null) {
  374 + table.setTableAlias(definition.getChildAlias());
  375 + }
370 376 // fall through
371 377 case ChildExtension:
372 378 childPlusExtTables.add(table);
32 src/org/restsql/core/impl/ConnectionFactoryImpl.java
@@ -2,8 +2,10 @@
2 2 package org.restsql.core.impl;
3 3
4 4 import java.sql.Connection;
  5 +import java.sql.Driver;
5 6 import java.sql.DriverManager;
6 7 import java.sql.SQLException;
  8 +import java.util.Properties;
7 9
8 10 import org.restsql.core.Config;
9 11 import org.restsql.core.Factory.ConnectionFactory;
@@ -15,27 +17,41 @@
15 17 * @author Mark Sawers
16 18 */
17 19 public class ConnectionFactoryImpl implements ConnectionFactory {
18   - private String driverClassName, url, user, password;
  20 + private final String driverClassName, url;
  21 + private final Properties connectProperties;
  22 + private Driver driver;
19 23
20 24 public ConnectionFactoryImpl() {
21 25 driverClassName = Config.properties.getProperty(Config.KEY_DATABASE_DRIVER_CLASSNAME,
22 26 Config.DEFAULT_DATABASE_DRIVER_CLASSNAME);
23 27 url = Config.properties.getProperty(Config.KEY_DATABASE_URL, Config.DEFAULT_DATABASE_URL);
24   - user = Config.properties.getProperty(Config.KEY_DATABASE_USER, Config.DEFAULT_DATABASE_USER);
25   - password = Config.properties.getProperty(Config.KEY_DATABASE_PASSWORD,
  28 + String user = Config.properties.getProperty(Config.KEY_DATABASE_USER, Config.DEFAULT_DATABASE_USER);
  29 + String password = Config.properties.getProperty(Config.KEY_DATABASE_PASSWORD,
26 30 Config.DEFAULT_DATABASE_PASSWORD);
  31 + connectProperties = new Properties();
  32 + connectProperties.put("user", user);
  33 + connectProperties.put("password", password);
27 34 }
28 35
29 36 public Connection getConnection(String defaultDatabase) throws SQLException {
30   - try {
31   - Class.forName(driverClassName).newInstance();
32   - } catch (Exception exception) {
33   - throw new SQLException("Failed to load JDBC driver class " + driverClassName, exception);
  37 + if (driver == null) {
  38 + try {
  39 + Class.forName(driverClassName).newInstance();
  40 + } catch (Exception exception) {
  41 + throw new SQLException("Failed to load JDBC driver class " + driverClassName, exception);
  42 + }
  43 + driver = DriverManager.getDriver(url);
34 44 }
35   - Connection connection = DriverManager.getConnection(url, user, password);
  45 + Connection connection = driver.connect(url, connectProperties);
36 46 if (defaultDatabase != null) {
37 47 connection.setCatalog(defaultDatabase);
38 48 }
39 49 return connection;
40 50 }
  51 +
  52 + public void destroy() throws SQLException {
  53 + if (driver != null) {
  54 + DriverManager.deregisterDriver(driver);
  55 + }
  56 + }
41 57 }
8 src/org/restsql/core/impl/Serializer.java
@@ -85,9 +85,9 @@ static void appendReadDocStart(final StringBuffer string) {
85 85 private static void serializeRows(final SqlResource sqlResource, final List<Map<String, Object>> rows,
86 86 final StringBuffer string, final int level) {
87 87 boolean hierarchical = false;
88   - String tableName = sqlResource.getDefinition().getParent();
  88 + String tableAlias = sqlResource.getParentTable().getTableAlias();
89 89 if (level == 2) {
90   - tableName = sqlResource.getDefinition().getChild();
  90 + tableAlias = sqlResource.getChildTable().getTableAlias();
91 91 }
92 92 for (final Map<String, Object> row : rows) {
93 93 if (level == 1) {
@@ -95,7 +95,7 @@ private static void serializeRows(final SqlResource sqlResource, final List<Map<
95 95 } else {
96 96 string.append("\n\t\t<");
97 97 }
98   - string.append(tableName);
  98 + string.append(tableAlias);
99 99
100 100 // Do parent attribute columns
101 101 for (final String columnLabel : row.keySet()) {
@@ -118,7 +118,7 @@ private static void serializeRows(final SqlResource sqlResource, final List<Map<
118 118
119 119 if (hierarchical) {
120 120 string.append("\n\t</");
121   - string.append(tableName);
  121 + string.append(tableAlias);
122 122 string.append(">");
123 123 } else if (level == 2) {
124 124 string.append(" />");
6 src/org/restsql/core/impl/SqlResourceImpl.java
@@ -88,7 +88,7 @@ public boolean isHierarchical() {
88 88 * @throws TriggerException if a trigger error occurs
89 89 * @return list of rows, where each row is a map of name-value pairs
90 90 */
91   - public List<Map<String, Object>> readCollection(final Request request) throws SqlResourceException {
  91 + public List<Map<String, Object>> readAsCollection(final Request request) throws SqlResourceException {
92 92 TriggerManager.executeTriggers(getName(), request, true);
93 93
94 94 final List<Map<String, Object>> results;
@@ -131,7 +131,7 @@ public boolean isHierarchical() {
131 131 * @throws SqlResourceException if the request is invalid or a database access error or trigger exception occurs
132 132 * @return xml string
133 133 */
134   - public String readXml(final Request request) throws SqlResourceException {
  134 + public String readAsXml(final Request request) throws SqlResourceException {
135 135 TriggerManager.executeTriggers(getName(), request, true);
136 136
137 137 String results;
@@ -280,7 +280,7 @@ private String buildReadResultsFlatXml(final ResultSet resultSet) throws SQLExce
280 280 boolean newParent = false;
281 281 final int numberParentElementColumns = metaData.getParentReadColumns().size();
282 282 final int numberChildElementColumns = metaData.getChildReadColumns().size();
283   - final String childRowElementName = definition.getChild() + "s";
  283 + final String childRowElementName = metaData.getChild().getTableAlias() + "s";
284 284 Map<String, Object> parentRow = null;
285 285 List<Map<String, Object>> childRows = null;
286 286
10 src/org/restsql/core/impl/TableMetaDataImpl.java
@@ -20,12 +20,14 @@
20 20 private final String databaseName;
21 21 private final List<ColumnMetaData> primaryKeys;
22 22 private final String qualifiedTableName;
  23 + private String tableAlias;
23 24 private final String tableName;
24 25 private final TableRole tableRole;
25 26
26 27 public TableMetaDataImpl(final String tableName, final String qualifedTableName,
27 28 final String databaseName, final TableRole tableRole) {
28 29 this.tableName = tableName;
  30 + this.tableAlias = tableName;
29 31 qualifiedTableName = qualifedTableName;
30 32 this.databaseName = databaseName;
31 33 this.tableRole = tableRole;
@@ -57,6 +59,10 @@ public String getQualifiedTableName() {
57 59 return qualifiedTableName;
58 60 }
59 61
  62 + public String getTableAlias() {
  63 + return tableAlias;
  64 + }
  65 +
60 66 public String getTableName() {
61 67 return tableName;
62 68 }
@@ -72,4 +78,8 @@ public boolean isChild() {
72 78 public boolean isParent() {
73 79 return tableRole == TableRole.Parent;
74 80 }
  81 +
  82 + void setTableAlias(String tableAlias) {
  83 + this.tableAlias = tableAlias;
  84 + }
75 85 }
18 src/org/restsql/core/sqlresource/ObjectFactory.java
@@ -2,7 +2,7 @@
2 2 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-147
3 3 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
4 4 // Any modifications to this file will be lost upon recompilation of the source schema.
5   -// Generated on: 2011.07.12 at 06:05:14 PM EDT
  5 +// Generated on: 2011.10.23 at 11:14:14 AM EDT
6 6 //
7 7
8 8
@@ -41,6 +41,14 @@ public ObjectFactory() {
41 41 }
42 42
43 43 /**
  44 + * Create an instance of {@link ValidatedAttribute }
  45 + *
  46 + */
  47 + public ValidatedAttribute createValidatedAttribute() {
  48 + return new ValidatedAttribute();
  49 + }
  50 +
  51 + /**
44 52 * Create an instance of {@link Query }
45 53 *
46 54 */
@@ -57,14 +65,6 @@ public SqlResourceDefinition createSqlResourceDefinition() {
57 65 }
58 66
59 67 /**
60   - * Create an instance of {@link ValidatedAttribute }
61   - *
62   - */
63   - public ValidatedAttribute createValidatedAttribute() {
64   - return new ValidatedAttribute();
65   - }
66   -
67   - /**
68 68 * Create an instance of {@link JAXBElement }{@code <}{@link SqlResourceDefinition }{@code >}}
69 69 *
70 70 */
2  src/org/restsql/core/sqlresource/Query.java
@@ -2,7 +2,7 @@
2 2 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-147
3 3 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
4 4 // Any modifications to this file will be lost upon recompilation of the source schema.
5   -// Generated on: 2011.07.12 at 06:05:14 PM EDT
  5 +// Generated on: 2011.10.23 at 11:14:14 AM EDT
6 6 //
7 7
8 8
56 src/org/restsql/core/sqlresource/SqlResourceDefinition.java
@@ -2,7 +2,7 @@
2 2 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-147
3 3 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
4 4 // Any modifications to this file will be lost upon recompilation of the source schema.
5   -// Generated on: 2011.07.12 at 06:05:14 PM EDT
  5 +// Generated on: 2011.10.23 at 11:14:14 AM EDT
6 6 //
7 7
8 8
@@ -33,8 +33,10 @@
33 33 * &lt;attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
34 34 * &lt;attribute name="defaultDatabase" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
35 35 * &lt;attribute name="parent" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
  36 + * &lt;attribute name="parentAlias" type="{http://www.w3.org/2001/XMLSchema}string" />
36 37 * &lt;attribute name="parentExt" type="{http://www.w3.org/2001/XMLSchema}string" />
37 38 * &lt;attribute name="child" type="{http://www.w3.org/2001/XMLSchema}string" />
  39 + * &lt;attribute name="childAlias" type="{http://www.w3.org/2001/XMLSchema}string" />
38 40 * &lt;attribute name="childExt" type="{http://www.w3.org/2001/XMLSchema}string" />
39 41 * &lt;attribute name="join" type="{http://www.w3.org/2001/XMLSchema}string" />
40 42 * &lt;/restriction>
@@ -60,10 +62,14 @@
60 62 protected String defaultDatabase;
61 63 @XmlAttribute(name = "parent", required = true)
62 64 protected String parent;
  65 + @XmlAttribute(name = "parentAlias")
  66 + protected String parentAlias;
63 67 @XmlAttribute(name = "parentExt")
64 68 protected String parentExt;
65 69 @XmlAttribute(name = "child")
66 70 protected String child;
  71 + @XmlAttribute(name = "childAlias")
  72 + protected String childAlias;
67 73 @XmlAttribute(name = "childExt")
68 74 protected String childExt;
69 75 @XmlAttribute(name = "join")
@@ -195,6 +201,30 @@ public void setParent(String value) {
195 201 }
196 202
197 203 /**
  204 + * Gets the value of the parentAlias property.
  205 + *
  206 + * @return
  207 + * possible object is
  208 + * {@link String }
  209 + *
  210 + */
  211 + public String getParentAlias() {
  212 + return parentAlias;
  213 + }
  214 +
  215 + /**
  216 + * Sets the value of the parentAlias property.
  217 + *
  218 + * @param value
  219 + * allowed object is
  220 + * {@link String }
  221 + *
  222 + */
  223 + public void setParentAlias(String value) {
  224 + this.parentAlias = value;
  225 + }
  226 +
  227 + /**
198 228 * Gets the value of the parentExt property.
199 229 *
200 230 * @return
@@ -243,6 +273,30 @@ public void setChild(String value) {
243 273 }
244 274
245 275 /**
  276 + * Gets the value of the childAlias property.
  277 + *
  278 + * @return
  279 + * possible object is
  280 + * {@link String }
  281 + *
  282 + */
  283 + public String getChildAlias() {
  284 + return childAlias;
  285 + }
  286 +
  287 + /**
  288 + * Sets the value of the childAlias property.
  289 + *
  290 + * @param value
  291 + * allowed object is
  292 + * {@link String }
  293 + *
  294 + */
  295 + public void setChildAlias(String value) {
  296 + this.childAlias = value;
  297 + }
  298 +
  299 + /**
246 300 * Gets the value of the childExt property.
247 301 *
248 302 * @return
2  src/org/restsql/core/sqlresource/ValidatedAttribute.java
@@ -2,7 +2,7 @@
2 2 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-147
3 3 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
4 4 // Any modifications to this file will be lost upon recompilation of the source schema.
5   -// Generated on: 2011.07.12 at 06:05:14 PM EDT
  5 +// Generated on: 2011.10.23 at 11:14:14 AM EDT
6 6 //
7 7
8 8
2  src/org/restsql/core/sqlresource/package-info.java
@@ -2,7 +2,7 @@
2 2 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-147
3 3 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
4 4 // Any modifications to this file will be lost upon recompilation of the source schema.
5   -// Generated on: 2011.07.12 at 06:05:14 PM EDT
  5 +// Generated on: 2011.10.23 at 11:14:14 AM EDT
6 6 //
7 7
8 8 @javax.xml.bind.annotation.XmlSchema(namespace = "http://restsql.org/schema")
10 src/org/restsql/service/LifecycleListener.java
... ... @@ -1,10 +1,13 @@
1 1 /* Copyright (c) restSQL Project Contributors. Licensed under MIT. */
2 2 package org.restsql.service;
3 3
  4 +import java.sql.SQLException;
  5 +
4 6 import javax.servlet.ServletContextEvent;
5 7 import javax.servlet.ServletContextListener;
6 8
7 9 import org.restsql.core.Config;
  10 +import org.restsql.core.Factory;
8 11
9 12 /**
10 13 * Loads properties file from servlet context.
@@ -27,7 +30,12 @@ public void contextInitialized(ServletContextEvent event) {
27 30 /**
28 31 * @see ServletContextListener#contextDestroyed(ServletContextEvent)
29 32 */
30   - public void contextDestroyed(ServletContextEvent arg0) {
  33 + public void contextDestroyed(ServletContextEvent arg0) {
  34 + try {
  35 + Factory.getConnectionFactory().destroy();
  36 + } catch (SQLException exception) {
  37 + exception.printStackTrace();
  38 + }
31 39 }
32 40
33 41 }
2  src/org/restsql/service/ResResource.java
@@ -329,7 +329,7 @@ private Response executeRequest(final Request.Type requestType, final String res
329 329 if (requestType.equals(Request.Type.SELECT)) {
330 330 final Request request = Factory.getRequest(requestType, resName, resIds, params, null,
331 331 requestLogger);
332   - responseBody = sqlResource.readXml(request);
  332 + responseBody = sqlResource.readAsXml(request);
333 333 } else { // INSERT, UPDATE or DELETE
334 334 final int rowsAffected;
335 335 if (body == null || body.length() == 0) {
4 src/org/restsql/service/XmlRequestProcessor.java
@@ -69,7 +69,7 @@ public static int execWrite(final Request.Type requestType, final List<NameValue
69 69 @Override
70 70 public void endElement(final String uri, final String localName, final String qName)
71 71 throws SAXException {
72   - if (qName.equals(sqlResource.getParentTable().getTableName())) {
  72 + if (qName.equals(sqlResource.getParentTable().getTableAlias())) {
73 73 if (childrenParams != null) {
74 74 // Apply operation to the children
75 75 // Parent is only for giving context to child inserts and updates
@@ -107,7 +107,7 @@ public int getRowsAffected() {
107 107 public void startElement(final String uri, final String localName, final String qName,
108 108 final Attributes attributes) throws SAXException {
109 109 if (!qName.equals(TAG_REQUEST)) {
110   - if (qName.equals(sqlResource.getParentTable().getTableName())) {
  110 + if (qName.equals(sqlResource.getParentTable().getTableAlias())) {
111 111 parentAttributes = parseAttributes(attributes);
112 112 } else { // child element
113 113 if (childrenParams == null) {
2  src/resources/xml/SqlResource.xsd
@@ -20,8 +20,10 @@
20 20 <attribute name="name" type="string" use="required"></attribute>
21 21 <attribute name="defaultDatabase" type="string" use="required"></attribute>
22 22 <attribute name="parent" type="string" use="required"></attribute>
  23 + <attribute name="parentAlias" type="string" use="optional"></attribute>
23 24 <attribute name="parentExt" type="string" use="optional"></attribute>
24 25 <attribute name="child" type="string" use="optional"></attribute>
  26 + <attribute name="childAlias" type="string" use="optional"></attribute>
25 27 <attribute name="childExt" type="string" use="optional"></attribute>
26 28 <attribute name="join" type="string" use="optional"></attribute>
27 29 </complexType>

0 comments on commit 35585f6

Please sign in to comment.
Something went wrong with that request. Please try again.