Commit 67622181 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

nfs: merge nfsstat3 and nfsstat4

as v2, v3 and v4 specs backward compatible with error codes,
merge them into a single utility class. NFSException updated
to print human readable string.
parent e17c4b11
......@@ -25,17 +25,12 @@ public class ChimeraNFSException extends java.io.IOException {
private static final long serialVersionUID = 4319461664218810541L;
private final int nfsStatus;
public ChimeraNFSException(int newStatus, String msg) {
super(msg);
nfsStatus = newStatus;
public ChimeraNFSException(int status ,String msg) {
super(nfsstat.toString(status) + " : " + msg);
nfsStatus = status;
}
public int getStatus() {
return nfsStatus;
}
@Override
public String toString() {
return super.toString() + " NFS status: " + nfsStatus;
}
}
......@@ -19,7 +19,6 @@ package org.dcache.chimera.nfs.v3;
import java.io.IOException;
import org.dcache.chimera.nfs.v3.xdr.specdata3;
import org.dcache.chimera.nfs.v3.xdr.nfsstat3;
import org.dcache.chimera.nfs.v3.xdr.uint64;
import org.dcache.chimera.nfs.v3.xdr.uid3;
import org.dcache.chimera.nfs.v3.xdr.gid3;
......@@ -198,103 +197,6 @@ public class HimeraNfsUtils {
return ret;
}
static public String nfsErr2String(int nfsStatus) {
String ret = null;
switch (nfsStatus) {
case nfsstat3.NFS3_OK:
ret = "NFS3_OK";
break;
case nfsstat3.NFS3ERR_PERM:
ret = "NFS3ERR_PERM";
break;
case nfsstat3.NFS3ERR_NOENT:
ret = "NFS3ERR_NOENT";
break;
case nfsstat3.NFS3ERR_IO:
ret = "NFS3ERR_IO";
break;
case nfsstat3.NFS3ERR_NXIO:
ret = "NFS3ERR_NXIO";
break;
case nfsstat3.NFS3ERR_ACCES:
ret = "NFS3ERR_ACCES";
break;
case nfsstat3.NFS3ERR_EXIST:
ret = "NFS3ERR_EXIST";
break;
case nfsstat3.NFS3ERR_XDEV:
ret = "NFS3ERR_XDEV";
break;
case nfsstat3.NFS3ERR_NODEV:
ret = "NFS3ERR_NODEV";
break;
case nfsstat3.NFS3ERR_NOTDIR:
ret = "NFS3ERR_NOTDIR";
break;
case nfsstat3.NFS3ERR_ISDIR:
ret = "NFS3ERR_ISDIR";
break;
case nfsstat3.NFS3ERR_INVAL:
ret = "NFS3ERR_INVAL";
break;
case nfsstat3.NFS3ERR_FBIG:
ret = "NFS3ERR_FBIG";
break;
case nfsstat3.NFS3ERR_NOSPC:
ret = "NFS3ERR_NOSPC";
break;
case nfsstat3.NFS3ERR_ROFS:
ret = "NFS3ERR_ROFS";
break;
case nfsstat3.NFS3ERR_MLINK:
ret = "NFS3ERR_MLINK";
break;
case nfsstat3.NFS3ERR_NAMETOOLONG:
ret = "NFS3ERR_NAMETOOLONG";
break;
case nfsstat3.NFS3ERR_NOTEMPTY:
ret = "NFS3ERR_NOTEMPTY";
break;
case nfsstat3.NFS3ERR_DQUOT:
ret = "NFS3ERR_DQUOT";
break;
case nfsstat3.NFS3ERR_STALE:
ret = "NFS3ERR_STALE";
break;
case nfsstat3.NFS3ERR_REMOTE:
ret = "NFS3ERR_REMOTE";
break;
case nfsstat3.NFS3ERR_BADHANDLE:
ret = "NFS3ERR_BADHANDLE";
break;
case nfsstat3.NFS3ERR_NOT_SYNC:
ret = "NFS3ERR_NOT_SYNC";
break;
case nfsstat3.NFS3ERR_BAD_COOKIE:
ret = "NFS3ERR_BAD_COOKIE";
break;
case nfsstat3.NFS3ERR_NOTSUPP:
ret = "NFS3ERR_NOTSUPP";
break;
case nfsstat3.NFS3ERR_TOOSMALL:
ret = "NFS3ERR_TOOSMALL";
break;
case nfsstat3.NFS3ERR_SERVERFAULT:
ret = "NFS3ERR_SERVERFAULT";
break;
case nfsstat3.NFS3ERR_BADTYPE:
ret = "NFS3ERR_BADTYPE";
break;
case nfsstat3.NFS3ERR_JUKEBOX:
ret = "NFS3ERR_JUKEBOX";
break;
}
return ret;
}
/**
* Create empty post operational attributes.
* @return attrs
......
......@@ -4,9 +4,9 @@
* See http://remotetea.sourceforge.net for details
*/
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.chimera.nfs.v3.*;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class ACCESS3res implements XdrAble {
public int status;
......@@ -25,7 +25,7 @@ public class ACCESS3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -38,7 +38,7 @@ public class ACCESS3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new ACCESS3resok(xdr);
break;
default:
......
......@@ -4,9 +4,9 @@
* See http://remotetea.sourceforge.net for details
*/
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.chimera.nfs.v3.*;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class COMMIT3res implements XdrAble {
public int status;
......@@ -25,7 +25,7 @@ public class COMMIT3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -38,7 +38,7 @@ public class COMMIT3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new COMMIT3resok(xdr);
break;
default:
......
......@@ -4,9 +4,9 @@
* See http://remotetea.sourceforge.net for details
*/
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.chimera.nfs.v3.*;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class CREATE3res implements XdrAble {
public int status;
......@@ -25,7 +25,7 @@ public class CREATE3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -38,7 +38,7 @@ public class CREATE3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new CREATE3resok(xdr);
break;
default:
......
......@@ -4,9 +4,9 @@
* See http://remotetea.sourceforge.net for details
*/
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.chimera.nfs.v3.*;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class FSINFO3res implements XdrAble {
public int status;
......@@ -25,7 +25,7 @@ public class FSINFO3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -38,7 +38,7 @@ public class FSINFO3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new FSINFO3resok(xdr);
break;
default:
......
......@@ -4,9 +4,9 @@
* See http://remotetea.sourceforge.net for details
*/
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.chimera.nfs.v3.*;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class FSSTAT3res implements XdrAble {
public int status;
......@@ -25,7 +25,7 @@ public class FSSTAT3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -38,7 +38,7 @@ public class FSSTAT3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new FSSTAT3resok(xdr);
break;
default:
......
......@@ -4,9 +4,9 @@
* See http://remotetea.sourceforge.net for details
*/
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.chimera.nfs.v3.*;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class GETATTR3res implements XdrAble {
public int status;
......@@ -24,7 +24,7 @@ public class GETATTR3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -36,7 +36,7 @@ public class GETATTR3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new GETATTR3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class LINK3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class LINK3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class LINK3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new LINK3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class LOOKUP3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class LOOKUP3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class LOOKUP3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new LOOKUP3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class MKDIR3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class MKDIR3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class MKDIR3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new MKDIR3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class MKNOD3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class MKNOD3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class MKNOD3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new MKNOD3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class PATHCONF3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class PATHCONF3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class PATHCONF3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new PATHCONF3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class READ3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class READ3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class READ3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new READ3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class READDIR3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class READDIR3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class READDIR3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new READDIR3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class READDIRPLUS3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class READDIRPLUS3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class READDIRPLUS3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new READDIRPLUS3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class READLINK3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class READLINK3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class READLINK3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new READLINK3resok(xdr);
break;
default:
......
......@@ -6,6 +6,7 @@
package org.dcache.chimera.nfs.v3.xdr;
import org.dcache.xdr.*;
import java.io.IOException;
import org.dcache.chimera.nfs.nfsstat;
public class REMOVE3res implements XdrAble {
public int status;
......@@ -24,7 +25,7 @@ public class REMOVE3res implements XdrAble {
throws OncRpcException, IOException {
xdr.xdrEncodeInt(status);
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok.xdrEncode(xdr);
break;
default:
......@@ -37,7 +38,7 @@ public class REMOVE3res implements XdrAble {
throws OncRpcException, IOException {
status = xdr.xdrDecodeInt();
switch ( status ) {
case nfsstat3.NFS3_OK:
case nfsstat.NFS_OK:
resok = new REMOVE3resok(xdr);
break;
default:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment