diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
new file mode 100644
index 0000000..c4c9543
--- /dev/null
+++ b/.idea/codeStyleSettings.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 7efd95f..e757fd8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
de.selfomat
selfomat-single-user
- 0.4.0.11-SNAPSHOT
+ 0.4.0.13-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 f864923..a69f8d0 100644
--- a/src/main/java/GUI/CaptureCtl.java
+++ b/src/main/java/GUI/CaptureCtl.java
@@ -204,7 +204,7 @@ public class CaptureCtl {
Platform.runLater(new Runnable() {
public void run() {
// Set Countdown Text
- countdownText.setText(String.valueOf(counter + 1));
+ countdownText.setText(String.valueOf(counter + 2));
// Set the Counter Visible
countdownText.setVisible(true);
}
diff --git a/src/main/java/GUI/SOMGUI.java b/src/main/java/GUI/SOMGUI.java
index 3d3be91..2d67cc6 100644
--- a/src/main/java/GUI/SOMGUI.java
+++ b/src/main/java/GUI/SOMGUI.java
@@ -119,8 +119,8 @@ public class SOMGUI extends Application {
// Set the Upload scene
changetoupload();
- // Start Upload Process
+
+ // Start Upload Process (switches over to Picture afterwards)
FilesWorker.upload();
- // Set the Picture scene
}
}
\ No newline at end of file
diff --git a/src/main/java/model/SOMConfig.java b/src/main/java/model/SOMConfig.java
index 96cefe1..092ea04 100644
--- a/src/main/java/model/SOMConfig.java
+++ b/src/main/java/model/SOMConfig.java
@@ -31,7 +31,7 @@ public class SOMConfig {
public static final int SERIES_COUNTER = 4;
// Seconds before image is taken
@XmlElement(name = "COUNTDOWN_COUNTER")
- public static final int COUNTDOWN_COUNTER = 3;
+ public static final int COUNTDOWN_COUNTER = 4;
// Images per Page in the Gallery
public static final int IMAGES_PER_PAGE = 9;
// Limot of Parallel Uploads
diff --git a/src/main/java/model/SOMEvent.java b/src/main/java/model/SOMEvent.java
index 7b2622b..2e17a94 100644
--- a/src/main/java/model/SOMEvent.java
+++ b/src/main/java/model/SOMEvent.java
@@ -61,7 +61,7 @@ public class SOMEvent {
*/
public void getEventImages() {
// Behandelt
- if (!imagesread) {
+// if (!imagesread) {
File[] files = FilesWorker.getSourcePath().listFiles();
@@ -74,8 +74,8 @@ public class SOMEvent {
this.addImage(img);
}
- imagesread = true;
- }
+// imagesread = true;
+// }
// return;
}
diff --git a/src/main/java/model/SOMImage.java b/src/main/java/model/SOMImage.java
index 3b114ae..51fea69 100644
--- a/src/main/java/model/SOMImage.java
+++ b/src/main/java/model/SOMImage.java
@@ -2,14 +2,15 @@ package model;
import workers.FilesWorker;
-import javax.swing.*;
import java.io.File;
import java.nio.file.Files;
public class SOMImage {
private static String name; // the filename
+
private final SOMConfig config = SOMConfig.getInstance();
+
private final File tmb; // thumbnail
private final File prv; // preview
private final File src; // source
@@ -25,8 +26,7 @@ public class SOMImage {
File src = new File(FilesWorker.getSourcePath().toString() + "/" + name);
- File prv = new File(FilesWorker.getPreviewPath().toString() + "/"
- + name);
+ File prv = new File(FilesWorker.getPreviewPath().toString() + "/" + name);
File tmb = new File(FilesWorker.getThumbPath().toString() + "/" + name);
@@ -153,23 +153,23 @@ public class SOMImage {
* @param type 0 = thumb, 1 = preview, 2 = full Size
* @return
*/
- public ImageIcon toImageIcon(int type) {
- File imagepath;
- switch (type) {
- case 0:
- imagepath = getTmb();
- break;
- case 1:
- imagepath = getPrv();
- break;
- case 2:
- imagepath = getSrc();
- break;
- default:
- imagepath = null;
- break;
- }
-
- return new ImageIcon(imagepath.getPath());
- }
+// public ImageIcon toImageIcon(int type) {
+// File imagepath;
+// switch (type) {
+// case 0:
+// imagepath = getTmb();
+// break;
+// case 1:
+// imagepath = getPrv();
+// break;
+// case 2:
+// imagepath = getSrc();
+// break;
+// default:
+// imagepath = null;
+// break;
+// }
+//
+// return new ImageIcon(imagepath.getPath());
+// }
}
diff --git a/src/main/java/workers/FilesWorker.java b/src/main/java/workers/FilesWorker.java
index 0abbb4a..c171f9a 100644
--- a/src/main/java/workers/FilesWorker.java
+++ b/src/main/java/workers/FilesWorker.java
@@ -131,14 +131,13 @@ public class FilesWorker {
public static void upload() {
try {
- // Backup the Backup
-
-
// Get all Files in the image Folder
List images = allFilesForUpload();
+
// Lists for either dirs or pictures
List dirs = new ArrayList();
List pics = new ArrayList();
+ List remv = new ArrayList();
// Check for internet connection
if (internet()) {
@@ -150,6 +149,7 @@ public class FilesWorker {
String currentdir = "";
for (String split : splits) {
+
currentdir = currentdir + "/" + split;
dirs.add(new File(currentdir));
@@ -168,6 +168,8 @@ public class FilesWorker {
if (file.isFile()
&& file.toString().contains("src")) {
pics.add(file);
+ } else {
+ remv.add(file);
}
}
@@ -178,9 +180,6 @@ public class FilesWorker {
int queueddirs = 0;
int queuedfiles = 0;
- // GET THE UI
- SOMGUI.changetoupload();
-
// UPLOAD DIRECTORIES
List limitdirs = new ArrayList();
@@ -221,9 +220,25 @@ public class FilesWorker {
System.out.println("Clear File Queue");
limitpics.clear();
+ } else if (queuedfiles == pics.size() && pics.size() != 0) {
+ // reboot
+ new ProcessBuilder("reboot").start();
}
}
+ // Remove the rest of the files (thumbs, previews)
+ for (File rem : remv) {
+ if (rem.isFile()) {
+ rem.delete();
+ }
+ }
+
+ // Archive the Backup
+ archiveBackup();
+
+ // Update the State fot previews and thumbs
+ SOMEvent.getInstance().getImages();
+
SOMGUI.changetopicture();
}
} catch (IOException e) {
@@ -235,6 +250,42 @@ public class FilesWorker {
}
}
+ private static void archiveBackup() {
+ Task task = new Task() {
+
+ @Override
+ protected Boolean call() throws Exception {
+ // build the archive process
+ // TODO remove -k option (this option skips certificate verification)
+ // TODO Make Software run in SELFOMAT Directory
+ ProcessBuilder builder = new ProcessBuilder(
+ "bash",
+ "SELFOMAT/sh/move-backup.sh"
+ );
+
+ // make the process traceable
+ builder.redirectErrorStream(true);
+ // launch archive process
+ Process process = builder.start();
+
+ // wait for the process to end
+ if (process.waitFor() == 0) {
+ // process ended successful
+ System.out.println("archiving Backup");
+
+ return true;
+
+ } else {
+ // process ended failing
+ // TODO Catch failed uploads
+
+ System.out.println("Backup archiving failed!");
+ return false;
+ }
+ }
+ };
+ }
+
private static void uploadFile(final List files) throws Exception {
final Thread[] threads = new Thread[files.size()];
@@ -325,8 +376,7 @@ public class FilesWorker {
SOMConfig.CLOUD_CREDENTIALS,
"-X",
"MKCOL",
- SOMConfig.CLOUD_ADDRESS + SOMConfig.getEventPicDir(),
-// dir.toString().replace("/src", ""),
+ SOMConfig.CLOUD_ADDRESS + dir.toString().replace("/src", ""),
"-k");
// make the process traceable
diff --git a/src/main/resources/sh/backup-move.sh b/src/main/resources/sh/backup-move.sh
new file mode 100644
index 0000000..4c197c6
--- /dev/null
+++ b/src/main/resources/sh/backup-move.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+# get the current Time
+STAMP=$(date "+%Y%m%d-%H%M%S")
+# make the dir to move to
+mkdir img.backup/${STAMP}/
+# move the files
+mv img.backup/images/src/* img.backup/${STAMP}/
\ No newline at end of file
diff --git a/src/main/resources/sh/upload.sh b/src/main/resources/sh/upload.sh
index e67da9c..2d7810c 100644
--- a/src/main/resources/sh/upload.sh
+++ b/src/main/resources/sh/upload.sh
@@ -29,7 +29,7 @@ if [ "$1" == "-h" ];
# get the local images' MD5
pre_local_md5=$(md5sum "$1" | awk '{print $1}')
- # compare both MD5s
+ # compare both MD5s manually (for development)
echo "$pre_online_md5"
echo "$pre_local_md5"
@@ -63,7 +63,7 @@ if [ "$1" == "-h" ];
# get the local images' MD5
local_md5=$(md5sum "$1" | awk '{print $1}')
- # compare both MD5s
+ # compare both MD5s manually (for development)
echo "$online_md5"
echo "$local_md5"