You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by bf...@apache.org on 2010/12/23 03:48:11 UTC

svn commit: r1052148 [15/17] - in /oodt/branches/wengine-branch/filemgr: ./ .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/nasa/jpl/oodt...

Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DateTimeVersioner.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DateTimeVersioner.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DateTimeVersioner.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DateTimeVersioner.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,209 @@
+/*
+ * 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.filemgr.versioning;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.commons.util.DateConvert;
+
+//JDK imports
+import java.text.SimpleDateFormat;
+import java.text.ParseException;
+import java.util.Iterator;
+import java.util.Date;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.MalformedURLException;
+import java.net.URLEncoder;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ * 
+ * <p>
+ * A simple versioning scheme that versions {@link Product}s with their
+ * production date time.
+ * </p>
+ * 
+ */
+public class DateTimeVersioner implements Versioner {
+
+    /* our log stream */
+    private static Logger LOG = Logger.getLogger(DateTimeVersioner.class.getName());
+
+    /**
+     * <p>
+     * Default Constructor
+     * </p>
+     */
+    public DateTimeVersioner() {
+        super();
+        // TODO Auto-generated constructor stub
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see gov.nasa.jpl.oodt.cas.versioning.Versioner#createDataStoreReferences(gov.nasa.jpl.
+     *      oodt.cas.data.structs.Product)
+     */
+    public void createDataStoreReferences(Product product, Metadata metadata)
+            throws VersioningException {
+        // first, we need to know if its heirarchical, or flat
+        if (product.getProductStructure() == null) {
+            LOG
+                    .log(Level.WARNING,
+                            "DateTimeVersioner: Product Structure must be defined in order to version!");
+            return;
+        }
+
+        SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyddMM.HHmmss");
+        String productionDateTime = metadata
+                .getMetadata("CAS.ProductReceivedTime");
+        if (productionDateTime == null) { // generate it ourselves then
+            productionDateTime = dateFormatter.format(new Date());
+        } else {
+            Date prodDateTime = null;
+            try {
+                prodDateTime = DateConvert.isoParse(productionDateTime);
+            } catch (ParseException e) {
+                LOG.log(Level.WARNING,
+                        "Unable to parse production date time CAS.ProductReceivedTime: "
+                                + productionDateTime
+                                + ": generating it ourselves");
+                prodDateTime = new Date();
+            }
+            productionDateTime = dateFormatter.format(prodDateTime);
+        }
+
+        if (product.getProductStructure().equals(Product.STRUCTURE_FLAT)) {
+            // if its flat, just return references that include
+            // productTypeRepo/productName/fileName.productionDateTime
+            // we'll use the format: yyyy.dd.MM.HH.mm.ss
+
+            for (Iterator<Reference> i = product.getProductReferences().iterator(); i
+                    .hasNext();) {
+                Reference r = i.next();
+                String dataStoreRef = null;
+
+                try {
+                    dataStoreRef = new File(new URI(product.getProductType()
+                            .getProductRepositoryPath())).toURL()
+                            .toExternalForm()
+                            + "/"
+                            + product.getProductName()
+                            + "/"
+                            + new File(new URI(r.getOrigReference())).getName()
+                            + "." + productionDateTime;
+                    LOG.log(Level.FINER,
+                            "DateTimeVersioner: Generated dataStoreRef: "
+                                    + dataStoreRef + " from original ref: "
+                                    + r.getOrigReference());
+                    r.setDataStoreReference(dataStoreRef);
+                } catch (URISyntaxException e) {
+                    LOG
+                            .log(
+                                    Level.WARNING,
+                                    "DateTimeVersioner: Error generating URI to get name "
+                                            + "of original ref while generating data store ref for orig ref: "
+                                            + r.getOrigReference()
+                                            + ": Message: " + e.getMessage());
+                    // try and keep generating
+                } catch (MalformedURLException e) {
+                    LOG.log(Level.WARNING,
+                            "DateTimeVersioner: Error getting URL for product repository path "
+                                    + product.getProductType()
+                                            .getProductRepositoryPath()
+                                    + ": Message: " + e.getMessage());
+                    // try and keep generating
+                }
+
+            }
+        } else if (product.getProductStructure().equals(
+                Product.STRUCTURE_HIERARCHICAL)) {
+            // if its heirarchical, then we'll version the files within the
+            // directory
+            // first, we need to get a list of all the references from the
+            // original dir
+            Reference origDirRef = (Reference) product.getProductReferences()
+                    .get(0);
+
+            try {
+                String dataStoreRef = new File(new URI(product.getProductType()
+                        .getProductRepositoryPath())).toURL().toExternalForm()
+                        + URLEncoder.encode(product.getProductName(), "UTF-8")
+                        + "/";
+                LOG.log(Level.INFO,
+                        "DateTimeVersioner: generated DataStore ref: "
+                                + dataStoreRef + " from origDirRef: "
+                                + origDirRef.getOrigReference());
+                origDirRef.setDataStoreReference(dataStoreRef);
+            } catch (MalformedURLException e) {
+                LOG.log(Level.WARNING,
+                        "DateTimeVersioner: MalformedURLException while generating "
+                                + "initial data store ref for origRef: "
+                                + origDirRef.getOrigReference());
+                throw new VersioningException(e);
+            } catch (URISyntaxException e) {
+                LOG.log(Level.WARNING,
+                        "DateTimeVersioner: Error creating File reference from original dir URI: "
+                                + origDirRef.getOrigReference() + ": Message: "
+                                + e.getMessage());
+                throw new VersioningException(
+                        "Unable to generate references from original dir reference for product: "
+                                + product.getProductName() + ": Message: "
+                                + e.getMessage());
+            } catch (UnsupportedEncodingException e) {
+                LOG.log(Level.WARNING,
+                        "DateTimeVersioner: UnsupportedEncodingException while generating "
+                                + "initial data store ref for origRef: "
+                                + origDirRef.getOrigReference());
+                throw new VersioningException(e);
+            }
+
+            // create the basic data store refs
+            VersioningUtils.createBasicDataStoreRefsHierarchical(product
+                    .getProductReferences());
+
+            // add the production date time
+            addProductDateTimeToReferences(product.getProductReferences(),
+                    productionDateTime);
+
+        }
+    }
+
+    private void addProductDateTimeToReferences(List<Reference> references,
+            String productionDateTime) {
+        for (Iterator<Reference> i = references.iterator(); i.hasNext();) {
+            Reference r = i.next();
+            if (!r.getOrigReference().endsWith("/")) {
+                r.setDataStoreReference(r.getDataStoreReference() + "."
+                        + productionDateTime);
+            }
+        }
+    }
+
+}

Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/MetadataBasedFileVersioner.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/MetadataBasedFileVersioner.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/MetadataBasedFileVersioner.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/MetadataBasedFileVersioner.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,156 @@
+/*
+ * 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.filemgr.versioning;
+
+//JDK imports
+import java.io.File;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException;
+import org.apache.oodt.cas.metadata.util.PathUtils;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ * 
+ * <p>
+ * A Versioner class that uses {@link Metadata} fields and a given
+ * <code>filePathSpec</code> to version references. The filePathSpec should be
+ * of the form:<br>
+ * <br>
+ * 
+ * <code>/[FieldName1]/other/text/.../[FieldName2]...</code>
+ * 
+ * where <code>FieldName1</code> and <code>FieldName2</code> are Metadata
+ * fields provided by the given Metadata object.
+ * </p>.
+ */
+public class MetadataBasedFileVersioner implements Versioner {
+
+    /* file path spec denoted by metadata fields and static path */
+    private String filePathSpec = null;
+
+    /* our log stream */
+    private static Logger LOG = Logger
+            .getLogger(MetadataBasedFileVersioner.class.getName());
+
+    /* whether or not we only handle flat products */
+    private boolean flatProducts = true;
+
+    public MetadataBasedFileVersioner() {
+        filePathSpec = "/[Filename]";
+    }
+
+    public MetadataBasedFileVersioner(String filePathSpec) {
+        this.filePathSpec = filePathSpec;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see gov.nasa.jpl.oodt.cas.filemgr.versioning.Versioner#createDataStoreReferences(gov.nasa.
+     *      jpl.oodt.cas.filemgr.structs.Product,
+     *      gov.nasa.jpl.oodt.cas.metadata.Metadata)
+     */
+    public void createDataStoreReferences(Product product, Metadata metadata)
+            throws VersioningException {
+
+        // since we need the metadata, if the metadata is null, throw an
+        // exception
+        if (metadata == null) {
+            throw new VersioningException(
+                    "Unable to version product with no metadata!");
+        }
+
+        // we also only deal with Flat products, that is, Products with a single
+        // reference
+        if (flatProducts
+                && !product.getProductStructure()
+                        .equals(Product.STRUCTURE_FLAT)) {
+            throw new VersioningException(
+                    "Can only handle FLAT product structures");
+        }
+
+        // get the product type repo path
+        String productTypeRepoPath = VersioningUtils
+                .getAbsolutePathFromUri(product.getProductType()
+                        .getProductRepositoryPath());
+
+        // parse the file path spec
+        String filePathRef = parseFilePathSpec(filePathSpec,
+                productTypeRepoPath, metadata);
+        String filePathUri = new File(filePathRef).toURI().toString();
+
+        Reference r = (Reference) product.getProductReferences().get(0);
+        LOG.log(Level.INFO, "Generated data store ref: [" + filePathUri
+                + "] from origRef: [" + r.getOrigReference() + "]");
+        r.setDataStoreReference(filePathUri);
+    }
+
+    private String parseFilePathSpec(String filePathSpec,
+            String productTypeRepoPath, Metadata metadata) {
+        StringBuffer finalFilePath = new StringBuffer();
+        finalFilePath.append(productTypeRepoPath);
+
+        if (finalFilePath.charAt(finalFilePath.length() - 1) == '/') {
+            finalFilePath.deleteCharAt(finalFilePath.length() - 1);
+        }
+
+        if (!filePathSpec.startsWith("/")) {
+            filePathSpec = "/" + filePathSpec;
+        }
+
+        finalFilePath.append(PathUtils.replaceEnvVariables(filePathSpec,
+                metadata));
+        return finalFilePath.toString();
+    }
+
+    /**
+     * @return the filePathSpec
+     */
+    public String getFilePathSpec() {
+        return filePathSpec;
+    }
+
+    /**
+     * @param filePathSpec
+     *            the filePathSpec to set
+     */
+    public void setFilePathSpec(String filePathSpec) {
+        this.filePathSpec = filePathSpec;
+    }
+
+    /**
+     * @return the flatProducts
+     */
+    public boolean isFlatProducts() {
+        return flatProducts;
+    }
+
+    /**
+     * @param flatProducts
+     *            the flatProducts to set
+     */
+    public void setFlatProducts(boolean flatProducts) {
+        this.flatProducts = flatProducts;
+    }
+}

Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/SingleFileBasicVersioner.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/SingleFileBasicVersioner.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/SingleFileBasicVersioner.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/SingleFileBasicVersioner.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,109 @@
+/*
+ * 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.filemgr.versioning;
+
+//JDK imports
+import java.io.File;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ * 
+ * <p>
+ * A {@link Versioner} that handles single file {@link Product}s by storing
+ * them in <code>productTypeRepoPath/Filename</code>.
+ * </p>
+ * 
+ */
+public class SingleFileBasicVersioner implements Versioner {
+
+    /* filename fields */
+    public static final String FILENAME_FIELD = "Filename";
+
+    /* our log stream */
+    private static Logger LOG = Logger.getLogger(SingleFileBasicVersioner.class
+            .getName());
+
+    /**
+     * 
+     */
+    public SingleFileBasicVersioner() {
+        super();
+        // TODO Auto-generated constructor stub
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see gov.nasa.jpl.oodt.cas.filemgr.versioning.Versioner#createDataStoreReferences(gov.nasa.
+     *      jpl.oodt.cas.filemgr.structs.Product,
+     *      gov.nasa.jpl.oodt.cas.metadata.Metadata)
+     */
+    public void createDataStoreReferences(Product product, Metadata metadata)
+            throws VersioningException {
+        // we only handle single files, so throw exception if product is
+        // heirarhical
+
+        if (!product.getProductStructure().equals(Product.STRUCTURE_FLAT)) {
+            throw new VersioningException(
+                    "SingleFileVersioner: unable to version" + " Product: ["
+                            + product.getProductName()
+                            + "] with heirarchical structure");
+        }
+
+        // we need the Filename Metadata parameter for this to work
+        String filename = metadata.getMetadata(FILENAME_FIELD);
+
+        if (filename == null || (filename != null && filename.equals(""))) {
+            throw new VersioningException(
+                    "SingleFileVersioner: unable to version without "
+                            + "Filename metadata field specified!");
+        }
+
+        // now we need the product type repo path
+        String productTypeRepoPathUri = product.getProductType()
+                .getProductRepositoryPath();
+        String productTypeRepoPath = VersioningUtils
+                .getAbsolutePathFromUri(productTypeRepoPathUri);
+
+        if (!productTypeRepoPath.endsWith("/")) {
+            productTypeRepoPath += "/";
+        }
+
+        // final file location is:
+        // /productTypeRepoPath/Filename
+
+        String dataStorePath = productTypeRepoPath + filename;
+        String dataStoreRef = new File(dataStorePath).toURI().toString();
+
+        // get the first reference back
+        // set its data store ref
+        Reference ref = (Reference) product.getProductReferences().get(0);
+        LOG.log(Level.INFO, "Generated data store ref: [" + dataStoreRef
+                + "] from origRef: [" + ref.getOrigReference() + "]");
+        ref.setDataStoreReference(dataStoreRef);
+
+    }
+}

Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/Versioner.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/Versioner.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/Versioner.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/Versioner.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,41 @@
+/*
+ * 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.filemgr.versioning;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ * 
+ * <p>
+ * This interface defines a versioning scheme for generating the DataStore
+ * references for the items in a {@link Product}.
+ * </p>
+ * 
+ */
+public interface Versioner {
+
+    public static final String X_POINT_ID = Versioner.class.getName();
+
+    public void createDataStoreReferences(Product product, Metadata metadata)
+            throws VersioningException;
+
+}

Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/VersioningUtils.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/VersioningUtils.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/VersioningUtils.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/VersioningUtils.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,286 @@
+/*
+ * 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.filemgr.versioning;
+
+//JDK imports
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLEncoder;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ * 
+ * <p>
+ * A Utility component to help out with versioning.
+ * </p>
+ * 
+ * 
+ */
+public final class VersioningUtils {
+
+    /* our log stream */
+    private static Logger LOG = Logger.getLogger(VersioningUtils.class
+            .getName());
+
+    // filter to only find directories when doing a listFiles
+    private static FileFilter DIR_FILTER = new FileFilter() {
+        public boolean accept(File file) {
+            return file.isDirectory();
+        }
+    };
+
+    // filter to only find files when doing a listFiles
+    private static FileFilter FILE_FILTER = new FileFilter() {
+        public boolean accept(File file) {
+            return file.isFile();
+        }
+    };
+
+    public static List<Reference> getReferencesFromDir(File dirRoot) {
+        List<Reference> references = null;
+
+        if (dirRoot == null)
+            throw new IllegalArgumentException("null");
+        if (!dirRoot.isDirectory())
+            dirRoot = dirRoot.getParentFile();
+
+        references = new Vector<Reference>();
+
+        Stack<File> stack = new Stack<File>();
+        stack.push(dirRoot);
+        while (!stack.isEmpty()) {
+            File dir = stack.pop();
+            // add the reference for the dir
+            // except if it's the rootDir, then, skip it
+            if (!dir.equals(dirRoot)) {
+                try {
+                    Reference r = new Reference();
+                    r.setOrigReference(dir.toURL().toExternalForm());
+                    r.setFileSize(dir.length());
+                    references.add(r);
+                } catch (MalformedURLException e) {
+                    e.printStackTrace();
+                    LOG.log(Level.WARNING,
+                            "MalformedURLException when generating reference for dir: "
+                                    + dir);
+                }
+            }
+
+            File[] files = dir.listFiles(FILE_FILTER);
+
+            for (int i = 0; i < files.length; i++) {
+                // add the file references
+                try {
+                    Reference r = new Reference();
+                    r.setOrigReference(files[i].toURL().toExternalForm());
+                    r.setFileSize(files[i].length());
+                    references.add(r);
+                } catch (MalformedURLException e) {
+                    e.printStackTrace();
+                    LOG.log(Level.WARNING,
+                            "MalformedURLException when generating reference for file: "
+                                    + files[i]);
+                }
+
+            }
+            File[] subdirs = dir.listFiles(DIR_FILTER);
+            if (subdirs != null)
+                for (int i = 0; i < subdirs.length; i++) {
+                    stack.push(subdirs[i]);
+                }
+        }
+
+        return references;
+    }
+
+    public static List<String> getURIsFromDir(File dirRoot) {
+        List<String> uris = null;
+
+        if (dirRoot == null)
+            throw new IllegalArgumentException("null");
+        if (!dirRoot.isDirectory())
+            dirRoot = dirRoot.getParentFile();
+
+        uris = new Vector<String>();
+
+        Stack<File> stack = new Stack<File>();
+        stack.push(dirRoot);
+        while (!stack.isEmpty()) {
+            File dir = stack.pop();
+            // add the reference for the dir
+            // except if it's the rootDir, then, skip it
+            if (!dir.equals(dirRoot)) {
+                uris.add(dir.toURI().toString());
+            }
+
+            File[] files = dir.listFiles(FILE_FILTER);
+
+            for (int i = 0; i < files.length; i++) {
+                // add the file references
+                uris.add(files[i].toURI().toString());
+            }
+
+            File[] subdirs = dir.listFiles(DIR_FILTER);
+            if (subdirs != null)
+                for (int i = 0; i < subdirs.length; i++) {
+                    stack.push(subdirs[i]);
+                }
+        }
+
+        return uris;
+    }
+
+    public static void createBasicDataStoreRefsHierarchical(List<Reference> references) {
+        // file:///www/folder1
+        // file:///www/folder1/file1
+        // file:///www/folder1/file2
+        // file:///www/folder1/folder2/
+        // file:///www/folder1/folder2/file3
+
+        // toDir: file:///www/myfolder/product1
+        // origDir: file:///www/folder1
+
+        String toDirRef = references.get(0)
+                .getDataStoreReference();
+        String origDirRef = references.get(0).getOrigReference();
+        String origDirRefName = new File(origDirRef).getName();
+
+        for (Iterator<Reference> i = references.iterator(); i.hasNext();) {
+            Reference r = i.next();
+
+            // don't bother with the first one, because it's already set
+            // correctly
+            if (r.getOrigReference().equals(origDirRef)) {
+                continue;
+            }
+
+            // get the first occurence of the origDir name in the string
+            // then, the ref becomes:
+            // toDir+r.getOrigRef.substring(first occurence of
+            // origDir).substring(first occurence of '/'+1)
+
+            String dataStoreRef = toDirRef;
+            int firstOccurenceOfOrigDir = r.getOrigReference().indexOf(
+                    origDirRefName);
+            String tmpRef = r.getOrigReference().substring(
+                    firstOccurenceOfOrigDir);
+            LOG.log(Level.FINER, "tmpRef: " + tmpRef);
+            int firstOccurenceSlash = tmpRef.indexOf("/");
+            dataStoreRef += tmpRef.substring(firstOccurenceSlash + 1);
+
+            LOG.log(Level.FINE, "VersioningUtils: Generated data store ref: "
+                    + dataStoreRef + " from origRef: " + r.getOrigReference());
+            r.setDataStoreReference(dataStoreRef);
+        }
+
+    }
+
+    public static void createBasicDataStoreRefsFlat(String productName,
+            String productRepoPath, List<Reference> references) {
+        for (Iterator<Reference> i = references.iterator(); i.hasNext();) {
+            Reference r = i.next();
+
+            String dataStoreRef = null;
+            String productRepoPathRef = null;
+
+            try {
+                productRepoPathRef = new File(new URI(productRepoPath)).toURL()
+                        .toExternalForm();
+
+                if (!productRepoPathRef.endsWith("/")) {
+                    productRepoPathRef += "/";
+                }
+
+                dataStoreRef = productRepoPathRef
+                        + URLEncoder.encode(productName, "UTF-8") + "/"
+                        + new File(new URI(r.getOrigReference())).getName();
+            } catch (IOException e) {
+                LOG.log(Level.WARNING,
+                        "VersioningUtils: Error generating dataStoreRef for "
+                                + r.getOrigReference() + ": Message: "
+                                + e.getMessage());
+            } catch (URISyntaxException e) {
+                LOG.log(Level.WARNING,
+                        "VersioningUtils: Error generating dataStoreRef for "
+                                + r.getOrigReference() + ": Message: "
+                                + e.getMessage());
+            }
+
+            LOG.log(Level.FINE, "VersioningUtils: Generated data store ref: "
+                    + dataStoreRef + " from origRef: " + r.getOrigReference());
+            r.setDataStoreReference(dataStoreRef);
+        }
+
+    }
+
+    public static void addRefsFromUris(Product p, List<String> uris) {
+        // add the refs to the Product
+        for (Iterator<String> i = uris.iterator(); i.hasNext();) {
+            String ref = i.next();
+            Reference r = new Reference(ref, null, quietGetFileSizeFromUri(ref));
+            p.getProductReferences().add(r);
+        }
+    }
+
+    public static String getAbsolutePathFromUri(String uriStr) {
+        URI uri = null;
+        String absPath = null;
+
+        try {
+            uri = new URI(uriStr);
+            absPath = new File(uri).getAbsolutePath();
+        } catch (URISyntaxException e) {
+            LOG.log(Level.WARNING,
+                    "URISyntaxException getting URI from URI str: [" + uriStr
+                            + "]");
+        }
+
+        return absPath;
+    }
+
+    private static long quietGetFileSizeFromUri(String uri) {
+        File fileRef = null;
+
+        try {
+            fileRef = new File(new URI(uri));
+        } catch (URISyntaxException e) {
+            LOG.log(Level.WARNING,
+                    "URISyntaxException when getting file size from uri: ["
+                            + uri + "]: Message: " + e.getMessage());
+            return -1L;
+        }
+
+        return fileRef.length();
+    }
+
+}

Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/examples/UpdateMetadataVersioner.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/examples/UpdateMetadataVersioner.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/examples/UpdateMetadataVersioner.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/examples/UpdateMetadataVersioner.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,38 @@
+/*
+ * 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.filemgr.versioning.examples;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException;
+import org.apache.oodt.cas.filemgr.versioning.MetadataBasedFileVersioner;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ * 
+ */
+public class UpdateMetadataVersioner extends MetadataBasedFileVersioner {
+
+    public void createDataStoreReferences(Product product, Metadata metadata)
+            throws VersioningException {
+        metadata.addMetadata("TestElement", "TestValue");
+        super.createDataStoreReferences(product, metadata);
+    }
+    
+}

