/* * 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; import java.nio.file.Path; import java.util.List; public class FileInfo { private int nodeId; private String osPath; private String virtualPath; private String virtualName; private String fsPath; // actualBasePath differs from base path in db due to some location type // dependent manipulations (performed by FileDAO) private String actualBasePath; private boolean isPublic; private boolean virtualParent; private boolean directory; private boolean link; private String target; private List groupRead; private List groupWrite; private String ownerId; private boolean asyncTrans; private List acceptViews; private List provideViews; private String contentType; private String contentEncoding; private Long contentLength; private String contentMd5; private Integer locationId; private String locationType; private String jobId; public String getTarget() { return target; } public void setTarget(String target) { this.target = target; } public int getNodeId() { return nodeId; } 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; } 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; } public boolean isPublic() { return isPublic; } public void setPublic(boolean isPublic) { 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; } public List getGroupRead() { return groupRead; } public void setGroupRead(List groupRead) { this.groupRead = groupRead; } public List getGroupWrite() { return groupWrite; } public void setGroupWrite(List groupWrite) { this.groupWrite = groupWrite; } public String getOwnerId() { return ownerId; } public void setOwnerId(String ownerId) { this.ownerId = ownerId; } public boolean isAsyncTrans() { return asyncTrans; } public void setAsyncTrans(boolean asyncTrans) { this.asyncTrans = asyncTrans; } public List getAcceptViews() { return acceptViews; } public void setAcceptViews(List acceptViews) { this.acceptViews = acceptViews; } public List getProvideViews() { return provideViews; } public void setProvideViews(List 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("/")); } }