
io.github.qsy7.remote.impl.plugins.file.handler.DeleteFileMessageCallable Maven / Gradle / Ivy
The newest version!
package io.github.qsy7.remote.impl.plugins.file.handler;
import io.github.qsy7.file.api.service.FileStorageService;
import io.github.qsy7.remote.impl.plugins.file.message.DeleteFileMessage;
import java.io.IOException;
import jakarta.inject.Inject;
import org.apache.commons.io.FileUtils;
// import io.github.qsy7.queue.api.queuedJob.AbstractJobRunnable;
public class DeleteFileMessageCallable /* extends AbstractRunnable*/ {
protected final FileStorageService fileStorageService;
@Inject
public DeleteFileMessageCallable(FileStorageService fileStorageService) {
this.fileStorageService = fileStorageService;
}
protected void deleteFile(DeleteFileMessage deleteFileMessage) throws IOException {
final java.io.File target = new java.io.File(deleteFileMessage.getTarget());
if (target.isDirectory()) {
FileUtils.deleteDirectory(target);
} else if (target.isFile()) {
FileUtils.deleteQuietly(target);
} else {
throw new IllegalStateException("Target (" + target.getAbsolutePath() + ") already exists.");
}
}
// @Override
// protected boolean isRetryable(Throwable thrown) {
// return false;
// }
//
// @Override
// public Void call() throws Exception {
// deleteFile(entity);
//
// return null;
// }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy