Compare commits

...

10 Commits

9 changed files with 66 additions and 28 deletions

View File

@@ -1,6 +1,9 @@
<factorypath> <factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/net/monarchpass/libpiecannon/0.0.1-SNAPSHOT/libpiecannon-0.0.1-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/> <factorypathentry kind="VARJAR" id="M2_REPO/net/monarchpass/libpiecannon/0.0.1-SNAPSHOT/libpiecannon-0.0.1-SNAPSHOT.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/mwiede/jsch/0.1.60/jsch-0.1.60.jar" enabled="true" runInBatchMode="false"/> <factorypathentry kind="VARJAR" id="M2_REPO/com/github/mwiede/jsch/0.1.60/jsch-0.1.60.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/jodd/jodd-http/6.0.3/jodd-http-6.0.3.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/jodd/jodd-util/6.0.0/jodd-util-6.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar" enabled="true" runInBatchMode="false"/> <factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" enabled="true" runInBatchMode="false"/> <factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" enabled="true" runInBatchMode="false"/> <factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" enabled="true" runInBatchMode="false"/>
@@ -9,6 +12,5 @@
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar" enabled="true" runInBatchMode="false"/> <factorypathentry kind="VARJAR" id="M2_REPO/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" enabled="true" runInBatchMode="false"/> <factorypathentry kind="VARJAR" id="M2_REPO/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/net/kothar/xdg-java/0.1.1/xdg-java-0.1.1.jar" enabled="true" runInBatchMode="false"/> <factorypathentry kind="VARJAR" id="M2_REPO/net/kothar/xdg-java/0.1.1/xdg-java-0.1.1.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/projectlombok/lombok/1.18.16/lombok-1.18.16.jar" enabled="true" runInBatchMode="false"/> <factorypathentry kind="VARJAR" id="M2_REPO/org/projectlombok/lombok/1.18.16/lombok-1.18.16.jar" enabled="true" runInBatchMode="false"/>
</factorypath> </factorypath>

12
desktop/Makefile Normal file
View File

@@ -0,0 +1,12 @@
PREFIX=~/.local
DEST=$(PREFIX)/lib/piecannon
COMMAND=$(PREFIX)/bin/piecannon
target:
mvn install
install: target
mkdir -p $(DEST)
cp target/piecannon-*.jar $(DEST)/piecannon.jar
sed "s#@JAR_PATH@#$(DEST)/piecannon.jar#g" piecannon.in > $(COMMAND)
chmod +x $(COMMAND)

View File

@@ -1,20 +0,0 @@
#!/bin/sh
PC_GROUP="net.monarchpass"
PC_ARTIFACT="piecannon-desktop-app"
PC_VERSION="0.0.1-SNAPSHOT"
PC_CLASS="net.monarchpass.piecannon.App"
STUB_POM="<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 https://maven.apache.org/xsd/maven-4.0.0.xsd'> <modelVersion>4.0.0</modelVersion> <groupId>$PC_GROUP</groupId> <artifactId>piecannon-launcher</artifactId> <version>$PC_VERSION</version> <dependencies> <dependency><groupId>$PC_GROUP</groupId><artifactId>$PC_ARTIFACT</artifactId><version>\${project.version}</version></dependency></dependencies></project>"
STUB_POM_FILE=/tmp/pc.xml
echo $STUB_POM > $STUB_POM_FILE
OUTPUT=$(mvn -f $STUB_POM_FILE -B exec:java -Dexec.mainClass=$PC_CLASS -Dexec.arguments=$1 -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN)
EXEC_RESULT=$?
echo "$OUTPUT"
if [ $EXEC_RESULT != 0 ]; then
exit $EXEC_RESULT;
fi
RESULT=$(echo "$OUTPUT" | tail -n 1)
xdg-open $RESULT

10
desktop/piecannon.in Normal file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
JAR_PATH=@JAR_PATH@
if [ "$1" = "--file-selector" ]; then
RESULT=$(java -jar "$JAR_PATH" $(yad --file))
else
RESULT=$(java -jar "$JAR_PATH" "$@")
fi
xdg-open $RESULT

View File

@@ -57,6 +57,31 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version> <version>2.22.2</version>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>net.monarchpass.piecannon.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@@ -51,8 +51,16 @@ public class App {
public static void testServers (final List<Server> servers) { public static void testServers (final List<Server> servers) {
log.log(Level.INFO, "Testing all defined servers"); log.log(Level.INFO, "Testing all defined servers");
for (final Server server : servers) { for (final Server server : servers) {
Object result;
try {
result = PieCannon.testServer(server);
}
catch (final Exception exception) {
result = exception;
}
log.log(Level.INFO, "{0} {1}: {2}", new Object[] { log.log(Level.INFO, "{0} {1}: {2}", new Object[] {
server.getClass().getSimpleName(), server.getLabel(), PieCannon.testServer(server) server.getClass().getSimpleName(), server.getLabel(), result
}); });
} }
} }

View File

@@ -10,16 +10,12 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Random; import java.util.Random;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.io.CharSource; import com.google.common.io.CharSource;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import java.util.stream.Collectors;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;

View File

@@ -6,6 +6,7 @@ import java.net.URI;
import com.google.common.io.ByteSource; import com.google.common.io.ByteSource;
import jodd.http.HttpRequest; import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import lombok.Data; import lombok.Data;
import net.monarchpass.piecannon.Server; import net.monarchpass.piecannon.Server;
@@ -28,7 +29,11 @@ public class WebDavServer implements Server {
request.basicAuthentication(username, password); request.basicAuthentication(username, password);
} }
request.send(); final HttpResponse response = request.send();
if (response.statusCode() >= 400) {
throw new RuntimeException(response.statusCode() + ": " + response.statusPhrase());
}
return target; return target;
} catch (final IOException exception) { } catch (final IOException exception) {
throw new RuntimeException(exception); throw new RuntimeException(exception);