use of com.bonree.brfs.disknode.server.handler.data.DeleteData in project BRFS by zhangnianli.
the class DeleteMessageHandler method handle.
@Override
public void handle(HttpMessage msg, HandleResultCallback callback) {
HandleResult result = new HandleResult();
try {
String filePath = diskContext.getConcreteFilePath(msg.getPath());
Map<String, String> params = msg.getParams();
LOG.info("delete params--{}", params);
DeleteData data = new DeleteData();
data.setForceClose(params.containsKey("force") ? true : false);
data.setRecursive(params.containsKey("recursive") ? true : false);
LOG.info("deleting path[{}], force[{}], recursive[{}]", filePath, data.isForceClose(), data.isRecursive());
File targetFile = new File(filePath);
if (targetFile.isFile()) {
try {
closeFile(targetFile, data.isForceClose());
result.setSuccess(true);
} catch (Exception e) {
result.setSuccess(false);
result.setCause(e);
return;
}
} else {
try {
closeDir(targetFile, data.isRecursive(), data.isForceClose());
result.setSuccess(true);
} catch (Exception e) {
result.setSuccess(false);
result.setCause(e);
return;
}
}
} catch (Exception e) {
LOG.error("delete message error", e);
result.setSuccess(false);
} finally {
callback.completed(result);
}
}
Aggregations