Added: oodt/branches/wengine-branch/filemgr/src/main/php/Metadata.class.php
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/php/Metadata.class.php?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/php/Metadata.class.php (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/php/Metadata.class.php Thu Dec 23 02:48:02 2010
@@ -0,0 +1,72 @@
+<?php
+//Copyright (c) 2008, California Institute of Technology.
+//ALL RIGHTS RESERVED. U.S. Government sponsorship acknowledged.
+//
+//$Id$
+
+require_once ("XML/RPC.php");
+
+/**
+ * @author mattmann
+ * 
+ * A PHP representation of the CAS metadata data structure, which
+ * is a structure of key=>List of String values.
+ */
+class CAS_Filemgr_Metadata {
+
+	public $elemMap;
+
+	function __construct($xmlRpcData = array ()) {
+		$this->elemMap = $xmlRpcData;
+	}
+
+	function __destruct() {
+
+	}
+
+	function toXmlRpcStruct() {
+		$xmlRpcStruct = array ();
+		foreach ($this->elemMap as $key => $val) {
+			$valList = array ();
+			foreach ($val as $v) {
+				array_push($valList, new XML_RPC_VALUE($v, 'string'));
+			}
+			$xmlRpcStruct[$key] = new XML_RPC_VALUE($valList, 'array');
+		}
+
+		return new XML_RPC_VALUE($xmlRpcStruct, 'struct');
+	}
+
+	function toAssocArray() {
+		return $this->elemMap;
+	}
+
+	function addMetadata($key, $value) {
+		array_push($this->elemMap[$key], $value);
+	}
+
+	function replaceMetadata($key, $value) {
+		$this->elemMap[$key] = $value;
+	}
+
+	function removeMetadata($key) {
+		unset ($this->elemMap[$key]);
+	}
+
+	function getAllMetadata($key) {
+		return $this->elemMap[$key];
+	}
+
+	function getMetadata($key) {
+		return $this->elemMap[$key][0];
+	}
+
+	function containsKey($key) {
+		return array_key_exists($key, $this->elemMap);
+	}
+
+	function isMultiValued($key) {
+		return array_count_values($this->elemMap[$key]) > 1;
+	}
+}
+?>
\ No newline at end of file

Added: oodt/branches/wengine-branch/filemgr/src/main/php/Product.class.php
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/php/Product.class.php?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/php/Product.class.php (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/php/Product.class.php Thu Dec 23 02:48:02 2010
@@ -0,0 +1,89 @@
+<?php
+//Copyright (c) 2008, California Institute of Technology.
+//ALL RIGHTS RESERVED. U.S. Government sponsorship acknowledged.
+//
+//$Id$
+
+require_once("XML/RPC.php");
+
+/**
+ * @author ahart
+ * <p>The core file manager data structure, ported
+ * to PHP.
+ * </p>
+ */
+class CAS_Filemgr_Product {
+	
+	 public $id;
+	 public $name;
+	 public $type;
+	 public $structure;
+	 public $transferStatus;
+	 public $references;
+	
+
+	function __construct($xmlRpcData = array()) {
+		$this->id = (isset($xmlRpcData['id']))
+			? $xmlRpcData['id'] 
+			: '';
+		$this->name = (isset($xmlRpcData['name']))
+			? $xmlRpcData['name'] 
+			: '';
+		$this->type = (isset($xmlRpcData['type']))
+			? new ProductType($xmlRpcData['type']) 
+			: new ProductType();
+		$this->structure = (isset($xmlRpcData['structure']))
+			? $xmlRpcData['structure'] 
+			: '';
+		$this->transferStatus = (isset($xmlRpcData['transferStatus']))
+			? $xmlRpcData['transferStatus'] 
+			: '';
+		$this->references = (isset($xmlRpcData['references']))
+			? $xmlRpcData['references'] 
+			: array();
+	}
+	
+	function __destruct() {
+		
+	}
+	
+	function toAssocArray(){
+		return array(
+			'id' => $this->id,
+			'name' => $this->name,
+			'type' => $this->type->toAssocArray(),
+			'structure' => $this->structure,
+			'transferStatus' => $this->transferStatus,
+			'references' => $this->references);
+	}
+	
+	function toXmlRpcStruct(){
+		return new XML_RPC_VALUE(array(
+			'id' => new XML_RPC_Value($this->id,'string'),
+			'name' => new XML_RPC_Value($this->name,'string'),
+			'type' => $this->type->toXmlRpcStruct(),
+			'structure' => new XML_RPC_Value($this->structure,'string'),
+			'transferStatus' => new XML_RPC_Value($this->transferStatus,'string'),
+			'references' => new XML_RPC_Value($this->references,'array')),'struct');
+	}
+	
+	/*
+	 * Getter/Setter functions
+	 */
+	function getId(){return $this->id;}
+	function getName(){return $this->name;}
+	function getType(){return $this->type;}
+	function getStructure(){return $this->structure;}
+	function getTransferStatus(){return $this->transferStatus;}
+	function getReferences(){return $this->references;}
+	
+	function setId($val){$this->id = $val;}
+	function setName($val){$this->name = $val;}
+	function setType($val){$this->type = $val;}
+	function setStructure($val){$this->structure = $val;}
+	function setTransferStatus(){$this->transferStatus = $val;}
+	function setReferences($val){$this->references = $val;}
+	
+}
+
+?>
\ No newline at end of file

Added: oodt/branches/wengine-branch/filemgr/src/main/php/ProductType.class.php
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/php/ProductType.class.php?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/php/ProductType.class.php (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/php/ProductType.class.php Thu Dec 23 02:48:02 2010
@@ -0,0 +1,91 @@
+<?php
+//Copyright (c) 2008, California Institute of Technology.
+//ALL RIGHTS RESERVED. U.S. Government sponsorship acknowledged.
+//
+//$Id$
+
+require_once("XML/RPC.php");
+require_once("CAS/Filemgr/Metadata.class.php");
+
+/**
+ * Ports the core file manager data structure, 
+ * ProductType, to PHP.
+ * 
+ * @author ahart
+ * @author mattmann
+ * 
+ */
+class CAS_Filemgr_ProductType {
+	
+	 public $id;
+	 public $name;
+	 public $description;
+	 public $repositoryPath;
+	 public $versionerClass;
+	 public $typeMetadata;
+	
+	function __construct($xmlRpcData = array()){
+		$this->id = (isset($xmlRpcData['id']))
+			? $xmlRpcData['id'] 
+			: '';
+		$this->name = (isset($xmlRpcData['name']))
+			? $xmlRpcData['name'] 
+			: '';
+		$this->description = (isset($xmlRpcData['description']))
+			? $xmlRpcData['description'] 
+			: '';
+		$this->repositoryPath = (isset($xmlRpcData['repositoryPath']))
+			? $xmlRpcData['repositoryPath'] 
+			: '';
+		$this->versionerClass = (isset($xmlRpcData['versionerClass']))
+			? $xmlRpcData['versionerClass'] 
+			: '';
+		$this->typeMetadata = (isset($xmlRpcData['typeMetadata'])) 
+		    ? new Metadata($xmlRpcData['typeMetadata'])
+		    : new Metadata();
+	}
+	
+	function __destruct(){
+		
+	}
+	
+	function toAssocArray(){
+		return array(
+			'id' => $this->id,
+			'name' => $this->name,
+			'description' => $this->description,
+			'repositoryPath' => $this->repositoryPath,
+			'versionerClass' => $this->versionerClass,
+			'typeMetadata' => $this->typeMetadata->toAssocArray());
+	}
+	
+	function toXmlRpcStruct(){
+		return new XML_RPC_Value(array(
+			'id' => new XML_RPC_Value($this->id,'string'),
+			'name' => new XML_RPC_Value($this->name,'string'),
+			'description' => new XML_RPC_Value($this->description,'string'),
+			'repositoryPath' => new XML_RPC_Value($this->repositoryPath,'string'),
+			'versionerClass' => new XML_RPC_Value($this->versionerClass,'string'),
+            'typeMetadata' => $this->typeMetadata->toXmlRpcStruct()), 'struct');
+	}
+	
+	/*
+	 * Getter/Setter Functions
+	 */
+	function getId(){return $this->id;}
+	function getName(){return $this->name;}
+	function getDescription(){return $this->description;}
+	function getRepositoryPath(){return $this->repositoryPath;}
+	function getVersionerClass(){return $this->versionerClass;}
+	function getTypeMetadata(){return $this->typeMetadata;}
+	
+	function setId($val){$this->id = $val;}
+	function setName($val){$this->name = $val;}
+	function setDescription($val){$this->description = $val;}
+	function setRepositoryPath($val){$this->repositoryPath = $val;}
+	function setVersionerClass($val){$this->versionerClass = $val;}
+	function setTypeMetadata($val){$this->typeMetadata = $val;}
+	
+}
+
+?>
\ No newline at end of file

Added: oodt/branches/wengine-branch/filemgr/src/main/php/XmlRpcFilemgrClient.class.php
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/php/XmlRpcFilemgrClient.class.php?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/php/XmlRpcFilemgrClient.class.php (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/php/XmlRpcFilemgrClient.class.php Thu Dec 23 02:48:02 2010
@@ -0,0 +1,164 @@
+<?php
+//Copyright (c) 2008, California Institute of Technology.
+//ALL RIGHTS RESERVED. U.S. Government sponsorship acknowledged.
+//
+//$Id$
+
+require_once("XML/RPC.php");
+
+/**
+ * XML-RPC PHP version of the file manager client.
+ * 
+ * Not all of the core functionality/methods are ported yet
+ * but this is a good start.
+ * 
+ * @author ahart
+ * 
+ */
+class CAS_Filemgr_XmlRpcFilemgrClient {
+	private $client;		// The XML/RPC client
+	public $serverURL;		// The base URL of the server (default is localhost:9000)
+	public $serverPath;		// The path to the XMLRPC handler (/path/to/xmlrpc)
+	
+	function __construct($serverURL = 'localhost:9000',$serverPath = '/'){
+		$this->serverURL = $serverURL;
+		$this->serverPath = $serverPath;
+		try {
+			$this->client = new XML_RPC_Client($this->serverPath,$this->serverURL);
+		} catch (Exception $e) {
+			echo "<h4>Error creating XMLRPC client: " . $e.getMessage();
+			exit();
+		}
+	}
+	
+	function __destruct(){
+
+	}
+
+
+	function getProductById($productID){
+		$params = array(new XML_RPC_Value($productID,'string'));
+		$message = new XML_RPC_Message('filemgr.getProductById',$params);
+		$response = $this->client->send($message);
+		
+		if (!$response){
+			echo "<h4>Communication Error: {$this->client->errstr}</h4>";
+			exit(); 
+		}
+		
+		if (!$response->faultCode()) {
+			$value = $response->value();
+			$data = XML_RPC_decode($value);
+			return $data;
+		} else {
+			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
+			exit();
+		}
+	}
+	function getProductReferences($product){
+		$params = array($product->toXmlRpcStruct());
+		$message = new XML_RPC_Message('filemgr.getProductReferences',$params);
+		$response = $this->client->send($message);
+		
+		if (!$response){
+			echo "<h4>Communication Error: {$this->client->errstr}</h4>";
+			exit(); 
+		}
+		
+		if (!$response->faultCode()) {
+			$value = $response->value();
+			$data = XML_RPC_decode($value);
+			return $data;
+		} else {
+			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
+			exit();
+		}
+	}
+	
+	function getMetadata($product){	
+		$params = array($product->toXmlRpcStruct());
+		$message = new XML_RPC_Message('filemgr.getMetadata',$params);
+		$response = $this->client->send($message);
+		
+		if (!$response){
+			echo "<h4>Communication Error: {$this->client->errstr}</h4>";
+			exit(); 
+		}
+		
+		if (!$response->faultCode()) {
+			$value = $response->value();
+			$data = XML_RPC_decode($value);
+			return $data;
+		} else {
+			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
+			exit();
+		}
+	}
+	
+	function getProductTypeById($typeID){
+		$params = array(new XML_RPC_Value($typeID,'string'));
+		$message = new XML_RPC_Message("filemgr.getProductTypeById", $params);
+		$response = $this->client->send($message);
+		
+		if (!$response->faultCode()) {
+			$value = $response->value();
+			$data = XML_RPC_decode($value);
+			return $data;
+		} else {
+			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
+			exit();
+		}		
+		
+	}
+	
+	function getProductsByProductType($type){
+		$params = array($type->toXmlRpcStruct());
+		$message = new XML_RPC_Message("filemgr.getProductsByProductType", $params);
+		$response = $this->client->send($message);
+		
+		if (!$response->faultCode()) {
+			$value = $response->value();
+			$data = XML_RPC_decode($value);
+			return $data;
+		} else {
+			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
+			exit();
+		}		
+		
+	}
+
+	function getProductTypes(){
+		$params = array();
+		$message = new XML_RPC_Message("filemgr.getProductTypes", $params);
+		$response = $this->client->send($message);
+		
+		if (!$response->faultCode()) {
+			$value = $response->value();
+			$data = XML_RPC_decode($value);
+			return $data;
+		} else {
+			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
+			exit();
+		}		
+		
+	}
+		
+	
+	
+    function getNumProducts($type){
+		$params = array($type->toXmlRpcStruct());
+		$message = new XML_RPC_Message("filemgr.getNumProducts", $params);
+		$response = $this->client->send($message);
+		
+		if (!$response->faultCode()) {
+			$value = $response->value();
+			$data = XML_RPC_decode($value);
+			return $data;
+		} else {
+			echo "<h4>Fault Code Returned: (" . $response->faultCode . ") </h4>";
+			exit();
+		}		
+		
+	}
+}
+?>
\ No newline at end of file

Added: oodt/branches/wengine-branch/filemgr/src/main/php/package.xml
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/php/package.xml?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/php/package.xml (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/php/package.xml Thu Dec 23 02:48:02 2010
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+  @package CAS_Filemgr
+  @author Chris A. Mattmann
+  @version $Revision$
+  @copyright Copyright (c) 2008, California Institute of Technology. 
+  ALL RIGHTS RESERVED. U.S. Government sponsorship acknowledged.
+  @version $Id$
+-->
+<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0"
+  xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0.xsd
+         http://pear.php.net/dtd/package-2.0
+         http://pear.php.net/dtd/package-2.0.xsd">
+  <name>CAS_Filemgr</name>
+  <uri>http://oodt.jpl.nasa.gov/cas-filemgr</uri>
+  <!-- <channel/>-->
+  <summary>PHP CAS Filemgr Client and supporting API classes</summary>
+  <description>
+    This package provides a PHP-based XML-RPC client for the CAS filemgr
+    component. Though incomplete, the long term goals are to support the same
+    command line and API access that the Java-based client provides.
+  </description>
+  <lead>
+    <name>Chris Mattmann</name>
+    <user>mattmann</user>
+    <email>chris.mattmann@jpl.nasa.gov</email>
+    <active>yes</active>
+  </lead>
+  <date>2008-10-24</date>
+  <version>
+    <release>1.0.0</release>
+    <api>1.0.0</api>
+  </version>
+  <stability>
+    <release>stable</release>
+    <api>stable</api>
+  </stability>
+  <license
+    uri="http://openchannelsoftware.com/project/print_license.php?group_id=332&amp;license_id=40">
+    OODT License
+  </license>
+  <notes>
+    This package provides a PHP-based XML-RPC client for the CAS filemgr
+    component. Though incomplete, the long term goals are to support the same
+    command line and API access that the Java-based client provides.
+  </notes>
+  <contents>
+    <dir name="/" baseinstalldir="CAS/Filemgr">
+      <file name="Metadata.class.php" role="php" />
+      <file name="Product.class.php" role="php" />
+      <file name="ProductType.class.php" role="php" />
+      <file name="XmlRpcFilemgrClient.class.php" role="php" />
+    </dir><!-- / -->
+  </contents>
+  <dependencies>
+    <required>
+      <php>
+        <min>5.1.6</min>
+      </php>
+      <pearinstaller>
+        <min>1.6.1</min>
+      </pearinstaller>
+    </required>
+  </dependencies>
+  <phprelease />
+  <changelog>
+    <release>
+      <version>
+        <release>1.0.0</release>
+        <api>1.0.0</api>
+      </version>
+      <stability>
+        <release>stable</release>
+        <api>stable</api>
+      </stability>
+      <date>2008-10-24</date>
+      <license
+        uri="http://openchannelsoftware.com/project/print_license.php?group_id=332&amp;license_id=40">
+        OODT License
+      </license>
+      <notes>
+        This package provides a PHP-based XML-RPC client for the CAS filemgr
+        component. Though incomplete, the long term goals are to support the
+        same command line and API access that the Java-based client provides.
+      </notes>
+    </release>
+  </changelog>
+</package>
\ No newline at end of file

Added: oodt/branches/wengine-branch/filemgr/src/main/python/fm.conf
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/python/fm.conf?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/python/fm.conf (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/python/fm.conf Thu Dec 23 02:48:02 2010
@@ -0,0 +1,29 @@
+# encoding: utf-8
+# Copyright 2008 California Institute of Technology. ALL RIGHTS
+# RESERVED. U.S. Government Sponsorship acknowledged.
+
+[index]
+# The path gives the name of the directory where the Lucene search engine
+# will build its indexes.  The path refers to a directory; it will be created
+# if it doesn't exist.  If it does exist, it must refer to an
+# existing Lucene index with correct sub-files present.  So, don't make this
+# directory manually, or you'll be confused by error messages!
+path = @INDEX_PATH@
+pageSize = 20
+
+[policies]
+# The 'repo' and 'validation' are comma-separated lists of URLs.  Typically, they
+# contain a single "file:" style URL that names a directory with policy XML files
+# within.  The 'user' identifies the user database.  It'll be created if it
+# doesn't exist.
+repo = @REPO_POLICY_URLS@
+validation = @VALIDATION_POLICY_URLS@
+user = @USER_DB_PATH@
+
+[factories]
+# There's no need to change anything here unless you really know what you're doing,
+# and trust me, you don't.  Don't take it personally.  It's just a fact.
+catalog = gov.nasa.jpl.oodt.cas.filemgr.catalog.LuceneCatalogFactory
+repository = gov.nasa.jpl.oodt.cas.filemgr.repository.XMLRepositoryManagerFactory
+datatransfer = gov.nasa.jpl.oodt.cas.filemgr.datatransfer.LocalDataTransferFactory
+validation =gov.nasa.jpl.oodt.cas.filemgr.validation.XMLValidationLayerFactory

Added: oodt/branches/wengine-branch/filemgr/src/main/python/fm.py
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/python/fm.py?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/python/fm.py (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/python/fm.py Thu Dec 23 02:48:02 2010
@@ -0,0 +1,542 @@
+#!/usr/bin/env python
+# encoding: utf-8
+# Copyright 2008 California Institute of Technology. ALL RIGHTS
+# RESERVED. U.S. Government Sponsorship acknowledged.
+#
+# $Id$
+'''
+CAS Filemgr Python Server
+
+This is the Python server API for an authenticated Catalog and Archive System.  It uses the
+OODT Catalog and Archive System as its core, adding user/password-based authentication
+and role-based authorization.
+'''
+
+import sys, os, os.path
+import getopt, sha, pickle
+
+from ConfigParser import ConfigParser
+from gov.nasa.jpl.oodt.cas.filemgr.system.auth import SecureWebServer, Dispatcher, Result
+from gov.nasa.jpl.oodt.cas.filemgr.datatransfer import TransferStatusTracker
+from gov.nasa.jpl.oodt.cas.filemgr.structs import Product
+from gov.nasa.jpl.oodt.cas.filemgr.util import GenericFileManagerObjectFactory
+from gov.nasa.jpl.oodt.cas.filemgr.util import XmlRpcStructFactory as Structs
+from gov.nasa.jpl.oodt.cas.metadata import Metadata
+from java.lang import Boolean, Double, Integer
+from java.util import Hashtable, Vector
+
+# We choose these default factory classes because it minimizes our dependencies
+# on heavyweight external packages, like smelly old SQL databases.
+_defaultFactories = {
+	'catalog': 'gov.nasa.jpl.oodt.cas.filemgr.catalog.LuceneCatalogFactory',
+	'repository': 'gov.nasa.jpl.oodt.cas.filemgr.repository.XMLRepositoryManagerFactory',
+	'datatransfer': 'gov.nasa.jpl.oodt.cas.filemgr.datatransfer.LocalDataTransferFactory',
+	'validation': 'gov.nasa.jpl.oodt.cas.filemgr.validation.XMLValidationLayerFactory'
+}
+
+# All available permissions.  By default, the "root" user will be in the "wheel"
+# group and will have these permissions.
+_allPerms = [
+	'filemgr.addMetadata',
+	'filemgr.addProductReferences',
+	'filemgr.addProductType',
+	'filemgr.catalogProduct',
+	'filemgr.getCurrentFileTransfer',
+	'filemgr.getCurrentFileTransfers',
+	'filemgr.getElementById',
+	'filemgr.getElementByName',
+	'filemgr.getElementsByProductType',
+	'filemgr.getFirstPage',
+	'filemgr.getLastPage',
+	'filemgr.getMetadata',
+	'filemgr.getNextPage',
+	'filemgr.getNumProducts',
+	'filemgr.getPrevPage',
+	'filemgr.getProductById',
+	'filemgr.getProductByName',
+	'filemgr.getProductPctTransferred',
+	'filemgr.getProductReferences',
+	'filemgr.getProductsByProductType',
+	'filemgr.getProductTypeById',
+	'filemgr.getProductTypeByName',
+	'filemgr.getProductTypes',
+	'filemgr.getRefPctTransferred',
+	'filemgr.getTopNProducts',
+	'filemgr.handleRequest',
+	'filemgr.hasProduct',
+	'filemgr.ingestProduct',
+	'filemgr.isTransferComplete',
+	'filemgr.pagedQuery',
+	'filemgr.query',
+	'filemgr.removeFile',
+	'filemgr.removeProductTransferStatus',
+	'filemgr.setProductTransferStatus',
+	'filemgr.transferFile',
+	'filemgr.transferringProduct',
+	'usermgr.addGroup',
+	'usermgr.addPermissionToGroup',
+	'usermgr.addUser',
+	'usermgr.addUserToGroup',
+	'usermgr.removeGroup',
+	'usermgr.removePermissionFromGroup',
+	'usermgr.removeUser',
+	'usermgr.removeUserFromGroup'
+]
+
+def _toJavaBoolean(truthiness):
+	'''Convert a Python boolean into the string format that Java uses: true or false.
+	'''
+	if truthiness:
+		return 'true'
+	else:
+		return 'false'
+	
+
+def _encodePassword(pw):
+	'''Encode a password using an SHA-1 digest.
+	'''
+	return sha.new(pw).digest()
+	
+
+class User:
+	'''A user of the CAS.  Users don't have permissions directly; instead they receive
+	them implicitly by being members of groups, which do have permissions.
+	'''
+	def __init__(self, userID, name, email, password, groups=[]):
+		self.userID, self.name, self.email, self.password, self.groups = userID, name, email, password, groups
+		
+	def __cmp__(self, other):
+		return cmp(self.userID, other.userID)
+		
+	def __hash__(self):
+		return hash(self.userID)
+	
+	def __repr__(self):
+		return 'User(userID=%s,name=%s,email=%s,password=%s,groups=%r)' % (
+			self.userID, self.name, self.email, self.password, self.groups
+		)
+	
+
+class Group:
+	'''A CAS group.  The group contains a sequence of permissions, which are strings
+	that name the XML-RPC methods that the group is allowed to call.
+	'''
+	def __init__(self, groupID, name, email, perms=[]):
+		self.groupID, self.name, self.email, self.perms = groupID, name, email, perms
+		
+	def __cmp__(self, other):
+		return cmp(self.groupID, other.groupID)
+		
+	def __hash__(self):
+		return hash(self.groupID)
+		
+	def __repr__(self):
+		return 'Group(groupdID=%s,name=%s,email=%s,perms=%r)' % (self.groupdID, self.name, self.email, self.perms)
+	
+
+class UserDB:
+	'''The user database records all the users and groups.
+	'''
+	def __init__(self, users, groups, filename):
+		self.users, self.groups, self.filename = users, groups, filename
+		
+	def authenticate(self, name, password):
+		'''Authenticate a user by checking the user name and password.
+		Return true if the user's password matches the given one.  The
+		password given should be in SHA-1 digest format.
+		'''
+		user = self.users[name]
+		return user.userID == name and user.password == password
+	
+	def authorize(self, name, perm):
+		'''Authorize if the user has the given permission.  Return true if
+		the user can do it, false otherwise.
+		'''
+		user = self.users[name]
+		for group in user.groups:
+			if perm in group.perms:
+				return True
+		return False
+	
+	def save(self):
+		'''Save the user database to disk.
+		'''
+		f = file(self.filename, 'wb')
+		pickle.dump(self, f)
+		f.close()
+	
+
+class FileMgrDispatcher(Dispatcher):
+	'''The file manager dispatcher handles all XML-RPC calls.
+	'''
+	def __init__(self, catalog, repo, xfer, userDB):
+		self.catalog, self.repo, self.xfer, self.userDB = catalog, repo, xfer, userDB
+		self.tracker = TransferStatusTracker(self.catalog)
+	
+	def handleRequest(self, methodSpecifier, params, user, password):
+		'''Handle an XML-RPC request.  First, authenticate the user.  If the user's
+		authentic (by dint of providing a correct user ID and password pair), then
+		authorize if the method the user is trying to call is available.
+		'''
+		password = _encodePassword(password)
+		if self.userDB.authenticate(user, password):
+			if self.userDB.authorize(user, methodSpecifier):
+				obj, method = methodSpecifier.split('.')
+				if obj not in ('filemgr', 'usermgr'):
+					raise ValueError('Unknown object')
+				func = getattr(self, method)
+				return func(params)
+			raise ValueError('Not authorized for "%s"' % methodSpecifier)
+		raise ValueError('Illegal user name "%s" and/or password' % user)
+	
+	def getProductTypeByName(self, params):
+		return Result(None, Structs.getXmlRpcProductType(self.repo.getProductTypeByName(params[0])))
+	
+	def ingestProduct(self, params):
+		productHash, metadata, clientXfer = params
+		p = Structs.getProductFromXmlRpc(productHash)
+		p.setTransferStatus(Product.STATUS_TRANSFER)
+		self.catalog.addProduct(p)
+		
+		m = Metadata()
+		m.addMetadata(metadata)
+		self.catalog.addMetadata(m, p)
+		
+		if not clientXfer:
+	                versioner = GenericFileManagerObjectFactory.getVersionerFromClassName(p.getProductType().getVersioner())
+			versioner.createDataStoreReferences(p, m)
+			self.catalog.addProductReferences(p)
+			self.xfer.transferProduct(p)
+			p.setTransferStatus(Product.STATUS_RECEIVED)
+			self.catalog.setProductTranfserStatus(p)
+		return Result(None, p.getProductId())
+	
+	def addProductReferences(self, params):
+		self.catalog.addProductReferences(Structs.getProductFromXmlRpc(params[0]))
+		return Result(Boolean, 'true')
+	
+	def transferringProduct(self, params):
+		self.tracker.transferringProduct(Structs.getProductFromXmlRpc(params[0]))
+		return Result(Boolean, 'true')
+	
+	def removeProductTransferStatus(self, params):
+		self.tracker.removeProductTransferStatus(Structs.getProductFromXmlRpc(params[0]))
+		return Result(Boolean, 'true')
+	
+	def setProductTransferStatus(self, params):
+		self.catalog.setProductTransferStatus(Structs.getProductFromXmlRpc(params[0]))
+		return Result(Boolean, 'true')
+		
+	def getCurrentFileTransfer(self, params):
+		status = self.tracker.getCurrentFileTransfer()
+		if status is None:
+			return Result(None, Hashtable())
+		else:
+			return Result(None, Structs.getXmlRpcFileTransferStatus(status))
+	
+	def getCurrentFileTransfers(self, params):
+		xfers = self.tracker.getCurrentFileTransfers()
+		if xfers is not None and len(xfers) > 0:
+			return Result(None, Structs.getXmlRpcFileTransferStatuses(xfers))
+		else:
+			return Result(None, Vector())
+	
+	def getProductPctTransferred(self, params):
+		return Result(Double, str(self.tracker.getPctTransferred((Structs.getProductFromXmlRpc(params[0])))))
+	
+	def getRefPctTransferred(self, params):
+		pct = self.tracker.getPctTransferred(Structs.getReferenceFromXmlRpc(params[0]))
+		return Result(Double, str(pct))
+	
+	def isTransferComplete(self, params):
+		return Result(Boolean, _toJavaBoolean(self.tracker.isTransferComplete(Structs.getProductFromXmlRpc(params[0]))))
+	
+	def pagedQuery(self, params):
+		ptype = Structs.getProductTypeFromXmlRpc(params[1])
+		query = Structs.getQueryFromXmlRpc(params[0])
+		return Result(None, Structs.getXmlRpcProductPage(self.catalog.pagedQuery(query, ptype, params[2])))
+	
+	def getFirstPage(self, params):
+		ptype = Structs.getProductTypeFromXmlRpc(params[0])
+		return Result(None, Structs.getXmlRpcProductPage(self.catalog.getFirstPage(ptype)))
+	
+	def getLastPage(self, params):
+		ptype = Structs.getProductTypeFromXmlRpc(params[0])
+		return Result(None, Structs.getXmlRpcProductPage(self.catalog.getLastProductPage(ptype)))
+	
+	def getNextPage(self, params):
+		ptype = Structs.getProductTypeFromXmlRpc(params[0])
+		page = Structs.getProductPageFromXmlRpc(params[1])
+		return Result(None, Structs.getXmlRpcProductPage(self.catalog.getNextPage(ptype, page)))
+	
+	def getPrevPage(self, params):
+		ptype = Structs.getProductTypeFromXmlRpc(params[0])
+		page = Structs.getProductPageFromXmlRpc(params[1])
+		return Result(None, Structs.getXmlRpcProductPage(self.catalog.getPrevPage(ptype, page)))
+		
+	def addProductType(self, params):
+		ptype = Structs.getProductTypeFromXmlRpc(params[0])
+		self.repo.addProductType(ptype)
+		return Result(None, ptype.getProductTypeId())
+	
+	def getNumProducts(self, params):
+		ptype = Structs.getProductTypeFromXmlRpc(params[0])
+		return Result(Integer, str(self.catalog.getNumProducts(ptype)))
+	
+	def getTopNProducts(self, params):
+		if len(params) == 1:
+			return Result(None, Structs.getXmlRpcProductList(self.catalog.getTopNProducts(params[0])))
+		ptype = Structs.getProductTypeFromXmlRpc(params[1])
+		return Result(None, Structs.getXmlRpcProductList(self.catalog.getTopNProducts(params[0], ptype)))
+	
+	def hasProduct(self, params):
+		p = self.catalog.getProductByName(params[0])
+		return Result(Boolean, _toJavaBoolean(p is not None and p.transferStatus == Product.STATUS_RECEIVED))
+	
+	def getMetadata(self, params):
+		return Result(None, self.catalog.getMetadata(Structs.getProductFromXmlRpc(params[0])).getHashtable())
+	
+	def getProductTypes(self, params):
+		return Result(None, Structs.getXmlRpcProductList(self.repo.getProductTypes()))
+	
+	def getProductReferences(self, params):
+		p = Structs.getProductFromXmlRpc(params[0])
+		return Result(None, Structs.getXmlRpcReferences(self.catalog.getProductReferences(p)))
+	
+	def getProductById(self, params):
+		return Result(None, Structs.getXmlRpcProduct(self.catalog.getProductById(params[0])))
+	
+	def getProductByName(self, params):
+		return Result(None, Structs.getXmlRpcProduct(self.catalog.getProductByName(params[0])))
+	
+	def getProductsByProductType(self, params):
+		ptype = Structs.getProductTypeFromXmlRpc(params[0])
+		return Result(None, Structs.getXmlRpcProductList(self.catalog.getProductsByProductType(ptype)))
+	
+	def getElementsByProductType(self, params):
+		ptype = Structs.getProductTypeFromXmlRpc(params[0])
+		return Structs.getXmlRpcElementList(self.catalog.getValidationLayer().getElements(ptype))
+	
+	def getElementById(self, params):
+		return Structs.getXmlRpcElement(self.catalog.getValidationLayer().getElementById(params[0]))
+		
+	def getElementByName(self, params):
+		return Structs.getXmlRpcElement(self.catalog.getValidationLayer().getElementByName(params[0]))
+	
+	def query(self, params):
+		q = Structs.getQueryFromXmlRpc(params[0])
+		ptype = Structs.getProductTypeFromXmlRpc(params[1])
+		ids = self.catalog.query(q, ptype)
+		if ids is not None and len(ids) > 0:
+			return Result(None, [self.catalog.getProductById(i) for i in ids])
+		return Result(None, Vector())
+	
+	def getProductTypeById(self, params):
+		ptype = self.repo.getProductTypeById(params[0])
+		return Result(None, Structs.getXmlRpcProductType(ptype))
+	
+	def catalogProduct(self, params):
+		p = Structs.getProductFromXmlRpc(params[0])
+		return Result(None, self.catalog.addProduct(p))
+	
+	def addMetadata(self, params):
+		p = Structs.getProductFromXmlRpc(params[0])
+		m = Metadata()
+		m.addMetadata(params[1])
+		self.catalog.addMetadata(m, p)
+		return Result(Boolean, 'true')
+		
+	def transferFile(self, params):
+		outFile, data, offset, numBytes = params
+		if os.path.exists(outFile):
+			out = file(outFile, 'ab')
+		else:
+			dirPath = os.dirname(outFile)
+			os.makedirs(dirPath)
+			out = file(outFile, 'wb')
+		out.seek(offset)
+		out.write(data)
+		out.close()
+		return Result(Boolean, 'true')
+	
+	def removeFile(self, params):
+		os.remove(params[0])
+		return Result(Boolean, 'true')
+		
+	def addUser(self, params):
+		userID = params[0]
+		user = User(userID, params[1], params[2], _encodePassword(params[3]), [])
+		self.userDB.users[userID] = user
+		self.userDB.save()
+		return Result(Boolean, 'true')
+		
+	def removeUser(self, params):
+		del self.userDB.users[params[0]]
+		return Result(Boolean, 'true')
+	
+	def addGroup(self, params):
+		groupID = params[0]
+		group = Group(groupID, params[1], params[2])
+		self.userDB.groups[groupID] = group
+		self.userDB.save()
+		return Result(Boolean, 'true')
+	
+	def removeGroup(self, params):
+		groupID = params[0]
+		del self.userDB.groups[groupID]
+		for user in self.userDB.users.itervalues():
+			indexes = []
+			index = 0
+			for group in user.groups:
+				if group.groupID == groupID:
+					indexes.append(index)
+				index += 1
+			indexes.reverse()
+			for index in indexes:
+				del user.groups[index]
+		self.userDB.save()
+		return Result(Boolean, 'true')
+		
+	def addUserToGroup(self, params):
+		self.userDB.users[params[0]].groups.append(self.userDB.groups[params[1]])
+		return Result(Boolean, 'true')
+
+	def removeUserFromGroup(self, params):
+		groupID = params[1]
+		user = self.userDB.users[params[0]]
+		indexes = []
+		index = 0
+		for group in user.group:
+			if group.groupID == groupID:
+				indexes.append(index)
+			index += 1
+		indexes.reverse()
+		for index in indexes:
+			del user.groups[index]
+		self.userDB.save()
+		return Result(Boolean, 'true')
+		
+	def addPermissionToGroup(self, params):
+		self.userDB.groups[params[0]].perms.append(params[1])
+		self.userDB.save()
+		return Result(Boolean, 'true')
+		
+	def removePermissionFromGroup(self, params):
+		permName = params[1]
+		group = self.userDB.groups[params[0]]
+		indexes = []
+		index = 0
+		for perm in group.perms:
+			if perm == permName:
+				indexes.append(index)
+		indexes.reverse()
+		for index in indexes:
+			del group.perms[index]
+		self.userDB.save()
+		return Result(Boolean, 'true')
+	
+
+def _usage():
+	'''Show a usage message to the stderr and quit.
+	'''
+	print >>sys.stderr, 'Usage: %s [-c <configFile>]' % sys.argv[0]
+	print >>sys.stderr, '   or: %s [--config=<configFile>]' % sys.argv[0]
+	sys.exit(2)
+	
+
+def _parseCommandLine():
+	'''Parse the command line options.  If any.  The only option is -c (or --config)
+	that names a configuration file to use.  If none given, reasonable defaults are
+	used.  Well, mostly reasonable.
+	'''
+	try:
+		opts, args = getopt.getopt(sys.argv[1:], 'c:', 'config=')
+	except getopt.GetoptError:
+		_usage()
+	configFile = None
+	for option, arg in opts:
+		if option in ('-c', '--config'):
+			configFile = arg
+			if configFile is None or len(configFile) == 0:
+				_usage()
+	return configFile
+	
+
+def _getConfig(configFile):
+	'''Get the configuration.  This populates a configuration with default values
+	and then overwrites them with the configFile, which may be None (in which case,
+	no overwriting happens).
+	'''
+	configParser = ConfigParser()
+	configParser.add_section('factories')
+	for key, val in _defaultFactories.iteritems():
+		configParser.set('factories', key, val)
+
+	configParser.add_section('index')
+	configParser.set('index', 'path', 'index')
+	configParser.set('index', 'pageSize', '20')
+
+	current = '/'.join(os.path.split(os.getcwd()))
+	configParser.add_section('policies')
+	configParser.set('policies', 'repo', 'file:%s/policy' % current)
+	configParser.set('policies', 'validation', 'file:%s/policy' % current)
+	configParser.set('policies', 'user', '%s/user.db' % current)
+
+	if configFile is not None:
+		configParser.readfp(file(configFile))
+	return configParser
+	
+
+def _setJavaProperties(config):
+	'''Set Java-based properties.  The Java-based cas expects a whole bunch of
+	system properties to be set, sort of like global variables.  Woot!  Global
+	variables!
+	'''
+	from java.lang import System
+	System.setProperty('gov.nasa.jpl.oodt.cas.filemgr.catalog.lucene.idxPath', config.get('index', 'path'))
+	System.setProperty('gov.nasa.jpl.oodt.cas.filemgr.catalog.lucene.pageSize', config.get('index', 'pageSize'))
+	System.setProperty('gov.nasa.jpl.oodt.cas.filemgr.repositorymgr.dirs', config.get('policies', 'repo'))
+	System.setProperty('gov.nasa.jpl.oodt.cas.filemgr.validation.dirs', config.get('policies', 'validation'))
+	System.setProperty('gov.nasa.jpl.oodt.cas.filemgr.datatransfer.remote.chunkSize', '1024')
+	System.setProperty('filemgr.repository.factory', config.get('factories', 'repository'))
+	System.setProperty('filemgr.catalog.factory', config.get('factories', 'catalog'))
+	System.setProperty('filemgr.datatransfer.factory', config.get('factories', 'datatransfer'))
+	System.setProperty('filemgr.validationLayer.factory', config.get('factories', 'validation'))
+	
+def _getUserDB(path):
+	'''Get the user database, creating it if necessary.
+	'''
+	try:
+		f = file(path, 'rb')
+		db = pickle.load(f)
+		f.close()
+		db.filename = path
+		db.save()
+	except:
+		wheel = Group('wheel', 'Administrators', 'teh.power@power.users', _allPerms)
+		root = User('root', 'Super User', 'teh.root@power.users', _encodePassword('poipu'), [wheel])
+		db = UserDB({'root': root}, {'wheel': wheel}, path)
+		db.save()
+	return db
+	
+
+def main():
+	'''Start the CAS Filemgr Backend.
+	'''
+	configFile = _parseCommandLine()
+	configParser = _getConfig(configFile)
+	_setJavaProperties(configParser)
+
+	catalog = GenericFileManagerObjectFactory.getCatalogServiceFromFactory(configParser.get('factories', 'catalog'))
+	repo = GenericFileManagerObjectFactory.getRepositoryManagerServiceFromFactory(configParser.get('factories', 'repository'))
+	xfer = GenericFileManagerObjectFactory.getDataTransferServiceFromFactory(configParser.get('factories', 'datatransfer'))
+	userDB = _getUserDB(configParser.get('policies', 'user'))
+
+	ws = SecureWebServer(1999)
+	ws.addDispatcher(FileMgrDispatcher(catalog, repo, xfer, userDB))
+	ws.start()
+	
+
+if __name__ == '__main__':
+	main()
+	

Added: oodt/branches/wengine-branch/filemgr/src/main/python/setclasspath.sh
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/python/setclasspath.sh?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/python/setclasspath.sh (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/python/setclasspath.sh Thu Dec 23 02:48:02 2010
@@ -0,0 +1,2 @@
+
+setenv CLASSPATH ${HOME}/.m2/repository/gov/nasa/jpl/oodt/cas-filemgr/1.7.0-dev/cas-filemgr-1.7.0-dev.jar:${HOME}/.m2/repository/xmlrpc/xmlrpc/2.1-dev/xmlrpc-2.1-dev.jar:${HOME}/.m2/repository/gov/nasa/jpl/oodt/cas-metadata/1.5.0/cas-metadata-1.5.0.jar:${HOME}/.m2/repository/org/apache/lucene/lucene-core/2.0.0/lucene-core-2.0.0.jar:${HOME}/.m2/repository/jug/jug-asl/2.0.0/jug-asl-2.0.0.jar
\ No newline at end of file

Propchange: oodt/branches/wengine-branch/filemgr/src/main/python/setclasspath.sh
------------------------------------------------------------------------------
    svn:executable = 

Added: oodt/branches/wengine-branch/filemgr/src/main/resources/CAS File Manager User Guide.doc
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/resources/CAS%20File%20Manager%20User%20Guide.doc?rev=1052148&view=auto
==============================================================================
Binary file - no diff available.

Propchange: oodt/branches/wengine-branch/filemgr/src/main/resources/CAS File Manager User Guide.doc
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: oodt/branches/wengine-branch/filemgr/src/main/resources/MysqlToOracleFilter.pl
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/resources/MysqlToOracleFilter.pl?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/resources/MysqlToOracleFilter.pl (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/resources/MysqlToOracleFilter.pl Thu Dec 23 02:48:02 2010
@@ -0,0 +1,206 @@
+#!/usr/bin/env perl
+#
+# filter to transform mysql ddl into oracle ddl
+# author: Dennis Box, dbox@fnal.gov
+# date: Dec 2001
+# usage MysqlToOracleFilter.pl inputfile.mysql > inputfile.ora_sql
+#
+use strict;
+
+#my $data_tablespace='MINOSDEV_DATA';
+#my $idx_tablespace='MINOSDEV_IDX';
+my $data_tablespace='MINOS_DEV_DATA';
+my $idx_tablespace='MINOS_DEV_IDX';
+my $line;
+my $big_line;
+my $table=0;
+my $pk_name=0;
+my $fk_name=0;
+my $old_table=0;
+my $col_flag=0;
+my $next_col=0;
+my $trigger_yada="
+DROP SEQUENCE _SEQ_NAME_;
+
+CREATE SEQUENCE _SEQ_NAME_
+ INCREMENT BY 1
+ START WITH 1
+ NOMAXVALUE
+ MINVALUE 1
+ NOCYCLE
+ NOCACHE
+/ 
+DROP  PUBLIC SYNONYM  _SEQ_NAME_;
+CREATE PUBLIC SYNONYM  _SEQ_NAME_ FOR  _SEQ_NAME_ ;
+
+CREATE OR REPLACE TRIGGER _TRG_NAME_
+BEFORE INSERT
+ON _TAB_NAME_
+REFERENCING OLD AS OLD NEW AS NEW
+FOR EACH ROW
+BEGIN
+DECLARE
+NEXT         NUMBER;
+BEGIN
+SELECT _SEQ_NAME_.NEXTVAL INTO NEXT FROM DUAL;
+:new.ROW_COUNTER:=NEXT;
+END;
+END _TRG_NAME_;
+/
+
+DROP PUBLIC SYNONYM  _TRG_NAME_ ;
+CREATE PUBLIC SYNONYM  _TRG_NAME_ FOR  _TRG_NAME_ ;
+";
+
+
+
+if($ENV{'DATA_TABLESPACE'}){
+  $data_tablespace=$ENV{'DATA_TABLESPACE'};
+}
+if($ENV{'INDEX_TABLESPACE'}){
+  $idx_tablespace=$ENV{'INDEX_TABLESPACE'};
+}
+
+
+print "SET ECHO ON;\n";
+print "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD hh24:mi:ss';\n";
+while (<>){
+  $line = $_;
+  $line = "\U$_" unless "\U$line" =~/^INSERT INTO/;
+  $line =~ s/\`//g;
+  $line =~ s/.* KEY .*//g unless $line =~/ PRIMARY /;
+  $line =~ s/ IF EXISTS / /g;
+  $line =~ s/ IF NOT EXISTS / /g;
+  $line =~ s/ DATETIME/ DATE/g;
+  $line =~ s/ UNSIGNED//g;
+  $line =~ s/ TINYINT/ number/g;
+  $line =~ s/ SMALLINT/ number/g;
+  $line =~ s/ INT\(/ number\(/g;
+  $line =~ s/   VIEW/    View_dir/g;
+  $line =~ s/VALIDITY/VLD/g;
+  $line =~ s/VALID/VLD/g;
+  #$line =~ s/ DOUBLE/ BINARY_DOUBLE/g;
+  $line =~ s/ TEXT/ VARCHAR(2000)/g;
+  $line =~ s/\#/-- /;
+  $line =~ s/ TINYTEXT/ VARCHAR(200)/g;
+  $line =~ s/MODE /TASK /g;
+  #$line =~ s/ CHAR\(/ VARCHAR\(/g;
+  $line =~ s/AUTO_INCREMENT//g;
+  $line =~ s/UNSIGNED//g;
+  $line =~ s/^\>\>/-- /g;
+  $line =~ s/^\<\</-- /g;
+  $line =~ s/TYPE=MYISAM//g;
+  $line =~ s/, INDEX \(SEQNO\)//g;
+  $line =~ s/'(\d\d\d\d-\d\d-\d\d) (\d\d:\d\d:\d\d)'/to_date\('$1 $2','YYYY-MM-DD hh24:mi:ss'\) /g;
+  $line =~ s/0000-00-00/0001-01-01/g;
+  $line =~ s/KEY SEQNO \(SEQNO\)/CONSTRAINT $fk_name FOREIGN KEY\(SEQNO\) REFERENCES $table.VLD\(SEQNO\)/g;
+  $line =~ s/PRIMARY KEY  \(SEQNO\)/CONSTRAINT $pk_name PRIMARY KEY\(SEQNO\) USING INDEX TABLESPACE $idx_tablespace/g;
+  $line =~ s/PRIMARY KEY  \(SEQNO,ROW_COUNTER\)/CONSTRAINT $pk_name PRIMARY KEY\(SEQNO,ROW_COUNTER\) USING INDEX TABLESPACE $idx_tablespace/g;
+  $line =~ s/,$// if $line =~/CONSTRAINT/;
+
+  $line =~ s/\.VLD/VLD/g;
+  $line =~ s/COMMENT/RUN_COMMENT/g;
+  $line =~ s/ENGINE=.*$/;/g;
+  #$line =~ s/FLOAT\(.*\)/BINARY_FLOAT/g;
+  $line =~ s/FLOAT\(.*\)/FLOAT/g;
+  $line =~ s/BIGINT\(.*\)/INTEGER/g;
+  #$line =~ s/FLOAT /BINARY_FLOAT /g;
+  $line =~ s/NOT NULL DEFAULT(.*,$)/ DEFAULT $1 NOT NULL, /;
+  $line =~ s/NOT NULL DEFAULT(.*$)/ DEFAULT $1 NOT NULL /;
+  $line =~ s/\, NOT NULL/NOT NULL/g;
+  $line =~ s/\\N/NULL/g;
+  $line =~ s/^\) ;/\)TABLESPACE $data_tablespace;/g;
+
+  if($line =~/SEQNO number/){
+    $col_flag=1;
+    $next_col='';
+  }
+
+
+
+  if("\U$line" =~ /CREATE/ and  "\U$line" =~ /TABLE/){
+    if(!("\U$line" =~/VLD/)){
+     # $line = $line."\tROW_COUNTER INTEGER DEFAULT NULL,\n";
+    }
+    $old_table=$table;
+    my @parts = split(/\s+/,$line);
+    $table = $parts[2];
+    $table =~ s/\(.*//;
+    $fk_name = 'FK_'.$table;
+    $pk_name = 'PK_'.$table;
+    $fk_name =~s/[aeiouAEIOU]+//g if length($fk_name)>25;
+    $pk_name =~s/[aeiouAEIOU]+//g if length($pk_name)>25;
+    if($old_table ne 0){
+      print "\Ugrant  select on $old_table to minos_reader;\n";
+      print "\Ugrant  select,insert,update on $old_table to minos_writer;\n";
+      print "\Ucreate public synonym $old_table for $old_table;\n" ;
+    
+      if(!($old_table =~/VLD/)){
+	my $idx = $old_table.'_idx';
+	my $trigger_incant=&make_trigger($old_table);
+	$idx=~s/[aeiouAEIOU]+//g if length($idx)>25;
+	#print "ALTER TABLE $old_table ADD CONSTRAINT $pk_name PRIMARY KEY(SEQNO,ROW_COUNTER) using index tablespace  $idx_tablespace;  \n";
+	print "\Ucreate index $idx  on ";
+	print " $old_table(seqno) tablespace $idx_tablespace;  \n\n\n";
+	#print "$trigger_incant";
+      }else{
+	#print "ALTER TABLE $old_table ADD CONSTRAINT $pk_name PRIMARY KEY(SEQNO) using index tablespace  $idx_tablespace;  \n";
+      }
+    }
+
+
+    if($table ne 0){
+      my $tab_ref = $table;
+      $tab_ref =~ s/VLD//;
+      if($tab_ref ne $table){
+	print "\Udrop table $tab_ref;\n" ;
+	print "\Udrop public synonym $tab_ref;\n\n";
+	print "\Udrop table $table;\n" ;
+	print "\Udrop public synonym $table;\n\n";
+      }
+    }
+  }
+  next if  "\U$line" =~ /^\s+$/;
+  next if  "\U$line" =~ /^DROP TABLE/;
+  next if  "\U$line" =~ /^DESCRIBE/;
+  next if "\U$line" =~ /^USE/;
+  next if "\U$line" =~ /^#/;
+  #print $line;
+  $big_line=$big_line.$line;
+}
+print $big_line;
+$big_line='';
+print "create public synonym $table for $table;\n" if ($table);
+print "grant  select on $table to minos_reader;\n" if ($table);
+print "grant  select,insert,update on $table to minos_writer;\n" if ($table);
+my $idx = $table.'_idx';
+
+$idx=~s/[aeiouAEIOU]+//g if length($idx)>25;
+if($table && !($table =~/VLD/)){
+  my $trigger_incant=&make_trigger($table);
+  #print "ALTER TABLE $table ADD CONSTRAINT $pk_name \n"; 
+  #print "PRIMARY KEY(SEQNO,ROW_COUNTER) using index tablespace  $idx_tablespace;\n";
+  print "create index $idx  on $table(seqno) tablespace $idx_tablespace; \n\n";
+  #print "$trigger_incant";
+
+}
+
+ 
+
+print "EXIT;\n";
+
+
+sub make_trigger()
+  {
+    my ($table) = @_;
+    my $stable=$table;
+    $stable=~s/[aeiouAEIOU]+//g if length($stable)>25;
+
+    my $trg=$stable.'_TRG';
+    my $seq=$stable.'_SEQ';
+    my $incant=$trigger_yada;
+    $incant =~s/_SEQ_NAME_/$seq/g;
+    $incant =~s/_TRG_NAME_/$trg/g;
+    $incant =~s/_TAB_NAME_/$table/g;
+    $incant;
+  }

Added: oodt/branches/wengine-branch/filemgr/src/main/resources/REMOVE.log
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/resources/REMOVE.log?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/resources/REMOVE.log (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/resources/REMOVE.log Thu Dec 23 02:48:02 2010
@@ -0,0 +1,2 @@
+You can remove this file. It was only included to ensure that the log directory for this
+distribution was created on assembly.

Added: oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-core-schema-oracle.sql
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-core-schema-oracle.sql?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-core-schema-oracle.sql (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-core-schema-oracle.sql Thu Dec 23 02:48:02 2010
@@ -0,0 +1,15 @@
+SET ECHO ON;
+ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD hh24:mi:ss';
+
+CREATE TABLE PRODUCTS (
+  PRODUCT_ID number(11) NOT NULL ,
+  PRODUCT_STRUCTURE VARCHAR(20)  DEFAULT  ''NOT NULL, 
+  PRODUCT_TYPE_ID number(11)  DEFAULT  '0'NOT NULL, 
+  PRODUCT_NAME VARCHAR(255)  DEFAULT  ''NOT NULL, 
+  PRODUCT_TRANSFER_STATUS VARCHAR(255) DEFAULT 'TRANSFERING' NOT NULL,
+  PRIMARY KEY  (PRODUCT_ID)
+);
+
+CREATE INDEX PRODUCTS_idx ON PRODUCTS(product_id);  
+
+EXIT;

Added: oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-dyn-catalog-schema.sql
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-dyn-catalog-schema.sql?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-dyn-catalog-schema.sql (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-dyn-catalog-schema.sql Thu Dec 23 02:48:02 2010
@@ -0,0 +1,17 @@
+CREATE TABLE YourProductTypeName_metadata
+(
+  product_id int NOT NULL,
+  element_id varchar(1000) NOT NULL,
+  metadata_value varchar(2500) NOT NULL
+)
+
+CREATE TABLE YourProductTypeName_reference
+(
+  product_id int NOT NULL,
+  product_orig_reference varchar(2000) NOT NULL,
+  product_datastore_reference varchar(2000), 
+  product_reference_filesize int NOT NULL,
+  product_reference_mimetype varchar(50)
+)
+
+

Added: oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-repositorymgr-schema-oracle.sql
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-repositorymgr-schema-oracle.sql?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-repositorymgr-schema-oracle.sql (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-repositorymgr-schema-oracle.sql Thu Dec 23 02:48:02 2010
@@ -0,0 +1,15 @@
+SET ECHO ON;
+ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD hh24:mi:ss';
+
+CREATE TABLE PRODUCT_TYPES (
+  PRODUCT_TYPE_ID number(11) NOT NULL ,
+  PRODUCT_TYPE_NAME VARCHAR(255)  DEFAULT  ''NOT NULL, 
+  PRODUCT_TYPE_DESCRIPTION VARCHAR(255)  DEFAULT  ''NOT NULL, 
+  PRODUCT_TYPE_VERSIONER_CLASS VARCHAR(255) DEFAULT '',
+  PRODUCT_TYPE_REPOSITORY_PATH VARCHAR(255)  DEFAULT  ''NOT NULL, 
+  PRIMARY KEY  (PRODUCT_TYPE_ID)
+);
+ 
+CREATE INDEX PRODUCT_TYPES_IDX  ON  PRODUCT_TYPES(seqno);  
+
+EXIT;

Added: oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-schema-mysql.sql
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-schema-mysql.sql?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-schema-mysql.sql (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/resources/cas-filemgr-schema-mysql.sql Thu Dec 23 02:48:02 2010
@@ -0,0 +1,55 @@
+# Connection: localhost
+# Host: spawn
+# Saved: 2006-01-02 18:12:06
+# 
+
+# Host: spawn
+# Database: test_cas
+# Table: 'elements'
+# 
+CREATE TABLE `elements` (
+  `element_id` int(11) NOT NULL auto_increment,
+  `element_name` varchar(255) NOT NULL default '',
+  `data_type_id` int(11) NOT NULL default '0',
+  `dc_element` varchar(100) default '',
+  `element_description` varchar(255) NOT NULL default '',
+  PRIMARY KEY  (`element_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1; 
+
+# Host: spawn
+# Database: test_cas
+# Table: 'product_type_element_map'
+# 
+CREATE TABLE `product_type_element_map` (
+  `product_type_element_map_id` int(11) NOT NULL auto_increment,
+  `product_type_id` int(11) NOT NULL default '0',
+  `element_id` int(11) NOT NULL default '0',
+  PRIMARY KEY  (`product_type_element_map_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1; 
+
+# Host: spawn
+# Database: test_cas
+# Table: 'product_types'
+# 
+CREATE TABLE `product_types` (
+  `product_type_id` int(11) NOT NULL auto_increment,
+  `product_type_name` varchar(255) NOT NULL default '',
+  `product_type_description` varchar(255) NOT NULL default '',
+  `product_type_versioner_class` varchar(255) default '',
+  `product_type_repository_path` varchar(255) NOT NULL default '',
+  PRIMARY KEY  (`product_type_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1; 
+
+# Host: spawn
+# Database: test_cas
+# Table: 'products'
+# 
+CREATE TABLE `products` (
+  `product_id` int(11) NOT NULL auto_increment,
+  `product_structure` varchar(20) NOT NULL default '',
+  `product_type_id` int(11) NOT NULL default '0',
+  `product_name` varchar(255) NOT NULL default '',
+  `product_transfer_status` varchar(255) NOT NULL default 'TRANSFERING',
+  PRIMARY KEY  (`product_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1; 
+