teiid SVN: r3450 - branches/as7/admin.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-03 18:46:04 -0400 (Sat, 03 Sep 2011)
New Revision: 3450
Modified:
branches/as7/admin/
Log:
TEIID-1720: add ignore to target
Property changes on: branches/as7/admin
___________________________________________________________________
Modified: svn:ignore
- .classpath
.project
.settings
+ .classpath
.project
.settings
target
13 years, 7 months
teiid SVN: r3449 - branches/as7/admin.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-03 18:39:45 -0400 (Sat, 03 Sep 2011)
New Revision: 3449
Removed:
branches/as7/admin/target/
Log:
TEIID-1720: delete the target accidentally checked in
13 years, 7 months
teiid SVN: r3448 - in trunk: documentation/caching-guide/src/main/docbook/en-US/content and 12 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-09-02 21:59:26 -0400 (Fri, 02 Sep 2011)
New Revision: 3448
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
trunk/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml
trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java
trunk/engine/src/…
[View More]main/java/org/teiid/common/buffer/SPage.java
trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java
trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java
trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
TEIID-942 adding increased transaction support for temp tables
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-09-03 01:59:26 UTC (rev 3448)
@@ -29,6 +29,7 @@
<LI><B>Procedure language features</B> - Added support for compound/block statements, BEGIN [[NOT] ATOMIC], loop/block labels, and the leave statement. See the reference for more.
<LI><B>File Enhancements</B> - the file translator can now optionally (via the ExceptionIfFileNotFound property) throw an exception if the path refers to a file that doesn't exist. The file resource adapter can be configured to map file names and can prevent parent path .. references. See the Admin Guide or the file-ds.xml template for more.
<LI><B>TEXTTABLE Enhancements</B> - TEXTTABLE can now parse fixed width files that do not use a row delimiter and can optionally produce fixed values that haven't been trimmed.
+ <LI><B>Temp table transactions</B> - Internal materialized views and temp table usage from a session and within procedures can take advantage of greater transaction support.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2011-09-03 01:59:26 UTC (rev 3448)
@@ -104,6 +104,7 @@
Internal materialization also provides more built-in facilities for refreshing and monitoring.</para>
<para>The cache hint, when used in the context of an internal materialized view transformation query, provides the ability to fine tune the materialized table.
The pref_mem option also applies to internal materialized views. Internal table index pages already have a memory preference, so the perf_mem option indicates that the data pages should prefer memory as well.</para>
+ <para>All internal materialized view refresh and updates happen atomically. Internal materialized views support READ_COMMITTED (used also for READ_UNCOMMITED) and SERIALIZABLE (used also for REPEATABLE_READ) transaction isolation levels.</para>
<section>
<title>Loading And Refreshing</title>
<para>An internal materialized view table is initially in an invalid state (there is no data). The first user query will trigger an implicit loading of the data.
@@ -120,22 +121,6 @@
subsequent refreshes performed with <code>refreshMatView</code> will use dependent materialized view tables if they exist. Only one load may occur at a time. If a load is already in progress when
the <code>SYSADMIN.refreshMatView</code> procedure is called, it will return -1 immediately rather than preempting the current load.
</para>
- <para>
- When Teiid is running clustered mode, after of loading of internal materialized view contents, an event will be sent to all
- the other participating nodes in the cluster to refresh the contents from the original node in asynchronus fashion.
- During this remote node loading process, if the node that is reading the contents gets a request from user to serve the
- results of that view, then the current results in cache will be served. If no results were available at that node, then
- request will be blocked until load process is finished.
- </para>
- <para>
- When a Teiid node joins the cluster, at the end of start-up cycle, an asynchronus job
- will be started to fetch all the previously cached internal materialized views at other nodes
- for the deployed VDBs. The query request behaviour during this load process is same as above.
- </para>
- <note><para>In the clustered mode, the "invalidate=true" flag in the "SYSADMIN.refreshMatView" procedure
- will only apply to the node that is refreshing the contents from source. All other nodes, will still serve the
- old contents during the refresh process.</para>
- </note>
<section>
<title>TTL Snapshot Refresh</title>
<para>The <link linkend="cache-hint">cache hint</link> may be used to automatically trigger a full snapshot refresh after a specified time to live (ttl).
@@ -198,12 +183,9 @@
<section>
<title>Clustering Considerations</title>
<para>Each member in a cluster maintains its own copy of each materialized table and associated indexes.
- With cache clustering enabled, an additional snapshot copy of the table is maintained for loading by other members.
An attempt is made to ensure each member receives the same full refresh events as the others.
Full consistency for updatable materialized views however is not guaranteed.
Periodic full refreshes of updatable materialized view tables helps ensure consistency among members.
- <note><para>Loads of materialized tables are not coordinated across the cluster. It is possible for the same ttl expiration to trigger a load at each member.</para></note>
- In many clustered scenarios using external materialization is advantageous to fully control the loading of the tables and to have materialized data that is durable.
</para>
</section>
</section>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/ddl_support.xml 2011-09-03 01:59:26 UTC (rev 3448)
@@ -77,7 +77,7 @@
</para>
</listitem>
<listitem>
- <para>Only local temporary tables are supported. This implies that the scope of temp table will be either to the sesssion or the block of a virtual procedure that creates it.
+ <para>Only local temporary tables are supported. This implies that the scope of temp table will be either to the session or the block of a virtual procedure that creates it.
</para>
</listitem>
<listitem>
@@ -85,7 +85,9 @@
</para>
</listitem>
<listitem>
- <para>Temp tables are non-transactional.
+ <para>Temp tables support a READ_UNCOMMITED transaction isolation level. There are no locking mechanisms available to support higher isolation levels and the result of a rollback may be inconsistent across multiple transactions.
+ If concurrent transactions are not associated with the same local temporary table or session, then the transaction isolation level is effectively SERIALIZABLE.
+ If you want full constency with local temporary tables, then only use a connection with 1 transaction at a time. This mode of operation is ensured by connection pooling that tracking connections by transaction.
</para>
</listitem>
<listitem>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2011-09-03 01:59:26 UTC (rev 3448)
@@ -341,11 +341,6 @@
connector, however this isolation level is fixed and cannot be
changed at runtime for specific connections/commands.</para>
</listitem>
- <listitem>
- <para>Temporary tables are not transactional. For example,
- a global temporary table will retain all inserts performed during a
- local transaction that was rolled back.</para>
- </listitem>
<!-- <listitem>
<para>Connectors may be set to immutable to prevent their
participation in transactions. This is useful in situations where
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -26,6 +26,12 @@
public interface BatchManager {
+ public interface CleanupHook {
+
+ void cleanup();
+
+ }
+
public interface ManagedBatch {
TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException;
@@ -34,6 +40,13 @@
void setPrefersMemory(boolean prefers);
+ /**
+ * Get an object that can cleaup the {@link ManagedBatch}, but does not hold a hard reference to
+ * the {@link ManagedBatch} or the {@link BatchManager}
+ * @return
+ */
+ CleanupHook getCleanupHook();
+
}
ManagedBatch createManagedBatch(TupleBatch batch, boolean softCache) throws TeiidComponentException;
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/SPage.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -22,24 +22,34 @@
package org.teiid.common.buffer;
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Set;
+import org.teiid.common.buffer.BatchManager.CleanupHook;
import org.teiid.common.buffer.BatchManager.ManagedBatch;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
/**
* A linked list Page entry in the tree
*
* TODO: return the tuplebatch from getvalues, since that is what we're tracking
*
+ * State cloning allows a single storage reference to be shared in many trees.
+ * A phantom reference is used for proper cleanup once cloned.
+ *
+ * TODO: a better purging strategy for managedbatchs.
+ *
*/
@SuppressWarnings("unchecked")
-class SPage {
+class SPage implements Cloneable {
static final int MIN_PERSISTENT_SIZE = 16;
@@ -54,24 +64,75 @@
}
}
- private static AtomicInteger counter = new AtomicInteger();
-
+ private static final Set<PhantomReference<Object>> REFERENCES = Collections.newSetFromMap(new IdentityHashMap<PhantomReference<Object>, Boolean>());
+ private static ReferenceQueue<Object> QUEUE = new ReferenceQueue<Object>();
+ static class CleanupReference extends PhantomReference<Object> {
+
+ private CleanupHook batch;
+
+ public CleanupReference(Object referent, CleanupHook batch) {
+ super(referent, QUEUE);
+ this.batch = batch;
+ }
+
+ public void cleanup() {
+ try {
+ this.batch.cleanup();
+ } finally {
+ this.clear();
+ }
+ }
+ }
+
STree stree;
+ private int id;
protected SPage next;
protected SPage prev;
protected ManagedBatch managedBatch;
+ private Object trackingObject;
protected TupleBatch values;
protected ArrayList<SPage> children;
+ //TODO: could track cloning more completely, which would allow for earlier batch removal
+ private boolean cloned;
SPage(STree stree, boolean leaf) {
this.stree = stree;
- this.values = new TupleBatch(counter.getAndIncrement(), new ArrayList(stree.pageSize/4));
+ this.id = stree.counter.getAndIncrement();
+ stree.pages.put(this.id, this);
+ //TODO: this counter is a hack. need a better idea of a storage id
+ this.values = new TupleBatch(id, new ArrayList(stree.pageSize/4));
if (!leaf) {
children = new ArrayList<SPage>(stree.pageSize/4);
}
}
+ public SPage clone(STree tree) {
+ try {
+ if (this.managedBatch != null && trackingObject == null) {
+ cloned = true;
+ this.trackingObject = new Object();
+ CleanupReference managedBatchReference = new CleanupReference(trackingObject, managedBatch.getCleanupHook());
+ REFERENCES.add(managedBatchReference);
+ }
+ SPage clone = (SPage) super.clone();
+ clone.stree = tree;
+ if (children != null) {
+ clone.children = new ArrayList<SPage>(children);
+ }
+ if (values != null) {
+ clone.values = new TupleBatch(stree.counter.getAndIncrement(), new ArrayList<List<?>>(values.getTuples()));
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ public int getId() {
+ return id;
+ }
+
static SearchResult search(SPage page, List k, LinkedList<SearchResult> parent) throws TeiidComponentException {
TupleBatch previousValues = null;
for (;;) {
@@ -121,7 +182,7 @@
}
protected void setValues(TupleBatch values) throws TeiidComponentException {
- if (managedBatch != null) {
+ if (managedBatch != null && !cloned) {
managedBatch.remove();
}
if (values.getTuples().size() < MIN_PERSISTENT_SIZE) {
@@ -134,17 +195,25 @@
} else {
values.setDataTypes(stree.types);
}
+ if (cloned) {
+ values.setRowOffset(stree.counter.getAndIncrement());
+ cloned = false;
+ trackingObject = null;
+ }
if (children != null) {
managedBatch = stree.keyManager.createManagedBatch(values, true);
} else {
managedBatch = stree.leafManager.createManagedBatch(values, stree.preferMemory);
}
}
-
- protected void remove() {
+
+ protected void remove(boolean force) {
if (managedBatch != null) {
- managedBatch.remove();
+ if (force || !cloned) {
+ managedBatch.remove();
+ }
managedBatch = null;
+ trackingObject = null;
}
values = null;
children = null;
@@ -157,6 +226,14 @@
if (managedBatch == null) {
throw new AssertionError("Batch removed"); //$NON-NLS-1$
}
+ for (int i = 0; i < 10; i++) {
+ CleanupReference ref = (CleanupReference)QUEUE.poll();
+ if (ref == null) {
+ break;
+ }
+ REFERENCES.remove(ref);
+ ref.cleanup();
+ }
if (children != null) {
return managedBatch.getBatch(true, stree.keytypes);
}
@@ -173,7 +250,7 @@
if (current.children != null) {
current.children.addAll(current.next.children);
}
- current.next.remove();
+ current.next.remove(false);
current.next = current.next.next;
if (current.next != null) {
current.next.prev = current;
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -29,13 +29,16 @@
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import org.teiid.client.BatchSerializer;
import org.teiid.common.buffer.SPage.SearchResult;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.query.processor.relational.ListNestedSortComparator;
/**
@@ -44,7 +47,7 @@
* but with fewer updates.
*/
@SuppressWarnings("unchecked")
-public class STree {
+public class STree implements Cloneable {
public enum InsertMode {ORDERED, NEW, UPDATE}
@@ -53,7 +56,9 @@
protected int randomSeed;
private int mask = 1;
private int shift = 1;
-
+
+ protected AtomicInteger counter = new AtomicInteger();
+ protected ConcurrentHashMap<Integer, SPage> pages = new ConcurrentHashMap<Integer, SPage>();
protected volatile SPage[] header = new SPage[] {new SPage(this, true)};
protected BatchManager keyManager;
protected BatchManager leafManager;
@@ -91,6 +96,47 @@
this.keytypes = Arrays.copyOf(types, keyLength);
}
+ public STree clone() {
+ updateLock.lock();
+ try {
+ STree clone = (STree) super.clone();
+ clone.updateLock = new ReentrantLock();
+ clone.rowCount = new AtomicInteger(rowCount.get());
+ //clone the pages
+ clone.pages = new ConcurrentHashMap<Integer, SPage>(pages);
+ for (Map.Entry<Integer, SPage> entry : clone.pages.entrySet()) {
+ entry.setValue(entry.getValue().clone(clone));
+ }
+ //reset the pointers
+ for (Map.Entry<Integer, SPage> entry : clone.pages.entrySet()) {
+ SPage clonePage = entry.getValue();
+ clonePage.next = clone.getPage(clonePage.next);
+ clonePage.prev = clone.getPage(clonePage.prev);
+ if (clonePage.children != null) {
+ for (int i = 0; i < clonePage.children.size(); i++) {
+ clonePage.children.set(i, clone.getPage(clonePage.children.get(i)));
+ }
+ }
+ }
+ clone.header = Arrays.copyOf(header, header.length);
+ for (int i = 0; i < header.length; i++) {
+ clone.header[i] = clone.pages.get(header[i].getId());
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException(e);
+ } finally {
+ updateLock.unlock();
+ }
+ }
+
+ private SPage getPage(SPage page) {
+ if (page == null) {
+ return page;
+ }
+ return pages.get(page.getId());
+ }
+
public void writeValuesTo(ObjectOutputStream oos) throws TeiidComponentException, IOException {
SPage page = header[0];
oos.writeInt(this.rowCount.get());
@@ -357,7 +403,7 @@
int size = searchResult.values.getTuples().size();
if (size == 0) {
if (header[i] != searchResult.page) {
- searchResult.page.remove();
+ searchResult.page.remove(false);
if (searchResult.page.next != null) {
searchResult.page.next.prev = searchResult.page.prev;
}
@@ -366,7 +412,7 @@
searchResult.page.prev = null;
continue;
}
- header[i].remove();
+ header[i].remove(false);
if (header[i].next != null) {
header[i] = header[i].next;
header[i].prev = null;
@@ -401,7 +447,7 @@
}
public void remove() {
- truncate();
+ truncate(false);
this.keyManager.remove();
this.leafManager.remove();
}
@@ -410,12 +456,12 @@
return this.rowCount.get();
}
- public int truncate() {
+ public int truncate(boolean force) {
int oldSize = rowCount.getAndSet(0);
for (int i = 0; i < header.length; i++) {
SPage page = header[i];
while (page != null) {
- page.remove();
+ page.remove(force);
page = page.next;
}
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -92,6 +92,28 @@
private static final int IO_BUFFER_SIZE = 1 << 14;
private static final int COMPACTION_THRESHOLD = 1 << 25; //start checking at 32 megs
+ private final class CleanupHook implements org.teiid.common.buffer.BatchManager.CleanupHook {
+
+ private long id;
+ private int beginRow;
+ private WeakReference<BatchManagerImpl> ref;
+
+ CleanupHook(long id, int beginRow, BatchManagerImpl batchManager) {
+ this.id = id;
+ this.beginRow = beginRow;
+ this.ref = new WeakReference<BatchManagerImpl>(batchManager);
+ }
+
+ public void cleanup() {
+ BatchManagerImpl batchManager = ref.get();
+ if (batchManager == null) {
+ return;
+ }
+ cleanupManagedBatch(batchManager, beginRow, id);
+ }
+
+ }
+
private final class BatchManagerImpl implements BatchManager {
private final String id;
private volatile FileStore store;
@@ -163,7 +185,9 @@
store = newStore;
long oldOffset = offset;
offset = store.getLength();
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Compacted store", id, "pre-size", oldOffset, "post-size", offset); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Compacted store", id, "pre-size", oldOffset, "post-size", offset); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
return offset;
} finally {
this.compactionLock.writeLock().unlock();
@@ -213,7 +237,9 @@
this.lobManager = new LobManager();
}
sizeEstimate = (int) Math.max(1, manager.sizeUtility.getBatchSize(batch) / 1024);
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", id, "with size estimate", sizeEstimate); //$NON-NLS-1$ //$NON-NLS-2$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", id, "with size estimate", sizeEstimate); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
@Override
@@ -249,7 +275,9 @@
@Override
public TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException {
long reads = readAttempts.incrementAndGet();
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
synchronized (activeBatches) {
TupleBufferInfo tbi = activeBatches.remove(batchManager.id);
if (tbi != null) {
@@ -286,7 +314,9 @@
}
}
long count = readCount.incrementAndGet();
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading batch from disk, total reads:", count); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading batch from disk, total reads:", count); //$NON-NLS-1$
+ }
try {
this.batchManager.compactionLock.readLock().lock();
long[] info = batchManager.physicalMapping.get(this.id);
@@ -324,7 +354,9 @@
if (batch != null) {
if (!persistent) {
long count = writeCount.incrementAndGet();
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing batch to disk, total writes: ", count); //$NON-NLS-1$
+ }
long offset = 0;
if (lobManager != null) {
for (List<?> tuple : batch.getTuples()) {
@@ -341,7 +373,9 @@
long[] info = new long[] {offset, size};
batchManager.physicalMapping.put(this.id, info);
}
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
+ }
}
if (softCache) {
this.batchReference = new SoftReference<TupleBatch>(batch);
@@ -363,25 +397,17 @@
}
public void remove() {
- synchronized (activeBatches) {
- TupleBufferInfo tbi = activeBatches.get(batchManager.id);
- if (tbi != null && tbi.removeBatch(this.beginRow) != null) {
- if (tbi.batches.isEmpty()) {
- activeBatches.remove(batchManager.id);
- }
- }
- }
- long[] info = batchManager.physicalMapping.remove(id);
- if (info != null) {
- batchManager.unusedSpace.addAndGet(info[1]);
- }
- activeBatch = null;
- batchReference = null;
+ cleanupManagedBatch(batchManager, beginRow, id);
}
+
+ @Override
+ public CleanupHook getCleanupHook() {
+ return new CleanupHook(id, beginRow, batchManager);
+ }
@Override
public String toString() {
- return "ManagedBatch " + batchManager.id + " " + activeBatch; //$NON-NLS-1$ //$NON-NLS-2$
+ return "ManagedBatch " + batchManager.id + " " + this.beginRow + " " + activeBatch; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -487,6 +513,21 @@
return tupleBuffer;
}
+ private void cleanupManagedBatch(BatchManagerImpl batchManager, int beginRow, long id) {
+ synchronized (activeBatches) {
+ TupleBufferInfo tbi = activeBatches.get(batchManager.id);
+ if (tbi != null && tbi.removeBatch(beginRow) != null) {
+ if (tbi.batches.isEmpty()) {
+ activeBatches.remove(batchManager.id);
+ }
+ }
+ }
+ long[] info = batchManager.physicalMapping.remove(id);
+ if (info != null) {
+ batchManager.unusedSpace.addAndGet(info[1]);
+ }
+ }
+
public STree createSTree(final List elements, String groupName, int keyLength) {
String newID = String.valueOf(this.tsId.getAndIncrement());
int[] lobIndexes = LobManager.getLobIndexes(elements);
@@ -496,13 +537,17 @@
for (int i = 1; i < compareIndexes.length; i++) {
compareIndexes[i] = i;
}
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating STree:", newID); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating STree:", newID); //$NON-NLS-1$
+ }
return new STree(keyManager, bm, new ListNestedSortComparator(compareIndexes), getProcessorBatchSize(), keyLength, TupleBuffer.getTypeNames(elements));
}
@Override
public FileStore createFileStore(String name) {
- LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Creating FileStore:", name); //$NON-NLS-1$
+ }
return this.diskMgr.createFileStore(name);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -76,6 +76,7 @@
import org.teiid.query.QueryPlugin;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
/**
@@ -235,7 +236,7 @@
}
ClientState state = clientState.get(key);
if (state == null && create) {
- state = new ClientState(new TempTableStore(key));
+ state = new ClientState(new TempTableStore(key, TransactionMode.ISOLATE_WRITES));
clientState.put(key, state);
}
return state;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -356,13 +356,14 @@
if (startAutoWrapTxn) {
try {
- tc = transactionService.begin(tc);
+ transactionService.begin(tc);
} catch (XATransactionException err) {
throw new TeiidComponentException(err);
}
}
}
+ tc.setIsolationLevel(requestMsg.getTransactionIsolation());
this.transactionContext = tc;
this.processor = new QueryProcessor(processPlan, context, bufferManager, processorDataManager);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -462,31 +462,28 @@
/**
* Request level transaction
*/
- public TransactionContext begin(TransactionContext context) throws XATransactionException{
+ public void begin(TransactionContext context) throws XATransactionException{
if (context.getTransactionType() != TransactionContext.Scope.NONE) {
throw new XATransactionException(QueryPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
beginDirect(context);
context.setTransactionType(TransactionContext.Scope.REQUEST);
- return context;
}
/**
* Request level transaction
*/
- public TransactionContext commit(TransactionContext context) throws XATransactionException {
+ public void commit(TransactionContext context) throws XATransactionException {
Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
commitDirect(context);
- return context;
}
/**
* Request level transaction
*/
- public TransactionContext rollback(TransactionContext context) throws XATransactionException {
+ public void rollback(TransactionContext context) throws XATransactionException {
Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
rollbackDirect(context);
- return context;
}
public void cancelTransactions(String threadId, boolean requestOnly) throws XATransactionException {
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -46,7 +46,16 @@
private long creationTime;
private Transaction transaction;
private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
+ private int isolationLevel;
+
+ public int getIsolationLevel() {
+ return isolationLevel;
+ }
+ public void setIsolationLevel(int isolationLevel) {
+ this.isolationLevel = isolationLevel;
+ }
+
public long getCreationTime() {
return creationTime;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -39,11 +39,11 @@
public interface TransactionService {
// processor level methods
- TransactionContext begin(TransactionContext context) throws XATransactionException;
+ void begin(TransactionContext context) throws XATransactionException;
- TransactionContext commit(TransactionContext context) throws XATransactionException;
+ void commit(TransactionContext context) throws XATransactionException;
- TransactionContext rollback(TransactionContext context) throws XATransactionException;
+ void rollback(TransactionContext context) throws XATransactionException;
TransactionContext getOrCreateTransactionContext(String threadId);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/Program.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -29,6 +29,7 @@
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.sql.proc.Statement.Labeled;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
/**
@@ -113,7 +114,7 @@
*/
public void reset(String sessionId){
counter = 0;
- this.tempTables = new TempTableStore(sessionId);
+ this.tempTables = new TempTableStore(sessionId, TransactionMode.ISOLATE_WRITES);
this.startedTxn = false;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -46,6 +46,7 @@
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.WithQueryCommand;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.util.CommandContext;
/**
@@ -87,7 +88,7 @@
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
if (this.with != null) {
context = context.clone();
- tempTableStore = new TempTableStore(context.getConnectionID());
+ tempTableStore = new TempTableStore(context.getConnectionID(), TransactionMode.NONE);
tempTableStore.setParentTempTableStore(context.getTempTableStore());
context.setTempTableStore(tempTableStore);
for (WithQueryCommand withCommand : this.with) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -60,6 +60,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.util.CommandContext;
import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
@@ -110,7 +111,7 @@
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
context = context.clone();
setContext(context);
- TempTableStore tempTableStore = new TempTableStore(context.getConnectionID());
+ TempTableStore tempTableStore = new TempTableStore(context.getConnectionID(), TransactionMode.NONE);
tempTableStore.setParentTempTableStore(context.getTempTableStore());
context.setTempTableStore(tempTableStore);
this.dataMgr = dataMgr;
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStore.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -30,6 +30,7 @@
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
@@ -52,7 +53,7 @@
List<?> updateMatViewRow(String matTableName, List<?> tuple, boolean delete) throws TeiidComponentException;
TempTable createMatTable(String tableName, GroupSymbol group)
- throws TeiidComponentException, QueryMetadataException, QueryResolverException, QueryValidatorException;
+ throws TeiidComponentException, QueryMetadataException, TeiidProcessingException;
@Replicated
void failedLoad(String matTableName);
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -40,6 +40,7 @@
import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.language.SQLConstants;
@@ -60,6 +61,7 @@
import org.teiid.query.sql.lang.Create;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
public class GlobalTableStoreImpl implements GlobalTableStore, ReplicatedObject {
@@ -154,7 +156,7 @@
}
private ConcurrentHashMap<String, MatTableInfo> matTables = new ConcurrentHashMap<String, MatTableInfo>();
- private TempTableStore tableStore = new TempTableStore("SYSTEM"); //$NON-NLS-1$
+ private TempTableStore tableStore = new TempTableStore("SYSTEM", TransactionMode.ISOLATE_READS); //$NON-NLS-1$
private BufferManager bufferManager;
private QueryMetadataInterface metadata;
private Serializable localAddress;
@@ -196,13 +198,13 @@
String matTableName = RelationalPlanner.MAT_PREFIX+matViewName.toUpperCase();
GroupSymbol group = new GroupSymbol(matViewName);
group.setMetadataID(viewId);
- TempMetadataID id = tableStore.tempMetadataStore.getTempGroupID(matTableName);
+ TempMetadataID id = tableStore.getMetadataStore().getTempGroupID(matTableName);
//define the table preserving the key/index information and ensure that only a single instance exists
if (id == null) {
synchronized (viewId) {
- id = tableStore.tempMetadataStore.getTempGroupID(matTableName);
+ id = tableStore.getMetadataStore().getTempGroupID(matTableName);
if (id == null) {
- id = tableStore.tempMetadataStore.addTempGroup(matTableName, ResolverUtil.resolveElementsInGroup(group, metadata), false, true);
+ id = tableStore.getMetadataStore().addTempGroup(matTableName, ResolverUtil.resolveElementsInGroup(group, metadata), false, true);
id.setQueryNode(metadata.getVirtualPlan(viewId));
id.setCardinality(metadata.getCardinality(viewId));
id.setOriginalMetadataID(viewId);
@@ -273,16 +275,31 @@
@Override
public void loaded(String matTableName, TempTable table) {
- this.tableStore.swapTempTable(matTableName, table);
+ swapTempTable(matTableName, table);
this.getMatTableInfo(matTableName).setState(MatState.LOADED, true);
}
+
+ private void swapTempTable(String tempTableName, TempTable tempTable) {
+ this.tableStore.getTempTables().put(tempTableName, tempTable);
+ }
@Override
public List<?> updateMatViewRow(String matTableName, List<?> tuple,
boolean delete) throws TeiidComponentException {
TempTable tempTable = tableStore.getTempTable(matTableName);
if (tempTable != null) {
- return tempTable.updateTuple(tuple, delete);
+ TempMetadataID id = tableStore.getMetadataStore().getTempGroupID(matTableName);
+ synchronized (id) {
+ boolean clone = tempTable.getActiveReaders().get() != 0;
+ if (clone) {
+ tempTable = tempTable.clone();
+ }
+ List<?> result = tempTable.updateTuple(tuple, delete);
+ if (clone) {
+ swapTempTable(matTableName, tempTable);
+ }
+ return result;
+ }
}
return null;
}
@@ -294,7 +311,7 @@
@Override
public TempTable createMatTable(final String tableName, GroupSymbol group) throws TeiidComponentException,
- QueryMetadataException, QueryResolverException, QueryValidatorException {
+ QueryMetadataException, TeiidProcessingException {
Create create = new Create();
create.setTable(group);
List<ElementSymbol> allColumns = ResolverUtil.resolveElementsInGroup(group, metadata);
@@ -304,7 +321,7 @@
List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk);
create.getPrimaryKey().addAll(pkColumns);
}
- TempTable table = getTempTableStore().addTempTable(tableName, create, bufferManager, false);
+ TempTable table = getTempTableStore().addTempTable(tableName, create, bufferManager, false, null);
table.setUpdatable(false);
CacheHint hint = table.getCacheHint();
if (hint != null) {
@@ -424,8 +441,8 @@
private void loadTable(String stateId, ObjectInputStream ois)
throws TeiidComponentException, QueryMetadataException,
- QueryResolverException, QueryValidatorException, IOException,
- ClassNotFoundException {
+ IOException,
+ ClassNotFoundException, TeiidProcessingException {
LogManager.logDetail(LogConstants.CTX_DQP, "loading table from remote stream", stateId); //$NON-NLS-1$
long updateTime = ois.readLong();
Serializable loadingAddress = (Serializable) ois.readObject();
@@ -449,7 +466,7 @@
tempTable.readFrom(ois);
MatTableInfo info = this.getMatTableInfo(stateId);
synchronized (info) {
- this.tableStore.swapTempTable(stateId, tempTable);
+ swapTempTable(stateId, tempTable);
info.setState(state, true);
info.updateTime = updateTime;
info.loadingAddress = loadingAddress;
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -51,6 +51,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -75,7 +76,7 @@
* TODO: in this implementation blocked exceptions will not happen
* allowing for subquery evaluation though would cause pauses
*/
-public class TempTable {
+public class TempTable implements Cloneable {
private final class InsertUpdateProcessor extends UpdateProcessor {
@@ -274,7 +275,9 @@
}
}
+ private static AtomicInteger ID_GENERATOR = new AtomicInteger();
+ private int id = ID_GENERATOR.getAndIncrement();
private STree tree;
private AtomicInteger rowId;
private List<ElementSymbol> columns;
@@ -292,6 +295,8 @@
private List<Integer> notNull = new LinkedList<Integer>();
private Map<Integer, AtomicInteger> sequences;
private int uniqueColIndex;
+
+ private AtomicInteger activeReaders = new AtomicInteger();
TempTable(TempMetadataID tid, BufferManager bm, List<ElementSymbol> columns, int primaryKeyLength, String sessionID) {
this.tid = tid;
@@ -333,6 +338,33 @@
this.leafBatchSize = bm.getSchemaSize(columns.subList(0, primaryKeyLength));
}
+ public TempTable clone() {
+ lock.readLock().lock();
+ try {
+ TempTable clone = (TempTable) super.clone();
+ clone.lock = new ReentrantReadWriteLock();
+ if (clone.indexTables != null) {
+ clone.indexTables = new LinkedHashMap<List<ElementSymbol>, TempTable>(clone.indexTables);
+ for (Map.Entry<List<ElementSymbol>, TempTable> entry : clone.indexTables.entrySet()) {
+ TempTable indexClone = entry.getValue().clone();
+ indexClone.lock = clone.lock;
+ entry.setValue(indexClone);
+ }
+ }
+ clone.tree = tree.clone();
+ clone.activeReaders = new AtomicInteger();
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException();
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
+ public AtomicInteger getActiveReaders() {
+ return activeReaders;
+ }
+
void addIndex(List<ElementSymbol> indexColumns, boolean unique) throws TeiidComponentException, TeiidProcessingException {
List<ElementSymbol> keyColumns = columns.subList(0, tree.getKeyLength());
if (keyColumns.equals(indexColumns) || (indexTables != null && indexTables.containsKey(indexColumns))) {
@@ -500,9 +532,9 @@
return tree.getRowCount();
}
- public int truncate() {
+ public int truncate(boolean force) {
this.tid.getTableData().dataModified(tree.getRowCount());
- return tree.truncate();
+ return tree.truncate(force);
}
public void remove() {
@@ -770,5 +802,26 @@
public TempMetadataID getMetadataId() {
return tid;
}
+
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof TempTable)) {
+ return false;
+ }
+ TempTable other = (TempTable)obj;
+ return id == other.id;
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -43,6 +43,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.Assertion;
import org.teiid.core.util.StringUtil;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.SessionAwareCache;
@@ -164,7 +165,7 @@
return null;
}
final String groupKey = group.getNonCorrelationName().toUpperCase();
- final TempTable table = contextStore.getOrCreateTempTable(groupKey, command, bufferManager, true);
+ final TempTable table = contextStore.getOrCreateTempTable(groupKey, command, bufferManager, true, true, context);
if (command instanceof Insert) {
Insert insert = (Insert)command;
TupleSource ts = insert.getTupleSource();
@@ -186,8 +187,8 @@
final Delete delete = (Delete)command;
final Criteria crit = delete.getCriteria();
if (crit == null) {
- //because we are non-transactional, just use a truncate
- int rows = table.truncate();
+ //TODO: we'll add a real truncate later
+ int rows = table.truncate(false);
return CollectionTupleSource.createUpdateCountTupleSource(rows);
}
return table.delete(crit);
@@ -199,17 +200,18 @@
if (contextStore.hasTempTable(tempTableName)) {
throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableStore.table_exist_error", tempTableName));//$NON-NLS-1$
}
- contextStore.addTempTable(tempTableName, create, bufferManager, true);
+ contextStore.addTempTable(tempTableName, create, bufferManager, true, context);
return CollectionTupleSource.createUpdateCountTupleSource(0);
}
if (command instanceof Drop) {
String tempTableName = ((Drop)command).getTable().getCanonicalName();
- contextStore.removeTempTableByName(tempTableName);
+ contextStore.removeTempTableByName(tempTableName, context);
return CollectionTupleSource.createUpdateCountTupleSource(0);
}
if (command instanceof AlterTempTable) {
AlterTempTable att = (AlterTempTable)command;
- TempTable tt = contextStore.getOrCreateTempTable(att.getTempTable().toUpperCase(), command, bufferManager, true);
+ TempTable tt = contextStore.getTempTable(att.getTempTable().toUpperCase());
+ Assertion.isNotNull(tt, "Table doesn't exist"); //$NON-NLS-1$
tt.setUpdatable(false);
if (att.getIndexColumns() != null) {
tt.addIndex(att.getIndexColumns(), false);
@@ -388,10 +390,10 @@
loadAsynch(context, group, tableName, globalStore);
}
}
- table = globalStore.getTempTableStore().getOrCreateTempTable(tableName, query, bufferManager, false);
+ table = globalStore.getTempTableStore().getOrCreateTempTable(tableName, query, bufferManager, false, false, context);
context.accessedDataObject(group.getMetadataID());
} else {
- table = contextStore.getOrCreateTempTable(tableName, query, bufferManager, true);
+ table = contextStore.getOrCreateTempTable(tableName, query, bufferManager, true, false, context);
if (context.getDataObjects() != null) {
Object id = RelationalPlanner.getTrackableGroup(group, context.getMetadata());
if (id != null) {
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -22,15 +22,26 @@
package org.teiid.query.tempdata;
+import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+
import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.query.QueryPlugin;
@@ -42,16 +53,121 @@
import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.util.CommandContext;
+/**
+ * TempTableStores are transactional, but do not act as full resource manager.
+ * This means we are effectively 1PC and don't allow any heuristic exceptions
+ * on commit.
+ *
+ * Table state snapshoting and a {@link Synchronization} are used to
+ * perform the appropriate commit/rollback actions.
+ *
+ * Full row level MVCC would be a good next step as it would remove the
+ * cost of state cloning and would allow for concurrent read/write transactions.
+ */
public class TempTableStore {
- TempMetadataStore tempMetadataStore = new TempMetadataStore(new ConcurrentHashMap<String, TempMetadataID>());
+ public interface TransactionCallback {
+ void commit();
+ void rollback();
+ }
+
+ public enum TransactionMode {
+ ISOLATE_READS, //for matviews that have atomic updates
+ ISOLATE_WRITES, //for session/procedure stores that need rollback support - this is effectively READ_UNCOMMITTED
+ NONE
+ }
+
+ public class TempTableSynchronization implements Synchronization {
+
+ private String id;
+ Set<Integer> existingTables = new HashSet<Integer>();
+ ConcurrentHashMap<String, TempTable> tables = new ConcurrentHashMap<String, TempTable>();
+ private List<TransactionCallback> callbacks = new LinkedList<TransactionCallback>();
+
+ private boolean completed;
+
+ public TempTableSynchronization(final String id) {
+ this.id = id;
+ for (TempTable tempTable : tempTables.values()) {
+ existingTables.add(tempTable.getId());
+ }
+ if (transactionMode == TransactionMode.ISOLATE_WRITES) {
+ addCallback(new TransactionCallback() {
+ private Map<String, TempMetadataID> clonedMetadata = new ConcurrentHashMap<String, TempMetadataID>(tempMetadataStore.getData());
+ private Map<String, TempTable> clonedTables = new ConcurrentHashMap<String, TempTable>(tempTables);
+
+ @Override
+ public void rollback() {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Rolling back txn", id, "restoring", clonedTables.keySet(), "using rollback tables", tables); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ //remove any tables created in the scope of this txn
+ tempTables.values().removeAll(clonedTables.values());
+ for (TempTable table : tempTables.values()) {
+ table.remove();
+ }
+
+ //restore the state
+ tempMetadataStore.getData().clear();
+ tempMetadataStore.getData().putAll(clonedMetadata);
+ tempTables.clear();
+ tempTables.putAll(clonedTables);
+
+ //overlay the rollback tables
+ tempTables.putAll(tables);
+ }
+
+ @Override
+ public void commit() {
+ //remove any original tables that were removed in this txn
+ clonedTables.values().removeAll(tempTables.values());
+ for (TempTable table : clonedTables.values()) {
+ table.remove();
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public synchronized void afterCompletion(int status) {
+ //TODO: cleanup tables
+ completed = true;
+ synchronizations.remove(id);
+ for (TransactionCallback callback : callbacks) {
+ if (status == Status.STATUS_COMMITTED) {
+ callback.commit();
+ } else {
+ callback.rollback();
+ }
+ }
+ callbacks.clear();
+ }
+
+ @Override
+ public void beforeCompletion() {
+
+ }
+
+ public synchronized boolean addCallback(TransactionCallback callback) {
+ if (!completed) {
+ callbacks.add(0, callback);
+ }
+ return !completed;
+ }
+ }
+
+ private Map<String, TempTableSynchronization> synchronizations = new ConcurrentHashMap<String, TempTableSynchronization>();
+ private TransactionMode transactionMode = TransactionMode.NONE;
+
+ private TempMetadataStore tempMetadataStore = new TempMetadataStore(new ConcurrentHashMap<String, TempMetadataID>());
private Map<String, TempTable> tempTables = new ConcurrentHashMap<String, TempTable>();
private String sessionID;
private TempTableStore parentTempTableStore;
- public TempTableStore(String sessionID) {
+ public TempTableStore(String sessionID, TransactionMode transactionMode) {
this.sessionID = sessionID;
+ this.transactionMode = transactionMode;
}
public void setParentTempTableStore(TempTableStore parentTempTableStore) {
@@ -62,9 +178,10 @@
return tempTables.containsKey(tempTableName);
}
- TempTable addTempTable(String tempTableName, Create create, BufferManager buffer, boolean add) {
+ TempTable addTempTable(final String tempTableName, Create create, BufferManager buffer, boolean add, CommandContext context) throws TeiidProcessingException {
List<ElementSymbol> columns = create.getColumnSymbols();
TempMetadataID id = tempMetadataStore.getTempGroupID(tempTableName);
+ getSynchronization(context);
if (id == null) {
//add metadata
id = tempMetadataStore.addTempGroup(tempTableName, columns, false, true);
@@ -77,32 +194,67 @@
columns.removeAll(primaryKey);
columns.addAll(0, primaryKey);
}
- TempTable tempTable = new TempTable(id, buffer, columns, create.getPrimaryKey().size(), sessionID);
+ final TempTable tempTable = new TempTable(id, buffer, columns, create.getPrimaryKey().size(), sessionID);
if (add) {
tempTables.put(tempTableName, tempTable);
}
return tempTable;
}
- void swapTempTable(String tempTableName, TempTable tempTable) {
- tempTables.put(tempTableName, tempTable);
+ public void removeTempTableByName(final String tempTableName, CommandContext context) throws TeiidProcessingException {
+ TempTableSynchronization synch = getSynchronization(context);
+ tempMetadataStore.removeTempGroup(tempTableName);
+ final TempTable table = this.tempTables.remove(tempTableName);
+ if (table == null) {
+ return;
+ }
+ if (transactionMode != TransactionMode.ISOLATE_WRITES || synch == null || !synch.existingTables.contains(table.getId())) {
+ table.remove();
+ }
}
- public void removeTempTableByName(String tempTableName) {
- tempMetadataStore.removeTempGroup(tempTableName);
- TempTable table = this.tempTables.remove(tempTableName);
- if(table != null) {
- table.remove();
- }
- }
-
+ private TempTableSynchronization getSynchronization(CommandContext context) throws TeiidProcessingException {
+ TempTableSynchronization synch = null;
+ if (context == null || transactionMode == TransactionMode.NONE) {
+ return null;
+ }
+ TransactionContext tc = context.getTransactionContext();
+ if (tc == null || tc.getTransactionType() == Scope.NONE) {
+ return null;
+ }
+ String transactionId = tc.getTransactionId();
+ synch = synchronizations.get(transactionId);
+ if (synch == null) {
+ boolean success = false;
+ try {
+ synch = new TempTableSynchronization(transactionId);
+ synchronizations.put(transactionId, synch);
+ tc.getTransaction().registerSynchronization(synch);
+ success = true;
+ } catch (RollbackException e) {
+ throw new TeiidProcessingException(e);
+ } catch (SystemException e) {
+ throw new TeiidProcessingException(e);
+ } finally {
+ if (!success) {
+ synchronizations.remove(transactionId);
+ }
+ }
+ }
+ return synch;
+ }
+
public TempMetadataStore getMetadataStore() {
return tempMetadataStore;
}
- public void removeTempTables() {
+ public void removeTempTables() throws TeiidComponentException {
for (String name : tempTables.keySet()) {
- removeTempTableByName(name);
+ try {
+ removeTempTableByName(name, null);
+ } catch (TeiidProcessingException e) {
+ throw new TeiidComponentException(e);
+ }
}
}
@@ -117,8 +269,8 @@
return this.tempTables.get(tempTableID);
}
- TempTable getOrCreateTempTable(String tempTableID, Command command, BufferManager buffer, boolean delegate) throws QueryProcessingException{
- TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate);
+ TempTable getOrCreateTempTable(String tempTableID, Command command, BufferManager buffer, boolean delegate, boolean forUpdate, CommandContext context) throws TeiidProcessingException{
+ TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
if (tempTable != null) {
return tempTable;
}
@@ -138,18 +290,63 @@
Create create = new Create();
create.setTable(new GroupSymbol(tempTableID));
create.setElementSymbolsAsColumns(columns);
- return addTempTable(tempTableID, create, buffer, true);
+ return addTempTable(tempTableID, create, buffer, true, context);
}
private TempTable getTempTable(String tempTableID, Command command,
- BufferManager buffer, boolean delegate)
- throws QueryProcessingException {
- TempTable tsID = tempTables.get(tempTableID);
- if(tsID != null) {
- return tsID;
+ BufferManager buffer, boolean delegate, boolean forUpdate, CommandContext context)
+ throws TeiidProcessingException {
+ final TempTable tempTable = tempTables.get(tempTableID);
+ if(tempTable != null) {
+ //isolate if needed
+ if (forUpdate) {
+ if (transactionMode == TransactionMode.ISOLATE_WRITES) {
+ TransactionContext tc = context.getTransactionContext();
+ if (tc != null) {
+ TempTableSynchronization synch = getSynchronization(context);
+ if (synch != null && synch.existingTables.contains(tempTable.getId())) {
+ TempTable result = synch.tables.get(tempTableID);
+ if (result == null) {
+ synch.tables.put(tempTableID, tempTable.clone());
+ }
+ return tempTable;
+ }
+ }
+ }
+ } else if (transactionMode == TransactionMode.ISOLATE_READS) {
+ TransactionContext tc = context.getTransactionContext();
+ if (tc != null && tc.getIsolationLevel() > Connection.TRANSACTION_READ_COMMITTED) {
+ TempTableSynchronization synch = getSynchronization(context);
+ if (synch != null) {
+ TempTable result = synch.tables.get(tempTableID);
+ if (result == null) {
+ synch.tables.put(tempTableID, tempTable);
+ result = tempTable;
+ result.getActiveReaders().getAndIncrement();
+ TransactionCallback callback = new TransactionCallback() {
+
+ @Override
+ public void rollback() {
+ tempTable.getActiveReaders().getAndDecrement();
+ }
+
+ @Override
+ public void commit() {
+ tempTable.getActiveReaders().getAndDecrement();
+ }
+ };
+ if (!synch.addCallback(callback)) {
+ callback.rollback();
+ }
+ }
+ return result;
+ }
+ }
+ }
+ return tempTable;
}
if(delegate && this.parentTempTableStore != null){
- return this.parentTempTableStore.getTempTable(tempTableID, command, buffer, delegate);
+ return this.parentTempTableStore.getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
}
return null;
}
Modified: trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -65,6 +65,11 @@
public void setPrefersMemory(boolean prefers) {
}
+
+ @Override
+ public CleanupHook getCleanupHook() {
+ return null;
+ }
};
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -42,6 +42,7 @@
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.ContextProperties;
@@ -52,7 +53,7 @@
*/
public class TestRequest extends TestCase {
- private static final TempTableStore TEMP_TABLE_STORE = new TempTableStore("1"); //$NON-NLS-1$
+ private static final TempTableStore TEMP_TABLE_STORE = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$
private final static String QUERY = "SELECT * FROM pm1.g1"; //$NON-NLS-1$
/**
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -48,6 +48,7 @@
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -62,7 +63,7 @@
private HardcodedDataManager hdm;
@Before public void setUp() {
- tempStore = new TempTableStore("1"); //$NON-NLS-1$
+ tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
QueryMetadataInterface actualMetadata = RealMetadataFactory.exampleMaterializedView();
globalStore = new GlobalTableStoreImpl(bm, actualMetadata);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -96,6 +96,7 @@
import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.query.util.CommandContext;
@@ -244,7 +245,7 @@
}
context.getNextRand(0);
if (context.getTempTableStore() == null) {
- context.setTempTableStore(new TempTableStore(context.getConnectionID()));
+ context.setTempTableStore(new TempTableStore(context.getConnectionID(), TransactionMode.ISOLATE_WRITES));
}
if (context.getGlobalTableStore() == null) {
GlobalTableStoreImpl gts = new GlobalTableStoreImpl(bufferMgr, context.getMetadata());
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-09-02 21:01:40 UTC (rev 3447)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2011-09-03 01:59:26 UTC (rev 3448)
@@ -24,24 +24,38 @@
import static org.junit.Assert.*;
+import java.sql.Connection;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.tempdata.GlobalTableStoreImpl;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -52,6 +66,10 @@
private TempTableDataManager dataManager;
private TempTableStore tempStore;
+ private TransactionContext tc;
+ private Transaction txn;
+ private Synchronization synch;
+
private ProcessorPlan execute(String sql, List[] expectedResults) throws Exception {
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata);
execute(plan, expectedResults);
@@ -60,6 +78,7 @@
private void execute(ProcessorPlan processorPlan, List[] expectedResults) throws Exception {
CommandContext cc = TestProcessor.createCommandContext();
+ cc.setTransactionContext(tc);
cc.setMetadata(metadata);
cc.setTempTableStore(tempStore);
TestProcessor.doProcess(processorPlan, dataManager, expectedResults, cc);
@@ -67,7 +86,7 @@
}
@Before public void setUp() {
- tempStore = new TempTableStore("1"); //$NON-NLS-1$
+ tempStore = new TempTableStore("1", TransactionMode.ISOLATE_WRITES); //$NON-NLS-1$
metadata = new TempMetadataAdapter(RealMetadataFactory.example1Cached(), tempStore.getMetadataStore());
metadata.setSession(true);
FakeDataManager fdm = new FakeDataManager();
@@ -84,6 +103,96 @@
dataManager = new TempTableDataManager(fdm, bm, executor, cache);
}
+ @Test public void testRollbackNoExisting() throws Exception {
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+
+ Mockito.verify(txn).registerSynchronization((Synchronization) Mockito.anyObject());
+ synch.afterCompletion(Status.STATUS_ROLLEDBACK);
+
+ try {
+ execute("select * from x", new List[] {});
+ fail();
+ } catch (Exception e) {
+
+ }
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ }
+
+ @Test public void testRollbackExisting() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ //execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(172)}); //$NON-NLS-1$
+
+ synch.afterCompletion(Status.STATUS_ROLLEDBACK);
+
+ execute("select * from x", new List[] {});
+ }
+
+ @Test public void testRollbackExisting1() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ //execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(344)}); //$NON-NLS-1$
+
+ synch.afterCompletion(Status.STATUS_ROLLEDBACK);
+ this.tc = null;
+
+ execute("select count(*) from x", new List[] {Arrays.asList(516)});
+
+ execute("delete from x", new List[] {Arrays.asList(516)});
+ }
+
+ @Test public void testIsolateReads() throws Exception {
+ GlobalTableStoreImpl gtsi = new GlobalTableStoreImpl(BufferManagerFactory.getStandaloneBufferManager(), RealMetadataFactory.example1Cached());
+ tempStore = gtsi.getTempTableStore();
+ metadata = new TempMetadataAdapter(RealMetadataFactory.example1Cached(), tempStore.getMetadataStore());
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ for (int i = 0; i < 86; i++) {
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ execute("select count(*) from x", new List[] {Arrays.asList(516)});
+ gtsi.updateMatViewRow("X", Arrays.asList(1), true);
+ tc=null;
+ //outside of the transaction we can see the row removed
+ execute("select count(*) from x", new List[] {Arrays.asList(515)});
+
+ //back in the transaction we see the original state
+ setupTransaction(Connection.TRANSACTION_SERIALIZABLE);
+ execute("select count(*) from x", new List[] {Arrays.asList(516)});
+
+ synch.afterCompletion(Status.STATUS_COMMITTED);
+ }
+
+ private void setupTransaction(int isolation) throws RollbackException, SystemException {
+ txn = Mockito.mock(Transaction.class);
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ synch = (Synchronization)invocation.getArguments()[0];
+ return null;
+ }
+ }).when(txn).registerSynchronization((Synchronization)Mockito.anyObject());
+ Mockito.stub(txn.toString()).toReturn("txn");
+ tc = new TransactionContext();
+ tc.setTransaction(txn);
+ tc.setIsolationLevel(isolation);
+ tc.setTransactionType(Scope.REQUEST);
+ }
+
@Test public void testInsertWithQueryExpression() throws Exception {
execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
[View Less]
13 years, 7 months
teiid SVN: r3447 - in branches/as7/client/src: main/java/org/teiid/adminapi/impl and 1 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-02 17:01:40 -0400 (Fri, 02 Sep 2011)
New Revision: 3447
Removed:
branches/as7/client/src/main/java/org/teiid/adminapi/Admin.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminComponentException.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminException.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminFactory.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminObject.java
branches/as7/client/src/…
[View More]main/java/org/teiid/adminapi/AdminPlugin.java
branches/as7/client/src/main/java/org/teiid/adminapi/AdminProcessingException.java
branches/as7/client/src/main/java/org/teiid/adminapi/CacheStatistics.java
branches/as7/client/src/main/java/org/teiid/adminapi/DataPolicy.java
branches/as7/client/src/main/java/org/teiid/adminapi/Model.java
branches/as7/client/src/main/java/org/teiid/adminapi/PropertyDefinition.java
branches/as7/client/src/main/java/org/teiid/adminapi/Request.java
branches/as7/client/src/main/java/org/teiid/adminapi/Session.java
branches/as7/client/src/main/java/org/teiid/adminapi/Transaction.java
branches/as7/client/src/main/java/org/teiid/adminapi/Translator.java
branches/as7/client/src/main/java/org/teiid/adminapi/VDB.java
branches/as7/client/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
Log:
TEIID-1720: Removing the admin classes from client
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Admin.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Admin.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,298 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Properties;
-import java.util.Set;
-
-import org.teiid.adminapi.VDB.ConnectionType;
-
-public interface Admin {
-
- public enum Cache {PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE};
-
- /**
- * Assign a {@link Translator} and Data source to a {@link VDB}'s Model
- *
- * @param vdbName Name of the VDB
- * @param vdbVersion Version of the VDB
- * @param modelName Name of the Model to map Connection Factory
- * @param sourceName sourceName for the model
- * @param translatorName
- * @param dsName data source name that can found in the JNDI map.
- * @throws AdminException
- */
- void assignToModel(String vdbName, int vdbVersion, String modelName, String sourceName, String translatorName, String dsName) throws AdminException;
-
- /**
- * Change the {@link ConnectionType} of the {@link VDB}.
- * @param vdbName Name of the VDB
- * @param vdbVersion Version of the VDB
- * @param type
- * @throws AdminException
- */
- void changeVDBConnectionType(String vdbName, int vdbVersion, ConnectionType type) throws AdminException;
-
- /**
- * Deploy a {@link VDB} file.
- * @param name Name of the VDB file to save under
- * @param VDB VDB.
- * @throws AdminException
- *
- * @return the {@link VDB} representing the current property values and runtime state.
- */
- public void deployVDB(String fileName, InputStream vdb) throws AdminException;
-
-
- /**
- * Delete the VDB with the given name and version
- * @param vdbName
- * @param version
- * @throws AdminException
- */
- void deleteVDB(String vdbName, int vdbVersion) throws AdminException;
-
- /**
- * Get the VDBs that currently deployed in the system
- *
- * @return Collection of {@link VDB}s. There could be multiple VDBs with the
- * same name in the Collection but they will differ by VDB version.
- * @throws AdminException
- */
- Set<VDB> getVDBs() throws AdminException;
-
- /**
- * Get the VDB
- * @param vdbName
- * @param vbdVersion
- * @throws AdminException
- * @return
- */
- VDB getVDB(String vdbName, int vbdVersion) throws AdminException;
-
- /**
- * Get the translators that are available in the configuration
- *
- * @return Collection of {@link Translator}
- * @throws AdminException
- */
- Collection<Translator> getTranslators() throws AdminException;
-
- /**
- * Get the translator by the given the deployed name.
- * @param deployedName - name of the deployed translator
- * @return null if not found
- * @throws AdminException
- */
- Translator getTranslator(String deployedName) throws AdminException;
-
- /**
- * Get the Worker Pool statistics in runtime engine.
- *
- * @return {@link WorkerPoolStatistics}
- * @throws AdminException
- */
- WorkerPoolStatistics getWorkerPoolStats() throws AdminException;
-
- /**
- * Get the Caches that correspond to the specified identifier pattern
- * @return Collection of {@link String}
- * @throws AdminException
- */
- Collection<String> getCacheTypes() throws AdminException;
-
- /**
- * Get all the current Sessions.
- * @return Collection of {@link Session}
- * @throws AdminException
- */
- Collection<Session> getSessions() throws AdminException;
-
- /**
- * Get the all Requests that are currently in process
- * @return Collection of {@link Request}
- * @throws AdminException
- */
- Collection<Request> getRequests() throws AdminException;
-
- /**
- * Get the Requests for the given session
- * @return Collection of {@link Request}
- * @throws AdminException
- */
- Collection<Request> getRequestsForSession(String sessionId) throws AdminException;
-
-
- /**
- * Get all of the available configuration Properties for the specified connector
- * @param templateName - Name of the connector
- * @return
- * @throws AdminException
- */
- Collection<PropertyDefinition> getTemplatePropertyDefinitions(String templateName) throws AdminException;
-
-
- /**
- * Get all transaction matching the identifier.
- * @return
- * @throws AdminException
- */
- Collection<Transaction> getTransactions() throws AdminException;
-
- /**
- * Clear the cache or caches specified by the cacheIdentifier.
- * @param cacheType Cache Type
- * No wild cards currently supported, must be explicit
- * @throws AdminException
- */
- void clearCache(String cacheType) throws AdminException;
-
- /**
- * Clear the cache of the given VDB for provided cache type
- * @param cacheType Cache Type
- * No wild cards currently supported, must be explicit
- * @param vdbName - Name of the VDB
- * @param vdbVersion - VDB version
- * @throws AdminException
- */
- void clearCache(String cacheType, String vdbName, int vdbVersion) throws AdminException;
-
-
- /**
- * Get the Cache Statistics for the given type
- * @param cacheType Cache Type
- * @return {@link CacheStatistics}
- * @throws AdminException
- */
- CacheStatistics getCacheStats(String cacheType) throws AdminException;
-
- /**
- * Terminate the Session
- *
- * @param identifier Session Identifier {@link org.teiid.adminapi.Session}.
- * No wild cards currently supported, must be explicit
- * @throws AdminException
- */
- void terminateSession(String sessionId) throws AdminException;
-
- /**
- * Cancel Request
- *
- * @param sessionId session Identifier for the request.
- * @param executionId request Identifier
- *
- * @throws AdminException
- */
- void cancelRequest(String sessionId, long executionId) throws AdminException;
-
- /**
- * Mark the given global transaction as rollback only.
- * @param transactionId
- * @throws AdminException
- */
- void terminateTransaction(String transactionId) throws AdminException;
-
- /**
- * Closes the admin connection
- */
- void close();
-
- /**
- * Assign a Role name to the Data Role in a given VDB
- *
- * @param vdbName
- * @param vdbVersion
- * @param dataRole
- * @param mappedRoleName
- */
- void addDataRoleMapping(String vdbName, int vdbVersion, String dataRole, String mappedRoleName) throws AdminException;
-
- /**
- * Remove a Role name to the Data Role in a given VDB
- *
- * @param vdbName
- * @param vdbVersion
- * @param dataRole
- * @param mappedRoleName
- */
- void removeDataRoleMapping(String vdbName, int vdbVersion, String dataRole, String mappedRoleName) throws AdminException;
-
- /**
- * Set the any authenticated flag on the Data Role in a given VDB
- *
- * @param vdbName
- * @param vdbVersion
- * @param dataRole
- * @param anyAuthenticated
- */
- void setAnyAuthenticatedForDataRole(String vdbName, int vdbVersion, String dataRole, boolean anyAuthenticated) throws AdminException;
-
- /**
- * Merge the Source VDB into Target VDB. Both Source and Target VDBs must be present for this method to
- * succeed. The changes will not be persistent between server restarts.
- * @param sourceVDBName
- * @param sourceVDBVersion
- * @param targetVDBName
- * @param targetVDBVersion
- */
- void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException;
-
-
- /**
- * Creates a JCA data source
- * @param deploymentName - name of the source
- * @param templateName - template of data source
- * @param properties - properties
- * @throws AdminException
- */
- void createDataSource(String deploymentName, String templateName, Properties properties) throws AdminException;
-
- /**
- * Delete data source.
- * @param deployedName
- * @throws AdminException
- */
- void deleteDataSource(String deployedName) throws AdminException;
-
- /**
- * Returns the all names of all the data sources available in the configuration.
- */
- Collection<String> getDataSourceNames() throws AdminException;
-
- /**
- * Get the Datasource templates available in the configuration.
- *
- * @return Set of template names.
- * @throws AdminException
- */
- Set<String> getDataSourceTemplateNames() throws AdminException;
-
- /**
- * Tell the engine that the given source is available. Pending dynamic vdb metadata loads will be resumed.
- * @param jndiName
- * @throws AdminException
- */
- void markDataSourceAvailable(String jndiName) throws AdminException;
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminComponentException.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminComponentException.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminComponentException.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-/**
- * An <code>AdminComponentException</code> is thrown when an error occurs as a
- * result of an internal component error.
- *
- * <p>This exception class is capable of containing multiple exceptions. See
- * {@link AdminException} for details.
- */
-public final class AdminComponentException extends AdminException {
-
- private static final long serialVersionUID = 7117721841515240902L;
-
-
- public AdminComponentException() {
- super();
- }
-
- /**
- * Construct with a message.
- * @param msg the error message.
- * @since 4.3
- */
- public AdminComponentException(String msg) {
- super(msg);
- }
-
- public AdminComponentException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Construct with an optional error code and a message.
- * @param code an optional error code
- * @param msg the error message.
- * @since 4.3
- */
- public AdminComponentException(int code, String msg) {
- super(code, msg);
- }
-
- public AdminComponentException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
- public AdminComponentException(int code, String msg, Throwable cause) {
- super(code, msg, cause);
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminException.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminException.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminException.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.teiid.core.TeiidException;
-
-
-/**
- * <code>AdminException</code> is the base exception for the admin package. Many *Admin methods throw this
- * exception. Instances will be one of the concrete subtypes:
- * {@link AdminComponentException} or {@link AdminProcessingException}</p>
- *
- * <p><code>AdminException</code>s may contain multiple child exceptions. An example
- * of this could be when performing an admin action results in multiple failures. Admin
- * clients should be aware of this and use the {@link #hasMultiple()} method to
- * determine if they need to check the child exceptions.</p>
- */
-public abstract class AdminException extends TeiidException {
-
- private static final long serialVersionUID = -4446936145500241358L;
- // List of Admin exceptions in
- // case of multiple failure
- private List children;
-
- /**
- * No-arg ctor.
- *
- * @since 4.3
- */
- AdminException() {
- super();
- }
-
- /**
- * Construct with a message.
- * @param msg the error message.
- * @since 4.3
- */
- AdminException(String msg) {
- super(msg);
- }
-
- AdminException(Throwable cause) {
- this(cause.getMessage(), cause);
- }
-
- /**
- * Construct with an optional error code and a message.
- * @param code an optional error code
- * @param msg the error message.
- * @since 4.3
- */
- AdminException(int code, String msg) {
- super(Integer.toString(code), msg);
- }
-
- AdminException(String msg, Throwable cause) {
- super(cause, msg);
- }
-
- AdminException(int code, String msg, Throwable cause) {
- super(cause, Integer.toString(code),msg);
- }
-
- /**
- * Determine whether this exception is representing
- * mutliple component failures.
- * @return <code>true</code> iff this exception contains multiple
- * component failure exceptions.
- * @since 4.3
- */
- public boolean hasMultiple() {
- return (children != null && children.size() > 0);
- }
-
- /**
- * Returns a non-null list of failures (<code>AdminException</code>s), one for each
- * component that failed.
- *
- * <p>The list will have members when {@link #hasMultiple()} returns <code>true</code>.</p>
- * @return The non-null list of failures.
- * @since 4.3
- */
- public List getChildren() {
- return (children != null ? children : Collections.EMPTY_LIST);
- }
-
- /**
- * Add a child <code>AdminException</code> for a particular failure
- * if and action resulted in multiple failures.
- *
- * @param child a specific failure
- * @since 4.3
- */
- public void addChild(AdminException child) {
- if ( children == null ) {
- children = new ArrayList();
- }
- children.add(child);
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,343 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.UnknownHostException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.security.auth.callback.*;
-import javax.security.sasl.RealmCallback;
-import javax.security.sasl.RealmChoiceCallback;
-
-import org.jboss.as.cli.Util;
-import org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress;
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.teiid.adminapi.VDB.ConnectionType;
-
-
-/**
- * Singleton factory for class for creating Admin connections to the Teiid
- */
-public class AdminFactory {
- private static AdminFactory INSTANCE = new AdminFactory();
-
- public static AdminFactory getInstance() {
- return INSTANCE;
- }
- /**
- * Creates a ServerAdmin with the specified connection properties.
- * @param userName
- * @param password
- * @param serverURL
- * @param applicationName
- * @return
- * @throws AdminException
- */
- public Admin createAdmin(String host, int port, String userName, char[] password) throws AdminException {
- if(host == null) {
- host = "localhost"; //$NON-NLS-1$
- }
-
- if(port < 0) {
- port = 9990;
- }
-
- try {
- CallbackHandler cbh = new AuthenticationCallbackHandler(userName, password);
- ModelControllerClient newClient = ModelControllerClient.Factory.create(host, port, cbh);
-
- List<String> nodeTypes = Util.getNodeTypes(newClient, new DefaultOperationRequestAddress());
- if (!nodeTypes.isEmpty()) {
- boolean domainMode = nodeTypes.contains("server-group"); //$NON-NLS-1$
- System.out.println("Connected to " //$NON-NLS-1$
- + (domainMode ? "domain controller at " : "standalone controller at ") //$NON-NLS-1$ //$NON-NLS-2$
- + host + ":" + port); //$NON-NLS-1$
- return new AdminImpl(newClient);
- }
- System.out.println("The controller is not available at " + host + ":" + port); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (UnknownHostException e) {
- System.out.println("Failed to resolve host '" + host + "': " + e.getLocalizedMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return null;
- }
-
- private class AuthenticationCallbackHandler implements CallbackHandler {
- private boolean realmShown = false;
- private String userName = null;
- private char[] password = null;
-
- public AuthenticationCallbackHandler(String user, char[] password) {
- this.userName = user;
- this.password = password;
- }
-
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
- // Special case for anonymous authentication to avoid prompting user for their name.
- if (callbacks.length == 1 && callbacks[0] instanceof NameCallback) {
- ((NameCallback)callbacks[0]).setName("anonymous CLI user"); //$NON-NLS-1$
- return;
- }
-
- for (Callback current : callbacks) {
- if (current instanceof RealmCallback) {
- RealmCallback rcb = (RealmCallback) current;
- String defaultText = rcb.getDefaultText();
- rcb.setText(defaultText); // For now just use the realm suggested.
- if (realmShown == false) {
- realmShown = true;
- }
- } else if (current instanceof RealmChoiceCallback) {
- throw new UnsupportedCallbackException(current, "Realm choice not currently supported."); //$NON-NLS-1$
- } else if (current instanceof NameCallback) {
- NameCallback ncb = (NameCallback) current;
- ncb.setName(userName);
- } else if (current instanceof PasswordCallback) {
- PasswordCallback pcb = (PasswordCallback) current;
- pcb.setPassword(password);
- } else {
- throw new UnsupportedCallbackException(current);
- }
- }
- }
-
- }
-
- private class AdminImpl implements Admin{
- public AdminImpl (ModelControllerClient connection) {
-
- }
-
- @Override
- public void addDataRoleMapping(String vdbName, int vdbVersion,
- String dataRole, String mappedRoleName) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void assignToModel(String vdbName, int vdbVersion,
- String modelName, String sourceName, String translatorName,
- String dsName) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void cancelRequest(String sessionId, long executionId)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void changeVDBConnectionType(String vdbName, int vdbVersion,
- ConnectionType type) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void clearCache(String cacheType) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void clearCache(String cacheType, String vdbName, int vdbVersion)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void close() {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void createDataSource(String deploymentName,
- String templateName, Properties properties)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void deleteDataSource(String deployedName) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void deleteVDB(String vdbName, int vdbVersion)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void deployVDB(String fileName, InputStream vdb)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public CacheStatistics getCacheStats(String cacheType)
- throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<String> getCacheTypes() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<String> getDataSourceNames() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<String> getDataSourceTemplateNames() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Request> getRequests() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Request> getRequestsForSession(String sessionId)
- throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Session> getSessions() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<PropertyDefinition> getTemplatePropertyDefinitions(
- String templateName) throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Transaction> getTransactions() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Translator getTranslator(String deployedName)
- throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Translator> getTranslators() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public VDB getVDB(String vdbName, int vbdVersion) throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<VDB> getVDBs() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public WorkerPoolStatistics getWorkerPoolStats() throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void markDataSourceAvailable(String jndiName)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void mergeVDBs(String sourceVDBName, int sourceVDBVersion,
- String targetVDBName, int targetVDBVersion)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void removeDataRoleMapping(String vdbName, int vdbVersion,
- String dataRole, String mappedRoleName) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void setAnyAuthenticatedForDataRole(String vdbName,
- int vdbVersion, String dataRole, boolean anyAuthenticated)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void terminateSession(String sessionId) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
- public void terminateTransaction(String transactionId)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminObject.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminObject.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminObject.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * Base interface of client side admin objects. Specifies behaviors and properties common to all administrative objects.
- * <p>
- * Unique identifiers are available for all <code>AdminObject</code>s and their forms are specific to each object. See
- * the javadoc on the individual object for its particular identifier pattern required.
- * </p>
- * <p>
- * This interface need not be used directly by clients except when coding to constants.
- * </p>
- *
- * @since 4.3
- */
-public interface AdminObject extends Serializable {
-
- /**
- * The character that delimits the atomic components of the identifier.
- * @see #DELIMITER
- */
- public static final char DELIMITER_CHAR = '|';
-
- /**
- * The character (as a <code>String</code>) that delimits the atomic components of the identifier.
- *
- * <p>It is <emph>strongly</emph> advisable to write admin client code using this <code>DELIMITER</code>
- * rather than hard-coding a delimiter character in admin code. Doing this eliminates the possibility
- * of admin client code breaking if/when the delimiter character must be changed.</p>
- */
- public static final String DELIMITER = new String(new char[] {DELIMITER_CHAR});
-
- /**
- * The delimiter character as a <code>String</code> escaped.
- * @see #DELIMITER
- */
- public static final String ESCAPED_DELIMITER = "\\" + DELIMITER; //$NON-NLS-1$
-
- /**
- * The wildcard character (as a <code>String</code>) that can be used in may identifier patterns
- * to indicate <i>"anything"</i> or, more specifically, replace <i>"zero or more"</i>
- * identifier components.
- *
- * <p>It is <emph>strongly</emph> advisable to write admin client code using this <code>WILDCARD</code>
- * rather than hard-coding a wildcard character in admin code. Doing this eliminates the possibility
- * of admin client code breaking if/when the wildcard character must be changed.</p>
- */
- public static final String WILDCARD = "*"; //$NON-NLS-1$
-
- /**
- * The wildcard character as a <code>String</code> escaped.
- * @see #WILDCARD
- */
- public static final String ESCAPED_WILDCARD = "\\" + WILDCARD; //$NON-NLS-1$
-
- /**
- * Get the name for this AdminObject, usually the last component of the identifier.
- *
- * @return String Name
- * @since 4.3
- */
- String getName();
-
- /**
- * Get the Configuration Properties that defines this process
- *
- * @return Properties
- * @since 4.3
- */
- Properties getProperties();
-
- /**
- * Searches for the property with the specified key in this Admin Object. If the key is not found the method returns
- * <code>null</code>.
- *
- * @param name
- * the property key.
- * @return the value in this Admin Object with the specified key value.
- * @since 4.3
- */
-
- String getPropertyValue(String name);
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.ResourceBundle;
-
-import org.teiid.core.BundleUtil;
-
-public class AdminPlugin {
- public static final String PLUGIN_ID = "org.teiid.adminapi" ; //$NON-NLS-1$
- public static final BundleUtil Util = new BundleUtil(PLUGIN_ID, PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/AdminProcessingException.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminProcessingException.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminProcessingException.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-/**
- * An <code>AdminProcessingException</code> indicates that an error occured during processing as a result
- * of user input. This exception is the result of handling an invalid user
- * request, not the result of an internal error.</p>
- *
- * <p>This exception class is capable of containing multiple exceptions. See
- * {@link AdminException} for details.
- */
-public final class AdminProcessingException extends AdminException {
-
- private static final long serialVersionUID = -878521636838205857L;
-
- /**
- * No-arg ctor.
- *
- * @since 4.3
- */
- public AdminProcessingException() {
- super();
- }
-
- /**
- * Construct with a message.
- * @param msg the error message.
- * @since 4.3
- */
- public AdminProcessingException(String msg) {
- super(msg);
- }
-
- public AdminProcessingException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Construct with an optional error code and a message.
- * @param code an optional error code
- * @param msg the error message.
- * @since 4.3
- */
- public AdminProcessingException(int code, String msg) {
- super(code, msg);
- }
-
- public AdminProcessingException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
- public AdminProcessingException(int code, String msg, Throwable cause) {
- super(code, msg, cause);
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/CacheStatistics.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/CacheStatistics.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/CacheStatistics.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi;
-
-public interface CacheStatistics extends AdminObject {
-
- double getHitRatio();
-
- int getTotalEntries();
-
- int getRequestCount();
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/DataPolicy.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,121 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi;
-
-import java.util.List;
-
-public interface DataPolicy {
-
- public enum Context {
- CREATE,
- DROP,
- QUERY,
- INSERT,
- UPDATE,
- DELETE,
- FUNCTION,
- ALTER,
- STORED_PROCEDURE;
- }
-
- public enum PermissionType {CREATE, READ, UPDATE, DELETE, ALTER, EXECUTE, DROP};
-
- /**
- * Get the Name of the Data Policy
- * @return
- */
- String getName();
-
- /**
- * Get the description of the Data Policy
- * @return
- */
- String getDescription();
-
- /**
- * Get the List of Permissions for this Data Policy.
- * @return
- */
- List<DataPermission> getPermissions();
-
- /**
- * Mapped Container Role names for this Data Policy
- * @return
- */
- List<String> getMappedRoleNames();
-
- /**
- * If the policy applies to any authenticated user
- * @return
- */
- boolean isAnyAuthenticated();
-
- /**
- * If the policy allows for temporary table usage
- * @return
- */
- Boolean isAllowCreateTemporaryTables();
-
- interface DataPermission {
- /**
- * Get the Resource Name that Data Permission representing
- * @return
- */
- String getResourceName();
-
- /**
- * Is "CREATE" allowed?
- * @return
- */
- Boolean getAllowCreate();
-
- /**
- * Is "SELECT" allowed?
- * @return
- */
- Boolean getAllowRead();
-
- /**
- * Is "INSERT/UPDATE" allowed?
- * @return
- */
- Boolean getAllowUpdate();
-
- /**
- * Is "DELETE" allowed?
- * @return
- */
- Boolean getAllowDelete();
-
- /**
- * Is "ALTER" allowed?
- * @return
- */
- Boolean getAllowAlter();
-
- /**
- * Is "EXECUTE" allowed?
- * @return
- */
- Boolean getAllowExecute();
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Model.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Model.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Model.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.List;
-
-
-/**
- * Represents a metadata model in the Teiid system.
- *
- * @since 4.3
- */
-public interface Model extends AdminObject {
-
- enum Type {PHYSICAL, VIRTUAL, FUNCTION, OTHER};
-
- /**
- * Description about the model
- * @return
- */
- String getDescription();
-
- /**
- * Determine if this model is a Source model.
- *
- * @return <code>true</code> if it contains physical group(s).
- */
- boolean isSource();
-
- /**
- * Determine whether this model is exposed for querying.
- *
- * @return <code>true</code> if the model is visible
- * for querying.
- */
- boolean isVisible();
-
- /**
- * Retrieve the model type.
- * @return model type
- */
- Type getModelType();
-
- /**
- * Determine whether this model can support more than one source.
- *
- * @return <code>true</code> if this model supports multiple sources
- */
- boolean isSupportsMultiSourceBindings();
-
- /**
- * Associated Source Names for the Models
- * @return String
- */
- List<String> getSourceNames();
-
- /**
- * Get the configured JNDI name for the given source name.
- * @param sourceName - name of the source
- * @return null if none configured.
- */
- String getSourceConnectionJndiName(String sourceName);
-
-
- /**
- * Get the configured translator name for the given source
- * @param sourceName
- * @return
- */
- String getSourceTranslatorName(String sourceName);
-}
\ No newline at end of file
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/PropertyDefinition.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/PropertyDefinition.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/PropertyDefinition.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,137 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.Collection;
-
-/**
- * Information about a property of an AdminObject
- */
-public interface PropertyDefinition extends AdminObject {
-
- public enum RestartType {
- NONE,
- SERVICE,
- PROCESS,
- ALL_PROCESSES,
- CLUSTER
- }
- /**
- * The value of the maximum multiplicity if the multiplicity is considered unbounded.
- */
- public static final int UNBOUNDED_VALUE = Integer.MAX_VALUE;
-
-
- /**
- * Get the localized display name of this property.
- * @return the displayable name for this property
- */
- String getDisplayName();
-
- /**
- * Get the description of this property.
- * @return the description for this property
- */
- String getDescription();
-
-
- /**
- * Get the name of the java class that best represents the property type.
- * @return the name of the java class that best represents the property type.
- */
- String getPropertyTypeClassName();
-
-
- /**
- * Get the default value for values of this property, or an empty String if
- * there is no default value.
- * @return the default value for this property, or an empty String
- * if there is no default value.
- */
- Object getDefaultValue();
-
- /**
- * Get the allowed values for this property.
- * @return the list of allowed values for this property, or an empty
- * set if the values do not have to conform to a fixed set.
- */
- Collection getAllowedValues();
-
- /**
- * Get whether this property requires the system to be restarted before it takes effect.
- * @return true if this property requires the system to be restarted before it takes effect.
- */
- public RestartType getRequiresRestart();
-
- /**
- * The modifiable flag is used to identify features that may not be changed once
- * they are set.
- * @return true if this property is marked with the modifyable
- * flag, or false otherwise.
- */
- boolean isModifiable();
-
- /**
- * Return whether the value or values for this property are constrained to be only
- * those in the AllowedValues list.
- * @see #getAllowedValues
- * @return true if this property's value must be with the list of AllowedValues.
- */
- boolean isConstrainedToAllowedValues();
-
- /**
- * The "expert" flag is used to distinguish between features that are
- * intended for expert users from those that are intended for normal users.
- * @return true if this property is to be marked with the expert flag,
- * or false otherwise.
- */
- boolean isAdvanced();
- /**
- * The "required" flag is used to identify features that require at least
- * one value (possibly a default value) by the consumer of the property. Whether
- * a property definition is required or not can be determined entirely from the
- * multiplicity: if the multiplicity includes '0', then the property is
- * not required.
- * <p>
- * Whether a property is required by the consumer is unrelated to whether
- * there is a default value, which only simplifies the task of the property
- * provider. A property may be required, meaning it must have at least one
- * value, but that same property definition may or may not have a default.
- * The combination of required and whether it has a default will determine
- * whether the user must supply a value.
- * @return true if this property requires at least one value.
- */
- boolean isRequired();
- /**
- * The "masked" flag is used to tell whether the value should be masked
- * when displayed to users.
- * @return true if this property value is to be masked,
- * or false otherwise.
- */
- boolean isMasked();
-
-
-
-}
-
-
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Request.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Request.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Request.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-
-
-/**
- * When a user submits a SQL command to the system for processing, usually that represents
- * a single request. A single request might have one or more source
- * requests (the requests that are being processed on the physical data sources) as part
- * of original request.
- *
- * <p>A request is identified by a numbers separated by '|'. usually in they are arranged
- * in the pattern [session]|[request] or [session]|[request]|[source request] </p>
- */
-public interface Request extends AdminObject {
-
- public enum ProcessingState {
- PROCESSING,
- DONE,
- CANCELED
- }
-
- public enum ThreadState {
- RUNNING,
- QUEUED,
- IDLE
- }
-
- /**
- * Get the ExecutionId for a Request
- * @return ExecutionId
- */
- public long getExecutionId();
-
- /**
- * Get the SessionID for a Request
- *
- * @return String SessionID
- */
- public String getSessionId();
-
- /**
- * Get the SQL Command sent to the Server for a Request
- *
- * @return SQL Command
- */
- public String getCommand();
-
- /**
- * Get when the processing began for this Request
- * @return Date processing began
- */
- public long getStartTime();
-
- /**
- * Get the TransactionID of the Request
- *
- * @return String of TransactionID if in a transaction
- */
- public String getTransactionId();
-
- /**
- * @return Returns whether this is a Source Request.
- */
- public boolean sourceRequest();
-
- /**
- * @return In the case that this is a source request this represents the node id. Otherwise null
- */
- public Integer getNodeId();
-
- /**
- * @return The request state
- */
- ProcessingState getState();
-
- /**
- * @return The thread state
- */
- ThreadState getThreadState();
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Session.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Session.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-/**
- * A Session represents a single connection between a client and the server.
- *
- * A user is allowed to have multiple sessions active simultaneously.
- */
-public interface Session extends AdminObject {
-
- /**
- * Get the Last time Client has check to see if the server is still available
- *
- * @return Date of the last ping to the server.
- */
- public long getLastPingTime();
-
-
- /**
- * Get the Application Name
- *
- * @return String of the Application Name
- */
- public String getApplicationName();
-
- /**
- * Get the unique Teiid session
- * within a given Teiid System
- *
- * @return String of the Session ID
- */
- public String getSessionId();
-
- /**
- * Get User Name for this Session
- *
- * @return String of UserName
- */
- public String getUserName();
-
- /**
- * Get the VDB Name for this Session
- *
- * @return String name of the VDB
- */
- public String getVDBName();
-
- /**
- * Get the VDB Version for this Session
- *
- * @return String name/number of the VDB Version
- */
- public int getVDBVersion();
-
- /**
- * Get the IPAddress for this Session. Note this value is reported from the client.
- * @return
- */
- public String getIPAddress();
-
-
- /**
- * Get the host name of the machine the client is
- * accessing from. Note this value is reported from the client.
- * @return
- */
- public String getClientHostName();
-
- /**
- * Get the client hardware (typically MAC) address. Note this value is reported from the client.
- * @return the hardware address as a hex string or null if not available.
- */
- public String getClientHardwareAddress();
-
- /**
- * Get the time the {@link Session} was created.
- * @return
- */
- public long getCreatedTime();
-
-
- /**
- * Security Domain user logged into currently
- * @return
- */
- public String getSecurityDomain();
-
-}
\ No newline at end of file
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Transaction.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Transaction.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Transaction.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-
-public interface Transaction extends AdminObject {
-
- /**
- * Get the session associated with the this transaction.
- * May be null for an unassociated Global transaction.
- * @return
- */
- String getAssociatedSession();
-
- /**
- * Get the scope for the transaction. Will be one of GLOBAL, LOCAL, or REQUEST
- * @return
- */
- String getScope();
-
- /**
- * Returns the Xid string for GLOBAL transactions or the Transaction id string LOCAL/REQUEST.
- * @return
- */
- String getId();
-
-
- /**
- * Get the local creation time.
- * @return
- */
- long getCreatedTime();
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/Translator.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/Translator.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/Translator.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi;
-
-
-public interface Translator extends AdminObject{
- public static final String EXECUTION_FACTORY_CLASS = "execution-factory-class"; //$NON-NLS-1$
- public static final String TRANSLATOR_PROPERTY = "property"; //$NON-NLS-1$
-
- /**
- * Get the Translator type
- * @return
- */
- public String getType();
-
- /**
- * Get the Translator description
- * @return
- */
- public String getDescription();
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/VDB.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/VDB.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.util.List;
-
-/**
- * Represents a Virtual Database in the Teiid System.
- * <br>A VDB has a name and a version.</br>
- *
- * <p>The identifier pattern for a VDB is <CODE>"name<{@link #DELIMITER_CHAR}>version"</CODE>,
- * where the name of the VDB and its version represent its unique identifier in the Teiid system.
- * There are no spaces allowed in a given VDB name, and VDB name must start with a letter.
- * A version number is automatically assigned to a VDB when it is deployed into
- * a system. A VDB is uniquely identified by <CODE>"name<{@link #DELIMITER_CHAR}>version"</CODE>.
- * For example: <CODE>"Accounts<{@link #DELIMITER_CHAR}>1"</CODE>, <CODE>"UnifiedSales<{@link #DELIMITER_CHAR}>4</CODE>" etc.
- * </p>
- *
- * @since 4.3
- */
-public interface VDB extends AdminObject {
-
- public static enum Status{INACTIVE, ACTIVE};
-
- public enum ConnectionType {NONE, BY_VERSION, ANY}
-
- /**
- * @return Collection of Teiid Models
- */
- public List<Model> getModels();
-
- /**
- * @return the status
- */
- public Status getStatus();
-
- /**
- * @return the connection status
- */
- public ConnectionType getConnectionType();
-
- /**
- * @return the VDB version
- */
- public int getVersion();
-
- /**
- * Get the URL for the VDB
- * @return
- */
- public String getUrl();
-
- /**
- * Get the description of the VDB
- * @return
- */
- public String getDescription();
-
- /**
- * Shows any validity errors present in the VDB
- * @return
- */
- public List<String> getValidityErrors();
-
- /**
- * Shows if VDB is a valid entity
- * @return
- */
- public boolean isValid();
-
- /**
- * Get the data roles defined on this VDB
- * @return
- */
- public List<DataPolicy> getDataPolicies();
-
- /**
- * Get the list of translators defined in the VDB
- * @return
- */
- public List<Translator> getOverrideTranslators();
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi;
-
-public interface WorkerPoolStatistics extends AdminObject {
-
- /**
- * Current active thread count
- * @return
- */
- public int getActiveThreads();
-
- /**
- * Highest Active threads recorded so far
- * @return
- */
- public int getHighestActiveThreads();
-
-
- /**
- * Queue Name
- * @return
- */
- public String getQueueName();
-
-
- /**
- * Max number of active threads allowed
- * @return
- */
- public int getMaxThreads();
-
- /**
- * @return Returns the number of requests queued.
- * @since 4.3
- */
- public int getQueued();
-
- /**
- * @return The number of completed tasks
- */
- long getTotalCompleted();
-
-
- /**
- * @return The number of submitted tasks
- */
- long getTotalSubmitted();
-
- /**
- * @return Returns the highest queue size
- */
- public int getHighestQueued();
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,187 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-
-import org.teiid.adminapi.AdminObject;
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-public abstract class AdminObjectImpl implements AdminObject, Serializable {
-
- private static final long serialVersionUID = -6381303538713462682L;
-
- private String name;
-
- private ListOverMap<PropertyMetadata> properties = new ListOverMap<PropertyMetadata>(new KeyBuilder<PropertyMetadata>() {
- private static final long serialVersionUID = 3687928367250819142L;
-
- @Override
- public String getKey(PropertyMetadata entry) {
- return entry.getName();
- }
- });
-
- private transient Map<String, Object> attachments = Collections.synchronizedMap(new HashMap<String, Object>());
-
- @Override
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public Properties getProperties() {
- Properties props = new Properties();
- for (PropertyMetadata p:this.properties.getMap().values()) {
- props.setProperty(p.getName(), p.getValue());
- }
- return props;
- }
-
- public void setProperties(Properties props) {
- this.properties.clear();
- if (props != null) {
- for (String key:props.stringPropertyNames()) {
- addProperty(key, props.getProperty(key));
- }
- }
- }
-
- public List<PropertyMetadata> getJAXBProperties(){
- return properties;
- }
-
- public void setJAXBProperties(List<PropertyMetadata> props){
- this.properties.clear();
- if (props != null) {
- for (PropertyMetadata prop:props) {
- addProperty(prop.getName(), prop.getValue());
- }
- }
- }
-
- @Override
- public String getPropertyValue(String name) {
- PropertyMetadata prop = this.properties.getMap().get(name);
- if (prop == null) {
- return null;
- }
- return prop.getValue();
- }
-
- public void addProperty(String key, String value) {
- this.properties.getMap().put(key, new PropertyMetadata(key, value));
- }
-
- /**
- * Add attachment
- *
- * @param <T> the expected type
- * @param attachment the attachment
- * @param type the type
- * @return any previous attachment
- * @throws IllegalArgumentException for a null name, attachment or type
- * @throws UnsupportedOperationException when not supported by the implementation
- */
- public <T> T addAttchment(Class<T> type, T attachment) {
- if (type == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.put(type.getName(), attachment);
- if (result == null)
- return null;
- return type.cast(result);
-
- }
-
- public Object addAttchment(String key, Object attachment) {
- if (key == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.put(key, attachment);
- if (result == null)
- return null;
- return result;
- }
-
- /**
- * Remove attachment
- *
- * @param <T> the expected type
- * @return the attachment or null if not present
- * @param type the type
- * @throws IllegalArgumentException for a null name or type
- */
- public <T> T removeAttachment(Class<T> type) {
- if (type == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.remove(type.getName());
- if (result == null)
- return null;
- return type.cast(result);
- }
-
- public Object removeAttachment(String key) {
- if (key == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.remove(key);
- if (result == null)
- return null;
- return result;
- }
- /**
- * Get attachment
- *
- * @param <T> the expected type
- * @param type the type
- * @return the attachment or null if not present
- * @throws IllegalArgumentException for a null name or type
- */
- public <T> T getAttachment(Class<T> type) {
- if (type == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.get(type.getName());
- if (result == null)
- return null;
- return type.cast(result);
- }
-
- public Object getAttachment(String key) {
- if (key == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.get(key);
- if (result == null)
- return null;
- return result;
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import org.teiid.adminapi.CacheStatistics;
-
-public class CacheStatisticsMetadata extends AdminObjectImpl implements CacheStatistics{
-
- private static final long serialVersionUID = -3514505497661004560L;
-
- private double hitRatio;
- private int totalEntries;
- private int requestCount;
-
- @Override
- public int getRequestCount() {
- return requestCount;
- }
-
- public void setRequestCount(int count) {
- this.requestCount = count;
- }
-
- @Override
- public double getHitRatio() {
- return this.hitRatio;
- }
-
- @Override
- public int getTotalEntries() {
- return this.totalEntries;
- }
-
- public void setHitRatio(double value) {
- this.hitRatio = value;
- }
-
- public void setTotalEntries(int value) {
- this.totalEntries = value;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("hitRatio=").append(hitRatio);//$NON-NLS-1$
- sb.append("; totalEntries=").append(totalEntries); //$NON-NLS-1$
- sb.append("; requestCount=").append(requestCount); //$NON-NLS-1$
- return sb.toString();
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.teiid.adminapi.AdminException;
-
-
-public interface DQPManagement {
- List<RequestMetadata> getRequestsForSession(String sessionId) ;
- List<RequestMetadata> getRequests();
- WorkerPoolStatisticsMetadata getWorkerPoolStatistics();
- void terminateSession(String terminateeId);
- boolean cancelRequest(String sessionId, long requestId) throws AdminException;
- Collection<String> getCacheTypes();
- void clearCache(String cacheType);
- void clearCache(String cacheType, String vdbName, int version);
- Collection<SessionMetadata> getActiveSessions() throws AdminException;
- int getActiveSessionsCount() throws AdminException;
- Collection<TransactionMetadata> getTransactions();
- void terminateTransaction(String xid) throws AdminException ;
- void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException;
- List<RequestMetadata> getLongRunningRequests();
- List<RequestMetadata> getRequestsUsingVDB(String vdbName, int vdbVersion) throws AdminException;
- CacheStatisticsMetadata getCacheStatistics(String cacheType);
- List<List> executeQuery(String vdbName, int version, String command, long timoutInMilli) throws AdminException;
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,291 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.*;
-
-import org.teiid.adminapi.DataPolicy;
-
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "permissions",
- "mappedRoleNames"
-})
-public class DataPolicyMetadata implements DataPolicy, Serializable {
- private static final long serialVersionUID = -4119646357275977190L;
-
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlElement(name = "description")
- protected String description;
- @XmlAttribute(name = "any-authenticated")
- protected boolean anyAuthenticated;
- @XmlAttribute(name = "allow-create-temporary-tables")
- protected Boolean allowCreateTemporaryTables;
-
- @XmlElement(name = "permission")
- protected PermissionMap permissions = new PermissionMap(new KeyBuilder<PermissionMetaData>() {
- private static final long serialVersionUID = -6992984146431492449L;
- @Override
- public String getKey(PermissionMetaData entry) {
- return entry.getResourceName().toLowerCase();
- }
- });
-
- @XmlElement(name = "mapped-role-name")
- protected List<String> mappedRoleNames = new ArrayList<String>();
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String value) {
- this.name = value;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String value) {
- this.description = value;
- }
-
- @Override
- public List<DataPermission> getPermissions() {
- return new ArrayList<DataPermission>(this.permissions.getMap().values());
- }
-
- public void setPermissions(List<DataPermission> permissions) {
- this.permissions.getMap().clear();
- for (DataPermission permission:permissions) {
- this.permissions.add((PermissionMetaData)permission);
- }
- }
-
- public void addPermission(PermissionMetaData... permissions) {
- for (PermissionMetaData permission:permissions) {
- this.permissions.add(permission);
- }
- }
-
- @Override
- public List<String> getMappedRoleNames() {
- return mappedRoleNames;
- }
-
- public void setMappedRoleNames(List<String> names) {
- this.mappedRoleNames.clear();
- this.mappedRoleNames.addAll(names);
- }
-
- public void addMappedRoleName(String name) {
- this.mappedRoleNames.add(name);
- }
-
- public boolean allows(String resourceName, DataPolicy.PermissionType type) {
- resourceName = resourceName.toLowerCase();
- while (resourceName.length() > 0) {
- PermissionMetaData p = this.permissions.getMap().get(resourceName);
- if (p != null) {
- Boolean allowed = p.allows(type);
- if (allowed != null) {
- return allowed;
- }
- }
- resourceName = resourceName.substring(0, Math.max(0, resourceName.lastIndexOf('.')));
- }
- return false;
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = {
- "resourceName",
- "allowCreate",
- "allowRead",
- "allowUpdate",
- "allowDelete",
- "allowExecute",
- "allowAlter"
- })
- public static class PermissionMetaData implements DataPermission, Serializable {
- private static final long serialVersionUID = 7034744531663164277L;
-
- // XML based fields
- private String resourceName;
- @XmlElement(name = "allow-create")
- protected Boolean allowCreate;
- @XmlElement(name = "allow-read")
- protected Boolean allowRead;
- @XmlElement(name = "allow-update")
- protected Boolean allowUpdate;
- @XmlElement(name = "allow-delete")
- protected Boolean allowDelete;
- @XmlElement(name = "allow-execute")
- protected Boolean allowExecute;
- @XmlElement(name = "allow-alter")
- protected Boolean allowAlter;
-
- @Override
- @XmlElement(name = "resource-name", required = true)
- public String getResourceName() {
- return resourceName;
- }
-
- public void setResourceName(String value) {
- this.resourceName = value;
- }
-
- @Override
- public Boolean getAllowCreate() {
- return allowCreate;
- }
-
- public void setAllowCreate(Boolean value) {
- this.allowCreate = value;
- }
-
- @Override
- public Boolean getAllowRead() {
- return allowRead;
- }
-
- public void setAllowRead(Boolean value) {
- this.allowRead = value;
- }
-
- @Override
- public Boolean getAllowUpdate() {
- return allowUpdate;
- }
-
- public void setAllowUpdate(Boolean value) {
- this.allowUpdate = value;
- }
-
- @Override
- public Boolean getAllowDelete() {
- return allowDelete;
- }
-
- public void setAllowDelete(Boolean value) {
- this.allowDelete = value;
- }
-
- public String getType() {
- StringBuilder sb = new StringBuilder();
- if (Boolean.TRUE.equals(getAllowCreate())) {
- sb.append("C");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowRead())) {
- sb.append("R");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowUpdate())) {
- sb.append("U");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowDelete())) {
- sb.append("D");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowExecute())) {
- sb.append("E");//$NON-NLS-1$
- }
- if (Boolean.TRUE.equals(getAllowAlter())) {
- sb.append("A");//$NON-NLS-1$
- }
- return sb.toString();
- }
-
- public Boolean allows(PermissionType type) {
- switch (type) {
- case ALTER:
- return getAllowAlter();
- case CREATE:
- return getAllowCreate();
- case EXECUTE:
- if (getAllowExecute() != null) {
- return getAllowExecute();
- }
- case READ:
- return getAllowRead();
- case UPDATE:
- return getAllowUpdate();
- case DELETE:
- return getAllowDelete();
- }
- throw new AssertionError();
- }
-
- @Override
- public Boolean getAllowAlter() {
- return allowAlter;
- }
-
- @Override
- public Boolean getAllowExecute() {
- return allowExecute;
- }
-
- public void setAllowAlter(Boolean allowAlter) {
- this.allowAlter = allowAlter;
- }
-
- public void setAllowExecute(Boolean allowExecute) {
- this.allowExecute = allowExecute;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(getResourceName());
- sb.append("["); //$NON-NLS-1$
- sb.append(getType());
- sb.append("]");//$NON-NLS-1$
- return sb.toString();
- }
- }
-
- public Boolean isAllowCreateTemporaryTables() {
- return allowCreateTemporaryTables;
- }
-
- public void setAllowCreateTemporaryTables(Boolean allowCreateTemporaryTables) {
- this.allowCreateTemporaryTables = allowCreateTemporaryTables;
- }
-
- @Override
- public boolean isAnyAuthenticated() {
- return this.anyAuthenticated;
- }
-
- public void setAnyAuthenticated(boolean anyAuthenticated) {
- this.anyAuthenticated = anyAuthenticated;
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2008 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.AbstractList;
-import java.util.LinkedHashMap;
-import java.util.Set;
-
-class ListOverMap<E> extends AbstractList<E> implements Serializable {
-
- private static final long serialVersionUID = 5171741731121210240L;
-
- protected LinkedHashMap<String, E> map = new LinkedHashMap<String, E>();
- protected KeyBuilder<E> builder;
-
- public ListOverMap(KeyBuilder<E> builder) {
- this.builder = builder;
- }
-
- public LinkedHashMap<String, E> getMap() {
- return map;
- }
-
- @Override
- public void add(int index, E element) {
- this.map.put(builder.getKey(element), element);
- }
-
- @Override
- public E remove(int index) {
- String key = getKey(index);
- if (key == null) {
- throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return this.map.remove(key);
- }
-
- @Override
- public E get(int index) {
- String key = getKey(index);
- if (key == null) {
- throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return this.map.get(key);
- }
-
- private String getKey(int index) {
- Set<String> keys = this.map.keySet();
- int i = 0;
- for (String key:keys) {
- if (i == index) {
- return key;
- }
- i++;
- }
- return null;
- }
-
- @Override
- public int size() {
- return this.map.size();
- }
-}
-
-interface KeyBuilder<E> extends Serializable {
- String getKey(E entry);
-}
-
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,1071 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-import org.teiid.adminapi.AdminPlugin;
-import org.teiid.adminapi.DataPolicy;
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.Request.ProcessingState;
-import org.teiid.adminapi.Request.ThreadState;
-import org.teiid.adminapi.VDB.ConnectionType;
-import org.teiid.adminapi.VDB.Status;
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-
-
-public class MetadataMapper {
- private static final String VDBNAME = "vdb-name"; //$NON-NLS-1$
- private static final String CONNECTIONTYPE = "connection-type"; //$NON-NLS-1$
- private static final String STATUS = "status"; //$NON-NLS-1$
- private static final String VERSION = "vdb-version"; //$NON-NLS-1$
- private static final String URL = "url"; //$NON-NLS-1$
- private static final String MODELS = "models"; //$NON-NLS-1$
- private static final String OVERRIDE_TRANSLATORS = "override-translators"; //$NON-NLS-1$
- private static final String DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String PROPERTIES = "properties"; //$NON-NLS-1$
- private static final String DYNAMIC = "dynamic"; //$NON-NLS-1$
- private static final String DATA_POLICIES = "data-policies"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(VDBMetaData vdb, ModelNode node) {
- if (vdb == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(VDBNAME).set(vdb.getName());
- node.get(CONNECTIONTYPE).set(vdb.getConnectionType().toString());
- node.get(STATUS).set(vdb.getStatus().toString());
- node.get(VERSION).set(vdb.getVersion());
- if (vdb.getUrl() != null) {
- }
- if (vdb.getDescription() != null) {
- node.get(DESCRIPTION).set(vdb.getDescription());
- }
- node.get(DYNAMIC).set(vdb.isDynamic());
-
- //PROPERTIES
- List<PropertyMetadata> properties = vdb.getJAXBProperties();
- if (properties!= null && !properties.isEmpty()) {
- ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
- for (PropertyMetadata prop:properties) {
- propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
- }
- }
-
- // MODELS
- Map<String, ModelMetaData> models = vdb.getModelMetaDatas();
- if (models != null && !models.isEmpty()) {
- ModelNode modelNodes = node.get(CHILDREN, MODELS);
- for(ModelMetaData model:models.values()) {
- modelNodes.add(ModelMetadataMapper.wrap(model, new ModelNode()));
- }
- }
-
- // OVERRIDE_TRANSLATORS
- List<Translator> translators = vdb.getOverrideTranslators();
- if (translators != null && !translators.isEmpty()) {
- ModelNode translatorNodes = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
- for (Translator translator:translators) {
- translatorNodes.add(VDBTranslatorMetaDataMapper.wrap((VDBTranslatorMetaData)translator, new ModelNode()));
- }
- }
-
- // DATA_POLICIES
- List<DataPolicy> policies = vdb.getDataPolicies();
- if (policies != null && !policies.isEmpty()) {
- ModelNode dataPoliciesNodes = node.get(CHILDREN, DATA_POLICIES);
- for (DataPolicy policy:policies) {
- dataPoliciesNodes.add(DataPolicyMetadataMapper.wrap((DataPolicyMetadata)policy, new ModelNode()));
- }
- }
- return node;
- }
-
- public static VDBMetaData unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- VDBMetaData vdb = new VDBMetaData();
- if (node.has(VDBNAME)) {
- vdb.setName(node.get(VDBNAME).asString());
- }
- if (node.has(CONNECTIONTYPE)) {
- vdb.setConnectionType(node.get(CONNECTIONTYPE).asString());
- }
- if (node.has(STATUS)) {
- vdb.setStatus(node.get(STATUS).asString());
- }
- if (node.has(VERSION)) {
- vdb.setVersion(node.get(VERSION).asInt());
- }
- if (node.has(URL)) {
- vdb.setUrl(node.get(URL).asString());
- }
- if(node.has(DESCRIPTION)) {
- vdb.setDescription(node.get(DESCRIPTION).asString());
- }
- if (node.has(DYNAMIC)) {
- vdb.setDynamic(node.get(DYNAMIC).asBoolean());
- }
-
- //PROPERTIES
- if (node.get(CHILDREN, PROPERTIES).isDefined()) {
- List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
- for (ModelNode propNode:propNodes) {
- PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
- if (prop != null) {
- vdb.addProperty(prop.getName(), prop.getValue());
- }
- }
- }
-
- // MODELS
- if (node.get(CHILDREN, MODELS).isDefined()) {
- List<ModelNode> modelNodes = node.get(CHILDREN, MODELS).asList();
- for(ModelNode modelNode:modelNodes) {
- ModelMetaData model = ModelMetadataMapper.unwrap(modelNode);
- if (model != null) {
- vdb.addModel(model);
- }
- }
- }
-
- // OVERRIDE_TRANSLATORS
- if (node.get(CHILDREN, OVERRIDE_TRANSLATORS).isDefined()) {
- List<ModelNode> translatorNodes = node.get(CHILDREN, OVERRIDE_TRANSLATORS).asList();
- for (ModelNode translatorNode:translatorNodes) {
- VDBTranslatorMetaData translator = VDBTranslatorMetaDataMapper.unwrap(translatorNode);
- if (translator != null) {
- vdb.addOverideTranslator(translator);
- }
- }
- }
-
- // DATA_POLICIES
- if (node.get(CHILDREN, DATA_POLICIES).isDefined()) {
- List<ModelNode> policiesNodes = node.get(CHILDREN, DATA_POLICIES).asList();
- for (ModelNode policyNode:policiesNodes) {
- DataPolicyMetadata policy = DataPolicyMetadataMapper.unwrap(policyNode);
- if (policy != null) {
- vdb.addDataPolicy(policy);
- }
-
- }
- }
- return vdb;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, VDBNAME, ModelType.STRING, true);
-
- ModelNode connectionsAllowed = new ModelNode();
- connectionsAllowed.add(ConnectionType.NONE.toString());
- connectionsAllowed.add(ConnectionType.ANY.toString());
- connectionsAllowed.add(ConnectionType.BY_VERSION.toString());
- addAttribute(node, CONNECTIONTYPE, ModelType.STRING, false).get(ALLOWED).set(connectionsAllowed);
-
- ModelNode statusAllowed = new ModelNode();
- statusAllowed.add(Status.ACTIVE.toString());
- statusAllowed.add(Status.INACTIVE.toString());
- addAttribute(node, STATUS, ModelType.STRING, true).get(ALLOWED).set(statusAllowed);
-
- addAttribute(node, VERSION, ModelType.INT, true);
- addAttribute(node, URL, ModelType.STRING, false);
- addAttribute(node, DESCRIPTION, ModelType.STRING, false);
- addAttribute(node, DYNAMIC, ModelType.BOOLEAN, false);
-
- ModelNode props = node.get(CHILDREN, PROPERTIES);
- props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
- PropertyMetaDataMapper.describe(props);
-
- ModelNode models = node.get(CHILDREN, MODELS);
- ModelMetadataMapper.describe(models);
- models.get(DESCRIPTION).set(AdminPlugin.Util.getString(MODELS+DOT_DESC));
- models.get(MIN_OCCURS).set(1);
-
- ModelNode translators = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
- translators.get(DESCRIPTION).set(AdminPlugin.Util.getString(OVERRIDE_TRANSLATORS+DOT_DESC));
- VDBTranslatorMetaDataMapper.describe(translators);
-
- ModelNode dataPolicies = node.get(CHILDREN, DATA_POLICIES);
- dataPolicies.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_POLICIES+DOT_DESC));
- DataPolicyMetadataMapper.describe(dataPolicies);
- return node;
- }
-
- /**
- * model metadata mapper
- */
- public static class ModelMetadataMapper {
- private static final String MODEL_NAME = "model-name"; //$NON-NLS-1$
- private static final String DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String VISIBLE = "visible"; //$NON-NLS-1$
- private static final String MODEL_TYPE = "model-type"; //$NON-NLS-1$
- private static final String MODELPATH = "model-path"; //$NON-NLS-1$
- private static final String PROPERTIES = "properties"; //$NON-NLS-1$
- private static final String SOURCE_MAPPINGS = "source-mappings"; //$NON-NLS-1$
- private static final String VALIDITY_ERRORS = "validity-errors"; //$NON-NLS-1$
-
- public static ModelNode wrap(ModelMetaData model, ModelNode node) {
- if (model == null) {
- return null;
- }
- node.get(TYPE).set(ModelType.OBJECT);
-
- node.get(MODEL_NAME).set(model.getName());
- if (model.getDescription() != null) {
- node.get(DESCRIPTION).set(model.getDescription());
- }
- node.get(VISIBLE).set(model.isVisible());
- node.get(MODEL_TYPE).set(model.getModelType().toString());
- if (model.getPath() != null) {
- node.get(MODELPATH).set(model.getPath());
- }
-
- List<PropertyMetadata> properties = model.getJAXBProperties();
- if (properties!= null && !properties.isEmpty()) {
- ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
- for (PropertyMetadata prop:properties) {
- propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
- }
- }
-
- List<SourceMappingMetadata> sources = model.getSourceMappings();
- if (sources != null && !sources.isEmpty()) {
- ModelNode sourceMappingNode = node.get(CHILDREN, SOURCE_MAPPINGS);
- for(SourceMappingMetadata source:sources) {
- sourceMappingNode.add(SourceMappingMetadataMapper.wrap(source, new ModelNode()));
- }
- }
-
- List<ValidationError> errors = model.getErrors();
- if (errors != null && !errors.isEmpty()) {
- ModelNode errorsNode = node.get(CHILDREN, VALIDITY_ERRORS);
- for (ValidationError error:errors) {
- errorsNode.add(ValidationErrorMapper.wrap(error));
- }
- }
- return node;
- }
-
- public static ModelMetaData unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
-
- ModelMetaData model = new ModelMetaData();
- if (node.has(MODEL_NAME)) {
- model.setName(node.get(MODEL_NAME).asString());
- }
- if (node.has(DESCRIPTION)) {
- model.setDescription(node.get(DESCRIPTION).asString());
- }
- if (node.has(VISIBLE)) {
- model.setVisible(node.get(VISIBLE).asBoolean());
- }
- if(node.has(MODEL_TYPE)) {
- model.setModelType(node.get(MODEL_TYPE).asString());
- }
- if(node.has(MODELPATH)) {
- model.setPath(node.get(MODELPATH).asString());
- }
-
- if (node.get(CHILDREN, PROPERTIES).isDefined()) {
- List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
- for (ModelNode propNode:propNodes) {
- PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
- if (prop != null) {
- model.addProperty(prop.getName(), prop.getValue());
- }
- }
- }
-
- if (node.get(CHILDREN, SOURCE_MAPPINGS).isDefined()) {
- List<ModelNode> sourceMappingNodes = node.get(CHILDREN, SOURCE_MAPPINGS).asList();
- for (ModelNode sourceMapping:sourceMappingNodes) {
- SourceMappingMetadata source = SourceMappingMetadataMapper.unwrap(sourceMapping);
- if (source != null) {
- model.addSourceMapping(source);
- }
- }
- }
-
- if (node.get(CHILDREN, VALIDITY_ERRORS).isDefined()) {
- List<ModelNode> errorNodes = node.get(CHILDREN, VALIDITY_ERRORS).asList();
- for(ModelNode errorNode:errorNodes) {
- ValidationError error = ValidationErrorMapper.unwrap(errorNode);
- if (error != null) {
- model.addError(error);
- }
- }
- }
- return model;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
-
- ModelNode modelTypes = new ModelNode();
- modelTypes.add(Model.Type.PHYSICAL.toString());
- modelTypes.add(Model.Type.VIRTUAL.toString());
- modelTypes.add(Model.Type.FUNCTION.toString());
- modelTypes.add(Model.Type.OTHER.toString());
- addAttribute(node, MODEL_NAME, ModelType.STRING, true).get(ALLOWED).set(modelTypes);
-
- addAttribute(node, DESCRIPTION, ModelType.STRING, false);
- addAttribute(node, VISIBLE, ModelType.BOOLEAN, false);
- addAttribute(node, MODEL_TYPE, ModelType.STRING, true);
- addAttribute(node, MODELPATH, ModelType.STRING, false);
-
- ModelNode props = node.get(CHILDREN, PROPERTIES);
- props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
- PropertyMetaDataMapper.describe(props);
-
- ModelNode source = node.get(CHILDREN, SOURCE_MAPPINGS);
- source.get(DESCRIPTION).set(AdminPlugin.Util.getString(SOURCE_MAPPINGS+DOT_DESC));
- SourceMappingMetadataMapper.describe(source);
-
- ModelNode errors = node.get(CHILDREN, VALIDITY_ERRORS);
- errors.get(DESCRIPTION).set(AdminPlugin.Util.getString(VALIDITY_ERRORS+DOT_DESC));
- ValidationErrorMapper.describe(errors);
-
- return node;
- }
- }
-
- /**
- * validation error mapper
- */
- public static class ValidationErrorMapper {
- private static final String ERROR_PATH = "error-path"; //$NON-NLS-1$
- private static final String SEVERITY = "severity"; //$NON-NLS-1$
- private static final String MESSAGE = "message"; //$NON-NLS-1$
-
- public static ModelNode wrap(ValidationError error) {
- if (error == null) {
- return null;
- }
-
- ModelNode node = new ModelNode();
- node.get(TYPE).set(ModelType.OBJECT);
- if (error.getPath() != null) {
- node.get(ERROR_PATH).set(error.getPath());
- }
- node.get(SEVERITY).set(error.getSeverity());
- node.get(MESSAGE).set(error.getValue());
-
- return node;
- }
-
- public static ValidationError unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
-
- ValidationError error = new ValidationError();
- if (node.has(ERROR_PATH)) {
- error.setPath(node.get(ERROR_PATH).asString());
- }
- if (node.has(SEVERITY)) {
- error.setSeverity(node.get(SEVERITY).asString());
- }
- if(node.has(MESSAGE)) {
- error.setValue(node.get(MESSAGE).asString());
- }
- return error;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, ERROR_PATH, ModelType.STRING, false);
- addAttribute(node, SEVERITY, ModelType.STRING, true);
- addAttribute(node, MESSAGE, ModelType.STRING, true);
- return node;
- }
- }
-
- /**
- * Source Mapping Metadata mapper
- */
- public static class SourceMappingMetadataMapper {
- private static final String SOURCE_NAME = "source-name"; //$NON-NLS-1$
- private static final String JNDI_NAME = "jndi-name"; //$NON-NLS-1$
- private static final String TRANSLATOR_NAME = "translator-name"; //$NON-NLS-1$
-
- public static ModelNode wrap(SourceMappingMetadata source, ModelNode node) {
- if (source == null) {
- return null;
- }
-
- node.get(TYPE).set(ModelType.OBJECT);
-
- node.get(SOURCE_NAME).set(source.getName());
- node.get(JNDI_NAME).set(source.getConnectionJndiName());
- node.get(TRANSLATOR_NAME).set(source.getTranslatorName());
- return node;
- }
-
- public static SourceMappingMetadata unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
- SourceMappingMetadata source = new SourceMappingMetadata();
- if (node.has(SOURCE_NAME)) {
- source.setName(node.get(SOURCE_NAME).asString());
- }
- if (node.has(JNDI_NAME)) {
- source.setConnectionJndiName(node.get(JNDI_NAME).asString());
- }
- if (node.has(TRANSLATOR_NAME)) {
- source.setTranslatorName(node.get(TRANSLATOR_NAME).asString());
- }
- return source;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, SOURCE_NAME, ModelType.STRING, true);
- addAttribute(node, JNDI_NAME, ModelType.STRING, true);
- addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
- return node;
- }
- }
-
- /**
- * Source Mapping Metadata mapper
- */
- public static class VDBTranslatorMetaDataMapper {
- private static final String TRANSLATOR_NAME = "translator-name"; //$NON-NLS-1$
- private static final String BASETYPE = "base-type"; //$NON-NLS-1$
- private static final String DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String PROPERTIES = "properties"; //$NON-NLS-1$
- private static final String MODULE_NAME = "module-name"; //$NON-NLS-1$
-
- public static ModelNode wrap(VDBTranslatorMetaData translator, ModelNode node) {
- if (translator == null) {
- return null;
- }
- node.get(TYPE).set(ModelType.OBJECT);
-
- node.get(TRANSLATOR_NAME).set(translator.getName());
- if (translator.getType() != null) {
- node.get(BASETYPE).set(translator.getType());
- }
- if (translator.getDescription() != null) {
- node.get(DESCRIPTION).set(translator.getDescription());
- }
-
- if (translator.getModuleName() != null) {
- node.get(MODULE_NAME).set(translator.getModuleName());
- }
-
- List<PropertyMetadata> properties = translator.getJAXBProperties();
- if (properties!= null && !properties.isEmpty()) {
- ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
- for (PropertyMetadata prop:properties) {
- propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
- }
- }
- return node;
- }
-
- public static VDBTranslatorMetaData unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
- VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
- if (node.has(TRANSLATOR_NAME)) {
- translator.setName(node.get(TRANSLATOR_NAME).asString());
- }
- if (node.has(BASETYPE)) {
- translator.setType(node.get(BASETYPE).asString());
- }
- if (node.has(DESCRIPTION)) {
- translator.setDescription(node.get(DESCRIPTION).asString());
- }
- if (node.has(MODULE_NAME)) {
- translator.setModuleName(node.get(MODULE_NAME).asString());
- }
-
- if (node.get(CHILDREN,PROPERTIES).isDefined()) {
- List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
- for (ModelNode propNode:propNodes) {
- PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
- if (prop != null) {
- translator.addProperty(prop.getName(), prop.getValue());
- }
- }
- }
- return translator;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
- addAttribute(node, BASETYPE, ModelType.STRING, true);
- addAttribute(node, DESCRIPTION, ModelType.STRING, false);
- addAttribute(node, MODULE_NAME, ModelType.STRING, false);
-
- ModelNode props = node.get(CHILDREN, PROPERTIES);
- props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
- PropertyMetaDataMapper.describe(props);
- return node;
- }
- }
-
- /**
- * Property Metadata mapper
- */
- public static class PropertyMetaDataMapper {
- private static final String PROPERTY_NAME = "property-name"; //$NON-NLS-1$
- private static final String PROPERTY_VALUE = "property-value"; //$NON-NLS-1$
-
- public static ModelNode wrap(PropertyMetadata property, ModelNode node) {
- if (property == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(PROPERTY_NAME).set(property.getName());
- node.get(PROPERTY_VALUE).set(property.getValue());
-
- return node;
- }
-
- public static PropertyMetadata unwrap(ModelNode node) {
- if(node == null) {
- return null;
- }
- PropertyMetadata property = new PropertyMetadata();
- if (node.has(PROPERTY_NAME)) {
- property.setName(node.get(PROPERTY_NAME).asString());
- }
- if(node.has(PROPERTY_VALUE)) {
- property.setValue(node.get(PROPERTY_VALUE).asString());
- }
- return property;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, PROPERTY_NAME, ModelType.STRING, true);
- addAttribute(node, PROPERTY_VALUE, ModelType.STRING, true);
- return node;
- }
- }
-
- /**
- * DataPolicy Metadata mapper
- */
- public static class DataPolicyMetadataMapper {
- private static final String POLICY_NAME = "policy-name"; //$NON-NLS-1$
- private static final String DATA_PERMISSIONS = "data-permissions"; //$NON-NLS-1$
- private static final String MAPPED_ROLE_NAMES = "mapped-role-names"; //$NON-NLS-1$
- private static final String ALLOW_CREATE_TEMP_TABLES = "allow-create-temp-tables"; //$NON-NLS-1$
- private static final String ANY_AUTHENTICATED = "any-authenticated"; //$NON-NLS-1$
-
- public static ModelNode wrap(DataPolicyMetadata policy, ModelNode node) {
- if (policy == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(POLICY_NAME).set(policy.getName());
- if (policy.getDescription() != null) {
- node.get(DESCRIPTION).set(policy.getDescription());
- }
- if (policy.isAllowCreateTemporaryTables() != null) {
- node.get(ALLOW_CREATE_TEMP_TABLES).set(policy.isAllowCreateTemporaryTables());
- }
- node.get(ANY_AUTHENTICATED).set(policy.isAnyAuthenticated());
-
- //DATA_PERMISSIONS
- List<DataPolicy.DataPermission> permissions = policy.getPermissions();
- if (permissions != null && !permissions.isEmpty()) {
- ModelNode permissionNodes = node.get(CHILDREN, DATA_PERMISSIONS);
- for (DataPolicy.DataPermission dataPermission:permissions) {
- permissionNodes.add(PermissionMetaDataMapper.wrap((PermissionMetaData)dataPermission, new ModelNode()));
- }
- }
-
- //MAPPED_ROLE_NAMES
- if (policy.getMappedRoleNames() != null && !policy.getMappedRoleNames().isEmpty()) {
- ModelNode mappedRoleNodes = node.get(CHILDREN, MAPPED_ROLE_NAMES);
- for (String role:policy.getMappedRoleNames()) {
- mappedRoleNodes.add(role);
- }
- }
- return node;
- }
-
- public static DataPolicyMetadata unwrap(ModelNode node) {
- if(node == null) {
- return null;
- }
- DataPolicyMetadata policy = new DataPolicyMetadata();
- if (node.has(POLICY_NAME)) {
- policy.setName(node.get(POLICY_NAME).asString());
- }
- if (node.has(DESCRIPTION)) {
- policy.setDescription(node.get(DESCRIPTION).asString());
- }
- if (node.has(ALLOW_CREATE_TEMP_TABLES)) {
- policy.setAllowCreateTemporaryTables(node.get(ALLOW_CREATE_TEMP_TABLES).asBoolean());
- }
- if (node.has(ANY_AUTHENTICATED)) {
- policy.setAnyAuthenticated(node.get(ANY_AUTHENTICATED).asBoolean());
- }
-
- //DATA_PERMISSIONS
- if (node.get(CHILDREN, DATA_PERMISSIONS).isDefined()) {
- List<ModelNode> permissionNodes = node.get(CHILDREN, DATA_PERMISSIONS).asList();
- for (ModelNode permissionNode:permissionNodes) {
- PermissionMetaData permission = PermissionMetaDataMapper.unwrap(permissionNode);
- if (permission != null) {
- policy.addPermission(permission);
- }
- }
- }
-
- //MAPPED_ROLE_NAMES
- if (node.get(CHILDREN, MAPPED_ROLE_NAMES).isDefined()) {
- List<ModelNode> roleNameNodes = node.get(CHILDREN, MAPPED_ROLE_NAMES).asList();
- for (ModelNode roleNameNode:roleNameNodes) {
- policy.addMappedRoleName(roleNameNode.asString());
- }
- }
- return policy;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, POLICY_NAME, ModelType.STRING, true);
- addAttribute(node, DESCRIPTION, ModelType.STRING, false);
- addAttribute(node, ALLOW_CREATE_TEMP_TABLES, ModelType.BOOLEAN, false);
- addAttribute(node, ANY_AUTHENTICATED, ModelType.BOOLEAN, false);
-
- ModelNode permissions = node.get(CHILDREN, DATA_PERMISSIONS);
- PropertyMetaDataMapper.describe(permissions);
- permissions.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_PERMISSIONS+DOT_DESC));
- permissions.get(MIN_OCCURS).set(1);
-
- ModelNode roleNames = node.get(CHILDREN, MAPPED_ROLE_NAMES);
- roleNames.get(TYPE).set(ModelType.LIST);
- roleNames.get(DESCRIPTION).set(AdminPlugin.Util.getString(MAPPED_ROLE_NAMES+DOT_DESC));
- roleNames.get("value-type").set(ModelType.STRING); //$NON-NLS-1$
- return node;
- }
- }
-
- public static class PermissionMetaDataMapper{
- private static final String RESOURCE_NAME = "resource-name"; //$NON-NLS-1$
- private static final String ALLOW_CREATE = "allow-create"; //$NON-NLS-1$
- private static final String ALLOW_DELETE = "allow-delete"; //$NON-NLS-1$
- private static final String ALLOW_UPADTE = "allow-update"; //$NON-NLS-1$
- private static final String ALLOW_READ = "allow-read"; //$NON-NLS-1$
- private static final String ALLOW_EXECUTE = "allow-execute"; //$NON-NLS-1$
- private static final String ALLOW_ALTER = "allow-alter"; //$NON-NLS-1$
-
-
-
- public static ModelNode wrap(PermissionMetaData permission, ModelNode node) {
- if (permission == null) {
- return null;
- }
-
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(RESOURCE_NAME).set(permission.getResourceName());
- if (permission.getAllowCreate() != null) {
- node.get(ALLOW_CREATE).set(permission.getAllowCreate().booleanValue());
- }
- if (permission.getAllowDelete() != null) {
- node.get(ALLOW_DELETE).set(permission.getAllowDelete().booleanValue());
- }
- if (permission.getAllowUpdate() != null) {
- node.get(ALLOW_UPADTE).set(permission.getAllowUpdate().booleanValue());
- }
- if (permission.getAllowRead() != null) {
- node.get(ALLOW_READ).set(permission.getAllowRead().booleanValue());
- }
- if (permission.getAllowExecute() != null) {
- node.get(ALLOW_EXECUTE).set(permission.getAllowExecute().booleanValue());
- }
- if(permission.getAllowAlter() != null) {
- node.get(ALLOW_ALTER).set(permission.getAllowAlter().booleanValue());
- }
- return node;
- }
-
- public static PermissionMetaData unwrap(ModelNode node) {
- if (node == null) {
- return null;
- }
-
- PermissionMetaData permission = new PermissionMetaData();
- if (node.get(RESOURCE_NAME) != null) {
- permission.setResourceName(node.get(RESOURCE_NAME).asString());
- }
- if (node.has(ALLOW_CREATE)) {
- permission.setAllowCreate(node.get(ALLOW_CREATE).asBoolean());
- }
- if (node.has(ALLOW_DELETE)) {
- permission.setAllowDelete(node.get(ALLOW_DELETE).asBoolean());
- }
- if (node.has(ALLOW_UPADTE)) {
- permission.setAllowUpdate(node.get(ALLOW_UPADTE).asBoolean());
- }
- if (node.has(ALLOW_READ)) {
- permission.setAllowRead(node.get(ALLOW_READ).asBoolean());
- }
- if (node.has(ALLOW_EXECUTE)) {
- permission.setAllowExecute(node.get(ALLOW_EXECUTE).asBoolean());
- }
- if (node.has(ALLOW_ALTER)) {
- permission.setAllowAlter(node.get(ALLOW_ALTER).asBoolean());
- }
- return permission;
- }
- public static ModelNode describe(ModelNode node) {
- addAttribute(node, RESOURCE_NAME, ModelType.STRING, true);
- addAttribute(node, ALLOW_CREATE, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_DELETE, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_UPADTE, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_READ, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_EXECUTE, ModelType.BOOLEAN, false);
- addAttribute(node, ALLOW_ALTER, ModelType.BOOLEAN, false);
- return node;
- }
- }
-
- public static class CacheStatisticsMetadataMapper {
- private static final String HITRATIO = "hitRatio"; //$NON-NLS-1$
- private static final String TOTAL_ENTRIES = "totalEntries"; //$NON-NLS-1$
- private static final String REQUEST_COUNT = "requestCount"; //$NON-NLS-1$
-
- public static ModelNode wrap(CacheStatisticsMetadata object, ModelNode node) {
- if (object == null)
- return null;
-
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(TOTAL_ENTRIES).set(object.getTotalEntries());
- node.get(HITRATIO).set(object.getHitRatio());
- node.get(REQUEST_COUNT).set(object.getRequestCount());
-
- return node;
- }
-
- public static CacheStatisticsMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- CacheStatisticsMetadata cache = new CacheStatisticsMetadata();
- cache.setTotalEntries(node.get(TOTAL_ENTRIES).asInt());
- cache.setHitRatio(node.get(HITRATIO).asDouble());
- cache.setRequestCount(node.get(REQUEST_COUNT).asInt());
- return cache;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, TOTAL_ENTRIES, ModelType.STRING, true);
- addAttribute(node, HITRATIO, ModelType.STRING, true);
- addAttribute(node, REQUEST_COUNT, ModelType.STRING, true);
- return node;
- }
- }
-
- public static class RequestMetadataMapper {
- private static final String TRANSACTION_ID = "transaction-id"; //$NON-NLS-1$
- private static final String NODE_ID = "node-id"; //$NON-NLS-1$
- private static final String SOURCE_REQUEST = "source-request"; //$NON-NLS-1$
- private static final String COMMAND = "command"; //$NON-NLS-1$
- private static final String START_TIME = "start-time"; //$NON-NLS-1$
- private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
- private static final String EXECUTION_ID = "execution-id"; //$NON-NLS-1$
- private static final String STATE = "processing-state"; //$NON-NLS-1$
- private static final String THREAD_STATE = "thread-state"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(RequestMetadata request, ModelNode node) {
- if (request == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(EXECUTION_ID).set(request.getExecutionId());
- node.get(SESSION_ID).set(request.getSessionId());
- node.get(START_TIME).set(request.getStartTime());
- node.get(COMMAND).set(request.getCommand());
- node.get(SOURCE_REQUEST).set(request.sourceRequest());
- if (request.getNodeId() != null) {
- node.get(NODE_ID).set(request.getNodeId());
- }
- if (request.getTransactionId() != null) {
- node.get(TRANSACTION_ID).set(request.getTransactionId());
- }
- node.get(STATE).set(request.getState().name());
- node.get(THREAD_STATE).set(request.getThreadState().name());
- return node;
- }
-
- public static RequestMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- RequestMetadata request = new RequestMetadata();
- request.setExecutionId(node.get(EXECUTION_ID).asLong());
- request.setSessionId(node.get(SESSION_ID).asString());
- request.setStartTime(node.get(START_TIME).asLong());
- request.setCommand(node.get(COMMAND).asString());
- request.setSourceRequest(node.get(SOURCE_REQUEST).asBoolean());
- if (node.has(NODE_ID)) {
- request.setNodeId(node.get(NODE_ID).asInt());
- }
- if (node.has(TRANSACTION_ID)) {
- request.setTransactionId(node.get(TRANSACTION_ID).asString());
- }
- request.setState(ProcessingState.valueOf(node.get(STATE).asString()));
- request.setThreadState(ThreadState.valueOf(node.get(THREAD_STATE).asString()));
- return request;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, EXECUTION_ID, ModelType.LONG, true);
- addAttribute(node, SESSION_ID, ModelType.STRING, true);
- addAttribute(node, START_TIME, ModelType.LONG, true);
- addAttribute(node, COMMAND, ModelType.STRING, true);
- addAttribute(node, SOURCE_REQUEST, ModelType.BOOLEAN, true);
- addAttribute(node, NODE_ID, ModelType.INT, false);
- addAttribute(node, TRANSACTION_ID, ModelType.STRING, false);
- addAttribute(node, STATE, ModelType.STRING, true);
- addAttribute(node, THREAD_STATE, ModelType.STRING, true);
- return node;
- }
- }
-
- public static class SessionMetadataMapper {
- private static final String SECURITY_DOMAIN = "security-domain"; //$NON-NLS-1$
- private static final String VDB_VERSION = "vdb-version"; //$NON-NLS-1$
- private static final String VDB_NAME = "vdb-name"; //$NON-NLS-1$
- private static final String USER_NAME = "user-name"; //$NON-NLS-1$
- private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
- private static final String LAST_PING_TIME = "last-ping-time"; //$NON-NLS-1$
- private static final String IP_ADDRESS = "ip-address"; //$NON-NLS-1$
- private static final String CLIENT_HOST_NAME = "client-host-address"; //$NON-NLS-1$
- private static final String CREATED_TIME = "created-time"; //$NON-NLS-1$
- private static final String APPLICATION_NAME = "application-name"; //$NON-NLS-1$
- private static final String CLIENT_HARDWARE_ADRESS = "client-hardware-address"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(SessionMetadata session, ModelNode node) {
- if (session == null) {
- return null;
- }
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- if (session.getApplicationName() != null) {
- node.get(APPLICATION_NAME).set(session.getApplicationName());
- }
- node.get(CREATED_TIME).set(session.getCreatedTime());
- node.get(CLIENT_HOST_NAME).set(session.getClientHostName());
- node.get(IP_ADDRESS).set(session.getIPAddress());
- node.get(LAST_PING_TIME).set(session.getLastPingTime());
- node.get(SESSION_ID).set(session.getSessionId());
- node.get(USER_NAME).set(session.getUserName());
- node.get(VDB_NAME).set(session.getVDBName());
- node.get(VDB_VERSION).set(session.getVDBVersion());
- if (session.getSecurityDomain() != null){
- node.get(SECURITY_DOMAIN).set(session.getSecurityDomain());
- }
- if (session.getClientHardwareAddress() != null) {
- node.get(CLIENT_HARDWARE_ADRESS).set(session.getClientHardwareAddress());
- }
- return node;
- }
-
- public static SessionMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- SessionMetadata session = new SessionMetadata();
- if (node.has(APPLICATION_NAME)) {
- session.setApplicationName(node.get(APPLICATION_NAME).asString());
- }
- session.setCreatedTime(node.get(CREATED_TIME).asLong());
- session.setClientHostName(node.get(CLIENT_HOST_NAME).asString());
- session.setIPAddress(node.get(IP_ADDRESS).asString());
- session.setLastPingTime(node.get(LAST_PING_TIME).asLong());
- session.setSessionId(node.get(SESSION_ID).asString());
- session.setUserName(node.get(USER_NAME).asString());
- session.setVDBName(node.get(VDB_NAME).asString());
- session.setVDBVersion(node.get(VDB_VERSION).asInt());
- if (node.has(SECURITY_DOMAIN)) {
- session.setSecurityDomain(node.get(SECURITY_DOMAIN).asString());
- }
- if (node.has(CLIENT_HARDWARE_ADRESS)) {
- session.setClientHardwareAddress(node.get(CLIENT_HARDWARE_ADRESS).asString());
- }
- return session;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, APPLICATION_NAME, ModelType.STRING, false);
- addAttribute(node, CREATED_TIME, ModelType.LONG, true);
- addAttribute(node, CLIENT_HOST_NAME, ModelType.LONG, true);
- addAttribute(node, IP_ADDRESS, ModelType.STRING, true);
- addAttribute(node, LAST_PING_TIME, ModelType.LONG, true);
- addAttribute(node, SESSION_ID, ModelType.STRING, true);
- addAttribute(node, USER_NAME, ModelType.STRING, true);
- addAttribute(node, VDB_NAME, ModelType.STRING, true);
- addAttribute(node, VDB_VERSION, ModelType.INT, true);
- addAttribute(node, SECURITY_DOMAIN, ModelType.STRING, false);
- return node;
- }
- }
-
- public static class TransactionMetadataMapper {
- private static final String ID = "txn-id"; //$NON-NLS-1$
- private static final String SCOPE = "txn-scope"; //$NON-NLS-1$
- private static final String CREATED_TIME = "txn-created-time"; //$NON-NLS-1$
- private static final String ASSOCIATED_SESSION = "session-id"; //$NON-NLS-1$
-
- public static ModelNode wrap(TransactionMetadata object, ModelNode transaction) {
- if (object == null)
- return null;
-
- transaction.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
- transaction.get(ASSOCIATED_SESSION).set(object.getAssociatedSession());
- transaction.get(CREATED_TIME).set(object.getCreatedTime());
- transaction.get(SCOPE).set(object.getScope());
- transaction.get(ID).set(object.getId());
-
- return transaction;
- }
-
- public static TransactionMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- TransactionMetadata transaction = new TransactionMetadata();
- transaction.setAssociatedSession(node.get(ASSOCIATED_SESSION).asString());
- transaction.setCreatedTime(node.get(CREATED_TIME).asLong());
- transaction.setScope(node.get(SCOPE).asString());
- transaction.setId(node.get(ID).asString());
- return transaction;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, ASSOCIATED_SESSION, ModelType.STRING, true);
- addAttribute(node, CREATED_TIME, ModelType.LONG, true);
- addAttribute(node, SCOPE, ModelType.LONG, true);
- addAttribute(node, ID, ModelType.STRING, true);
- return node;
- }
- }
-
- public static class WorkerPoolStatisticsMetadataMapper {
- private static final String MAX_THREADS = "max-threads"; //$NON-NLS-1$
- private static final String HIGHEST_QUEUED = "highest-queued"; //$NON-NLS-1$
- private static final String QUEUED = "queued"; //$NON-NLS-1$
- private static final String QUEUE_NAME = "queue-name"; //$NON-NLS-1$
- private static final String TOTAL_SUBMITTED = "total-submitted"; //$NON-NLS-1$
- private static final String TOTAL_COMPLETED = "total-completed"; //$NON-NLS-1$
- private static final String HIGHEST_ACTIVE_THREADS = "highest-active-threads"; //$NON-NLS-1$
- private static final String ACTIVE_THREADS = "active-threads"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(WorkerPoolStatisticsMetadata stats, ModelNode node) {
- if (stats == null)
- return null;
- node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- node.get(ACTIVE_THREADS).set(stats.getActiveThreads());
- node.get(HIGHEST_ACTIVE_THREADS).set(stats.getHighestActiveThreads());
- node.get(TOTAL_COMPLETED).set(stats.getTotalCompleted());
- node.get(TOTAL_SUBMITTED).set(stats.getTotalSubmitted());
- node.get(QUEUE_NAME).set(stats.getQueueName());
- node.get(QUEUED).set(stats.getQueued());
- node.get(HIGHEST_QUEUED).set(stats.getHighestQueued());
- node.get(MAX_THREADS).set(stats.getMaxThreads());
-
- return node;
- }
-
- public static WorkerPoolStatisticsMetadata unwrapMetaValue(ModelNode node) {
- if (node == null)
- return null;
-
- WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
- stats.setActiveThreads(node.get(ACTIVE_THREADS).asInt());
- stats.setHighestActiveThreads(node.get(HIGHEST_ACTIVE_THREADS).asInt());
- stats.setTotalCompleted(node.get(TOTAL_COMPLETED).asLong());
- stats.setTotalSubmitted(node.get(TOTAL_SUBMITTED).asLong());
- stats.setQueueName(node.get(QUEUE_NAME).asString());
- stats.setQueued(node.get(QUEUED).asInt());
- stats.setHighestQueued(node.get(HIGHEST_QUEUED).asInt());
- stats.setMaxThreads(node.get(MAX_THREADS).asInt());
- return stats;
- }
-
- public static ModelNode describe(ModelNode node) {
- node.get(TYPE).set(ModelType.OBJECT);
- addAttribute(node, ACTIVE_THREADS, ModelType.INT, true);
- addAttribute(node, HIGHEST_ACTIVE_THREADS, ModelType.INT, true);
- addAttribute(node, TOTAL_COMPLETED, ModelType.LONG, true);
- addAttribute(node, TOTAL_SUBMITTED, ModelType.LONG, true);
- addAttribute(node, QUEUE_NAME, ModelType.STRING, true);
- addAttribute(node, QUEUED, ModelType.INT, true);
- addAttribute(node, HIGHEST_QUEUED, ModelType.INT, true);
- addAttribute(node, MAX_THREADS, ModelType.INT, true);
- return node;
- }
- }
-
- private static final String CHILDREN = "children"; //$NON-NLS-1$
- private static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
- private static final String DOT_DESC = ".describe"; //$NON-NLS-1$
- private static final String TYPE = "type"; //$NON-NLS-1$
- private static final String MIN_OCCURS = "min-occurs"; //$NON-NLS-1$
- private static final String REQUIRED = "required"; //$NON-NLS-1$
- private static final String ALLOWED = "allowed"; //$NON-NLS-1$
- static ModelNode addAttribute(ModelNode node, String name, ModelType dataType, boolean required) {
- node.get(ATTRIBUTES, name, TYPE).set(dataType);
- node.get(ATTRIBUTES, name, DESCRIPTION).set(AdminPlugin.Util.getString(name+DOT_DESC));
- node.get(ATTRIBUTES, name, REQUIRED).set(required);
- return node;
- }
-}
-
-
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,321 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.xml.bind.annotation.*;
-
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
-
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "JAXBProperties",
- "sources",
- "errors"
-})
-public class ModelMetaData extends AdminObjectImpl implements Model {
-
- private static final int DEFAULT_ERROR_HISTORY = 10;
- private static final String SUPPORTS_MULTI_SOURCE_BINDINGS_KEY = "supports-multi-source-bindings"; //$NON-NLS-1$
- private static final long serialVersionUID = 3714234763056162230L;
-
- @XmlElement(name = "source")
- protected ListOverMap<SourceMappingMetadata> sources = new ListOverMap<SourceMappingMetadata>(new KeyBuilder<SourceMappingMetadata>() {
- private static final long serialVersionUID = 2273673984691112369L;
-
- @Override
- public String getKey(SourceMappingMetadata entry) {
- return entry.getName();
- }
- });
-
- @XmlAttribute(name = "type")
- protected String modelType = Type.PHYSICAL.name();
-
- @XmlElement(name = "description")
- protected String description;
-
- @XmlAttribute(name = "path")
- protected String path;
-
- @XmlAttribute(name = "visible")
- protected Boolean visible = true;
-
- @XmlElement(name = "validation-error")
- protected List<ValidationError> errors;
-
- @XmlAttribute(name = "name", required = true)
- public String getName() {
- return super.getName();
- }
-
- // This is needed by JAXB
- public void setName(String name) {
- super.setName(name);
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- @Override
- public boolean isSource() {
- return getModelType() == Model.Type.PHYSICAL;
- }
-
- @Override
- public boolean isVisible() {
- return this.visible;
- }
-
- @Override
- public Type getModelType() {
- try {
- return Type.valueOf(modelType.toUpperCase());
- } catch(IllegalArgumentException e) {
- return Type.OTHER;
- }
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- @Override
- public boolean isSupportsMultiSourceBindings() {
- String supports = getPropertyValue(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY);
- return Boolean.parseBoolean(supports);
- }
-
- @Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
- public List<PropertyMetadata> getJAXBProperties(){
- return super.getJAXBProperties();
- }
-
- public void setSupportsMultiSourceBindings(boolean supports) {
- addProperty(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY, Boolean.toString(supports));
- }
-
- public void setModelType(Model.Type modelType) {
- this.modelType = modelType.name();
- }
-
- public void setModelType(String modelType) {
- this.modelType = modelType;
- }
-
- public String toString() {
- return getName() + this.sources;
- }
-
- public void setVisible(Boolean value) {
- this.visible = value;
- }
-
- public List<SourceMappingMetadata> getSourceMappings(){
- return new ArrayList<SourceMappingMetadata>(this.sources.getMap().values());
- }
-
- public void setSourceMappings(List<SourceMappingMetadata> sources){
- for (SourceMappingMetadata source: sources) {
- addSourceMapping(source.getName(), source.getTranslatorName(), source.getConnectionJndiName());
- }
- }
-
- @Override
- public List<String> getSourceNames() {
- return new ArrayList<String>(this.sources.getMap().keySet());
- }
-
- @Override
- public String getSourceConnectionJndiName(String sourceName) {
- SourceMappingMetadata s = this.sources.getMap().get(sourceName);
- if (s == null) {
- return null;
- }
- return s.getConnectionJndiName();
- }
-
- @Override
- public String getSourceTranslatorName(String sourceName) {
- SourceMappingMetadata s = this.sources.getMap().get(sourceName);
- if (s == null) {
- return null;
- }
- return s.getTranslatorName();
- }
-
- public void addSourceMapping(String name, String translatorName, String connJndiName) {
- this.sources.getMap().put(name, new SourceMappingMetadata(name, translatorName, connJndiName));
- }
-
- public void addSourceMapping(SourceMappingMetadata source) {
- this.sources.getMap().put(source.getName(), new SourceMappingMetadata(source.getName(), source.getTranslatorName(), source.getConnectionJndiName()));
- }
-
- public List<ValidationError> getErrors(){
- return getValidationErrors(Severity.ERROR);
- }
-
- public void setErrors(List<ValidationError> errors){
- this.errors = errors;
- }
-
- public synchronized List<ValidationError> getValidationErrors(ValidationError.Severity severity){
- if (this.errors == null) {
- return Collections.emptyList();
- }
- List<ValidationError> list = new ArrayList<ValidationError>();
- for (ValidationError ve: this.errors) {
- if (Severity.valueOf(ve.severity) == severity) {
- list.add(ve);
- }
- }
- return list;
- }
-
- public synchronized ValidationError addError(String severity, String message) {
- if (this.errors == null) {
- this.errors = new LinkedList<ValidationError>();
- }
- ValidationError ve = new ValidationError(severity, message);
- this.errors.add(ve);
- if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
- this.errors.remove(0);
- }
- return ve;
- }
-
- public synchronized ValidationError addError(ValidationError ve) {
- if (this.errors == null) {
- this.errors = new LinkedList<ValidationError>();
- }
- this.errors.add(ve);
- if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
- this.errors.remove(0);
- }
- return ve;
- }
-
-
- public synchronized boolean removeError(ValidationError remove) {
- if (this.errors == null) {
- return false;
- }
- return this.errors.remove(remove);
- }
-
- public synchronized void clearErrors() {
- this.errors.clear();
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = {
- "value"
- })
- public static class ValidationError implements Serializable{
- private static final long serialVersionUID = 2044197069467559527L;
-
- public enum Severity {ERROR, WARNING};
-
- @XmlValue
- protected String value;
-
- @XmlAttribute(name = "severity", required = true)
- protected String severity;
-
- @XmlAttribute(name = "path")
- protected String path;
-
- public ValidationError() {};
-
- public ValidationError(String severity, String msg) {
- this.severity = severity;
- this.value = msg;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getSeverity() {
- return severity;
- }
-
- public void setSeverity(String severity) {
- this.severity = severity;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ValidationError other = (ValidationError) obj;
- if (severity == null) {
- if (other.severity != null)
- return false;
- } else if (!severity.equals(other.severity))
- return false;
- if (value == null) {
- if (other.value != null)
- return false;
- } else if (!value.equals(other.value))
- return false;
- return true;
- }
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-
-public class ModelNodeConstants {
- public static final String TYPE = "type";//$NON-NLS-1$
- public static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
- public static final String DESCRIPTION = "description"; //$NON-NLS-1$
-
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/PermissionMap.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/PermissionMap.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2008 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-
-public class PermissionMap extends ListOverMap<PermissionMetaData> {
-
- private static final long serialVersionUID = -1170556665834875267L;
-
- public PermissionMap(KeyBuilder<PermissionMetaData> builder) {
- super(builder);
- }
-
- @Override
- public void add(int index, PermissionMetaData element) {
- PermissionMetaData previous = this.map.get(builder.getKey(element));
- if (previous != null) {
- if (element.allowCreate != null) {
- previous.setAllowCreate(element.allowCreate);
- }
- if (element.allowRead != null) {
- previous.setAllowRead(element.allowRead);
- }
- if (element.allowUpdate != null) {
- previous.setAllowUpdate(element.allowUpdate);
- }
- if (element.allowDelete != null) {
- previous.setAllowDelete(element.allowDelete);
- }
- }
- else {
- super.add(index, element);
- }
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,214 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.teiid.adminapi.PropertyDefinition;
-
-
-
-public class PropertyDefinitionMetadata extends AdminObjectImpl implements PropertyDefinition {
- private static final long serialVersionUID = 6612838530524627205L;
- private Collection allowedValues = new ArrayList();
- private Object defaultValue = null;
- private String description = null;
- private String displayName = null;
- private String propertyTypeClassName = String.class.getName();
- private RestartType requiresRestart = RestartType.NONE;
- private boolean advanced = false;
- private boolean masked = false;
- private boolean modifiable = true;
- private boolean required = false;
-
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append("Display Name:").append(getDisplayName()); //$NON-NLS-1$
- result.append(" Description:").append(getDescription()); //$NON-NLS-1$
- result.append(" Property Type Classname:").append(getPropertyTypeClassName()); //$NON-NLS-1$
- result.append(" Default Value:").append(getDefaultValue()); //$NON-NLS-1$
- result.append(" Constrained To Allow Values:").append(isConstrainedToAllowedValues()); //$NON-NLS-1$
- result.append(" Allowed Values:").append(getAllowedValues()); //$NON-NLS-1$
- result.append(" Required:").append(isRequired()); //$NON-NLS-1$
- result.append(" Expert:").append(isAdvanced()); //$NON-NLS-1$
- result.append(" Masked:").append(isMasked()); //$NON-NLS-1$
- result.append(" Modifiable:").append(isModifiable()); //$NON-NLS-1$
- result.append(" RequiresRestart:").append(getRequiresRestart()); //$NON-NLS-1$
- return result.toString();
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getAllowedValues()
- */
- public Collection getAllowedValues() {
- return allowedValues;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getDefaultValue()
- */
- public Object getDefaultValue() {
- return defaultValue;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getDescription()
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getDisplayName()
- */
- public String getDisplayName() {
- return displayName;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getPropertyTypeClassName()
- */
- public String getPropertyTypeClassName() {
- return propertyTypeClassName;
- }
-
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#getRequiresRestart()
- */
- public RestartType getRequiresRestart() {
- return requiresRestart;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#isExpert()
- * @since 4.3
- */
- public boolean isAdvanced() {
- return advanced;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#isMasked()
- */
- public boolean isMasked() {
- return masked;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#isModifiable()
- */
- public boolean isModifiable() {
- return modifiable;
- }
-
- /**
- * @see org.teiid.adminapi.PropertyDefinition#isRequired()
- */
- public boolean isRequired() {
- return required;
- }
-
- /**
- * @param allowedValues The allowedValues to set.
- */
- public void setAllowedValues(Collection allowedValues) {
- this.allowedValues = allowedValues;
- }
-
- /**
- * @param defaultValue The defaultValue to set.
- */
- public void setDefaultValue(Serializable defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- /**
- * @param description The description to set.
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
-
- /**
- * @param displayName The displayName to set.
- */
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
-
- /**
- * @param expert The value of expert to set.
- */
- public void setAdvanced(boolean expert) {
- this.advanced = expert;
- }
-
- /**
- * @param masked The value of masked to set.
- */
- public void setMasked(boolean masked) {
- this.masked = masked;
- }
- /**
- * @param modifiable The value of modifiable to set.
- */
- public void setModifiable(boolean modifiable) {
- this.modifiable = modifiable;
- }
-
- /**
- * @param propertyTypeClassName The propertyTypeName to set.
- */
- public void setPropertyTypeClassName(String propertyTypeClassName) {
- this.propertyTypeClassName = propertyTypeClassName;
- }
-
-
- /**
- * @param required The value of required to set.
- */
- public void setRequired(boolean required) {
- this.required = required;
- }
-
- /**
- * @param requiresRestart The value of requiresRestart to set.
- */
- public void setRequiresRestart(RestartType requiresRestart) {
- this.requiresRestart = requiresRestart;
- }
-
- @Override
- public boolean isConstrainedToAllowedValues() {
- return allowedValues != null && !allowedValues.isEmpty();
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- * <pre>
- * <complexType name="property">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "property")
-public class PropertyMetadata implements Serializable{
- private static final long serialVersionUID = -5040224539939758816L;
-
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlAttribute(name = "value", required = true)
- protected String value;
-
- public PropertyMetadata() {
- }
-
- public PropertyMetadata(String key, String value) {
- this.name = key;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String toString() {
- return this.name+"="+this.value; //$NON-NLS-1$
- }
-}
\ No newline at end of file
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,160 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.util.Date;
-
-import org.teiid.adminapi.Request;
-import org.teiid.core.util.HashCodeUtil;
-
-
-
-public class RequestMetadata extends AdminObjectImpl implements Request {
-
- private static final long serialVersionUID = -2779106368517784259L;
-
- private long executionId;
- private String sessionId;
- private String command;
- private long startTime;
- private boolean sourceRequest;
- private Integer nodeID;
- private String transactionId;
- private ProcessingState processingState = ProcessingState.PROCESSING;
- private ThreadState threadState = ThreadState.RUNNING;
-
- @Override
- public long getExecutionId() {
- return executionId;
- }
-
- public void setExecutionId(long id) {
- this.executionId = id;
- }
-
- @Override
- public ProcessingState getState() {
- return processingState;
- }
-
- public void setState(ProcessingState state) {
- this.processingState = state;
- }
-
- @Override
- public ThreadState getThreadState() {
- return threadState;
- }
-
- public void setThreadState(ThreadState threadState) {
- this.threadState = threadState;
- }
-
- @Override
- public String getSessionId() {
- return this.sessionId;
- }
-
- public void setSessionId(String session) {
- this.sessionId = session;
- }
-
- @Override
- public long getStartTime() {
- return this.startTime;
- }
-
- public void setStartTime(long time) {
- this.startTime = time;
- }
-
- @Override
- public String getCommand() {
- return this.command;
- }
-
- public void setCommand(String cmd) {
- this.command = cmd;
- }
-
- @Override
- public boolean sourceRequest() {
- return sourceRequest;
- }
-
- public void setSourceRequest(boolean sourceRequest) {
- this.sourceRequest = sourceRequest;
- }
-
- @Override
- public Integer getNodeId() {
- return this.nodeID;
- }
-
- public void setNodeId(Integer nodeID) {
- this.nodeID = nodeID;
- }
-
- @Override
- public String getTransactionId() {
- return this.transactionId;
- }
-
- public void setTransactionId(String id) {
- this.transactionId = id;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof RequestMetadata)) {
- return false;
- }
- RequestMetadata value = (RequestMetadata)obj;
- if (!sourceRequest()) {
- return sessionId == value.sessionId && executionId == value.executionId;
- }
- return sessionId == value.sessionId && executionId == value.executionId && nodeID.equals(value.nodeID);
- }
-
- public int hashCode() {
- return HashCodeUtil.hashCode((int)executionId, sessionId);
- }
-
- @SuppressWarnings("nls")
- public String toString() {
- StringBuilder str = new StringBuilder();
- str.append("Request: sessionid=").append(sessionId);
- str.append("; executionId=").append(executionId);
- if (nodeID != null) {
- str.append("; nodeId=").append(nodeID);
- }
- if (transactionId != null) {
- str.append("; transactionId=").append(transactionId);
- }
- str.append("; sourceRequest=").append(sourceRequest);
- str.append("; processingTime=").append(new Date(startTime));
- str.append("; command=").append(command);
-
- return str.toString();
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,217 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.Date;
-
-import javax.security.auth.Subject;
-
-import org.teiid.adminapi.Session;
-import org.teiid.client.security.SessionToken;
-
-
-
-/**
- * Add and delete properties also in the Mapper class for correct wrapping for profile service.
- *
- */
-/* TODO: it would probably be good to let ipAddress denote the connecting address
- and add clientIpAdress as the client reported value */
-public class SessionMetadata extends AdminObjectImpl implements Session {
-
- private static final long serialVersionUID = 918638989081830034L;
- private String applicationName;
- private long lastPingTime = System.currentTimeMillis();
- private long createdTime;
- private String ipAddress;
- private String clientHostName;
- private String clientHardwareAddress;
- private String userName;
- private String vdbName;
- private int vdbVersion;
- private String sessionId;
- private String securityDomain;
-
- //server session state
- private transient VDBMetaData vdb;
- private transient SessionToken sessionToken;
- private transient Subject subject;
- private transient Object securityContext;
- private transient boolean embedded;
-
- @Override
- public String getApplicationName() {
- return this.applicationName;
- }
-
- public void setApplicationName(String applicationName) {
- this.applicationName = applicationName;
- }
-
- @Override
- public long getCreatedTime() {
- return this.createdTime;
- }
-
- public void setCreatedTime(long createdTime) {
- this.createdTime = createdTime;
- }
-
- @Override
- public String getClientHostName() {
- return this.clientHostName;
- }
-
- public void setClientHostName(String clientHostname) {
- this.clientHostName = clientHostname;
- }
-
- @Override
- public String getIPAddress() {
- return this.ipAddress;
- }
-
- public void setIPAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- @Override
- public long getLastPingTime() {
- return this.lastPingTime;
- }
-
- public void setLastPingTime(long lastPingTime) {
- this.lastPingTime = lastPingTime;
- }
-
- @Override
- public String getSessionId() {
- return this.sessionId;
- }
-
- public void setSessionId(String sessionId) {
- this.sessionId = sessionId;
- }
-
- @Override
- public String getUserName() {
- return this.userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- @Override
- public String getVDBName() {
- return this.vdbName;
- }
-
- public void setVDBName(String vdbName) {
- this.vdbName = vdbName;
- }
-
- @Override
- public int getVDBVersion() {
- return this.vdbVersion;
- }
-
- public void setVDBVersion(int vdbVersion) {
- this.vdbVersion = vdbVersion;
- }
-
- @Override
- public String getSecurityDomain() {
- return this.securityDomain;
- }
-
- public void setSecurityDomain(String domain) {
- this.securityDomain = domain;
- }
-
- @SuppressWarnings("nls")
- public String toString() {
- StringBuilder str = new StringBuilder();
- str.append("session: sessionid=").append(sessionId);
- str.append("; userName=").append(userName);
- str.append("; vdbName=").append(vdbName);
- str.append("; vdbVersion=").append(vdbVersion);
- str.append("; createdTime=").append(new Date(createdTime));
- str.append("; applicationName=").append(applicationName);
- str.append("; clientHostName=").append(clientHostName);
- str.append("; clientHardwareAddress=").append(clientHardwareAddress);
- str.append("; IPAddress=").append(ipAddress);
- str.append("; securityDomain=").append(securityDomain);
- str.append("; lastPingTime=").append(new Date(lastPingTime));
- return str.toString();
- }
-
- public VDBMetaData getVdb() {
- return vdb;
- }
-
- public void setVdb(VDBMetaData vdb) {
- this.vdb = vdb;
- }
-
- public SessionToken getSessionToken() {
- return sessionToken;
- }
-
- public void setSessionToken(SessionToken sessionToken) {
- this.sessionToken = sessionToken;
- }
-
- public void setSubject(Subject subject) {
- this.subject = subject;
- }
-
- public Object getSecurityContext() {
- return securityContext;
- }
-
- public void setSecurityContext(Object securityContext) {
- this.securityContext = securityContext;
- }
-
- public Subject getSubject() {
- return this.subject;
- }
-
- public void setEmbedded(boolean embedded) {
- this.embedded = embedded;
- }
-
- public boolean isEmbedded() {
- return embedded;
- }
-
- @Override
- public String getClientHardwareAddress() {
- return this.clientHardwareAddress;
- }
-
- public void setClientHardwareAddress(String clientHardwareAddress) {
- this.clientHardwareAddress = clientHardwareAddress;
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2008 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.Serializable;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "")
-public class SourceMappingMetadata implements Serializable {
- private static final long serialVersionUID = -4417878417697685794L;
-
- @XmlAttribute(name = "name", required = true)
- private String name;
-
- @XmlAttribute(name = "connection-jndi-name")
- private String jndiName;
-
- @XmlAttribute(name = "translator-name",required = true)
- private String translatorName;
-
- public SourceMappingMetadata() {}
-
- public SourceMappingMetadata(String name, String translatorName, String connJndiName) {
- this.name = name;
- this.translatorName = translatorName;
- this.jndiName = connJndiName;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getConnectionJndiName() {
- // this default could be controlled if needed.
- if (this.jndiName == null) {
- return "java:"+name; //$NON-NLS-1$
- }
- return jndiName;
- }
-
- public void setConnectionJndiName(String jndiName) {
- this.jndiName = jndiName;
- }
-
- public String getTranslatorName() {
- return translatorName;
- }
-
- public void setTranslatorName(String translatorName) {
- this.translatorName = translatorName;
- }
-
- public String toString() {
- return getName()+"/"+getTranslatorName()+"/"+getConnectionJndiName(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
\ No newline at end of file
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import java.util.Date;
-
-import org.teiid.adminapi.Transaction;
-
-
-public class TransactionMetadata extends AdminObjectImpl implements Transaction {
-
- private static final long serialVersionUID = -8588785315218789068L;
- private String associatedSession;
- private String scope;
- private String id;
- private long createdTime;
-
- @Override
- public String getAssociatedSession() {
- return associatedSession;
- }
-
- public void setAssociatedSession(String associatedSession) {
- this.associatedSession = associatedSession;
- }
-
- @Override
- public String getScope() {
- return scope;
- }
-
- public void setScope(String scope) {
- this.scope = scope;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public long getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(long time) {
- this.createdTime = time;
- }
-
- @Override
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append("Associated Session:").append(associatedSession); //$NON-NLS-1$
- result.append("Scope:").append(scope); //$NON-NLS-1$
- result.append("Id:").append(id); //$NON-NLS-1$
- result.append("CreatedTime:").append(new Date(createdTime)); //$NON-NLS-1$
- return result.toString();
- }
-
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,343 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.net.URL;
-import java.util.*;
-
-import javax.xml.bind.annotation.*;
-
-import org.teiid.adminapi.DataPolicy;
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-import org.teiid.core.util.StringUtil;
-
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "JAXBProperties",
- "models",
- "translators",
- "dataPolicies"
-})
-@XmlRootElement(name = "vdb")
-public class VDBMetaData extends AdminObjectImpl implements VDB {
-
- private static final String VERSION_DELIM = "."; //$NON-NLS-1$
-
- private static final long serialVersionUID = -4723595252013356436L;
-
- /**
- * This simulating a list over a map. JAXB requires a list and performance recommends
- * map and we would like to keep one variable to represent both.
- */
- @XmlElement(name = "model", required = true, type = ModelMetaData.class)
- protected ListOverMap<ModelMetaData> models = new ListOverMap<ModelMetaData>(new KeyBuilder<ModelMetaData>() {
- private static final long serialVersionUID = 846247100420118961L;
-
- @Override
- public String getKey(ModelMetaData entry) {
- return entry.getName();
- }
- });
-
- @XmlElement(name = "translator", required = true, type = VDBTranslatorMetaData.class)
- protected ListOverMap<VDBTranslatorMetaData> translators = new ListOverMap<VDBTranslatorMetaData>(new KeyBuilder<VDBTranslatorMetaData>() {
- private static final long serialVersionUID = 3890502172003653563L;
-
- @Override
- public String getKey(VDBTranslatorMetaData entry) {
- return entry.getName();
- }
- });
-
- @XmlElement(name = "data-role", required = true, type = DataPolicyMetadata.class)
- protected ListOverMap<DataPolicyMetadata> dataPolicies = new ListOverMap<DataPolicyMetadata>(new KeyBuilder<DataPolicyMetadata>() {
- private static final long serialVersionUID = 4954591545242715254L;
-
- @Override
- public String getKey(DataPolicyMetadata entry) {
- return entry.getName();
- }
- });
-
- @XmlAttribute(name = "version", required = true)
- private int version = 1;
-
- @XmlElement(name = "description")
- protected String description;
-
- private String fileUrl = null;
- private boolean dynamic = false;
- private VDB.Status status = VDB.Status.INACTIVE;
- private ConnectionType connectionType = VDB.ConnectionType.BY_VERSION;
- private boolean removed;
-
- @XmlAttribute(name = "name", required = true)
- public String getName() {
- return super.getName();
- }
-
- public String getFullName() {
- return getName() + VERSION_DELIM + getVersion();
- }
-
- // This needed by JAXB marshaling
- public void setName(String name) {
- super.setName(name);
- }
-
- public boolean isRemoved() {
- return removed;
- }
-
- public void setRemoved(boolean removed) {
- this.removed = removed;
- }
-
- @Override
- public ConnectionType getConnectionType() {
- return this.connectionType;
- }
-
- public void setConnectionType(ConnectionType allowConnections) {
- this.connectionType = allowConnections;
- }
-
- public void setConnectionType(String allowConnections) {
- this.connectionType = ConnectionType.valueOf(allowConnections);
- }
-
- @Override
- public Status getStatus() {
- return this.status;
- }
-
- public void setStatus(Status s) {
- this.status = s;
- }
-
- public void setStatus(String s) {
- this.status = Status.valueOf(s);
- }
-
-
- @Override
- public int getVersion() {
- return this.version;
- }
-
- public void setVersion(int version) {
- this.version = version;
- }
-
- @Override
- public String getUrl() {
- return this.fileUrl;
- }
-
- public void setUrl(String url) {
- this.fileUrl = url;
- }
-
- public void setUrl(URL url) {
- this.setUrl(url.toExternalForm());
- String path = url.getPath();
- if (path.endsWith("/")) { //$NON-NLS-1$
- path = path.substring(0, path.length() - 1);
- }
- String fileName = StringUtil.getLastToken(path, "/"); //$NON-NLS-1$
- String[] parts = fileName.split("\\."); //$NON-NLS-1$
- if (parts[0].equalsIgnoreCase(getName()) && parts.length >= 3) {
- try {
- int fileVersion = Integer.parseInt(parts[parts.length - 2]);
- this.setVersion(fileVersion);
- } catch (NumberFormatException e) {
-
- }
- }
- }
-
- @Override
- public List<Model> getModels(){
- return new ArrayList<Model>(this.models.getMap().values());
- }
-
- public Map<String, ModelMetaData> getModelMetaDatas() {
- return this.models.getMap();
- }
-
- /**
- * This method required to make the JNDI assignment on the model work; if not persistent Management framework
- * treating "models" as ReadOnly property. The actual assignment is done in the VDBMetaDataClassInstancefactory
- * @param models
- */
- public void setModels(List<Model> models) {
- for (Model obj : models) {
- ModelMetaData model = (ModelMetaData) obj;
- addModel(model);
- }
- }
-
- public void addModel(ModelMetaData m) {
- this.models.getMap().put(m.getName(), m);
- }
-
- @Override
- public List<Translator> getOverrideTranslators() {
- return new ArrayList<Translator>(this.translators.getMap().values());
- }
-
- public void setOverrideTranslators(List<Translator> translators) {
- for (Translator t: translators) {
- this.translators.getMap().put(t.getName(), (VDBTranslatorMetaData)t);
- }
- }
-
- public void addOverideTranslator(VDBTranslatorMetaData t) {
- this.translators.getMap().put(t.getName(), t);
- }
-
- @Override
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String desc) {
- this.description = desc;
- }
-
- @Override
- public List<String> getValidityErrors(){
- List<String> allErrors = new ArrayList<String>();
- for (ModelMetaData model:this.models.getMap().values()) {
- List<ValidationError> errors = model.getErrors();
- if (errors != null && !errors.isEmpty()) {
- for (ValidationError m:errors) {
- if (ValidationError.Severity.valueOf(m.getSeverity()).equals(ValidationError.Severity.ERROR)) {
- allErrors.add(m.getValue());
- }
- }
- }
- }
- return allErrors;
- }
-
- @Override
- public boolean isValid() {
- if (!getValidityErrors().isEmpty()) {
- return false;
- }
-
- if (getModels().isEmpty()) {
- return false;
- }
- for(ModelMetaData m: this.models.getMap().values()) {
- if (m.isSource()) {
- List<String> resourceNames = m.getSourceNames();
- if (resourceNames.isEmpty()) {
- return false;
- }
- for (String sourceName:resourceNames) {
- if (m.getSourceConnectionJndiName(sourceName) == null) {
- return false;
- }
- }
- }
- }
- return true;
- }
-
- public String toString() {
- return getName()+VERSION_DELIM+getVersion()+ models.getMap().values();
- }
-
- public boolean isVisible(String modelName) {
- ModelMetaData model = getModel(modelName);
- return model == null || model.isVisible();
- }
-
- public ModelMetaData getModel(String modelName) {
- return this.models.getMap().get(modelName);
- }
-
- public Set<String> getMultiSourceModelNames(){
- Set<String> list = new HashSet<String>();
- for(ModelMetaData m: models.getMap().values()) {
- if (m.isSupportsMultiSourceBindings()) {
- list.add(m.getName());
- }
- }
- return list;
- }
-
- // This one manages the JAXB binding
- @Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
- public List<PropertyMetadata> getJAXBProperties(){
- return super.getJAXBProperties();
- }
-
- public boolean isDynamic() {
- return dynamic;
- }
-
- public void setDynamic(boolean dynamic) {
- this.dynamic = dynamic;
- }
-
- @Override
- public List<DataPolicy> getDataPolicies(){
- return new ArrayList<DataPolicy>(this.dataPolicies.getMap().values());
- }
-
- /**
- * This method is required by the Management framework to write the mappings to the persistent form. The actual assignment is done
- * in the VDBMetaDataClassInstancefactory
- * @param policies
- */
- public void setDataPolicies(List<DataPolicy> policies){
- this.dataPolicies.getMap().clear();
- for (DataPolicy policy:policies) {
- this.dataPolicies.getMap().put(policy.getName(), (DataPolicyMetadata)policy);
- }
- }
-
- public void addDataPolicy(DataPolicyMetadata policy){
- this.dataPolicies.getMap().put(policy.getName(), policy);
- }
-
- public DataPolicyMetadata getDataPolicy(String policyName) {
- return this.dataPolicies.getMap().get(policyName);
- }
-
- public VDBTranslatorMetaData getTranslator(String name) {
- return this.translators.getMap().get(name);
- }
-
- public boolean isPreview() {
- return Boolean.valueOf(getPropertyValue("preview")); //$NON-NLS-1$
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,310 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-import org.teiid.adminapi.impl.VDBMetaData;
-
-@SuppressWarnings("nls")
-public class VDBMetadataParser {
-
- public static VDBMetaData unmarshell(InputStream content) throws XMLStreamException {
- XMLInputFactory inputFactory=XMLInputFactory.newInstance();
- XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
-
- // elements
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case VDB:
- VDBMetaData vdb = new VDBMetaData();
- Properties props = getAttributes(reader);
- vdb.setName(props.getProperty(Element.NAME.getLocalName()));
- vdb.setVersion(Integer.parseInt(props.getProperty(Element.VERSION.getLocalName())));
- parseVDB(reader, vdb);
- return vdb;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- return null;
- }
-
- private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException {
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case DESCRIPTION:
- vdb.setDescription(reader.getElementText());
- break;
- case PROPERTY:
- parseProperty(reader, vdb);
- break;
- case MODEL:
- ModelMetaData model = new ModelMetaData();
- parseModel(reader, model);
- vdb.addModel(model);
- break;
- case TRANSLATOR:
- VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
- parseTranslator(reader, translator);
- vdb.addOverideTranslator(translator);
- break;
- case DATA_ROLE:
- DataPolicyMetadata policy = new DataPolicyMetadata();
- parseDataRole(reader, policy);
- vdb.addDataPolicy(policy);
- break;
- case ENTRY:
- // this is designer specific.
- break;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
- private static void parseProperty(XMLStreamReader reader, AdminObjectImpl anObj)
- throws XMLStreamException {
- if (reader.getAttributeCount() > 0) {
- String key = null;
- String value = null;
- for(int i=0; i<reader.getAttributeCount(); i++) {
- String attrName = reader.getAttributeLocalName(i);
- String attrValue = reader.getAttributeValue(i);
- if (attrName.equals(Element.NAME.getLocalName())) {
- key = attrValue;
- }
- if (attrName.equals(Element.VALUE.getLocalName())) {
- value = attrValue;
- }
- }
- anObj.addProperty(key, value);
- }
- while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
- }
-
- private static void parseDataRole(XMLStreamReader reader, DataPolicyMetadata policy) throws XMLStreamException {
- Properties props = getAttributes(reader);
- policy.setName(props.getProperty(Element.NAME.getLocalName()));
- policy.setAnyAuthenticated(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ANY_ATHENTICATED_ATTR.getLocalName())));
- policy.setAllowCreateTemporaryTables(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ALLOW_TEMP_TABLES_ATTR.getLocalName())));
-
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case DESCRIPTION:
- policy.setDescription(reader.getElementText());
- break;
- case PERMISSION:
- PermissionMetaData permission = new PermissionMetaData();
- parsePermission(reader, permission);
- policy.addPermission(permission);
- break;
- case MAPPED_ROLE_NAME:
- policy.addMappedRoleName(reader.getElementText());
- break;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
- private static void parsePermission(XMLStreamReader reader, PermissionMetaData permission) throws XMLStreamException {
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case RESOURCE_NAME:
- permission.setResourceName(reader.getElementText());
- break;
- case ALLOW_ALTER:
- permission.setAllowAlter(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_CREATE:
- permission.setAllowCreate(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_DELETE:
- permission.setAllowDelete(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_EXECUTE:
- permission.setAllowExecute(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_READ:
- permission.setAllowRead(Boolean.parseBoolean(reader.getElementText()));
- break;
- case ALLOW_UPADTE:
- permission.setAllowUpdate(Boolean.parseBoolean(reader.getElementText()));
- break;
-
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
- private static void parseTranslator(XMLStreamReader reader, VDBTranslatorMetaData translator) throws XMLStreamException {
- Properties props = getAttributes(reader);
- translator.setName(props.getProperty(Element.NAME.getLocalName()));
- translator.setType(props.getProperty(Element.TYPE.getLocalName()));
- translator.setDescription(props.getProperty(Element.DESCRIPTION.getLocalName()));
-
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case PROPERTY:
- parseProperty(reader, translator);
- break;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
- private static void parseModel(XMLStreamReader reader, ModelMetaData model) throws XMLStreamException {
- Properties props = getAttributes(reader);
- model.setName(props.getProperty(Element.NAME.getLocalName()));
- model.setModelType(Model.Type.valueOf(props.getProperty(Element.TYPE.getLocalName(), "PHYSICAL")));
- model.setVisible(Boolean.parseBoolean(props.getProperty(Element.VISIBLE.getLocalName(), "true")));
- model.setPath(props.getProperty(Element.PATH.getLocalName()));
-
- while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
- Element element = Element.forName(reader.getLocalName());
- switch (element) {
- case DESCRIPTION:
- model.setDescription(reader.getElementText());
- break;
- case PROPERTY:
- parseProperty(reader, model);
- break;
- case SOURCE:
- Properties sourceProps = getAttributes(reader);
- String name = sourceProps.getProperty(Element.NAME.getLocalName());
- String translatorName = sourceProps.getProperty(Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName());
- String connectionName = sourceProps.getProperty(Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName());
- model.addSourceMapping(name, translatorName, connectionName);
- while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
- break;
- case VALIDATION_ERROR:
- Properties validationProps = getAttributes(reader);
- String msg = reader.getElementText();
- String severity = validationProps.getProperty(Element.VALIDATION_SEVERITY_ATTR.getLocalName());
- String path = validationProps.getProperty(Element.PATH.getLocalName());
- ValidationError ve = new ValidationError(severity, msg);
- ve.setPath(path);
- model.addError(ve);
- break;
- default:
- throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
- }
- }
- }
-
-
- private static Properties getAttributes(XMLStreamReader reader) {
- Properties props = new Properties();
- if (reader.getAttributeCount() > 0) {
- for(int i=0; i<reader.getAttributeCount(); i++) {
- String attrName = reader.getAttributeLocalName(i);
- String attrValue = reader.getAttributeValue(i);
- props.setProperty(attrName, attrValue);
- }
- }
- return props;
- }
-
- enum Element {
- // must be first
- UNKNOWN(null),
- VDB("vdb"),
- NAME("name"),
- VERSION("version"),
- DESCRIPTION("description"),
- PROPERTY("property"),
- VALUE("value"),
- MODEL("model"),
- TYPE("type"),
- VISIBLE("visible"),
- PATH("path"),
- SOURCE("source"),
- SOURCE_TRANSLATOR_NAME_ATTR("translator-name"),
- SOURCE_CONNECTION_JNDI_NAME_ATTR("connection-jndi-name"),
- VALIDATION_ERROR("validation-error"),
- VALIDATION_SEVERITY_ATTR("severity"),
- TRANSLATOR("translator"),
- DATA_ROLE("data-role"),
- DATA_ROLE_ANY_ATHENTICATED_ATTR("any-authenticated"),
- DATA_ROLE_ALLOW_TEMP_TABLES_ATTR("allow-create-temporary-tables"),
- PERMISSION("permission"),
- RESOURCE_NAME("resource-name"),
- ALLOW_CREATE("allow-create"),
- ALLOW_READ("allow-read"),
- ALLOW_UPADTE("allow-update"),
- ALLOW_DELETE("allow-delete"),
- ALLOW_EXECUTE("allow-execute"),
- ALLOW_ALTER("allow-alyer"),
- MAPPED_ROLE_NAME("mapped-role-name"),
- ENTRY("entry");
-
- private final String name;
-
- Element(final String name) {
- this.name = name;
- }
-
- /**
- * Get the local name of this element.
- *
- * @return the local name
- */
- public String getLocalName() {
- return name;
- }
-
- private static final Map<String, Element> elements;
-
- static {
- final Map<String, Element> map = new HashMap<String, Element>();
- for (Element element : values()) {
- final String name = element.getLocalName();
- if (name != null) map.put(name, element);
- }
- elements = map;
- }
-
- public static Element forName(String localName) {
- final Element element = elements.get(localName);
- return element == null ? UNKNOWN : element;
- }
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
-import org.teiid.adminapi.Translator;
-
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-public class VDBTranslatorMetaData extends AdminObjectImpl implements Translator {
- private static final long serialVersionUID = -3454161477587996138L;
- private String type;
- private Class<?> executionClass;
- private String description;
- private String moduleName;
-
- @Override
- public String getName() {
- return super.getName();
- }
-
- @XmlAttribute(name = "name", required = true)
- public void setName(String name) {
- super.setName(name);
- }
-
- @Override
- public String getType() {
- return type;
- }
-
- @XmlAttribute(name = "type",required = true)
- public void setType(String type) {
- this.type = type;
- }
-
- @Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
- public List<PropertyMetadata> getJAXBProperties(){
- return super.getJAXBProperties();
- }
-
- public String toString() {
- return getName();
- }
-
- public Class<?> getExecutionFactoryClass() {
- return this.executionClass;
- }
-
- public void setExecutionFactoryClass(Class<?> clazz) {
- this.executionClass = clazz;
- addProperty(EXECUTION_FACTORY_CLASS, clazz.getName());
- }
-
- public String getDescription() {
- return this.description;
- }
-
- @XmlAttribute(name = "description")
- public void setDescription(String desc) {
- this.description = desc;
- }
-
- public String getModuleName() {
- return this.moduleName;
- }
-
- public void setModuleName(String name) {
- this.moduleName = name;
- }
-}
Deleted: branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,131 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import org.teiid.adminapi.WorkerPoolStatistics;
-
-/**
- * This class is a holder for all the statistics gathered about a worker pool.
- */
-public class WorkerPoolStatisticsMetadata extends AdminObjectImpl implements WorkerPoolStatistics {
-
- private static final long serialVersionUID = -4917902925523802295L;
-
- // Current state
- private int queued;
- private int highestQueued;
- private int maxThreads;
- private int activeThreads;
- private int highestActiveThreads;
- private long totalSubmitted;
- private long totalCompleted;
-
- @Override
- public int getActiveThreads() {
- return activeThreads;
- }
-
- @Override
- public int getHighestActiveThreads() {
- return highestActiveThreads;
- }
-
- @Override
- public long getTotalCompleted() {
- return totalCompleted;
- }
-
- @Override
- public long getTotalSubmitted() {
- return totalSubmitted;
- }
-
- @Override
- public String getQueueName() {
- return getName();
- }
-
- @Override
- public int getQueued() {
- return queued;
- }
-
- @Override
- public int getHighestQueued() {
- return highestQueued;
- }
-
- @Override
- public int getMaxThreads() {
- return maxThreads;
- }
-
- public void setQueued(int queued) {
- this.queued = queued;
- }
-
- public void setHighestQueued(int highestQueued) {
- this.highestQueued = highestQueued;
- }
-
- public void setMaxThreads(int maxThreads) {
- this.maxThreads = maxThreads;
- }
-
- public void setActiveThreads(int activeThreads) {
- this.activeThreads = activeThreads;
- }
-
- public void setHighestActiveThreads(int highestActiveThreads) {
- this.highestActiveThreads = highestActiveThreads;
- }
-
- public void setTotalSubmitted(long totalSubmitted) {
- this.totalSubmitted = totalSubmitted;
- }
-
- public void setTotalCompleted(long totalCompleted) {
- this.totalCompleted = totalCompleted;
- }
-
- public void setQueueName(String name) {
- setName(name);
- }
-
- public String toString() {
- StringBuilder str = new StringBuilder();
-
- str.append("WorkerPoolStats:"); //$NON-NLS-1$
- str.append(" queue-name = " + getName()); //$NON-NLS-1$
- str.append("; queued = " + queued); //$NON-NLS-1$
- str.append("; highestQueued = " + highestQueued); //$NON-NLS-1$
- str.append("; maxThreads = " + maxThreads); //$NON-NLS-1$
- str.append("; activeThreads = " + activeThreads); //$NON-NLS-1$
- str.append("; highestActiveThreads = " + highestActiveThreads); //$NON-NLS-1$
- str.append("; totalSubmitted = " + totalSubmitted); //$NON-NLS-1$
- str.append("; totalCompleted = " + totalCompleted); //$NON-NLS-1$
- return str.toString();
- }
-
-}
-
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import java.util.Arrays;
-
-import org.junit.Test;
-import org.teiid.adminapi.DataPolicy.PermissionType;
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-import static junit.framework.Assert.*;
-
-public class TestDataPolicyMetaData {
-
- @Test
- public void testAllowed() {
- DataPolicyMetadata policy = new DataPolicyMetadata();
- policy.setName("readOnly"); //$NON-NLS-1$
- policy.setDescription("Only has read only permissions"); //$NON-NLS-1$
- policy.setMappedRoleNames(Arrays.asList("jack", "susan")); //$NON-NLS-1$ //$NON-NLS-2$
-
-
- PermissionMetaData perm1 = new PermissionMetaData();
- perm1.setResourceName("catalog.schema.Table1"); //$NON-NLS-1$
- perm1.setAllowRead(true);
-
- PermissionMetaData perm2 = new PermissionMetaData();
- perm2.setResourceName("catalog.schema.Table2"); //$NON-NLS-1$
- perm2.setAllowRead(false);
-
- PermissionMetaData perm3 = new PermissionMetaData();
- perm3.setResourceName("catalog.schema.Table3"); //$NON-NLS-1$
- perm3.setAllowRead(true);
-
- PermissionMetaData perm4 = new PermissionMetaData();
- perm4.setResourceName("catalog.schema.Table4"); //$NON-NLS-1$
- perm4.setAllowRead(true);
-
- PermissionMetaData perm5 = new PermissionMetaData();
- perm5.setResourceName("catalog.schema.Table5.column1"); //$NON-NLS-1$
- perm5.setAllowRead(true);
-
- policy.addPermission(perm1, perm2, perm3, perm4, perm5);
-
-
- assertTrue(policy.allows("catalog.schema.Table1", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table1", PermissionType.CREATE)); //$NON-NLS-1$
-
- assertFalse(policy.allows("catalog.schema", PermissionType.READ)); //$NON-NLS-1$
-
- assertFalse(policy.allows("catalog.schema.Table2.column", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table2", PermissionType.READ)); //$NON-NLS-1$
-
- assertTrue(policy.allows("catalog.schema.Table3.column", PermissionType.READ)); //$NON-NLS-1$
- assertTrue(policy.allows("catalog.schema.Table3", PermissionType.READ)); //$NON-NLS-1$
-
- assertTrue(policy.allows("catalog.schema.Table4.column", PermissionType.READ)); //$NON-NLS-1$
- assertTrue(policy.allows("catalog.schema.Table4", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table4", PermissionType.DELETE)); //$NON-NLS-1$
-
- assertTrue(policy.allows("catalog.schema.Table5.column1", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table5.column2", PermissionType.READ)); //$NON-NLS-1$
- assertFalse(policy.allows("catalog.schema.Table5", PermissionType.READ)); //$NON-NLS-1$
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.teiid.adminapi.Model;
-
-@SuppressWarnings("nls")
-public class TestModelMetaData {
-
- @Test
- public void testModelType() {
-
- ModelMetaData model = new ModelMetaData();
- model.modelType = "physical";
-
- assertTrue(model.getModelType() == Model.Type.PHYSICAL);
- assertTrue(model.isSource());
-
- model.modelType = "VIRTUAL";
- assertTrue(model.getModelType() == Model.Type.VIRTUAL);
-
- model.modelType = "TYPE";
- assertTrue(model.getModelType() == Model.Type.OTHER);
- assertTrue(!model.isSource());
- }
-
- @Test
- public void testSupportMultiSource() {
- ModelMetaData model = new ModelMetaData();
- assertFalse(model.isSupportsMultiSourceBindings());
- model.setSupportsMultiSourceBindings(true);
-
- assertTrue(model.isSupportsMultiSourceBindings());
-
- assertTrue(!model.getProperties().isEmpty());
- }
-
- public void testErrors() {
- ModelMetaData m = new ModelMetaData();
- m.addError("ERROR", "I am Error");
- m.addError("WARNING", "I am warning");
-
- assertFalse(m.getErrors().isEmpty());
- assertEquals(1, m.getErrors().size());
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,134 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import org.jboss.dmr.ModelNode;
-import org.junit.Test;
-import org.teiid.adminapi.Request.ProcessingState;
-import org.teiid.adminapi.Request.ThreadState;
-@SuppressWarnings("nls")
-public class TestRequestMetadata {
-
- @Test public void testMapping() {
- RequestMetadata request = buildRequest();
-
- ModelNode node = MetadataMapper.RequestMetadataMapper.wrap(request, new ModelNode());
-
- RequestMetadata actual = MetadataMapper.RequestMetadataMapper.unwrap(node);
-
- assertEquals(request, actual);
- assertEquals(request.getState(), actual.getState());
- }
-
- private RequestMetadata buildRequest() {
- RequestMetadata request = new RequestMetadata();
- request.setState(ProcessingState.PROCESSING);
- request.setCommand("select * from foo"); //$NON-NLS-1$
- request.setExecutionId(1234);
- request.setName("request-name"); //$NON-NLS-1$
- request.setSessionId("session-id");//$NON-NLS-1$
- request.setSourceRequest(false);
- request.setStartTime(12345L);
- request.setTransactionId("transaction-id");//$NON-NLS-1$
- request.setThreadState(ThreadState.RUNNING);
- //request.setNodeId(1);
- return request;
- }
-
- public static final String desc = "{\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
- " },\n" +
- " \"attributes\" : {\n" +
- " \"execution-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Unique Identifier for Request\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"session-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Session Identifier\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"start-time\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Start time for the request\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"command\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Executing Command\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"source-request\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"BOOLEAN\"\n" +
- " },\n" +
- " \"description\" : \"Is this Connector level request\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"node-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
- " },\n" +
- " \"description\" : \"Node Identifier\",\n" +
- " \"required\" : false\n" +
- " },\n" +
- " \"transaction-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Get Transaction XID if transaction involved\",\n" +
- " \"required\" : false\n" +
- " },\n" +
- " \"processing-state\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"State of the Request\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"thread-state\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Thread state\",\n" +
- " \"required\" : true\n" +
- " }\n" +
- " }\n" +
- "}";
- @Test public void testDescribe() {
- assertEquals(desc, MetadataMapper.RequestMetadataMapper.describe(new ModelNode()).toJSONString(false));
- }
-
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,137 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import org.jboss.dmr.ModelNode;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public class TestSessionMetadata {
-
- @Test public void testMapping() {
- SessionMetadata session = new SessionMetadata();
- session.setSessionId("test");
- session.setApplicationName("foo");
- session.setClientHostName("localhost");
- session.setCreatedTime(1234);
- session.setIPAddress("127.0.0.1");
- session.setVDBName("vdb-name");
- session.setVDBVersion(2);
- session.setSecurityContext("auth-domain");
- session.setUserName("user");
-
- ModelNode node = MetadataMapper.SessionMetadataMapper.wrap(session, new ModelNode());
-
- SessionMetadata session1 = MetadataMapper.SessionMetadataMapper.unwrap(node);
-
- assertEquals(session.getSessionId(), session1.getSessionId());
- assertEquals(session.getApplicationName(), session1.getApplicationName());
-
- }
-
- private static final String describe = "{\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
- " },\n" +
- " \"attributes\" : {\n" +
- " \"application-name\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Application assosiated with Session\",\n" +
- " \"required\" : false\n" +
- " },\n" +
- " \"created-time\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"When session created\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"client-host-address\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Host name from where the session created\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"ip-address\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"IP address from where session is created\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"last-ping-time\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Last ping time\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"session-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Session Identifier\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"user-name\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"User name associated with session\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"vdb-name\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"The Virtual Database Name\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"vdb-version\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
- " },\n" +
- " \"description\" : \"The Virtual Database Version\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"security-domain\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Security domain that session used for login\",\n" +
- " \"required\" : false\n" +
- " }\n" +
- " }\n" +
- "}";
-
- @Test public void testDescribe() {
- ModelNode n = MetadataMapper.SessionMetadataMapper.describe(new ModelNode());
- //System.out.println(n.toJSONString(false));
- assertEquals(describe, n.toJSONString(false));
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,92 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import org.jboss.dmr.ModelNode;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public class TestTransactionMetadata {
-
- @Test public void testMapping() {
- TransactionMetadata tm = new TransactionMetadata();
- tm.setAssociatedSession("x");
- tm.setCreatedTime(1234);
- tm.setId("tnx-id");
- tm.setScope("scope");
-
- ModelNode node = MetadataMapper.TransactionMetadataMapper.wrap(tm, new ModelNode());
-
- TransactionMetadata tm1 = MetadataMapper.TransactionMetadataMapper.unwrap(node);
-
- assertEquals(tm.getAssociatedSession(), tm1.getAssociatedSession());
-
- assertEquals(tm.getCreatedTime(), tm1.getCreatedTime());
- assertEquals(tm.getId(), tm1.getId());
- assertEquals(tm.getScope(), tm1.getScope());
- }
-
- private static final String describe = "{\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
- " },\n" +
- " \"attributes\" : {\n" +
- " \"session-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Session Identifier\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"txn-created-time\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Transaction created time\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"txn-scope\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
- " },\n" +
- " \"description\" : \"Transaction scope (Request, Local, Global)\",\n" +
- " \"required\" : true\n" +
- " },\n" +
- " \"txn-id\" : {\n" +
- " \"type\" : {\n" +
- " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
- " },\n" +
- " \"description\" : \"Transaction Identifier (XID)\",\n" +
- " \"required\" : true\n" +
- " }\n" +
- " }\n" +
- "}";
- @Test
- public void testDescribe() {
- ModelNode n = MetadataMapper.TransactionMetadataMapper.describe(new ModelNode());
- //System.out.println(n.toJSONString(false));
- assertEquals(describe, n.toJSONString(false));
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,232 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.impl;
-
-import static org.junit.Assert.*;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.jboss.dmr.ModelNode;
-import org.junit.Test;
-import org.teiid.adminapi.DataPolicy;
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-import org.teiid.core.util.ObjectConverterUtil;
-import org.teiid.core.util.PropertiesUtils;
-import org.teiid.core.util.UnitTestUtil;
-
-@SuppressWarnings("nls")
-public class TestVDBMetaData {
-
- @Test
- public void testMarshellUnmarshell() throws Exception {
-
- VDBMetaData vdb = buildVDB();
-
- SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd")); //$NON-NLS-1$
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
- Marshaller marshell = jc.createMarshaller();
- marshell.setSchema(schema);
- marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
-
- StringWriter sw = new StringWriter();
- marshell.marshal(vdb, sw);
-
- System.out.println(sw.toString());
-
- // UnMarshell
- Unmarshaller un = jc.createUnmarshaller();
- un.setSchema(schema);
- vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
-
- validateVDB(vdb);
- }
-
- static void validateVDB(VDBMetaData vdb) {
- ModelMetaData modelOne;
- ModelMetaData modelTwo;
- assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$
- assertEquals("vdb description", vdb.getDescription()); //$NON-NLS-1$
- assertEquals(1, vdb.getVersion());
- assertEquals("vdb-value", vdb.getPropertyValue("vdb-property")); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertNotNull(vdb.getModel("model-one")); //$NON-NLS-1$
- assertNotNull(vdb.getModel("model-two")); //$NON-NLS-1$
- assertNull(vdb.getModel("model-unknown")); //$NON-NLS-1$
-
- modelOne = vdb.getModel("model-one"); //$NON-NLS-1$
- assertEquals("model-one", modelOne.getName()); //$NON-NLS-1$
- assertEquals("s1", modelOne.getSourceNames().get(0)); //$NON-NLS-1$
- assertEquals(Model.Type.PHYSICAL, modelOne.getModelType());
- assertEquals("model-value-override", modelOne.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse(modelOne.isVisible());
- assertEquals("model description", modelOne.getDescription());
-
- modelTwo = vdb.getModel("model-two"); //$NON-NLS-1$
- assertEquals("model-two", modelTwo.getName()); //$NON-NLS-1$
- assertTrue(modelTwo.getSourceNames().contains("s1")); //$NON-NLS-1$
- assertTrue(modelTwo.getSourceNames().contains("s2")); //$NON-NLS-1$
- assertEquals(Model.Type.VIRTUAL, modelTwo.getModelType()); // this is not persisted in the XML
- assertEquals("model-value", modelTwo.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
-
-
- assertTrue(vdb.getValidityErrors().contains("There is an error in VDB")); //$NON-NLS-1$
-
- List<Translator> translators = vdb.getOverrideTranslators();
- assertTrue(translators.size() == 1);
-
- Translator translator = translators.get(0);
- assertEquals("oracleOverride", translator.getName());
- assertEquals("oracle", translator.getType());
- assertEquals("my-value", translator.getPropertyValue("my-property"));
- assertEquals("hello world", translator.getDescription());
- List<DataPolicy> roles = vdb.getDataPolicies();
-
- assertTrue(roles.size() == 1);
-
- DataPolicyMetadata role = vdb.getDataPolicy("roleOne"); //$NON-NLS-1$
- assertTrue(role.isAllowCreateTemporaryTables());
- assertEquals("roleOne described", role.getDescription()); //$NON-NLS-1$
- assertNotNull(role.getMappedRoleNames());
- assertTrue(role.getMappedRoleNames().contains("ROLE1")); //$NON-NLS-1$
- assertTrue(role.getMappedRoleNames().contains("ROLE2")); //$NON-NLS-1$
-
- List<DataPolicy.DataPermission> permissions = role.getPermissions();
- assertEquals(2, permissions.size());
-
- for (DataPolicy.DataPermission p: permissions) {
- if (p.getResourceName().equalsIgnoreCase("myTable.T1")) { //$NON-NLS-1$
- assertTrue(p.getAllowRead());
- assertNull(p.getAllowDelete());
- }
- else {
- assertFalse(p.getAllowRead());
- assertTrue(p.getAllowDelete());
- }
- }
- }
-
- private VDBMetaData buildVDB() {
- VDBMetaData vdb = new VDBMetaData();
- vdb.setName("myVDB"); //$NON-NLS-1$
- vdb.setDescription("vdb description"); //$NON-NLS-1$
- vdb.setVersion(1);
- vdb.addProperty("vdb-property", "vdb-value"); //$NON-NLS-1$ //$NON-NLS-2$
- vdb.addProperty("vdb-property2", "vdb-value2"); //$NON-NLS-1$ //$NON-NLS-2$
-
- ModelMetaData modelOne = new ModelMetaData();
- modelOne.setName("model-one"); //$NON-NLS-1$
- modelOne.addSourceMapping("s1", "translator", "java:mybinding"); //$NON-NLS-1$ //$NON-NLS-2$
- modelOne.setModelType(Model.Type.PHYSICAL); //$NON-NLS-1$
- modelOne.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
- modelOne.addProperty("model-prop", "model-value-override"); //$NON-NLS-1$ //$NON-NLS-2$
- modelOne.setVisible(false);
- modelOne.addError("ERROR", "There is an error in VDB"); //$NON-NLS-1$ //$NON-NLS-2$
- modelOne.setDescription("model description");
-
- vdb.addModel(modelOne);
-
- ModelMetaData modelTwo = new ModelMetaData();
- modelTwo.setName("model-two"); //$NON-NLS-1$
- modelTwo.addSourceMapping("s1", "translator", "java:binding-one"); //$NON-NLS-1$ //$NON-NLS-2$
- modelTwo.addSourceMapping("s2", "translator", "java:binding-two"); //$NON-NLS-1$ //$NON-NLS-2$
- modelTwo.setModelType(Model.Type.VIRTUAL); //$NON-NLS-1$
- modelTwo.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
-
- vdb.addModel(modelTwo);
-
- VDBTranslatorMetaData t1 = new VDBTranslatorMetaData();
- t1.setName("oracleOverride");
- t1.setType("oracle");
- t1.setDescription("hello world");
- t1.addProperty("my-property", "my-value");
- List<Translator> list = new ArrayList<Translator>();
- list.add(t1);
- vdb.setOverrideTranslators(list);
-
- DataPolicyMetadata roleOne = new DataPolicyMetadata();
- roleOne.setName("roleOne"); //$NON-NLS-1$
- roleOne.setDescription("roleOne described"); //$NON-NLS-1$
- roleOne.setAllowCreateTemporaryTables(true);
- PermissionMetaData perm1 = new PermissionMetaData();
- perm1.setResourceName("myTable.T1"); //$NON-NLS-1$
- perm1.setAllowRead(true);
- roleOne.addPermission(perm1);
-
- PermissionMetaData perm2 = new PermissionMetaData();
- perm2.setResourceName("myTable.T2"); //$NON-NLS-1$
- perm2.setAllowRead(false);
- perm2.setAllowDelete(true);
- roleOne.addPermission(perm2);
-
- roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2")); //$NON-NLS-1$ //$NON-NLS-2$
-
- vdb.addDataPolicy(roleOne);
- return vdb;
- }
-
- @Test
- public void testAdminMOCreation() {
- VDBMetaData vdb = new VDBMetaData();
-
- PropertiesUtils.setBeanProperty(vdb, "url", "http://teiid.org/myvdb.vdb");
-
- assertEquals("http://teiid.org/myvdb.vdb", vdb.getUrl());
- }
-
- @Test public void testSetUrlVersion() throws MalformedURLException {
- VDBMetaData vdb = new VDBMetaData();
- vdb.setName("foo");
- vdb.setUrl(new URL("file:///x/foo.2.vdb"));
- assertEquals(2, vdb.getVersion());
- }
-
- @Test public void testVDBMetaDataMapper() {
- VDBMetaData vdb = buildVDB();
-
- ModelNode node = MetadataMapper.wrap(vdb, new ModelNode());
-
- vdb = MetadataMapper.unwrap(node);
- validateVDB(vdb);
- }
-
- @Test
- public void testVDBMetaDataDescribe() throws Exception {
- ModelNode node = MetadataMapper.describe(new ModelNode());
- String actual = node.toJSONString(false);
- assertEquals(ObjectConverterUtil.convertFileToString(new File(UnitTestUtil.getTestDataPath() + "/vdb-describe.txt")), actual);
- }
-}
Deleted: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java 2011-09-02 20:55:50 UTC (rev 3446)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java 2011-09-02 21:01:40 UTC (rev 3447)
@@ -1,17 +0,0 @@
-package org.teiid.adminapi.impl;
-
-import java.io.FileInputStream;
-
-import org.junit.Test;
-import org.teiid.core.util.UnitTestUtil;
-
-@SuppressWarnings("nls")
-public class TestVDBMetadataParser {
-
- @Test
- public void testparseVDB() throws Exception {
- FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/parser-test-vdb.xml");
- VDBMetaData vdb = VDBMetadataParser.unmarshell(in);
- TestVDBMetaData.validateVDB(vdb);
- }
-}
[View Less]
13 years, 7 months
teiid SVN: r3446 - branches/as7/admin.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-02 16:55:50 -0400 (Fri, 02 Sep 2011)
New Revision: 3446
Modified:
branches/as7/admin/
Log:
TEIID-1720: adding ignores
Property changes on: branches/as7/admin
___________________________________________________________________
Added: svn:ignore
+ .classpath
.project
.settings
13 years, 7 months
teiid SVN: r3445 - in branches/as7: admin and 35 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-02 16:49:18 -0400 (Fri, 02 Sep 2011)
New Revision: 3445
Added:
branches/as7/admin/
branches/as7/admin/pom.xml
branches/as7/admin/src/
branches/as7/admin/src/main/
branches/as7/admin/src/main/java/
branches/as7/admin/src/main/java/org/
branches/as7/admin/src/main/java/org/teiid/
branches/as7/admin/src/main/java/org/teiid/adminapi/
branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java
branches/as7/admin/src/main/java/org/teiid/…
[View More]adminapi/AdminComponentException.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java
branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java
branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java
branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java
branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java
branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java
branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java
branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
branches/as7/admin/src/main/resources/
branches/as7/admin/src/test/
branches/as7/admin/src/test/java/
branches/as7/admin/src/test/java/org/
branches/as7/admin/src/test/java/org/teiid/
branches/as7/admin/src/test/java/org/teiid/adminapi/
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
branches/as7/admin/src/test/resources/
branches/as7/admin/target/
branches/as7/admin/target/classes/
branches/as7/admin/target/classes/org/
branches/as7/admin/target/classes/org/teiid/
branches/as7/admin/target/classes/org/teiid/adminapi/
branches/as7/admin/target/classes/org/teiid/adminapi/impl/
branches/as7/admin/target/maven-archiver/
branches/as7/admin/target/test-classes/
branches/as7/admin/target/test-classes/org/
branches/as7/admin/target/test-classes/org/teiid/
branches/as7/admin/target/test-classes/org/teiid/adminapi/
branches/as7/admin/target/test-classes/org/teiid/adminapi/impl/
branches/as7/connectors/translator-ws/src/main/java/META-INF/
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java
Modified:
branches/as7/adminshell/pom.xml
branches/as7/api/pom.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
branches/as7/connectors/pom.xml
branches/as7/engine/pom.xml
branches/as7/jboss-integration/
branches/as7/jboss-integration/pom.xml
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineRemove.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorRemove.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
branches/as7/metadata/pom.xml
branches/as7/pom.xml
branches/as7/runtime/pom.xml
branches/as7/test-integration/pom.xml
Log:
TEIID-1720: Fixed the all the admin calls and resource models for engine and translator
Added: branches/as7/admin/pom.xml
===================================================================
--- branches/as7/admin/pom.xml (rev 0)
+++ branches/as7/admin/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>teiid-parent</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.6.0.Alpha1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>teiid-admin</artifactId>
+ <name>admin</name>
+ <description>Admin API for Teiid</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-dmr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-controller-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-cli</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,298 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Properties;
+import java.util.Set;
+
+import org.teiid.adminapi.VDB.ConnectionType;
+
+public interface Admin {
+
+ public enum Cache {PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE};
+
+ /**
+ * Assign a {@link Translator} and Data source to a {@link VDB}'s Model
+ *
+ * @param vdbName Name of the VDB
+ * @param vdbVersion Version of the VDB
+ * @param modelName Name of the Model to map Connection Factory
+ * @param sourceName sourceName for the model
+ * @param translatorName
+ * @param dsName data source name that can found in the JNDI map.
+ * @throws AdminException
+ */
+ void assignToModel(String vdbName, int vdbVersion, String modelName, String sourceName, String translatorName, String dsName) throws AdminException;
+
+ /**
+ * Change the {@link ConnectionType} of the {@link VDB}.
+ * @param vdbName Name of the VDB
+ * @param vdbVersion Version of the VDB
+ * @param type
+ * @throws AdminException
+ */
+ void changeVDBConnectionType(String vdbName, int vdbVersion, ConnectionType type) throws AdminException;
+
+ /**
+ * Deploy a {@link VDB} file.
+ * @param name Name of the VDB file to save under
+ * @param VDB VDB.
+ * @throws AdminException
+ *
+ * @return the {@link VDB} representing the current property values and runtime state.
+ */
+ public void deployVDB(String fileName, InputStream vdb) throws AdminException;
+
+
+ /**
+ * Delete the VDB with the given name and version
+ * @param vdbName
+ * @param version
+ * @throws AdminException
+ */
+ void deleteVDB(String vdbName, int vdbVersion) throws AdminException;
+
+ /**
+ * Get the VDBs that currently deployed in the system
+ *
+ * @return Collection of {@link VDB}s. There could be multiple VDBs with the
+ * same name in the Collection but they will differ by VDB version.
+ * @throws AdminException
+ */
+ Set<VDB> getVDBs() throws AdminException;
+
+ /**
+ * Get the VDB
+ * @param vdbName
+ * @param vbdVersion
+ * @throws AdminException
+ * @return
+ */
+ VDB getVDB(String vdbName, int vbdVersion) throws AdminException;
+
+ /**
+ * Get the translators that are available in the configuration
+ *
+ * @return Collection of {@link Translator}
+ * @throws AdminException
+ */
+ Collection<Translator> getTranslators() throws AdminException;
+
+ /**
+ * Get the translator by the given the deployed name.
+ * @param deployedName - name of the deployed translator
+ * @return null if not found
+ * @throws AdminException
+ */
+ Translator getTranslator(String deployedName) throws AdminException;
+
+ /**
+ * Get the Worker Pool statistics in runtime engine.
+ *
+ * @return {@link WorkerPoolStatistics}
+ * @throws AdminException
+ */
+ WorkerPoolStatistics getWorkerPoolStats() throws AdminException;
+
+ /**
+ * Get the Caches that correspond to the specified identifier pattern
+ * @return Collection of {@link String}
+ * @throws AdminException
+ */
+ Collection<String> getCacheTypes() throws AdminException;
+
+ /**
+ * Get all the current Sessions.
+ * @return Collection of {@link Session}
+ * @throws AdminException
+ */
+ Collection<Session> getSessions() throws AdminException;
+
+ /**
+ * Get the all Requests that are currently in process
+ * @return Collection of {@link Request}
+ * @throws AdminException
+ */
+ Collection<Request> getRequests() throws AdminException;
+
+ /**
+ * Get the Requests for the given session
+ * @return Collection of {@link Request}
+ * @throws AdminException
+ */
+ Collection<Request> getRequestsForSession(String sessionId) throws AdminException;
+
+
+ /**
+ * Get all of the available configuration Properties for the specified connector
+ * @param templateName - Name of the connector
+ * @return
+ * @throws AdminException
+ */
+ Collection<PropertyDefinition> getTemplatePropertyDefinitions(String templateName) throws AdminException;
+
+
+ /**
+ * Get all transaction matching the identifier.
+ * @return
+ * @throws AdminException
+ */
+ Collection<Transaction> getTransactions() throws AdminException;
+
+ /**
+ * Clear the cache or caches specified by the cacheIdentifier.
+ * @param cacheType Cache Type
+ * No wild cards currently supported, must be explicit
+ * @throws AdminException
+ */
+ void clearCache(String cacheType) throws AdminException;
+
+ /**
+ * Clear the cache of the given VDB for provided cache type
+ * @param cacheType Cache Type
+ * No wild cards currently supported, must be explicit
+ * @param vdbName - Name of the VDB
+ * @param vdbVersion - VDB version
+ * @throws AdminException
+ */
+ void clearCache(String cacheType, String vdbName, int vdbVersion) throws AdminException;
+
+
+ /**
+ * Get the Cache Statistics for the given type
+ * @param cacheType Cache Type
+ * @return {@link CacheStatistics}
+ * @throws AdminException
+ */
+ CacheStatistics getCacheStats(String cacheType) throws AdminException;
+
+ /**
+ * Terminate the Session
+ *
+ * @param identifier Session Identifier {@link org.teiid.adminapi.Session}.
+ * No wild cards currently supported, must be explicit
+ * @throws AdminException
+ */
+ void terminateSession(String sessionId) throws AdminException;
+
+ /**
+ * Cancel Request
+ *
+ * @param sessionId session Identifier for the request.
+ * @param executionId request Identifier
+ *
+ * @throws AdminException
+ */
+ void cancelRequest(String sessionId, long executionId) throws AdminException;
+
+ /**
+ * Mark the given global transaction as rollback only.
+ * @param transactionId
+ * @throws AdminException
+ */
+ void terminateTransaction(String transactionId) throws AdminException;
+
+ /**
+ * Closes the admin connection
+ */
+ void close();
+
+ /**
+ * Assign a Role name to the Data Role in a given VDB
+ *
+ * @param vdbName
+ * @param vdbVersion
+ * @param dataRole
+ * @param mappedRoleName
+ */
+ void addDataRoleMapping(String vdbName, int vdbVersion, String dataRole, String mappedRoleName) throws AdminException;
+
+ /**
+ * Remove a Role name to the Data Role in a given VDB
+ *
+ * @param vdbName
+ * @param vdbVersion
+ * @param dataRole
+ * @param mappedRoleName
+ */
+ void removeDataRoleMapping(String vdbName, int vdbVersion, String dataRole, String mappedRoleName) throws AdminException;
+
+ /**
+ * Set the any authenticated flag on the Data Role in a given VDB
+ *
+ * @param vdbName
+ * @param vdbVersion
+ * @param dataRole
+ * @param anyAuthenticated
+ */
+ void setAnyAuthenticatedForDataRole(String vdbName, int vdbVersion, String dataRole, boolean anyAuthenticated) throws AdminException;
+
+ /**
+ * Merge the Source VDB into Target VDB. Both Source and Target VDBs must be present for this method to
+ * succeed. The changes will not be persistent between server restarts.
+ * @param sourceVDBName
+ * @param sourceVDBVersion
+ * @param targetVDBName
+ * @param targetVDBVersion
+ */
+ void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException;
+
+
+ /**
+ * Creates a JCA data source
+ * @param deploymentName - name of the source
+ * @param templateName - template of data source
+ * @param properties - properties
+ * @throws AdminException
+ */
+ void createDataSource(String deploymentName, String templateName, Properties properties) throws AdminException;
+
+ /**
+ * Delete data source.
+ * @param deployedName
+ * @throws AdminException
+ */
+ void deleteDataSource(String deployedName) throws AdminException;
+
+ /**
+ * Returns the all names of all the data sources available in the configuration.
+ */
+ Collection<String> getDataSourceNames() throws AdminException;
+
+ /**
+ * Get the Datasource templates available in the configuration.
+ *
+ * @return Set of template names.
+ * @throws AdminException
+ */
+ Set<String> getDataSourceTemplateNames() throws AdminException;
+
+ /**
+ * Tell the engine that the given source is available. Pending dynamic vdb metadata loads will be resumed.
+ * @param jndiName
+ * @throws AdminException
+ */
+ void markDataSourceAvailable(String jndiName) throws AdminException;
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Admin.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminComponentException.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminComponentException.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminComponentException.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+/**
+ * An <code>AdminComponentException</code> is thrown when an error occurs as a
+ * result of an internal component error.
+ *
+ * <p>This exception class is capable of containing multiple exceptions. See
+ * {@link AdminException} for details.
+ */
+public final class AdminComponentException extends AdminException {
+
+ private static final long serialVersionUID = 7117721841515240902L;
+
+
+ public AdminComponentException() {
+ super();
+ }
+
+ /**
+ * Construct with a message.
+ * @param msg the error message.
+ * @since 4.3
+ */
+ public AdminComponentException(String msg) {
+ super(msg);
+ }
+
+ public AdminComponentException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Construct with an optional error code and a message.
+ * @param code an optional error code
+ * @param msg the error message.
+ * @since 4.3
+ */
+ public AdminComponentException(int code, String msg) {
+ super(code, msg);
+ }
+
+ public AdminComponentException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public AdminComponentException(int code, String msg, Throwable cause) {
+ super(code, msg, cause);
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminComponentException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.teiid.core.TeiidException;
+
+
+/**
+ * <code>AdminException</code> is the base exception for the admin package. Many *Admin methods throw this
+ * exception. Instances will be one of the concrete subtypes:
+ * {@link AdminComponentException} or {@link AdminProcessingException}</p>
+ *
+ * <p><code>AdminException</code>s may contain multiple child exceptions. An example
+ * of this could be when performing an admin action results in multiple failures. Admin
+ * clients should be aware of this and use the {@link #hasMultiple()} method to
+ * determine if they need to check the child exceptions.</p>
+ */
+public abstract class AdminException extends TeiidException {
+
+ private static final long serialVersionUID = -4446936145500241358L;
+ // List of Admin exceptions in
+ // case of multiple failure
+ private List children;
+
+ /**
+ * No-arg ctor.
+ *
+ * @since 4.3
+ */
+ AdminException() {
+ super();
+ }
+
+ /**
+ * Construct with a message.
+ * @param msg the error message.
+ * @since 4.3
+ */
+ AdminException(String msg) {
+ super(msg);
+ }
+
+ AdminException(Throwable cause) {
+ this(cause.getMessage(), cause);
+ }
+
+ /**
+ * Construct with an optional error code and a message.
+ * @param code an optional error code
+ * @param msg the error message.
+ * @since 4.3
+ */
+ AdminException(int code, String msg) {
+ super(Integer.toString(code), msg);
+ }
+
+ AdminException(String msg, Throwable cause) {
+ super(cause, msg);
+ }
+
+ AdminException(int code, String msg, Throwable cause) {
+ super(cause, Integer.toString(code),msg);
+ }
+
+ /**
+ * Determine whether this exception is representing
+ * mutliple component failures.
+ * @return <code>true</code> iff this exception contains multiple
+ * component failure exceptions.
+ * @since 4.3
+ */
+ public boolean hasMultiple() {
+ return (children != null && children.size() > 0);
+ }
+
+ /**
+ * Returns a non-null list of failures (<code>AdminException</code>s), one for each
+ * component that failed.
+ *
+ * <p>The list will have members when {@link #hasMultiple()} returns <code>true</code>.</p>
+ * @return The non-null list of failures.
+ * @since 4.3
+ */
+ public List getChildren() {
+ return (children != null ? children : Collections.EMPTY_LIST);
+ }
+
+ /**
+ * Add a child <code>AdminException</code> for a particular failure
+ * if and action resulted in multiple failures.
+ *
+ * @param child a specific failure
+ * @since 4.3
+ */
+ public void addChild(AdminException child) {
+ if ( children == null ) {
+ children = new ArrayList();
+ }
+ children.add(child);
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,343 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.security.auth.callback.*;
+import javax.security.sasl.RealmCallback;
+import javax.security.sasl.RealmChoiceCallback;
+
+import org.jboss.as.cli.Util;
+import org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress;
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.teiid.adminapi.VDB.ConnectionType;
+
+
+/**
+ * Singleton factory for class for creating Admin connections to the Teiid
+ */
+public class AdminFactory {
+ private static AdminFactory INSTANCE = new AdminFactory();
+
+ public static AdminFactory getInstance() {
+ return INSTANCE;
+ }
+ /**
+ * Creates a ServerAdmin with the specified connection properties.
+ * @param userName
+ * @param password
+ * @param serverURL
+ * @param applicationName
+ * @return
+ * @throws AdminException
+ */
+ public Admin createAdmin(String host, int port, String userName, char[] password) throws AdminException {
+ if(host == null) {
+ host = "localhost"; //$NON-NLS-1$
+ }
+
+ if(port < 0) {
+ port = 9990;
+ }
+
+ try {
+ CallbackHandler cbh = new AuthenticationCallbackHandler(userName, password);
+ ModelControllerClient newClient = ModelControllerClient.Factory.create(host, port, cbh);
+
+ List<String> nodeTypes = Util.getNodeTypes(newClient, new DefaultOperationRequestAddress());
+ if (!nodeTypes.isEmpty()) {
+ boolean domainMode = nodeTypes.contains("server-group"); //$NON-NLS-1$
+ System.out.println("Connected to " //$NON-NLS-1$
+ + (domainMode ? "domain controller at " : "standalone controller at ") //$NON-NLS-1$ //$NON-NLS-2$
+ + host + ":" + port); //$NON-NLS-1$
+ return new AdminImpl(newClient);
+ }
+ System.out.println("The controller is not available at " + host + ":" + port); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (UnknownHostException e) {
+ System.out.println("Failed to resolve host '" + host + "': " + e.getLocalizedMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+
+ private class AuthenticationCallbackHandler implements CallbackHandler {
+ private boolean realmShown = false;
+ private String userName = null;
+ private char[] password = null;
+
+ public AuthenticationCallbackHandler(String user, char[] password) {
+ this.userName = user;
+ this.password = password;
+ }
+
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ // Special case for anonymous authentication to avoid prompting user for their name.
+ if (callbacks.length == 1 && callbacks[0] instanceof NameCallback) {
+ ((NameCallback)callbacks[0]).setName("anonymous CLI user"); //$NON-NLS-1$
+ return;
+ }
+
+ for (Callback current : callbacks) {
+ if (current instanceof RealmCallback) {
+ RealmCallback rcb = (RealmCallback) current;
+ String defaultText = rcb.getDefaultText();
+ rcb.setText(defaultText); // For now just use the realm suggested.
+ if (realmShown == false) {
+ realmShown = true;
+ }
+ } else if (current instanceof RealmChoiceCallback) {
+ throw new UnsupportedCallbackException(current, "Realm choice not currently supported."); //$NON-NLS-1$
+ } else if (current instanceof NameCallback) {
+ NameCallback ncb = (NameCallback) current;
+ ncb.setName(userName);
+ } else if (current instanceof PasswordCallback) {
+ PasswordCallback pcb = (PasswordCallback) current;
+ pcb.setPassword(password);
+ } else {
+ throw new UnsupportedCallbackException(current);
+ }
+ }
+ }
+
+ }
+
+ private class AdminImpl implements Admin{
+ public AdminImpl (ModelControllerClient connection) {
+
+ }
+
+ @Override
+ public void addDataRoleMapping(String vdbName, int vdbVersion,
+ String dataRole, String mappedRoleName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void assignToModel(String vdbName, int vdbVersion,
+ String modelName, String sourceName, String translatorName,
+ String dsName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void cancelRequest(String sessionId, long executionId)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void changeVDBConnectionType(String vdbName, int vdbVersion,
+ ConnectionType type) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearCache(String cacheType) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearCache(String cacheType, String vdbName, int vdbVersion)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void close() {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void createDataSource(String deploymentName,
+ String templateName, Properties properties)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteDataSource(String deployedName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteVDB(String vdbName, int vdbVersion)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deployVDB(String fileName, InputStream vdb)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public CacheStatistics getCacheStats(String cacheType)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<String> getCacheTypes() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<String> getDataSourceNames() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<String> getDataSourceTemplateNames() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Request> getRequests() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Request> getRequestsForSession(String sessionId)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Session> getSessions() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<PropertyDefinition> getTemplatePropertyDefinitions(
+ String templateName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Transaction> getTransactions() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Translator getTranslator(String deployedName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Translator> getTranslators() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public VDB getVDB(String vdbName, int vbdVersion) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<VDB> getVDBs() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public WorkerPoolStatistics getWorkerPoolStats() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void markDataSourceAvailable(String jndiName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mergeVDBs(String sourceVDBName, int sourceVDBVersion,
+ String targetVDBName, int targetVDBVersion)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeDataRoleMapping(String vdbName, int vdbVersion,
+ String dataRole, String mappedRoleName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setAnyAuthenticatedForDataRole(String vdbName,
+ int vdbVersion, String dataRole, boolean anyAuthenticated)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateSession(String sessionId) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateTransaction(String transactionId)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * Base interface of client side admin objects. Specifies behaviors and properties common to all administrative objects.
+ * <p>
+ * Unique identifiers are available for all <code>AdminObject</code>s and their forms are specific to each object. See
+ * the javadoc on the individual object for its particular identifier pattern required.
+ * </p>
+ * <p>
+ * This interface need not be used directly by clients except when coding to constants.
+ * </p>
+ *
+ * @since 4.3
+ */
+public interface AdminObject extends Serializable {
+
+ /**
+ * The character that delimits the atomic components of the identifier.
+ * @see #DELIMITER
+ */
+ public static final char DELIMITER_CHAR = '|';
+
+ /**
+ * The character (as a <code>String</code>) that delimits the atomic components of the identifier.
+ *
+ * <p>It is <emph>strongly</emph> advisable to write admin client code using this <code>DELIMITER</code>
+ * rather than hard-coding a delimiter character in admin code. Doing this eliminates the possibility
+ * of admin client code breaking if/when the delimiter character must be changed.</p>
+ */
+ public static final String DELIMITER = new String(new char[] {DELIMITER_CHAR});
+
+ /**
+ * The delimiter character as a <code>String</code> escaped.
+ * @see #DELIMITER
+ */
+ public static final String ESCAPED_DELIMITER = "\\" + DELIMITER; //$NON-NLS-1$
+
+ /**
+ * The wildcard character (as a <code>String</code>) that can be used in may identifier patterns
+ * to indicate <i>"anything"</i> or, more specifically, replace <i>"zero or more"</i>
+ * identifier components.
+ *
+ * <p>It is <emph>strongly</emph> advisable to write admin client code using this <code>WILDCARD</code>
+ * rather than hard-coding a wildcard character in admin code. Doing this eliminates the possibility
+ * of admin client code breaking if/when the wildcard character must be changed.</p>
+ */
+ public static final String WILDCARD = "*"; //$NON-NLS-1$
+
+ /**
+ * The wildcard character as a <code>String</code> escaped.
+ * @see #WILDCARD
+ */
+ public static final String ESCAPED_WILDCARD = "\\" + WILDCARD; //$NON-NLS-1$
+
+ /**
+ * Get the name for this AdminObject, usually the last component of the identifier.
+ *
+ * @return String Name
+ * @since 4.3
+ */
+ String getName();
+
+ /**
+ * Get the Configuration Properties that defines this process
+ *
+ * @return Properties
+ * @since 4.3
+ */
+ Properties getProperties();
+
+ /**
+ * Searches for the property with the specified key in this Admin Object. If the key is not found the method returns
+ * <code>null</code>.
+ *
+ * @param name
+ * the property key.
+ * @return the value in this Admin Object with the specified key value.
+ * @since 4.3
+ */
+
+ String getPropertyValue(String name);
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminObject.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.util.ResourceBundle;
+
+import org.teiid.core.BundleUtil;
+
+public class AdminPlugin {
+ public static final String PLUGIN_ID = "org.teiid.adminapi" ; //$NON-NLS-1$
+ public static final BundleUtil Util = new BundleUtil(PLUGIN_ID, PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminPlugin.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+/**
+ * An <code>AdminProcessingException</code> indicates that an error occured during processing as a result
+ * of user input. This exception is the result of handling an invalid user
+ * request, not the result of an internal error.</p>
+ *
+ * <p>This exception class is capable of containing multiple exceptions. See
+ * {@link AdminException} for details.
+ */
+public final class AdminProcessingException extends AdminException {
+
+ private static final long serialVersionUID = -878521636838205857L;
+
+ /**
+ * No-arg ctor.
+ *
+ * @since 4.3
+ */
+ public AdminProcessingException() {
+ super();
+ }
+
+ /**
+ * Construct with a message.
+ * @param msg the error message.
+ * @since 4.3
+ */
+ public AdminProcessingException(String msg) {
+ super(msg);
+ }
+
+ public AdminProcessingException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Construct with an optional error code and a message.
+ * @param code an optional error code
+ * @param msg the error message.
+ * @since 4.3
+ */
+ public AdminProcessingException(int code, String msg) {
+ super(code, msg);
+ }
+
+ public AdminProcessingException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public AdminProcessingException(int code, String msg, Throwable cause) {
+ super(code, msg, cause);
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/AdminProcessingException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+public interface CacheStatistics extends AdminObject {
+
+ double getHitRatio();
+
+ int getTotalEntries();
+
+ int getRequestCount();
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/CacheStatistics.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+import java.util.List;
+
+public interface DataPolicy {
+
+ public enum Context {
+ CREATE,
+ DROP,
+ QUERY,
+ INSERT,
+ UPDATE,
+ DELETE,
+ FUNCTION,
+ ALTER,
+ STORED_PROCEDURE;
+ }
+
+ public enum PermissionType {CREATE, READ, UPDATE, DELETE, ALTER, EXECUTE, DROP};
+
+ /**
+ * Get the Name of the Data Policy
+ * @return
+ */
+ String getName();
+
+ /**
+ * Get the description of the Data Policy
+ * @return
+ */
+ String getDescription();
+
+ /**
+ * Get the List of Permissions for this Data Policy.
+ * @return
+ */
+ List<DataPermission> getPermissions();
+
+ /**
+ * Mapped Container Role names for this Data Policy
+ * @return
+ */
+ List<String> getMappedRoleNames();
+
+ /**
+ * If the policy applies to any authenticated user
+ * @return
+ */
+ boolean isAnyAuthenticated();
+
+ /**
+ * If the policy allows for temporary table usage
+ * @return
+ */
+ Boolean isAllowCreateTemporaryTables();
+
+ interface DataPermission {
+ /**
+ * Get the Resource Name that Data Permission representing
+ * @return
+ */
+ String getResourceName();
+
+ /**
+ * Is "CREATE" allowed?
+ * @return
+ */
+ Boolean getAllowCreate();
+
+ /**
+ * Is "SELECT" allowed?
+ * @return
+ */
+ Boolean getAllowRead();
+
+ /**
+ * Is "INSERT/UPDATE" allowed?
+ * @return
+ */
+ Boolean getAllowUpdate();
+
+ /**
+ * Is "DELETE" allowed?
+ * @return
+ */
+ Boolean getAllowDelete();
+
+ /**
+ * Is "ALTER" allowed?
+ * @return
+ */
+ Boolean getAllowAlter();
+
+ /**
+ * Is "EXECUTE" allowed?
+ * @return
+ */
+ Boolean getAllowExecute();
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/DataPolicy.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.util.List;
+
+
+/**
+ * Represents a metadata model in the Teiid system.
+ *
+ * @since 4.3
+ */
+public interface Model extends AdminObject {
+
+ enum Type {PHYSICAL, VIRTUAL, FUNCTION, OTHER};
+
+ /**
+ * Description about the model
+ * @return
+ */
+ String getDescription();
+
+ /**
+ * Determine if this model is a Source model.
+ *
+ * @return <code>true</code> if it contains physical group(s).
+ */
+ boolean isSource();
+
+ /**
+ * Determine whether this model is exposed for querying.
+ *
+ * @return <code>true</code> if the model is visible
+ * for querying.
+ */
+ boolean isVisible();
+
+ /**
+ * Retrieve the model type.
+ * @return model type
+ */
+ Type getModelType();
+
+ /**
+ * Determine whether this model can support more than one source.
+ *
+ * @return <code>true</code> if this model supports multiple sources
+ */
+ boolean isSupportsMultiSourceBindings();
+
+ /**
+ * Associated Source Names for the Models
+ * @return String
+ */
+ List<String> getSourceNames();
+
+ /**
+ * Get the configured JNDI name for the given source name.
+ * @param sourceName - name of the source
+ * @return null if none configured.
+ */
+ String getSourceConnectionJndiName(String sourceName);
+
+
+ /**
+ * Get the configured translator name for the given source
+ * @param sourceName
+ * @return
+ */
+ String getSourceTranslatorName(String sourceName);
+}
\ No newline at end of file
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Model.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.util.Collection;
+
+/**
+ * Information about a property of an AdminObject
+ */
+public interface PropertyDefinition extends AdminObject {
+
+ public enum RestartType {
+ NONE,
+ SERVICE,
+ PROCESS,
+ ALL_PROCESSES,
+ CLUSTER
+ }
+ /**
+ * The value of the maximum multiplicity if the multiplicity is considered unbounded.
+ */
+ public static final int UNBOUNDED_VALUE = Integer.MAX_VALUE;
+
+
+ /**
+ * Get the localized display name of this property.
+ * @return the displayable name for this property
+ */
+ String getDisplayName();
+
+ /**
+ * Get the description of this property.
+ * @return the description for this property
+ */
+ String getDescription();
+
+
+ /**
+ * Get the name of the java class that best represents the property type.
+ * @return the name of the java class that best represents the property type.
+ */
+ String getPropertyTypeClassName();
+
+
+ /**
+ * Get the default value for values of this property, or an empty String if
+ * there is no default value.
+ * @return the default value for this property, or an empty String
+ * if there is no default value.
+ */
+ Object getDefaultValue();
+
+ /**
+ * Get the allowed values for this property.
+ * @return the list of allowed values for this property, or an empty
+ * set if the values do not have to conform to a fixed set.
+ */
+ Collection getAllowedValues();
+
+ /**
+ * Get whether this property requires the system to be restarted before it takes effect.
+ * @return true if this property requires the system to be restarted before it takes effect.
+ */
+ public RestartType getRequiresRestart();
+
+ /**
+ * The modifiable flag is used to identify features that may not be changed once
+ * they are set.
+ * @return true if this property is marked with the modifyable
+ * flag, or false otherwise.
+ */
+ boolean isModifiable();
+
+ /**
+ * Return whether the value or values for this property are constrained to be only
+ * those in the AllowedValues list.
+ * @see #getAllowedValues
+ * @return true if this property's value must be with the list of AllowedValues.
+ */
+ boolean isConstrainedToAllowedValues();
+
+ /**
+ * The "expert" flag is used to distinguish between features that are
+ * intended for expert users from those that are intended for normal users.
+ * @return true if this property is to be marked with the expert flag,
+ * or false otherwise.
+ */
+ boolean isAdvanced();
+ /**
+ * The "required" flag is used to identify features that require at least
+ * one value (possibly a default value) by the consumer of the property. Whether
+ * a property definition is required or not can be determined entirely from the
+ * multiplicity: if the multiplicity includes '0', then the property is
+ * not required.
+ * <p>
+ * Whether a property is required by the consumer is unrelated to whether
+ * there is a default value, which only simplifies the task of the property
+ * provider. A property may be required, meaning it must have at least one
+ * value, but that same property definition may or may not have a default.
+ * The combination of required and whether it has a default will determine
+ * whether the user must supply a value.
+ * @return true if this property requires at least one value.
+ */
+ boolean isRequired();
+ /**
+ * The "masked" flag is used to tell whether the value should be masked
+ * when displayed to users.
+ * @return true if this property value is to be masked,
+ * or false otherwise.
+ */
+ boolean isMasked();
+
+
+
+}
+
+
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/PropertyDefinition.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+
+
+/**
+ * When a user submits a SQL command to the system for processing, usually that represents
+ * a single request. A single request might have one or more source
+ * requests (the requests that are being processed on the physical data sources) as part
+ * of original request.
+ *
+ * <p>A request is identified by a numbers separated by '|'. usually in they are arranged
+ * in the pattern [session]|[request] or [session]|[request]|[source request] </p>
+ */
+public interface Request extends AdminObject {
+
+ public enum ProcessingState {
+ PROCESSING,
+ DONE,
+ CANCELED
+ }
+
+ public enum ThreadState {
+ RUNNING,
+ QUEUED,
+ IDLE
+ }
+
+ /**
+ * Get the ExecutionId for a Request
+ * @return ExecutionId
+ */
+ public long getExecutionId();
+
+ /**
+ * Get the SessionID for a Request
+ *
+ * @return String SessionID
+ */
+ public String getSessionId();
+
+ /**
+ * Get the SQL Command sent to the Server for a Request
+ *
+ * @return SQL Command
+ */
+ public String getCommand();
+
+ /**
+ * Get when the processing began for this Request
+ * @return Date processing began
+ */
+ public long getStartTime();
+
+ /**
+ * Get the TransactionID of the Request
+ *
+ * @return String of TransactionID if in a transaction
+ */
+ public String getTransactionId();
+
+ /**
+ * @return Returns whether this is a Source Request.
+ */
+ public boolean sourceRequest();
+
+ /**
+ * @return In the case that this is a source request this represents the node id. Otherwise null
+ */
+ public Integer getNodeId();
+
+ /**
+ * @return The request state
+ */
+ ProcessingState getState();
+
+ /**
+ * @return The thread state
+ */
+ ThreadState getThreadState();
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Request.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+/**
+ * A Session represents a single connection between a client and the server.
+ *
+ * A user is allowed to have multiple sessions active simultaneously.
+ */
+public interface Session extends AdminObject {
+
+ /**
+ * Get the Last time Client has check to see if the server is still available
+ *
+ * @return Date of the last ping to the server.
+ */
+ public long getLastPingTime();
+
+
+ /**
+ * Get the Application Name
+ *
+ * @return String of the Application Name
+ */
+ public String getApplicationName();
+
+ /**
+ * Get the unique Teiid session
+ * within a given Teiid System
+ *
+ * @return String of the Session ID
+ */
+ public String getSessionId();
+
+ /**
+ * Get User Name for this Session
+ *
+ * @return String of UserName
+ */
+ public String getUserName();
+
+ /**
+ * Get the VDB Name for this Session
+ *
+ * @return String name of the VDB
+ */
+ public String getVDBName();
+
+ /**
+ * Get the VDB Version for this Session
+ *
+ * @return String name/number of the VDB Version
+ */
+ public int getVDBVersion();
+
+ /**
+ * Get the IPAddress for this Session. Note this value is reported from the client.
+ * @return
+ */
+ public String getIPAddress();
+
+
+ /**
+ * Get the host name of the machine the client is
+ * accessing from. Note this value is reported from the client.
+ * @return
+ */
+ public String getClientHostName();
+
+ /**
+ * Get the client hardware (typically MAC) address. Note this value is reported from the client.
+ * @return the hardware address as a hex string or null if not available.
+ */
+ public String getClientHardwareAddress();
+
+ /**
+ * Get the time the {@link Session} was created.
+ * @return
+ */
+ public long getCreatedTime();
+
+
+ /**
+ * Security Domain user logged into currently
+ * @return
+ */
+ public String getSecurityDomain();
+
+}
\ No newline at end of file
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Session.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+
+public interface Transaction extends AdminObject {
+
+ /**
+ * Get the session associated with the this transaction.
+ * May be null for an unassociated Global transaction.
+ * @return
+ */
+ String getAssociatedSession();
+
+ /**
+ * Get the scope for the transaction. Will be one of GLOBAL, LOCAL, or REQUEST
+ * @return
+ */
+ String getScope();
+
+ /**
+ * Returns the Xid string for GLOBAL transactions or the Transaction id string LOCAL/REQUEST.
+ * @return
+ */
+ String getId();
+
+
+ /**
+ * Get the local creation time.
+ * @return
+ */
+ long getCreatedTime();
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Transaction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+
+public interface Translator extends AdminObject{
+ public static final String EXECUTION_FACTORY_CLASS = "execution-factory-class"; //$NON-NLS-1$
+ public static final String TRANSLATOR_PROPERTY = "property"; //$NON-NLS-1$
+
+ /**
+ * Get the Translator type
+ * @return
+ */
+ public String getType();
+
+ /**
+ * Get the Translator description
+ * @return
+ */
+ public String getDescription();
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/Translator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.util.List;
+
+/**
+ * Represents a Virtual Database in the Teiid System.
+ * <br>A VDB has a name and a version.</br>
+ *
+ * <p>The identifier pattern for a VDB is <CODE>"name<{@link #DELIMITER_CHAR}>version"</CODE>,
+ * where the name of the VDB and its version represent its unique identifier in the Teiid system.
+ * There are no spaces allowed in a given VDB name, and VDB name must start with a letter.
+ * A version number is automatically assigned to a VDB when it is deployed into
+ * a system. A VDB is uniquely identified by <CODE>"name<{@link #DELIMITER_CHAR}>version"</CODE>.
+ * For example: <CODE>"Accounts<{@link #DELIMITER_CHAR}>1"</CODE>, <CODE>"UnifiedSales<{@link #DELIMITER_CHAR}>4</CODE>" etc.
+ * </p>
+ *
+ * @since 4.3
+ */
+public interface VDB extends AdminObject {
+
+ public static enum Status{INACTIVE, ACTIVE};
+
+ public enum ConnectionType {NONE, BY_VERSION, ANY}
+
+ /**
+ * @return Collection of Teiid Models
+ */
+ public List<Model> getModels();
+
+ /**
+ * @return the status
+ */
+ public Status getStatus();
+
+ /**
+ * @return the connection status
+ */
+ public ConnectionType getConnectionType();
+
+ /**
+ * @return the VDB version
+ */
+ public int getVersion();
+
+ /**
+ * Get the URL for the VDB
+ * @return
+ */
+ public String getUrl();
+
+ /**
+ * Get the description of the VDB
+ * @return
+ */
+ public String getDescription();
+
+ /**
+ * Shows any validity errors present in the VDB
+ * @return
+ */
+ public List<String> getValidityErrors();
+
+ /**
+ * Shows if VDB is a valid entity
+ * @return
+ */
+ public boolean isValid();
+
+ /**
+ * Get the data roles defined on this VDB
+ * @return
+ */
+ public List<DataPolicy> getDataPolicies();
+
+ /**
+ * Get the list of translators defined in the VDB
+ * @return
+ */
+ public List<Translator> getOverrideTranslators();
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/VDB.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+public interface WorkerPoolStatistics extends AdminObject {
+
+ /**
+ * Current active thread count
+ * @return
+ */
+ public int getActiveThreads();
+
+ /**
+ * Highest Active threads recorded so far
+ * @return
+ */
+ public int getHighestActiveThreads();
+
+
+ /**
+ * Queue Name
+ * @return
+ */
+ public String getQueueName();
+
+
+ /**
+ * Max number of active threads allowed
+ * @return
+ */
+ public int getMaxThreads();
+
+ /**
+ * @return Returns the number of requests queued.
+ * @since 4.3
+ */
+ public int getQueued();
+
+ /**
+ * @return The number of completed tasks
+ */
+ long getTotalCompleted();
+
+
+ /**
+ * @return The number of submitted tasks
+ */
+ long getTotalSubmitted();
+
+ /**
+ * @return Returns the highest queue size
+ */
+ public int getHighestQueued();
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/WorkerPoolStatistics.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.teiid.adminapi.AdminObject;
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+public abstract class AdminObjectImpl implements AdminObject, Serializable {
+
+ private static final long serialVersionUID = -6381303538713462682L;
+
+ private String name;
+
+ private ListOverMap<PropertyMetadata> properties = new ListOverMap<PropertyMetadata>(new KeyBuilder<PropertyMetadata>() {
+ private static final long serialVersionUID = 3687928367250819142L;
+
+ @Override
+ public String getKey(PropertyMetadata entry) {
+ return entry.getName();
+ }
+ });
+
+ private transient Map<String, Object> attachments = Collections.synchronizedMap(new HashMap<String, Object>());
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public Properties getProperties() {
+ Properties props = new Properties();
+ for (PropertyMetadata p:this.properties.getMap().values()) {
+ props.setProperty(p.getName(), p.getValue());
+ }
+ return props;
+ }
+
+ public void setProperties(Properties props) {
+ this.properties.clear();
+ if (props != null) {
+ for (String key:props.stringPropertyNames()) {
+ addProperty(key, props.getProperty(key));
+ }
+ }
+ }
+
+ public List<PropertyMetadata> getJAXBProperties(){
+ return properties;
+ }
+
+ public void setJAXBProperties(List<PropertyMetadata> props){
+ this.properties.clear();
+ if (props != null) {
+ for (PropertyMetadata prop:props) {
+ addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+
+ @Override
+ public String getPropertyValue(String name) {
+ PropertyMetadata prop = this.properties.getMap().get(name);
+ if (prop == null) {
+ return null;
+ }
+ return prop.getValue();
+ }
+
+ public void addProperty(String key, String value) {
+ this.properties.getMap().put(key, new PropertyMetadata(key, value));
+ }
+
+ /**
+ * Add attachment
+ *
+ * @param <T> the expected type
+ * @param attachment the attachment
+ * @param type the type
+ * @return any previous attachment
+ * @throws IllegalArgumentException for a null name, attachment or type
+ * @throws UnsupportedOperationException when not supported by the implementation
+ */
+ public <T> T addAttchment(Class<T> type, T attachment) {
+ if (type == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.put(type.getName(), attachment);
+ if (result == null)
+ return null;
+ return type.cast(result);
+
+ }
+
+ public Object addAttchment(String key, Object attachment) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.put(key, attachment);
+ if (result == null)
+ return null;
+ return result;
+ }
+
+ /**
+ * Remove attachment
+ *
+ * @param <T> the expected type
+ * @return the attachment or null if not present
+ * @param type the type
+ * @throws IllegalArgumentException for a null name or type
+ */
+ public <T> T removeAttachment(Class<T> type) {
+ if (type == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.remove(type.getName());
+ if (result == null)
+ return null;
+ return type.cast(result);
+ }
+
+ public Object removeAttachment(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.remove(key);
+ if (result == null)
+ return null;
+ return result;
+ }
+ /**
+ * Get attachment
+ *
+ * @param <T> the expected type
+ * @param type the type
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name or type
+ */
+ public <T> T getAttachment(Class<T> type) {
+ if (type == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.get(type.getName());
+ if (result == null)
+ return null;
+ return type.cast(result);
+ }
+
+ public Object getAttachment(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.get(key);
+ if (result == null)
+ return null;
+ return result;
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import org.teiid.adminapi.CacheStatistics;
+
+public class CacheStatisticsMetadata extends AdminObjectImpl implements CacheStatistics{
+
+ private static final long serialVersionUID = -3514505497661004560L;
+
+ private double hitRatio;
+ private int totalEntries;
+ private int requestCount;
+
+ @Override
+ public int getRequestCount() {
+ return requestCount;
+ }
+
+ public void setRequestCount(int count) {
+ this.requestCount = count;
+ }
+
+ @Override
+ public double getHitRatio() {
+ return this.hitRatio;
+ }
+
+ @Override
+ public int getTotalEntries() {
+ return this.totalEntries;
+ }
+
+ public void setHitRatio(double value) {
+ this.hitRatio = value;
+ }
+
+ public void setTotalEntries(int value) {
+ this.totalEntries = value;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("hitRatio=").append(hitRatio);//$NON-NLS-1$
+ sb.append("; totalEntries=").append(totalEntries); //$NON-NLS-1$
+ sb.append("; requestCount=").append(requestCount); //$NON-NLS-1$
+ return sb.toString();
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.teiid.adminapi.AdminException;
+
+
+public interface DQPManagement {
+ List<RequestMetadata> getRequestsForSession(String sessionId) ;
+ List<RequestMetadata> getRequests();
+ WorkerPoolStatisticsMetadata getWorkerPoolStatistics();
+ void terminateSession(String terminateeId);
+ boolean cancelRequest(String sessionId, long requestId) throws AdminException;
+ Collection<String> getCacheTypes();
+ void clearCache(String cacheType);
+ void clearCache(String cacheType, String vdbName, int version);
+ Collection<SessionMetadata> getActiveSessions() throws AdminException;
+ int getActiveSessionsCount() throws AdminException;
+ Collection<TransactionMetadata> getTransactions();
+ void terminateTransaction(String xid) throws AdminException ;
+ List<RequestMetadata> getLongRunningRequests();
+ List<RequestMetadata> getRequestsUsingVDB(String vdbName, int vdbVersion) throws AdminException;
+ CacheStatisticsMetadata getCacheStatistics(String cacheType);
+ List<List> executeQuery(String vdbName, int version, String command, long timoutInMilli) throws AdminException;
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,291 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.*;
+
+import org.teiid.adminapi.DataPolicy;
+
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "", propOrder = {
+ "description",
+ "permissions",
+ "mappedRoleNames"
+})
+public class DataPolicyMetadata implements DataPolicy, Serializable {
+ private static final long serialVersionUID = -4119646357275977190L;
+
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlElement(name = "description")
+ protected String description;
+ @XmlAttribute(name = "any-authenticated")
+ protected boolean anyAuthenticated;
+ @XmlAttribute(name = "allow-create-temporary-tables")
+ protected Boolean allowCreateTemporaryTables;
+
+ @XmlElement(name = "permission")
+ protected PermissionMap permissions = new PermissionMap(new KeyBuilder<PermissionMetaData>() {
+ private static final long serialVersionUID = -6992984146431492449L;
+ @Override
+ public String getKey(PermissionMetaData entry) {
+ return entry.getResourceName().toLowerCase();
+ }
+ });
+
+ @XmlElement(name = "mapped-role-name")
+ protected List<String> mappedRoleNames = new ArrayList<String>();
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String value) {
+ this.description = value;
+ }
+
+ @Override
+ public List<DataPermission> getPermissions() {
+ return new ArrayList<DataPermission>(this.permissions.getMap().values());
+ }
+
+ public void setPermissions(List<DataPermission> permissions) {
+ this.permissions.getMap().clear();
+ for (DataPermission permission:permissions) {
+ this.permissions.add((PermissionMetaData)permission);
+ }
+ }
+
+ public void addPermission(PermissionMetaData... permissions) {
+ for (PermissionMetaData permission:permissions) {
+ this.permissions.add(permission);
+ }
+ }
+
+ @Override
+ public List<String> getMappedRoleNames() {
+ return mappedRoleNames;
+ }
+
+ public void setMappedRoleNames(List<String> names) {
+ this.mappedRoleNames.clear();
+ this.mappedRoleNames.addAll(names);
+ }
+
+ public void addMappedRoleName(String name) {
+ this.mappedRoleNames.add(name);
+ }
+
+ public boolean allows(String resourceName, DataPolicy.PermissionType type) {
+ resourceName = resourceName.toLowerCase();
+ while (resourceName.length() > 0) {
+ PermissionMetaData p = this.permissions.getMap().get(resourceName);
+ if (p != null) {
+ Boolean allowed = p.allows(type);
+ if (allowed != null) {
+ return allowed;
+ }
+ }
+ resourceName = resourceName.substring(0, Math.max(0, resourceName.lastIndexOf('.')));
+ }
+ return false;
+ }
+
+
+ @XmlAccessorType(XmlAccessType.NONE)
+ @XmlType(name = "", propOrder = {
+ "resourceName",
+ "allowCreate",
+ "allowRead",
+ "allowUpdate",
+ "allowDelete",
+ "allowExecute",
+ "allowAlter"
+ })
+ public static class PermissionMetaData implements DataPermission, Serializable {
+ private static final long serialVersionUID = 7034744531663164277L;
+
+ // XML based fields
+ private String resourceName;
+ @XmlElement(name = "allow-create")
+ protected Boolean allowCreate;
+ @XmlElement(name = "allow-read")
+ protected Boolean allowRead;
+ @XmlElement(name = "allow-update")
+ protected Boolean allowUpdate;
+ @XmlElement(name = "allow-delete")
+ protected Boolean allowDelete;
+ @XmlElement(name = "allow-execute")
+ protected Boolean allowExecute;
+ @XmlElement(name = "allow-alter")
+ protected Boolean allowAlter;
+
+ @Override
+ @XmlElement(name = "resource-name", required = true)
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String value) {
+ this.resourceName = value;
+ }
+
+ @Override
+ public Boolean getAllowCreate() {
+ return allowCreate;
+ }
+
+ public void setAllowCreate(Boolean value) {
+ this.allowCreate = value;
+ }
+
+ @Override
+ public Boolean getAllowRead() {
+ return allowRead;
+ }
+
+ public void setAllowRead(Boolean value) {
+ this.allowRead = value;
+ }
+
+ @Override
+ public Boolean getAllowUpdate() {
+ return allowUpdate;
+ }
+
+ public void setAllowUpdate(Boolean value) {
+ this.allowUpdate = value;
+ }
+
+ @Override
+ public Boolean getAllowDelete() {
+ return allowDelete;
+ }
+
+ public void setAllowDelete(Boolean value) {
+ this.allowDelete = value;
+ }
+
+ public String getType() {
+ StringBuilder sb = new StringBuilder();
+ if (Boolean.TRUE.equals(getAllowCreate())) {
+ sb.append("C");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowRead())) {
+ sb.append("R");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowUpdate())) {
+ sb.append("U");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowDelete())) {
+ sb.append("D");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowExecute())) {
+ sb.append("E");//$NON-NLS-1$
+ }
+ if (Boolean.TRUE.equals(getAllowAlter())) {
+ sb.append("A");//$NON-NLS-1$
+ }
+ return sb.toString();
+ }
+
+ public Boolean allows(PermissionType type) {
+ switch (type) {
+ case ALTER:
+ return getAllowAlter();
+ case CREATE:
+ return getAllowCreate();
+ case EXECUTE:
+ if (getAllowExecute() != null) {
+ return getAllowExecute();
+ }
+ case READ:
+ return getAllowRead();
+ case UPDATE:
+ return getAllowUpdate();
+ case DELETE:
+ return getAllowDelete();
+ }
+ throw new AssertionError();
+ }
+
+ @Override
+ public Boolean getAllowAlter() {
+ return allowAlter;
+ }
+
+ @Override
+ public Boolean getAllowExecute() {
+ return allowExecute;
+ }
+
+ public void setAllowAlter(Boolean allowAlter) {
+ this.allowAlter = allowAlter;
+ }
+
+ public void setAllowExecute(Boolean allowExecute) {
+ this.allowExecute = allowExecute;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getResourceName());
+ sb.append("["); //$NON-NLS-1$
+ sb.append(getType());
+ sb.append("]");//$NON-NLS-1$
+ return sb.toString();
+ }
+ }
+
+ public Boolean isAllowCreateTemporaryTables() {
+ return allowCreateTemporaryTables;
+ }
+
+ public void setAllowCreateTemporaryTables(Boolean allowCreateTemporaryTables) {
+ this.allowCreateTemporaryTables = allowCreateTemporaryTables;
+ }
+
+ @Override
+ public boolean isAnyAuthenticated() {
+ return this.anyAuthenticated;
+ }
+
+ public void setAnyAuthenticated(boolean anyAuthenticated) {
+ this.anyAuthenticated = anyAuthenticated;
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.AbstractList;
+import java.util.LinkedHashMap;
+import java.util.Set;
+
+class ListOverMap<E> extends AbstractList<E> implements Serializable {
+
+ private static final long serialVersionUID = 5171741731121210240L;
+
+ protected LinkedHashMap<String, E> map = new LinkedHashMap<String, E>();
+ protected KeyBuilder<E> builder;
+
+ public ListOverMap(KeyBuilder<E> builder) {
+ this.builder = builder;
+ }
+
+ public LinkedHashMap<String, E> getMap() {
+ return map;
+ }
+
+ @Override
+ public void add(int index, E element) {
+ this.map.put(builder.getKey(element), element);
+ }
+
+ @Override
+ public E remove(int index) {
+ String key = getKey(index);
+ if (key == null) {
+ throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return this.map.remove(key);
+ }
+
+ @Override
+ public E get(int index) {
+ String key = getKey(index);
+ if (key == null) {
+ throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return this.map.get(key);
+ }
+
+ private String getKey(int index) {
+ Set<String> keys = this.map.keySet();
+ int i = 0;
+ for (String key:keys) {
+ if (i == index) {
+ return key;
+ }
+ i++;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return this.map.size();
+ }
+}
+
+interface KeyBuilder<E> extends Serializable {
+ String getKey(E entry);
+}
+
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,1071 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.teiid.adminapi.AdminPlugin;
+import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.Request.ProcessingState;
+import org.teiid.adminapi.Request.ThreadState;
+import org.teiid.adminapi.VDB.ConnectionType;
+import org.teiid.adminapi.VDB.Status;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+
+
+public class MetadataMapper {
+ private static final String VDBNAME = "vdb-name"; //$NON-NLS-1$
+ private static final String CONNECTIONTYPE = "connection-type"; //$NON-NLS-1$
+ private static final String STATUS = "status"; //$NON-NLS-1$
+ private static final String VERSION = "vdb-version"; //$NON-NLS-1$
+ private static final String URL = "url"; //$NON-NLS-1$
+ private static final String MODELS = "models"; //$NON-NLS-1$
+ private static final String OVERRIDE_TRANSLATORS = "override-translators"; //$NON-NLS-1$
+ private static final String DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String DYNAMIC = "dynamic"; //$NON-NLS-1$
+ private static final String DATA_POLICIES = "data-policies"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(VDBMetaData vdb, ModelNode node) {
+ if (vdb == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(VDBNAME).set(vdb.getName());
+ node.get(CONNECTIONTYPE).set(vdb.getConnectionType().toString());
+ node.get(STATUS).set(vdb.getStatus().toString());
+ node.get(VERSION).set(vdb.getVersion());
+ if (vdb.getUrl() != null) {
+ }
+ if (vdb.getDescription() != null) {
+ node.get(DESCRIPTION).set(vdb.getDescription());
+ }
+ node.get(DYNAMIC).set(vdb.isDynamic());
+
+ //PROPERTIES
+ List<PropertyMetadata> properties = vdb.getJAXBProperties();
+ if (properties!= null && !properties.isEmpty()) {
+ ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
+ for (PropertyMetadata prop:properties) {
+ propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
+ }
+ }
+
+ // MODELS
+ Map<String, ModelMetaData> models = vdb.getModelMetaDatas();
+ if (models != null && !models.isEmpty()) {
+ ModelNode modelNodes = node.get(CHILDREN, MODELS);
+ for(ModelMetaData model:models.values()) {
+ modelNodes.add(ModelMetadataMapper.wrap(model, new ModelNode()));
+ }
+ }
+
+ // OVERRIDE_TRANSLATORS
+ List<Translator> translators = vdb.getOverrideTranslators();
+ if (translators != null && !translators.isEmpty()) {
+ ModelNode translatorNodes = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
+ for (Translator translator:translators) {
+ translatorNodes.add(VDBTranslatorMetaDataMapper.wrap((VDBTranslatorMetaData)translator, new ModelNode()));
+ }
+ }
+
+ // DATA_POLICIES
+ List<DataPolicy> policies = vdb.getDataPolicies();
+ if (policies != null && !policies.isEmpty()) {
+ ModelNode dataPoliciesNodes = node.get(CHILDREN, DATA_POLICIES);
+ for (DataPolicy policy:policies) {
+ dataPoliciesNodes.add(DataPolicyMetadataMapper.wrap((DataPolicyMetadata)policy, new ModelNode()));
+ }
+ }
+ return node;
+ }
+
+ public static VDBMetaData unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ VDBMetaData vdb = new VDBMetaData();
+ if (node.has(VDBNAME)) {
+ vdb.setName(node.get(VDBNAME).asString());
+ }
+ if (node.has(CONNECTIONTYPE)) {
+ vdb.setConnectionType(node.get(CONNECTIONTYPE).asString());
+ }
+ if (node.has(STATUS)) {
+ vdb.setStatus(node.get(STATUS).asString());
+ }
+ if (node.has(VERSION)) {
+ vdb.setVersion(node.get(VERSION).asInt());
+ }
+ if (node.has(URL)) {
+ vdb.setUrl(node.get(URL).asString());
+ }
+ if(node.has(DESCRIPTION)) {
+ vdb.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(DYNAMIC)) {
+ vdb.setDynamic(node.get(DYNAMIC).asBoolean());
+ }
+
+ //PROPERTIES
+ if (node.get(CHILDREN, PROPERTIES).isDefined()) {
+ List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
+ for (ModelNode propNode:propNodes) {
+ PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
+ if (prop != null) {
+ vdb.addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+
+ // MODELS
+ if (node.get(CHILDREN, MODELS).isDefined()) {
+ List<ModelNode> modelNodes = node.get(CHILDREN, MODELS).asList();
+ for(ModelNode modelNode:modelNodes) {
+ ModelMetaData model = ModelMetadataMapper.unwrap(modelNode);
+ if (model != null) {
+ vdb.addModel(model);
+ }
+ }
+ }
+
+ // OVERRIDE_TRANSLATORS
+ if (node.get(CHILDREN, OVERRIDE_TRANSLATORS).isDefined()) {
+ List<ModelNode> translatorNodes = node.get(CHILDREN, OVERRIDE_TRANSLATORS).asList();
+ for (ModelNode translatorNode:translatorNodes) {
+ VDBTranslatorMetaData translator = VDBTranslatorMetaDataMapper.unwrap(translatorNode);
+ if (translator != null) {
+ vdb.addOverideTranslator(translator);
+ }
+ }
+ }
+
+ // DATA_POLICIES
+ if (node.get(CHILDREN, DATA_POLICIES).isDefined()) {
+ List<ModelNode> policiesNodes = node.get(CHILDREN, DATA_POLICIES).asList();
+ for (ModelNode policyNode:policiesNodes) {
+ DataPolicyMetadata policy = DataPolicyMetadataMapper.unwrap(policyNode);
+ if (policy != null) {
+ vdb.addDataPolicy(policy);
+ }
+
+ }
+ }
+ return vdb;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, VDBNAME, ModelType.STRING, true);
+
+ ModelNode connectionsAllowed = new ModelNode();
+ connectionsAllowed.add(ConnectionType.NONE.toString());
+ connectionsAllowed.add(ConnectionType.ANY.toString());
+ connectionsAllowed.add(ConnectionType.BY_VERSION.toString());
+ addAttribute(node, CONNECTIONTYPE, ModelType.STRING, false).get(ALLOWED).set(connectionsAllowed);
+
+ ModelNode statusAllowed = new ModelNode();
+ statusAllowed.add(Status.ACTIVE.toString());
+ statusAllowed.add(Status.INACTIVE.toString());
+ addAttribute(node, STATUS, ModelType.STRING, true).get(ALLOWED).set(statusAllowed);
+
+ addAttribute(node, VERSION, ModelType.INT, true);
+ addAttribute(node, URL, ModelType.STRING, false);
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, DYNAMIC, ModelType.BOOLEAN, false);
+
+ ModelNode props = node.get(CHILDREN, PROPERTIES);
+ props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
+ PropertyMetaDataMapper.describe(props);
+
+ ModelNode models = node.get(CHILDREN, MODELS);
+ ModelMetadataMapper.describe(models);
+ models.get(DESCRIPTION).set(AdminPlugin.Util.getString(MODELS+DOT_DESC));
+ models.get(MIN_OCCURS).set(1);
+
+ ModelNode translators = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
+ translators.get(DESCRIPTION).set(AdminPlugin.Util.getString(OVERRIDE_TRANSLATORS+DOT_DESC));
+ VDBTranslatorMetaDataMapper.describe(translators);
+
+ ModelNode dataPolicies = node.get(CHILDREN, DATA_POLICIES);
+ dataPolicies.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_POLICIES+DOT_DESC));
+ DataPolicyMetadataMapper.describe(dataPolicies);
+ return node;
+ }
+
+ /**
+ * model metadata mapper
+ */
+ public static class ModelMetadataMapper {
+ private static final String MODEL_NAME = "model-name"; //$NON-NLS-1$
+ private static final String DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String VISIBLE = "visible"; //$NON-NLS-1$
+ private static final String MODEL_TYPE = "model-type"; //$NON-NLS-1$
+ private static final String MODELPATH = "model-path"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String SOURCE_MAPPINGS = "source-mappings"; //$NON-NLS-1$
+ private static final String VALIDITY_ERRORS = "validity-errors"; //$NON-NLS-1$
+
+ public static ModelNode wrap(ModelMetaData model, ModelNode node) {
+ if (model == null) {
+ return null;
+ }
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ node.get(MODEL_NAME).set(model.getName());
+ if (model.getDescription() != null) {
+ node.get(DESCRIPTION).set(model.getDescription());
+ }
+ node.get(VISIBLE).set(model.isVisible());
+ node.get(MODEL_TYPE).set(model.getModelType().toString());
+ if (model.getPath() != null) {
+ node.get(MODELPATH).set(model.getPath());
+ }
+
+ List<PropertyMetadata> properties = model.getJAXBProperties();
+ if (properties!= null && !properties.isEmpty()) {
+ ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
+ for (PropertyMetadata prop:properties) {
+ propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
+ }
+ }
+
+ List<SourceMappingMetadata> sources = model.getSourceMappings();
+ if (sources != null && !sources.isEmpty()) {
+ ModelNode sourceMappingNode = node.get(CHILDREN, SOURCE_MAPPINGS);
+ for(SourceMappingMetadata source:sources) {
+ sourceMappingNode.add(SourceMappingMetadataMapper.wrap(source, new ModelNode()));
+ }
+ }
+
+ List<ValidationError> errors = model.getErrors();
+ if (errors != null && !errors.isEmpty()) {
+ ModelNode errorsNode = node.get(CHILDREN, VALIDITY_ERRORS);
+ for (ValidationError error:errors) {
+ errorsNode.add(ValidationErrorMapper.wrap(error));
+ }
+ }
+ return node;
+ }
+
+ public static ModelMetaData unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+
+ ModelMetaData model = new ModelMetaData();
+ if (node.has(MODEL_NAME)) {
+ model.setName(node.get(MODEL_NAME).asString());
+ }
+ if (node.has(DESCRIPTION)) {
+ model.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(VISIBLE)) {
+ model.setVisible(node.get(VISIBLE).asBoolean());
+ }
+ if(node.has(MODEL_TYPE)) {
+ model.setModelType(node.get(MODEL_TYPE).asString());
+ }
+ if(node.has(MODELPATH)) {
+ model.setPath(node.get(MODELPATH).asString());
+ }
+
+ if (node.get(CHILDREN, PROPERTIES).isDefined()) {
+ List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
+ for (ModelNode propNode:propNodes) {
+ PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
+ if (prop != null) {
+ model.addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+
+ if (node.get(CHILDREN, SOURCE_MAPPINGS).isDefined()) {
+ List<ModelNode> sourceMappingNodes = node.get(CHILDREN, SOURCE_MAPPINGS).asList();
+ for (ModelNode sourceMapping:sourceMappingNodes) {
+ SourceMappingMetadata source = SourceMappingMetadataMapper.unwrap(sourceMapping);
+ if (source != null) {
+ model.addSourceMapping(source);
+ }
+ }
+ }
+
+ if (node.get(CHILDREN, VALIDITY_ERRORS).isDefined()) {
+ List<ModelNode> errorNodes = node.get(CHILDREN, VALIDITY_ERRORS).asList();
+ for(ModelNode errorNode:errorNodes) {
+ ValidationError error = ValidationErrorMapper.unwrap(errorNode);
+ if (error != null) {
+ model.addError(error);
+ }
+ }
+ }
+ return model;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ ModelNode modelTypes = new ModelNode();
+ modelTypes.add(Model.Type.PHYSICAL.toString());
+ modelTypes.add(Model.Type.VIRTUAL.toString());
+ modelTypes.add(Model.Type.FUNCTION.toString());
+ modelTypes.add(Model.Type.OTHER.toString());
+ addAttribute(node, MODEL_NAME, ModelType.STRING, true).get(ALLOWED).set(modelTypes);
+
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, VISIBLE, ModelType.BOOLEAN, false);
+ addAttribute(node, MODEL_TYPE, ModelType.STRING, true);
+ addAttribute(node, MODELPATH, ModelType.STRING, false);
+
+ ModelNode props = node.get(CHILDREN, PROPERTIES);
+ props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
+ PropertyMetaDataMapper.describe(props);
+
+ ModelNode source = node.get(CHILDREN, SOURCE_MAPPINGS);
+ source.get(DESCRIPTION).set(AdminPlugin.Util.getString(SOURCE_MAPPINGS+DOT_DESC));
+ SourceMappingMetadataMapper.describe(source);
+
+ ModelNode errors = node.get(CHILDREN, VALIDITY_ERRORS);
+ errors.get(DESCRIPTION).set(AdminPlugin.Util.getString(VALIDITY_ERRORS+DOT_DESC));
+ ValidationErrorMapper.describe(errors);
+
+ return node;
+ }
+ }
+
+ /**
+ * validation error mapper
+ */
+ public static class ValidationErrorMapper {
+ private static final String ERROR_PATH = "error-path"; //$NON-NLS-1$
+ private static final String SEVERITY = "severity"; //$NON-NLS-1$
+ private static final String MESSAGE = "message"; //$NON-NLS-1$
+
+ public static ModelNode wrap(ValidationError error) {
+ if (error == null) {
+ return null;
+ }
+
+ ModelNode node = new ModelNode();
+ node.get(TYPE).set(ModelType.OBJECT);
+ if (error.getPath() != null) {
+ node.get(ERROR_PATH).set(error.getPath());
+ }
+ node.get(SEVERITY).set(error.getSeverity());
+ node.get(MESSAGE).set(error.getValue());
+
+ return node;
+ }
+
+ public static ValidationError unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+
+ ValidationError error = new ValidationError();
+ if (node.has(ERROR_PATH)) {
+ error.setPath(node.get(ERROR_PATH).asString());
+ }
+ if (node.has(SEVERITY)) {
+ error.setSeverity(node.get(SEVERITY).asString());
+ }
+ if(node.has(MESSAGE)) {
+ error.setValue(node.get(MESSAGE).asString());
+ }
+ return error;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, ERROR_PATH, ModelType.STRING, false);
+ addAttribute(node, SEVERITY, ModelType.STRING, true);
+ addAttribute(node, MESSAGE, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ /**
+ * Source Mapping Metadata mapper
+ */
+ public static class SourceMappingMetadataMapper {
+ private static final String SOURCE_NAME = "source-name"; //$NON-NLS-1$
+ private static final String JNDI_NAME = "jndi-name"; //$NON-NLS-1$
+ private static final String TRANSLATOR_NAME = "translator-name"; //$NON-NLS-1$
+
+ public static ModelNode wrap(SourceMappingMetadata source, ModelNode node) {
+ if (source == null) {
+ return null;
+ }
+
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ node.get(SOURCE_NAME).set(source.getName());
+ node.get(JNDI_NAME).set(source.getConnectionJndiName());
+ node.get(TRANSLATOR_NAME).set(source.getTranslatorName());
+ return node;
+ }
+
+ public static SourceMappingMetadata unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+ SourceMappingMetadata source = new SourceMappingMetadata();
+ if (node.has(SOURCE_NAME)) {
+ source.setName(node.get(SOURCE_NAME).asString());
+ }
+ if (node.has(JNDI_NAME)) {
+ source.setConnectionJndiName(node.get(JNDI_NAME).asString());
+ }
+ if (node.has(TRANSLATOR_NAME)) {
+ source.setTranslatorName(node.get(TRANSLATOR_NAME).asString());
+ }
+ return source;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, SOURCE_NAME, ModelType.STRING, true);
+ addAttribute(node, JNDI_NAME, ModelType.STRING, true);
+ addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ /**
+ * Source Mapping Metadata mapper
+ */
+ public static class VDBTranslatorMetaDataMapper {
+ private static final String TRANSLATOR_NAME = "translator-name"; //$NON-NLS-1$
+ private static final String BASETYPE = "base-type"; //$NON-NLS-1$
+ private static final String DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String MODULE_NAME = "module-name"; //$NON-NLS-1$
+
+ public static ModelNode wrap(VDBTranslatorMetaData translator, ModelNode node) {
+ if (translator == null) {
+ return null;
+ }
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ node.get(TRANSLATOR_NAME).set(translator.getName());
+ if (translator.getType() != null) {
+ node.get(BASETYPE).set(translator.getType());
+ }
+ if (translator.getDescription() != null) {
+ node.get(DESCRIPTION).set(translator.getDescription());
+ }
+
+ if (translator.getModuleName() != null) {
+ node.get(MODULE_NAME).set(translator.getModuleName());
+ }
+
+ List<PropertyMetadata> properties = translator.getJAXBProperties();
+ if (properties!= null && !properties.isEmpty()) {
+ ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
+ for (PropertyMetadata prop:properties) {
+ propsNode.add(PropertyMetaDataMapper.wrap(prop, new ModelNode()));
+ }
+ }
+ return node;
+ }
+
+ public static VDBTranslatorMetaData unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+ VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
+ if (node.has(TRANSLATOR_NAME)) {
+ translator.setName(node.get(TRANSLATOR_NAME).asString());
+ }
+ if (node.has(BASETYPE)) {
+ translator.setType(node.get(BASETYPE).asString());
+ }
+ if (node.has(DESCRIPTION)) {
+ translator.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(MODULE_NAME)) {
+ translator.setModuleName(node.get(MODULE_NAME).asString());
+ }
+
+ if (node.get(CHILDREN,PROPERTIES).isDefined()) {
+ List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
+ for (ModelNode propNode:propNodes) {
+ PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
+ if (prop != null) {
+ translator.addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+ return translator;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
+ addAttribute(node, BASETYPE, ModelType.STRING, true);
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, MODULE_NAME, ModelType.STRING, false);
+
+ ModelNode props = node.get(CHILDREN, PROPERTIES);
+ props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
+ PropertyMetaDataMapper.describe(props);
+ return node;
+ }
+ }
+
+ /**
+ * Property Metadata mapper
+ */
+ public static class PropertyMetaDataMapper {
+ private static final String PROPERTY_NAME = "property-name"; //$NON-NLS-1$
+ private static final String PROPERTY_VALUE = "property-value"; //$NON-NLS-1$
+
+ public static ModelNode wrap(PropertyMetadata property, ModelNode node) {
+ if (property == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(PROPERTY_NAME).set(property.getName());
+ node.get(PROPERTY_VALUE).set(property.getValue());
+
+ return node;
+ }
+
+ public static PropertyMetadata unwrap(ModelNode node) {
+ if(node == null) {
+ return null;
+ }
+ PropertyMetadata property = new PropertyMetadata();
+ if (node.has(PROPERTY_NAME)) {
+ property.setName(node.get(PROPERTY_NAME).asString());
+ }
+ if(node.has(PROPERTY_VALUE)) {
+ property.setValue(node.get(PROPERTY_VALUE).asString());
+ }
+ return property;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, PROPERTY_NAME, ModelType.STRING, true);
+ addAttribute(node, PROPERTY_VALUE, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ /**
+ * DataPolicy Metadata mapper
+ */
+ public static class DataPolicyMetadataMapper {
+ private static final String POLICY_NAME = "policy-name"; //$NON-NLS-1$
+ private static final String DATA_PERMISSIONS = "data-permissions"; //$NON-NLS-1$
+ private static final String MAPPED_ROLE_NAMES = "mapped-role-names"; //$NON-NLS-1$
+ private static final String ALLOW_CREATE_TEMP_TABLES = "allow-create-temp-tables"; //$NON-NLS-1$
+ private static final String ANY_AUTHENTICATED = "any-authenticated"; //$NON-NLS-1$
+
+ public static ModelNode wrap(DataPolicyMetadata policy, ModelNode node) {
+ if (policy == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(POLICY_NAME).set(policy.getName());
+ if (policy.getDescription() != null) {
+ node.get(DESCRIPTION).set(policy.getDescription());
+ }
+ if (policy.isAllowCreateTemporaryTables() != null) {
+ node.get(ALLOW_CREATE_TEMP_TABLES).set(policy.isAllowCreateTemporaryTables());
+ }
+ node.get(ANY_AUTHENTICATED).set(policy.isAnyAuthenticated());
+
+ //DATA_PERMISSIONS
+ List<DataPolicy.DataPermission> permissions = policy.getPermissions();
+ if (permissions != null && !permissions.isEmpty()) {
+ ModelNode permissionNodes = node.get(CHILDREN, DATA_PERMISSIONS);
+ for (DataPolicy.DataPermission dataPermission:permissions) {
+ permissionNodes.add(PermissionMetaDataMapper.wrap((PermissionMetaData)dataPermission, new ModelNode()));
+ }
+ }
+
+ //MAPPED_ROLE_NAMES
+ if (policy.getMappedRoleNames() != null && !policy.getMappedRoleNames().isEmpty()) {
+ ModelNode mappedRoleNodes = node.get(CHILDREN, MAPPED_ROLE_NAMES);
+ for (String role:policy.getMappedRoleNames()) {
+ mappedRoleNodes.add(role);
+ }
+ }
+ return node;
+ }
+
+ public static DataPolicyMetadata unwrap(ModelNode node) {
+ if(node == null) {
+ return null;
+ }
+ DataPolicyMetadata policy = new DataPolicyMetadata();
+ if (node.has(POLICY_NAME)) {
+ policy.setName(node.get(POLICY_NAME).asString());
+ }
+ if (node.has(DESCRIPTION)) {
+ policy.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(ALLOW_CREATE_TEMP_TABLES)) {
+ policy.setAllowCreateTemporaryTables(node.get(ALLOW_CREATE_TEMP_TABLES).asBoolean());
+ }
+ if (node.has(ANY_AUTHENTICATED)) {
+ policy.setAnyAuthenticated(node.get(ANY_AUTHENTICATED).asBoolean());
+ }
+
+ //DATA_PERMISSIONS
+ if (node.get(CHILDREN, DATA_PERMISSIONS).isDefined()) {
+ List<ModelNode> permissionNodes = node.get(CHILDREN, DATA_PERMISSIONS).asList();
+ for (ModelNode permissionNode:permissionNodes) {
+ PermissionMetaData permission = PermissionMetaDataMapper.unwrap(permissionNode);
+ if (permission != null) {
+ policy.addPermission(permission);
+ }
+ }
+ }
+
+ //MAPPED_ROLE_NAMES
+ if (node.get(CHILDREN, MAPPED_ROLE_NAMES).isDefined()) {
+ List<ModelNode> roleNameNodes = node.get(CHILDREN, MAPPED_ROLE_NAMES).asList();
+ for (ModelNode roleNameNode:roleNameNodes) {
+ policy.addMappedRoleName(roleNameNode.asString());
+ }
+ }
+ return policy;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, POLICY_NAME, ModelType.STRING, true);
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, ALLOW_CREATE_TEMP_TABLES, ModelType.BOOLEAN, false);
+ addAttribute(node, ANY_AUTHENTICATED, ModelType.BOOLEAN, false);
+
+ ModelNode permissions = node.get(CHILDREN, DATA_PERMISSIONS);
+ PropertyMetaDataMapper.describe(permissions);
+ permissions.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_PERMISSIONS+DOT_DESC));
+ permissions.get(MIN_OCCURS).set(1);
+
+ ModelNode roleNames = node.get(CHILDREN, MAPPED_ROLE_NAMES);
+ roleNames.get(TYPE).set(ModelType.LIST);
+ roleNames.get(DESCRIPTION).set(AdminPlugin.Util.getString(MAPPED_ROLE_NAMES+DOT_DESC));
+ roleNames.get("value-type").set(ModelType.STRING); //$NON-NLS-1$
+ return node;
+ }
+ }
+
+ public static class PermissionMetaDataMapper{
+ private static final String RESOURCE_NAME = "resource-name"; //$NON-NLS-1$
+ private static final String ALLOW_CREATE = "allow-create"; //$NON-NLS-1$
+ private static final String ALLOW_DELETE = "allow-delete"; //$NON-NLS-1$
+ private static final String ALLOW_UPADTE = "allow-update"; //$NON-NLS-1$
+ private static final String ALLOW_READ = "allow-read"; //$NON-NLS-1$
+ private static final String ALLOW_EXECUTE = "allow-execute"; //$NON-NLS-1$
+ private static final String ALLOW_ALTER = "allow-alter"; //$NON-NLS-1$
+
+
+
+ public static ModelNode wrap(PermissionMetaData permission, ModelNode node) {
+ if (permission == null) {
+ return null;
+ }
+
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(RESOURCE_NAME).set(permission.getResourceName());
+ if (permission.getAllowCreate() != null) {
+ node.get(ALLOW_CREATE).set(permission.getAllowCreate().booleanValue());
+ }
+ if (permission.getAllowDelete() != null) {
+ node.get(ALLOW_DELETE).set(permission.getAllowDelete().booleanValue());
+ }
+ if (permission.getAllowUpdate() != null) {
+ node.get(ALLOW_UPADTE).set(permission.getAllowUpdate().booleanValue());
+ }
+ if (permission.getAllowRead() != null) {
+ node.get(ALLOW_READ).set(permission.getAllowRead().booleanValue());
+ }
+ if (permission.getAllowExecute() != null) {
+ node.get(ALLOW_EXECUTE).set(permission.getAllowExecute().booleanValue());
+ }
+ if(permission.getAllowAlter() != null) {
+ node.get(ALLOW_ALTER).set(permission.getAllowAlter().booleanValue());
+ }
+ return node;
+ }
+
+ public static PermissionMetaData unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+
+ PermissionMetaData permission = new PermissionMetaData();
+ if (node.get(RESOURCE_NAME) != null) {
+ permission.setResourceName(node.get(RESOURCE_NAME).asString());
+ }
+ if (node.has(ALLOW_CREATE)) {
+ permission.setAllowCreate(node.get(ALLOW_CREATE).asBoolean());
+ }
+ if (node.has(ALLOW_DELETE)) {
+ permission.setAllowDelete(node.get(ALLOW_DELETE).asBoolean());
+ }
+ if (node.has(ALLOW_UPADTE)) {
+ permission.setAllowUpdate(node.get(ALLOW_UPADTE).asBoolean());
+ }
+ if (node.has(ALLOW_READ)) {
+ permission.setAllowRead(node.get(ALLOW_READ).asBoolean());
+ }
+ if (node.has(ALLOW_EXECUTE)) {
+ permission.setAllowExecute(node.get(ALLOW_EXECUTE).asBoolean());
+ }
+ if (node.has(ALLOW_ALTER)) {
+ permission.setAllowAlter(node.get(ALLOW_ALTER).asBoolean());
+ }
+ return permission;
+ }
+ public static ModelNode describe(ModelNode node) {
+ addAttribute(node, RESOURCE_NAME, ModelType.STRING, true);
+ addAttribute(node, ALLOW_CREATE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_DELETE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_UPADTE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_READ, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_EXECUTE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_ALTER, ModelType.BOOLEAN, false);
+ return node;
+ }
+ }
+
+ public static class CacheStatisticsMetadataMapper {
+ private static final String HITRATIO = "hit-ratio"; //$NON-NLS-1$
+ private static final String TOTAL_ENTRIES = "total-entries"; //$NON-NLS-1$
+ private static final String REQUEST_COUNT = "request-count"; //$NON-NLS-1$
+
+ public static ModelNode wrap(CacheStatisticsMetadata object, ModelNode node) {
+ if (object == null)
+ return null;
+
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(TOTAL_ENTRIES).set(object.getTotalEntries());
+ node.get(HITRATIO).set(object.getHitRatio());
+ node.get(REQUEST_COUNT).set(object.getRequestCount());
+
+ return node;
+ }
+
+ public static CacheStatisticsMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ CacheStatisticsMetadata cache = new CacheStatisticsMetadata();
+ cache.setTotalEntries(node.get(TOTAL_ENTRIES).asInt());
+ cache.setHitRatio(node.get(HITRATIO).asDouble());
+ cache.setRequestCount(node.get(REQUEST_COUNT).asInt());
+ return cache;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, TOTAL_ENTRIES, ModelType.STRING, true);
+ addAttribute(node, HITRATIO, ModelType.STRING, true);
+ addAttribute(node, REQUEST_COUNT, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ public static class RequestMetadataMapper {
+ private static final String TRANSACTION_ID = "transaction-id"; //$NON-NLS-1$
+ private static final String NODE_ID = "node-id"; //$NON-NLS-1$
+ private static final String SOURCE_REQUEST = "source-request"; //$NON-NLS-1$
+ private static final String COMMAND = "command"; //$NON-NLS-1$
+ private static final String START_TIME = "start-time"; //$NON-NLS-1$
+ private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
+ private static final String EXECUTION_ID = "execution-id"; //$NON-NLS-1$
+ private static final String STATE = "processing-state"; //$NON-NLS-1$
+ private static final String THREAD_STATE = "thread-state"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(RequestMetadata request, ModelNode node) {
+ if (request == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(EXECUTION_ID).set(request.getExecutionId());
+ node.get(SESSION_ID).set(request.getSessionId());
+ node.get(START_TIME).set(request.getStartTime());
+ node.get(COMMAND).set(request.getCommand());
+ node.get(SOURCE_REQUEST).set(request.sourceRequest());
+ if (request.getNodeId() != null) {
+ node.get(NODE_ID).set(request.getNodeId());
+ }
+ if (request.getTransactionId() != null) {
+ node.get(TRANSACTION_ID).set(request.getTransactionId());
+ }
+ node.get(STATE).set(request.getState().name());
+ node.get(THREAD_STATE).set(request.getThreadState().name());
+ return node;
+ }
+
+ public static RequestMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ RequestMetadata request = new RequestMetadata();
+ request.setExecutionId(node.get(EXECUTION_ID).asLong());
+ request.setSessionId(node.get(SESSION_ID).asString());
+ request.setStartTime(node.get(START_TIME).asLong());
+ request.setCommand(node.get(COMMAND).asString());
+ request.setSourceRequest(node.get(SOURCE_REQUEST).asBoolean());
+ if (node.has(NODE_ID)) {
+ request.setNodeId(node.get(NODE_ID).asInt());
+ }
+ if (node.has(TRANSACTION_ID)) {
+ request.setTransactionId(node.get(TRANSACTION_ID).asString());
+ }
+ request.setState(ProcessingState.valueOf(node.get(STATE).asString()));
+ request.setThreadState(ThreadState.valueOf(node.get(THREAD_STATE).asString()));
+ return request;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, EXECUTION_ID, ModelType.LONG, true);
+ addAttribute(node, SESSION_ID, ModelType.STRING, true);
+ addAttribute(node, START_TIME, ModelType.LONG, true);
+ addAttribute(node, COMMAND, ModelType.STRING, true);
+ addAttribute(node, SOURCE_REQUEST, ModelType.BOOLEAN, true);
+ addAttribute(node, NODE_ID, ModelType.INT, false);
+ addAttribute(node, TRANSACTION_ID, ModelType.STRING, false);
+ addAttribute(node, STATE, ModelType.STRING, true);
+ addAttribute(node, THREAD_STATE, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ public static class SessionMetadataMapper {
+ private static final String SECURITY_DOMAIN = "security-domain"; //$NON-NLS-1$
+ private static final String VDB_VERSION = "vdb-version"; //$NON-NLS-1$
+ private static final String VDB_NAME = "vdb-name"; //$NON-NLS-1$
+ private static final String USER_NAME = "user-name"; //$NON-NLS-1$
+ private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
+ private static final String LAST_PING_TIME = "last-ping-time"; //$NON-NLS-1$
+ private static final String IP_ADDRESS = "ip-address"; //$NON-NLS-1$
+ private static final String CLIENT_HOST_NAME = "client-host-address"; //$NON-NLS-1$
+ private static final String CREATED_TIME = "created-time"; //$NON-NLS-1$
+ private static final String APPLICATION_NAME = "application-name"; //$NON-NLS-1$
+ private static final String CLIENT_HARDWARE_ADRESS = "client-hardware-address"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(SessionMetadata session, ModelNode node) {
+ if (session == null) {
+ return null;
+ }
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ if (session.getApplicationName() != null) {
+ node.get(APPLICATION_NAME).set(session.getApplicationName());
+ }
+ node.get(CREATED_TIME).set(session.getCreatedTime());
+ node.get(CLIENT_HOST_NAME).set(session.getClientHostName());
+ node.get(IP_ADDRESS).set(session.getIPAddress());
+ node.get(LAST_PING_TIME).set(session.getLastPingTime());
+ node.get(SESSION_ID).set(session.getSessionId());
+ node.get(USER_NAME).set(session.getUserName());
+ node.get(VDB_NAME).set(session.getVDBName());
+ node.get(VDB_VERSION).set(session.getVDBVersion());
+ if (session.getSecurityDomain() != null){
+ node.get(SECURITY_DOMAIN).set(session.getSecurityDomain());
+ }
+ if (session.getClientHardwareAddress() != null) {
+ node.get(CLIENT_HARDWARE_ADRESS).set(session.getClientHardwareAddress());
+ }
+ return node;
+ }
+
+ public static SessionMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ SessionMetadata session = new SessionMetadata();
+ if (node.has(APPLICATION_NAME)) {
+ session.setApplicationName(node.get(APPLICATION_NAME).asString());
+ }
+ session.setCreatedTime(node.get(CREATED_TIME).asLong());
+ session.setClientHostName(node.get(CLIENT_HOST_NAME).asString());
+ session.setIPAddress(node.get(IP_ADDRESS).asString());
+ session.setLastPingTime(node.get(LAST_PING_TIME).asLong());
+ session.setSessionId(node.get(SESSION_ID).asString());
+ session.setUserName(node.get(USER_NAME).asString());
+ session.setVDBName(node.get(VDB_NAME).asString());
+ session.setVDBVersion(node.get(VDB_VERSION).asInt());
+ if (node.has(SECURITY_DOMAIN)) {
+ session.setSecurityDomain(node.get(SECURITY_DOMAIN).asString());
+ }
+ if (node.has(CLIENT_HARDWARE_ADRESS)) {
+ session.setClientHardwareAddress(node.get(CLIENT_HARDWARE_ADRESS).asString());
+ }
+ return session;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, APPLICATION_NAME, ModelType.STRING, false);
+ addAttribute(node, CREATED_TIME, ModelType.LONG, true);
+ addAttribute(node, CLIENT_HOST_NAME, ModelType.LONG, true);
+ addAttribute(node, IP_ADDRESS, ModelType.STRING, true);
+ addAttribute(node, LAST_PING_TIME, ModelType.LONG, true);
+ addAttribute(node, SESSION_ID, ModelType.STRING, true);
+ addAttribute(node, USER_NAME, ModelType.STRING, true);
+ addAttribute(node, VDB_NAME, ModelType.STRING, true);
+ addAttribute(node, VDB_VERSION, ModelType.INT, true);
+ addAttribute(node, SECURITY_DOMAIN, ModelType.STRING, false);
+ return node;
+ }
+ }
+
+ public static class TransactionMetadataMapper {
+ private static final String ID = "txn-id"; //$NON-NLS-1$
+ private static final String SCOPE = "txn-scope"; //$NON-NLS-1$
+ private static final String CREATED_TIME = "txn-created-time"; //$NON-NLS-1$
+ private static final String ASSOCIATED_SESSION = "session-id"; //$NON-NLS-1$
+
+ public static ModelNode wrap(TransactionMetadata object, ModelNode transaction) {
+ if (object == null)
+ return null;
+
+ transaction.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+ transaction.get(ASSOCIATED_SESSION).set(object.getAssociatedSession());
+ transaction.get(CREATED_TIME).set(object.getCreatedTime());
+ transaction.get(SCOPE).set(object.getScope());
+ transaction.get(ID).set(object.getId());
+
+ return transaction;
+ }
+
+ public static TransactionMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ TransactionMetadata transaction = new TransactionMetadata();
+ transaction.setAssociatedSession(node.get(ASSOCIATED_SESSION).asString());
+ transaction.setCreatedTime(node.get(CREATED_TIME).asLong());
+ transaction.setScope(node.get(SCOPE).asString());
+ transaction.setId(node.get(ID).asString());
+ return transaction;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, ASSOCIATED_SESSION, ModelType.STRING, true);
+ addAttribute(node, CREATED_TIME, ModelType.LONG, true);
+ addAttribute(node, SCOPE, ModelType.LONG, true);
+ addAttribute(node, ID, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ public static class WorkerPoolStatisticsMetadataMapper {
+ private static final String MAX_THREADS = "max-threads"; //$NON-NLS-1$
+ private static final String HIGHEST_QUEUED = "highest-queued"; //$NON-NLS-1$
+ private static final String QUEUED = "queued"; //$NON-NLS-1$
+ private static final String QUEUE_NAME = "queue-name"; //$NON-NLS-1$
+ private static final String TOTAL_SUBMITTED = "total-submitted"; //$NON-NLS-1$
+ private static final String TOTAL_COMPLETED = "total-completed"; //$NON-NLS-1$
+ private static final String HIGHEST_ACTIVE_THREADS = "highest-active-threads"; //$NON-NLS-1$
+ private static final String ACTIVE_THREADS = "active-threads"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(WorkerPoolStatisticsMetadata stats, ModelNode node) {
+ if (stats == null)
+ return null;
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(ACTIVE_THREADS).set(stats.getActiveThreads());
+ node.get(HIGHEST_ACTIVE_THREADS).set(stats.getHighestActiveThreads());
+ node.get(TOTAL_COMPLETED).set(stats.getTotalCompleted());
+ node.get(TOTAL_SUBMITTED).set(stats.getTotalSubmitted());
+ node.get(QUEUE_NAME).set(stats.getQueueName());
+ node.get(QUEUED).set(stats.getQueued());
+ node.get(HIGHEST_QUEUED).set(stats.getHighestQueued());
+ node.get(MAX_THREADS).set(stats.getMaxThreads());
+
+ return node;
+ }
+
+ public static WorkerPoolStatisticsMetadata unwrapMetaValue(ModelNode node) {
+ if (node == null)
+ return null;
+
+ WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
+ stats.setActiveThreads(node.get(ACTIVE_THREADS).asInt());
+ stats.setHighestActiveThreads(node.get(HIGHEST_ACTIVE_THREADS).asInt());
+ stats.setTotalCompleted(node.get(TOTAL_COMPLETED).asLong());
+ stats.setTotalSubmitted(node.get(TOTAL_SUBMITTED).asLong());
+ stats.setQueueName(node.get(QUEUE_NAME).asString());
+ stats.setQueued(node.get(QUEUED).asInt());
+ stats.setHighestQueued(node.get(HIGHEST_QUEUED).asInt());
+ stats.setMaxThreads(node.get(MAX_THREADS).asInt());
+ return stats;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, ACTIVE_THREADS, ModelType.INT, true);
+ addAttribute(node, HIGHEST_ACTIVE_THREADS, ModelType.INT, true);
+ addAttribute(node, TOTAL_COMPLETED, ModelType.LONG, true);
+ addAttribute(node, TOTAL_SUBMITTED, ModelType.LONG, true);
+ addAttribute(node, QUEUE_NAME, ModelType.STRING, true);
+ addAttribute(node, QUEUED, ModelType.INT, true);
+ addAttribute(node, HIGHEST_QUEUED, ModelType.INT, true);
+ addAttribute(node, MAX_THREADS, ModelType.INT, true);
+ return node;
+ }
+ }
+
+ private static final String CHILDREN = "children"; //$NON-NLS-1$
+ private static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ private static final String DOT_DESC = ".describe"; //$NON-NLS-1$
+ private static final String TYPE = "type"; //$NON-NLS-1$
+ private static final String MIN_OCCURS = "min-occurs"; //$NON-NLS-1$
+ private static final String REQUIRED = "required"; //$NON-NLS-1$
+ private static final String ALLOWED = "allowed"; //$NON-NLS-1$
+ static ModelNode addAttribute(ModelNode node, String name, ModelType dataType, boolean required) {
+ node.get(ATTRIBUTES, name, TYPE).set(dataType);
+ node.get(ATTRIBUTES, name, DESCRIPTION).set(AdminPlugin.Util.getString(name+DOT_DESC));
+ node.get(ATTRIBUTES, name, REQUIRED).set(required);
+ return node;
+ }
+}
+
+
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,321 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.bind.annotation.*;
+
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
+
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "", propOrder = {
+ "description",
+ "JAXBProperties",
+ "sources",
+ "errors"
+})
+public class ModelMetaData extends AdminObjectImpl implements Model {
+
+ private static final int DEFAULT_ERROR_HISTORY = 10;
+ private static final String SUPPORTS_MULTI_SOURCE_BINDINGS_KEY = "supports-multi-source-bindings"; //$NON-NLS-1$
+ private static final long serialVersionUID = 3714234763056162230L;
+
+ @XmlElement(name = "source")
+ protected ListOverMap<SourceMappingMetadata> sources = new ListOverMap<SourceMappingMetadata>(new KeyBuilder<SourceMappingMetadata>() {
+ private static final long serialVersionUID = 2273673984691112369L;
+
+ @Override
+ public String getKey(SourceMappingMetadata entry) {
+ return entry.getName();
+ }
+ });
+
+ @XmlAttribute(name = "type")
+ protected String modelType = Type.PHYSICAL.name();
+
+ @XmlElement(name = "description")
+ protected String description;
+
+ @XmlAttribute(name = "path")
+ protected String path;
+
+ @XmlAttribute(name = "visible")
+ protected Boolean visible = true;
+
+ @XmlElement(name = "validation-error")
+ protected List<ValidationError> errors;
+
+ @XmlAttribute(name = "name", required = true)
+ public String getName() {
+ return super.getName();
+ }
+
+ // This is needed by JAXB
+ public void setName(String name) {
+ super.setName(name);
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public boolean isSource() {
+ return getModelType() == Model.Type.PHYSICAL;
+ }
+
+ @Override
+ public boolean isVisible() {
+ return this.visible;
+ }
+
+ @Override
+ public Type getModelType() {
+ try {
+ return Type.valueOf(modelType.toUpperCase());
+ } catch(IllegalArgumentException e) {
+ return Type.OTHER;
+ }
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public boolean isSupportsMultiSourceBindings() {
+ String supports = getPropertyValue(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY);
+ return Boolean.parseBoolean(supports);
+ }
+
+ @Override
+ @XmlElement(name = "property", type = PropertyMetadata.class)
+ public List<PropertyMetadata> getJAXBProperties(){
+ return super.getJAXBProperties();
+ }
+
+ public void setSupportsMultiSourceBindings(boolean supports) {
+ addProperty(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY, Boolean.toString(supports));
+ }
+
+ public void setModelType(Model.Type modelType) {
+ this.modelType = modelType.name();
+ }
+
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
+ public String toString() {
+ return getName() + this.sources;
+ }
+
+ public void setVisible(Boolean value) {
+ this.visible = value;
+ }
+
+ public List<SourceMappingMetadata> getSourceMappings(){
+ return new ArrayList<SourceMappingMetadata>(this.sources.getMap().values());
+ }
+
+ public void setSourceMappings(List<SourceMappingMetadata> sources){
+ for (SourceMappingMetadata source: sources) {
+ addSourceMapping(source.getName(), source.getTranslatorName(), source.getConnectionJndiName());
+ }
+ }
+
+ @Override
+ public List<String> getSourceNames() {
+ return new ArrayList<String>(this.sources.getMap().keySet());
+ }
+
+ @Override
+ public String getSourceConnectionJndiName(String sourceName) {
+ SourceMappingMetadata s = this.sources.getMap().get(sourceName);
+ if (s == null) {
+ return null;
+ }
+ return s.getConnectionJndiName();
+ }
+
+ @Override
+ public String getSourceTranslatorName(String sourceName) {
+ SourceMappingMetadata s = this.sources.getMap().get(sourceName);
+ if (s == null) {
+ return null;
+ }
+ return s.getTranslatorName();
+ }
+
+ public void addSourceMapping(String name, String translatorName, String connJndiName) {
+ this.sources.getMap().put(name, new SourceMappingMetadata(name, translatorName, connJndiName));
+ }
+
+ public void addSourceMapping(SourceMappingMetadata source) {
+ this.sources.getMap().put(source.getName(), new SourceMappingMetadata(source.getName(), source.getTranslatorName(), source.getConnectionJndiName()));
+ }
+
+ public List<ValidationError> getErrors(){
+ return getValidationErrors(Severity.ERROR);
+ }
+
+ public void setErrors(List<ValidationError> errors){
+ this.errors = errors;
+ }
+
+ public synchronized List<ValidationError> getValidationErrors(ValidationError.Severity severity){
+ if (this.errors == null) {
+ return Collections.emptyList();
+ }
+ List<ValidationError> list = new ArrayList<ValidationError>();
+ for (ValidationError ve: this.errors) {
+ if (Severity.valueOf(ve.severity) == severity) {
+ list.add(ve);
+ }
+ }
+ return list;
+ }
+
+ public synchronized ValidationError addError(String severity, String message) {
+ if (this.errors == null) {
+ this.errors = new LinkedList<ValidationError>();
+ }
+ ValidationError ve = new ValidationError(severity, message);
+ this.errors.add(ve);
+ if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
+ this.errors.remove(0);
+ }
+ return ve;
+ }
+
+ public synchronized ValidationError addError(ValidationError ve) {
+ if (this.errors == null) {
+ this.errors = new LinkedList<ValidationError>();
+ }
+ this.errors.add(ve);
+ if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
+ this.errors.remove(0);
+ }
+ return ve;
+ }
+
+
+ public synchronized boolean removeError(ValidationError remove) {
+ if (this.errors == null) {
+ return false;
+ }
+ return this.errors.remove(remove);
+ }
+
+ public synchronized void clearErrors() {
+ this.errors.clear();
+ }
+
+ @XmlAccessorType(XmlAccessType.NONE)
+ @XmlType(name = "", propOrder = {
+ "value"
+ })
+ public static class ValidationError implements Serializable{
+ private static final long serialVersionUID = 2044197069467559527L;
+
+ public enum Severity {ERROR, WARNING};
+
+ @XmlValue
+ protected String value;
+
+ @XmlAttribute(name = "severity", required = true)
+ protected String severity;
+
+ @XmlAttribute(name = "path")
+ protected String path;
+
+ public ValidationError() {};
+
+ public ValidationError(String severity, String msg) {
+ this.severity = severity;
+ this.value = msg;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getSeverity() {
+ return severity;
+ }
+
+ public void setSeverity(String severity) {
+ this.severity = severity;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ValidationError other = (ValidationError) obj;
+ if (severity == null) {
+ if (other.severity != null)
+ return false;
+ } else if (!severity.equals(other.severity))
+ return false;
+ if (value == null) {
+ if (other.value != null)
+ return false;
+ } else if (!value.equals(other.value))
+ return false;
+ return true;
+ }
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+
+public class ModelNodeConstants {
+ public static final String TYPE = "type";//$NON-NLS-1$
+ public static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ public static final String DESCRIPTION = "description"; //$NON-NLS-1$
+
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/ModelNodeConstants.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+
+public class PermissionMap extends ListOverMap<PermissionMetaData> {
+
+ private static final long serialVersionUID = -1170556665834875267L;
+
+ public PermissionMap(KeyBuilder<PermissionMetaData> builder) {
+ super(builder);
+ }
+
+ @Override
+ public void add(int index, PermissionMetaData element) {
+ PermissionMetaData previous = this.map.get(builder.getKey(element));
+ if (previous != null) {
+ if (element.allowCreate != null) {
+ previous.setAllowCreate(element.allowCreate);
+ }
+ if (element.allowRead != null) {
+ previous.setAllowRead(element.allowRead);
+ }
+ if (element.allowUpdate != null) {
+ previous.setAllowUpdate(element.allowUpdate);
+ }
+ if (element.allowDelete != null) {
+ previous.setAllowDelete(element.allowDelete);
+ }
+ }
+ else {
+ super.add(index, element);
+ }
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,214 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.teiid.adminapi.PropertyDefinition;
+
+
+
+public class PropertyDefinitionMetadata extends AdminObjectImpl implements PropertyDefinition {
+ private static final long serialVersionUID = 6612838530524627205L;
+ private Collection allowedValues = new ArrayList();
+ private Object defaultValue = null;
+ private String description = null;
+ private String displayName = null;
+ private String propertyTypeClassName = String.class.getName();
+ private RestartType requiresRestart = RestartType.NONE;
+ private boolean advanced = false;
+ private boolean masked = false;
+ private boolean modifiable = true;
+ private boolean required = false;
+
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("Display Name:").append(getDisplayName()); //$NON-NLS-1$
+ result.append(" Description:").append(getDescription()); //$NON-NLS-1$
+ result.append(" Property Type Classname:").append(getPropertyTypeClassName()); //$NON-NLS-1$
+ result.append(" Default Value:").append(getDefaultValue()); //$NON-NLS-1$
+ result.append(" Constrained To Allow Values:").append(isConstrainedToAllowedValues()); //$NON-NLS-1$
+ result.append(" Allowed Values:").append(getAllowedValues()); //$NON-NLS-1$
+ result.append(" Required:").append(isRequired()); //$NON-NLS-1$
+ result.append(" Expert:").append(isAdvanced()); //$NON-NLS-1$
+ result.append(" Masked:").append(isMasked()); //$NON-NLS-1$
+ result.append(" Modifiable:").append(isModifiable()); //$NON-NLS-1$
+ result.append(" RequiresRestart:").append(getRequiresRestart()); //$NON-NLS-1$
+ return result.toString();
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getAllowedValues()
+ */
+ public Collection getAllowedValues() {
+ return allowedValues;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getDescription()
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getDisplayName()
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getPropertyTypeClassName()
+ */
+ public String getPropertyTypeClassName() {
+ return propertyTypeClassName;
+ }
+
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#getRequiresRestart()
+ */
+ public RestartType getRequiresRestart() {
+ return requiresRestart;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#isExpert()
+ * @since 4.3
+ */
+ public boolean isAdvanced() {
+ return advanced;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#isMasked()
+ */
+ public boolean isMasked() {
+ return masked;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#isModifiable()
+ */
+ public boolean isModifiable() {
+ return modifiable;
+ }
+
+ /**
+ * @see org.teiid.adminapi.PropertyDefinition#isRequired()
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * @param allowedValues The allowedValues to set.
+ */
+ public void setAllowedValues(Collection allowedValues) {
+ this.allowedValues = allowedValues;
+ }
+
+ /**
+ * @param defaultValue The defaultValue to set.
+ */
+ public void setDefaultValue(Serializable defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+
+ /**
+ * @param displayName The displayName to set.
+ */
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+
+ /**
+ * @param expert The value of expert to set.
+ */
+ public void setAdvanced(boolean expert) {
+ this.advanced = expert;
+ }
+
+ /**
+ * @param masked The value of masked to set.
+ */
+ public void setMasked(boolean masked) {
+ this.masked = masked;
+ }
+ /**
+ * @param modifiable The value of modifiable to set.
+ */
+ public void setModifiable(boolean modifiable) {
+ this.modifiable = modifiable;
+ }
+
+ /**
+ * @param propertyTypeClassName The propertyTypeName to set.
+ */
+ public void setPropertyTypeClassName(String propertyTypeClassName) {
+ this.propertyTypeClassName = propertyTypeClassName;
+ }
+
+
+ /**
+ * @param required The value of required to set.
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ /**
+ * @param requiresRestart The value of requiresRestart to set.
+ */
+ public void setRequiresRestart(RestartType requiresRestart) {
+ this.requiresRestart = requiresRestart;
+ }
+
+ @Override
+ public boolean isConstrainedToAllowedValues() {
+ return allowedValues != null && !allowedValues.isEmpty();
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyDefinitionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <pre>
+ * <complexType name="property">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "property")
+public class PropertyMetadata implements Serializable{
+ private static final long serialVersionUID = -5040224539939758816L;
+
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlAttribute(name = "value", required = true)
+ protected String value;
+
+ public PropertyMetadata() {
+ }
+
+ public PropertyMetadata(String key, String value) {
+ this.name = key;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return this.name+"="+this.value; //$NON-NLS-1$
+ }
+}
\ No newline at end of file
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.util.Date;
+
+import org.teiid.adminapi.Request;
+import org.teiid.core.util.HashCodeUtil;
+
+
+
+public class RequestMetadata extends AdminObjectImpl implements Request {
+
+ private static final long serialVersionUID = -2779106368517784259L;
+
+ private long executionId;
+ private String sessionId;
+ private String command;
+ private long startTime;
+ private boolean sourceRequest;
+ private Integer nodeID;
+ private String transactionId;
+ private ProcessingState processingState = ProcessingState.PROCESSING;
+ private ThreadState threadState = ThreadState.RUNNING;
+
+ @Override
+ public long getExecutionId() {
+ return executionId;
+ }
+
+ public void setExecutionId(long id) {
+ this.executionId = id;
+ }
+
+ @Override
+ public ProcessingState getState() {
+ return processingState;
+ }
+
+ public void setState(ProcessingState state) {
+ this.processingState = state;
+ }
+
+ @Override
+ public ThreadState getThreadState() {
+ return threadState;
+ }
+
+ public void setThreadState(ThreadState threadState) {
+ this.threadState = threadState;
+ }
+
+ @Override
+ public String getSessionId() {
+ return this.sessionId;
+ }
+
+ public void setSessionId(String session) {
+ this.sessionId = session;
+ }
+
+ @Override
+ public long getStartTime() {
+ return this.startTime;
+ }
+
+ public void setStartTime(long time) {
+ this.startTime = time;
+ }
+
+ @Override
+ public String getCommand() {
+ return this.command;
+ }
+
+ public void setCommand(String cmd) {
+ this.command = cmd;
+ }
+
+ @Override
+ public boolean sourceRequest() {
+ return sourceRequest;
+ }
+
+ public void setSourceRequest(boolean sourceRequest) {
+ this.sourceRequest = sourceRequest;
+ }
+
+ @Override
+ public Integer getNodeId() {
+ return this.nodeID;
+ }
+
+ public void setNodeId(Integer nodeID) {
+ this.nodeID = nodeID;
+ }
+
+ @Override
+ public String getTransactionId() {
+ return this.transactionId;
+ }
+
+ public void setTransactionId(String id) {
+ this.transactionId = id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RequestMetadata)) {
+ return false;
+ }
+ RequestMetadata value = (RequestMetadata)obj;
+ if (!sourceRequest()) {
+ return sessionId == value.sessionId && executionId == value.executionId;
+ }
+ return sessionId == value.sessionId && executionId == value.executionId && nodeID.equals(value.nodeID);
+ }
+
+ public int hashCode() {
+ return HashCodeUtil.hashCode((int)executionId, sessionId);
+ }
+
+ @SuppressWarnings("nls")
+ public String toString() {
+ StringBuilder str = new StringBuilder();
+ str.append("Request: sessionid=").append(sessionId);
+ str.append("; executionId=").append(executionId);
+ if (nodeID != null) {
+ str.append("; nodeId=").append(nodeID);
+ }
+ if (transactionId != null) {
+ str.append("; transactionId=").append(transactionId);
+ }
+ str.append("; sourceRequest=").append(sourceRequest);
+ str.append("; processingTime=").append(new Date(startTime));
+ str.append("; command=").append(command);
+
+ return str.toString();
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,217 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.Date;
+
+import javax.security.auth.Subject;
+
+import org.teiid.adminapi.Session;
+import org.teiid.client.security.SessionToken;
+
+
+
+/**
+ * Add and delete properties also in the Mapper class for correct wrapping for profile service.
+ *
+ */
+/* TODO: it would probably be good to let ipAddress denote the connecting address
+ and add clientIpAdress as the client reported value */
+public class SessionMetadata extends AdminObjectImpl implements Session {
+
+ private static final long serialVersionUID = 918638989081830034L;
+ private String applicationName;
+ private long lastPingTime = System.currentTimeMillis();
+ private long createdTime;
+ private String ipAddress;
+ private String clientHostName;
+ private String clientHardwareAddress;
+ private String userName;
+ private String vdbName;
+ private int vdbVersion;
+ private String sessionId;
+ private String securityDomain;
+
+ //server session state
+ private transient VDBMetaData vdb;
+ private transient SessionToken sessionToken;
+ private transient Subject subject;
+ private transient Object securityContext;
+ private transient boolean embedded;
+
+ @Override
+ public String getApplicationName() {
+ return this.applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ @Override
+ public long getCreatedTime() {
+ return this.createdTime;
+ }
+
+ public void setCreatedTime(long createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ @Override
+ public String getClientHostName() {
+ return this.clientHostName;
+ }
+
+ public void setClientHostName(String clientHostname) {
+ this.clientHostName = clientHostname;
+ }
+
+ @Override
+ public String getIPAddress() {
+ return this.ipAddress;
+ }
+
+ public void setIPAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ @Override
+ public long getLastPingTime() {
+ return this.lastPingTime;
+ }
+
+ public void setLastPingTime(long lastPingTime) {
+ this.lastPingTime = lastPingTime;
+ }
+
+ @Override
+ public String getSessionId() {
+ return this.sessionId;
+ }
+
+ public void setSessionId(String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ public String getUserName() {
+ return this.userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ public String getVDBName() {
+ return this.vdbName;
+ }
+
+ public void setVDBName(String vdbName) {
+ this.vdbName = vdbName;
+ }
+
+ @Override
+ public int getVDBVersion() {
+ return this.vdbVersion;
+ }
+
+ public void setVDBVersion(int vdbVersion) {
+ this.vdbVersion = vdbVersion;
+ }
+
+ @Override
+ public String getSecurityDomain() {
+ return this.securityDomain;
+ }
+
+ public void setSecurityDomain(String domain) {
+ this.securityDomain = domain;
+ }
+
+ @SuppressWarnings("nls")
+ public String toString() {
+ StringBuilder str = new StringBuilder();
+ str.append("session: sessionid=").append(sessionId);
+ str.append("; userName=").append(userName);
+ str.append("; vdbName=").append(vdbName);
+ str.append("; vdbVersion=").append(vdbVersion);
+ str.append("; createdTime=").append(new Date(createdTime));
+ str.append("; applicationName=").append(applicationName);
+ str.append("; clientHostName=").append(clientHostName);
+ str.append("; clientHardwareAddress=").append(clientHardwareAddress);
+ str.append("; IPAddress=").append(ipAddress);
+ str.append("; securityDomain=").append(securityDomain);
+ str.append("; lastPingTime=").append(new Date(lastPingTime));
+ return str.toString();
+ }
+
+ public VDBMetaData getVdb() {
+ return vdb;
+ }
+
+ public void setVdb(VDBMetaData vdb) {
+ this.vdb = vdb;
+ }
+
+ public SessionToken getSessionToken() {
+ return sessionToken;
+ }
+
+ public void setSessionToken(SessionToken sessionToken) {
+ this.sessionToken = sessionToken;
+ }
+
+ public void setSubject(Subject subject) {
+ this.subject = subject;
+ }
+
+ public Object getSecurityContext() {
+ return securityContext;
+ }
+
+ public void setSecurityContext(Object securityContext) {
+ this.securityContext = securityContext;
+ }
+
+ public Subject getSubject() {
+ return this.subject;
+ }
+
+ public void setEmbedded(boolean embedded) {
+ this.embedded = embedded;
+ }
+
+ public boolean isEmbedded() {
+ return embedded;
+ }
+
+ @Override
+ public String getClientHardwareAddress() {
+ return this.clientHardwareAddress;
+ }
+
+ public void setClientHardwareAddress(String clientHardwareAddress) {
+ this.clientHardwareAddress = clientHardwareAddress;
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "")
+public class SourceMappingMetadata implements Serializable {
+ private static final long serialVersionUID = -4417878417697685794L;
+
+ @XmlAttribute(name = "name", required = true)
+ private String name;
+
+ @XmlAttribute(name = "connection-jndi-name")
+ private String jndiName;
+
+ @XmlAttribute(name = "translator-name",required = true)
+ private String translatorName;
+
+ public SourceMappingMetadata() {}
+
+ public SourceMappingMetadata(String name, String translatorName, String connJndiName) {
+ this.name = name;
+ this.translatorName = translatorName;
+ this.jndiName = connJndiName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getConnectionJndiName() {
+ // this default could be controlled if needed.
+ if (this.jndiName == null) {
+ return "java:"+name; //$NON-NLS-1$
+ }
+ return jndiName;
+ }
+
+ public void setConnectionJndiName(String jndiName) {
+ this.jndiName = jndiName;
+ }
+
+ public String getTranslatorName() {
+ return translatorName;
+ }
+
+ public void setTranslatorName(String translatorName) {
+ this.translatorName = translatorName;
+ }
+
+ public String toString() {
+ return getName()+"/"+getTranslatorName()+"/"+getConnectionJndiName(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
\ No newline at end of file
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import java.util.Date;
+
+import org.teiid.adminapi.Transaction;
+
+
+public class TransactionMetadata extends AdminObjectImpl implements Transaction {
+
+ private static final long serialVersionUID = -8588785315218789068L;
+ private String associatedSession;
+ private String scope;
+ private String id;
+ private long createdTime;
+
+ @Override
+ public String getAssociatedSession() {
+ return associatedSession;
+ }
+
+ public void setAssociatedSession(String associatedSession) {
+ this.associatedSession = associatedSession;
+ }
+
+ @Override
+ public String getScope() {
+ return scope;
+ }
+
+ public void setScope(String scope) {
+ this.scope = scope;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public long getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(long time) {
+ this.createdTime = time;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("Associated Session:").append(associatedSession); //$NON-NLS-1$
+ result.append("Scope:").append(scope); //$NON-NLS-1$
+ result.append("Id:").append(id); //$NON-NLS-1$
+ result.append("CreatedTime:").append(new Date(createdTime)); //$NON-NLS-1$
+ return result.toString();
+ }
+
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,343 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.net.URL;
+import java.util.*;
+
+import javax.xml.bind.annotation.*;
+
+import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.core.util.StringUtil;
+
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlType(name = "", propOrder = {
+ "description",
+ "JAXBProperties",
+ "models",
+ "translators",
+ "dataPolicies"
+})
+@XmlRootElement(name = "vdb")
+public class VDBMetaData extends AdminObjectImpl implements VDB {
+
+ private static final String VERSION_DELIM = "."; //$NON-NLS-1$
+
+ private static final long serialVersionUID = -4723595252013356436L;
+
+ /**
+ * This simulating a list over a map. JAXB requires a list and performance recommends
+ * map and we would like to keep one variable to represent both.
+ */
+ @XmlElement(name = "model", required = true, type = ModelMetaData.class)
+ protected ListOverMap<ModelMetaData> models = new ListOverMap<ModelMetaData>(new KeyBuilder<ModelMetaData>() {
+ private static final long serialVersionUID = 846247100420118961L;
+
+ @Override
+ public String getKey(ModelMetaData entry) {
+ return entry.getName();
+ }
+ });
+
+ @XmlElement(name = "translator", required = true, type = VDBTranslatorMetaData.class)
+ protected ListOverMap<VDBTranslatorMetaData> translators = new ListOverMap<VDBTranslatorMetaData>(new KeyBuilder<VDBTranslatorMetaData>() {
+ private static final long serialVersionUID = 3890502172003653563L;
+
+ @Override
+ public String getKey(VDBTranslatorMetaData entry) {
+ return entry.getName();
+ }
+ });
+
+ @XmlElement(name = "data-role", required = true, type = DataPolicyMetadata.class)
+ protected ListOverMap<DataPolicyMetadata> dataPolicies = new ListOverMap<DataPolicyMetadata>(new KeyBuilder<DataPolicyMetadata>() {
+ private static final long serialVersionUID = 4954591545242715254L;
+
+ @Override
+ public String getKey(DataPolicyMetadata entry) {
+ return entry.getName();
+ }
+ });
+
+ @XmlAttribute(name = "version", required = true)
+ private int version = 1;
+
+ @XmlElement(name = "description")
+ protected String description;
+
+ private String fileUrl = null;
+ private boolean dynamic = false;
+ private VDB.Status status = VDB.Status.INACTIVE;
+ private ConnectionType connectionType = VDB.ConnectionType.BY_VERSION;
+ private boolean removed;
+
+ @XmlAttribute(name = "name", required = true)
+ public String getName() {
+ return super.getName();
+ }
+
+ public String getFullName() {
+ return getName() + VERSION_DELIM + getVersion();
+ }
+
+ // This needed by JAXB marshaling
+ public void setName(String name) {
+ super.setName(name);
+ }
+
+ public boolean isRemoved() {
+ return removed;
+ }
+
+ public void setRemoved(boolean removed) {
+ this.removed = removed;
+ }
+
+ @Override
+ public ConnectionType getConnectionType() {
+ return this.connectionType;
+ }
+
+ public void setConnectionType(ConnectionType allowConnections) {
+ this.connectionType = allowConnections;
+ }
+
+ public void setConnectionType(String allowConnections) {
+ this.connectionType = ConnectionType.valueOf(allowConnections);
+ }
+
+ @Override
+ public Status getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(Status s) {
+ this.status = s;
+ }
+
+ public void setStatus(String s) {
+ this.status = Status.valueOf(s);
+ }
+
+
+ @Override
+ public int getVersion() {
+ return this.version;
+ }
+
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public String getUrl() {
+ return this.fileUrl;
+ }
+
+ public void setUrl(String url) {
+ this.fileUrl = url;
+ }
+
+ public void setUrl(URL url) {
+ this.setUrl(url.toExternalForm());
+ String path = url.getPath();
+ if (path.endsWith("/")) { //$NON-NLS-1$
+ path = path.substring(0, path.length() - 1);
+ }
+ String fileName = StringUtil.getLastToken(path, "/"); //$NON-NLS-1$
+ String[] parts = fileName.split("\\."); //$NON-NLS-1$
+ if (parts[0].equalsIgnoreCase(getName()) && parts.length >= 3) {
+ try {
+ int fileVersion = Integer.parseInt(parts[parts.length - 2]);
+ this.setVersion(fileVersion);
+ } catch (NumberFormatException e) {
+
+ }
+ }
+ }
+
+ @Override
+ public List<Model> getModels(){
+ return new ArrayList<Model>(this.models.getMap().values());
+ }
+
+ public Map<String, ModelMetaData> getModelMetaDatas() {
+ return this.models.getMap();
+ }
+
+ /**
+ * This method required to make the JNDI assignment on the model work; if not persistent Management framework
+ * treating "models" as ReadOnly property. The actual assignment is done in the VDBMetaDataClassInstancefactory
+ * @param models
+ */
+ public void setModels(List<Model> models) {
+ for (Model obj : models) {
+ ModelMetaData model = (ModelMetaData) obj;
+ addModel(model);
+ }
+ }
+
+ public void addModel(ModelMetaData m) {
+ this.models.getMap().put(m.getName(), m);
+ }
+
+ @Override
+ public List<Translator> getOverrideTranslators() {
+ return new ArrayList<Translator>(this.translators.getMap().values());
+ }
+
+ public void setOverrideTranslators(List<Translator> translators) {
+ for (Translator t: translators) {
+ this.translators.getMap().put(t.getName(), (VDBTranslatorMetaData)t);
+ }
+ }
+
+ public void addOverideTranslator(VDBTranslatorMetaData t) {
+ this.translators.getMap().put(t.getName(), t);
+ }
+
+ @Override
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String desc) {
+ this.description = desc;
+ }
+
+ @Override
+ public List<String> getValidityErrors(){
+ List<String> allErrors = new ArrayList<String>();
+ for (ModelMetaData model:this.models.getMap().values()) {
+ List<ValidationError> errors = model.getErrors();
+ if (errors != null && !errors.isEmpty()) {
+ for (ValidationError m:errors) {
+ if (ValidationError.Severity.valueOf(m.getSeverity()).equals(ValidationError.Severity.ERROR)) {
+ allErrors.add(m.getValue());
+ }
+ }
+ }
+ }
+ return allErrors;
+ }
+
+ @Override
+ public boolean isValid() {
+ if (!getValidityErrors().isEmpty()) {
+ return false;
+ }
+
+ if (getModels().isEmpty()) {
+ return false;
+ }
+ for(ModelMetaData m: this.models.getMap().values()) {
+ if (m.isSource()) {
+ List<String> resourceNames = m.getSourceNames();
+ if (resourceNames.isEmpty()) {
+ return false;
+ }
+ for (String sourceName:resourceNames) {
+ if (m.getSourceConnectionJndiName(sourceName) == null) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public String toString() {
+ return getName()+VERSION_DELIM+getVersion()+ models.getMap().values();
+ }
+
+ public boolean isVisible(String modelName) {
+ ModelMetaData model = getModel(modelName);
+ return model == null || model.isVisible();
+ }
+
+ public ModelMetaData getModel(String modelName) {
+ return this.models.getMap().get(modelName);
+ }
+
+ public Set<String> getMultiSourceModelNames(){
+ Set<String> list = new HashSet<String>();
+ for(ModelMetaData m: models.getMap().values()) {
+ if (m.isSupportsMultiSourceBindings()) {
+ list.add(m.getName());
+ }
+ }
+ return list;
+ }
+
+ // This one manages the JAXB binding
+ @Override
+ @XmlElement(name = "property", type = PropertyMetadata.class)
+ public List<PropertyMetadata> getJAXBProperties(){
+ return super.getJAXBProperties();
+ }
+
+ public boolean isDynamic() {
+ return dynamic;
+ }
+
+ public void setDynamic(boolean dynamic) {
+ this.dynamic = dynamic;
+ }
+
+ @Override
+ public List<DataPolicy> getDataPolicies(){
+ return new ArrayList<DataPolicy>(this.dataPolicies.getMap().values());
+ }
+
+ /**
+ * This method is required by the Management framework to write the mappings to the persistent form. The actual assignment is done
+ * in the VDBMetaDataClassInstancefactory
+ * @param policies
+ */
+ public void setDataPolicies(List<DataPolicy> policies){
+ this.dataPolicies.getMap().clear();
+ for (DataPolicy policy:policies) {
+ this.dataPolicies.getMap().put(policy.getName(), (DataPolicyMetadata)policy);
+ }
+ }
+
+ public void addDataPolicy(DataPolicyMetadata policy){
+ this.dataPolicies.getMap().put(policy.getName(), policy);
+ }
+
+ public DataPolicyMetadata getDataPolicy(String policyName) {
+ return this.dataPolicies.getMap().get(policyName);
+ }
+
+ public VDBTranslatorMetaData getTranslator(String name) {
+ return this.translators.getMap().get(name);
+ }
+
+ public boolean isPreview() {
+ return Boolean.valueOf(getPropertyValue("preview")); //$NON-NLS-1$
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,310 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.adminapi.impl.VDBMetaData;
+
+@SuppressWarnings("nls")
+public class VDBMetadataParser {
+
+ public static VDBMetaData unmarshell(InputStream content) throws XMLStreamException {
+ XMLInputFactory inputFactory=XMLInputFactory.newInstance();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
+
+ // elements
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case VDB:
+ VDBMetaData vdb = new VDBMetaData();
+ Properties props = getAttributes(reader);
+ vdb.setName(props.getProperty(Element.NAME.getLocalName()));
+ vdb.setVersion(Integer.parseInt(props.getProperty(Element.VERSION.getLocalName())));
+ parseVDB(reader, vdb);
+ return vdb;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ return null;
+ }
+
+ private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ vdb.setDescription(reader.getElementText());
+ break;
+ case PROPERTY:
+ parseProperty(reader, vdb);
+ break;
+ case MODEL:
+ ModelMetaData model = new ModelMetaData();
+ parseModel(reader, model);
+ vdb.addModel(model);
+ break;
+ case TRANSLATOR:
+ VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
+ parseTranslator(reader, translator);
+ vdb.addOverideTranslator(translator);
+ break;
+ case DATA_ROLE:
+ DataPolicyMetadata policy = new DataPolicyMetadata();
+ parseDataRole(reader, policy);
+ vdb.addDataPolicy(policy);
+ break;
+ case ENTRY:
+ // this is designer specific.
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseProperty(XMLStreamReader reader, AdminObjectImpl anObj)
+ throws XMLStreamException {
+ if (reader.getAttributeCount() > 0) {
+ String key = null;
+ String value = null;
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ if (attrName.equals(Element.NAME.getLocalName())) {
+ key = attrValue;
+ }
+ if (attrName.equals(Element.VALUE.getLocalName())) {
+ value = attrValue;
+ }
+ }
+ anObj.addProperty(key, value);
+ }
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ }
+
+ private static void parseDataRole(XMLStreamReader reader, DataPolicyMetadata policy) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ policy.setName(props.getProperty(Element.NAME.getLocalName()));
+ policy.setAnyAuthenticated(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ANY_ATHENTICATED_ATTR.getLocalName())));
+ policy.setAllowCreateTemporaryTables(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ALLOW_TEMP_TABLES_ATTR.getLocalName())));
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ policy.setDescription(reader.getElementText());
+ break;
+ case PERMISSION:
+ PermissionMetaData permission = new PermissionMetaData();
+ parsePermission(reader, permission);
+ policy.addPermission(permission);
+ break;
+ case MAPPED_ROLE_NAME:
+ policy.addMappedRoleName(reader.getElementText());
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parsePermission(XMLStreamReader reader, PermissionMetaData permission) throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case RESOURCE_NAME:
+ permission.setResourceName(reader.getElementText());
+ break;
+ case ALLOW_ALTER:
+ permission.setAllowAlter(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_CREATE:
+ permission.setAllowCreate(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_DELETE:
+ permission.setAllowDelete(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_EXECUTE:
+ permission.setAllowExecute(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_READ:
+ permission.setAllowRead(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_UPADTE:
+ permission.setAllowUpdate(Boolean.parseBoolean(reader.getElementText()));
+ break;
+
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseTranslator(XMLStreamReader reader, VDBTranslatorMetaData translator) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ translator.setName(props.getProperty(Element.NAME.getLocalName()));
+ translator.setType(props.getProperty(Element.TYPE.getLocalName()));
+ translator.setDescription(props.getProperty(Element.DESCRIPTION.getLocalName()));
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case PROPERTY:
+ parseProperty(reader, translator);
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseModel(XMLStreamReader reader, ModelMetaData model) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ model.setName(props.getProperty(Element.NAME.getLocalName()));
+ model.setModelType(Model.Type.valueOf(props.getProperty(Element.TYPE.getLocalName(), "PHYSICAL")));
+ model.setVisible(Boolean.parseBoolean(props.getProperty(Element.VISIBLE.getLocalName(), "true")));
+ model.setPath(props.getProperty(Element.PATH.getLocalName()));
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ model.setDescription(reader.getElementText());
+ break;
+ case PROPERTY:
+ parseProperty(reader, model);
+ break;
+ case SOURCE:
+ Properties sourceProps = getAttributes(reader);
+ String name = sourceProps.getProperty(Element.NAME.getLocalName());
+ String translatorName = sourceProps.getProperty(Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName());
+ String connectionName = sourceProps.getProperty(Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName());
+ model.addSourceMapping(name, translatorName, connectionName);
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ break;
+ case VALIDATION_ERROR:
+ Properties validationProps = getAttributes(reader);
+ String msg = reader.getElementText();
+ String severity = validationProps.getProperty(Element.VALIDATION_SEVERITY_ATTR.getLocalName());
+ String path = validationProps.getProperty(Element.PATH.getLocalName());
+ ValidationError ve = new ValidationError(severity, msg);
+ ve.setPath(path);
+ model.addError(ve);
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+
+ private static Properties getAttributes(XMLStreamReader reader) {
+ Properties props = new Properties();
+ if (reader.getAttributeCount() > 0) {
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ props.setProperty(attrName, attrValue);
+ }
+ }
+ return props;
+ }
+
+ enum Element {
+ // must be first
+ UNKNOWN(null),
+ VDB("vdb"),
+ NAME("name"),
+ VERSION("version"),
+ DESCRIPTION("description"),
+ PROPERTY("property"),
+ VALUE("value"),
+ MODEL("model"),
+ TYPE("type"),
+ VISIBLE("visible"),
+ PATH("path"),
+ SOURCE("source"),
+ SOURCE_TRANSLATOR_NAME_ATTR("translator-name"),
+ SOURCE_CONNECTION_JNDI_NAME_ATTR("connection-jndi-name"),
+ VALIDATION_ERROR("validation-error"),
+ VALIDATION_SEVERITY_ATTR("severity"),
+ TRANSLATOR("translator"),
+ DATA_ROLE("data-role"),
+ DATA_ROLE_ANY_ATHENTICATED_ATTR("any-authenticated"),
+ DATA_ROLE_ALLOW_TEMP_TABLES_ATTR("allow-create-temporary-tables"),
+ PERMISSION("permission"),
+ RESOURCE_NAME("resource-name"),
+ ALLOW_CREATE("allow-create"),
+ ALLOW_READ("allow-read"),
+ ALLOW_UPADTE("allow-update"),
+ ALLOW_DELETE("allow-delete"),
+ ALLOW_EXECUTE("allow-execute"),
+ ALLOW_ALTER("allow-alyer"),
+ MAPPED_ROLE_NAME("mapped-role-name"),
+ ENTRY("entry");
+
+ private final String name;
+
+ Element(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName() {
+ return name;
+ }
+
+ private static final Map<String, Element> elements;
+
+ static {
+ final Map<String, Element> map = new HashMap<String, Element>();
+ for (Element element : values()) {
+ final String name = element.getLocalName();
+ if (name != null) map.put(name, element);
+ }
+ elements = map;
+ }
+
+ public static Element forName(String localName) {
+ final Element element = elements.get(localName);
+ return element == null ? UNKNOWN : element;
+ }
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.teiid.adminapi.Translator;
+
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+public class VDBTranslatorMetaData extends AdminObjectImpl implements Translator {
+ private static final long serialVersionUID = -3454161477587996138L;
+ private String type;
+ private Class<?> executionClass;
+ private String description;
+ private String moduleName;
+
+ @Override
+ public String getName() {
+ return super.getName();
+ }
+
+ @XmlAttribute(name = "name", required = true)
+ public void setName(String name) {
+ super.setName(name);
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ @XmlAttribute(name = "type",required = true)
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ @XmlElement(name = "property", type = PropertyMetadata.class)
+ public List<PropertyMetadata> getJAXBProperties(){
+ return super.getJAXBProperties();
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public Class<?> getExecutionFactoryClass() {
+ return this.executionClass;
+ }
+
+ public void setExecutionFactoryClass(Class<?> clazz) {
+ this.executionClass = clazz;
+ addProperty(EXECUTION_FACTORY_CLASS, clazz.getName());
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ @XmlAttribute(name = "description")
+ public void setDescription(String desc) {
+ this.description = desc;
+ }
+
+ public String getModuleName() {
+ return this.moduleName;
+ }
+
+ public void setModuleName(String name) {
+ this.moduleName = name;
+ }
+}
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
===================================================================
--- branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java (rev 0)
+++ branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import org.teiid.adminapi.WorkerPoolStatistics;
+
+/**
+ * This class is a holder for all the statistics gathered about a worker pool.
+ */
+public class WorkerPoolStatisticsMetadata extends AdminObjectImpl implements WorkerPoolStatistics {
+
+ private static final long serialVersionUID = -4917902925523802295L;
+
+ // Current state
+ private int queued;
+ private int highestQueued;
+ private int maxThreads;
+ private int activeThreads;
+ private int highestActiveThreads;
+ private long totalSubmitted;
+ private long totalCompleted;
+
+ @Override
+ public int getActiveThreads() {
+ return activeThreads;
+ }
+
+ @Override
+ public int getHighestActiveThreads() {
+ return highestActiveThreads;
+ }
+
+ @Override
+ public long getTotalCompleted() {
+ return totalCompleted;
+ }
+
+ @Override
+ public long getTotalSubmitted() {
+ return totalSubmitted;
+ }
+
+ @Override
+ public String getQueueName() {
+ return getName();
+ }
+
+ @Override
+ public int getQueued() {
+ return queued;
+ }
+
+ @Override
+ public int getHighestQueued() {
+ return highestQueued;
+ }
+
+ @Override
+ public int getMaxThreads() {
+ return maxThreads;
+ }
+
+ public void setQueued(int queued) {
+ this.queued = queued;
+ }
+
+ public void setHighestQueued(int highestQueued) {
+ this.highestQueued = highestQueued;
+ }
+
+ public void setMaxThreads(int maxThreads) {
+ this.maxThreads = maxThreads;
+ }
+
+ public void setActiveThreads(int activeThreads) {
+ this.activeThreads = activeThreads;
+ }
+
+ public void setHighestActiveThreads(int highestActiveThreads) {
+ this.highestActiveThreads = highestActiveThreads;
+ }
+
+ public void setTotalSubmitted(long totalSubmitted) {
+ this.totalSubmitted = totalSubmitted;
+ }
+
+ public void setTotalCompleted(long totalCompleted) {
+ this.totalCompleted = totalCompleted;
+ }
+
+ public void setQueueName(String name) {
+ setName(name);
+ }
+
+ public String toString() {
+ StringBuilder str = new StringBuilder();
+
+ str.append("WorkerPoolStats:"); //$NON-NLS-1$
+ str.append(" queue-name = " + getName()); //$NON-NLS-1$
+ str.append("; queued = " + queued); //$NON-NLS-1$
+ str.append("; highestQueued = " + highestQueued); //$NON-NLS-1$
+ str.append("; maxThreads = " + maxThreads); //$NON-NLS-1$
+ str.append("; activeThreads = " + activeThreads); //$NON-NLS-1$
+ str.append("; highestActiveThreads = " + highestActiveThreads); //$NON-NLS-1$
+ str.append("; totalSubmitted = " + totalSubmitted); //$NON-NLS-1$
+ str.append("; totalCompleted = " + totalCompleted); //$NON-NLS-1$
+ return str.toString();
+ }
+
+}
+
Property changes on: branches/as7/admin/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.teiid.adminapi.DataPolicy.PermissionType;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import static junit.framework.Assert.*;
+
+public class TestDataPolicyMetaData {
+
+ @Test
+ public void testAllowed() {
+ DataPolicyMetadata policy = new DataPolicyMetadata();
+ policy.setName("readOnly"); //$NON-NLS-1$
+ policy.setDescription("Only has read only permissions"); //$NON-NLS-1$
+ policy.setMappedRoleNames(Arrays.asList("jack", "susan")); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ PermissionMetaData perm1 = new PermissionMetaData();
+ perm1.setResourceName("catalog.schema.Table1"); //$NON-NLS-1$
+ perm1.setAllowRead(true);
+
+ PermissionMetaData perm2 = new PermissionMetaData();
+ perm2.setResourceName("catalog.schema.Table2"); //$NON-NLS-1$
+ perm2.setAllowRead(false);
+
+ PermissionMetaData perm3 = new PermissionMetaData();
+ perm3.setResourceName("catalog.schema.Table3"); //$NON-NLS-1$
+ perm3.setAllowRead(true);
+
+ PermissionMetaData perm4 = new PermissionMetaData();
+ perm4.setResourceName("catalog.schema.Table4"); //$NON-NLS-1$
+ perm4.setAllowRead(true);
+
+ PermissionMetaData perm5 = new PermissionMetaData();
+ perm5.setResourceName("catalog.schema.Table5.column1"); //$NON-NLS-1$
+ perm5.setAllowRead(true);
+
+ policy.addPermission(perm1, perm2, perm3, perm4, perm5);
+
+
+ assertTrue(policy.allows("catalog.schema.Table1", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table1", PermissionType.CREATE)); //$NON-NLS-1$
+
+ assertFalse(policy.allows("catalog.schema", PermissionType.READ)); //$NON-NLS-1$
+
+ assertFalse(policy.allows("catalog.schema.Table2.column", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table2", PermissionType.READ)); //$NON-NLS-1$
+
+ assertTrue(policy.allows("catalog.schema.Table3.column", PermissionType.READ)); //$NON-NLS-1$
+ assertTrue(policy.allows("catalog.schema.Table3", PermissionType.READ)); //$NON-NLS-1$
+
+ assertTrue(policy.allows("catalog.schema.Table4.column", PermissionType.READ)); //$NON-NLS-1$
+ assertTrue(policy.allows("catalog.schema.Table4", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table4", PermissionType.DELETE)); //$NON-NLS-1$
+
+ assertTrue(policy.allows("catalog.schema.Table5.column1", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table5.column2", PermissionType.READ)); //$NON-NLS-1$
+ assertFalse(policy.allows("catalog.schema.Table5", PermissionType.READ)); //$NON-NLS-1$
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestDataPolicyMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.teiid.adminapi.Model;
+
+@SuppressWarnings("nls")
+public class TestModelMetaData {
+
+ @Test
+ public void testModelType() {
+
+ ModelMetaData model = new ModelMetaData();
+ model.modelType = "physical";
+
+ assertTrue(model.getModelType() == Model.Type.PHYSICAL);
+ assertTrue(model.isSource());
+
+ model.modelType = "VIRTUAL";
+ assertTrue(model.getModelType() == Model.Type.VIRTUAL);
+
+ model.modelType = "TYPE";
+ assertTrue(model.getModelType() == Model.Type.OTHER);
+ assertTrue(!model.isSource());
+ }
+
+ @Test
+ public void testSupportMultiSource() {
+ ModelMetaData model = new ModelMetaData();
+ assertFalse(model.isSupportsMultiSourceBindings());
+ model.setSupportsMultiSourceBindings(true);
+
+ assertTrue(model.isSupportsMultiSourceBindings());
+
+ assertTrue(!model.getProperties().isEmpty());
+ }
+
+ public void testErrors() {
+ ModelMetaData m = new ModelMetaData();
+ m.addError("ERROR", "I am Error");
+ m.addError("WARNING", "I am warning");
+
+ assertFalse(m.getErrors().isEmpty());
+ assertEquals(1, m.getErrors().size());
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestModelMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.dmr.ModelNode;
+import org.junit.Test;
+import org.teiid.adminapi.Request.ProcessingState;
+import org.teiid.adminapi.Request.ThreadState;
+@SuppressWarnings("nls")
+public class TestRequestMetadata {
+
+ @Test public void testMapping() {
+ RequestMetadata request = buildRequest();
+
+ ModelNode node = MetadataMapper.RequestMetadataMapper.wrap(request, new ModelNode());
+
+ RequestMetadata actual = MetadataMapper.RequestMetadataMapper.unwrap(node);
+
+ assertEquals(request, actual);
+ assertEquals(request.getState(), actual.getState());
+ }
+
+ private RequestMetadata buildRequest() {
+ RequestMetadata request = new RequestMetadata();
+ request.setState(ProcessingState.PROCESSING);
+ request.setCommand("select * from foo"); //$NON-NLS-1$
+ request.setExecutionId(1234);
+ request.setName("request-name"); //$NON-NLS-1$
+ request.setSessionId("session-id");//$NON-NLS-1$
+ request.setSourceRequest(false);
+ request.setStartTime(12345L);
+ request.setTransactionId("transaction-id");//$NON-NLS-1$
+ request.setThreadState(ThreadState.RUNNING);
+ //request.setNodeId(1);
+ return request;
+ }
+
+ public static final String desc = "{\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
+ " },\n" +
+ " \"attributes\" : {\n" +
+ " \"execution-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Unique Identifier for Request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"session-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Session Identifier\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"start-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Start time for the request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"command\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Executing Command\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"source-request\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"BOOLEAN\"\n" +
+ " },\n" +
+ " \"description\" : \"Is this Connector level request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"node-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
+ " },\n" +
+ " \"description\" : \"Node Identifier\",\n" +
+ " \"required\" : false\n" +
+ " },\n" +
+ " \"transaction-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Get Transaction XID if transaction involved\",\n" +
+ " \"required\" : false\n" +
+ " },\n" +
+ " \"processing-state\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"State of the Request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"thread-state\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Thread state\",\n" +
+ " \"required\" : true\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ @Test public void testDescribe() {
+ assertEquals(desc, MetadataMapper.RequestMetadataMapper.describe(new ModelNode()).toJSONString(false));
+ }
+
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.dmr.ModelNode;
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class TestSessionMetadata {
+
+ @Test public void testMapping() {
+ SessionMetadata session = new SessionMetadata();
+ session.setSessionId("test");
+ session.setApplicationName("foo");
+ session.setClientHostName("localhost");
+ session.setCreatedTime(1234);
+ session.setIPAddress("127.0.0.1");
+ session.setVDBName("vdb-name");
+ session.setVDBVersion(2);
+ session.setSecurityContext("auth-domain");
+ session.setUserName("user");
+
+ ModelNode node = MetadataMapper.SessionMetadataMapper.wrap(session, new ModelNode());
+
+ SessionMetadata session1 = MetadataMapper.SessionMetadataMapper.unwrap(node);
+
+ assertEquals(session.getSessionId(), session1.getSessionId());
+ assertEquals(session.getApplicationName(), session1.getApplicationName());
+
+ }
+
+ private static final String describe = "{\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
+ " },\n" +
+ " \"attributes\" : {\n" +
+ " \"application-name\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Application assosiated with Session\",\n" +
+ " \"required\" : false\n" +
+ " },\n" +
+ " \"created-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"When session created\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"client-host-address\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Host name from where the session created\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"ip-address\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"IP address from where session is created\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"last-ping-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Last ping time\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"session-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Session Identifier\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"user-name\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"User name associated with session\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"vdb-name\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"The Virtual Database Name\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"vdb-version\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
+ " },\n" +
+ " \"description\" : \"The Virtual Database Version\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"security-domain\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Security domain that session used for login\",\n" +
+ " \"required\" : false\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ @Test public void testDescribe() {
+ ModelNode n = MetadataMapper.SessionMetadataMapper.describe(new ModelNode());
+ //System.out.println(n.toJSONString(false));
+ assertEquals(describe, n.toJSONString(false));
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.dmr.ModelNode;
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class TestTransactionMetadata {
+
+ @Test public void testMapping() {
+ TransactionMetadata tm = new TransactionMetadata();
+ tm.setAssociatedSession("x");
+ tm.setCreatedTime(1234);
+ tm.setId("tnx-id");
+ tm.setScope("scope");
+
+ ModelNode node = MetadataMapper.TransactionMetadataMapper.wrap(tm, new ModelNode());
+
+ TransactionMetadata tm1 = MetadataMapper.TransactionMetadataMapper.unwrap(node);
+
+ assertEquals(tm.getAssociatedSession(), tm1.getAssociatedSession());
+
+ assertEquals(tm.getCreatedTime(), tm1.getCreatedTime());
+ assertEquals(tm.getId(), tm1.getId());
+ assertEquals(tm.getScope(), tm1.getScope());
+ }
+
+ private static final String describe = "{\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
+ " },\n" +
+ " \"attributes\" : {\n" +
+ " \"session-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Session Identifier\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"txn-created-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Transaction created time\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"txn-scope\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Transaction scope (Request, Local, Global)\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"txn-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Transaction Identifier (XID)\",\n" +
+ " \"required\" : true\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ @Test
+ public void testDescribe() {
+ ModelNode n = MetadataMapper.TransactionMetadataMapper.describe(new ModelNode());
+ //System.out.println(n.toJSONString(false));
+ assertEquals(describe, n.toJSONString(false));
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,232 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.jboss.dmr.ModelNode;
+import org.junit.Test;
+import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.PropertiesUtils;
+import org.teiid.core.util.UnitTestUtil;
+
+@SuppressWarnings("nls")
+public class TestVDBMetaData {
+
+ @Test
+ public void testMarshellUnmarshell() throws Exception {
+
+ VDBMetaData vdb = buildVDB();
+
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd")); //$NON-NLS-1$
+ JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
+ Marshaller marshell = jc.createMarshaller();
+ marshell.setSchema(schema);
+ marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
+
+ StringWriter sw = new StringWriter();
+ marshell.marshal(vdb, sw);
+
+ System.out.println(sw.toString());
+
+ // UnMarshell
+ Unmarshaller un = jc.createUnmarshaller();
+ un.setSchema(schema);
+ vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
+
+ validateVDB(vdb);
+ }
+
+ static void validateVDB(VDBMetaData vdb) {
+ ModelMetaData modelOne;
+ ModelMetaData modelTwo;
+ assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$
+ assertEquals("vdb description", vdb.getDescription()); //$NON-NLS-1$
+ assertEquals(1, vdb.getVersion());
+ assertEquals("vdb-value", vdb.getPropertyValue("vdb-property")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertNotNull(vdb.getModel("model-one")); //$NON-NLS-1$
+ assertNotNull(vdb.getModel("model-two")); //$NON-NLS-1$
+ assertNull(vdb.getModel("model-unknown")); //$NON-NLS-1$
+
+ modelOne = vdb.getModel("model-one"); //$NON-NLS-1$
+ assertEquals("model-one", modelOne.getName()); //$NON-NLS-1$
+ assertEquals("s1", modelOne.getSourceNames().get(0)); //$NON-NLS-1$
+ assertEquals(Model.Type.PHYSICAL, modelOne.getModelType());
+ assertEquals("model-value-override", modelOne.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse(modelOne.isVisible());
+ assertEquals("model description", modelOne.getDescription());
+
+ modelTwo = vdb.getModel("model-two"); //$NON-NLS-1$
+ assertEquals("model-two", modelTwo.getName()); //$NON-NLS-1$
+ assertTrue(modelTwo.getSourceNames().contains("s1")); //$NON-NLS-1$
+ assertTrue(modelTwo.getSourceNames().contains("s2")); //$NON-NLS-1$
+ assertEquals(Model.Type.VIRTUAL, modelTwo.getModelType()); // this is not persisted in the XML
+ assertEquals("model-value", modelTwo.getPropertyValue("model-prop")); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ assertTrue(vdb.getValidityErrors().contains("There is an error in VDB")); //$NON-NLS-1$
+
+ List<Translator> translators = vdb.getOverrideTranslators();
+ assertTrue(translators.size() == 1);
+
+ Translator translator = translators.get(0);
+ assertEquals("oracleOverride", translator.getName());
+ assertEquals("oracle", translator.getType());
+ assertEquals("my-value", translator.getPropertyValue("my-property"));
+ assertEquals("hello world", translator.getDescription());
+ List<DataPolicy> roles = vdb.getDataPolicies();
+
+ assertTrue(roles.size() == 1);
+
+ DataPolicyMetadata role = vdb.getDataPolicy("roleOne"); //$NON-NLS-1$
+ assertTrue(role.isAllowCreateTemporaryTables());
+ assertEquals("roleOne described", role.getDescription()); //$NON-NLS-1$
+ assertNotNull(role.getMappedRoleNames());
+ assertTrue(role.getMappedRoleNames().contains("ROLE1")); //$NON-NLS-1$
+ assertTrue(role.getMappedRoleNames().contains("ROLE2")); //$NON-NLS-1$
+
+ List<DataPolicy.DataPermission> permissions = role.getPermissions();
+ assertEquals(2, permissions.size());
+
+ for (DataPolicy.DataPermission p: permissions) {
+ if (p.getResourceName().equalsIgnoreCase("myTable.T1")) { //$NON-NLS-1$
+ assertTrue(p.getAllowRead());
+ assertNull(p.getAllowDelete());
+ }
+ else {
+ assertFalse(p.getAllowRead());
+ assertTrue(p.getAllowDelete());
+ }
+ }
+ }
+
+ private VDBMetaData buildVDB() {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("myVDB"); //$NON-NLS-1$
+ vdb.setDescription("vdb description"); //$NON-NLS-1$
+ vdb.setVersion(1);
+ vdb.addProperty("vdb-property", "vdb-value"); //$NON-NLS-1$ //$NON-NLS-2$
+ vdb.addProperty("vdb-property2", "vdb-value2"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ ModelMetaData modelOne = new ModelMetaData();
+ modelOne.setName("model-one"); //$NON-NLS-1$
+ modelOne.addSourceMapping("s1", "translator", "java:mybinding"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setModelType(Model.Type.PHYSICAL); //$NON-NLS-1$
+ modelOne.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.addProperty("model-prop", "model-value-override"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setVisible(false);
+ modelOne.addError("ERROR", "There is an error in VDB"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setDescription("model description");
+
+ vdb.addModel(modelOne);
+
+ ModelMetaData modelTwo = new ModelMetaData();
+ modelTwo.setName("model-two"); //$NON-NLS-1$
+ modelTwo.addSourceMapping("s1", "translator", "java:binding-one"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelTwo.addSourceMapping("s2", "translator", "java:binding-two"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelTwo.setModelType(Model.Type.VIRTUAL); //$NON-NLS-1$
+ modelTwo.addProperty("model-prop", "model-value"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ vdb.addModel(modelTwo);
+
+ VDBTranslatorMetaData t1 = new VDBTranslatorMetaData();
+ t1.setName("oracleOverride");
+ t1.setType("oracle");
+ t1.setDescription("hello world");
+ t1.addProperty("my-property", "my-value");
+ List<Translator> list = new ArrayList<Translator>();
+ list.add(t1);
+ vdb.setOverrideTranslators(list);
+
+ DataPolicyMetadata roleOne = new DataPolicyMetadata();
+ roleOne.setName("roleOne"); //$NON-NLS-1$
+ roleOne.setDescription("roleOne described"); //$NON-NLS-1$
+ roleOne.setAllowCreateTemporaryTables(true);
+ PermissionMetaData perm1 = new PermissionMetaData();
+ perm1.setResourceName("myTable.T1"); //$NON-NLS-1$
+ perm1.setAllowRead(true);
+ roleOne.addPermission(perm1);
+
+ PermissionMetaData perm2 = new PermissionMetaData();
+ perm2.setResourceName("myTable.T2"); //$NON-NLS-1$
+ perm2.setAllowRead(false);
+ perm2.setAllowDelete(true);
+ roleOne.addPermission(perm2);
+
+ roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ vdb.addDataPolicy(roleOne);
+ return vdb;
+ }
+
+ @Test
+ public void testAdminMOCreation() {
+ VDBMetaData vdb = new VDBMetaData();
+
+ PropertiesUtils.setBeanProperty(vdb, "url", "http://teiid.org/myvdb.vdb");
+
+ assertEquals("http://teiid.org/myvdb.vdb", vdb.getUrl());
+ }
+
+ @Test public void testSetUrlVersion() throws MalformedURLException {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("foo");
+ vdb.setUrl(new URL("file:///x/foo.2.vdb"));
+ assertEquals(2, vdb.getVersion());
+ }
+
+ @Test public void testVDBMetaDataMapper() {
+ VDBMetaData vdb = buildVDB();
+
+ ModelNode node = MetadataMapper.wrap(vdb, new ModelNode());
+
+ vdb = MetadataMapper.unwrap(node);
+ validateVDB(vdb);
+ }
+
+ @Test
+ public void testVDBMetaDataDescribe() throws Exception {
+ ModelNode node = MetadataMapper.describe(new ModelNode());
+ String actual = node.toJSONString(false);
+ assertEquals(ObjectConverterUtil.convertFileToString(new File(UnitTestUtil.getTestDataPath() + "/vdb-describe.txt")), actual);
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
===================================================================
--- branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java (rev 0)
+++ branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,17 @@
+package org.teiid.adminapi.impl;
+
+import java.io.FileInputStream;
+
+import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
+
+@SuppressWarnings("nls")
+public class TestVDBMetadataParser {
+
+ @Test
+ public void testparseVDB() throws Exception {
+ FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/parser-test-vdb.xml");
+ VDBMetaData vdb = VDBMetadataParser.unmarshell(in);
+ TestVDBMetaData.validateVDB(vdb);
+ }
+}
Property changes on: branches/as7/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/adminshell/pom.xml
===================================================================
--- branches/as7/adminshell/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/adminshell/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -25,6 +25,10 @@
<artifactId>teiid-client</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ </dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
Modified: branches/as7/api/pom.xml
===================================================================
--- branches/as7/api/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/api/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -25,6 +25,12 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -9,6 +9,7 @@
<resource-root path="teiid-metadata-${project.version}.jar" />
<resource-root path="teiid-runtime-${project.version}.jar" />
<resource-root path="teiid-engine-${project.version}.jar" />
+ <resource-root path="teiid-admin-${project.version}.jar" />
<resource-root path="saxonhe-9.2.1.5.jar" />
<resource-root path="json-simple-1.1.jar" />
<resource-root path="conf" />
Modified: branches/as7/connectors/pom.xml
===================================================================
--- branches/as7/connectors/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/connectors/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -44,6 +44,11 @@
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-engine</artifactId>
<scope>test</scope>
</dependency>
Modified: branches/as7/engine/pom.xml
===================================================================
--- branches/as7/engine/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/engine/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -47,6 +47,12 @@
<artifactId>teiid-client</artifactId>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
Property changes on: branches/as7/jboss-integration
___________________________________________________________________
Modified: svn:ignore
- .classpath
.project
.settings
target
+ .classpath
.project
.settings
target
transaction.log
Modified: branches/as7/jboss-integration/pom.xml
===================================================================
--- branches/as7/jboss-integration/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -30,6 +30,11 @@
</dependency>
<dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
<scope>provided</scope>
Added: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java (rev 0)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.teiid.jboss;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.OperationStepHandler;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.descriptions.DescriptionProvider;
+import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.dmr.ModelNode;
+
+public abstract class BaseOperationHandler<T> implements DescriptionProvider, OperationStepHandler {
+ private static final String DESCRIBE = ".describe"; //$NON-NLS-1$
+ protected static final String MISSING = ".missing"; //$NON-NLS-1$
+
+ private String operationName;
+
+ protected BaseOperationHandler(String operationName){
+ this.operationName = operationName;
+ }
+
+ public void register(ManagementResourceRegistration subsystem) {
+ subsystem.registerOperationHandler(this.operationName, this, this);
+ }
+
+ public String name() {
+ return this.operationName;
+ }
+
+ public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
+ if (context.getType() == OperationContext.Type.SERVER) {
+ context.addStep(new OperationStepHandler() {
+ public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
+
+ ModelNode model = context.getResult();
+
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+
+ executeOperation(getService(context, pathAddress), operation, model);
+
+ context.completeStep();
+ }
+
+ }, OperationContext.Stage.RUNTIME);
+ }
+ else {
+ context.getResult().set("no metrics available"); //$NON-NLS-1$
+ }
+ context.completeStep();
+ }
+
+ @SuppressWarnings("unused")
+ protected T getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException{
+ return null;
+ }
+
+ @Override
+ public ModelNode getModelDescription(final Locale locale) {
+ final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
+ final ModelNode operation = new ModelNode();
+ operation.get(OPERATION_NAME).set(this.operationName);
+ operation.get(DESCRIPTION).set(bundle.getString(name()+DESCRIBE));
+ describeParameters(operation, bundle);
+ return operation;
+ }
+
+ protected String getReplyName() {
+ return name()+".reply"+DESCRIBE; //$NON-NLS-1$
+ }
+
+ protected String getParameterDescription(ResourceBundle bundle, String paramName) {
+ return bundle.getString(name()+"."+paramName+DESCRIBE); //$NON-NLS-1$
+ }
+
+ abstract protected void executeOperation(T service, ModelNode operation, ModelNode node) throws OperationFailedException;
+
+ protected void describeParameters(@SuppressWarnings("unused") ModelNode operationNode, @SuppressWarnings("unused")ResourceBundle bundle) {
+ }
+}
Property changes on: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/BaseOperationHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -33,10 +33,7 @@
import javax.resource.spi.work.WorkManager;
import javax.transaction.TransactionManager;
-import org.jboss.as.controller.AbstractBoottimeAddStepHandler;
-import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.controller.ServiceVerificationHandler;
+import org.jboss.as.controller.*;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.NamingStore;
@@ -63,7 +60,7 @@
import org.teiid.transport.SSLConfiguration;
import org.teiid.transport.SocketConfiguration;
-class QueryEngineAdd extends AbstractBoottimeAddStepHandler implements DescriptionProvider {
+class QueryEngineAdd extends AbstractAddStepHandler implements DescriptionProvider {
@Override
public ModelNode getModelDescription(Locale locale) {
@@ -80,18 +77,27 @@
@Override
protected void populateModel(ModelNode operation, ModelNode model) {
- populateQueryEngine(operation, model);
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+ final String engineName = pathAddress.getLastElement().getValue();
+
+ populateQueryEngine(engineName, operation, model);
}
@Override
- protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {
+ protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
+ final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
ServiceTarget target = context.getServiceTarget();
final JBossLifeCycleListener shutdownListener = new JBossLifeCycleListener();
-
+
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+ final String engineName = pathAddress.getLastElement().getValue();
+
// now build the engine
- final RuntimeEngineDeployer engine = buildQueryEngine(operation);
+ final RuntimeEngineDeployer engine = buildQueryEngine(engineName, operation);
engine.setSecurityHelper(new JBossSecurityHelper());
engine.setContainerLifeCycleListener(shutdownListener);
// TODO: none of the caching is configured..
@@ -161,8 +167,8 @@
}
- private RuntimeEngineDeployer buildQueryEngine(ModelNode node) {
- RuntimeEngineDeployer engine = new RuntimeEngineDeployer(node.require(Configuration.ENGINE_NAME).asString());
+ private RuntimeEngineDeployer buildQueryEngine(String engineName, ModelNode node) {
+ RuntimeEngineDeployer engine = new RuntimeEngineDeployer(engineName);
if (node.hasDefined(Configuration.MAX_THREADS)) {
engine.setMaxThreads(node.get(Configuration.MAX_THREADS).asInt());
@@ -280,7 +286,6 @@
}
static void describeQueryEngine(ModelNode node, String type, ResourceBundle bundle) {
- addAttribute(node, Configuration.ENGINE_NAME, type, bundle.getString(Configuration.ENGINE_NAME+Configuration.DESC), ModelType.STRING, true, null);
addAttribute(node, Configuration.MAX_THREADS, type, bundle.getString(Configuration.MAX_THREADS+DESC), ModelType.INT, false, "64"); //$NON-NLS-1$
addAttribute(node, Configuration.MAX_ACTIVE_PLANS, type, bundle.getString(Configuration.MAX_ACTIVE_PLANS+DESC), ModelType.INT, false, "20"); //$NON-NLS-1$
addAttribute(node, Configuration.USER_REQUEST_SOURCE_CONCURRENCY, type, bundle.getString(Configuration.USER_REQUEST_SOURCE_CONCURRENCY+DESC), ModelType.INT, false, "0"); //$NON-NLS-1$
@@ -343,10 +348,10 @@
addAttribute(node, Configuration.AUTH_MODE, type, bundle.getString(Configuration.AUTH_MODE+DESC), ModelType.STRING, false, "anonymous"); //$NON-NLS-1$
}
- private void populateQueryEngine(ModelNode operation, ModelNode model) {
- model.get(Configuration.ENGINE_NAME).set(operation.require(Configuration.ENGINE_NAME).asString());
+ private void populateQueryEngine(String engineName, ModelNode operation, ModelNode model) {
+ model.get(Configuration.ENGINE_NAME).set(engineName);
- if (operation.hasDefined(Configuration.MAX_THREADS)) {
+ if (operation.hasDefined(Configuration.MAX_THREADS)) {
model.get(Configuration.MAX_THREADS).set(operation.get(Configuration.MAX_THREADS).asInt());
}
if (operation.hasDefined(Configuration.MAX_ACTIVE_PLANS)) {
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -22,73 +22,49 @@
package org.teiid.jboss;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
-import static org.teiid.jboss.Configuration.addAttribute;
import java.util.Collection;
import java.util.List;
-import java.util.Locale;
import java.util.ResourceBundle;
-import org.jboss.as.controller.*;
-import org.jboss.as.controller.descriptions.DescriptionProvider;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.impl.*;
+import org.teiid.adminapi.impl.MetadataMapper.TransactionMetadataMapper;
import org.teiid.adminapi.impl.MetadataMapper.VDBTranslatorMetaDataMapper;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.jboss.deployers.RuntimeEngineDeployer;
-abstract class QueryEngineOperationHandler extends AbstractAddStepHandler implements DescriptionProvider {
- private static final String DESCRIBE = ".describe"; //$NON-NLS-1$
+abstract class QueryEngineOperationHandler extends BaseOperationHandler<RuntimeEngineDeployer> {
- private String operationName;
-
protected QueryEngineOperationHandler(String operationName){
- this.operationName = operationName;
+ super(operationName);
}
@Override
- protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException{
-
+ protected RuntimeEngineDeployer getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ String serviceName = pathAddress.getLastElement().getValue();
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.engineServiceName(serviceName));
+ return RuntimeEngineDeployer.class.cast(sc.getValue());
}
+}
+
+abstract class TranslatorOperationHandler extends BaseOperationHandler<TranslatorRepository> {
+ protected TranslatorOperationHandler(String operationName){
+ super(operationName);
+ }
+
@Override
- protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
- final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
-
- ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.engineServiceName(operation.require(Configuration.ENGINE_NAME).asString()));
- RuntimeEngineDeployer engine = RuntimeEngineDeployer.class.cast(sc.getValue());
- executeOperation(engine, operation, model);
- }
-
-
- @Override
- public ModelNode getModelDescription(final Locale locale) {
- final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
- final ModelNode operation = new ModelNode();
- operation.get(OPERATION_NAME).set(this.operationName);
- operation.get(DESCRIPTION).set(bundle.getString(getBundleOperationName()+DESCRIBE));
- addAttribute(operation, Configuration.ENGINE_NAME, REQUEST_PROPERTIES, bundle.getString(Configuration.ENGINE_NAME+Configuration.DESC), ModelType.STRING, true, null);
- describeParameters(operation, bundle);
- return operation;
- }
-
- protected String getBundleOperationName() {
- return RuntimeEngineDeployer.class.getSimpleName()+"."+this.operationName; //$NON-NLS-1$
- }
-
- protected String getReplyName() {
- return getBundleOperationName()+".reply"+DESCRIBE; //$NON-NLS-1$
- }
-
- protected String getParameterDescription(ResourceBundle bundle, String parmName) {
- return bundle.getString(RuntimeEngineDeployer.class.getSimpleName()+"."+this.operationName+"."+parmName+DESCRIBE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- abstract protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException;
-
- protected void describeParameters(@SuppressWarnings("unused") ModelNode operationNode, @SuppressWarnings("unused")ResourceBundle bundle) {
+ public TranslatorRepository getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.TRANSLATOR_REPO);
+ return TranslatorRepository.class.cast(sc.getValue());
}
}
@@ -100,6 +76,10 @@
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
node.set(engine.getRuntimeVersion());
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.STRING);
+ operationNode.get(REPLY_PROPERTIES, DESCRIBE).set(bundle.getString(getReplyName()));
+ }
}
class GetActiveSessionsCount extends QueryEngineOperationHandler{
@@ -114,38 +94,45 @@
// TODO: handle exception in model node terms
}
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.INT);
+ operationNode.get(REPLY_PROPERTIES, DESCRIBE).set(bundle.getString(getReplyName()));
+ }
}
class GetActiveSessions extends QueryEngineOperationHandler{
- protected GetActiveSessions(String operationName) {
- super(operationName);
+ protected GetActiveSessions() {
+ super("active-sessions"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
- node.get(TYPE).set(ModelType.LIST);
-
try {
Collection<SessionMetadata> sessions = engine.getActiveSessions();
for (SessionMetadata session:sessions) {
- node.add(MetadataMapper.SessionMetadataMapper.wrap(session, node.add()));
+ MetadataMapper.SessionMetadataMapper.wrap(session, node.add());
}
} catch (AdminException e) {
// TODO: handle exception in model node terms
}
}
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.SessionMetadataMapper.describe(new ModelNode()));
+ }
}
class GetRequestsPerSession extends QueryEngineOperationHandler{
- protected GetRequestsPerSession(String operationName) {
- super(operationName);
+ protected GetRequestsPerSession() {
+ super("requests-per-session"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
- node.get(TYPE).set(ModelType.LIST);
-
+ if (!operation.hasDefined(OperationsConstants.SESSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
+ }
List<RequestMetadata> requests = engine.getRequestsForSession(operation.get(OperationsConstants.SESSION).asString());
for (RequestMetadata request:requests) {
- node.add(MetadataMapper.RequestMetadataMapper.wrap(request, node.add()));
+ MetadataMapper.RequestMetadataMapper.wrap(request, node.add());
}
}
@@ -154,27 +141,33 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
- //TODO: define response??
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.RequestMetadataMapper.describe(new ModelNode()));
}
}
class GetRequestsPerVDB extends QueryEngineOperationHandler{
- protected GetRequestsPerVDB(String operationName) {
- super(operationName);
+ protected GetRequestsPerVDB() {
+ super("requests-per-vdb"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
- node.get(TYPE).set(ModelType.LIST);
-
try {
+
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+
String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
List<RequestMetadata> requests = engine.getRequestsUsingVDB(vdbName,vdbVersion);
for (RequestMetadata request:requests) {
- node.add(MetadataMapper.RequestMetadataMapper.wrap(request, node.add()));
+ MetadataMapper.RequestMetadataMapper.wrap(request, node.add());
}
} catch (AdminException e) {
- // TODO: handle exception in model node terms
+ throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
}
}
@@ -187,31 +180,35 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
- //TODO: define response??
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.RequestMetadataMapper.describe(new ModelNode()));
}
}
class GetLongRunningQueries extends QueryEngineOperationHandler{
- protected GetLongRunningQueries(String operationName) {
- super(operationName);
+ protected GetLongRunningQueries() {
+ super("long-running-queries"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
- node.get(TYPE).set(ModelType.LIST);
-
List<RequestMetadata> requests = engine.getLongRunningRequests();
for (RequestMetadata request:requests) {
- node.add(MetadataMapper.RequestMetadataMapper.wrap(request, node.add()));
+ MetadataMapper.RequestMetadataMapper.wrap(request, node.add());
}
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.RequestMetadataMapper.describe(new ModelNode()));
+ }
}
class TerminateSession extends QueryEngineOperationHandler{
- protected TerminateSession(String operationName) {
- super(operationName);
+ protected TerminateSession() {
+ super("terminate-session"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
+ if (!operation.hasDefined(OperationsConstants.SESSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
+ }
engine.terminateSession(operation.get(OperationsConstants.SESSION).asString());
}
@@ -223,15 +220,19 @@
}
class CancelQuery extends QueryEngineOperationHandler{
- protected CancelQuery(String operationName) {
- super(operationName);
+ protected CancelQuery() {
+ super("cancel-query"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException{
try {
- engine.cancelRequest(operation.get(OperationsConstants.SESSION).asString(), operation.get(OperationsConstants.EXECUTION_ID).asLong());
+ if (!operation.hasDefined(OperationsConstants.SESSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
+ }
+ boolean pass = engine.cancelRequest(operation.get(OperationsConstants.SESSION).asString(), operation.get(OperationsConstants.EXECUTION_ID).asLong());
+ node.set(pass);
} catch (AdminException e) {
- // TODO: handle exception in model node terms
+ throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
}
}
@@ -243,30 +244,45 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, TYPE).set(ModelType.LONG);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.EXECUTION_ID));
+
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.BOOLEAN);
+ operationNode.get(REPLY_PROPERTIES, DESCRIBE).set(bundle.getString(getReplyName()));
}
}
class CacheTypes extends QueryEngineOperationHandler{
- protected CacheTypes(String operationName) {
- super(operationName);
+ protected CacheTypes() {
+ super("cache-types"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
- node.get(TYPE).set(ModelType.LIST);
Collection<String> types = engine.getCacheTypes();
for (String type:types) {
node.add(type);
}
}
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ ModelNode node = new ModelNode();
+ node.get(OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
+ node.get(OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
+ node.get(OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
+ operationNode.get(REPLY_PROPERTIES).add(node);
+ }
}
class ClearCache extends QueryEngineOperationHandler{
- protected ClearCache(String operationName) {
- super(operationName);
+ protected ClearCache() {
+ super("clear-cache"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
+ }
+
String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
if (operation.get(OperationsConstants.VDB_NAME) != null && operation.get(OperationsConstants.VDB_VERSION) != null) {
@@ -297,11 +313,14 @@
class CacheStatistics extends QueryEngineOperationHandler{
- protected CacheStatistics(String operationName) {
- super(operationName);
+ protected CacheStatistics() {
+ super("cache-statistics"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.CACHE_TYPE)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CACHE_TYPE+MISSING)));
+ }
String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
CacheStatisticsMetadata stats = engine.getCacheStatistics(cacheType);
MetadataMapper.CacheStatisticsMetadataMapper.wrap(stats, node);
@@ -311,51 +330,62 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
+
+ ModelNode node = new ModelNode();
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.CacheStatisticsMetadataMapper.describe(node));
}
}
class WorkerPoolStatistics extends QueryEngineOperationHandler{
- protected WorkerPoolStatistics(String operationName) {
- super(operationName);
+ protected WorkerPoolStatistics() {
+ super("workerpool-statistics"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
WorkerPoolStatisticsMetadata stats = engine.getWorkerPoolStatistics();
MetadataMapper.WorkerPoolStatisticsMetadataMapper.wrap(stats, node);
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.WorkerPoolStatisticsMetadataMapper.describe(new ModelNode()));
+ }
}
class ActiveTransactions extends QueryEngineOperationHandler{
- protected ActiveTransactions(String operationName) {
- super(operationName);
+ protected ActiveTransactions() {
+ super("active-transactions"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
Collection<TransactionMetadata> txns = engine.getTransactions();
-
- node.get(TYPE).set(ModelType.LIST);
-
for (TransactionMetadata txn:txns) {
- node.add(MetadataMapper.TransactionMetadataMapper.wrap(txn, node.add()));
+ MetadataMapper.TransactionMetadataMapper.wrap(txn, node.add());
}
-
}
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ ModelNode node = new ModelNode();
+ operationNode.get(REPLY_PROPERTIES).add(TransactionMetadataMapper.describe(node));
+ }
}
class TerminateTransaction extends QueryEngineOperationHandler{
- protected TerminateTransaction(String operationName) {
- super(operationName);
+ protected TerminateTransaction() {
+ super("terminate-transaction"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.XID)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.XID+MISSING)));
+ }
+
String xid = operation.get(OperationsConstants.XID).asString();
try {
engine.terminateTransaction(xid);
} catch (AdminException e) {
- // TODO: Handle exception
+ throw new OperationFailedException(e, new ModelNode().set(e.getMessage()));
}
}
@@ -366,19 +396,40 @@
}
}
-class MergeVDBs extends QueryEngineOperationHandler{
+class MergeVDBs extends BaseOperationHandler<VDBRepository>{
- protected MergeVDBs(String operationName) {
- super(operationName);
+ protected MergeVDBs() {
+ super("merge-vdbs"); //$NON-NLS-1$
}
+
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+ protected VDBRepository getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ return VDBRepository.class.cast(sc.getValue());
+ }
+
+ @Override
+ protected void executeOperation(VDBRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.SOURCE_VDBNAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBNAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.SOURCE_VDBVERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SOURCE_VDBVERSION+MISSING)));
+ }
+
+ if (!operation.hasDefined(OperationsConstants.TARGET_VDBNAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBNAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.TARGET_VDBVERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TARGET_VDBVERSION+MISSING)));
+ }
+
String sourceVDBName = operation.get(OperationsConstants.SOURCE_VDBNAME).asString();
int sourceVDBversion = operation.get(OperationsConstants.SOURCE_VDBVERSION).asInt();
String targetVDBName = operation.get(OperationsConstants.TARGET_VDBNAME).asString();
int targetVDBversion = operation.get(OperationsConstants.TARGET_VDBVERSION).asInt();
try {
- engine.mergeVDBs(sourceVDBName, sourceVDBversion, targetVDBName, targetVDBversion);
+ repo.mergeVDBs(sourceVDBName, sourceVDBversion, targetVDBName, targetVDBversion);
} catch (AdminException e) {
throw new OperationFailedException(new ModelNode().set(e.getMessage()));
}
@@ -405,18 +456,30 @@
class ExecuteQuery extends QueryEngineOperationHandler{
- protected ExecuteQuery(String operationName) {
- super(operationName);
+ protected ExecuteQuery() {
+ super("execute-query"); //$NON-NLS-1$
}
@Override
protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.SQL_QUERY)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SQL_QUERY+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.TIMEOUT_IN_MILLI)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TIMEOUT_IN_MILLI+MISSING)));
+ }
+
String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
String sql = operation.get(OperationsConstants.SQL_QUERY).asString();
int timeout = operation.get(OperationsConstants.TIMEOUT_IN_MILLI).asInt();
try {
- node.get(TYPE).set(ModelType.LIST);
-
List<List> results = engine.executeQuery(vdbName, vdbVersion, sql, timeout);
List colNames = results.get(0);
for (int rowNum = 1; rowNum < results.size(); rowNum++) {
@@ -452,20 +515,36 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TIMEOUT_IN_MILLI));
+
+ operationNode.get(REPLY_PROPERTIES).set(ModelType.LIST);
}
}
-class GetVDB extends QueryEngineOperationHandler{
+class GetVDB extends BaseOperationHandler<VDBRepository>{
- protected GetVDB(String operationName) {
- super(operationName);
+ protected GetVDB() {
+ super("get-vdb"); //$NON-NLS-1$
}
+
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+ protected VDBRepository getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ return VDBRepository.class.cast(sc.getValue());
+ }
+
+ @Override
+ protected void executeOperation(VDBRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+ if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
+ }
+ if (!operation.hasDefined(OperationsConstants.VDB_VERSION)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
+ }
+
String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
- VDBMetaData vdb = engine.getVDB(vdbName, vdbVersion);
+ VDBMetaData vdb = repo.getVDB(vdbName, vdbVersion);
MetadataMapper.wrap(vdb, node);
}
@@ -477,59 +556,71 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
+
+ operationNode.get(REPLY_PROPERTIES).set(MetadataMapper.describe(new ModelNode()));
}
}
-class GetVDBs extends QueryEngineOperationHandler{
+class ListVDBs extends BaseOperationHandler<VDBRepository>{
- protected GetVDBs(String operationName) {
- super(operationName);
+ protected ListVDBs() {
+ super("list-vdbs"); //$NON-NLS-1$
}
+
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
- List<VDBMetaData> vdbs = engine.getVDBs();
- node.get(TYPE).set(ModelType.LIST);
-
+ protected VDBRepository getService(OperationContext context, PathAddress pathAddress) throws OperationFailedException {
+ ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
+ return VDBRepository.class.cast(sc.getValue());
+ }
+
+ @Override
+ protected void executeOperation(VDBRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+ List<VDBMetaData> vdbs = repo.getVDBs();
for (VDBMetaData vdb:vdbs) {
node.add(MetadataMapper.wrap(vdb, node.add()));
}
}
-
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.describe(new ModelNode()));
+ }
}
-class GetTranslators extends QueryEngineOperationHandler{
+class GetTranslators extends TranslatorOperationHandler{
- protected GetTranslators(String operationName) {
- super(operationName);
+ protected GetTranslators() {
+ super("list-translators"); //$NON-NLS-1$
}
+
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
- List<VDBTranslatorMetaData> translators = engine.getTranslators();
- node.get(TYPE).set(ModelType.OBJECT);
-
+ protected void executeOperation(TranslatorRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+ List<VDBTranslatorMetaData> translators = repo.getTranslators();
for (VDBTranslatorMetaData t:translators) {
node.add(MetadataMapper.VDBTranslatorMetaDataMapper.wrap(t, node.add()));
}
}
protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REPLY_PROPERTIES, TYPE).set(ModelType.LIST);
- operationNode.get(REPLY_PROPERTIES, VALUE_TYPE).set(ModelType.OBJECT);
operationNode.get(REPLY_PROPERTIES, DESCRIPTION).set(bundle.getString(getReplyName()));
+ operationNode.get(REPLY_PROPERTIES).add(MetadataMapper.VDBTranslatorMetaDataMapper.describe(new ModelNode()));
}
}
-class GetTranslator extends QueryEngineOperationHandler{
+class GetTranslator extends TranslatorOperationHandler{
- protected GetTranslator(String operationName) {
- super(operationName);
+ protected GetTranslator() {
+ super("get-translator"); //$NON-NLS-1$
}
@Override
- protected void executeOperation(RuntimeEngineDeployer engine, ModelNode operation, ModelNode node) throws OperationFailedException {
+ protected void executeOperation(TranslatorRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.TRANSLATOR_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TRANSLATOR_NAME+MISSING)));
+ }
+
String translatorName = operation.get(OperationsConstants.TRANSLATOR_NAME).asString();
- VDBTranslatorMetaData translator = engine.getTranslator(translatorName);
+ VDBTranslatorMetaData translator = repo.getTranslatorMetaData(translatorName);
MetadataMapper.VDBTranslatorMetaDataMapper.wrap(translator, node);
}
@@ -538,7 +629,36 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TRANSLATOR_NAME));
- VDBTranslatorMetaDataMapper.describe(operationNode.get(REPLY_PROPERTIES));
+ operationNode.get(REPLY_PROPERTIES).set(VDBTranslatorMetaDataMapper.describe(new ModelNode()));
operationNode.get(REPLY_PROPERTIES, DESCRIPTION).set(bundle.getString(getReplyName()));
}
+}
+
+class ListQueryEngines extends TranslatorOperationHandler{
+
+ protected ListQueryEngines() {
+ super("list-engines"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void executeOperation(TranslatorRepository repo, ModelNode operation, ModelNode node) throws OperationFailedException {
+
+ if (!operation.hasDefined(OperationsConstants.TRANSLATOR_NAME)) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.TRANSLATOR_NAME+MISSING)));
+ }
+
+ String translatorName = operation.get(OperationsConstants.TRANSLATOR_NAME).asString();
+
+ VDBTranslatorMetaData translator = repo.getTranslatorMetaData(translatorName);
+ MetadataMapper.VDBTranslatorMetaDataMapper.wrap(translator, node);
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME, DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TRANSLATOR_NAME));
+
+ operationNode.get(REPLY_PROPERTIES).set(VDBTranslatorMetaDataMapper.describe(new ModelNode()));
+ operationNode.get(REPLY_PROPERTIES, DESCRIPTION).set(bundle.getString(getReplyName()));
+ }
}
\ No newline at end of file
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineRemove.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineRemove.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineRemove.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -21,53 +21,59 @@
*/
package org.teiid.jboss;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
-import static org.teiid.jboss.Configuration.addAttribute;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
-import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
-import org.jboss.as.controller.AbstractAddStepHandler;
+import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.controller.ServiceVerificationHandler;
+import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.DescriptionProvider;
+import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
+import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
+import org.teiid.transport.LocalServerConnection;
-public class QueryEngineRemove extends AbstractAddStepHandler implements DescriptionProvider {
+public class QueryEngineRemove extends AbstractRemoveStepHandler implements DescriptionProvider {
@Override
+ protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
+
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+
+ String engineName = pathAddress.getLastElement().getValue();
+
+ final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
+ ServiceName serviceName = TeiidServiceNames.engineServiceName(engineName);
+ final ServiceController<?> controller = serviceRegistry.getService(serviceName);
+ if (controller != null) {
+ context.removeService(serviceName);
+ }
+
+ final ServiceName referenceFactoryServiceName = TeiidServiceNames.engineServiceName(engineName).append("reference-factory"); //$NON-NLS-1$
+ final ServiceController<?> referceFactoryController = serviceRegistry.getService(referenceFactoryServiceName);
+ if (referceFactoryController != null) {
+ context.removeService(referenceFactoryServiceName);
+ }
+
+ final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(LocalServerConnection.TEIID_RUNTIME_CONTEXT+engineName);
+ final ServiceController<?> binderController = serviceRegistry.getService(bindInfo.getBinderServiceName());
+ if (binderController != null) {
+ context.removeService(bindInfo.getBinderServiceName());
+ }
+ }
+
+ @Override
public ModelNode getModelDescription(Locale locale) {
final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
final ModelNode operation = new ModelNode();
operation.get(OPERATION_NAME).set(REMOVE);
- operation.get(DESCRIPTION).set(bundle.getString("engine.remove")); //$NON-NLS-1$
- addAttribute(operation, Configuration.ENGINE_NAME, REQUEST_PROPERTIES, bundle.getString(Configuration.ENGINE_NAME+Configuration.DESC), ModelType.STRING, true, null);
+ operation.get(DESCRIPTION).set(bundle.getString(REMOVE+DESCRIBE));
return operation;
}
-
- @Override
- protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException {
- final String name = model.require(Configuration.ENGINE_NAME).asString();
- model.get(Configuration.ENGINE_NAME).set(name);
- }
-
- @Override
- protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
- final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
-
- final String engineName = model.require(Configuration.ENGINE_NAME).asString();
- final ServiceRegistry registry = context.getServiceRegistry(true);
- final ServiceController<?> controller = registry.getService(TeiidServiceNames.translatorServiceName(engineName));
- if (controller != null) {
- controller.setMode(ServiceController.Mode.REMOVE);
- }
- }
+
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -117,6 +117,10 @@
}
populateBufferManager(operation, model);
//TODO: add cache model descriptions
+
+ // these are just place holders
+// model.get(Configuration.QUERY_ENGINE);
+// model.get(Configuration.TRANSLATOR);
}
@Override
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -45,22 +45,6 @@
private static final String ACTIVE_SESSION_COUNT = "active-session-count"; //$NON-NLS-1$
private static final String RUNTIME_VERSION = "runtime-version"; //$NON-NLS-1$
- private static final String REQUESTS_PER_SESSION = "requests-per-session"; //$NON-NLS-1$
- private static final String ACTIVE_SESSIONS = "active-sessions"; //$NON-NLS-1$
- private static final String REQUESTS_PER_VDB = "requests-per-vdb"; //$NON-NLS-1$
- private static final String LONG_RUNNING_QUERIES = "long-running-queries"; //$NON-NLS-1$
- private static final String TERMINATE_SESSION = "terminate-session";//$NON-NLS-1$
- private static final String CANCEL_QUERY = "cancel-query";//$NON-NLS-1$
- private static final String CACHE_TYPES = "cache-types";//$NON-NLS-1$
- private static final String CLEAR_CACHE = "clear-cache";//$NON-NLS-1$
- private static final String CACHE_STATISTICS = "cache-statistics";//$NON-NLS-1$
- private static final String WORKERPOOL_STATISTICS = "workerpool-statistics";//$NON-NLS-1$
- private static final String ACTIVE_TRANSACTIONS = "active-transactions";//$NON-NLS-1$
- private static final String TERMINATE_TRANSACTION = "terminate-transaction";//$NON-NLS-1$
- private static final String MERGE_VDBS = "merge-vdbs";//$NON-NLS-1$
- private static final String EXECUTE_QUERY = "execute-query";//$NON-NLS-1$
- private static final String GETVDBS = "getVDBs";//$NON-NLS-1$
- private static final String GETVDB = "getVDB";//$NON-NLS-1$
public static final String TEIID_SUBSYSTEM = "teiid"; //$NON-NLS-1$
private static TeiidSubsystemParser parser = new TeiidSubsystemParser();
@@ -92,10 +76,10 @@
TeiidBootServicesAdd.describeTeiidRoot(bundle, ATTRIBUTES, node);
node.get(CHILDREN, Configuration.QUERY_ENGINE, DESCRIPTION).set(bundle.getString(Configuration.QUERY_ENGINE+Configuration.DESC));
- node.get(CHILDREN, Configuration.QUERY_ENGINE, REQUIRED).set(false);
+ node.get(CHILDREN, Configuration.QUERY_ENGINE, REQUIRED).set(true);
node.get(CHILDREN, Configuration.TRANSLATOR, DESCRIPTION).set(bundle.getString(Configuration.TRANSLATOR+Configuration.DESC));
- node.get(CHILDREN, Configuration.TRANSLATOR, REQUIRED).set(false);
+ node.get(CHILDREN, Configuration.TRANSLATOR, REQUIRED).set(true);
return node;
}
@@ -113,8 +97,6 @@
node.get(DESCRIPTION).set(bundle.getString(Configuration.TRANSLATOR+Configuration.DESC));
node.get(HEAD_COMMENT_ALLOWED).set(true);
node.get(TAIL_COMMENT_ALLOWED).set(true);
-
- addAttribute(node, Configuration.TRANSLATOR_NAME, ATTRIBUTES, bundle.getString(Configuration.TRANSLATOR_NAME+Configuration.DESC), ModelType.STRING, true, null);
addAttribute(node, Configuration.TRANSLATOR_MODULE, ATTRIBUTES, bundle.getString(Configuration.TRANSLATOR_MODULE+Configuration.DESC), ModelType.STRING, true, null);
return node;
}
@@ -141,57 +123,30 @@
engineSubsystem.registerOperationHandler(REMOVE, ENGINE_REMOVE, ENGINE_REMOVE, false);
- QueryEngineOperationHandler op;
engineSubsystem.registerReadOnlyAttribute(RUNTIME_VERSION, new GetRuntimeVersion(RUNTIME_VERSION), Storage.RUNTIME);
engineSubsystem.registerReadOnlyAttribute(ACTIVE_SESSION_COUNT, new GetActiveSessionsCount(ACTIVE_SESSION_COUNT), Storage.RUNTIME);
- op = new GetActiveSessions(ACTIVE_SESSIONS);
- engineSubsystem.registerOperationHandler(ACTIVE_SESSIONS, op, op);
+ // teiid level admin api operation handlers
+ new GetTranslator().register(teiidSubsystem);
+ new GetTranslators().register(teiidSubsystem);
+ new MergeVDBs().register(teiidSubsystem);
+ new ListVDBs().register(teiidSubsystem);
+ new GetVDB().register(teiidSubsystem);
- op = new GetRequestsPerSession(REQUESTS_PER_SESSION);
- engineSubsystem.registerOperationHandler(REQUESTS_PER_SESSION, op, op);
-
- op = new GetRequestsPerVDB(REQUESTS_PER_VDB);
- engineSubsystem.registerOperationHandler(REQUESTS_PER_VDB, op, op);
-
- op = new GetLongRunningQueries(LONG_RUNNING_QUERIES);
- engineSubsystem.registerOperationHandler(LONG_RUNNING_QUERIES, op, op);
-
- op = new TerminateSession(TERMINATE_SESSION);
- engineSubsystem.registerOperationHandler(TERMINATE_SESSION, op, op);
-
- op = new CancelQuery(CANCEL_QUERY);
- engineSubsystem.registerOperationHandler(CANCEL_QUERY, op, op);
-
- op = new CacheTypes(CACHE_TYPES);
- engineSubsystem.registerOperationHandler(CACHE_TYPES, op, op);
-
- op = new ClearCache(CLEAR_CACHE);
- engineSubsystem.registerOperationHandler(CLEAR_CACHE, op, op);
-
- op = new CacheStatistics(CACHE_STATISTICS);
- engineSubsystem.registerOperationHandler(CACHE_STATISTICS, op, op);
-
- op = new WorkerPoolStatistics(WORKERPOOL_STATISTICS);
- engineSubsystem.registerOperationHandler(WORKERPOOL_STATISTICS, op, op);
-
- op = new ActiveTransactions(ACTIVE_TRANSACTIONS);
- engineSubsystem.registerOperationHandler(ACTIVE_TRANSACTIONS, op, op);
-
- op = new TerminateTransaction(TERMINATE_TRANSACTION);
- engineSubsystem.registerOperationHandler(TERMINATE_TRANSACTION, op, op);
-
- op = new MergeVDBs(MERGE_VDBS);
- engineSubsystem.registerOperationHandler(MERGE_VDBS, op, op);
-
- op = new ExecuteQuery(EXECUTE_QUERY);
- engineSubsystem.registerOperationHandler(EXECUTE_QUERY, op, op);
-
- op = new GetVDBs(GETVDBS);
- engineSubsystem.registerOperationHandler(GETVDBS, op, op);
-
- op = new GetVDB(GETVDB);
- engineSubsystem.registerOperationHandler(GETVDB, op, op);
+ // engine level admin api handlers
+ new GetActiveSessions().register(engineSubsystem);
+ new GetRequestsPerSession().register(engineSubsystem);
+ new GetRequestsPerVDB().register(engineSubsystem);
+ new GetLongRunningQueries().register(engineSubsystem);
+ new TerminateSession().register(engineSubsystem);
+ new CancelQuery().register(engineSubsystem);
+ new CacheTypes().register(engineSubsystem);
+ new ClearCache().register(engineSubsystem);
+ new CacheStatistics().register(engineSubsystem);
+ new WorkerPoolStatistics().register(engineSubsystem);
+ new ActiveTransactions().register(engineSubsystem);
+ new TerminateTransaction().register(engineSubsystem);
+ new ExecuteQuery().register(engineSubsystem);
}
@Override
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -348,11 +348,11 @@
case SECURITY_DOMAIN_ELEMENT:
node.get(reader.getLocalName()).add(reader.getElementText());
break;
-
case JDBC_ELEMENT:
node.get(reader.getLocalName()).set(parseSocketConfiguration(reader));
break;
+
case ODBC_ELEMENT:
node.get(reader.getLocalName()).set(parseSocketConfiguration(reader));
break;
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -55,7 +55,6 @@
operation.get(OPERATION_NAME).set(ADD);
operation.get(DESCRIPTION).set(bundle.getString("translator.add")); //$NON-NLS-1$
- addAttribute(operation, Configuration.TRANSLATOR_NAME, ATTRIBUTES, bundle.getString(Configuration.TRANSLATOR_NAME+Configuration.DESC), ModelType.STRING, true, null);
addAttribute(operation, Configuration.TRANSLATOR_MODULE, ATTRIBUTES, bundle.getString(Configuration.TRANSLATOR_MODULE+Configuration.DESC), ModelType.STRING, true, null);
return operation;
}
@@ -75,7 +74,11 @@
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
- final String name = operation.require(Configuration.TRANSLATOR_NAME).asString();
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+
+ final String translatorName = pathAddress.getLastElement().getValue();
+
final String moduleName = operation.require(Configuration.TRANSLATOR_MODULE).asString();
final ServiceTarget target = context.getServiceTarget();
@@ -86,25 +89,32 @@
moduleId = ModuleIdentifier.create(moduleName);
module = Module.getCallerModuleLoader().loadModule(moduleId);
} catch (ModuleLoadException e) {
- throw new OperationFailedException(e, new ModelNode().set(IntegrationPlugin.Util.getString("failed_load_module", moduleName, name))); //$NON-NLS-1$
+ throw new OperationFailedException(e, new ModelNode().set(IntegrationPlugin.Util.getString("failed_load_module", moduleName, translatorName))); //$NON-NLS-1$
}
+
+ boolean added = false;
final ServiceLoader<ExecutionFactory> serviceLoader = module.loadService(ExecutionFactory.class);
if (serviceLoader != null) {
for (ExecutionFactory ef:serviceLoader) {
VDBTranslatorMetaData metadata = TranslatorUtil.buildTranslatorMetadata(ef, moduleName);
if (metadata == null) {
- throw new OperationFailedException( new ModelNode().set(IntegrationPlugin.Util.getString("error_adding_translator", name))); //$NON-NLS-1$
+ throw new OperationFailedException( new ModelNode().set(IntegrationPlugin.Util.getString("error_adding_translator", translatorName))); //$NON-NLS-1$
}
- if (name.equalsIgnoreCase(metadata.getName())) {
+ if (translatorName.equalsIgnoreCase(metadata.getName())) {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("translator.added", metadata.getName())); //$NON-NLS-1$
TranslatorService translatorService = new TranslatorService(metadata);
ServiceBuilder<VDBTranslatorMetaData> builder = target.addService(TeiidServiceNames.translatorServiceName(metadata.getName()), translatorService);
builder.addDependency(TeiidServiceNames.TRANSLATOR_REPO, TranslatorRepository.class, translatorService.repositoryInjector);
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
+ added = true;
}
}
}
+
+ if (!added) {
+ throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString("translator.failed-to-load", translatorName, moduleName))); //$NON-NLS-1$
+ }
}
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorRemove.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorRemove.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorRemove.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -23,25 +23,24 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
-import static org.teiid.jboss.Configuration.addAttribute;
-import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
-import org.jboss.as.controller.AbstractAddStepHandler;
+import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.controller.ServiceVerificationHandler;
+import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
+import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
-public class TranslatorRemove extends AbstractAddStepHandler implements DescriptionProvider {
+public class TranslatorRemove extends AbstractRemoveStepHandler implements DescriptionProvider {
@Override
public ModelNode getModelDescription(Locale locale) {
@@ -49,25 +48,23 @@
final ModelNode operation = new ModelNode();
operation.get(OPERATION_NAME).set(REMOVE);
operation.get(DESCRIPTION).set(bundle.getString("translator.remove")); //$NON-NLS-1$
- addAttribute(operation, Configuration.TRANSLATOR_NAME, REQUEST_PROPERTIES, bundle.getString(Configuration.TRANSLATOR_NAME+Configuration.DESC), ModelType.STRING, true, null);
return operation;
}
@Override
- protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException {
- final String translatorName = model.require(Configuration.TRANSLATOR_NAME).asString();
- model.get(Configuration.TRANSLATOR_NAME).set(translatorName);
- }
-
- @Override
- protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
- final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
-
- final String translatorName = model.require(Configuration.TRANSLATOR_NAME).asString();
- final ServiceRegistry registry = context.getServiceRegistry(true);
- final ServiceController<?> controller = registry.getService(TeiidServiceNames.translatorServiceName(translatorName));
+ protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
+
+ final ModelNode address = operation.require(OP_ADDR);
+ final PathAddress pathAddress = PathAddress.pathAddress(address);
+
+ String translatorName = pathAddress.getLastElement().getValue();
+
+ final ServiceRegistry registry = context.getServiceRegistry(true);
+ final ServiceName serviceName = TeiidServiceNames.translatorServiceName(translatorName);
+ final ServiceController<?> controller = registry.getService(serviceName);
if (controller != null) {
- controller.setMode(ServiceController.Mode.REMOVE);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("translator.removed", translatorName)); //$NON-NLS-1$
+ context.removeService(serviceName);
}
}
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-09-02 20:49:18 UTC (rev 3445)
@@ -466,12 +466,6 @@
}
@Override
- public void mergeVDBs(String sourceVDBName, int sourceVDBVersion,
- String targetVDBName, int targetVDBVersion) throws AdminException {
- this.vdbRepository.mergeVDBs(sourceVDBName, sourceVDBVersion, targetVDBName, targetVDBVersion);
- }
-
- @Override
public List<List> executeQuery(final String vdbName, final int version, final String command, final long timoutInMilli) throws AdminException {
String user = "JOPR ADMIN"; //$NON-NLS-1$
@@ -773,22 +767,6 @@
this.securityDomainNames.add(domain);
}
- public List<VDBMetaData> getVDBs(){
- return this.vdbRepository.getVDBs();
- }
-
- public VDBMetaData getVDB(String vdbName, int version){
- return this.vdbRepository.getVDB(vdbName, version);
- }
-
- public List<VDBTranslatorMetaData> getTranslators(){
- return getTranslatorRepositoryInjector().getValue().getTranslators();
- }
-
- public VDBTranslatorMetaData getTranslator(String translatorName) {
- return getTranslatorRepositoryInjector().getValue().getTranslatorMetaData(translatorName);
- }
-
private DQPCore.ContextProvider getContextProvider() {
return new DQPCore.ContextProvider() {
@Override
Modified: branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-09-02 20:49:18 UTC (rev 3445)
@@ -33,6 +33,7 @@
datasource_not_found=Datasource {0} not found in the configuration.
sourcename_not_found=No source name {0} found in the model: {1}.{2}.{3}
vdb_file_not_found = VDB file {0} not found at the location specified.
+socket_not_enabled=Socket based remote JDBC protocol is not enabled.
no_operation=No operation found with given name = {0}
failed_to_remove=Failed to remove the deployment
@@ -146,43 +147,43 @@
susbsystem.add = Add the Teiid Subsystem
#engine managed operations
-RuntimeEngineDeployer.active-sessions.describe=List of all the current active sessions in the Teiid subsystem.
-RuntimeEngineDeployer.requests-per-session.describe=Current active requests in progress in the query engine for a given session identifier
-RuntimeEngineDeployer.requests-per-session.session.describe=The session Identifier
-RuntimeEngineDeployer.requests-per-vdb.describe=Current active requests in progress in the query engine for a given VDB name and its version.
-RuntimeEngineDeployer.requests-per-vdb.vdb_name.describe=VDB Name
-RuntimeEngineDeployer.requests-per-vdb.vdb_version.describe=VDB Version
-RuntimeEngineDeployer.long-running-queries.describe=Long running queries that exceeded the threshold set by the 'queryThresholdInSecs' configuration property.
-RuntimeEngineDeployer.terminate-session.describe=Terminate the session
-RuntimeEngineDeployer.terminate-session.session.describe=The session Identifier of session to be terminated
-RuntimeEngineDeployer.cancel-query.describe=Cancel the execution of the actively running query
-RuntimeEngineDeployer.cancel-query.session.describe=The session Identifier of the user
-RuntimeEngineDeployer.cancel-query.execution-id.describe=The Execution Identifier of the query
-RuntimeEngineDeployer.cache-types.describe=List the available cache types
+active-sessions.describe=List of all the current active sessions in the Teiid subsystem.
+requests-per-session.describe=Current active requests in progress in the query engine for a given session identifier
+requests-per-session.session.describe=The session Identifier
+requests-per-vdb.describe=Current active requests in progress in the query engine for a given VDB name and its version.
+requests-per-vdb.vdb_name.describe=VDB Name
+requests-per-vdb.vdb_version.describe=VDB Version
+long-running-queries.describe=Long running queries that exceeded the threshold set by the 'queryThresholdInSecs' configuration property.
+terminate-session.describe=Terminate the session
+terminate-session.session.describe=The session Identifier of session to be terminated
+cancel-query.describe=Cancel the execution of the actively running query
+cancel-query.session.describe=The session Identifier of the user
+cancel-query.execution-id.describe=The Execution Identifier of the query
+cache-types.describe=List the available cache types
-RuntimeEngineDeployer.clear-cache.describe=Clear the caches in the system of the given type
-RuntimeEngineDeployer.clear-cache.cache-type.describe=cache type to be cleared. (PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE)
-RuntimeEngineDeployer.clear-cache.vdb-name.describe=VDB name
-RuntimeEngineDeployer.clear-cache.vdb_version.describe=VDB version
-RuntimeEngineDeployer.cache-statistics.describe=Get the cache statistics for the given cache type
-RuntimeEngineDeployer.cache-statistics.cache-type.describe=cache type (PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE)
+clear-cache.describe=Clear the caches in the system of the given type
+clear-cache.cache-type.describe=cache type to be cleared. (PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE)
+clear-cache.vdb-name.describe=VDB name
+clear-cache.vdb_version.describe=VDB version
+cache-statistics.describe=Get the cache statistics for the given cache type
+cache-statistics.cache-type.describe=cache type (PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE)
-RuntimeEngineDeployer.workerpool-statistics.describe=Get thread statistics worker pool
-RuntimeEngineDeployer.active-transactions.describe=Active Transactions in the Query Engine
+workerpool-statistics.describe=Get thread statistics worker pool
+active-transactions.describe=Active Transactions in the Query Engine
-RuntimeEngineDeployer.terminate-transaction.describe=Terminate the XA transaction
-RuntimeEngineDeployer.terminate-transaction.xid.describe=xid identifier of the XA transaction
-RuntimeEngineDeployer.merge-vdbs.describe=Merge Two VDBs
-RuntimeEngineDeployer.merge-vdbs.source-vdb-name.describe=Source VDB name
-RuntimeEngineDeployer.merge-vdbs.source-vdb-version.describe=Source VDB version number
-RuntimeEngineDeployer.merge-vdbs.target-vdb-name.describe=Target VDB name
-RuntimeEngineDeployer.merge-vdbs.target-vdb-version.describe=Target VDB version number
+terminate-transaction.describe=Terminate the XA transaction
+terminate-transaction.xid.describe=xid identifier of the XA transaction
+merge-vdbs.describe=Merge Two VDBs
+merge-vdbs.source-vdb-name.describe=Source VDB name
+merge-vdbs.source-vdb-version.describe=Source VDB version number
+merge-vdbs.target-vdb-name.describe=Target VDB name
+merge-vdbs.target-vdb-version.describe=Target VDB version number
-RuntimeEngineDeployer.execute-query.describe=Execute a sql query
-RuntimeEngineDeployer.execute-query.vdb-name.describe=vdb name
-RuntimeEngineDeployer.execute-query.vdb-version.describe=vdb version
-RuntimeEngineDeployer.execute-query.sql-query.describe=sql query to execute
-RuntimeEngineDeployer.execute-query.timeout-in-milli.describe=timeout
+execute-query.describe=Execute a sql query
+execute-query.vdb-name.describe=vdb name
+execute-query.vdb-version.describe=vdb version
+execute-query.sql-query.describe=sql query to execute
+execute-query.timeout-in-milli.describe=timeout
socket-binding.not_defined=Teiid socket binding not defined for JDBC or ODBC port.
@@ -193,4 +194,41 @@
translator.describe = Teiid Translators
translator.add = Add Teiid translator
translator.remove = Remove Teiid translator
-teiid-boot.add = Teiid boot services
\ No newline at end of file
+teiid-boot.add = Teiid boot serviceshitRatio.describe
+
+total-entries.describe = Total entries in Cache
+hit-ratio.describe = Cache Hit ratio
+request-count.describe=Total request count
+
+cache-types.cache-type.describe=cache type
+get-translators.reply.describe=Returns list of translators registered in the teiid container
+get-translator.reply.describe=Returns translator if found with given name
+active-session-count.reply.describe=Returns the count of active sessions
+runtime-version.reply.describe=Teiid runtime version
+list-vdbs.describe=List the available virtual databases in the system
+cancel-query.reply.describe=True if successful; false otherwise.
+clear-cache.vdb-version.describe=vdb version
+get-vdb.describe=Get the VDB with the given name and version
+get-vdb.vdb-name.describe=name of the vdb
+get-vdb.vdb-version.describe=vdb version
+requests-per-vdb.vdb-name.describe=vdb name
+requests-per-vdb.vdb-version.describe=vdb version
+remove.reply.describe=remove service
+remove.describe=remove service
+
+vdb-name.missing=Parameter "vdb-name" is required
+vdb-version.missing=Parameter "vdb-version" is required
+cache-type.missing=Parameter "cache-type" is required
+session.missing=Parameter "session" is required
+execution-id.missing=Parameter "execution-id" is required
+xid.missing=Parameter "xid" is required
+source-vdb-name.missing=Parameter "source-vdb-name" is required
+source-vdb-version.missing=Parameter "source-vdb-version" is required
+target-vdb-name.missing=Parameter "target-vdb-name" is required
+target-vdb-version.missing=Parameter "target-vdb-version" is required
+sql-query.missing=Parameter "sql-query" is required
+timeout-in-milli.missing=Parameter "timeout-in-milli" is required
+translator-name.missing=Parameter "translator-name" is required
+engine_service_not_found= Query Engine Service with name {0} is not found
+translator.removed = Translator "{0}" removed
+translator.failed-to-load = Translator "{0}" not found in the module "{1}"
\ No newline at end of file
Modified: branches/as7/metadata/pom.xml
===================================================================
--- branches/as7/metadata/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/metadata/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -43,6 +43,12 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-api</artifactId>
<scope>provided</scope>
</dependency>
Modified: branches/as7/pom.xml
===================================================================
--- branches/as7/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -273,6 +273,11 @@
<artifactId>teiid-client</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
@@ -532,6 +537,7 @@
<module>jboss-integration</module>
<module>test-integration</module>
<module>client-jdk15</module>
+ <module>admin</module>
</modules>
<distributionManagement>
<repository>
Modified: branches/as7/runtime/pom.xml
===================================================================
--- branches/as7/runtime/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/runtime/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -33,6 +33,11 @@
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-engine</artifactId>
</dependency>
<dependency>
Modified: branches/as7/test-integration/pom.xml
===================================================================
--- branches/as7/test-integration/pom.xml 2011-09-02 20:37:43 UTC (rev 3444)
+++ branches/as7/test-integration/pom.xml 2011-09-02 20:49:18 UTC (rev 3445)
@@ -47,6 +47,10 @@
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-admin</artifactId>
+ </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
[View Less]
13 years, 7 months
teiid SVN: r3444 - in branches/as7/client/src: test/java/org/teiid/net/socket and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-09-02 16:37:43 -0400 (Fri, 02 Sep 2011)
New Revision: 3444
Modified:
branches/as7/client/src/main/java/org/teiid/client/util/ExceptionUtil.java
branches/as7/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java
Log:
TEIID-1720: move the classes to admin module
Modified: branches/as7/client/src/main/java/org/teiid/client/util/ExceptionUtil.java
===================================================================
--- branches/as7/client/src/…
[View More]main/java/org/teiid/client/util/ExceptionUtil.java 2011-09-02 00:47:26 UTC (rev 3443)
+++ branches/as7/client/src/main/java/org/teiid/client/util/ExceptionUtil.java 2011-09-02 20:37:43 UTC (rev 3444)
@@ -24,12 +24,8 @@
import java.lang.reflect.Method;
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminProcessingException;
import org.teiid.client.xa.XATransactionException;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
@@ -59,18 +55,11 @@
return exception;
}
canThrowComponentException |= TeiidComponentException.class.isAssignableFrom(exceptionClasses[i]);
- canThrowAdminException |= AdminException.class.isAssignableFrom(exceptionClasses[i]);
canThrowXATransactionException |= XATransactionException.class.isAssignableFrom(exceptionClasses[i]);
}
if (canThrowComponentException) {
return new TeiidComponentException(exception);
}
- if (canThrowAdminException) {
- if (exception instanceof TeiidProcessingException) {
- return new AdminProcessingException(exception);
- }
- return new AdminComponentException(exception);
- }
if (canThrowXATransactionException) {
return new XATransactionException(exception);
}
Modified: branches/as7/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java 2011-09-02 00:47:26 UTC (rev 3443)
+++ branches/as7/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java 2011-09-02 20:37:43 UTC (rev 3444)
@@ -26,8 +26,6 @@
import junit.framework.TestCase;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
import org.teiid.client.DQP;
import org.teiid.client.util.ExceptionUtil;
import org.teiid.client.xa.XATransactionException;
@@ -50,15 +48,6 @@
assertTrue(t instanceof TeiidRuntimeException);
}
- public void testAdminExceptionConversion() throws Exception {
-
- Method m = Admin.class.getMethod("getCacheStats", new Class[] {String.class});
-
- Throwable t = ExceptionUtil.convertException(m, new TeiidComponentException());
-
- assertTrue(t instanceof AdminException);
- }
-
public void testComponentExceptionConversion() throws Exception {
Method m = DQP.class.getMethod("getMetadata", new Class[] {Long.TYPE});
[View Less]
13 years, 7 months
teiid SVN: r3443 - in trunk: connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-09-01 20:47:26 -0400 (Thu, 01 Sep 2011)
New Revision: 3443
Modified:
trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
Log:
TEIID-1737 fix for with pushdown
Modified: trunk/api/src/main/java/org/teiid/language/visitor/…
[View More]SQLStringVisitor.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-02 00:46:32 UTC (rev 3442)
+++ trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-02 00:47:26 UTC (rev 3443)
@@ -927,6 +927,7 @@
buffer.append(WITH);
buffer.append(Tokens.SPACE);
append(obj.getItems());
+ buffer.append(Tokens.SPACE);
}
@Override
@@ -940,6 +941,7 @@
buffer.append(Tokens.SPACE);
}
buffer.append(AS);
+ buffer.append(Tokens.SPACE);
buffer.append(Tokens.LPAREN);
append(obj.getSubquery());
buffer.append(Tokens.RPAREN);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-02 00:46:32 UTC (rev 3442)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-02 00:47:26 UTC (rev 3443)
@@ -200,5 +200,14 @@
Command obj = commandBuilder.getCommand(input, true, true);
TranslationHelper.helpTestVisitor(output, trans, obj);
}
+
+ @Test public void testWith() throws Exception {
+ String input = "with x as (select intkey from bqt1.smalla) select intkey from x limit 100"; //$NON-NLS-1$
+ String output = "WITH x AS (SELECT SmallA.IntKey FROM SmallA) SELECT TOP 100 g_0.intkey AS c_0 FROM x g_0"; //$NON-NLS-1$
+
+ CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
+ Command obj = commandBuilder.getCommand(input, true, true);
+ TranslationHelper.helpTestVisitor(output, trans, obj);
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-02 00:46:32 UTC (rev 3442)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-02 00:47:26 UTC (rev 3443)
@@ -230,6 +230,7 @@
}
}
item.setSubquery(translate(withQueryCommand.getCommand()));
+ items.add(item);
}
result.setItems(items);
return result;
[View Less]
13 years, 7 months
teiid SVN: r3442 - in branches/7.4.x: connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-09-01 20:46:32 -0400 (Thu, 01 Sep 2011)
New Revision: 3442
Modified:
branches/7.4.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
Log:
TEIID-1737 fix for with clause pushdown
Modified: branches/7.4.x/api/src/main/java/…
[View More]org/teiid/language/visitor/SQLStringVisitor.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-01 19:48:30 UTC (rev 3441)
+++ branches/7.4.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-09-02 00:46:32 UTC (rev 3442)
@@ -887,6 +887,7 @@
buffer.append(WITH);
buffer.append(Tokens.SPACE);
append(obj.getItems());
+ buffer.append(Tokens.SPACE);
}
@Override
@@ -900,6 +901,7 @@
buffer.append(Tokens.SPACE);
}
buffer.append(AS);
+ buffer.append(Tokens.SPACE);
buffer.append(Tokens.LPAREN);
append(obj.getSubquery());
buffer.append(Tokens.RPAREN);
Modified: branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-01 19:48:30 UTC (rev 3441)
+++ branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2011-09-02 00:46:32 UTC (rev 3442)
@@ -200,5 +200,14 @@
Command obj = commandBuilder.getCommand(input, true, true);
TranslationHelper.helpTestVisitor(output, trans, obj);
}
+
+ @Test public void testWith() throws Exception {
+ String input = "with x as (select intkey from bqt1.smalla) select intkey from x limit 100"; //$NON-NLS-1$
+ String output = "WITH x AS (SELECT SmallA.IntKey FROM SmallA) SELECT TOP 100 g_0.intkey AS c_0 FROM x g_0"; //$NON-NLS-1$
+
+ CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
+ Command obj = commandBuilder.getCommand(input, true, true);
+ TranslationHelper.helpTestVisitor(output, trans, obj);
+ }
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-01 19:48:30 UTC (rev 3441)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-09-02 00:46:32 UTC (rev 3442)
@@ -235,6 +235,7 @@
}
}
item.setSubquery(translate(withQueryCommand.getCommand()));
+ items.add(item);
}
result.setItems(items);
return result;
[View Less]
13 years, 7 months
teiid SVN: r3441 - in trunk: engine/src/main/java/org/teiid/dqp/internal/process and 9 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-09-01 15:48:30 -0400 (Thu, 01 Sep 2011)
New Revision: 3441
Modified:
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java
trunk/engine/src/main/java/org/teiid/query/processor/…
[View More]BatchCollector.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
trunk/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
Log:
forward merge from 7.4.1 and minor changes to undo behavior
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -35,6 +35,12 @@
public ExpirationAwareCache(Cache cacheStore, Fqn fqn) {
super(cacheStore, fqn);
}
+
+ @Override
+ protected boolean validateNode(Node node) {
+ Long future = (Long) node.get(ExpirationAlgorithmConfig.EXPIRATION_KEY);
+ return future == null || future > System.currentTimeMillis();
+ }
@Override
public V put(K key, V value) {
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -52,10 +52,17 @@
Node<K, V> node = getRootNode();
Node child = node.getChild(getFqn(key));
if (child != null) {
- return (V)child.get(key);
+ if (validateNode(child)) {
+ return (V)child.get(key);
+ }
+ remove(key);
}
return null;
}
+
+ protected boolean validateNode(Node node) {
+ return true;
+ }
protected Fqn<String> getFqn(K key) {
if (key.getClass().isPrimitive() || key instanceof String) {
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -29,6 +29,7 @@
import org.jboss.cache.Node;
import org.jboss.cache.Region;
import org.jboss.cache.config.EvictionAlgorithmConfig;
+import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
@@ -71,6 +72,8 @@
Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
cacheRegion.activate();
+ cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
+ cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
JBossCache jc = null;
if (config != null && config.getPolicy().equals(Policy.EXPIRATION)) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
package org.teiid.dqp.internal.process;
import java.util.Collections;
@@ -49,13 +71,20 @@
@Override
public boolean isTempAccessable(PermissionType action, String resource,
Context context, CommandContext commandContext) {
+ Boolean result = null;
for(DataPolicy p:commandContext.getAllowedDataPolicies().values()) {
DataPolicyMetadata policy = (DataPolicyMetadata)p;
if (policy.isAllowCreateTemporaryTables() != null) {
- return policy.isAllowCreateTemporaryTables();
+ if (policy.isAllowCreateTemporaryTables()) {
+ return true;
+ }
+ result = policy.isAllowCreateTemporaryTables();
}
}
+ if (result != null) {
+ return result;
+ }
return allowCreateTemporaryTablesByDefault;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -120,11 +120,12 @@
private TupleBuffer buffer;
private boolean forwardOnly;
- public BatchCollector(BatchProducer sourceNode, BufferManager bm, CommandContext context, boolean fowardOnly) throws TeiidComponentException {
+ public BatchCollector(BatchProducer sourceNode, BufferManager bm, CommandContext context, boolean forwardOnly) throws TeiidComponentException {
this.sourceNode = sourceNode;
+ this.forwardOnly = forwardOnly;
if (!this.sourceNode.hasFinalBuffer()) {
this.buffer = bm.createTupleBuffer(sourceNode.getOutputElements(), context.getConnectionID(), TupleSourceType.PROCESSOR);
- this.buffer.setForwardOnly(fowardOnly);
+ this.buffer.setForwardOnly(forwardOnly);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -133,7 +133,9 @@
public void closeDirect() {
if(this.output != null) {
- this.output.remove();
+ if (!usingOutput) {
+ this.output.remove();
+ }
this.output = null;
}
this.outputTs = null;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -50,6 +50,8 @@
/**
* Implements several modes of a multi-pass sort.
+ *
+ * TODO: could consider using an index for dup_removal and maintaining a separate output buffer
*/
public class SortUtility {
@@ -324,7 +326,7 @@
while (sublists.size() > 0) {
SortedSublist sortedSublist = sublists.remove(sublists.size() - 1);
merged.addTuple(sortedSublist.tuple);
- if (this.output != null && sortedSublist.index > masterSortIndex) {
+ if (this.output != null && masterSortIndex < maxSortIndex && sortedSublist.index != masterSortIndex) {
this.output.addTuple(sortedSublist.tuple); //a new distinct row
}
incrementWorkingTuple(sublists, sortedSublist);
@@ -339,7 +341,7 @@
}
merged.saveBatch();
this.activeTupleBuffers.add(merged);
- masterSortIndex = masterSortIndex - maxSortIndex + 1;
+ masterSortIndex = masterSortIndex - maxSortIndex;
if (masterSortIndex < 0) {
masterSortIndex = this.activeTupleBuffers.size() - 1;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -95,7 +95,9 @@
public void closeDirect() {
super.closeDirect();
if(this.buffer != null) {
- this.buffer.remove();
+ if (!usingOutput) {
+ this.buffer.remove();
+ }
this.buffer = null;
}
reset();
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -82,9 +82,9 @@
private boolean addRowId;
private int[] indexes;
- private InsertUpdateProcessor(TupleSource ts, boolean addRowId, int[] indexes)
+ private InsertUpdateProcessor(TupleSource ts, boolean addRowId, int[] indexes, boolean canUndo)
throws TeiidComponentException {
- super(null, ts);
+ super(null, ts, canUndo);
this.addRowId = addRowId;
this.indexes = indexes;
}
@@ -117,14 +117,14 @@
currentTuple = tuple;
for (int i : notNull) {
if (tuple.get(i) == null) {
- throw new TeiidProcessingException(QueryPlugin.Util.getString("TempTable.not_null", columns.get(i)));
+ throw new TeiidProcessingException(QueryPlugin.Util.getString("TempTable.not_null", columns.get(i))); //$NON-NLS-1$
}
}
insertTuple(tuple, addRowId);
}
@Override
- protected void undo(List tuple) throws TeiidComponentException,
+ protected void undo(List<?> tuple) throws TeiidComponentException,
TeiidProcessingException {
deleteTuple(tuple);
}
@@ -197,18 +197,20 @@
private abstract class UpdateProcessor {
private TupleSource ts;
- protected final Evaluator eval;
- private final Criteria crit;
+ protected Evaluator eval;
+ private Criteria crit;
protected int updateCount = 0;
protected List currentTuple;
protected TupleBuffer undoLog;
- UpdateProcessor(Criteria crit, TupleSource ts) throws TeiidComponentException {
+ UpdateProcessor(Criteria crit, TupleSource ts, boolean canUndo) throws TeiidComponentException {
this.ts = ts;
this.eval = new Evaluator(columnMap, null, null);
this.crit = crit;
- this.undoLog = bm.createTupleBuffer(columns, sessionID, TupleSourceType.PROCESSOR);
+ if (canUndo) {
+ this.undoLog = bm.createTupleBuffer(columns, sessionID, TupleSourceType.PROCESSOR);
+ }
}
int process() throws ExpressionEvaluationException, TeiidComponentException, TeiidProcessingException {
@@ -221,7 +223,9 @@
if (crit == null || eval.evaluate(crit, currentTuple)) {
tuplePassed(currentTuple);
updateCount++;
- undoLog.addTuple(currentTuple);
+ if (undoLog != null) {
+ undoLog.addTuple(currentTuple);
+ }
}
currentTuple = null;
}
@@ -230,19 +234,21 @@
success();
success = true;
} finally {
- bm.releaseBuffers(reserved);
try {
- if (!success) {
+ if (!success && undoLog != null) {
undoLog.setFinal(true);
TupleSource undoTs = undoLog.createIndexedTupleSource();
List<?> tuple = null;
while ((tuple = undoTs.nextTuple()) != null) {
- undo(tuple);
+ try {
+ undo(tuple);
+ } catch (TeiidException e) {
+ LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage());
+ }
}
}
- } catch (TeiidException e) {
- LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage());
} finally {
+ bm.releaseBuffers(reserved);
if (!held) {
lock.writeLock().unlock();
}
@@ -257,11 +263,14 @@
protected abstract void tuplePassed(List tuple) throws BlockedException, TeiidComponentException, TeiidProcessingException;
- protected abstract void undo(List tuple) throws TeiidComponentException, TeiidProcessingException;
+ protected abstract void undo(List<?> tuple) throws TeiidComponentException, TeiidProcessingException;
public void close() {
ts.closeSource();
- undoLog.remove();
+ ts = null;
+ if (undoLog != null) {
+ undoLog.remove();
+ }
}
}
@@ -332,7 +341,7 @@
TempTable indexTable = createIndexTable(indexColumns, unique);
//TODO: ordered insert optimization
TupleSource ts = createTupleSource(indexTable.getColumns(), null, null);
- indexTable.insert(ts, indexTable.getColumns());
+ indexTable.insert(ts, indexTable.getColumns(), false);
indexTable.getTree().compact();
}
@@ -497,11 +506,16 @@
}
public void remove() {
- tree.remove();
- if (this.indexTables != null) {
- for (TempTable indexTable : this.indexTables.values()) {
- indexTable.remove();
+ lock.writeLock().lock();
+ try {
+ tree.remove();
+ if (this.indexTables != null) {
+ for (TempTable indexTable : this.indexTables.values()) {
+ indexTable.remove();
+ }
}
+ } finally {
+ lock.writeLock().unlock();
}
}
@@ -512,7 +526,7 @@
return columns;
}
- public TupleSource insert(TupleSource tuples, final List<ElementSymbol> variables) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
+ public TupleSource insert(TupleSource tuples, final List<ElementSymbol> variables, boolean canUndo) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
List<ElementSymbol> cols = getColumns();
final int[] indexes = new int[cols.size()];
boolean shouldProject = false;
@@ -520,7 +534,7 @@
indexes[i] = variables.indexOf(cols.get(i));
shouldProject |= (indexes[i] != i);
}
- UpdateProcessor up = new InsertUpdateProcessor(tuples, rowId != null, shouldProject?indexes:null);
+ UpdateProcessor up = new InsertUpdateProcessor(tuples, rowId != null, shouldProject?indexes:null, canUndo);
int updateCount = up.process();
tid.setCardinality(tree.getRowCount());
tid.getTableData().dataModified(updateCount);
@@ -530,7 +544,7 @@
public TupleSource update(Criteria crit, final SetClauseList update) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
final boolean primaryKeyChangePossible = canChangePrimaryKey(update);
final TupleBrowser browser = createTupleBrower(crit, OrderBy.ASC);
- UpdateProcessor up = new UpdateProcessor(crit, browser) {
+ UpdateProcessor up = new UpdateProcessor(crit, browser, true) {
protected TupleBuffer changeSet;
protected UpdateProcessor changeSetProcessor;
@@ -556,7 +570,7 @@
}
@Override
- protected void undo(List tuple) throws TeiidComponentException, TeiidProcessingException {
+ protected void undo(List<?> tuple) throws TeiidComponentException, TeiidProcessingException {
if (primaryKeyChangePossible) {
insertTuple(tuple, false);
} else {
@@ -570,7 +584,7 @@
//changeSet contains possible updates
if (primaryKeyChangePossible) {
if (changeSetProcessor == null) {
- changeSetProcessor = new InsertUpdateProcessor(changeSet.createIndexedTupleSource(true), false, null);
+ changeSetProcessor = new InsertUpdateProcessor(changeSet.createIndexedTupleSource(true), false, null, true);
}
changeSetProcessor.process(); //when this returns, we're up to date
}
@@ -579,11 +593,10 @@
@Override
public void close() {
super.close();
- if (changeSetProcessor != null) {
- changeSetProcessor.close(); // causes a revert of the change set
- }
+ changeSetProcessor = null;
if (changeSet != null) {
changeSet.remove();
+ changeSet = null;
}
}
@@ -606,7 +619,7 @@
public TupleSource delete(Criteria crit) throws TeiidComponentException, ExpressionEvaluationException, TeiidProcessingException {
final TupleBrowser browser = createTupleBrower(crit, OrderBy.ASC);
- UpdateProcessor up = new UpdateProcessor(crit, browser) {
+ UpdateProcessor up = new UpdateProcessor(crit, browser, true) {
@Override
protected void tuplePassed(List tuple)
throws ExpressionEvaluationException,
@@ -616,7 +629,7 @@
}
@Override
- protected void undo(List tuple) throws TeiidComponentException, TeiidProcessingException {
+ protected void undo(List<?> tuple) throws TeiidComponentException, TeiidProcessingException {
insertTuple(tuple, false);
}
};
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -56,6 +56,7 @@
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.optimizer.relational.RelationalPlanner;
import org.teiid.query.parser.ParseInfo;
@@ -139,6 +140,9 @@
TempTableStore contextStore = context.getTempTableStore();
if (command instanceof Query) {
Query query = (Query)command;
+ if (modelName != null && !modelName.equals(TempMetadataAdapter.TEMP_MODEL.getID())) {
+ return null;
+ }
return registerQuery(context, contextStore, query);
}
if (command instanceof ProcedureContainer) {
@@ -171,7 +175,7 @@
}
ts = new CollectionTupleSource(Arrays.asList(values).iterator());
}
- return table.insert(ts, insert.getVariables());
+ return table.insert(ts, insert.getVariables(), true);
}
if (command instanceof Update) {
final Update update = (Update)command;
@@ -442,8 +446,7 @@
qp.getContext().setDataObjects(null);
TupleSource ts = new BatchCollector.BatchProducerTupleSource(qp);
- //TODO: if this insert fails, it's unnecessary to do the undo processing
- table.insert(ts, allColumns);
+ table.insert(ts, allColumns, false);
table.getTree().compact();
rowCount = table.getRowCount();
//TODO: could pre-process indexes to remove overlap
Modified: trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -171,7 +171,7 @@
throws QueryResolverException {
config.setErrorListener(ERROR_LISTENER);
this.xQueryString = xQueryString;
- StaticQueryContext context = new StaticQueryContext(config);
+ StaticQueryContext context = config.newStaticQueryContext();
IndependentContext ic = new IndependentContext(config);
namespaceMap.put(EMPTY_STRING, EMPTY_STRING);
if (namespaces != null) {
@@ -242,7 +242,13 @@
}
}
this.contextRoot = null;
- PathMap map = this.xQuery.getPathMap();
+ //we'll use a new pathmap, since we don't want to modify the one associated with the xquery.
+ PathMap map = null;
+ if (columns == null) {
+ map = this.xQuery.getPathMap();
+ } else {
+ map = new PathMap(this.xQuery.getExpression());
+ }
PathMapRoot parentRoot;
try {
parentRoot = map.getContextRoot();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -170,7 +170,7 @@
return svc;
}
- private void helpTest(DataPolicyMetadata policy, String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb) throws QueryParserException, QueryResolverException, TeiidComponentException {
+ private void helpTest(String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb, DataPolicyMetadata... roles) throws QueryParserException, QueryResolverException, TeiidComponentException {
QueryParser parser = QueryParser.getQueryParser();
Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
@@ -178,7 +178,9 @@
vdb.addAttchment(QueryMetadataInterface.class, metadata);
HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
- policies.put(policy.getName(), policy);
+ for (DataPolicyMetadata dataPolicyMetadata : roles) {
+ policies.put(dataPolicyMetadata.getName(), dataPolicyMetadata);
+ }
this.context.getDQPWorkContext().setPolicies(policies);
DataRolePolicyDecider dataRolePolicyDecider = new DataRolePolicyDecider();
dataRolePolicyDecider.setAllowFunctionCallsByDefault(false);
@@ -206,125 +208,127 @@
@Test public void testTemp() throws Exception {
//allowed by default
- helpTest(exampleAuthSvc1(), "create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
//explicitly denied
- helpTest(exampleAuthSvc2(), "create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {"x"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {"x"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testFunction() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
+ helpTest("SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible1() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible2() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testInaccesibleElement() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e2 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT e2 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testInaccesibleElement2() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e2', '1')", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT lookup('pm1.g1', 'e1', 'e2', '1')", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testInaccesibleGroup() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g2", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpTest("SELECT e1 FROM pm1.g2", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Test public void testInsert() throws Exception {
- helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testInsertInaccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testUpdate() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e2 = 5", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("UPDATE pm1.g1 SET e2 = 5", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testUpdateCriteriaInaccessibleForRead() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testUpdateCriteriaInaccessibleForRead1() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = cast(e1 as integer)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("UPDATE pm1.g2 SET e2 = cast(e1 as integer)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testUpdateElementInaccessibleForUpdate() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDelete() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("DELETE FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testDeleteCriteriaInaccesibleForRead() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g2 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("DELETE FROM pm1.g2 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDeleteInaccesibleGroup() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g3", RealMetadataFactory.example1Cached(), new String[] {"pm1.g3"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("DELETE FROM pm1.g3", RealMetadataFactory.example1Cached(), new String[] {"pm1.g3"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testProc() throws Exception {
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq1()", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("EXEC pm1.sq1()", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testProcInaccesible() throws Exception {
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')", RealMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("EXEC pm1.sq2('xyz')", RealMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testSelectIntoEverythingAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testSelectIntoTarget_e1_NotAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm2.g2", "pm2.g2.e2","pm2.g2.e4","pm2.g2.e3"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ helpTest("SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm2.g2", "pm2.g2.e2","pm2.g2.e4","pm2.g2.e3"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
@Test public void testSelectIntoTarget_e1e2_NotAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm3.g2", "pm3.g2.e4", "pm3.g2.e3"},RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpTest("SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm3.g2", "pm3.g2.e4", "pm3.g2.e3"}, RealMetadataFactory.example1VDB(),exampleAuthSvc2()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Test public void testTempTableSelectInto() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
+ helpTest("SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
+ helpTest("SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc2(), exampleAuthSvc1()); //$NON-NLS-1$
+
}
@Test public void testTempTableSelectInto1() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1, e2 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT e1, e2 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTempTableInsert() throws Exception {
- helpTest(exampleAuthSvc1(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
+ helpTest("insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testXMLAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testXMLInAccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testAlter() throws Exception {
- helpTest(exampleAuthSvc1(), "alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest(examplePolicyBQT(), "alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB(), examplePolicyBQT()); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest(exampleAuthSvc1(), "alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest(examplePolicyBQT(), "alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB(), examplePolicyBQT()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -333,6 +333,37 @@
assertEquals(100, item.resultsBuffer.getRowCount());
}
+ @Test public void testBufferReuse1() throws Exception {
+ //the sql should return 100 rows
+ String sql = "SELECT IntKey FROM texttable('1112131415' columns intkey integer width 2 no row delimiter) t " +
+ "union " +
+ "SELECT IntKey FROM bqt1.smalla"; //$NON-NLS-1$
+ String userName = "1"; //$NON-NLS-1$
+ String sessionid = "1"; //$NON-NLS-1$
+ agds.sleep = 500;
+ agds.setUseIntCounter(true);
+ RequestMessage reqMsg = exampleRequestMessage(sql);
+ reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
+ DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
+ DQPWorkContext.getWorkContext().getSession().setUserName(userName);
+ BufferManagerImpl bufferManager = (BufferManagerImpl)core.getBufferManager();
+ bufferManager.setProcessorBatchSize(20);
+ Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
+ ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+
+ message = core.processCursorRequest(reqMsg.getExecutionId(), 6, 5);
+ rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+
+ message = core.processCursorRequest(reqMsg.getExecutionId(), 11, 5);
+ rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+ }
+
@Test public void testSourceConcurrency() throws Exception {
//setup default of 2
agds.setSleep(100);
Modified: trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -59,13 +59,17 @@
public int sleep;
private final AtomicInteger executeCount = new AtomicInteger();
private final AtomicInteger closeCount = new AtomicInteger();
+ private boolean useIntCounter;
-
public AutoGenDataService() {
super("FakeConnector","FakeConnector"); //$NON-NLS-1$ //$NON-NLS-2$
caps = TestOptimizer.getTypicalCapabilities();
}
+ public void setUseIntCounter(boolean useIntCounter) {
+ this.useIntCounter = useIntCounter;
+ }
+
public void setSleep(int sleep) {
this.sleep = sleep;
}
@@ -151,7 +155,7 @@
while(iter.hasNext()) {
SingleElementSymbol symbol = (SingleElementSymbol) iter.next();
Class type = symbol.getType();
- row.add( getValue(type) );
+ row.add( getValue(type, i) );
}
rows[i] = row;
}
@@ -174,11 +178,11 @@
private static final java.sql.Time TIME_VAL = new java.sql.Time(0);
private static final java.sql.Timestamp TIMESTAMP_VAL = new java.sql.Timestamp(0);
- private Object getValue(Class<?> type) {
+ private Object getValue(Class<?> type, int row) {
if(type.equals(DataTypeManager.DefaultDataClasses.STRING)) {
return STRING_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.INTEGER)) {
- return INTEGER_VAL;
+ return useIntCounter?row:INTEGER_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.SHORT)) {
return SHORT_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.LONG)) {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -216,7 +216,11 @@
ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(), createCommandContext());
- helpProcess(plan, createCommandContext(), dataManager, expected);
+ helpProcess(plan, createCommandContext(), dataManager, expected);
+
+ plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(), createCommandContext());
+
+ doProcess(plan, dataManager, expected, createCommandContext());
}
@Test public void testXmlTableDefaultAndParent() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -64,10 +64,16 @@
String sql = "with a (x, y, z) as (select e1, e2, e3 from pm1.g1) SELECT a.x from a, a z"; //$NON-NLS-1$
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ List[] expected = new List[] {
+ Arrays.asList("a", 1, Boolean.FALSE),
+ };
+
+ dataManager.addData("WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1", expected);
- TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] {"WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1"}, ComparisonMode.EXACT_COMMAND_STRING);
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] {"WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1"}, ComparisonMode.EXACT_COMMAND_STRING);
+
+ helpProcess(plan, dataManager, expected);
}
@Test public void testWithPushdownWithConstants() throws TeiidException {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -46,7 +46,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.util.CommandContext;
-
+@SuppressWarnings("unchecked")
public class TestSortNode {
public static final int BATCH_SIZE = 100;
@@ -321,4 +321,37 @@
assertEquals(Arrays.asList(2), ts.nextTuple());
}
+ @Test public void testDupRemoveLowMemory() throws Exception {
+ ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$
+ es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ BufferManager bm = BufferManagerFactory.getTestBufferManager(0, 2);
+ TupleBuffer tsid = bm.createTupleBuffer(Arrays.asList(es1), "test", TupleSourceType.PROCESSOR); //$NON-NLS-1$
+ tsid.addTuple(Arrays.asList(1));
+ tsid.addTuple(Arrays.asList(2));
+ SortUtility su = new SortUtility(tsid.createIndexedTupleSource(), Arrays.asList(es1), Arrays.asList(Boolean.TRUE), Mode.DUP_REMOVE, bm, "test", tsid.getSchema()); //$NON-NLS-1$
+ TupleBuffer out = su.sort();
+ TupleSource ts = out.createIndexedTupleSource();
+ assertEquals(Arrays.asList(1), ts.nextTuple());
+ assertEquals(Arrays.asList(2), ts.nextTuple());
+ try {
+ ts.nextTuple();
+ fail();
+ } catch (BlockedException e) {
+
+ }
+ tsid.addTuple(Arrays.asList(3));
+ tsid.addTuple(Arrays.asList(4));
+ tsid.addTuple(Arrays.asList(5));
+ tsid.addTuple(Arrays.asList(6));
+ tsid.addTuple(Arrays.asList(6));
+ tsid.addTuple(Arrays.asList(6));
+ tsid.close();
+ su.sort();
+ ts.nextTuple();
+ ts.nextTuple();
+ assertNotNull(ts.nextTuple());
+ assertNotNull(ts.nextTuple());
+ assertNull(ts.nextTuple());
+ }
+
}
Modified: trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-08-31 18:43:49 UTC (rev 3440)
+++ trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-09-01 19:48:30 UTC (rev 3441)
@@ -488,7 +488,6 @@
List<PgColInfo> cols = getPgColInfo(stmt.getResultSet().getMetaData());
client.sendResults(query.sql, stmt.getResultSet(), cols, result, true);
} else {
- // null future
client.sendUpdateCount(query.sql, stmt.getUpdateCount());
setEncoding();
result.getResultsReceiver().receiveResults(1);
@@ -627,7 +626,7 @@
}
@Override
- public void executeQuery(final String query) {
+ public void executeQuery(String query) {
if (beginExecution()) {
errorOccurred("Awaiting asynch result"); //$NON-NLS-1$
ready();
@@ -636,12 +635,12 @@
//46.2.3 Note that a simple Query message also destroys the unnamed portal.
this.portalMap.remove(UNNAMED);
this.preparedMap.remove(UNNAMED);
-
- if (query.trim().length() == 0) {
- this.client.emptyQueryReceived();
+ query = query.trim();
+ if (query.length() == 0) {
+ client.emptyQueryReceived();
ready();
- return;
}
+
QueryWorkItem r = new QueryWorkItem(query);
r.run();
}
@@ -871,6 +870,15 @@
private QueryWorkItem(String query) {
this.reader = new ScriptReader(new StringReader(query));
}
+
+ private void done(Throwable error) {
+ if (error != null) {
+ errorOccurred(error);
+ } else {
+ doneExecuting();
+ }
+ ready();
+ }
@Override
public void run() {
@@ -890,14 +898,14 @@
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (IOException e) {
- client.errorOccurred(e);
+ done(e);
return;
} catch (ExecutionException e) {
Throwable cause = e;
while (cause instanceof ExecutionException && cause.getCause() != null && cause != cause.getCause()) {
cause = cause.getCause();
}
- client.errorOccurred(cause);
+ done(cause);
return;
}
QueryWorkItem.this.run(); //continue processing
@@ -943,15 +951,15 @@
}
return; //wait for the execution to finish
} catch (SQLException e) {
- errorOccurred(e);
- break;
+ done(e);
+ return;
}
}
} catch(IOException e) {
- errorOccurred(e);
+ done(e);
+ return;
}
- doneExecuting();
- ready();
+ done(null);
}
}
[View Less]
13 years, 7 months