Author: mattmann
Date: Mon Jul 12 19:50:01 2010
New Revision: 963451

URL: http://svn.apache.org/viewvc?rev=963451&view=rev
Log:
- progress towards OODT-15 One trunk for all OODT components with top level 
build

Modified:
    
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepository.java
    
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepositoryFactory.java
    
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepository.java
    
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepositoryFactory.java
    
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java
    
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepositoryFactory.java
    
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepository.java
    
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepositoryFactory.java

Modified: 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepository.java?rev=963451&r1=963450&r2=963451&view=diff
==============================================================================
--- 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepository.java
 (original)
+++ 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepository.java
 Mon Jul 12 19:50:01 2010
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
@@ -28,81 +28,52 @@ import org.apache.oodt.cas.catalog.util.
 
 /**
  * 
- * @author bfoster
- * @version $Revision$
+ * Repository where the CatalogService stores its TransactionId Mapping and
+ * serializes its Catalogs
  * 
- *          <p>
- *          Repository where the CatalogService stores its TransactionId 
Mapping
- *          and serializes its Catalogs
- *          <p>
  */
 public interface CatalogRepository {
-//
-//     /**
-//      * Verifies if the given Catalog URN has been serialized via {...@link
-//      * serializeCatalog(Catalog)}
-//      * 
-//      * @param catalogUrn
-//      *            The URN that unique represents the Catalog
-//      * @return True if the Catalog has been serialized, false otherwise
-//      * @throws CatalogRepositoryException
-//      *             Any Error
-//      */
-//     public boolean isCatalogSerialized(String catalogUrn)
-//                     throws CatalogRepositoryException;
-//
-       /**
-        * Serializes a given Catalog to the Repository
-        * 
-        * @param catalog
-        *            The Catalog to be serialized
-        * @throws CatalogRepositoryException
-        *             Any Error
-        */
-       public void serializeCatalog(Catalog catalog)
-                       throws CatalogRepositoryException;
-//
-//     /**
-//      * Loads a Catalog from the Repository
-//      * 
-//      * @param catalogUrn
-//      *            The URN that unique represents a Catalog
-//      * @return The Catalog represented by the given URN
-//      * @throws CatalogRepositoryException
-//      *             Any Error
-//      */
-//     public Catalog deserializeCatalog(String catalogUrn)
-//                     throws CatalogRepositoryException;
-//
-       /**
-        * Removes a Catalog from the Repository
-        * 
-        * @param catalogUrn
-        *            The URN that unique represents the Catalog to be removed
-        * @param preserveMapping
-        *            If true, don't erase TransactionId mapping for this 
catalog
-        * @throws CatalogRepositoryException
-        *             Any Error
-        */
-       public void deleteSerializedCatalog(String catalogUrn)
-                       throws CatalogRepositoryException;
-
-       /**
-        * Loads all Catalogs serialized in this Repository
-        * 
-        * @return All the Catalogs serialized in this Repository
-        * @throws CatalogRepositoryException
-        *             Any Error
-        */
-       public Set<Catalog> deserializeAllCatalogs()
-                       throws CatalogRepositoryException;
-
-       public void serializePluginURLs(List<PluginURL> urls) 
-                       throws CatalogRepositoryException;
-       
-       public List<PluginURL> deserializePluginURLs() 
-                       throws CatalogRepositoryException;
-       
-       public boolean isModifiable() throws CatalogRepositoryException;
-       
+
+  /**
+   * Serializes a given Catalog to the Repository
+   * 
+   * @param catalog
+   *          The Catalog to be serialized
+   * @throws CatalogRepositoryException
+   *           Any Error
+   */
+  public void serializeCatalog(Catalog catalog)
+      throws CatalogRepositoryException;
+
+  /**
+   * Removes a Catalog from the Repository
+   * 
+   * @param catalogUrn
+   *          The URN that unique represents the Catalog to be removed
+   * @param preserveMapping
+   *          If true, don't erase TransactionId mapping for this catalog
+   * @throws CatalogRepositoryException
+   *           Any Error
+   */
+  public void deleteSerializedCatalog(String catalogUrn)
+      throws CatalogRepositoryException;
+
+  /**
+   * Loads all Catalogs serialized in this Repository
+   * 
+   * @return All the Catalogs serialized in this Repository
+   * @throws CatalogRepositoryException
+   *           Any Error
+   */
+  public Set<Catalog> deserializeAllCatalogs()
+      throws CatalogRepositoryException;
+
+  public void serializePluginURLs(List<PluginURL> urls)
+      throws CatalogRepositoryException;
+
+  public List<PluginURL> deserializePluginURLs()
+      throws CatalogRepositoryException;
+
+  public boolean isModifiable() throws CatalogRepositoryException;
+
 }

