aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2019-08-21 07:33:47 +0200
committerMartin Stockhammer <martin_s@apache.org>2019-08-21 07:33:47 +0200
commitf10055958657b1ebf47e664d8d240afe2b200f0f (patch)
tree64ed89aeda016b6a422dbf21210a93a37b24b16f /archiva-modules
parentcda4ac8085f840060ced0163d21f1e34407411d8 (diff)
downloadarchiva-f10055958657b1ebf47e664d8d240afe2b200f0f.tar.gz
archiva-f10055958657b1ebf47e664d8d240afe2b200f0f.zip
Changing time type for modification time
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java14
-rw-r--r--archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java9
-rw-r--r--archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java2
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java3
4 files changed, 16 insertions, 12 deletions
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java
index a26167c86..c129d1ed8 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java
@@ -20,7 +20,11 @@ package org.apache.archiva.metadata.model;
*/
import javax.xml.bind.annotation.XmlRootElement;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
import java.time.ZonedDateTime;
+import java.time.temporal.TemporalAccessor;
import java.util.Date;
/**
@@ -77,7 +81,7 @@ public class ArtifactMetadata
/**
* The last modified date of the artifact file, if known.
*/
- private Date fileLastModified;
+ private ZonedDateTime fileLastModified;
/**
* The file size of the artifact, if known.
@@ -141,7 +145,7 @@ public class ArtifactMetadata
public void setFileLastModified( long fileLastModified )
{
- this.fileLastModified = new Date( fileLastModified );
+ this.fileLastModified = ZonedDateTime.ofInstant(Instant.ofEpochMilli(fileLastModified), ZoneId.of("GMT"));
}
public void setWhenGathered( ZonedDateTime whenGathered )
@@ -174,7 +178,7 @@ public class ArtifactMetadata
return sha1;
}
- public Date getFileLastModified()
+ public ZonedDateTime getFileLastModified()
{
return fileLastModified;
@@ -228,9 +232,9 @@ public class ArtifactMetadata
{
return false;
}
- // We allow some
+ // Time equality by instant that means the point in time must match, but not the time zone
if ( fileLastModified != null
- ? !fileLastModified.equals( that.fileLastModified )
+ ? !fileLastModified.toInstant().equals( that.fileLastModified.toInstant() )
: that.fileLastModified != null )
{
return false;
diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
index 2b84b0d34..aefa51dd6 100644
--- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
@@ -70,6 +70,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Instant;
+import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
@@ -1337,7 +1338,7 @@ public class CassandraMetadataRepository
{
// updater
ColumnFamilyUpdater<String, String> updater = this.artifactMetadataTemplate.createUpdater( key );
- updater.setLong( FILE_LAST_MODIFIED.toString(), artifactMeta.getFileLastModified().getTime() );
+ updater.setLong( FILE_LAST_MODIFIED.toString(), artifactMeta.getFileLastModified().toInstant().toEpochMilli());
updater.setLong( WHEN_GATHERED.toString(), artifactMeta.getWhenGathered().toInstant().toEpochMilli() );
updater.setLong( SIZE.toString(), artifactMeta.getSize() );
addUpdateStringValue( updater, MD5.toString(), artifactMeta.getMd5() );
@@ -1356,7 +1357,7 @@ public class CassandraMetadataRepository
.addInsertion( key, cf, column( PROJECT.toString(), artifactMeta.getProject() ) ) //
.addInsertion( key, cf, column( PROJECT_VERSION.toString(), projectVersion ) ) //
.addInsertion( key, cf, column( VERSION.toString(), artifactMeta.getVersion() ) ) //
- .addInsertion( key, cf, column( FILE_LAST_MODIFIED.toString(), artifactMeta.getFileLastModified().getTime() ) ) //
+ .addInsertion( key, cf, column( FILE_LAST_MODIFIED.toString(), artifactMeta.getFileLastModified().toInstant().toEpochMilli() ) ) //
.addInsertion( key, cf, column( SIZE.toString(), artifactMeta.getSize() ) ) //
.addInsertion( key, cf, column( MD5.toString(), artifactMeta.getMd5() ) ) //
.addInsertion( key, cf, column( SHA1.toString(), artifactMeta.getSha1() ) ) //
@@ -1407,8 +1408,8 @@ public class CassandraMetadataRepository
artifactMetadataModel.setProjectVersion( projectVersion );
artifactMetadataModel.setVersion( artifactMeta.getVersion() );
artifactMetadataModel.setFileLastModified( artifactMeta.getFileLastModified() == null
- ? new Date().getTime()
- : artifactMeta.getFileLastModified().getTime() );
+ ? ZonedDateTime.now().toInstant().toEpochMilli()
+ : artifactMeta.getFileLastModified().toInstant().toEpochMilli() );
// now facets
updateFacets( artifactMeta, artifactMetadataModel );
diff --git a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
index 48b0dfeee..da7007e9c 100644
--- a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
@@ -951,7 +951,7 @@ public class FileMetadataRepository
String id = artifact.getId();
properties.setProperty( "artifact:updated:" + id,
- Long.toString( artifact.getFileLastModified().getTime() ) );
+ Long.toString( artifact.getFileLastModified().toInstant().toEpochMilli()) );
properties.setProperty( "artifact:whenGathered:" + id,
Long.toString( artifact.getWhenGathered().toInstant().toEpochMilli()) );
properties.setProperty( "artifact:size:" + id, Long.toString( artifact.getSize() ) );
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
index 7ee48d083..404762daf 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
@@ -203,8 +203,7 @@ public class JcrMetadataRepository
getOrAddArtifactNode( jcrSession, repositoryId, namespace, projectId, projectVersion, artifactMeta.getId() );
node.setProperty( "id", artifactMeta.getId( ) );
- Calendar cal = Calendar.getInstance();
- cal.setTime( artifactMeta.getFileLastModified() );
+ Calendar cal = GregorianCalendar.from(artifactMeta.getFileLastModified());
node.setProperty( JCR_LAST_MODIFIED, cal );
cal = GregorianCalendar.from(artifactMeta.getWhenGathered());