#24 todo app
This commit is contained in:
@@ -28,7 +28,7 @@ public class FilesServiceImpl implements FilesService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createAppDirectory(App app) {
|
||||
public void createAppDirectoryIfNotExists(App app) {
|
||||
try {
|
||||
this.fileSystemService.createDirectory(resolve(app, Path.of("")));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import de.nbscloud.files.FileSystemService;
|
||||
import de.nbscloud.files.LocationTracker;
|
||||
import de.nbscloud.files.SessionInfo;
|
||||
import de.nbscloud.files.Share;
|
||||
import de.nbscloud.files.api.FilesService.ContentContainer;
|
||||
import de.nbscloud.files.config.FilesConfig;
|
||||
@@ -12,9 +13,9 @@ import de.nbscloud.files.form.PasswordForm;
|
||||
import de.nbscloud.files.form.RenameForm;
|
||||
import de.nbscloud.files.form.ShareForm;
|
||||
import de.nbscloud.webcontainer.MessageHelper;
|
||||
import de.nbscloud.files.SessionInfo;
|
||||
import de.nbscloud.webcontainer.registry.AppRegistry;
|
||||
import de.nbscloud.webcontainer.shared.config.WebContainerSharedConfig;
|
||||
import de.nbscloud.webcontainer.shared.util.ControllerUtils;
|
||||
import org.apache.commons.io.input.ObservableInputStream;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -43,7 +44,6 @@ import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@@ -248,11 +248,6 @@ public class FilesController implements InitializingBean {
|
||||
final Path filePath = this.locationTracker.getRelativeToBaseDir(this.locationTracker.resolve(filename));
|
||||
final String shareUuid = UUID.randomUUID().toString();
|
||||
final Share share = new Share();
|
||||
// The format is always "yyyy-MM-dd", see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
|
||||
final LocalDate expiryDate = Optional.ofNullable(expiryDateString)
|
||||
.map(ed -> ed.isBlank() ? null : ed)
|
||||
.map(ed -> LocalDate.parse(ed, DateTimeFormatter.ofPattern("yyyy-MM-dd")))
|
||||
.orElse(null);
|
||||
|
||||
if(StringUtils.isEmpty(password)) {
|
||||
password = null; // if no real password has been provided assume no password
|
||||
@@ -260,7 +255,7 @@ public class FilesController implements InitializingBean {
|
||||
|
||||
share.setUuid(shareUuid);
|
||||
share.setPath(filePath.toString());
|
||||
share.setExpiryDate(expiryDate);
|
||||
share.setExpiryDate(ControllerUtils.parseDate(expiryDateString));
|
||||
share.setOneTime(oneTime);
|
||||
share.setPassword(password);
|
||||
|
||||
@@ -281,6 +276,10 @@ public class FilesController implements InitializingBean {
|
||||
|
||||
@GetMapping("/files/shares/files/browse/**")
|
||||
public String sharesStart(Model model, HttpServletRequest httpServletRequest, String sortOrder) {
|
||||
if(!this.sessionInfo.isRestrictedSession()) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
final String start = start(model, httpServletRequest, sortOrder);
|
||||
|
||||
model.addAttribute("prefix", "/files/shares");
|
||||
@@ -301,8 +300,6 @@ public class FilesController implements InitializingBean {
|
||||
final Optional<LocalDate> optExpiryDate = Optional.ofNullable(share.getExpiryDate());
|
||||
final boolean expired = optExpiryDate.map(expiryDate -> LocalDate.now().isAfter(expiryDate)).orElse(false);
|
||||
|
||||
this.sessionInfo.setRestrictedSession(true);
|
||||
|
||||
if(share.getPassword() != null) {
|
||||
model.addAttribute("form", new PasswordForm(shareUuid, null));
|
||||
this.webContainerSharedConfig.addDefaults(model);
|
||||
@@ -320,6 +317,8 @@ public class FilesController implements InitializingBean {
|
||||
this.locationTracker.setBaseDirPath(share.getPath());
|
||||
this.locationTracker.resetCurrentLocation();
|
||||
|
||||
this.sessionInfo.setRestrictedSession(true);
|
||||
|
||||
return "redirect:/files/browse/";
|
||||
}
|
||||
else {
|
||||
@@ -354,6 +353,8 @@ public class FilesController implements InitializingBean {
|
||||
this.locationTracker.setBaseDirPath(share.getPath());
|
||||
this.locationTracker.resetCurrentLocation();
|
||||
|
||||
this.sessionInfo.setRestrictedSession(true);
|
||||
|
||||
return "redirect:/files/browse/";
|
||||
}
|
||||
else {
|
||||
@@ -408,6 +409,10 @@ public class FilesController implements InitializingBean {
|
||||
|
||||
@GetMapping("/files/shares/files/preview")
|
||||
public void sharesPreview(HttpServletResponse response, String filename) {
|
||||
if(!this.sessionInfo.isRestrictedSession()) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
preview(response, filename);
|
||||
}
|
||||
|
||||
@@ -426,6 +431,10 @@ public class FilesController implements InitializingBean {
|
||||
|
||||
@GetMapping("/files/shares/files/gallery")
|
||||
public String sharesGallery(Model model) {
|
||||
if(!this.sessionInfo.isRestrictedSession()) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
final String gallery = gallery(model);
|
||||
|
||||
model.addAttribute("prefix", "/files/shares");
|
||||
|
||||
Reference in New Issue
Block a user