diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 97626ba..3cee6c5 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Release.xml b/.idea/runConfigurations/Release.xml
new file mode 100644
index 0000000..9fa20b0
--- /dev/null
+++ b/.idea/runConfigurations/Release.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 4c5a68d..7efd95f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
de.selfomat
selfomat-single-user
- 0.4.0.5-SNAPSHOT
+ 0.4.0.11-SNAPSHOT
scm:svn:svn://simongehrig:L4ut5pr3ch3r!@svn.picture.tools/selfomat/trunk/selfomat-java-single-user
diff --git a/src/main/java/GUI/CaptureCtl.java b/src/main/java/GUI/CaptureCtl.java
index 0d6de4f..f864923 100644
--- a/src/main/java/GUI/CaptureCtl.java
+++ b/src/main/java/GUI/CaptureCtl.java
@@ -85,7 +85,7 @@ public class CaptureCtl {
image.setImage(SOMLayout.LOGO_IMAGE);
// make it fit the height of the Screen
- image.setFitWidth(SOMLayout.screenHeight / 2);
+// image.setFitWidth(SOMLayout.screenHeight / 2);
// Calculate the offset to center it horizontally if the image is wider than the screen (or narrower)
double aspect = image.getImage().getWidth() / image.getImage().getHeight();
diff --git a/src/main/java/GUI/PictureCtl.java b/src/main/java/GUI/PictureCtl.java
index 5075685..ddb861b 100644
--- a/src/main/java/GUI/PictureCtl.java
+++ b/src/main/java/GUI/PictureCtl.java
@@ -257,7 +257,7 @@ public class PictureCtl {
image.setImage(SOMLayout.LOGO_IMAGE);
// make it fit the height of the Screen
- image.setFitWidth(SOMLayout.screenHeight / 2);
+// image.setFitWidth(SOMLayout.screenHeight);
// Calculate the offset to center it horizontally if the image is wider than the screen (or narrower)
double aspect = image.getImage().getWidth() / image.getImage().getHeight();
diff --git a/src/main/java/model/SOMConfig.java b/src/main/java/model/SOMConfig.java
index 9e04409..c001ecc 100644
--- a/src/main/java/model/SOMConfig.java
+++ b/src/main/java/model/SOMConfig.java
@@ -35,6 +35,10 @@ public class SOMConfig {
public static final int COUNTDOWN_COUNTER = 3;
// Images per Page in the Gallery
public static final int IMAGES_PER_PAGE = 9;
+ // Limot of Parallel Uploads
+ public static final int PARALLEL_UPLOADS = 10;
+ // Cloud Credentials
+ public static final String CLOUD_CREDENTIALS = "upload:geheim";
// Make the Scaling Algorithm switchable
public static final int SCALING_GRAPHICS_2D = 0;
public static final int SCALING_IMAGE_ICON = 1;
@@ -70,7 +74,7 @@ public class SOMConfig {
*
* @return
*/
- private static String getEventPicDir() {
+ public static String getEventPicDir() {
// get current Date in String for Upload-dir
Calendar cal = Calendar.getInstance();
DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
diff --git a/src/main/java/model/SOMLanguage.java b/src/main/java/model/SOMLanguage.java
deleted file mode 100644
index 16b4702..0000000
--- a/src/main/java/model/SOMLanguage.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package model;
-
-public class SOMLanguage {
- // for Testing
- public static final String pre = "";
- // for Use
-// public static String pre = "/resources";
- /**
- * Languagestring of the Button that switches back one Panel
- */
- // public static final String UIBtnBack = "Zurück";
- /**
- * Tells People to SMILE!
- */
- public static final String UIBtnSmile = "SMILE";
-}
diff --git a/src/main/java/workers/FilesWorker.java b/src/main/java/workers/FilesWorker.java
index 856d17c..3846a04 100644
--- a/src/main/java/workers/FilesWorker.java
+++ b/src/main/java/workers/FilesWorker.java
@@ -2,7 +2,6 @@ package workers;
import GUI.SOMGUI;
import javafx.concurrent.Task;
-import javafx.fxml.FXMLLoader;
import model.SOMConfig;
import model.SOMEvent;
import model.SOMImage;
@@ -143,14 +142,23 @@ public class FilesWorker {
List dirs = new ArrayList();
List pics = new ArrayList();
- //relative ones
-// int directoriesUploaded = 0;
-// int picturesUploaded = 0;
-
// Check for internet connection
if (internet()) {
// Count Files and Dirs
+
+ // DIRS
+ String[] splits = SOMConfig.getEventPicDir().split("/");
+ String currentdir = "";
+
+ for (String split : splits) {
+ currentdir = currentdir + "/" + split;
+ dirs.add(new File(currentdir));
+
+ System.out.println("DIR added:" + currentdir);
+ }
+
+ // FILES
for (int i = 0; i < images.size(); i++) {
// get the current file
@@ -158,18 +166,9 @@ public class FilesWorker {
System.out.println(file);
- // get dirs
- if (file.isDirectory()
- && !file.toString().contains("prv")
- && !file.toString().contains("tmb")
- && !file.toString().contains("tmp")
- && !file.toString().contains("fnl")) {
- dirs.add(file);
-
- }
// get pics
- else if (file.isFile()
- && file.toPath().toString().contains("src")) {
+ if (file.isFile()
+ && file.toString().contains("src")) {
pics.add(file);
}
}
@@ -177,31 +176,25 @@ public class FilesWorker {
// REPORT TO CONSOLE
System.out.println(dirs.size() + " Directories");
System.out.println(pics.size() + " Pics");
+
+ int uploadeddirs = 0;
+ int uploadedfiles = 0;
+
// GET THE UI
+ SOMGUI.changetoupload();
-
- FXMLLoader fxmlLoader = new FXMLLoader();
- try {
- fxmlLoader.setLocation(
- FilesWorker.class.getClassLoader().getResource("fxml/upload.fxml")
- );
-
- fxmlLoader.load();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- int i = 0;
+ // UPLOAD DIRECTORIES
List limitdirs = new ArrayList();
- // TODO Limit Uploads
- for (File dir : dirs
- ) {
- i++;
+ for (File dir : dirs) {
- System.out.println("Queueing Dir " + dir.toString());
+ uploadeddirs++;
+
+ System.out.println("Queueing Directories " + dir.toString());
limitdirs.add(dir);
- if (limitdirs.size() >= 3 || limitdirs.size() == i) {
+ if (limitdirs.size() >= SOMConfig.PARALLEL_UPLOADS
+ // Upload even if limit is not reached
+ || (dirs.size() - uploadeddirs) < SOMConfig.PARALLEL_UPLOADS) {
System.out.println("Launch Dir upload");
uploadDir(limitdirs);
@@ -210,23 +203,28 @@ public class FilesWorker {
limitdirs.clear();
}
}
-// uploadDir(dirs);
+
+ // UPLOAD FILES
List limitpics = new ArrayList();
for (File pic : pics
) {
- i++;
- System.out.println("Queueing Dir " + pic.toString());
- limitpics.add(pic);
- if (limitpics.size() >= 3 || limitdirs.size() == i) {
- System.out.println("Launch Pic upload");
+ uploadedfiles++;
+
+ System.out.println("Queueing File " + pic.toString());
+ limitpics.add(pic);
+
+ if (limitpics.size() >= SOMConfig.PARALLEL_UPLOADS
+ // Upload even if limit is not reached
+ || (pics.size() - uploadedfiles) < SOMConfig.PARALLEL_UPLOADS) {
+
+ System.out.println("Launch File upload");
uploadFile(limitpics);
- System.out.println("Clear Queue");
+ System.out.println("Clear File Queue");
limitpics.clear();
}
}
-// uploadFile(pics);
SOMGUI.changetopicture();
}
@@ -245,9 +243,16 @@ public class FilesWorker {
for (int i = 0; i < threads.length; i++) {
- System.out.println("launch Upload Process: " + i);
+ System.out.println("LAUNCH Upload Process: " + i);
final File file = files.get(i);
+ final String target = "https://cloud.selfomat.de/remote.php/webdav/" + SOMConfig.getEventPicDir() + "/" + file.getName();
+
+ System.out.println(file.toString());
+ System.out.println("----------->");
+ System.out.println(target);
+ System.out.println("");
+ System.out.println("");
final int pictureCounter = i + 1;
Task task = new Task() {
@@ -257,20 +262,17 @@ public class FilesWorker {
// build the upload process
// TODO remove -k option (this option skips certificate verification)
ProcessBuilder builder = new ProcessBuilder(
- "curl",
- "-T",
+ "bash",
+ "SELFOMAT/sh/upload.sh",
file.toString(),
- "-u",
- "upload:geheim",
- "https://cloud.selfom.at/remote.php/webdav/" + file.toString().replace("/src", ""),
- "-k");
+ target,
+ SOMConfig.CLOUD_CREDENTIALS
+ );
// make the process traceable
builder.redirectErrorStream(true);
-
-
- Process process = builder.start();
// launch upload process
+ Process process = builder.start();
// wait for the process to end
if (process.waitFor() == 0) {
@@ -327,7 +329,8 @@ public class FilesWorker {
"upload:geheim",
"-X",
"MKCOL",
- "https://cloud.selfom.at/remote.php/webdav/" + dir.toString().replace("/src", ""),
+ "https://cloud.selfom.at/remote.php/webdav/" + SOMConfig.getEventPicDir(),
+// dir.toString().replace("/src", ""),
"-k");
// make the process traceable
diff --git a/src/main/resources/fxml/gallery.fxml b/src/main/resources/fxml/gallery.fxml
index 47ec4ea..a18b736 100644
--- a/src/main/resources/fxml/gallery.fxml
+++ b/src/main/resources/fxml/gallery.fxml
@@ -1,5 +1,6 @@
+
@@ -20,63 +21,72 @@
+
+
+
-
+
-
diff --git a/src/main/resources/img/SOMIcons_Back.png b/src/main/resources/img/SOMIcons_Back.png
index c24ca49..5035638 100644
Binary files a/src/main/resources/img/SOMIcons_Back.png and b/src/main/resources/img/SOMIcons_Back.png differ
diff --git a/src/main/resources/img/SOMIcons_CaptureSeries.png b/src/main/resources/img/SOMIcons_CaptureSeries.png
index 6232462..c6b5f95 100644
Binary files a/src/main/resources/img/SOMIcons_CaptureSeries.png and b/src/main/resources/img/SOMIcons_CaptureSeries.png differ
diff --git a/src/main/resources/img/SOMIcons_CaptureSingle.png b/src/main/resources/img/SOMIcons_CaptureSingle.png
index 4e8e7d9..13715d2 100644
Binary files a/src/main/resources/img/SOMIcons_CaptureSingle.png and b/src/main/resources/img/SOMIcons_CaptureSingle.png differ
diff --git a/src/main/resources/img/SOMIcons_Forth.png b/src/main/resources/img/SOMIcons_Forth.png
index f73b5ea..d899f8c 100644
Binary files a/src/main/resources/img/SOMIcons_Forth.png and b/src/main/resources/img/SOMIcons_Forth.png differ
diff --git a/src/main/resources/img/SOMIcons_Gallery.png b/src/main/resources/img/SOMIcons_Gallery.png
index 25b415c..8fabd55 100644
Binary files a/src/main/resources/img/SOMIcons_Gallery.png and b/src/main/resources/img/SOMIcons_Gallery.png differ
diff --git a/src/main/resources/img/SOMIcons_Picture.png b/src/main/resources/img/SOMIcons_Picture.png
index 70b73b7..f4168fb 100644
Binary files a/src/main/resources/img/SOMIcons_Picture.png and b/src/main/resources/img/SOMIcons_Picture.png differ
diff --git a/src/main/resources/img/SOMIcons_Print.png b/src/main/resources/img/SOMIcons_Print.png
index e86bdbe..cade14b 100644
Binary files a/src/main/resources/img/SOMIcons_Print.png and b/src/main/resources/img/SOMIcons_Print.png differ
diff --git a/src/main/resources/sh/capture.sh b/src/main/resources/sh/capture.sh
index 25296cb..9be8803 100644
--- a/src/main/resources/sh/capture.sh
+++ b/src/main/resources/sh/capture.sh
@@ -1,5 +1,16 @@
+#!/usr/bin/env bash
+
+# NOT USED AT THE TIME!!
+
+# go to images dir
cd images
+
+# capture
gphoto2 --capture-image
+# download
gphoto2 --get-all-images
+# delete on camera
gphoto2 --delete-all-images
+
+# change back to home dir
cd
diff --git a/src/main/resources/sh/upload.sh b/src/main/resources/sh/upload.sh
new file mode 100644
index 0000000..79f0d5a
--- /dev/null
+++ b/src/main/resources/sh/upload.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# Upload files to a webdav storage,
+# check them by an MD5 Hash
+# and remove the local copy afterwards.
+
+if [ "$1" == "-h" ];
+then
+echo "Syntax:"
+echo "upload.sh [Local File Location] [Remote File Location] [username:password]"
+
+elif [ $1 = $2 ];
+then
+echo "Source and Target are the same"
+echo "No Arguments provided!"
+
+else
+#upload the image
+curl -T $1 -u $3 $2 -k
+
+# get the online images' MD5up
+online_md5=$(curl $2 -k -u $3 | md5sum | awk '{print $1}')
+
+# get the local images' MD5
+local_md5=$(md5sum "$1" | awk '{print $1}')
+
+# compare both MD5s
+echo "$online_md5"
+echo "$local_md5"
+
+if [ "$online_md5" == "$local_md5" ];
+# Remove the original Image if successful
+then
+echo "Uploaded successfully!"
+
+# Remove Original
+rm $1
+
+# Fallback routine if not successful
+else
+echo "Upload failed!!"
+fi
+fi