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

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

15 Apr 2025 08:24AM UTC coverage: 86.955%. First build
#348

Pull #233

github

web-flow
Merge pull request #244 from kit-data-manager/renovate/commons-io-commons-io-2.x

chore(deps): update dependency commons-io:commons-io to v2.19.0
Pull Request #233: Version 2.1.0

521 of 659 new or added lines in 18 files covered. (79.06%)

1873 of 2154 relevant lines covered (86.95%)

0.87 hits per line

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

57.14
/src/main/java/edu/kit/datamanager/ro_crate/writer/RoCrateWriter.java
1
package edu.kit.datamanager.ro_crate.writer;
2

3
import edu.kit.datamanager.ro_crate.Crate;
4
import edu.kit.datamanager.ro_crate.validation.JsonSchemaValidation;
5
import edu.kit.datamanager.ro_crate.validation.Validator;
6
import java.io.OutputStream;
7
import org.slf4j.Logger;
8
import org.slf4j.LoggerFactory;
9

10
/**
11
 * The class used for writing (exporting) crates. The class uses a strategy
12
 * pattern for writing crates as different formats. (zip, folders, etc.)
13
 */
14
public class RoCrateWriter {
15

16
    private static Logger logger = LoggerFactory.getLogger(RoCrateWriter.class);
1✔
17

18
    private final WriterStrategy writer;
19

20
    public RoCrateWriter(WriterStrategy writer) {
1✔
21
        this.writer = writer;
1✔
22
    }
1✔
23

24
    /**
25
     * This method saves the crate to a destination provided.
26
     *
27
     * @param crate the crate to write.
28
     * @param destination the location where the crate should be written.
29
     */
30
    public void save(Crate crate, String destination) {
31
        Validator defaultValidation = new Validator(new JsonSchemaValidation());
1✔
32
        defaultValidation.validate(crate);
1✔
33
        this.writer.save(crate, destination);
1✔
34
    }
1✔
35

36
    /**
37
     * This method saves the crate to a destination provided.
38
     *
39
     * @param crate the crate to write.
40
     * @param destination the location where the crate should be written.
41
     */
42
    public void save(Crate crate, OutputStream destination) {
NEW
43
        Validator defaultValidation = new Validator(new JsonSchemaValidation());
×
NEW
44
        defaultValidation.validate(crate);
×
NEW
45
        if (writer instanceof StreamWriterStrategy streamWriterStrategy) {
×
NEW
46
            streamWriterStrategy.save(crate, destination);
×
47
        } else {
NEW
48
            logger.error("Provided writer does not implement StreamWriterStrategy. Please use 'save(Crate crate, String destination)'.");
×
49
        }
NEW
50
    }
×
51
}
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