Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasmiosczka committed Oct 19, 2021
1 parent 5ebca38 commit d1a3290
Show file tree
Hide file tree
Showing 24 changed files with 172 additions and 231 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.github.tobiasmiosczka.cinema.KDMManager.Starter</mainClass>
<mainClass>com.github.tobiasmiosczka.cinema.kdmmanager.Starter</mainClass>
</manifest>
</archive>
</configuration>
Expand All @@ -41,7 +41,7 @@
<configuration>
<archive>
<manifest>
<mainClass>com.github.tobiasmiosczka.cinema.KDMManager.Starter</mainClass>
<mainClass>com.github.tobiasmiosczka.cinema.kdmmanager.Starter</mainClass>
</manifest>
</archive>
<descriptorRefs>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.tobiasmiosczka.cinema.KDMManager;
package com.github.tobiasmiosczka.cinema.kdmmanager;

import com.github.tobiasmiosczka.cinema.KDMManager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.FtpLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.FtpLogin;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.tobiasmiosczka.cinema.KDMManager;
package com.github.tobiasmiosczka.cinema.kdmmanager;

import com.github.tobiasmiosczka.cinema.KDMManager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.FtpLogin;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.KDM;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.FtpLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.KDM;

public interface IUpdateProgress {
void onBegin();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package com.github.tobiasmiosczka.cinema.KDMManager;

import com.github.tobiasmiosczka.cinema.KDMManager.helper.ConfigParseException;
import com.github.tobiasmiosczka.cinema.KDMManager.helper.EmailHelper;
import com.github.tobiasmiosczka.cinema.KDMManager.helper.FtpHelper;
import com.github.tobiasmiosczka.cinema.KDMManager.helper.XmlHelper;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.Config;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.KDMManager.helper.FtpException;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.FtpLogin;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.KDM;
package com.github.tobiasmiosczka.cinema.kdmmanager;

import com.github.tobiasmiosczka.cinema.kdmmanager.helper.*;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.Config;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.FtpLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.KDM;
import org.jdom2.JDOMException;

import java.io.FileInputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.tobiasmiosczka.cinema.KDMManager;
package com.github.tobiasmiosczka.cinema.kdmmanager;

import com.github.tobiasmiosczka.cinema.KDMManager.gui.ProgressWindow;
import com.github.tobiasmiosczka.cinema.KDMManager.gui.Window;
import com.github.tobiasmiosczka.cinema.kdmmanager.gui.ProgressWindow;
import com.github.tobiasmiosczka.cinema.kdmmanager.gui.Window;

public class Starter {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.tobiasmiosczka.cinema.KDMManager.gui;
package com.github.tobiasmiosczka.cinema.kdmmanager.gui;

import com.github.tobiasmiosczka.cinema.KDMManager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.EmailLogin;

import javax.swing.JButton;
import javax.swing.JCheckBox;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.tobiasmiosczka.cinema.KDMManager.gui;
package com.github.tobiasmiosczka.cinema.kdmmanager.gui;

import com.github.tobiasmiosczka.cinema.KDMManager.pojo.FtpLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.FtpLogin;

import javax.swing.JButton;
import javax.swing.JDialog;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.tobiasmiosczka.cinema.KDMManager.gui;
package com.github.tobiasmiosczka.cinema.kdmmanager.gui;

import com.github.tobiasmiosczka.cinema.KDMManager.IUpdateProgress;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.FtpLogin;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.KDM;
import com.github.tobiasmiosczka.cinema.kdmmanager.IUpdateProgress;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.FtpLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.KDM;

import javax.swing.JButton;
import javax.swing.JFrame;
Expand Down Expand Up @@ -105,7 +105,7 @@ public void onUpdateEmailBox(int current, int total, EmailLogin emailLogin) {
pbMajor.setMaximum(total);
pbMajor.setValue(current);
pbMajor.setString("Loading Emails from: " + emailLogin.toString());
logMessage("Loading Emails from " + emailLogin.toString() + ".");
logMessage("Loading Emails from " + emailLogin + ".");
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.tobiasmiosczka.cinema.KDMManager.gui;
package com.github.tobiasmiosczka.cinema.kdmmanager.gui;

import com.github.tobiasmiosczka.cinema.KDMManager.IUpdateGui;
import com.github.tobiasmiosczka.cinema.KDMManager.Program;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.FtpLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.IUpdateGui;
import com.github.tobiasmiosczka.cinema.kdmmanager.Program;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.FtpLogin;

import javax.swing.DefaultListModel;
import javax.swing.JButton;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.tobiasmiosczka.cinema.KDMManager.helper;
package com.github.tobiasmiosczka.cinema.kdmmanager.helper;

import org.jdom2.Element;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.tobiasmiosczka.cinema.KDMManager.helper;
package com.github.tobiasmiosczka.cinema.kdmmanager.helper;

import com.github.tobiasmiosczka.cinema.KDMManager.IUpdateProgress;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.KDMManager.pojo.KDM;
import com.github.tobiasmiosczka.cinema.kdmmanager.IUpdateProgress;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.EmailLogin;
import com.github.tobiasmiosczka.cinema.kdmmanager.pojo.KDM;
import org.jdom2.Document;
import org.jdom2.JDOMException;

Expand All @@ -19,7 +19,6 @@
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Properties;
Expand All @@ -29,18 +28,15 @@

public class EmailHelper {

private static Collection<KDM> unzip(IUpdateProgress iUpdateProgress, InputStream inputStream) throws IOException, JDOMException, ParseException {
private static Collection<KDM> unzip(IUpdateProgress iUpdateProgress, InputStream inputStream) throws IOException, JDOMException, InvalidKdmException {
Collection<KDM> result = new HashSet<>();
ZipInputStream zis = new ZipInputStream(inputStream);
ZipEntry zipEntry = zis.getNextEntry();
while (zipEntry != null) {
String fileName = zipEntry.getName();
if (fileName.endsWith(".xml")) {
try {
result.add(getKdmFromInputStream(iUpdateProgress, zis, fileName));
} catch (InvalidKdmException e) {
//TODO: Exception Handling
}
result.add(getKdmFromInputStream(iUpdateProgress, zis, fileName));

}
zipEntry = zis.getNextEntry();
}
Expand All @@ -49,7 +45,7 @@ private static Collection<KDM> unzip(IUpdateProgress iUpdateProgress, InputStrea
return result;
}

private static KDM getKdmFromInputStream(IUpdateProgress iUpdateProgress, InputStream inputStream, String fileName) throws JDOMException, IOException, ParseException, InvalidKdmException {
private static KDM getKdmFromInputStream(IUpdateProgress iUpdateProgress, InputStream inputStream, String fileName) throws JDOMException, IOException, InvalidKdmException {
Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name());
String sData = scanner.useDelimiter("\\A").next();
Document document = XmlHelper.getDocument(StringHelper.toInputStream(sData));
Expand All @@ -76,7 +72,7 @@ private static String decode(String s) {
}
}

private static Collection<KDM> handleMessages(Message[] messages, IUpdateProgress iUpdateProgress) throws IOException, JDOMException, ParseException, MessagingException {
private static Collection<KDM> handleMessages(Message[] messages, IUpdateProgress iUpdateProgress) throws IOException, JDOMException, MessagingException, InvalidKdmException {
Collection<KDM> kdms = new HashSet<>();
for (int i = 0; i < messages.length; ++i) {
Message message = messages[i];
Expand All @@ -90,11 +86,8 @@ private static Collection<KDM> handleMessages(Message[] messages, IUpdateProgres
if (fileName.endsWith(".zip"))
kdms.addAll(unzip(iUpdateProgress, bodyPart.getInputStream()));
else if (fileName.endsWith(".xml"))
try {
kdms.add(getKdmFromInputStream(iUpdateProgress, bodyPart.getInputStream(), fileName));
} catch (InvalidKdmException e) {
//TODO: Exception Handling
}
kdms.add(getKdmFromInputStream(iUpdateProgress, bodyPart.getInputStream(), fileName));

}
}
}
Expand All @@ -103,7 +96,7 @@ else if (fileName.endsWith(".xml"))
return kdms;
}

public static Collection<KDM> getKdmsFromEmail(Collection<EmailLogin> emailLogins, IUpdateProgress iUpdateProgress) throws MessagingException, IOException, JDOMException, ParseException {
public static Collection<KDM> getKdmsFromEmail(Collection<EmailLogin> emailLogins, IUpdateProgress iUpdateProgress) throws MessagingException, IOException, JDOMException, InvalidKdmException {
Collection<KDM> kdms = new HashSet<>();
int current = 0;
for (EmailLogin emailLogin : emailLogins) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.tobiasmiosczka.cinema.KDMManager.helper;
package com.github.tobiasmiosczka.cinema.kdmmanager.helper;

public class FtpException extends Throwable {

Expand Down
Loading

0 comments on commit d1a3290

Please sign in to comment.