use of org.apache.hadoop.registry.client.exceptions.NoPathPermissionsException in project hadoop by apache.
the class CuratorService method operationFailure.
/**
* Create an IOE when an operation fails
* @param path path of operation
* @param operation operation attempted
* @param exception caught the exception caught
* @return an IOE to throw that contains the path and operation details.
*/
protected IOException operationFailure(String path, String operation, Exception exception, List<ACL> acls) {
IOException ioe;
String aclList = "[" + RegistrySecurity.aclsToString(acls) + "]";
if (exception instanceof KeeperException.NoNodeException) {
ioe = new PathNotFoundException(path);
} else if (exception instanceof KeeperException.NodeExistsException) {
ioe = new FileAlreadyExistsException(path);
} else if (exception instanceof KeeperException.NoAuthException) {
ioe = new NoPathPermissionsException(path, "Not authorized to access path; ACLs: " + aclList);
} else if (exception instanceof KeeperException.NotEmptyException) {
ioe = new PathIsNotEmptyDirectoryException(path);
} else if (exception instanceof KeeperException.AuthFailedException) {
ioe = new AuthenticationFailedException(path, "Authentication Failed: " + exception + "; " + securityConnectionDiagnostics, exception);
} else if (exception instanceof KeeperException.NoChildrenForEphemeralsException) {
ioe = new NoChildrenForEphemeralsException(path, "Cannot create a path under an ephemeral node: " + exception, exception);
} else if (exception instanceof KeeperException.InvalidACLException) {
// this is a security exception of a kind
// include the ACLs to help the diagnostics
StringBuilder builder = new StringBuilder();
builder.append("Path access failure ").append(aclList);
builder.append(" ");
builder.append(securityConnectionDiagnostics);
ioe = new NoPathPermissionsException(path, builder.toString());
} else {
ioe = new RegistryIOException(path, "Failure of " + operation + " on " + path + ": " + exception.toString(), exception);
}
if (ioe.getCause() == null) {
ioe.initCause(exception);
}
return ioe;
}
use of org.apache.hadoop.registry.client.exceptions.NoPathPermissionsException in project hadoop by apache.
the class CuratorService method zkMkPath.
/**
* Create a directory. It is not an error if it already exists
* @param path path to create
* @param mode mode for path
* @param createParents flag to trigger parent creation
* @param acls ACL for path
* @throws IOException any problem
*/
public boolean zkMkPath(String path, CreateMode mode, boolean createParents, List<ACL> acls) throws IOException {
checkServiceLive();
path = createFullPath(path);
if (acls == null || acls.isEmpty()) {
throw new NoPathPermissionsException(path, "Empty ACL list");
}
try {
RegistrySecurity.AclListInfo aclInfo = new RegistrySecurity.AclListInfo(acls);
if (LOG.isDebugEnabled()) {
LOG.debug("Creating path {} with mode {} and ACL {}", path, mode, aclInfo);
}
CreateBuilder createBuilder = curator.create();
createBuilder.withMode(mode).withACL(acls);
if (createParents) {
createBuilder.creatingParentsIfNeeded();
}
createBuilder.forPath(path);
} catch (KeeperException.NodeExistsException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("path already present: {}", path, e);
}
return false;
} catch (Exception e) {
throw operationFailure(path, "mkdir() ", e, acls);
}
return true;
}
Aggregations