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

devonfw / IDEasy / 13858963404

14 Mar 2025 02:38PM UTC coverage: 67.657% (-1.0%) from 68.619%
13858963404

push

github

web-flow
#1024: Move urls into url-updater module (#1025)

Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>

3036 of 4915 branches covered (61.77%)

Branch coverage included in aggregate %.

7825 of 11138 relevant lines covered (70.25%)

3.07 hits per line

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

38.71
cli/src/main/java/com/devonfw/tools/ide/url/model/file/UrlStatusFile.java
1
package com.devonfw.tools.ide.url.model.file;
2

3
import java.io.BufferedReader;
4
import java.io.BufferedWriter;
5
import java.nio.file.Files;
6
import java.nio.file.Path;
7

8
import com.devonfw.tools.ide.json.JsonMapping;
9
import com.devonfw.tools.ide.url.model.file.json.StatusJson;
10
import com.devonfw.tools.ide.url.model.folder.UrlVersion;
11
import com.fasterxml.jackson.databind.ObjectMapper;
12

13
/**
14
 * {@link UrlFile} for the "status.json" file.
15
 */
16
public class UrlStatusFile extends AbstractUrlFile<UrlVersion> {
17

18
  /**
19
   * Constant {@link UrlStatusFile#getName() filename}.
20
   */
21
  public static final String STATUS_JSON = "status.json";
22

23
  private static final ObjectMapper MAPPER = JsonMapping.create();
3✔
24

25
  private StatusJson statusJson;
26

27
  /**
28
   * The constructor.
29
   *
30
   * @param parent the {@link #getParent() parent folder}.
31
   */
32
  public UrlStatusFile(UrlVersion parent) {
33

34
    super(parent, STATUS_JSON);
4✔
35
    this.statusJson = new StatusJson();
5✔
36
  }
1✔
37

38
  /**
39
   * @return the content of the {@link StatusJson status.json} file.
40
   */
41
  public StatusJson getStatusJson() {
42

43
    return this.statusJson;
3✔
44
  }
45

46
  /**
47
   * @param statusJson new value of {@link #getStatusJson()}.
48
   */
49
  public void setStatusJson(StatusJson statusJson) {
50

51
    this.modified = true;
×
52
    this.statusJson = statusJson;
×
53
  }
×
54

55
  @Override
56
  protected void doLoad() {
57

58
    Path path = getPath();
3✔
59
    if (Files.exists(path)) {
5!
60
      try (BufferedReader reader = Files.newBufferedReader(path)) {
3✔
61
        this.statusJson = MAPPER.readValue(reader, StatusJson.class);
7✔
62
      } catch (Exception e) {
×
63
        throw new IllegalStateException("Failed to load " + path, e);
×
64
      }
1✔
65
    } else {
66
      this.statusJson = new StatusJson();
×
67
    }
68
  }
1✔
69

70
  @Override
71
  protected void doSave() {
72

73
    try (BufferedWriter writer = Files.newBufferedWriter(getPath())) {
×
74
      MAPPER.writeValue(writer, this.statusJson);
×
75
    } catch (Exception e) {
×
76
      throw new IllegalStateException("Failed to save file " + getPath(), e);
×
77
    }
×
78
  }
×
79

80
  /**
81
   * Performs a cleanup and removes all unused entries.
82
   *
83
   * @see StatusJson#cleanup()
84
   */
85
  public void cleanup() {
86

87
    boolean changed = this.statusJson.cleanup();
×
88
    if (changed) {
×
89
      this.modified = true;
×
90
    }
91
  }
×
92
}
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