1.Define teiid model project.
2. Define source
3.From modeling generate rest virtual procedure.
4. Defing VDB
5. Deploy VDB.
6. Generate Rest Jar via VDB and Deploy
7. Now hit for MetaData URl for rest services .
---------
Issue : Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
Then Extarct war generated by Teiid Designer
Class Generated by TEIID:
package org.teiid.rest.services;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response.Status;
import javax.xml.ws.WebServiceContext;
import org.teiid.core.types.BlobType;
import org.teiid.core.types.XMLType;
import org.teiid.core.util.ReaderInputStream;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion;
import org.teiid.query.function.source.XMLSystemFunctions;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.parser.TeiidNodeFactory;
import org.teiid.query.parser.TeiidNodeFactory.ASTNodes;
import org.teiid.query.parser.TeiidParser;
import org.teiid.query.sql.symbol.XMLSerialize;
import org.teiid.rest.RestPlugin;
public class TeiidRSProviderPost
{
protected WebServiceContext webServiceContext;
private static Logger logger = Logger.getLogger("org.teiid.rest");
@Resource
protected void setWebServiceContext(WebServiceContext paramWebServiceContext)
{ this.webServiceContext = paramWebServiceContext;
}
public DataSource getDataSource(String paramString)
throws NamingException
{
DataSource localDataSource = null;
InitialContext localInitialContext = new InitialContext();
localDataSource = (DataSource)localInitialContext.lookup(paramString);
return localDataSource;
}
public InputStream execute(String paramString1, Map<String, String> paramMap, String paramString2, Properties paramProperties)
throws WebApplicationException
{
Connection localConnection = null;
PreparedStatement localPreparedStatement = null;
Object localObject1 = null;
InputStream localInputStream = null;
Object localObject2 = null;
try
{
DataSource localDataSource = getDataSource(paramProperties.getProperty("jndiName"));
localConnection = localDataSource.getConnection();
int i = 0;
if (paramMap.isEmpty())
{
i = 1;
}
String str2 = new StringBuilder().append("call ").append(paramString1).append(i != 0 ? "()" : createParmString(paramMap)).append(";").toString();
localPreparedStatement = localConnection.prepareStatement(str2);
Object localObject3;
if (i == 0) {
bool = true;
for (localObject3 = paramMap.values().iterator(); ((Iterator)localObject3).hasNext(); )
{ Object localObject4 = ((Iterator)localObject3).next();
localPreparedStatement.setString(bool++, (String)localObject4);
}
}
boolean bool = localPreparedStatement.execute();
if (bool) {
localObject3 = localPreparedStatement.getResultSet();
if (((ResultSet)localObject3).next())
{
localObject1 = ((ResultSet)localObject3).getObject(1);
}
else
{
logger.log(Level.WARNING, new StringBuilder().append(RestPlugin.Util.getString("TeiidRSProvider.8")).append(paramString1).toString());
createWebApplicationException(new Exception(RestPlugin.Util.getString("TeiidRSProvider.2")), RestPlugin.Util.getString("TeiidRSProvider.2"));
}
((ResultSet)localObject3).close();
}
localPreparedStatement.close();
localInputStream = handleResult(paramString2, localObject1, paramProperties);
}
catch (SQLException localSQLException3)
{
str1 = RestPlugin.Util.getString("TeiidRSProvider.1");
logger.logrb(Level.SEVERE, "TeiidRSProvider", "execute", "org.teiid.rest", str1, new Throwable(localSQLException2));
createWebApplicationException(localSQLException2, localSQLException2.getMessage());
}
catch (Exception localSQLException4)
{
str1 = RestPlugin.Util.getString("TeiidRSProvider.1");
logger.logrb(Level.SEVERE, "TeiidRSProvider", "execute", "org.teiid.rest", str1, new Throwable(localException));
createWebApplicationException(localException, localException.getMessage());
}
finally
{
String str1;
if (localConnection != null) {
try
{
localConnection.close();
}
catch (SQLException localSQLException5)
{
String str3 = RestPlugin.Util.getString("TeiidRSProvider.1");
logger.logrb(Level.SEVERE, "TeiidRSProvider", "execute", "org.teiid.rest", str3, new Throwable(localSQLException5));
}
}
}
return (InputStream)localInputStream;
}
private InputStream handleResult(String paramString, Object paramObject, Properties paramProperties) throws SQLException, UnsupportedEncodingException {
if (paramObject == null)
{
return null;
}
String str = paramProperties.getProperty("teiidVersion");
TeiidServerVersion localTeiidServerVersion = new TeiidServerVersion(str);
QueryParser localQueryParser = new QueryParser(localTeiidServerVersion);
TeiidParser localTeiidParser = localQueryParser.getTeiidParser();
if ((paramObject instanceof SQLXML)) {
if (paramString != null) {
XMLSerialize localXMLSerialize = (XMLSerialize)TeiidNodeFactory.getInstance().create(localTeiidParser, TeiidNodeFactory.ASTNodes.XML_SERIALIZE);
localXMLSerialize.setTypeString("blob");
localXMLSerialize.setDeclaration(Boolean.valueOf(true));
localXMLSerialize.setEncoding(paramString);
localXMLSerialize.setDocument(Boolean.valueOf(true));
try
{
return ((BlobType)XMLSystemFunctions.serialize(localXMLSerialize, new XMLType((SQLXML)paramObject))).getBinaryStream();
}
catch (Exception localException)
{
throw new SQLException(localException);
}
}
return ((SQLXML)paramObject).getBinaryStream();
}
if ((paramObject instanceof Blob))
{
return ((Blob)paramObject).getBinaryStream();
}
if ((paramObject instanceof Clob))
{
return new ReaderInputStream(((Clob)paramObject).getCharacterStream(), Charset.forName(paramString));
}
return new ByteArrayInputStream(paramObject.toString().getBytes(paramString));
}
protected String createParmString(Map<String, String> paramMap) {
StringBuilder localStringBuilder = new StringBuilder();
localStringBuilder.append("(?");
for (int i = 1; i < paramMap.size(); i++)
{
localStringBuilder.append(",");
localStringBuilder.append("?");
}
localStringBuilder.append(")");
return localStringBuilder.toString();
}
protected void createWebApplicationException(Exception paramException, String paramString) throws WebApplicationException
{
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}