Skip to content
FileInfo.java 5.48 KiB
Newer Older
Sonia Zorba's avatar
Sonia Zorba committed
/*
 * This file is part of vospace-file-service
 * Copyright (C) 2021 Istituto Nazionale di Astrofisica
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package it.inaf.ia2.transfer.persistence.model;
Sonia Zorba's avatar
Sonia Zorba committed

import java.nio.file.Path;
Sonia Zorba's avatar
Sonia Zorba committed
import java.util.List;

public class FileInfo {

    private int nodeId;
    private String osPath;
    private String virtualPath;
    private String fsPath;
    // actualBasePath differs from base path in db due to some location type
    // dependent manipulations (performed by FileDAO)
    private String actualBasePath;    
Sonia Zorba's avatar
Sonia Zorba committed
    private boolean isPublic;
    private boolean virtualParent;
    private boolean directory;
    private boolean link;
    private String target;
Sonia Zorba's avatar
Sonia Zorba committed
    private List<String> groupRead;
    private List<String> groupWrite;
    private String ownerId;
Sonia Zorba's avatar
Sonia Zorba committed
    private boolean asyncTrans;
    private List<String> acceptViews;
    private List<String> provideViews;
    private String contentType;
    private String contentEncoding;
    private Long contentLength;
    private String contentMd5;
    private String jobId;
Sonia Zorba's avatar
Sonia Zorba committed

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public int getNodeId() {
        return nodeId;
Sonia Zorba's avatar
Sonia Zorba committed
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public String getContentEncoding() {
        return contentEncoding;
    }

    public void setContentEncoding(String contentEncoding) {
        this.contentEncoding = contentEncoding;
    }

    public Long getContentLength() {
        return contentLength;
    }

    public void setContentLength(Long contentLength) {
        this.contentLength = contentLength;
    }

    public String getContentMd5() {
        return contentMd5;
    }

    public void setContentMd5(String contentMd5) {
        this.contentMd5 = contentMd5;
    }

    public void setNodeId(int nodeId) {
        this.nodeId = nodeId;
    }

    public String getOsPath() {
        return osPath;
    }

    public void setOsPath(String osPath) {
        this.osPath = osPath;
Sonia Zorba's avatar
Sonia Zorba committed
    }

    public String getVirtualPath() {
        return virtualPath;
    }

    public void setVirtualPath(String virtualPath) {
        this.virtualPath = virtualPath;
    }

    public String getVirtualName() {
        return virtualName;
    }

    public void setVirtualName(String virtualName) {
        this.virtualName = virtualName;
    }

Sonia Zorba's avatar
Sonia Zorba committed
        return isPublic;
    }

    public void setPublic(boolean isPublic) {
Sonia Zorba's avatar
Sonia Zorba committed
        this.isPublic = isPublic;
    }

    public boolean isDirectory() {
        return directory;
    }

    public void setDirectory(boolean directory) {
        this.directory = directory;
    }
    public boolean isLink() {
        return link;
    }

    public void setLink(boolean link) {
        this.link = link;
    }
    public boolean hasVirtualParent() {
        return virtualParent;
    }

    public void setVirtualParent(boolean virtualParent) {
        this.virtualParent = virtualParent;
    }

Sonia Zorba's avatar
Sonia Zorba committed
    public List<String> getGroupRead() {
        return groupRead;
    }

    public void setGroupRead(List<String> groupRead) {
        this.groupRead = groupRead;
    }

    public List<String> getGroupWrite() {
        return groupWrite;
    }

    public void setGroupWrite(List<String> groupWrite) {
        this.groupWrite = groupWrite;
    }

    public String getOwnerId() {
        return ownerId;
    }

    public void setOwnerId(String ownerId) {
        this.ownerId = ownerId;
    }

Sonia Zorba's avatar
Sonia Zorba committed
    public boolean isAsyncTrans() {
        return asyncTrans;
    }

    public void setAsyncTrans(boolean asyncTrans) {
        this.asyncTrans = asyncTrans;
    }

    public List<String> getAcceptViews() {
        return acceptViews;
    }

    public void setAcceptViews(List<String> acceptViews) {
        this.acceptViews = acceptViews;
    }

    public List<String> getProvideViews() {
        return provideViews;
    }

    public void setProvideViews(List<String> provideViews) {
        this.provideViews = provideViews;
    }

    public Integer getLocationId() {
        return locationId;
    }

    public void setLocationId(Integer locationId) {
        this.locationId = locationId;
    }
    public String getLocationType() {
        return locationType;
    }

    public void setLocationType(String locationType) {
        this.locationType = locationType;
    }

    public String getJobId() {
        return jobId;
    }

    public void setJobId(String jobId) {
        this.jobId = jobId;
    }
    public String getFsPath() {
        return fsPath;
    }

    public void setFsPath(String fsPath) {
        this.fsPath = fsPath;
    }

    public String getActualBasePath() {
        return actualBasePath;
    }

    public void setActualBasePath(String actualBasePath) {
        this.actualBasePath = actualBasePath;
    }

    // This function returns the full path of this file on storage
    public String getFilePath() {
        if (this.actualBasePath == null || this.fsPath == null) {
            return null;
        } else {
            return Path.of(this.actualBasePath).resolve(this.fsPath).toString();
        }
    }

    public static String getVosParentPath(FileInfo fileInfo) {
        return fileInfo.getVirtualPath().substring(0, fileInfo.getVirtualPath().lastIndexOf("/"));
Sonia Zorba's avatar
Sonia Zorba committed
}