在Artifactory中,当存储库中的artifact的元数据发生更改时,即使文件内容没有更改,也会更新相关信息。这些信息包括'lastModified”和'lastUpdated”。
'lastModified”代表文件的最后修改时间戳,指的是在存储库中上载artifact文件的时间戳。
'lastUpdated”代表元数据的最后修改时间戳,指的是存储库元数据上次更新的时间戳。
以下是Java代码示例,可以使用Artifactory API来获取artifact的最后修改时间戳和元数据的最后修改时间戳:
import org.jfrog.artifactory.client.Artifactory;
import org.jfrog.artifactory.client.ArtifactoryClient;
import org.jfrog.artifactory.client.ArtifactoryRequest;
import org.jfrog.artifactory.client.ArtifactoryResponse;
public class ArtifactoryExample {
public static void main(String[] args) {
String repoUrl = "http://localhost:8081/artifactory";
String repoName = "libs-release-local";
String artifactPath = "com/example/my-library/1.0.0/my-library-1.0.0.jar";
// Create Artifactory client
Artifactory artifactory = ArtifactoryClient.create(repoUrl, "username", "password");
// Request the artifact info
ArtifactoryRequest request = new ArtifactoryRequest.Builder()
.method(ArtifactoryRequest.Method.GET)
.apiUrl(String.format("%s/%s/%s", repoUrl, repoName, artifactPath))
.build();
ArtifactoryResponse response = artifactory.restCall(request);
// Get the last modified and last updated timestamps
long lastModified = response.getLastModified();
long lastUpdated = response.getLastUpdated();
System.out.println("Last Modified: " + lastModified);
System.out.println("Last Updated: " + lastUpdated);
}
}