|
@@ -24,8 +24,10 @@ import java.io.OutputStream;
|
|
import java.io.PrintStream;
|
|
import java.io.PrintStream;
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
import java.net.URISyntaxException;
|
|
import java.net.URISyntaxException;
|
|
|
|
+import java.security.PrivilegedExceptionAction;
|
|
|
|
|
|
import javax.servlet.ServletContext;
|
|
import javax.servlet.ServletContext;
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import javax.ws.rs.Consumes;
|
|
import javax.ws.rs.Consumes;
|
|
import javax.ws.rs.DELETE;
|
|
import javax.ws.rs.DELETE;
|
|
import javax.ws.rs.DefaultValue;
|
|
import javax.ws.rs.DefaultValue;
|
|
@@ -47,6 +49,7 @@ import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
|
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
|
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
|
|
+import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager;
|
|
import org.apache.hadoop.hdfs.server.namenode.JspHelper;
|
|
import org.apache.hadoop.hdfs.server.namenode.JspHelper;
|
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
|
import org.apache.hadoop.hdfs.web.JsonUtil;
|
|
import org.apache.hadoop.hdfs.web.JsonUtil;
|
|
@@ -54,6 +57,7 @@ import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
|
|
import org.apache.hadoop.hdfs.web.resources.AccessTimeParam;
|
|
import org.apache.hadoop.hdfs.web.resources.AccessTimeParam;
|
|
import org.apache.hadoop.hdfs.web.resources.BlockSizeParam;
|
|
import org.apache.hadoop.hdfs.web.resources.BlockSizeParam;
|
|
import org.apache.hadoop.hdfs.web.resources.BufferSizeParam;
|
|
import org.apache.hadoop.hdfs.web.resources.BufferSizeParam;
|
|
|
|
+import org.apache.hadoop.hdfs.web.resources.DelegationParam;
|
|
import org.apache.hadoop.hdfs.web.resources.DeleteOpParam;
|
|
import org.apache.hadoop.hdfs.web.resources.DeleteOpParam;
|
|
import org.apache.hadoop.hdfs.web.resources.DstPathParam;
|
|
import org.apache.hadoop.hdfs.web.resources.DstPathParam;
|
|
import org.apache.hadoop.hdfs.web.resources.GetOpParam;
|
|
import org.apache.hadoop.hdfs.web.resources.GetOpParam;
|
|
@@ -71,6 +75,13 @@ import org.apache.hadoop.hdfs.web.resources.PutOpParam;
|
|
import org.apache.hadoop.hdfs.web.resources.RecursiveParam;
|
|
import org.apache.hadoop.hdfs.web.resources.RecursiveParam;
|
|
import org.apache.hadoop.hdfs.web.resources.ReplicationParam;
|
|
import org.apache.hadoop.hdfs.web.resources.ReplicationParam;
|
|
import org.apache.hadoop.hdfs.web.resources.UriFsPathParam;
|
|
import org.apache.hadoop.hdfs.web.resources.UriFsPathParam;
|
|
|
|
+import org.apache.hadoop.hdfs.web.resources.UserParam;
|
|
|
|
+import org.apache.hadoop.io.Text;
|
|
|
|
+import org.apache.hadoop.security.Credentials;
|
|
|
|
+import org.apache.hadoop.security.SecurityUtil;
|
|
|
|
+import org.apache.hadoop.security.UserGroupInformation;
|
|
|
|
+import org.apache.hadoop.security.token.Token;
|
|
|
|
+import org.apache.hadoop.security.token.TokenIdentifier;
|
|
|
|
|
|
/** Web-hdfs NameNode implementation. */
|
|
/** Web-hdfs NameNode implementation. */
|
|
@Path("")
|
|
@Path("")
|
|
@@ -78,6 +89,7 @@ public class NamenodeWebHdfsMethods {
|
|
private static final Log LOG = LogFactory.getLog(NamenodeWebHdfsMethods.class);
|
|
private static final Log LOG = LogFactory.getLog(NamenodeWebHdfsMethods.class);
|
|
|
|
|
|
private @Context ServletContext context;
|
|
private @Context ServletContext context;
|
|
|
|
+ private @Context HttpServletRequest request;
|
|
|
|
|
|
private static DatanodeInfo chooseDatanode(final NameNode namenode,
|
|
private static DatanodeInfo chooseDatanode(final NameNode namenode,
|
|
final String path, final HttpOpParam.Op op, final long openOffset
|
|
final String path, final HttpOpParam.Op op, final long openOffset
|
|
@@ -104,11 +116,40 @@ public class NamenodeWebHdfsMethods {
|
|
return namenode.getNamesystem().getRandomDatanode();
|
|
return namenode.getNamesystem().getRandomDatanode();
|
|
}
|
|
}
|
|
|
|
|
|
- private static URI redirectURI(final NameNode namenode,
|
|
|
|
|
|
+ private Token<? extends TokenIdentifier> generateDelegationToken(
|
|
|
|
+ final NameNode namenode, final UserGroupInformation ugi,
|
|
|
|
+ final String renewer) throws IOException {
|
|
|
|
+ final Credentials c = DelegationTokenSecretManager.createCredentials(
|
|
|
|
+ namenode, ugi, request.getUserPrincipal().getName());
|
|
|
|
+ final Token<? extends TokenIdentifier> t = c.getAllTokens().iterator().next();
|
|
|
|
+ t.setService(new Text(SecurityUtil.buildDTServiceName(
|
|
|
|
+ NameNode.getUri(namenode.getNameNodeAddress()),
|
|
|
|
+ NameNode.DEFAULT_PORT)));
|
|
|
|
+ return t;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private URI redirectURI(final NameNode namenode,
|
|
|
|
+ final UserGroupInformation ugi, final DelegationParam delegation,
|
|
final String path, final HttpOpParam.Op op, final long openOffset,
|
|
final String path, final HttpOpParam.Op op, final long openOffset,
|
|
final Param<?, ?>... parameters) throws URISyntaxException, IOException {
|
|
final Param<?, ?>... parameters) throws URISyntaxException, IOException {
|
|
final DatanodeInfo dn = chooseDatanode(namenode, path, op, openOffset);
|
|
final DatanodeInfo dn = chooseDatanode(namenode, path, op, openOffset);
|
|
- final String query = op.toQueryString() + Param.toSortedString("&", parameters);
|
|
|
|
|
|
+
|
|
|
|
+ final String delegationQuery;
|
|
|
|
+ if (!UserGroupInformation.isSecurityEnabled()) {
|
|
|
|
+ //security disabled
|
|
|
|
+ delegationQuery = "";
|
|
|
|
+ } else if (delegation.getValue() != null) {
|
|
|
|
+ //client has provided a token
|
|
|
|
+ delegationQuery = "&" + delegation;
|
|
|
|
+ } else {
|
|
|
|
+ //generate a token
|
|
|
|
+ final Token<? extends TokenIdentifier> t = generateDelegationToken(
|
|
|
|
+ namenode, ugi, request.getUserPrincipal().getName());
|
|
|
|
+ delegationQuery = "&" + new DelegationParam(t.encodeToUrlString());
|
|
|
|
+ }
|
|
|
|
+ final String query = op.toQueryString()
|
|
|
|
+ + '&' + new UserParam(ugi) + delegationQuery
|
|
|
|
+ + Param.toSortedString("&", parameters);
|
|
final String uripath = "/" + WebHdfsFileSystem.PATH_PREFIX + path;
|
|
final String uripath = "/" + WebHdfsFileSystem.PATH_PREFIX + path;
|
|
|
|
|
|
final URI uri = new URI("http", null, dn.getHostName(), dn.getInfoPort(),
|
|
final URI uri = new URI("http", null, dn.getHostName(), dn.getInfoPort(),
|
|
@@ -126,6 +167,9 @@ public class NamenodeWebHdfsMethods {
|
|
@Produces({MediaType.APPLICATION_JSON})
|
|
@Produces({MediaType.APPLICATION_JSON})
|
|
public Response put(
|
|
public Response put(
|
|
final InputStream in,
|
|
final InputStream in,
|
|
|
|
+ @Context final UserGroupInformation ugi,
|
|
|
|
+ @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
|
|
|
|
+ final DelegationParam delegation,
|
|
@PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
|
|
@PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
|
|
@QueryParam(PutOpParam.NAME) @DefaultValue(PutOpParam.DEFAULT)
|
|
@QueryParam(PutOpParam.NAME) @DefaultValue(PutOpParam.DEFAULT)
|
|
final PutOpParam op,
|
|
final PutOpParam op,
|
|
@@ -149,22 +193,27 @@ public class NamenodeWebHdfsMethods {
|
|
final ModificationTimeParam modificationTime,
|
|
final ModificationTimeParam modificationTime,
|
|
@QueryParam(AccessTimeParam.NAME) @DefaultValue(AccessTimeParam.DEFAULT)
|
|
@QueryParam(AccessTimeParam.NAME) @DefaultValue(AccessTimeParam.DEFAULT)
|
|
final AccessTimeParam accessTime
|
|
final AccessTimeParam accessTime
|
|
- ) throws IOException, URISyntaxException {
|
|
|
|
|
|
+ ) throws IOException, URISyntaxException, InterruptedException {
|
|
|
|
|
|
if (LOG.isTraceEnabled()) {
|
|
if (LOG.isTraceEnabled()) {
|
|
- LOG.trace(op + ": " + path
|
|
|
|
|
|
+ LOG.trace(op + ": " + path + ", ugi=" + ugi
|
|
+ Param.toSortedString(", ", dstPath, owner, group, permission,
|
|
+ Param.toSortedString(", ", dstPath, owner, group, permission,
|
|
overwrite, bufferSize, replication, blockSize,
|
|
overwrite, bufferSize, replication, blockSize,
|
|
modificationTime, accessTime));
|
|
modificationTime, accessTime));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Response run() throws IOException, URISyntaxException {
|
|
|
|
+
|
|
final String fullpath = path.getAbsolutePath();
|
|
final String fullpath = path.getAbsolutePath();
|
|
final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
|
|
|
|
switch(op.getValue()) {
|
|
switch(op.getValue()) {
|
|
case CREATE:
|
|
case CREATE:
|
|
{
|
|
{
|
|
- final URI uri = redirectURI(namenode, fullpath, op.getValue(), -1L,
|
|
|
|
|
|
+ final URI uri = redirectURI(namenode, ugi, delegation, fullpath,
|
|
|
|
+ op.getValue(), -1L,
|
|
permission, overwrite, bufferSize, replication, blockSize);
|
|
permission, overwrite, bufferSize, replication, blockSize);
|
|
return Response.temporaryRedirect(uri).build();
|
|
return Response.temporaryRedirect(uri).build();
|
|
}
|
|
}
|
|
@@ -204,6 +253,8 @@ public class NamenodeWebHdfsMethods {
|
|
default:
|
|
default:
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
/** Handle HTTP POST request. */
|
|
/** Handle HTTP POST request. */
|
|
@@ -213,31 +264,40 @@ public class NamenodeWebHdfsMethods {
|
|
@Produces({MediaType.APPLICATION_JSON})
|
|
@Produces({MediaType.APPLICATION_JSON})
|
|
public Response post(
|
|
public Response post(
|
|
final InputStream in,
|
|
final InputStream in,
|
|
|
|
+ @Context final UserGroupInformation ugi,
|
|
|
|
+ @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
|
|
|
|
+ final DelegationParam delegation,
|
|
@PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
|
|
@PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
|
|
@QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
|
|
@QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
|
|
final PostOpParam op,
|
|
final PostOpParam op,
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
final BufferSizeParam bufferSize
|
|
final BufferSizeParam bufferSize
|
|
- ) throws IOException, URISyntaxException {
|
|
|
|
|
|
+ ) throws IOException, URISyntaxException, InterruptedException {
|
|
|
|
|
|
if (LOG.isTraceEnabled()) {
|
|
if (LOG.isTraceEnabled()) {
|
|
- LOG.trace(op + ": " + path
|
|
|
|
- + Param.toSortedString(", ", bufferSize));
|
|
|
|
|
|
+ LOG.trace(op + ": " + path + ", ugi=" + ugi
|
|
|
|
+ + Param.toSortedString(", ", bufferSize));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Response run() throws IOException, URISyntaxException {
|
|
|
|
+
|
|
final String fullpath = path.getAbsolutePath();
|
|
final String fullpath = path.getAbsolutePath();
|
|
final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
|
|
|
|
switch(op.getValue()) {
|
|
switch(op.getValue()) {
|
|
case APPEND:
|
|
case APPEND:
|
|
{
|
|
{
|
|
- final URI uri = redirectURI(namenode, fullpath, op.getValue(), -1L,
|
|
|
|
- bufferSize);
|
|
|
|
|
|
+ final URI uri = redirectURI(namenode, ugi, delegation, fullpath,
|
|
|
|
+ op.getValue(), -1L, bufferSize);
|
|
return Response.temporaryRedirect(uri).build();
|
|
return Response.temporaryRedirect(uri).build();
|
|
}
|
|
}
|
|
default:
|
|
default:
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
private static final UriFsPathParam ROOT = new UriFsPathParam("");
|
|
private static final UriFsPathParam ROOT = new UriFsPathParam("");
|
|
@@ -247,6 +307,9 @@ public class NamenodeWebHdfsMethods {
|
|
@Path("/")
|
|
@Path("/")
|
|
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
|
|
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
|
|
public Response root(
|
|
public Response root(
|
|
|
|
+ @Context final UserGroupInformation ugi,
|
|
|
|
+ @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
|
|
|
|
+ final DelegationParam delegation,
|
|
@QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
|
|
@QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
|
|
final GetOpParam op,
|
|
final GetOpParam op,
|
|
@QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
|
|
@QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
|
|
@@ -255,8 +318,8 @@ public class NamenodeWebHdfsMethods {
|
|
final LengthParam length,
|
|
final LengthParam length,
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
final BufferSizeParam bufferSize
|
|
final BufferSizeParam bufferSize
|
|
- ) throws IOException, URISyntaxException {
|
|
|
|
- return get(ROOT, op, offset, length, bufferSize);
|
|
|
|
|
|
+ ) throws IOException, URISyntaxException, InterruptedException {
|
|
|
|
+ return get(ugi, delegation, ROOT, op, offset, length, bufferSize);
|
|
}
|
|
}
|
|
|
|
|
|
/** Handle HTTP GET request. */
|
|
/** Handle HTTP GET request. */
|
|
@@ -264,6 +327,9 @@ public class NamenodeWebHdfsMethods {
|
|
@Path("{" + UriFsPathParam.NAME + ":.*}")
|
|
@Path("{" + UriFsPathParam.NAME + ":.*}")
|
|
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
|
|
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
|
|
public Response get(
|
|
public Response get(
|
|
|
|
+ @Context final UserGroupInformation ugi,
|
|
|
|
+ @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
|
|
|
|
+ final DelegationParam delegation,
|
|
@PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
|
|
@PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
|
|
@QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
|
|
@QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
|
|
final GetOpParam op,
|
|
final GetOpParam op,
|
|
@@ -273,21 +339,26 @@ public class NamenodeWebHdfsMethods {
|
|
final LengthParam length,
|
|
final LengthParam length,
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
final BufferSizeParam bufferSize
|
|
final BufferSizeParam bufferSize
|
|
- ) throws IOException, URISyntaxException {
|
|
|
|
|
|
+ ) throws IOException, URISyntaxException, InterruptedException {
|
|
|
|
|
|
if (LOG.isTraceEnabled()) {
|
|
if (LOG.isTraceEnabled()) {
|
|
- LOG.trace(op + ", " + path
|
|
|
|
|
|
+ LOG.trace(op + ": " + path + ", ugi=" + ugi
|
|
+ Param.toSortedString(", ", offset, length, bufferSize));
|
|
+ Param.toSortedString(", ", offset, length, bufferSize));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Response run() throws IOException, URISyntaxException {
|
|
|
|
+
|
|
final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
final String fullpath = path.getAbsolutePath();
|
|
final String fullpath = path.getAbsolutePath();
|
|
|
|
|
|
switch(op.getValue()) {
|
|
switch(op.getValue()) {
|
|
case OPEN:
|
|
case OPEN:
|
|
{
|
|
{
|
|
- final URI uri = redirectURI(namenode, fullpath, op.getValue(),
|
|
|
|
- offset.getValue(), offset, length, bufferSize);
|
|
|
|
|
|
+ final URI uri = redirectURI(namenode, ugi, delegation, fullpath,
|
|
|
|
+ op.getValue(), offset.getValue(), offset, length, bufferSize);
|
|
return Response.temporaryRedirect(uri).build();
|
|
return Response.temporaryRedirect(uri).build();
|
|
}
|
|
}
|
|
case GETFILESTATUS:
|
|
case GETFILESTATUS:
|
|
@@ -304,6 +375,8 @@ public class NamenodeWebHdfsMethods {
|
|
default:
|
|
default:
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
private static DirectoryListing getDirectoryListing(final NameNode np,
|
|
private static DirectoryListing getDirectoryListing(final NameNode np,
|
|
@@ -353,28 +426,36 @@ public class NamenodeWebHdfsMethods {
|
|
@Path("{path:.*}")
|
|
@Path("{path:.*}")
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
public Response delete(
|
|
public Response delete(
|
|
|
|
+ @Context final UserGroupInformation ugi,
|
|
@PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
|
|
@PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
|
|
@QueryParam(DeleteOpParam.NAME) @DefaultValue(DeleteOpParam.DEFAULT)
|
|
@QueryParam(DeleteOpParam.NAME) @DefaultValue(DeleteOpParam.DEFAULT)
|
|
final DeleteOpParam op,
|
|
final DeleteOpParam op,
|
|
@QueryParam(RecursiveParam.NAME) @DefaultValue(RecursiveParam.DEFAULT)
|
|
@QueryParam(RecursiveParam.NAME) @DefaultValue(RecursiveParam.DEFAULT)
|
|
final RecursiveParam recursive
|
|
final RecursiveParam recursive
|
|
- ) throws IOException {
|
|
|
|
|
|
+ ) throws IOException, InterruptedException {
|
|
|
|
|
|
if (LOG.isTraceEnabled()) {
|
|
if (LOG.isTraceEnabled()) {
|
|
- LOG.trace(op + ", " + path
|
|
|
|
- + Param.toSortedString(", ", recursive));
|
|
|
|
|
|
+ LOG.trace(op + ": " + path + ", ugi=" + ugi
|
|
|
|
+ + Param.toSortedString(", ", recursive));
|
|
}
|
|
}
|
|
|
|
|
|
- switch(op.getValue()) {
|
|
|
|
- case DELETE:
|
|
|
|
- final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
|
|
- final String fullpath = path.getAbsolutePath();
|
|
|
|
- final boolean b = namenode.delete(fullpath, recursive.getValue());
|
|
|
|
- final String js = JsonUtil.toJsonString(DeleteOpParam.Op.DELETE, b);
|
|
|
|
- return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
|
|
|
|
-
|
|
|
|
- default:
|
|
|
|
- throw new UnsupportedOperationException(op + " is not supported");
|
|
|
|
- }
|
|
|
|
|
|
+ return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Response run() throws IOException {
|
|
|
|
+ final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
|
|
+ final String fullpath = path.getAbsolutePath();
|
|
|
|
+
|
|
|
|
+ switch(op.getValue()) {
|
|
|
|
+ case DELETE:
|
|
|
|
+ {
|
|
|
|
+ final boolean b = namenode.delete(fullpath, recursive.getValue());
|
|
|
|
+ final String js = JsonUtil.toJsonString(DeleteOpParam.Op.DELETE, b);
|
|
|
|
+ return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
|
|
|
|
+ }
|
|
|
|
+ default:
|
|
|
|
+ throw new UnsupportedOperationException(op + " is not supported");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|