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 2012/03/27 08:45:16 UTC
svn commit: r1305744 - in /oodt/trunk/metadata/src:
main/java/org/apache/oodt/cas/metadata/exceptions/
main/java/org/apache/oodt/cas/metadata/filenaming/
test/org/apache/oodt/cas/metadata/filenaming/
Author: bfoster
Date: Tue Mar 27 06:45:15 2012
New Revision: 1305744
URL: http://svn.apache.org/viewvc?rev=1305744&view=rev
Log:
- Introduce a CAS-Metadata based renaming interface (CAS-Metadata changes)
-------------
OODT-426
Added:
oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/NamingConventionException.java (with props)
oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/
oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/NamingConvention.java (with props)
oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/PathUtilsNamingConvention.java (with props)
oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/filenaming/
oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/filenaming/TestPathUtilsNamingConvention.java (with props)
Added: oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/NamingConventionException.java
URL: http://svn.apache.org/viewvc/oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/NamingConventionException.java?rev=1305744&view=auto
==============================================================================
--- oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/NamingConventionException.java (added)
+++ oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/NamingConventionException.java Tue Mar 27 06:45:15 2012
@@ -0,0 +1,39 @@
+/*
+ * 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.metadata.exceptions;
+
+/**
+ * Exception throw by {@link NamingConvention} on error.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class NamingConventionException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public NamingConventionException() {
+ super();
+ }
+
+ public NamingConventionException(String msg) {
+ super(msg);
+ }
+
+ public NamingConventionException(String msg, Throwable t) {
+ super(msg, t);
+ }
+}
Propchange: oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/exceptions/NamingConventionException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/NamingConvention.java
URL: http://svn.apache.org/viewvc/oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/NamingConvention.java?rev=1305744&view=auto
==============================================================================
--- oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/NamingConvention.java (added)
+++ oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/NamingConvention.java Tue Mar 27 06:45:15 2012
@@ -0,0 +1,35 @@
+/*
+ * 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.metadata.filenaming;
+
+//JDK imports
+import java.io.File;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.metadata.exceptions.NamingConventionException;
+
+/**
+ * Interface for renaming files.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public interface NamingConvention {
+
+ public File rename(File file, Metadata metadata)
+ throws NamingConventionException;
+}
Propchange: oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/NamingConvention.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/PathUtilsNamingConvention.java
URL: http://svn.apache.org/viewvc/oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/PathUtilsNamingConvention.java?rev=1305744&view=auto
==============================================================================
--- oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/PathUtilsNamingConvention.java (added)
+++ oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/PathUtilsNamingConvention.java Tue Mar 27 06:45:15 2012
@@ -0,0 +1,62 @@
+/*
+ * 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.metadata.filenaming;
+
+//JDK imports
+import java.io.File;
+import java.io.IOException;
+
+//Apache imports
+import org.apache.commons.lang.Validate;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.metadata.exceptions.NamingConventionException;
+import org.apache.oodt.cas.metadata.util.PathUtils;
+
+/**
+ * A {@link NamingConvention} which utilizes {@link PathUtils}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class PathUtilsNamingConvention implements NamingConvention {
+
+ private String namingConv;
+
+ public File rename(File file, Metadata metadata)
+ throws NamingConventionException {
+ try {
+ Validate.notNull(file, "Must specify file");
+ Validate.notNull(metadata, "Must specify metadata");
+
+ File newFile = new File(file.getParentFile(),
+ PathUtils.doDynamicReplacement(namingConv, metadata));
+ if (!file.renameTo(newFile)) {
+ throw new IOException("Renaming file [" + file + "] to [" + newFile
+ + "] returned false");
+ }
+ return newFile;
+ } catch (Exception e) {
+ throw new NamingConventionException("Failed to renaming file [" + file
+ + "] : " + e.getMessage(), e);
+ }
+ }
+
+ public void setNamingConv(String namingConv) {
+ this.namingConv = namingConv;
+ }
+}
Propchange: oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/filenaming/PathUtilsNamingConvention.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/filenaming/TestPathUtilsNamingConvention.java
URL: http://svn.apache.org/viewvc/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/filenaming/TestPathUtilsNamingConvention.java?rev=1305744&view=auto
==============================================================================
--- oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/filenaming/TestPathUtilsNamingConvention.java (added)
+++ oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/filenaming/TestPathUtilsNamingConvention.java Tue Mar 27 06:45:15 2012
@@ -0,0 +1,21 @@
+/*
+ * 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.metadata.filenaming;
+
+public class TestPathUtilsNamingConvention extends TestCase {
+
+}
Propchange: oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/filenaming/TestPathUtilsNamingConvention.java
------------------------------------------------------------------------------
svn:mime-type = text/plain