Skip to content
Snippets Groups Projects

refactor(DownloadToken) : use solidify download token & solidify permission service

Merged Hugues.Cazeaux requested to merge HCA-SolidifyDownloadToken into master
All threads resolved!
27 files
+ 158
268
Compare changes
  • Side-by-side
  • Inline
Files
27
@@ -27,40 +27,44 @@ import java.net.URI;
import java.net.URISyntaxException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import ch.unige.solidify.config.SolidifyProperties;
import ch.unige.solidify.model.security.DownloadToken;
import ch.unige.solidify.repository.DownloadTokenRepository;
import ch.unige.solidify.rest.ActionName;
import ch.unige.aou.config.AouProperties;
import ch.unige.aou.controller.AccessController;
import ch.unige.aou.model.settings.DownloadToken;
import ch.unige.aou.controller.AouDownloadTokenController;
import ch.unige.aou.model.security.DownloadTokenType;
import ch.unige.aou.rest.ResourceName;
import ch.unige.aou.rest.UrlPath;
import ch.unige.aou.service.DownloadTokenService;
@RestController
@ConditionalOnBean(AccessController.class)
public class AccessDownloadTokenController {
public class AccessDownloadTokenController extends AouDownloadTokenController {
private final DownloadTokenService downloadTokenService;
private final String accessModulePath;
public AccessDownloadTokenController(AouProperties aouProperties, DownloadTokenService downloadTokenService) throws URISyntaxException {
this.downloadTokenService = downloadTokenService;
public AccessDownloadTokenController(SolidifyProperties solidifyConfig, DownloadTokenRepository downloadTokenRepository,
AouProperties aouProperties) throws URISyntaxException {
super(solidifyConfig, downloadTokenRepository);
this.accessModulePath = new URI(aouProperties.getModule().getAccess().getPublicUrl()).getPath();
}
@GetMapping(UrlPath.ACCESS_METADATA + "/{archiveId}/" + ActionName.DOWNLOAD_TOKEN)
@PreAuthorize("@publicationDownloadPermissionService.isAllowed(#archiveId, 'DOWNLOAD_FILE')")
public ResponseEntity<DownloadToken> getTokenForArchive(@PathVariable String archiveId) {
final String cookiePath = this.accessModulePath + "/" + ResourceName.METADATA + "/" + archiveId + "/" + ActionName.DOWNLOAD;
return new ResponseEntity<>(this.downloadTokenService.getHeadersWithToken(archiveId, cookiePath), HttpStatus.OK);
final String cookiePath = this.accessModulePath
+ "/" + ResourceName.METADATA
+ "/" + archiveId
+ "/" + ActionName.DOWNLOAD;
return this.getToken(archiveId, DownloadTokenType.ARCHIVE, cookiePath);
}
}
Loading