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

kit-data-manager / ro-crate-java / #357

16 Apr 2025 04:19PM UTC coverage: 86.147%. First build
#357

Pull #233

github

Pfeil
fix: replace get() with path() for safer JSON node access in CustomPreview
Pull Request #233: Version 2.1.0

532 of 690 new or added lines in 19 files covered. (77.1%)

1878 of 2180 relevant lines covered (86.15%)

0.86 hits per line

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

7.69
/src/main/java/edu/kit/datamanager/ro_crate/reader/StreamReaderStrategy.java
1
package edu.kit.datamanager.ro_crate.reader;
2

3
import com.fasterxml.jackson.databind.node.ObjectNode;
4
import edu.kit.datamanager.ro_crate.writer.StreamWriterStrategy;
5
import java.io.File;
6
import java.io.FileInputStream;
7
import java.io.FileNotFoundException;
8
import java.io.InputStream;
9
import org.slf4j.LoggerFactory;
10

11
/**
12
 * Interface for reading RO-Crate metadata and content from input streams.
13
 *
14
 * @author jejkal
15
 */
16
public interface StreamReaderStrategy extends ReaderStrategy {
17

18
    org.slf4j.Logger logger = LoggerFactory.getLogger(StreamReaderStrategy.class);
1✔
19

20
    /**
21
     * Default override of readMetadataJson interface from ReaderStrategy. The
22
     * override assumes, that location is a file, which is used as input stream.
23
     * If this assumption is not true, this call will fail.
24
     *
25
     * @param location The source, which is supposed to be a file.
26
     *
27
     * @return the RO-Crate metadata as ObjectNode
28
     */
29
    @Override
30
    default ObjectNode readMetadataJson(String location) {
NEW
31
        ObjectNode result = null;
×
32
        try {
NEW
33
            result = readMetadataJson(new FileInputStream(new File(location)));
×
NEW
34
        } catch (FileNotFoundException ex) {
×
NEW
35
            logger.error("Failed read crate from source " + location, ex);
×
NEW
36
        }
×
NEW
37
        return result;
×
38
    }
39

40
    /**
41
     * Default override of readContent interface from ReaderStrategy. The
42
     * override assumes, that location is a file, which is used as input stream.
43
     * If this assumption is not true, this call will fail.
44
     *
45
     * @param location The source, which is supposed to be a file.
46
     *
47
     * @return the RO-Crate content as file, i.e., a folder
48
     */
49
    @Override
50
    default File readContent(String location) {
NEW
51
        File result = null;
×
52
        try {
NEW
53
            result = readContent(new FileInputStream(new File(location)));
×
NEW
54
        } catch (FileNotFoundException ex) {
×
NEW
55
            logger.error("Failed read crate from source " + location, ex);
×
NEW
56
        }
×
NEW
57
        return result;
×
58
    }
59

60
    ObjectNode readMetadataJson(InputStream source);
61

62
    File readContent(InputStream source);
63

64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc