All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sippnex.fileblade.dtos.FileDto Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.sippnex.fileblade.dtos;

import com.sippnex.fileblade.entities.File;

public class FileDto extends FilebladeItemDto {

    private String downloadUrl;

    public String getDownloadUrl() {
        return downloadUrl;
    }

    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }

    public static FileDto parse(File file, String serverBaseUrl) {
        FileDto fileDto = new FileDto();
        fileDto.setId(file.getId());
        fileDto.setName(file.getName());
        fileDto.setPath(file.getPath());
        fileDto.setDownloadUrl(serverBaseUrl + "/fileblade/download/" + fileDto.getPath().substring(1).replace("/", "+"));
        if (file.getParentDirectory() != null) {
            fileDto.setParentDirectoryId(file.getParentDirectory().getId());
        } else {
            fileDto.setParentDirectoryId((long)0);
        }
        fileDto.setType(Type.File);
        return fileDto;
    }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy