• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Commonjava / indy-tracking-service / 44786446415

20 Nov 2026 05:46PM UTC coverage: 37.562% (-29.5%) from 67.036%
44786446415

push

github

rnc
Bump org.commonjava.atlas:atlas-relationships-api from 1.2.2 to 1.2.3

Bumps [org.commonjava.atlas:atlas-relationships-api](https://github.com/Commonjava/atlas) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/Commonjava/atlas/releases)
- [Commits](https://github.com/Commonjava/atlas/compare/atlas-parent-1.2.2...atlas-parent-1.2.3)

---
updated-dependencies:
- dependency-name: org.commonjava.atlas:atlas-relationships-api
  dependency-version: 1.2.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

678 of 1805 relevant lines covered (37.56%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.03
/src/main/java/org/commonjava/indy/service/tracking/model/TrackedContentEntry.java
1
/**
2
 * Copyright (C) 2022-2023 Red Hat, Inc. (https://github.com/Commonjava/indy-tracking-service)
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *         http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package org.commonjava.indy.service.tracking.model;
17

18
import java.io.Externalizable;
19
import java.io.IOException;
20
import java.io.ObjectInput;
21
import java.io.ObjectOutput;
22
import java.util.Collections;
23
import java.util.HashSet;
24
import java.util.Set;
25

26
import static org.commonjava.indy.service.tracking.model.AccessChannel.GENERIC_PROXY;
27
import static org.commonjava.indy.service.tracking.model.pkg.PackageTypeConstants.PKG_TYPE_GENERIC_HTTP;
28
import static org.commonjava.indy.service.tracking.model.pkg.PackageTypeConstants.PKG_TYPE_MAVEN;
29

30
public class TrackedContentEntry
31
                implements Comparable<TrackedContentEntry>, Externalizable
32
{
33
    private static final long serialVersionUID = 6469004486206600578L;
34

35
    private static final int VERSION = 3;
36

37
    private TrackingKey trackingKey;
38

39
    private StoreKey storeKey;
40

41
    private AccessChannel accessChannel;
42

43
    private String path;
44

45
    private String originUrl;
46

47
    private StoreEffect effect;
48

49
    private String md5;
50

51
    private String sha256;
52

53
    private String sha1;
54

55
    private Long size;
56

57
    private long index = System.currentTimeMillis();
2 ✔
58

59
    private Set<Long> timestamps;
60

61
    public TrackedContentEntry()
62
    {
2 ✔
63
    }
2 ✔
64

65
    public TrackedContentEntry( final TrackingKey trackingKey, final StoreKey storeKey,
66
                                final AccessChannel accessChannel, final String originUrl, final String path,
67
                                final StoreEffect effect, final Long size, final String md5, final String sha1,
68
                                final String sha256 )
69
    {
2 ✔
70
        this.trackingKey = trackingKey;
2 ✔
71
        this.storeKey = storeKey;
2 ✔
72
        this.accessChannel = accessChannel;
2 ✔
73
        this.path = path;
2 ✔
74
        this.originUrl = originUrl;
2 ✔
75
        this.effect = effect;
2 ✔
76
        this.md5 = md5;
2 ✔
77
        this.sha1 = sha1;
2 ✔
78
        this.sha256 = sha256;
2 ✔
79
        this.size = size;
2 ✔
80
        this.timestamps = new HashSet<>( Collections.singleton( System.currentTimeMillis() ) );
2 ✔
81
    }
2 ✔
82

83
    public String getOriginUrl()
84
    {
85
        return originUrl;
2 ✔
86
    }
87

88
    public void setOriginUrl( String originUrl )
89
    {
90
        this.originUrl = originUrl;
2 ✔
91
    }
2 ✔
92

93
    public String getMd5()
94
    {
95
        return md5;
2 ✔
96
    }
97

98
    public void setMd5( String md5 )
99
    {
100
        this.md5 = md5;
2 ✔
101
    }
2 ✔
102

103
    public String getSha256()
104
    {
105
        return sha256;
2 ✔
106
    }
107

108
    public void setSha256( String sha256 )
109
    {
110
        this.sha256 = sha256;
2 ✔
111
    }
2 ✔
112

113
    public String getSha1()
114
    {
115
        return sha1;
2 ✔
116
    }
117

118
    public void setSha1( String sha1 )
119
    {
120
        this.sha1 = sha1;
2 ✔
121
    }
2 ✔
122

123
    public StoreKey getStoreKey()
124
    {
125
        return storeKey;
2 ✔
126
    }
127

128
    public void setStoreKey( StoreKey storeKey )
129
    {
130
        this.storeKey = storeKey;
2 ✔
131
    }
2 ✔
132

133
    public AccessChannel getAccessChannel()
134
    {
135
        return accessChannel;
2 ✔
136
    }
137

138
    public void setAccessChannel( AccessChannel accessChannel )
139
    {
140
        this.accessChannel = accessChannel;
2 ✔
141
    }
2 ✔
142

143
    public String getPath()
144
    {
145
        return path;
2 ✔
146
    }
147

148
    public void setPath( String path )
149
    {
150
        this.path = path;
2 ✔
151
    }
2 ✔
152

153
    public TrackingKey getTrackingKey()
154
    {
155
        return trackingKey;
2 ✔
156
    }
157

158
    public void setTrackingKey( TrackingKey trackingKey )
159
    {
160
        this.trackingKey = trackingKey;
2 ✔
161
    }
2 ✔
162

163
    public StoreEffect getEffect()
164
    {
165
        return effect;
2 ✔
166
    }
167

168
    public void setEffect( StoreEffect effect )
169
    {
170
        this.effect = effect;
2 ✔
171
    }
2 ✔
172

173
    public Long getSize()
174
    {
175
        return size;
2 ✔
176
    }
177

178
    public void setSize( Long size )
179
    {
180
        this.size = size;
×
181
    }
×
182

183
    public long getIndex()
184
    {
185
        return index;
×
186
    }
187

188
    public void setIndex( long index )
189
    {
190
        this.index = index;
×
191
    }
×
192

193
    @Override
194
    public int compareTo( final TrackedContentEntry other )
195
    {
196
        int comp = trackingKey.getId().compareTo( other.getTrackingKey().getId() );
×
197
        if ( comp == 0 )
×
198
        {
199
            comp = storeKey.compareTo( other.getStoreKey() );
×
200
        }
201
        if ( comp == 0 )
×
202
        {
203
            comp = accessChannel.compareTo( other.getAccessChannel() );
×
204
        }
205
        if ( comp == 0 )
×
206
        {
207
            comp = path.compareTo( other.getPath() );
×
208
        }
209
        if ( comp == 0 )
×
210
        {
211
            comp = effect.compareTo( other.getEffect() );
×
212
        }
213

214
        return comp;
×
215
    }
216

217
    @Override
218
    public int hashCode()
219
    {
220
        final int prime = 31;
2 ✔
221
        int result = 1;
2 ✔
222
        result = prime * result + ( ( trackingKey == null ) ? 0 : trackingKey.hashCode() );
2 ✔
223
        result = prime * result + ( ( path == null ) ? 0 : path.hashCode() );
2 ✔
224
        result = prime * result + ( ( storeKey == null ) ? 0 : storeKey.hashCode() );
2 ✔
225
        result = prime * result + ( ( accessChannel == null ) ? 0 : accessChannel.hashCode() );
2 ✔
226
        result = prime * result + ( ( effect == null ) ? 0 : effect.hashCode() );
2 ✔
227
        return result;
2 ✔
228
    }
229

230
    @Override
231
    public boolean equals( final Object obj )
232
    {
233
        if ( this == obj )
×
234
        {
235
            return true;
×
236
        }
237
        if ( obj == null )
×
238
        {
239
            return false;
×
240
        }
241
        if ( getClass() != obj.getClass() )
×
242
        {
243
            return false;
×
244
        }
245
        final TrackedContentEntry other = (TrackedContentEntry) obj;
×
246
        if ( trackingKey == null )
×
247
        {
248
            if ( other.trackingKey != null )
×
249
            {
250
                return false;
×
251
            }
252
        }
253
        else if ( !trackingKey.equals( other.trackingKey ) )
×
254
        {
255
            return false;
×
256
        }
257
        if ( path == null )
×
258
        {
259
            if ( other.path != null )
×
260
            {
261
                return false;
×
262
            }
263
        }
264
        else if ( !path.equals( other.path ) )
×
265
        {
266
            return false;
×
267
        }
268
        if ( storeKey == null )
×
269
        {
270
            if ( other.storeKey != null )
×
271
            {
272
                return false;
×
273
            }
274
        }
275
        else if ( !storeKey.equals( other.storeKey ) )
×
276
        {
277
            return false;
×
278
        }
279
        if ( accessChannel == null )
×
280
        {
281
            if ( other.accessChannel != null )
×
282
            {
283
                return false;
×
284
            }
285
        }
286
        else if ( !accessChannel.equals( other.accessChannel ) )
×
287
        {
288
            return false;
×
289
        }
290
        if ( effect == null )
×
291
        {
292
            return other.effect == null;
×
293
        }
294
        else
295
            return effect.equals( other.effect );
×
296
    }
297

298
    @Override
299
    public String toString()
300
    {
301
        return String.format(
×
302
                        "TrackedContentEntry [\n  trackingKey=%s\n  storeKey=%s\n  accessChannel=%s\n  path=%s\n  originUrl=%s\n  effect=%s\n  md5=%s\n  sha1=%s\n  sha256=%s\nObject hashcode=%s\n]",
303
                        trackingKey, storeKey, accessChannel, path, originUrl, effect, md5, sha1, sha256,
304
                        super.hashCode() );
×
305
    }
306

307
    @Override
308
    public void writeExternal( final ObjectOutput out ) throws IOException
309
    {
310
        out.writeObject( Integer.toString( VERSION ) );
2 ✔
311
        out.writeObject( trackingKey );
2 ✔
312
        out.writeObject( storeKey.getPackageType() );
2 ✔
313
        out.writeObject( storeKey.getName() );
2 ✔
314
        out.writeObject( storeKey.getType().name() );
2 ✔
315
        out.writeObject( accessChannel.name() );
2 ✔
316
        out.writeObject( path == null ? "" : path );
2 ✔
317
        out.writeObject( originUrl == null ? "" : originUrl );
2 ✔
318
        out.writeObject( effect == null ? "" : effect.name() );
2 ✔
319
        out.writeObject( md5 == null ? "" : md5 );
2 ✔
320
        out.writeObject( sha1 == null ? "" : sha1 );
2 ✔
321
        out.writeObject( sha256 == null ? "" : sha256 );
2 ✔
322
        out.writeObject( size );
2 ✔
323
        out.writeLong( index );
2 ✔
324
        out.writeObject( timestamps );
2 ✔
325
    }
2 ✔
326

327
    @Override
328
    public void readExternal( final ObjectInput in ) throws IOException, ClassNotFoundException
329
    {
330
        // This is a little awkward. The original version didn't have a version constant, so it wasn't possible
331
        // to just read it from the data stream and use it to guide the deserialization process. Instead,
332
        // we have to read the first object and determine whether it's the object version or the tracking key,
333
        // which was the first field in the serialized data stream back in the first version of this class.
334
        Object whatIsThis = in.readObject();
2 ✔
335

336
        int version;
337
        String packageType;
338

339
        if ( whatIsThis == null )
2 ✔
340
        {
341
            // we see NumberFormatException: For input string: "null" in parseInt. It might be because we forget
342
            // to persist the trackingKey for some reason. In this case, we just ignore it and continues
343
            version = 1;
×
344
            trackingKey = null;
×
345
            packageType = PKG_TYPE_MAVEN;
×
346
        }
347
        else if ( whatIsThis instanceof TrackingKey )
2 ✔
348
        {
349
            version = 1;
2 ✔
350
            trackingKey = (TrackingKey) whatIsThis;
2 ✔
351
            packageType = PKG_TYPE_MAVEN;
2 ✔
352
        }
353
        else
354
        {
355
            version = Integer.parseInt( String.valueOf( whatIsThis ) );
2 ✔
356
            trackingKey = (TrackingKey) in.readObject();
2 ✔
357
            packageType = (String) in.readObject();
2 ✔
358
        }
359

360
        // TODO: We should make future versioning / deserialization decisions based on the version we read / infer above
361
        if ( version > VERSION )
2 ✔
362
        {
363
            throw new IOException( "This class is of an older version: " + VERSION
×
364
                                                   + " vs. the version read from the data stream: " + version
365
                                                   + ". Cannot deserialize." );
366
        }
367

368
        final String storeKeyName = (String) in.readObject();
2 ✔
369
        final StoreType storeType = StoreType.get( (String) in.readObject() );
2 ✔
370

371
        final String accessChannelStr = (String) in.readObject();
2 ✔
372
        accessChannel = "".equals( accessChannelStr ) ? null : AccessChannel.valueOf( accessChannelStr );
2 ✔
373

374
        if ( version == 1 && accessChannel == GENERIC_PROXY )
2 ✔
375
        {
376
            packageType = PKG_TYPE_GENERIC_HTTP;
2 ✔
377
        }
378

379
        storeKey = new StoreKey( packageType, storeType, storeKeyName );
2 ✔
380

381
        final String pathStr = (String) in.readObject();
2 ✔
382
        path = "".equals( pathStr ) ? null : pathStr;
2 ✔
383

384
        final String originUrlStr = (String) in.readObject();
2 ✔
385
        originUrl = "".equals( originUrlStr ) ? null : originUrlStr;
2 ✔
386

387
        final String effectStr = (String) in.readObject();
2 ✔
388
        effect = "".equals( effectStr ) ? null : StoreEffect.valueOf( effectStr );
2 ✔
389

390
        final String md5Str = (String) in.readObject();
2 ✔
391
        md5 = "".equals( md5Str ) ? null : md5Str;
2 ✔
392

393
        final String sha1Str = (String) in.readObject();
2 ✔
394
        sha1 = "".equals( sha1Str ) ? null : sha1Str;
2 ✔
395

396
        final String sha256Str = (String) in.readObject();
2 ✔
397
        sha256 = "".equals( sha256Str ) ? null : sha256Str;
2 ✔
398

399
        size = (Long) in.readObject();
2 ✔
400

401
        index = in.readLong();
2 ✔
402

403
        if ( version > 2 )
2 ✔
404
        {
405
            final Set<Long> tstamps = (Set<Long>) in.readObject();
2 ✔
406
            timestamps = tstamps;
2 ✔
407
        }
408
    }
2 ✔
409

410
    public Set<Long> getTimestamps()
411
    {
412
        return timestamps;
2 ✔
413
    }
414

415
    public void setTimestamps( final Set<Long> timestamps )
416
    {
417
        this.timestamps = timestamps;
2 ✔
418
    }
2 ✔
419

420
    public void merge( TrackedContentEntry from )
421
    {
422
        this.md5 = from.md5;
×
423
        this.sha1 = from.sha1;
×
424
        this.sha256 = from.sha256;
×
425
        this.size = from.size;
×
426
        this.timestamps.addAll( from.timestamps );
×
427
    }
×
428
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc