incubator-oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfos...@apache.org
Subject svn commit: r1002752 [7/9] - in /incubator/oodt/trunk/catalog: ./ .externalToolBuilders/ .settings/ src/ src/main/ src/main/assembly/ src/main/bin/ src/main/java/ src/main/java/gov/ src/main/java/gov/nasa/ src/main/java/gov/nasa/jpl/ src/main/java/gov/...
Date Wed, 29 Sep 2010 17:19:15 GMT
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/dictionary/WorkflowManagerDictionaryFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/dictionary/WorkflowManagerDictionaryFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/dictionary/WorkflowManagerDictionaryFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/dictionary/WorkflowManagerDictionaryFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.dictionary;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.struct.DictionaryFactory;
+
+/**
+ * 
+ * @author bfoster
+ * @version $Revision$
+ * 
+ */
+public class WorkflowManagerDictionaryFactory implements DictionaryFactory {
+
+	public WorkflowManagerDictionary createDictionary() {
+		return new WorkflowManagerDictionary();
+	}
+
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndex.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndex.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndex.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndex.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,459 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.index;
+
+//JDK imports
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//SQL imports
+import javax.sql.DataSource;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.exception.CatalogIndexException;
+import org.apache.oodt.cas.catalog.exception.IngestServiceException;
+import org.apache.oodt.cas.catalog.exception.QueryServiceException;
+import org.apache.oodt.cas.catalog.page.IndexPager;
+import org.apache.oodt.cas.catalog.page.IngestReceipt;
+import org.apache.oodt.cas.catalog.page.PageInfo;
+import org.apache.oodt.cas.catalog.page.ProcessedPageInfo;
+import org.apache.oodt.cas.catalog.query.ComparisonQueryExpression;
+import org.apache.oodt.cas.catalog.query.NotQueryExpression;
+import org.apache.oodt.cas.catalog.query.QueryExpression;
+import org.apache.oodt.cas.catalog.query.QueryLogicalGroup;
+import org.apache.oodt.cas.catalog.query.StdQueryExpression;
+import org.apache.oodt.cas.catalog.struct.Index;
+import org.apache.oodt.cas.catalog.struct.IngestService;
+import org.apache.oodt.cas.catalog.struct.QueryService;
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.struct.TransactionIdFactory;
+import org.apache.oodt.cas.catalog.struct.impl.transaction.UuidTransactionIdFactory;
+import org.apache.oodt.cas.catalog.term.Term;
+import org.apache.oodt.cas.catalog.term.TermBucket;
+import org.apache.oodt.commons.database.DatabaseConnectionBuilder;
+import org.apache.oodt.commons.date.DateUtils;
+
+/**
+ * 
+ * DataSource Indexer which supports both ingest and query
+ * 
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class DataSourceIndex implements Index, IngestService, QueryService {
+
+	private static final Logger LOG = Logger.getLogger(DataSourceIndex.class.getName());
+	
+	protected DataSource dataSource;
+	protected boolean useUTF8;
+	
+	public DataSourceIndex(String user, String pass, String driver, String jdbcUrl, boolean useUTF8) {
+		this.dataSource = DatabaseConnectionBuilder.buildDataSource(user, pass, driver, jdbcUrl);
+		this.useUTF8 = useUTF8;
+	}
+	
+	public IndexPager getPager(PageInfo pageInfo) throws CatalogIndexException {
+		return new IndexPager(new ProcessedPageInfo(pageInfo.getPageSize(), pageInfo.getPageNum(), this.getNumOfTransactions()));
+	}
+	
+	protected int getNumOfTransactions() throws CatalogIndexException {
+		Connection conn = null;
+		Statement stmt = null;
+		ResultSet rs = null;
+		try {
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			rs = stmt.executeQuery("SELECT COUNT(transaction_id) AS numTransIds FROM transactions");
+			if (rs.next())
+				return rs.getInt("numTransIds");
+			else
+				throw new Exception("Failed to query for number of transactions");
+		}catch (Exception e) {
+			throw new CatalogIndexException("Failed to get number of transactions : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+			try {
+				rs.close();
+			}catch(Exception e) {}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public List<TransactionId<?>> getPage(IndexPager indexPage) throws CatalogIndexException {
+//		Connection conn = null;
+//		Statement stmt = null;
+//		ResultSet rs = null;
+//		try {
+//			conn = this.dataSource.getConnection();
+//			stmt = conn.createStatement();
+//			rs = stmt.executeQuery("SELECT transaction_id,transaction_class,transaction_date FROM transactions");
+//			int startLoc = pager.getPageNum() * pager.getPageSize();
+//			int endLoc = startLoc + pager.getPageSize();
+//			List<IngestReceipt> receipts = new Vector<IngestReceipt>();
+//			for (int i = startLoc; i < endLoc && rs.next(); i++) {
+//				receipts.add(new IngestReceipt(((TransactionId<?>) Class.forName(rs.getString("transaction_class")).getConstructor(String.class).newInstance(rs.getString("transaction_id"))), DateUtils.toCalendar(rs.getString("transaction_date"), DateUtils.FormatType.LOCAL_FORMAT).getTime()));
+//			}
+//			return rs.next();
+//		}catch (Exception e) {
+//			throw new CatalogIndexException("Failed to check for transaction id '" + transactionId + "' : " + e.getMessage(), e);
+//		}finally {
+//			try {
+//				conn.close();
+//			}catch(Exception e) {}
+//			try {
+//				stmt.close();
+//			}catch(Exception e) {}
+//			try {
+//				rs.close();
+//			}catch(Exception e) {}
+//		}
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public Properties getProperties() throws CatalogIndexException {
+		return new Properties();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public String getProperty(String key) throws CatalogIndexException {
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public TransactionIdFactory getTransactionIdFactory()
+			throws CatalogIndexException {
+		return new UuidTransactionIdFactory();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean hasTransactionId(TransactionId<?> transactionId)
+			throws CatalogIndexException {
+		Connection conn = null;
+		Statement stmt = null;
+		ResultSet rs = null;
+		try {
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			rs = stmt.executeQuery("SELECT DISTINCT transaction_id FROM transactions WHERE transaction_id = '" + transactionId + "'");
+			return rs.next();
+		}catch (Exception e) {
+			throw new CatalogIndexException("Failed to check for transaction id '" + transactionId + "' : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+			try {
+				rs.close();
+			}catch(Exception e) {}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean delete(TransactionId<?> transactionId)
+			throws IngestServiceException {
+		Connection conn = null;
+		Statement stmt = null;
+		try {
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			stmt.execute("DELETE FROM transactions WHERE transaction_id = '" + transactionId + "'");
+			stmt.execute("DELETE FROM transaction_terms WHERE transaction_id = '" + transactionId + "'");
+			conn.commit();
+			return true;
+		}catch (Exception e) {
+			throw new IngestServiceException("Failed to delete transaction id '" + transactionId + "' : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public IngestReceipt ingest(List<TermBucket> termBuckets) throws IngestServiceException {
+		Connection conn = null;
+		Statement stmt = null;
+		TransactionId<?> catalogTransactionId = null;
+		try {
+			catalogTransactionId = this.getTransactionIdFactory().createNewTransactionId();
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			Calendar calendar = DateUtils.getCurrentLocalTime();
+			stmt.execute("INSERT INTO transactions VALUES ('" + catalogTransactionId + "','" + DateUtils.toString(calendar) + "')");
+			for (TermBucket termBucket : termBuckets) {
+				for (Term term : termBucket.getTerms()) {
+					for (String value : term.getValues()) {
+						try {
+							stmt.execute("INSERT INTO transaction_terms VALUES ('" + catalogTransactionId + "','" + termBucket.getName() + "','" + term.getName() + "','" + (this.useUTF8 ? URLEncoder.encode(value, "UTF8") : value) + "')");
+						}catch (Exception e) {
+							LOG.log(Level.WARNING, "Failed to ingest term: '" + catalogTransactionId + "','" + termBucket.getName() + "','" + term.getName() + "','" + value + "'");
+						}
+					}
+				}
+			}
+			conn.commit();
+			return new IngestReceipt(catalogTransactionId, calendar.getTime());
+		}catch (Exception e) {
+			throw new IngestServiceException("Failed to ingest metadata for transaction id '" + catalogTransactionId + "' : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean reduce(TransactionId<?> transactionId,
+			List<TermBucket> termBuckets) throws IngestServiceException {
+		Connection conn = null;
+		Statement stmt = null;
+		try {
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			for (TermBucket termBucket : termBuckets) 
+				for (Term term : termBucket.getTerms()) 
+					for (String value : term.getValues()) 
+						try {
+							stmt.execute("DELETE FROM transaction_terms WHERE transaction_id = '" + transactionId + "' AND bucket_name = '" + termBucket.getName() + "' AND term_name = '" + term.getName() + "' AND term_value = '" + (this.useUTF8 ? URLEncoder.encode(value, "UTF8") : value) + "'");
+						}catch (Exception e) {
+							LOG.log(Level.WARNING, "Failed to delete term: '" + transactionId + "','" + termBucket.getName() + "','" + term.getName() + "','" + value + "'");
+						}
+			conn.commit();
+			return true;
+		}catch (Exception e) {
+			throw new IngestServiceException("Failed to delete transaction id '" + transactionId + "' : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public IngestReceipt update(TransactionId<?> transactionId,
+			List<TermBucket> termBuckets) throws IngestServiceException {
+		Connection conn = null;
+		Statement stmt = null;
+		try {
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			for (TermBucket termBucket : termBuckets) 
+				for (Term term : termBucket.getTerms()) 
+					for (String value : term.getValues())
+						try {
+							stmt.execute("DELETE FROM transaction_terms WHERE transaction_id = '" + transactionId + "' AND bucket_name = '" + termBucket.getName() + "' AND term_name = '" + term.getName() + "'");
+							stmt.execute("INSERT INTO transaction_terms VALUES ('" + transactionId + "','" + termBucket.getName() + "','" + term.getName() + "','" + (this.useUTF8 ? URLEncoder.encode(value, "UTF8") : value) + "')");
+						}catch (Exception e) {
+							LOG.log(Level.WARNING, "Failed to ingest term: '" + transactionId + "','" + termBucket.getName() + "','" + term.getName() + "','" + value + "'");
+						}
+			Calendar calendar = DateUtils.getCurrentLocalTime();
+			stmt.execute("UPDATE transactions SET transaction_date = '" + DateUtils.toString(calendar) + "' WHERE transaction_id = '" + transactionId + "'");
+			return new IngestReceipt(transactionId, calendar.getTime());
+		}catch (Exception e) {
+			throw new IngestServiceException("Failed to ingest metadata for transaction id '" + transactionId + "' : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public List<TermBucket> getBuckets(TransactionId<?> transactionId)
+			throws QueryServiceException {
+		Connection conn = null;
+		Statement stmt = null;
+		ResultSet rs = null;
+		try {
+			HashMap<String, TermBucket> termBuckets = new HashMap<String, TermBucket>();
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			rs = stmt.executeQuery("SELECT bucket_name,term_name,term_value FROM transaction_terms WHERE transaction_id = '" + transactionId + "'");
+			while (rs.next()) {
+                String bucketName = rs.getString("bucket_name");
+                String termName = rs.getString("term_name");
+                String termValue = rs.getString("term_value");
+                TermBucket bucket = termBuckets.get(bucketName);
+                if (bucket == null)
+                	bucket = new TermBucket(bucketName);
+                Term term = new Term(termName, Collections.singletonList((this.useUTF8 ? URLDecoder.decode(termValue, "UTF8") : termValue)));
+                bucket.addTerm(term);
+                termBuckets.put(bucketName, bucket);
+			}
+			return new Vector<TermBucket>(termBuckets.values());
+		}catch (Exception e) {
+			throw new QueryServiceException("Failed to get term buckets for transaction id '" + transactionId + "' : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+			try {
+				rs.close();
+			}catch(Exception e) {}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public Map<TransactionId<?>, List<TermBucket>> getBuckets(
+			List<TransactionId<?>> transactionIds) throws QueryServiceException {
+		HashMap<TransactionId<?>, List<TermBucket>> map = new HashMap<TransactionId<?>, List<TermBucket>>();
+		for (TransactionId<?> transactionId : transactionIds) 
+			map.put(transactionId, this.getBuckets(transactionId));
+		return map;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public List<IngestReceipt> query(QueryExpression queryExpression)
+			throws QueryServiceException {
+		Connection conn = null;
+		Statement stmt = null;
+		ResultSet rs = null;
+		try {
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			String sqlQuery = "SELECT DISTINCT transaction_id,transaction_date FROM transactions WHERE transaction_id IN (" + this.getSqlQuery(queryExpression) + ")";
+	        LOG.log(Level.INFO, "Performing Query: " + sqlQuery);
+			rs = stmt.executeQuery(sqlQuery);	
+
+			List<IngestReceipt> receipts = new Vector<IngestReceipt>();
+			while (rs.next()) 
+				receipts.add(new IngestReceipt(this.getTransactionIdFactory().createTransactionId(rs.getString("transaction_id")), DateUtils.toCalendar(rs.getString("transaction_date"), DateUtils.FormatType.LOCAL_FORMAT).getTime()));
+			return receipts;
+		}catch (Exception e) {
+			throw new QueryServiceException("Failed to query Workflow Instances Database : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+			try {
+				rs.close();
+			}catch(Exception e) {}
+		}
+	}
+	
+    private String getSqlQuery(QueryExpression queryExpression) throws QueryServiceException, UnsupportedEncodingException {
+        String sqlQuery = null;
+        if (queryExpression instanceof QueryLogicalGroup) {
+        	QueryLogicalGroup qlg = (QueryLogicalGroup) queryExpression;
+            sqlQuery = "(" + this.getSqlQuery(qlg.getExpressions().get(0));
+            String op = qlg.getOperator() == QueryLogicalGroup.Operator.AND ? "INTERSECT" : "UNION";
+            for (int i = 1; i < qlg.getExpressions().size(); i++) 
+                sqlQuery += ") " + op + " (" + this.getSqlQuery(qlg.getExpressions().get(i));
+            sqlQuery += ")";
+        }else if (queryExpression instanceof ComparisonQueryExpression){
+        	ComparisonQueryExpression cqe = (ComparisonQueryExpression) queryExpression;
+        	String operator = null;
+            if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.EQUAL_TO)) {
+            	operator = "=";
+            } else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.GREATER_THAN)) {
+            	operator = ">";
+            } else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.GREATER_THAN_EQUAL_TO)) {
+            	operator = ">=";
+            } else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.LESS_THAN)) {
+            	operator = "<";
+            } else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.LESS_THAN_EQUAL_TO)) {
+            	operator = "<=";
+            } else {
+                throw new QueryServiceException("Invalid ComparisonQueryExpression Operator '" + cqe.getOperator() + "'");
+            }
+            
+            sqlQuery = "SELECT DISTINCT transaction_id FROM transaction_terms WHERE term_name = '" + cqe.getTerm().getName() + "' AND (";
+        	for (int i = 0; i < cqe.getTerm().getValues().size(); i++) {
+        		String value = cqe.getTerm().getValues().get(i);
+                sqlQuery += "term_value " + operator + " '" + (this.useUTF8 ? URLEncoder.encode(value, "UTF-8") : value) + "'";
+	            if ((i + 1) < cqe.getTerm().getValues().size())
+	            	sqlQuery += " OR ";
+        	}
+        	sqlQuery += ")";
+        }else if (queryExpression instanceof NotQueryExpression) {
+        	NotQueryExpression nqe = (NotQueryExpression) queryExpression;
+            sqlQuery = "SELECT DISTINCT transaction_id FROM transaction_terms WHERE NOT (" + this.getSqlQuery(nqe.getQueryExpression()) + ")";
+        }else if (queryExpression instanceof StdQueryExpression) {
+            sqlQuery = "SELECT DISTINCT transaction_id FROM transaction_terms";
+        }else {
+            throw new QueryServiceException("Invalid QueryExpression '" + queryExpression.getClass().getCanonicalName() + "'");
+        }
+        return sqlQuery;
+    }
+
+}
+	
\ No newline at end of file

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndexFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndexFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndexFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/DataSourceIndexFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.index;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.struct.Index;
+import org.apache.oodt.cas.catalog.struct.IndexFactory;
+
+/**
+ * 
+ * Factory for creating DataSourceIndex(s).
+ * 
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class DataSourceIndexFactory implements IndexFactory {
+
+    protected String jdbcUrl;
+    protected String user;
+    protected String pass;
+    protected String driver;
+    protected boolean useUTF8;
+	
+    public DataSourceIndexFactory() {
+    	this.useUTF8 = false;
+    }
+    
+	public Index createIndex() {
+		return new DataSourceIndex(this.user, this.pass, this.driver, this.jdbcUrl, this.useUTF8);
+	}
+	
+	public void setJdbcUrl(String jdbcUrl) {
+		this.jdbcUrl = jdbcUrl;
+	}
+
+	public void setUser(String user) {
+		this.user = user;
+	}
+
+	public void setPass(String pass) {
+		this.pass = pass;
+	}
+
+	public void setDriver(String driver) {
+		this.driver = driver;
+	}
+	
+	public void setUseUTF8(boolean useUTF8) {
+		this.useUTF8 = useUTF8;
+	}
+
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/InMemoryIndex.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/InMemoryIndex.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/InMemoryIndex.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/InMemoryIndex.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.index;
+
+//JDK imports
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+
+//OODT imports
+import org.apache.oodt.commons.database.SqlScript;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A in memory Index which is ingestable
+ * <p>
+ */
+public class InMemoryIndex extends DataSourceIndex {
+
+	public InMemoryIndex(String user, String pass, String driver,
+			String jdbcUrl, boolean useUTF8, String tablesFile) throws SQLException, IOException {
+		super(user, pass, driver, jdbcUrl, useUTF8);
+        SqlScript coreSchemaScript = new SqlScript(new File(tablesFile).getAbsolutePath(), this.dataSource);
+        coreSchemaScript.loadScript();
+        coreSchemaScript.execute();
+	}
+
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/InMemoryIndexFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/InMemoryIndexFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/InMemoryIndexFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/InMemoryIndexFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.index;
+
+//JDK imports
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class InMemoryIndexFactory extends DataSourceIndexFactory {
+
+	private static final Logger LOG = Logger.getLogger(InMemoryIndexFactory.class.getName());
+	
+	protected String tablesFile;
+	
+	public InMemoryIndex createIndex() {
+		try {
+			return new InMemoryIndex(this.user, this.pass, this.driver, this.jdbcUrl, this.useUTF8, this.tablesFile);
+		}catch (Exception e) {
+			LOG.log(Level.SEVERE, "Failed to create InMemoryIndex : " + e.getMessage(), e);
+			return null;
+		}
+	}
+	
+	public void setTablesFile(String tablesFile) {
+		this.tablesFile = tablesFile;
+	}
+	
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndex.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndex.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndex.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndex.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.index;
+
+//JDK imports
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//SQL imports
+import javax.sql.DataSource;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.exception.CatalogIndexException;
+import org.apache.oodt.cas.catalog.exception.QueryServiceException;
+import org.apache.oodt.cas.catalog.page.IndexPager;
+import org.apache.oodt.cas.catalog.page.IngestReceipt;
+import org.apache.oodt.cas.catalog.query.ComparisonQueryExpression;
+import org.apache.oodt.cas.catalog.query.NotQueryExpression;
+import org.apache.oodt.cas.catalog.query.QueryExpression;
+import org.apache.oodt.cas.catalog.query.QueryLogicalGroup;
+import org.apache.oodt.cas.catalog.query.StdQueryExpression;
+import org.apache.oodt.cas.catalog.struct.Index;
+import org.apache.oodt.cas.catalog.struct.QueryService;
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.struct.TransactionIdFactory;
+import org.apache.oodt.cas.catalog.struct.impl.transaction.LongTransactionIdFactory;
+import org.apache.oodt.cas.catalog.term.Term;
+import org.apache.oodt.cas.catalog.term.TermBucket;
+import org.apache.oodt.commons.database.DatabaseConnectionBuilder;
+
+//EDA imports
+import org.apache.oodt.commons.util.DateConvert;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A queriable index for querying for original cas-workflow instance metadata (not for cas-workflow2)
+ * <p>
+ */
+public class WorkflowManagerDataSourceIndex implements Index, QueryService {
+
+	private static final Logger LOG = Logger.getLogger(WorkflowManagerDataSourceIndex.class.getName());
+	
+	protected DataSource dataSource;
+	
+	public WorkflowManagerDataSourceIndex(String user, String pass, String driver, String jdbcUrl) throws InstantiationException {
+		this.dataSource = DatabaseConnectionBuilder.buildDataSource(user, pass, driver, jdbcUrl);
+	}
+	
+	public List<TransactionId<?>> getPage(IndexPager indexPage)
+			throws CatalogIndexException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public Properties getProperties() throws CatalogIndexException {
+		return new Properties();
+	}
+
+	public String getProperty(String key) throws CatalogIndexException {
+		return null;
+	}
+
+	public TransactionIdFactory getTransactionIdFactory() throws CatalogIndexException {
+		return new LongTransactionIdFactory();
+	}
+
+	public boolean hasTransactionId(TransactionId<?> transactionId)
+			throws CatalogIndexException {
+		Connection conn = null;
+		Statement stmt = null;
+		ResultSet rs = null;
+		try {
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			rs = stmt.executeQuery("SELECT DISTINCT workflow_instance_id FROM workflow_instance_metadata WHERE workflow_instance_id = '" + transactionId + "'");	
+			return rs.next();
+		}catch (Exception e) {
+			throw new CatalogIndexException("Failed to check for workflow id '" + transactionId + "' : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+			try {
+				rs.close();
+			}catch(Exception e) {}
+		}
+	}
+
+	public List<TermBucket> getBuckets(TransactionId<?> transactionId)
+			throws QueryServiceException {
+		Connection conn = null;
+		Statement stmt = null;
+		ResultSet rs = null;
+		try {
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			rs = stmt.executeQuery("SELECT * FROM workflow_instance_metadata WHERE workflow_instance_id = '" + transactionId + "'");	
+			
+			TermBucket tb = new TermBucket("Workflows");
+			while (rs.next()) {
+                String key = rs.getString("workflow_met_key");
+                String value = URLDecoder.decode(rs.getString("workflow_met_val"), "UTF-8");
+                tb.addTerm(new Term(key, Collections.singletonList(value)));
+            }
+			return Collections.singletonList(tb);
+		}catch (Exception e) {
+			throw new QueryServiceException("Failed to get Workflow Instance Metadata for workflow id '" + transactionId + "' : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+			try {
+				rs.close();
+			}catch(Exception e) {}
+		}
+	}
+
+	public Map<TransactionId<?>, List<TermBucket>> getBuckets(
+			List<TransactionId<?>> transactionIds) throws QueryServiceException {
+		Map<TransactionId<?>, List<TermBucket>> returnMap = new HashMap<TransactionId<?>, List<TermBucket>>();
+		for (TransactionId<?> transactionId : transactionIds) 
+			returnMap.put(transactionId, this.getBuckets(transactionId));
+		return returnMap;
+	}
+
+	public List<IngestReceipt> query(QueryExpression queryExpression)
+			throws QueryServiceException {
+		Connection conn = null;
+		Statement stmt = null;
+		ResultSet rs = null;
+		try {
+			conn = this.dataSource.getConnection();
+			stmt = conn.createStatement();
+			String sqlQuery = "SELECT workflow_instance_id,start_date_time FROM workflow_instances WHERE workflow_instance_id IN (" + this.getSqlQuery(queryExpression) + ")";
+	        LOG.log(Level.INFO, "Performing Query: " + sqlQuery);
+			rs = stmt.executeQuery(sqlQuery);
+			
+			List<IngestReceipt> receipts = new Vector<IngestReceipt>();
+			while (rs.next()) 
+                receipts.add(new IngestReceipt(new LongTransactionIdFactory().createTransactionId(rs.getString("workflow_instance_id")), DateConvert.isoParse(rs.getString("start_date_time"))));
+			return receipts;
+		}catch (Exception e) {
+			throw new QueryServiceException("Failed to query Workflow Instances Database : " + e.getMessage(), e);
+		}finally {
+			try {
+				conn.close();
+			}catch(Exception e) {}
+			try {
+				stmt.close();
+			}catch(Exception e) {}
+			try {
+				rs.close();
+			}catch(Exception e) {}
+		}
+	}
+	
+    private String getSqlQuery(QueryExpression queryExpression) throws QueryServiceException, UnsupportedEncodingException {
+        String sqlQuery = null;
+        if (queryExpression instanceof QueryLogicalGroup) {
+        	QueryLogicalGroup qlg = (QueryLogicalGroup) queryExpression;
+            sqlQuery = "(" + this.getSqlQuery(qlg.getExpressions().get(0));
+            String op = qlg.getOperator() == QueryLogicalGroup.Operator.AND ? "INTERSECT" : "UNION";
+            for (int i = 1; i < qlg.getExpressions().size(); i++) 
+                sqlQuery += ") " + op + " (" + this.getSqlQuery(qlg.getExpressions().get(i));
+            sqlQuery += ")";
+        }else if (queryExpression instanceof ComparisonQueryExpression){
+        	ComparisonQueryExpression cqe = (ComparisonQueryExpression) queryExpression;
+        	String operator = null;
+            if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.EQUAL_TO)) {
+            	operator = "=";
+            } else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.GREATER_THAN)) {
+            	operator = ">";
+            } else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.GREATER_THAN_EQUAL_TO)) {
+            	operator = ">=";
+            } else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.LESS_THAN)) {
+            	operator = "<";
+            } else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.LESS_THAN_EQUAL_TO)) {
+            	operator = "<=";
+            } else {
+                throw new QueryServiceException("Invalid ComparisonQueryExpression Operator '" + cqe.getOperator() + "'");
+            }
+            
+            sqlQuery = "SELECT DISTINCT workflow_instance_id FROM workflow_instance_metadata WHERE workflow_met_key = '" + cqe.getTerm().getName() + "' AND (";
+        	for (int i = 0; i < cqe.getTerm().getValues().size(); i++) {
+        		String value = cqe.getTerm().getValues().get(i);
+                sqlQuery += "workflow_met_val " + operator + " '" + URLEncoder.encode(value, "UTF-8") + "'";
+	            if ((i + 1) < cqe.getTerm().getValues().size())
+	            	sqlQuery += "OR";
+        	}
+        	sqlQuery += ")";
+        }else if (queryExpression instanceof NotQueryExpression) {
+        	NotQueryExpression nqe = (NotQueryExpression) queryExpression;
+            sqlQuery = "SELECT DISTINCT workflow_instance_id FROM workflow_instance_metadata WHERE NOT (" + this.getSqlQuery(nqe.getQueryExpression()) + ")";
+        }else if (queryExpression instanceof StdQueryExpression) {
+            sqlQuery = "SELECT DISTINCT workflow_instance_id FROM workflow_instance_metadata";
+        }else {
+            throw new QueryServiceException("Invalid QueryExpression '" + queryExpression.getClass().getCanonicalName() + "'");
+        }
+        return sqlQuery;
+    }
+
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndexFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndexFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndexFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/index/WorkflowManagerDataSourceIndexFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.index;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.struct.IndexFactory;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class WorkflowManagerDataSourceIndexFactory implements IndexFactory {
+
+    protected String jdbcUrl;
+    protected String user;
+    protected String pass;
+    protected String driver;
+	
+	public WorkflowManagerDataSourceIndex createIndex() {
+		try {
+			return new WorkflowManagerDataSourceIndex(this.user, this.pass, this.driver, this.jdbcUrl);
+		}catch (Exception e) {
+			//log
+			return null;
+		}
+	}
+
+	public void setJdbcUrl(String jdbcUrl) {
+		this.jdbcUrl = jdbcUrl;
+	}
+
+	public void setUser(String user) {
+		this.user = user;
+	}
+
+	public void setPass(String pass) {
+		this.pass = pass;
+	}
+
+	public void setDriver(String driver) {
+		this.driver = driver;
+	}
+	
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/LongTransactionIdFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/LongTransactionIdFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/LongTransactionIdFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/LongTransactionIdFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.transaction;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.struct.TransactionIdFactory;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class LongTransactionIdFactory implements TransactionIdFactory {
+
+	public TransactionId<?> createNewTransactionId() {
+		return new TransactionId<Long>(System.currentTimeMillis()) {
+
+			@Override
+			protected Long fromString(String stringId) {
+				return Long.parseLong(stringId);
+			}
+			
+		};
+	}
+
+	public TransactionId<?> createTransactionId(String transactionIdString) {
+		return new TransactionId<Long>(transactionIdString) {
+
+			@Override
+			protected Long fromString(String stringId) {
+				return Long.parseLong(stringId);
+			}
+			
+		};
+	}
+
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/StringTransactionIdFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/StringTransactionIdFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/StringTransactionIdFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/StringTransactionIdFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.transaction;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.struct.TransactionIdFactory;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class StringTransactionIdFactory implements TransactionIdFactory {
+
+	public TransactionId<String> createNewTransactionId() {
+		return new StringTransactionId(Long.toString(System.currentTimeMillis()));
+	}
+
+	public TransactionId<?> createTransactionId(String transactionIdString) {
+		return new StringTransactionId(transactionIdString);
+	}
+	
+	private class StringTransactionId extends TransactionId<String> {
+
+		public StringTransactionId(String stringValue) {
+			this.nativeId = stringValue;
+		}
+		
+		@Override
+		protected String fromString(String stringId) {
+			return stringId;
+		}
+		
+	}
+
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/UuidTransactionIdFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/UuidTransactionIdFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/UuidTransactionIdFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/struct/impl/transaction/UuidTransactionIdFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.struct.impl.transaction;
+
+//JDK imports
+import java.util.UUID;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.struct.TransactionIdFactory;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class UuidTransactionIdFactory implements TransactionIdFactory {
+
+	public TransactionId<?> createNewTransactionId() {
+		return new TransactionId<UUID>(UUID.randomUUID()) {
+
+			@Override
+			protected UUID fromString(String stringId) {
+				return UUID.fromString(stringId);
+			}
+			
+		};
+	}
+
+	public TransactionId<?> createTransactionId(String transactionIdString) {
+		return new TransactionId<UUID>(transactionIdString) {
+
+			@Override
+			protected UUID fromString(String stringId) {
+				return UUID.fromString(stringId);
+			}
+			
+		};
+	}
+
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/Catalog.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/Catalog.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/Catalog.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/Catalog.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,353 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.system;
+
+//JDK imports
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.exception.CatalogDictionaryException;
+import org.apache.oodt.cas.catalog.exception.CatalogException;
+import org.apache.oodt.cas.catalog.exception.CatalogIndexException;
+import org.apache.oodt.cas.catalog.exception.IngestServiceException;
+import org.apache.oodt.cas.catalog.page.CatalogReceipt;
+import org.apache.oodt.cas.catalog.page.IndexPager;
+import org.apache.oodt.cas.catalog.page.IngestReceipt;
+import org.apache.oodt.cas.catalog.query.QueryExpression;
+import org.apache.oodt.cas.catalog.struct.Dictionary;
+import org.apache.oodt.cas.catalog.struct.Index;
+import org.apache.oodt.cas.catalog.struct.IngestService;
+import org.apache.oodt.cas.catalog.struct.QueryService;
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.struct.TransactionIdFactory;
+import org.apache.oodt.cas.catalog.term.Term;
+import org.apache.oodt.cas.catalog.term.TermBucket;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Calatog is a communication interface between the CatalogService and an underlying
+ * database or index service
+ * <p>
+ */
+public class Catalog {
+
+	private static Logger LOG = Logger.getLogger(Catalog.class.getName());
+		
+	protected Vector<Dictionary> dictionaries;
+	protected Index index;
+	protected String id;
+	protected boolean restrictQueryPermissions = true;
+	protected boolean restrictIngestPermissions = true;
+	
+	public Catalog(String id, Index index, List<Dictionary> dictionaries, boolean restrictQueryPermissions, boolean restrictIngestPermissions) {
+		this.id = id;
+		this.index = index;
+		if (dictionaries != null)
+			this.dictionaries = new Vector<Dictionary>(dictionaries);
+		this.restrictQueryPermissions = restrictQueryPermissions;
+		this.restrictIngestPermissions = restrictIngestPermissions;
+	}
+	
+	public String getId() {
+		return this.id;
+	}
+
+	public TransactionIdFactory getTransactionIdFactory() throws CatalogIndexException {
+		return this.index.getTransactionIdFactory();
+	}
+	
+	public void setIndex(Index index) {
+		this.index = index;
+	}
+	
+	public void setDictionaries(List<Dictionary> dictionaries) {
+		this.dictionaries = new Vector<Dictionary>(dictionaries);
+	}
+	
+	public List<Dictionary> getDictionaries() {
+		return Collections.unmodifiableList(this.dictionaries);
+	}
+	
+	public void addDictionary(Dictionary dictionary) {
+		if (this.dictionaries == null)
+			this.dictionaries = new Vector<Dictionary>();
+		this.dictionaries.add(dictionary);
+	}
+
+	public void setRestrictQueryPermissions(boolean restrictQueryPermissions) {
+		this.restrictQueryPermissions = restrictQueryPermissions;
+	}
+
+	public void setRestrictIngestPermissions(boolean restrictIngestPermissions) {
+		this.restrictIngestPermissions = restrictIngestPermissions;
+	}
+
+	public boolean isQueriable() {
+		return this.index instanceof QueryService && !this.restrictQueryPermissions;
+	}
+	
+	public boolean isIngestable() {
+		return this.index instanceof IngestService && !this.restrictIngestPermissions;
+	}
+	
+	public List<TransactionId<?>> getPage(IndexPager indexPage) throws CatalogIndexException {
+		return this.index.getPage(indexPage);
+	}
+	
+	public TransactionId<?> getTransactionIdFromString(String catalogTransactionId) throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, CatalogIndexException {
+		return this.getTransactionIdFactory().createTransactionId(catalogTransactionId);
+	}
+	
+	public boolean hasTransactionId(TransactionId<?> catalogTransactionid)  throws CatalogIndexException {
+		return this.index.hasTransactionId(catalogTransactionid);
+	}
+	
+	public String getProperty(String key)  throws CatalogException {
+		try {
+			return this.index.getProperty(key);
+		}catch (Exception e) {
+			throw new CatalogException("Failed to get property '" + key + "' : " + e.getMessage(), e);
+		}
+	}
+	
+	public Properties getProperties() throws CatalogException {
+		try {
+			return this.index.getProperties();
+		}catch (Exception e) {
+			throw new CatalogException("Failed to get properties : " + e.getMessage(), e);
+		}
+	}
+	
+	/**
+	 * 
+	 * @param transactionId
+	 * @param metadata
+	 * @return TransactionId param if used by underlying catalog, otherwise
+	 * the TransactionId generated and used by underlying catalog.  if no
+	 * TermBuckets where created from the Metadata then null is returned
+	 * @throws IngestServiceException
+	 */
+	public CatalogReceipt ingest(Metadata metadata) throws CatalogException {
+		try {
+			if (this.isIngestable()) {
+				List<TermBucket> termBuckets = this.getTermBuckets(metadata);
+				if (termBuckets.size() > 0) {
+					LOG.log(Level.INFO, "Catalog '" + this + "' attemping ingest metadata");
+					return new CatalogReceipt(((IngestService) this.index).ingest(termBuckets), this.getId());
+				}else {
+					LOG.log(Level.WARNING, "Catalog '" + this + "' dictionaries did not generate any TermBuckets from Metadata");
+					return null;
+				}
+			}else {
+				LOG.log(Level.WARNING, "Catalog '" + this + "' is not ingestable");
+				return null;
+			}
+		}catch (Exception e) {
+			throw new CatalogException("", e);
+		}
+	}
+	
+	public CatalogReceipt update(TransactionId<?> transactionId, Metadata metadata) throws CatalogException {
+		try {
+			if (this.isIngestable()) {
+				List<TermBucket> termBuckets = this.getTermBuckets(metadata);
+				if (termBuckets.size() > 0) {
+					LOG.log(Level.INFO, "Catalog '" + this + "' attemping update metadata for catalog TransactionId [id = '" + transactionId + "']");
+					IngestReceipt ingestReceipt = ((IngestService) this.index).update(transactionId, termBuckets);
+					if (ingestReceipt != null)
+						return new CatalogReceipt(ingestReceipt, this.getId());
+					else
+						return null;
+				}else {
+					LOG.log(Level.WARNING, "Catalog '" + this + "' did not generate any TermBuckets from Metadata for catalog TransactionId [id = '" + transactionId + "']");
+					return null;
+				}
+			}else {
+				LOG.log(Level.WARNING, "Catalog '" + this + "' is not ingestable");
+				return null;
+			}
+		}catch (Exception e) {
+			throw new CatalogException("", e);
+		}
+	}
+	
+	public boolean delete(TransactionId<?> transactionId) throws CatalogException {
+		try {
+			if (this.isIngestable()) {
+				LOG.log(Level.INFO, "Catalog '" + this + "' attemping to delete all TermBuckets associated with catalog TransactionId [id = '" + transactionId + "']");
+				return ((IngestService) this.index).delete(transactionId);
+			}else {
+				LOG.log(Level.WARNING, "Catalog '" + this + "' is not ingestable");
+				return false;
+			}
+		}catch (Exception e) {
+			throw new CatalogException("", e);
+		}
+	}
+	
+	public boolean reduce(TransactionId<?> transactionId, Metadata metadata) throws CatalogException {
+		try {
+			if (this.isIngestable()) {
+				List<TermBucket> termBuckets = this.getTermBuckets(metadata);
+				if (termBuckets.size() > 0) {
+					LOG.log(Level.INFO, "Catalog '" + this + "' attemping reduce metadata for catalog TransactionId [id = '" + transactionId + "']");
+					return ((IngestService) this.index).reduce(transactionId, termBuckets);
+				}else {
+					LOG.log(Level.WARNING, "Catalog '" + this + "' did not generate any TermBuckets from Metadata for catalog TransactionId [id = '" + transactionId + "'] -- no metadata reduction took place");
+					return false;
+				}
+			}else {
+				LOG.log(Level.WARNING, "Catalog '" + this + "' is not ingestable");
+				return false;
+			}
+		}catch(Exception e) {
+			throw new CatalogException("", e);
+		}
+	}
+		
+	public List<CatalogReceipt> query(QueryExpression queryExpression) throws CatalogException {
+		try {
+			if (this.isQueriable()) {
+				QueryService queryService = (QueryService) this.index;
+				List<CatalogReceipt> catalogReceipts = new Vector<CatalogReceipt>();
+				for (IngestReceipt ingestReceipt : queryService.query(queryExpression)) 
+					catalogReceipts.add(new CatalogReceipt(ingestReceipt, this.getId()));
+				return Collections.unmodifiableList(catalogReceipts);
+			}else {
+				LOG.log(Level.WARNING, "Catalog '" + this + "' is not queriable");
+				return Collections.emptyList();
+			}
+		}catch (Exception e) {
+			throw new CatalogException("", e);
+		}
+	}
+	
+	public Metadata getMetadata(TransactionId<?> transactionId) throws CatalogException {
+		try {
+			if (this.isQueriable()) {
+				QueryService queryService = (QueryService) this.index;
+				return this.getMetadataFromBuckets(queryService.getBuckets(transactionId));
+			}else { 
+				LOG.log(Level.WARNING, "Catalog '" + this + "' is not queriable");
+				return new Metadata();
+			}
+		}catch(Exception e) {
+			throw new CatalogException("", e);
+		}
+	}
+	
+	public Map<TransactionId<?>, Metadata> getMetadata(List<TransactionId<?>> transactionIds) throws CatalogException {
+		try {
+			Map<TransactionId<?>, Metadata> metadataMap = new HashMap<TransactionId<?>, Metadata>();
+			if (this.isQueriable()) {
+				QueryService queryService = (QueryService) this.index;
+				Map<TransactionId<?>, List<TermBucket>> termBucketMap = queryService.getBuckets(transactionIds);
+				for (TransactionId<?> transactionId : termBucketMap.keySet())
+					metadataMap.put(transactionId, this.getMetadataFromBuckets(termBucketMap.get(transactionId)));
+			}else {
+				LOG.log(Level.WARNING, "Catalog '" + this + "' is not queriable");
+			}
+			return metadataMap;
+		}catch(Exception e) {
+			throw new CatalogException("", e);
+		}
+	}
+	
+	public boolean isInterested(QueryExpression queryExpression) throws CatalogException {
+		try {
+			if (this.dictionaries != null) {
+				for (Dictionary dictionary : this.dictionaries)
+					if (dictionary.understands(queryExpression))
+						return true;
+				return false;
+			}else {
+				return true;
+			}
+		}catch(Exception e) {
+			throw new CatalogException("", e);
+		}
+	}
+	
+	protected Metadata getMetadataFromBuckets(List<TermBucket> termBuckets) throws CatalogDictionaryException {
+		Metadata metadata = new Metadata();
+		for (TermBucket termBucket : termBuckets) {
+			if (this.dictionaries != null) {
+				for (Dictionary dictionary : this.dictionaries) 
+					metadata.addMetadata(dictionary.reverseLookup(termBucket));
+			}else {
+				metadata.addMetadata(this.asMetadata(termBuckets));
+			}
+		}
+		return metadata;
+	}
+	
+	protected Metadata asMetadata(List<TermBucket> termBuckets) {
+		Metadata m = new Metadata();
+		for (TermBucket bucket : termBuckets)
+			for (Term term : bucket.getTerms())
+				m.addMetadata(term.getName(), term.getValues());
+		return m;
+	}
+    
+	protected List<TermBucket> getTermBuckets(Metadata metadata) throws CatalogDictionaryException {
+		List<TermBucket> termBuckets = new Vector<TermBucket>();
+		if (this.dictionaries != null) {
+			for (Dictionary dictionary : this.dictionaries) {
+				TermBucket termBucket = dictionary.lookup(metadata);
+				if (termBucket != null)
+					termBuckets.add(termBucket);
+			}
+		}else {
+			LOG.log(Level.WARNING, "Catalog '" + this + "' has no dictionaries defined, attempting to send all Metadata in a default TermBucket");
+			TermBucket bucket = new TermBucket();
+			for (String key : metadata.getAllKeys())
+				bucket.addTerm(new Term(key, metadata.getAllMetadata(key)));
+			termBuckets.add(bucket);
+		}
+		return termBuckets;
+	}
+	
+	public int hashCode() {
+		return this.toString().hashCode();
+	}
+	
+	public boolean equals(Object obj) {
+		if (obj instanceof Catalog) 
+			return ((Catalog) obj).getId().equals(this.getId());
+		else if (obj instanceof String) 
+			return this.getId().equals((String) obj);
+		else
+			return false;
+	}
+	
+    public String toString() {
+    	return this.getId();
+    }
+		
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.system;
+
+//JDK imports
+import java.util.List;
+import java.util.Vector;
+
+//OOD imports
+import org.apache.oodt.cas.catalog.struct.Dictionary;
+import org.apache.oodt.cas.catalog.struct.DictionaryFactory;
+import org.apache.oodt.cas.catalog.struct.IndexFactory;
+
+//Spring imports
+import org.springframework.beans.factory.annotation.Required;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class CatalogFactory {
+
+	protected String catalogId;
+	protected IndexFactory indexFactory;
+	protected List<DictionaryFactory> dictionaryFactories;
+	protected boolean restrictQueryPermissions;
+	protected boolean restrictIngestPermissions;
+	
+	public Catalog createCatalog() {
+		Vector<Dictionary> dictionaries = null;
+		if (this.dictionaryFactories != null) {
+			dictionaries = new Vector<Dictionary>();
+			for (DictionaryFactory dictionaryFactory : this.dictionaryFactories)
+				dictionaries.add(dictionaryFactory.createDictionary());
+		}
+		return new Catalog(this.catalogId, this.indexFactory.createIndex(), dictionaries, this.restrictQueryPermissions, this.restrictIngestPermissions);
+	}
+
+	@Required
+	public void setCatalogId(String catalogId) {
+		this.catalogId = catalogId;
+	}
+
+	@Required
+	public void setIndexFactory(IndexFactory indexFactory) {
+		this.indexFactory = indexFactory;
+	}
+
+	@Required
+	public void setDictionaryFactories(List<DictionaryFactory> dictionaryFactories) {
+		this.dictionaryFactories = dictionaryFactories;
+	}
+
+	@Required
+	public void setRestrictQueryPermissions(boolean restrictQueryPermissions) {
+		this.restrictQueryPermissions = restrictQueryPermissions;
+	}
+
+	@Required
+	public void setRestrictIngestPermissions(boolean restrictIngestPermissions) {
+		this.restrictIngestPermissions = restrictIngestPermissions;
+	}
+	
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogService.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogService.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogService.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogService.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.system;
+
+//JDK imports
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.exception.CatalogServiceException;
+import org.apache.oodt.cas.catalog.metadata.TransactionalMetadata;
+import org.apache.oodt.cas.catalog.page.CatalogReceipt;
+import org.apache.oodt.cas.catalog.page.Page;
+import org.apache.oodt.cas.catalog.page.PageInfo;
+import org.apache.oodt.cas.catalog.page.QueryPager;
+import org.apache.oodt.cas.catalog.page.TransactionReceipt;
+import org.apache.oodt.cas.catalog.query.QueryExpression;
+import org.apache.oodt.cas.catalog.struct.Dictionary;
+import org.apache.oodt.cas.catalog.struct.Index;
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.util.PluginURL;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * An interface for a Metadata Catalog Manager Service
+ * <p>
+ */
+public interface CatalogService {
+		
+	public static final String CATALOG_SERVICE_TRANSACTION_ID_MET_KEY = "urn:CatalogService:TransactionId";
+	public static final String CATALOG_IDS_MET_KEY = "urn:CatalogService:CatalogIds";
+	public static final String CATALOG_TRANSACTION_ID_MET_KEY = "urn:Catalog:TransactionId";
+	public static final String CATALOG_ID_MET_KEY = "urn:Catalog:Id";
+
+	public void shutdown() throws CatalogServiceException;
+	
+	public boolean isRestrictQueryPermissions() throws CatalogServiceException;
+
+	public boolean isRestrictIngestPermissions() throws CatalogServiceException;
+
+	public void addCatalog(Catalog catalog) throws CatalogServiceException;
+	
+	public void replaceCatalog(Catalog catalog) throws CatalogServiceException;
+	
+	public void addCatalog(String catalogId, Index index) throws CatalogServiceException;
+	
+	public void addCatalog(String catalogId, Index index, List<Dictionary> dictionaries) throws CatalogServiceException;
+
+	public void addCatalog(String catalogId, Index index, List<Dictionary> dictionaries, boolean restrictQueryPermission, boolean restrictIngestPermission) throws CatalogServiceException;
+
+	public void addDictionary(String catalogId, Dictionary dictionary) throws CatalogServiceException;
+
+	public void replaceDictionaries(String catalogId, List<Dictionary> dictionaries) throws CatalogServiceException;
+	
+	public void replaceIndex(String catalogId, Index index) throws CatalogServiceException;
+
+	public void modifyIngestPermission(String catalogId, boolean restrictIngestPermission) throws CatalogServiceException;
+	
+	public void modifyQueryPermission(String catalogId, boolean restrictQueryPermission) throws CatalogServiceException;
+		
+	public void removeCatalog(String catalogId) throws CatalogServiceException;
+
+	public URL getPluginStorageDir() throws CatalogServiceException;
+	
+	public List<PluginURL> getPluginUrls() throws CatalogServiceException;
+
+	public void addPluginUrls(List<PluginURL> pluginURLs) throws CatalogServiceException;
+
+	public Set<String> getCurrentCatalogIds() throws CatalogServiceException;
+		
+	public TransactionReceipt ingest(Metadata metadata) throws CatalogServiceException;
+	
+	public void delete(Metadata metadata) throws CatalogServiceException;
+	
+	public List<String> getProperty(String key) throws CatalogServiceException;
+
+	public Properties getCalalogProperties() throws CatalogServiceException;
+	
+	public Properties getCalalogProperties(String catalogUrn) throws CatalogServiceException;
+	
+	public Page getNextPage(Page page) throws CatalogServiceException;
+		
+	public Page getPage(PageInfo pageInfo, QueryExpression queryExpression) throws CatalogServiceException;
+	
+	public Page getPage(PageInfo pageInfo, QueryExpression queryExpression, Set<String> catalogIds) throws CatalogServiceException;
+
+	public List<TransactionalMetadata> getMetadata(Page page) throws CatalogServiceException;
+	
+	public QueryPager query(QueryExpression queryExpression) throws CatalogServiceException;
+
+	public QueryPager query(QueryExpression queryExpression, Set<String> catalogIds) throws CatalogServiceException;
+	 
+	public List<TransactionalMetadata> getNextPage(QueryPager queryPager) throws CatalogServiceException;
+	
+	public List<TransactionalMetadata> getAllPages(QueryPager queryPager) throws CatalogServiceException;
+	
+	public List<TransactionalMetadata> getMetadataFromTransactionIdStrings(List<String> catalogServiceTransactionIdStrings) throws CatalogServiceException;
+	
+	public List<TransactionalMetadata> getMetadataFromTransactionIds(List<TransactionId<?>> catalogServiceTransactionIds) throws CatalogServiceException;
+	
+	public List<TransactionId<?>> getCatalogServiceTransactionIds(List<TransactionId<?>> catalogTransactionIds, String catalogUrn) throws CatalogServiceException;
+	
+	public TransactionId<?> getCatalogServiceTransactionId(TransactionId<?> catalogTransactionId, String catalogUrn) throws CatalogServiceException;
+	
+	public TransactionId<?> getCatalogServiceTransactionId(CatalogReceipt catalogReceipt, boolean generateNew) throws CatalogServiceException;
+	
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogServiceFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogServiceFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/CatalogServiceFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.system;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Factory for CatalogService
+ * <p>
+ */
+public interface CatalogServiceFactory {
+
+	public CatalogService createCatalogService();
+	
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClient.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClient.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClient.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/system/impl/CatalogServiceClient.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,407 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.system.impl;
+
+//JDK imports
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.exception.CatalogServiceException;
+import org.apache.oodt.cas.catalog.metadata.TransactionalMetadata;
+import org.apache.oodt.cas.catalog.page.CatalogReceipt;
+import org.apache.oodt.cas.catalog.page.Page;
+import org.apache.oodt.cas.catalog.page.PageInfo;
+import org.apache.oodt.cas.catalog.page.QueryPager;
+import org.apache.oodt.cas.catalog.page.TransactionReceipt;
+import org.apache.oodt.cas.catalog.query.QueryExpression;
+import org.apache.oodt.cas.catalog.server.channel.CommunicationChannelClient;
+import org.apache.oodt.cas.catalog.struct.Dictionary;
+import org.apache.oodt.cas.catalog.struct.Index;
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.system.Catalog;
+import org.apache.oodt.cas.catalog.system.CatalogService;
+import org.apache.oodt.cas.catalog.util.PluginURL;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Client that appears to be a CatalogService, but communicates with a CatalogService Server
+ * <p>
+ */
+public class CatalogServiceClient implements CatalogService {
+
+	protected CommunicationChannelClient communicationChannelClient;
+	protected int autoPagerSize;
+	
+	public CatalogServiceClient(CommunicationChannelClient communicationChannelClient, int autoPagerSize) {
+		this.communicationChannelClient = communicationChannelClient;
+		this.autoPagerSize = autoPagerSize;
+	}
+	
+	public void shutdown() throws CatalogServiceException  {
+		try {
+			this.communicationChannelClient.shutdown();
+		}catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	protected List<PluginURL> transferToServerSide(List<PluginURL> clientSideUrls) throws CatalogServiceException {
+		try {
+			URL customUrlStorageDir = this.communicationChannelClient.getPluginStorageDir();
+			System.out.println("Got Tmp dir : " + customUrlStorageDir);
+			Vector<PluginURL> serverSideUrls = new Vector<PluginURL>();
+			for (PluginURL pluginURL : clientSideUrls) {
+				PluginURL serverSideURL = new PluginURL(pluginURL.getCatalogId(), new URL(customUrlStorageDir, new File(pluginURL.getURL().getFile()).getName()));
+				System.out.println("generated server side url : " + customUrlStorageDir);
+				this.communicationChannelClient.transferUrl(pluginURL.getURL(), serverSideURL.getURL());
+				serverSideUrls.add(serverSideURL);
+			}
+			return serverSideUrls;
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+		
+	public void addCatalog(Catalog catalog) throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.addCatalog(catalog);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public void replaceCatalog(Catalog catalog)
+			throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.replaceCatalog(catalog);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public void addCatalog(String catalogId, Index index)
+			throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.addCatalog(catalogId, index);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public void addCatalog(String catalogId, Index index, List<Dictionary> dictionaries) throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.addCatalog(catalogId, index, dictionaries);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public void addCatalog(String catalogId, Index index, List<Dictionary> dictionaries, boolean restrictQueryPermission,
+			boolean restrictIngestPermission) throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.addCatalog(catalogId, index, dictionaries, restrictQueryPermission, restrictIngestPermission);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public void addDictionary(String catalogId, Dictionary dictionary)
+			throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.addDictionary(catalogId, dictionary);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public void replaceDictionaries(String catalogId, List<Dictionary> dictionaries) throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.replaceDictionaries(catalogId, dictionaries);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public void modifyIngestPermission(String catalogId,
+			boolean restrictIngestPermission) throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.modifyIngestPermission(catalogId, restrictIngestPermission);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public void modifyQueryPermission(String catalogId,
+			boolean restrictQueryPermission) throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.modifyQueryPermission(catalogId, restrictQueryPermission);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public void replaceIndex(String catalogId, Index index)
+			throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.replaceIndex(catalogId, index);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public void removeCatalog(String catalogId) throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.removeCatalog(catalogId);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public URL getPluginStorageDir() throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getPluginStorageDir();
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public List<PluginURL> getPluginUrls() throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getPluginUrls();
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public void addPluginUrls(List<PluginURL> urls) throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.addPluginUrls(this.transferToServerSide(urls));
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public void delete(Metadata metadata) throws CatalogServiceException {
+		try {
+			this.communicationChannelClient.delete(metadata);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public List<TransactionalMetadata> getAllPages(QueryPager queryPager)
+			throws CatalogServiceException {
+		try {
+			List<TransactionalMetadata> metadata = new Vector<TransactionalMetadata>();
+			if (queryPager.getTotalPages() > 0) {
+				queryPager.setPageInfo(new PageInfo(this.autoPagerSize, PageInfo.FIRST_PAGE));
+				while (!queryPager.isLastPage()) {
+					metadata.addAll(this.communicationChannelClient.getNextPage(queryPager));
+					queryPager.incrementPageNumber();
+				}
+				metadata.addAll(this.communicationChannelClient.getNextPage(queryPager));
+			}
+			return metadata;
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public Properties getCalalogProperties() throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getCalalogProperties();
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public Properties getCalalogProperties(String catalogUrn)
+			throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getCalalogProperties(catalogUrn);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public TransactionId<?> getCatalogServiceTransactionId(
+			TransactionId<?> catalogTransactionId, String catalogUrn)
+			throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getCatalogServiceTransactionId(catalogTransactionId, catalogUrn);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public TransactionId<?> getCatalogServiceTransactionId(
+			CatalogReceipt catalogReceipt, boolean generateNew) throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getCatalogServiceTransactionId(catalogReceipt, generateNew);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public List<TransactionId<?>> getCatalogServiceTransactionIds(
+			List<TransactionId<?>> catalogTransactionIds, String catalogUrn)
+			throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getCatalogServiceTransactionIds(catalogTransactionIds, catalogUrn);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public Set<String> getCurrentCatalogIds() throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getCurrentCatalogIds();
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public List<TransactionalMetadata> getMetadataFromTransactionIdStrings(
+			List<String> catalogServiceTransactionIdStrings)
+			throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getMetadataFromTransactionIdStrings(catalogServiceTransactionIdStrings);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public List<TransactionalMetadata> getMetadataFromTransactionIds(
+			List<TransactionId<?>> catalogServiceTransactionIds)
+			throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getMetadataFromTransactionIds(catalogServiceTransactionIds);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public List<TransactionalMetadata> getNextPage(QueryPager queryPager)
+			throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getNextPage(queryPager);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public List<String> getProperty(String key) throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getProperty(key);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public List<TransactionId<?>> getTransactionIdsForAllPages(
+			QueryPager queryPager) throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getTransactionIdsForAllPages(queryPager);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public TransactionReceipt ingest(Metadata metadata)
+			throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.ingest(metadata);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public boolean isRestrictIngestPermissions() throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.isRestrictIngestPermissions();
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+	public boolean isRestrictQueryPermissions() throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.isRestrictQueryPermissions();
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public Page getNextPage(Page page) throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getNextPage(page);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public Page getPage(PageInfo pageInfo, QueryExpression queryExpression) throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getPage(pageInfo, queryExpression);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public Page getPage(PageInfo pageInfo, QueryExpression queryExpression, Set<String> catalogIds) throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getPage(pageInfo, queryExpression, catalogIds);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public List<TransactionalMetadata> getMetadata(Page page) throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.getMetadata(page);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public QueryPager query(QueryExpression queryExpression)
+			throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.query(queryExpression);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+	
+	public QueryPager query(QueryExpression queryExpression, Set<String> catalogIds) throws CatalogServiceException {
+		try {
+			return this.communicationChannelClient.query(queryExpression, catalogIds);
+		} catch (Exception e) {
+			throw new CatalogServiceException("", e);
+		}
+	}
+
+}



Mime
View raw message