Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions urlUpdater/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.devonfw.tools.ide.dev</groupId>
<artifactId>devonfw-ide</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<groupId>com.devonfw.tools.ide</groupId>
<artifactId>devonfw-ide-url-updater</artifactId>
<packaging>jar</packaging>
<version>${revision}</version>
<name>${project.artifactId}</name>
<description>Code for maintenance of download urls of IDEs tools (Eclipse, Docker, etc.).</description>

<dependencies>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.devonfw.tools.ide.url.folderhandling.UrlRepository</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.devonfw.tools.ide.url.folderhandling;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;

/**
*
* @param <P> Parent type
* @param <C> Child type
*/
public abstract class UrlArtifact<P, C> {
protected final Path path;

public UrlArtifact(Path path) {
this.path = path;
}

public Path getPath() {
return this.path;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.devonfw.tools.ide.url.folderhandling;

public class UrlEdition extends UrlHasChildParentArtifact<UrlTool, UrlVersion> {

public UrlEdition(UrlTool parent, String name) {

super(parent, name);
}

@Override
protected UrlVersion newChild(String name) {

return new UrlVersion(this, name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.devonfw.tools.ide.url.folderhandling;

import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.List;
import java.util.stream.Collectors;

/**
*
*
*/
public class UrlFile extends UrlHasParentArtifact<UrlVersion, UrlFile> {


public UrlFile(UrlVersion parent, String name) {
super(parent, name);

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.devonfw.tools.ide.url.folderhandling;

import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;

public abstract class UrlHasChildArtifact<P ,C> extends UrlArtifact<P,C> {
protected Map<String, C> children;


public UrlHasChildArtifact(Path path) {
super(path);
this.children = new HashMap<>();
}


public int getChildCount() {

return this.children.size();
}

public C getChild(String name) {

return this.children.get(name);
}

public C getOrCreateChild(String name) {

return this.children.computeIfAbsent(name, p -> newChild(name));
}


protected abstract C newChild(String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.devonfw.tools.ide.url.folderhandling;

import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;

public abstract class UrlHasChildParentArtifact<P extends UrlArtifact<?, ?>, C> extends UrlArtifact<P, C> {
protected final P parent;

protected final String name;

protected Map<String, C> children;


public UrlHasChildParentArtifact(P parent, String name) {
super(parent.getPath().resolve(name));
this.parent = parent;
this.name = name;
this.children = new HashMap<>();

}

public P getParent() {

return this.parent;
}

public String getName() {

return this.name;
}

public int getChildCount() {

return this.children.size();
}

public C getChild(String name) {

return this.children.get(name);
}

public C getOrCreateChild(String name) {

return this.children.computeIfAbsent(name, p -> newChild(name));
}

protected abstract C newChild(String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.devonfw.tools.ide.url.folderhandling;

import java.nio.file.Path;
import java.util.Map;

public abstract class UrlHasParentArtifact<P extends UrlArtifact<?, ?>, C> extends UrlArtifact<UrlArtifact<?, ?>, C> {
protected final P parent;
protected final String name;

public UrlHasParentArtifact(P parent, String name) {
super(parent.getPath().resolve(name));
this.parent = parent;
this.name = name;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.devonfw.tools.ide.url.folderhandling;

import java.nio.file.Path;

public class UrlRepository extends UrlHasChildArtifact<UrlRepository, UrlTool> {

Path path;

/**
*
* @param path Enter the path to the url folder structure in which the tool folders are supposed to be later on in the
* creation process.
*/
public UrlRepository(Path path) {
super(path);
this.path = path;

}

@Override
protected UrlTool newChild(String name) {

return new UrlTool(this, name);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.devonfw.tools.ide.url.folderhandling;

public class UrlTool extends UrlHasChildParentArtifact<UrlRepository, UrlEdition> {

public UrlTool(UrlRepository parent, String name) {

super(parent, name);
}

@Override
protected UrlEdition newChild(String name) {

return new UrlEdition(this, name);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.devonfw.tools.ide.url.folderhandling;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public class UrlVersion extends UrlHasChildParentArtifact<UrlEdition, UrlFile> {

public UrlVersion(UrlEdition parent, String name) {

super(parent, name);
}

protected void makeFile(String os, String arch) throws IOException {

Path filePath = getPath().resolve(os + "_" + arch + ".urls");
if (!Files.exists(filePath)) {
Files.createFile(filePath);
}
}

protected void makeFile(String os) throws IOException {

Path filePath = getPath().resolve(os + ".urls");
if (!Files.exists(filePath)) {
Files.createFile(filePath);
}
}

protected void makeFile() throws IOException {

Path filePath = getPath().resolve("urls");
if (!Files.exists(filePath)) {
Files.createFile(filePath);
}
}

@Override
protected UrlFile newChild(String name) {

return new UrlFile(this, name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
url/1
url/2