Modified: 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepositoryFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepositoryFactory.java?rev=963451&r1=963450&r2=963451&view=diff
==============================================================================
--- 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepositoryFactory.java
 (original)
+++ 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/CatalogRepositoryFactory.java
 Mon Jul 12 19:50:01 2010
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
@@ -21,15 +21,12 @@ package org.apache.oodt.cas.catalog.repo
 import org.apache.oodt.cas.catalog.exception.CatalogRepositoryException;
 
 /**
- * @author bfoster
- * @version $Revision$
- *
- * <p>
- * A Factory for creating CatalogRepository
- * <p>
+ * 
+ * A factory for creating CatalogRepositories.
+ * 
  */
 public interface CatalogRepositoryFactory {
 
-       public CatalogRepository createRepository() throws 
CatalogRepositoryException;
-       
+  public CatalogRepository createRepository() throws 
CatalogRepositoryException;
+
 }

Modified: 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepository.java?rev=963451&r1=963450&r2=963451&view=diff
==============================================================================
--- 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepository.java
 (original)
+++ 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepository.java
 Mon Jul 12 19:50:01 2010
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
@@ -31,94 +31,89 @@ import java.util.Vector;
 
 /**
  * 
- * @author bfoster
- * @version $Revision$
+ * Memory based Repository where the CatalogService stores its TransactionId
+ * Mapping and serializes its Catalogs
  * 
- *          <p>
- *          Memory based Repository where the CatalogService stores its
- *          TransactionId Mapping and serializes its Catalogs
- *          <p>
  */
 public class MemoryBasedCatalogRepository implements CatalogRepository {
-       
-       protected HashMap<String, Catalog> catalogMap;
-       protected List<PluginURL> classLoaderUrls;
-
-       public MemoryBasedCatalogRepository() {
-               this.catalogMap = new HashMap<String, Catalog>();
-               this.classLoaderUrls = new Vector<PluginURL>();
-       }
-       
-       /*
-        * (non-Javadoc)
-        * 
-        * @seeorg.apache.oodt.cas.catalog.repository.CatalogRepository#
-        * deleteSerializedCatalog(java.lang.String)
-        */
-       public void deleteSerializedCatalog(String catalogUrn)
-                       throws CatalogRepositoryException {
-               this.catalogMap.remove(catalogUrn);
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @seeorg.apache.oodt.cas.catalog.repository.CatalogRepository#
-        * deserializeAllCatalogs()
-        */
-       public Set<Catalog> deserializeAllCatalogs()
-                       throws CatalogRepositoryException {
-               return new HashSet<Catalog>(this.catalogMap.values());
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * 
org.apache.oodt.cas.catalog.repository.CatalogRepository#deserializeCatalog
-        * (java.lang.String)
-        */
-       public Catalog deserializeCatalog(String catalogUrn)
-                       throws CatalogRepositoryException {
-               return this.catalogMap.get(catalogUrn);
-       }
-       
-       /*
-        * (non-Javadoc)
-        * 
-        * @seeorg.apache.oodt.cas.catalog.repository.CatalogRepository#
-        * isCatalogSerialized(java.lang.String)
-        */
-       public boolean isCatalogSerialized(String catalogUrn)
-                       throws CatalogRepositoryException {
-               return this.catalogMap.containsKey(catalogUrn);
-       }
-       
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * 
org.apache.oodt.cas.catalog.repository.CatalogRepository#serializeCatalog
-        * (org.apache.oodt.cas.catalog.Catalog)
-        */
-       public void serializeCatalog(Catalog catalog)
-                       throws CatalogRepositoryException {
-               this.catalogMap.put(catalog.getId(), catalog);
-       }
-       
-       public void serializePluginURLs(List<PluginURL> urls) 
-                       throws CatalogRepositoryException {
-               this.classLoaderUrls.addAll(urls);
-       }
-
-       public List<PluginURL> deserializePluginURLs() 
-                       throws CatalogRepositoryException {
-               return new Vector<PluginURL>(this.classLoaderUrls);
-       }
-       
-       public boolean isModifiable() 
-                       throws CatalogRepositoryException {
-               return true;
-       }
+
+  protected HashMap<String, Catalog> catalogMap;
+  protected List<PluginURL> classLoaderUrls;
+
+  public MemoryBasedCatalogRepository() {
+    this.catalogMap = new HashMap<String, Catalog>();
+    this.classLoaderUrls = new Vector<PluginURL>();
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.oodt.cas.catalog.repository.CatalogRepository#
+   * deleteSerializedCatalog(java.lang.String)
+   */
+  public void deleteSerializedCatalog(String catalogUrn)
+      throws CatalogRepositoryException {
+    this.catalogMap.remove(catalogUrn);
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.oodt.cas.catalog.repository.CatalogRepository#
+   * deserializeAllCatalogs()
+   */
+  public Set<Catalog> deserializeAllCatalogs()
+      throws CatalogRepositoryException {
+    return new HashSet<Catalog>(this.catalogMap.values());
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * 
org.apache.oodt.cas.catalog.repository.CatalogRepository#deserializeCatalog
+   * (java.lang.String)
+   */
+  public Catalog deserializeCatalog(String catalogUrn)
+      throws CatalogRepositoryException {
+    return this.catalogMap.get(catalogUrn);
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.oodt.cas.catalog.repository.CatalogRepository#
+   * isCatalogSerialized(java.lang.String)
+   */
+  public boolean isCatalogSerialized(String catalogUrn)
+      throws CatalogRepositoryException {
+    return this.catalogMap.containsKey(catalogUrn);
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * org.apache.oodt.cas.catalog.repository.CatalogRepository#serializeCatalog
+   * (org.apache.oodt.cas.catalog.Catalog)
+   */
+  public void serializeCatalog(Catalog catalog)
+      throws CatalogRepositoryException {
+    this.catalogMap.put(catalog.getId(), catalog);
+  }
+
+  public void serializePluginURLs(List<PluginURL> urls)
+      throws CatalogRepositoryException {
+    this.classLoaderUrls.addAll(urls);
+  }
+
+  public List<PluginURL> deserializePluginURLs()
+      throws CatalogRepositoryException {
+    return new Vector<PluginURL>(this.classLoaderUrls);
+  }
+
+  public boolean isModifiable() throws CatalogRepositoryException {
+    return true;
+  }
 
 }

Modified: 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepositoryFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepositoryFactory.java?rev=963451&r1=963450&r2=963451&view=diff
==============================================================================
--- 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepositoryFactory.java
 (original)
+++ 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/MemoryBasedCatalogRepositoryFactory.java
 Mon Jul 12 19:50:01 2010
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
@@ -21,19 +21,16 @@ package org.apache.oodt.cas.catalog.repo
 import org.apache.oodt.cas.catalog.exception.CatalogRepositoryException;
 
 /**
- * @author bfoster
- * @version $Revision$
- *
- * <p>
+ * 
  * A Factory for creating MemoryBasedCatalogRepository
- * <p>
+ * 
  */
 public class MemoryBasedCatalogRepositoryFactory implements
-               CatalogRepositoryFactory {
+    CatalogRepositoryFactory {
 
-       public MemoryBasedCatalogRepository createRepository()
-                       throws CatalogRepositoryException {
-               return new MemoryBasedCatalogRepository();
-       }
+  public MemoryBasedCatalogRepository createRepository()
+      throws CatalogRepositoryException {
+    return new MemoryBasedCatalogRepository();
+  }
 
 }

Modified: 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java?rev=963451&r1=963450&r2=963451&view=diff
==============================================================================
--- 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java
 (original)
+++ 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepository.java
 Mon Jul 12 19:50:01 2010
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
@@ -38,173 +38,207 @@ import java.util.logging.Logger;
 import org.apache.commons.io.FileUtils;
 
 /**
- * @author bfoster
- * @version $Revision$
- *
- * <p>
+ * 
  * Catalog Repository that serializes Catalogs via XStream utility
- * <p>
+ * 
  */
 public class SerializedCatalogRepository implements CatalogRepository {
 
-       private static Logger LOG = 
Logger.getLogger(SerializedCatalogRepository.class.getName());
-       protected String storageDir;
-       
-       public SerializedCatalogRepository(String storageDir) throws 
InstantiationException {
-               try {
-                       this.storageDir = storageDir;
-                       new File(this.storageDir + "/catalogs").mkdirs();
-                       new File(this.storageDir + "/classloaders").mkdirs();
-               }catch(Exception e) {
-                       e.printStackTrace();
-                       throw new InstantiationException("Failed to instantiate 
SerializedCatalogRepository : " + e.getMessage());
-               }
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see 
org.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#deleteSerializedCatalog(java.lang.String)
-        */
-       public void deleteSerializedCatalog(String catalogUrn)
-                       throws CatalogRepositoryException {
-               LOG.log(Level.INFO, "Deleting Catalog: '" + catalogUrn + "' . . 
. ");
-               boolean catalogFileDelete = 
this.getCatalogFile(catalogUrn).delete();
-               if (!catalogFileDelete)
-                       throw new CatalogRepositoryException("Failed to 
deserialize catalog '" + catalogUrn + "', delete files returned false");
-               else 
-                       LOG.log(Level.INFO, "Successfully deleting Catalog: '" 
+ catalogUrn + "'");
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see 
org.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#deserializeCatalog(java.lang.String)
-        */
-       public Catalog deserializeCatalog(String catalogUrn)
-                       throws CatalogRepositoryException {
-               LOG.log(Level.INFO, "Deserializing Catalog: " + catalogUrn);
-               FileInputStream catalogIn = null;
-               try {
-                       return new 
Serializer().deserializeObject(Catalog.class, catalogIn = new 
FileInputStream(this.getCatalogFile(catalogUrn)));
-               }catch (Exception e) {
-                       throw new CatalogRepositoryException("Failed to 
Deserialized Catalogs from '" + this.storageDir + "' : " + e.getMessage(), e);
-               }finally {
-                       try {
-                               catalogIn.close();
-                       }catch (Exception e) {}
-               }
-       }
-       
-       /*
-        * (non-Javadoc)
-        * @see 
org.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#deserializeAllCatalogs()
-        */
-       public Set<Catalog> deserializeAllCatalogs()
-                       throws CatalogRepositoryException {
-               HashSet<Catalog> catalogs = new HashSet<Catalog>();
-               for (String catalogFile : new File(this.storageDir + 
"/catalogs").list()) {
-                       Catalog catalog = 
this.deserializeCatalog(catalogFile.split("\\.ser")[0]);
-                       catalogs.add(catalog);
-               }
-               return catalogs;
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see 
org.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#isCatalogSerialized(java.lang.String)
-        */
-       public boolean isCatalogSerialized(String catalogUrn)
-                       throws CatalogRepositoryException {
-               return this.getCatalogFile(catalogUrn).exists();
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see 
org.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#serializeCatalog(org.apache.oodt.cas.catalog.Catalog)
-        */
-       public void serializeCatalog(Catalog catalog)
-                       throws CatalogRepositoryException {
-               LOG.log(Level.INFO, "Serializing Catalog: " + catalog.getId());
-               FileOutputStream catalogOut = null;
-               try {
-                       //serialize Catalog
-                       new Serializer().serializeObject(catalog, (catalogOut = 
new FileOutputStream(this.getCatalogFileWorker(catalog.getId()))));
-                       if (this.getCatalogFile(catalog.getId()).exists())
-                               
FileUtils.copyFile(this.getCatalogFile(catalog.getId()), 
this.getCatalogFileBkup(catalog.getId()), true);
-                       
FileUtils.copyFile(this.getCatalogFileWorker(catalog.getId()), 
this.getCatalogFile(catalog.getId()), true);
-                       this.getCatalogFileWorker(catalog.getId()).delete();
-                       this.getCatalogFileBkup(catalog.getId()).delete();
-               }catch (Exception e) {
-                       throw new CatalogRepositoryException("Failed to 
Serialized Catalogs to '" + this.storageDir + "' : " + e.getMessage(), e);
-               }finally {
-                       try {
-                               catalogOut.close();
-                       }catch (Exception e) {}
-               }       
-       }
-       
-       public void serializePluginURLs(List<PluginURL> urls) 
-                       throws CatalogRepositoryException {
-               FileOutputStream urlsOut = null;
-               try {
-                       //serialize URLs
-                       new Serializer().serializeObject(urls, (urlsOut = new 
FileOutputStream(this.getClassLoaderUrlsFileWorker())));
-                       if (this.getClassLoaderUrlsFile().exists())
-                               
FileUtils.copyFile(this.getClassLoaderUrlsFile(), 
this.getClassLoaderUrlsFileBkup(), true);
-                       FileUtils.copyFile(this.getClassLoaderUrlsFileWorker(), 
this.getClassLoaderUrlsFile(), true);
-                       this.getClassLoaderUrlsFileWorker().delete();
-                       this.getClassLoaderUrlsFileBkup().delete();
-               }catch (Exception e) {
-                       throw new CatalogRepositoryException("Failed to 
Serialized ClassLoader URLs to '" + this.storageDir + "' : " + e.getMessage(), 
e);
-               }finally {
-                       try {
-                               urlsOut.close();
-                       }catch (Exception e) {}
-               }       
-       }
-
-       public List<PluginURL> deserializePluginURLs() throws 
CatalogRepositoryException {
-               FileInputStream urlsIn = null;
-               try {
-                       if (this.getClassLoaderUrlsFile().exists())
-                               return new 
Serializer().deserializeObject(List.class, (urlsIn = new 
FileInputStream(this.getClassLoaderUrlsFile())));
-                       else
-                               return Collections.emptyList();
-               }catch (Exception e) {
-                       throw new CatalogRepositoryException("Failed to 
Deserialized All ClassLoader URLs from '" + this.storageDir + "' : " + 
e.getMessage(), e);
-               }finally {
-                       try {
-                               urlsIn.close();
-                       }catch (Exception e) {}
-               }
-       }
-
-       public boolean isModifiable() 
-                       throws CatalogRepositoryException {
-               return true;
-       }
-
-       protected File getCatalogFile(String catalogUrn) {
-               return new File(this.storageDir + "/catalogs/" + catalogUrn + 
".ser");
-       }
-
-       protected File getCatalogFileBkup(String catalogUrn) {
-               return new File(this.storageDir + "/catalogs/" + catalogUrn + 
".ser-bkup");
-       }
-       
-       protected File getCatalogFileWorker(String catalogUrn) {
-               return new File(this.storageDir + "/catalogs/" + catalogUrn + 
".ser-worker");
-       }
-       
-       protected File getClassLoaderUrlsFile() {
-               return new File(this.storageDir + "/classloaders/urls.ser");
-       }
-       
-       protected File getClassLoaderUrlsFileBkup() {
-               return new File(this.storageDir + 
"/classloaders/urls.ser-bkup");
-       }
-       
-       protected File getClassLoaderUrlsFileWorker() {
-               return new File(this.storageDir + 
"/classloaders/urls.ser-worker");
-       }
-       
+  private static Logger LOG = Logger
+      .getLogger(SerializedCatalogRepository.class.getName());
+  protected String storageDir;
+
+  public SerializedCatalogRepository(String storageDir)
+      throws InstantiationException {
+    try {
+      this.storageDir = storageDir;
+      new File(this.storageDir + "/catalogs").mkdirs();
+      new File(this.storageDir + "/classloaders").mkdirs();
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new InstantiationException(
+          "Failed to instantiate SerializedCatalogRepository : "
+              + e.getMessage());
+    }
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#
+   * deleteSerializedCatalog(java.lang.String)
+   */
+  public void deleteSerializedCatalog(String catalogUrn)
+      throws CatalogRepositoryException {
+    LOG.log(Level.INFO, "Deleting Catalog: '" + catalogUrn + "' . . . ");
+    boolean catalogFileDelete = this.getCatalogFile(catalogUrn).delete();
+    if (!catalogFileDelete)
+      throw new CatalogRepositoryException("Failed to deserialize catalog '"
+          + catalogUrn + "', delete files returned false");
+    else
+      LOG
+          .log(Level.INFO, "Successfully deleting Catalog: '" + catalogUrn
+              + "'");
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#
+   * deserializeCatalog(java.lang.String)
+   */
+  public Catalog deserializeCatalog(String catalogUrn)
+      throws CatalogRepositoryException {
+    LOG.log(Level.INFO, "Deserializing Catalog: " + catalogUrn);
+    FileInputStream catalogIn = null;
+    try {
+      return new Serializer().deserializeObject(Catalog.class,
+          catalogIn = new FileInputStream(this.getCatalogFile(catalogUrn)));
+    } catch (Exception e) {
+      throw new CatalogRepositoryException(
+          "Failed to Deserialized Catalogs from '" + this.storageDir + "' : "
+              + e.getMessage(), e);
+    } finally {
+      try {
+        catalogIn.close();
+      } catch (Exception e) {
+      }
+    }
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#
+   * deserializeAllCatalogs()
+   */
+  public Set<Catalog> deserializeAllCatalogs()
+      throws CatalogRepositoryException {
+    HashSet<Catalog> catalogs = new HashSet<Catalog>();
+    for (String catalogFile : new File(this.storageDir + "/catalogs").list()) {
+      Catalog catalog = 
this.deserializeCatalog(catalogFile.split("\\.ser")[0]);
+      catalogs.add(catalog);
+    }
+    return catalogs;
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#
+   * isCatalogSerialized(java.lang.String)
+   */
+  public boolean isCatalogSerialized(String catalogUrn)
+      throws CatalogRepositoryException {
+    return this.getCatalogFile(catalogUrn).exists();
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @seeorg.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepository#
+   * serializeCatalog(org.apache.oodt.cas.catalog.Catalog)
+   */
+  public void serializeCatalog(Catalog catalog)
+      throws CatalogRepositoryException {
+    LOG.log(Level.INFO, "Serializing Catalog: " + catalog.getId());
+    FileOutputStream catalogOut = null;
+    try {
+      // serialize Catalog
+      new Serializer().serializeObject(catalog,
+          (catalogOut = new FileOutputStream(this.getCatalogFileWorker(catalog
+              .getId()))));
+      if (this.getCatalogFile(catalog.getId()).exists())
+        FileUtils.copyFile(this.getCatalogFile(catalog.getId()), this
+            .getCatalogFileBkup(catalog.getId()), true);
+      FileUtils.copyFile(this.getCatalogFileWorker(catalog.getId()), this
+          .getCatalogFile(catalog.getId()), true);
+      this.getCatalogFileWorker(catalog.getId()).delete();
+      this.getCatalogFileBkup(catalog.getId()).delete();
+    } catch (Exception e) {
+      throw new CatalogRepositoryException("Failed to Serialized Catalogs to '"
+          + this.storageDir + "' : " + e.getMessage(), e);
+    } finally {
+      try {
+        catalogOut.close();
+      } catch (Exception e) {
+      }
+    }
+  }
+
+  public void serializePluginURLs(List<PluginURL> urls)
+      throws CatalogRepositoryException {
+    FileOutputStream urlsOut = null;
+    try {
+      // serialize URLs
+      new Serializer().serializeObject(urls, (urlsOut = new FileOutputStream(
+          this.getClassLoaderUrlsFileWorker())));
+      if (this.getClassLoaderUrlsFile().exists())
+        FileUtils.copyFile(this.getClassLoaderUrlsFile(), this
+            .getClassLoaderUrlsFileBkup(), true);
+      FileUtils.copyFile(this.getClassLoaderUrlsFileWorker(), this
+          .getClassLoaderUrlsFile(), true);
+      this.getClassLoaderUrlsFileWorker().delete();
+      this.getClassLoaderUrlsFileBkup().delete();
+    } catch (Exception e) {
+      throw new CatalogRepositoryException(
+          "Failed to Serialized ClassLoader URLs to '" + this.storageDir
+              + "' : " + e.getMessage(), e);
+    } finally {
+      try {
+        urlsOut.close();
+      } catch (Exception e) {
+      }
+    }
+  }
+
+  public List<PluginURL> deserializePluginURLs()
+      throws CatalogRepositoryException {
+    FileInputStream urlsIn = null;
+    try {
+      if (this.getClassLoaderUrlsFile().exists())
+        return new Serializer().deserializeObject(List.class,
+            (urlsIn = new FileInputStream(this.getClassLoaderUrlsFile())));
+      else
+        return Collections.emptyList();
+    } catch (Exception e) {
+      throw new CatalogRepositoryException(
+          "Failed to Deserialized All ClassLoader URLs from '"
+              + this.storageDir + "' : " + e.getMessage(), e);
+    } finally {
+      try {
+        urlsIn.close();
+      } catch (Exception e) {
+      }
+    }
+  }
+
+  public boolean isModifiable() throws CatalogRepositoryException {
+    return true;
+  }
+
+  protected File getCatalogFile(String catalogUrn) {
+    return new File(this.storageDir + "/catalogs/" + catalogUrn + ".ser");
+  }
+
+  protected File getCatalogFileBkup(String catalogUrn) {
+    return new File(this.storageDir + "/catalogs/" + catalogUrn + ".ser-bkup");
+  }
+
+  protected File getCatalogFileWorker(String catalogUrn) {
+    return new File(this.storageDir + "/catalogs/" + catalogUrn + 
".ser-worker");
+  }
+
+  protected File getClassLoaderUrlsFile() {
+    return new File(this.storageDir + "/classloaders/urls.ser");
+  }
+
+  protected File getClassLoaderUrlsFileBkup() {
+    return new File(this.storageDir + "/classloaders/urls.ser-bkup");
+  }
+
+  protected File getClassLoaderUrlsFileWorker() {
+    return new File(this.storageDir + "/classloaders/urls.ser-worker");
+  }
+
 }

Modified: 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepositoryFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepositoryFactory.java?rev=963451&r1=963450&r2=963451&view=diff
==============================================================================
--- 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepositoryFactory.java
 (original)
+++ 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SerializedCatalogRepositoryFactory.java
 Mon Jul 12 19:50:01 2010
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
@@ -25,31 +25,33 @@ import org.apache.oodt.cas.catalog.excep
 import org.apache.oodt.cas.metadata.util.PathUtils;
 
 /**
- * @author bfoster
- * @version $Revision$
- *
- * <p>
+ * 
  * A Factory for creating SerializedMemoryBasedCatalogRepository
- * <p>
+ * 
  */
-public class SerializedCatalogRepositoryFactory implements 
CatalogRepositoryFactory {
+public class SerializedCatalogRepositoryFactory implements
+    CatalogRepositoryFactory {
+
+  protected String storageDir;
 
-       protected String storageDir;
+  public SerializedCatalogRepositoryFactory() {
+  }
 
-       public SerializedCatalogRepositoryFactory() {}
-       
-       @Required
-       public void setStorageDir(String storageDir) {
-               this.storageDir = storageDir;
-       }
-
-       public SerializedCatalogRepository createRepository()
-                       throws CatalogRepositoryException {
-               try {
-                       return new 
SerializedCatalogRepository(PathUtils.doDynamicReplacement(this.storageDir));
-               }catch (Exception e) {
-                       throw new CatalogRepositoryException("Failed to create 
Serialized Catalog Repository : " + e.getMessage(), e);
-               }
-       }
+  @Required
+  public void setStorageDir(String storageDir) {
+    this.storageDir = storageDir;
+  }
+
+  public SerializedCatalogRepository createRepository()
+      throws CatalogRepositoryException {
+    try {
+      return new SerializedCatalogRepository(PathUtils
+          .doDynamicReplacement(this.storageDir));
+    } catch (Exception e) {
+      throw new CatalogRepositoryException(
+          "Failed to create Serialized Catalog Repository : " + e.getMessage(),
+          e);
+    }
+  }
 
 }

Modified: 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepository.java
URL: 
http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepository.java?rev=963451&r1=963450&r2=963451&view=diff
==============================================================================
--- 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepository.java
 (original)
+++ 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepository.java
 Mon Jul 12 19:50:01 2010
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
@@ -33,56 +33,58 @@ import java.util.Set;
 import org.springframework.context.support.FileSystemXmlApplicationContext;
 
 /**
- * @author bfoster
- * @version $Revision$
- *
- * <p>
+ * 
  * A Spring Framework based CatalogRepository
- * <p>
+ * 
  */
 public class SpringCatalogRepository implements CatalogRepository {
 
-       protected String beanRepo;
-       
-       public SpringCatalogRepository(String beanRepo) {
-               this.beanRepo = beanRepo;
-       }
-       
-       public Set<Catalog> deserializeAllCatalogs()
-                       throws CatalogRepositoryException {
-               try {
-               FileSystemXmlApplicationContext appContext = new 
FileSystemXmlApplicationContext(new String[] { this.beanRepo }, false);
-               appContext.setClassLoader(new Serializer().getClassLoader());
-               appContext.refresh();
-               return new 
HashSet<Catalog>(appContext.getBeansOfType(Catalog.class).values());
-               } catch (Exception e) {
-                       throw new CatalogRepositoryException("", e);
-               }
-       }
-
-       public void deleteSerializedCatalog(String catalogUrn)
-                       throws CatalogRepositoryException {
-               throw new CatalogRepositoryException("Modification not allowed 
during runtime");
-       }
-
-       public boolean isModifiable() throws CatalogRepositoryException {
-               return false;
-       }
-
-       public void serializeCatalog(Catalog catalog)
-                       throws CatalogRepositoryException {
-               throw new CatalogRepositoryException("Modification not allowed 
during runtime");                
-       }
-
-       public List<PluginURL> deserializePluginURLs()
-                       throws CatalogRepositoryException {
-               // TODO Auto-generated method stub
-               return Collections.emptyList();
-       }
-
-       public void serializePluginURLs(List<PluginURL> urls)
-                       throws CatalogRepositoryException {
-               throw new CatalogRepositoryException("Modification not allowed 
during runtime");                
-       }
-       
+  protected String beanRepo;
+
+  public SpringCatalogRepository(String beanRepo) {
+    this.beanRepo = beanRepo;
+  }
+
+  public Set<Catalog> deserializeAllCatalogs()
+      throws CatalogRepositoryException {
+    try {
+      FileSystemXmlApplicationContext appContext = new 
FileSystemXmlApplicationContext(
+          new String[] { this.beanRepo }, false);
+      appContext.setClassLoader(new Serializer().getClassLoader());
+      appContext.refresh();
+      return new HashSet<Catalog>(appContext.getBeansOfType(Catalog.class)
+          .values());
+    } catch (Exception e) {
+      throw new CatalogRepositoryException("", e);
+    }
+  }
+
+  public void deleteSerializedCatalog(String catalogUrn)
+      throws CatalogRepositoryException {
+    throw new CatalogRepositoryException(
+        "Modification not allowed during runtime");
+  }
+
+  public boolean isModifiable() throws CatalogRepositoryException {
+    return false;
+  }
+
+  public void serializeCatalog(Catalog catalog)
+      throws CatalogRepositoryException {
+    throw new CatalogRepositoryException(
+        "Modification not allowed during runtime");
+  }
+
+  public List<PluginURL> deserializePluginURLs()
+      throws CatalogRepositoryException {
+    // TODO Auto-generated method stub
+    return Collections.emptyList();
+  }
+
+  public void serializePluginURLs(List<PluginURL> urls)
+      throws CatalogRepositoryException {
+    throw new CatalogRepositoryException(
+        "Modification not allowed during runtime");
+  }
+
 }

Modified: 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepositoryFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepositoryFactory.java?rev=963451&r1=963450&r2=963451&view=diff
==============================================================================
--- 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepositoryFactory.java
 (original)
+++ 
incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/repository/SpringCatalogRepositoryFactory.java
 Mon Jul 12 19:50:01 2010
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
@@ -21,12 +21,9 @@ package org.apache.oodt.cas.catalog.repo
 import org.apache.oodt.cas.catalog.exception.CatalogRepositoryException;
 
 /**
- * @author bfoster
- * @version $Revision$
- *
- * <p>
+ * 
  * A factory for creating SpringCatalogRepository
- * <p>
+ * 
  */
 public class SpringCatalogRepositoryFactory implements 
CatalogRepositoryFactory {
 


Reply via email to