]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
java: add FileAlreadyExists exception
authorNoah Watkins <noahwatkins@gmail.com>
Fri, 19 Oct 2012 19:10:25 +0000 (12:10 -0700)
committerNoah Watkins <noahwatkins@gmail.com>
Fri, 26 Oct 2012 20:30:27 +0000 (13:30 -0700)
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
src/java/Makefile.am
src/java/java/com/ceph/fs/CephFileAlreadyExistsException.java [new file with mode: 0644]
src/java/native/libcephfs_jni.cc

index c712cf78cba7f1ba24417b2fb7f4130d5f1ae942..48266653b0afaa9ccd892334f4e7e6916bef3aac 100644 (file)
@@ -5,7 +5,8 @@ JAVA_SRC = \
        java/com/ceph/fs/CephStat.java \
        java/com/ceph/fs/CephStatVFS.java \
        java/com/ceph/fs/CephNativeLoader.java \
-       java/com/ceph/fs/CephNotMountedException.java
+       java/com/ceph/fs/CephNotMountedException.java \
+       java/com/ceph/fs/CephFileAlreadyExistsException.java
 
 EXTRA_DIST = $(JAVA_SRC) test
 
diff --git a/src/java/java/com/ceph/fs/CephFileAlreadyExistsException.java b/src/java/java/com/ceph/fs/CephFileAlreadyExistsException.java
new file mode 100644 (file)
index 0000000..f750a6e
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package com.ceph.fs;
+
+import java.io.IOException;
+
+/**
+ * Ceph file/directory already exists.
+ */
+public class CephFileAlreadyExistsException extends IOException {
+
+  /**
+   * Construct CephFileAlreadyExistsException.
+   */
+  public CephFileAlreadyExistsException() {
+    super();
+  }
+
+  /**
+   * Construct CephFileAlreadyExistsException with message.
+   */
+  public CephFileAlreadyExistsException(String s) {
+    super(s);
+  }
+}
index fe5ce754f321e56e0695238e0b5e994d9d9428ac..dd23c36d6e180be199c36ed368c007839abe7988 100644 (file)
@@ -36,6 +36,7 @@
 #define CEPH_STAT_VFS_CP "com/ceph/fs/CephStatVFS"
 #define CEPH_MOUNT_CP "com/ceph/fs/CephMount"
 #define CEPH_NOTMOUNTED_CP "com/ceph/fs/CephNotMountedException"
+#define CEPH_FILEEXISTS_CP "com/ceph/fs/CephFileAlreadyExistsException"
 
 /*
  * Flags to open(). must be synchronized with CephMount.java
@@ -191,12 +192,20 @@ static void cephThrowFNF(JNIEnv *env, const char *msg)
   THROW(env, "java/io/FileNotFoundException", msg);
 }
 
+static void cephThrowFileExists(JNIEnv *env, const char *msg)
+{
+  THROW(env, CEPH_FILEEXISTS_CP, msg);
+}
+
 static void handle_error(JNIEnv *env, int rc)
 {
   switch (rc) {
   case -ENOENT:
     cephThrowFNF(env, "");
     return;
+  case -EEXIST:
+    cephThrowFileExists(env, "");
+    return;
   default:
     break;
   }