• 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

12.5
/src/main/java/org/commonjava/indy/service/tracking/util/TrackingUtils.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.util;
17

18
import org.commonjava.indy.service.tracking.model.TrackedContent;
19
import org.slf4j.Logger;
20
import org.slf4j.LoggerFactory;
21

22
import java.io.ByteArrayInputStream;
23
import java.io.ByteArrayOutputStream;
24
import java.io.File;
25
import java.io.FileOutputStream;
26
import java.io.IOException;
27
import java.io.InputStream;
28
import java.io.ObjectInputStream;
29
import java.io.ObjectOutputStream;
30
import java.io.OutputStream;
31
import java.util.Set;
32
import java.util.function.Consumer;
33
import java.util.zip.ZipEntry;
34
import java.util.zip.ZipInputStream;
35
import java.util.zip.ZipOutputStream;
36

37
import static org.apache.commons.io.IOUtils.copy;
38
import static org.commonjava.indy.service.tracking.Constants.TRACKING_TYPE.SEALED;
39

40
public class TrackingUtils
×
41
{
42
    private static final Logger logger = LoggerFactory.getLogger( TrackingUtils.class );
2 ✔
43

44
    /**
45
     * Write sealed records to a zip file.
46
     */
47
    public static void zipTrackedContent( File out, Set<TrackedContent> sealed ) throws IOException
48
    {
49
        logger.info( "Writing sealed zip to: '{}'", out.getAbsolutePath() );
×
50

51
        try (ZipOutputStream zip = new ZipOutputStream( new FileOutputStream( out ) ))
×
52
        {
53
            for ( TrackedContent f : sealed )
×
54
            {
55
                String name = SEALED.getValue() + "/" + f.getKey().getId();
×
56

57
                logger.trace( "Adding {} to zip", name );
×
58
                zip.putNextEntry( new ZipEntry( name ) );
×
59
                copy( toInputStream( f ), zip );
×
60
            }
×
61
        }
62
    }
×
63

64
    public static void backupTrackedContent( File dir, Set<TrackedContent> sealed ) throws IOException
65
    {
66
        logger.info( "Backup sealed to: '{}', size: {}", dir.getAbsolutePath(), sealed.size() );
×
67
        for ( TrackedContent f : sealed )
×
68
        {
69
            String name = f.getKey().getId();
×
70
            logger.trace( "Adding {} to {}", name, dir );
×
71
            try (OutputStream out = new FileOutputStream( new File( dir, name ) ))
×
72
            {
73
                copy( toInputStream( f ), out );
×
74
            }
75
        }
×
76
    }
×
77

78
    /**
79
     * Read records from input stream and execute consumer function.
80
     * @param inputStream
81
     * @param consumer
82
     * @return count of records read from the stream
83
     */
84
    public static int readZipInputStreamAnd( InputStream inputStream, Consumer<TrackedContent> consumer )
85
                    throws IOException, ClassNotFoundException
86
    {
87
        int count = 0;
2 ✔
88
        try (ZipInputStream stream = new ZipInputStream( inputStream ))
2 ✔
89
        {
90
            ZipEntry entry;
91
            while ( ( entry = stream.getNextEntry() ) != null )
2 ✔
92
            {
93
                logger.trace( "Read entry: %s, len: %d", entry.getName(), entry.getSize() );
×
94
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
×
95
                int len;
96
                byte[] buffer = new byte[1024];
×
97
                while ( ( len = stream.read( buffer ) ) > 0 )
×
98
                {
99
                    bos.write( buffer, 0, len );
×
100
                }
101
                bos.close();
×
102

103
                ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream( bos.toByteArray() ) );
×
104
                TrackedContent record = (TrackedContent) ois.readObject();
×
105
                consumer.accept( record );
×
106
                count++;
×
107
            }
×
108
        }
109
        return count;
2 ✔
110
    }
111

112
    public static InputStream toInputStream( TrackedContent f ) throws IOException
113
    {
114
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
×
115

116
        ObjectOutputStream oos = new ObjectOutputStream( baos );
×
117
        oos.writeObject( f );
×
118
        oos.flush();
×
119
        oos.close();
×
120

121
        return new ByteArrayInputStream( baos.toByteArray() );
×
122
    }
123

124
}
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