Skip to content

Commit

Permalink
renamed Crawler to ProjectileClientApi
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Bley committed Aug 19, 2016
1 parent e2b6589 commit ed4fe57
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.saxsys.projectiler.crawler;
package de.saxsys.projectiler.api;

/**
* A booking is a period of time booked for a project.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package de.saxsys.projectiler.crawler;
package de.saxsys.projectiler.api;

/**
* Exception to be thrown by Crawler implementations if the connection to Projectile fails.
*
* @author stefan.bley
*/
public class ConnectionException extends CrawlingException {
public class ConnectionException extends ProjectileApiException {
private static final long serialVersionUID = 6824662682328693910L;

public ConnectionException(final Throwable cause) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.saxsys.projectiler.crawler;
package de.saxsys.projectiler.api;

/**
* Credentials to log into Projectile.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package de.saxsys.projectiler.crawler;
package de.saxsys.projectiler.api;

/**
* Exception to be thrown by Crawler implementations if credentials are invalid.
*
* @author stefan.bley
*/
public final class InvalidCredentialsException extends CrawlingException {
public final class InvalidCredentialsException extends ProjectileApiException {

private static final long serialVersionUID = 2792697136523800724L;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package de.saxsys.projectiler.crawler;
package de.saxsys.projectiler.api;

/**
* Exception to be thrown by Crawler implementations if the booking would consume more than the remaining budget for
* this project.
*
* @author stefan.bley
*/
public class NoBudgetException extends CrawlingException {
public class NoBudgetException extends ProjectileApiException {

private static final long serialVersionUID = 7232508869516591946L;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package de.saxsys.projectiler.crawler;
package de.saxsys.projectiler.api;

/**
* Exception to be thrown by Crawler implementations if the booking overlaps an existing booking.
*
* @author stefan.bley
*/
public class OverlapException extends CrawlingException {
public class OverlapException extends ProjectileApiException {

private static final long serialVersionUID = 7232508869516591946L;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package de.saxsys.projectiler.crawler;
package de.saxsys.projectiler.api;

/**
* Exception to be thrown by Crawler implementations if there is any failure.
*
* @author stefan.bley
*/
public class CrawlingException extends Exception {
public class ProjectileApiException extends Exception {

private static final long serialVersionUID = 7232508869516591946L;

public CrawlingException(String message) {
public ProjectileApiException(String message) {
super(message);
}

public CrawlingException(String message, Throwable cause) {
public ProjectileApiException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.saxsys.projectiler.crawler;
package de.saxsys.projectiler.api;

import java.util.Date;
import java.util.List;
Expand All @@ -12,7 +12,7 @@
*
* @author stefan.bley
*/
public interface Crawler {
public interface ProjectileClientApi {

/**
* Verifies the credentials are valid.
Expand All @@ -21,23 +21,23 @@ public interface Crawler {
* if the credentials are invalid
* @throws ConnectionException
* if connection to Projectile cannot be established
* @throws CrawlingException
* @throws ProjectileApiException
* in case the crawling fails
*/
void checkCredentials(Credentials credentials) throws InvalidCredentialsException,
ConnectionException, CrawlingException;
ConnectionException, ProjectileApiException;

/**
* Get a list of all available project names.
*
* @throws ConnectionException
* if connection to Projectile cannot be established
* @throws CrawlingException
* @throws ProjectileApiException
* in case the crawling fails
* @return project names or empty list
*/
List<String> getProjectNames(Credentials credentials) throws ConnectionException,
CrawlingException;
ProjectileApiException;

/**
* Clock time for given user and project.
Expand All @@ -54,22 +54,22 @@ List<String> getProjectNames(Credentials credentials) throws ConnectionException
* (optional)
* @throws ConnectionException
* if connection to Projectile cannot be established
* @throws CrawlingException
* @throws ProjectileApiException
* in case the crawling fails
*/
void clock(Credentials credentials, String projectName, Date start, Date end, String comment)
throws ConnectionException, CrawlingException;
throws ConnectionException, ProjectileApiException;

/**
* Get a list of clocked times for the current day and user.
*
* @return list of clocked times or empty list
* @throws ConnectionException
* if connection to Projectile cannot be established
* @throws CrawlingException
* @throws ProjectileApiException
* in case the crawling fails
*/
List<Booking> getDailyReport(Credentials credentials) throws ConnectionException,
CrawlingException;
ProjectileApiException;

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.saxsys.projectiler.crawler;
package de.saxsys.projectiler.api;

import java.util.concurrent.TimeUnit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import org.junit.Test;

import de.saxsys.projectiler.api.Credentials;

public class CredentialsTest {

@Test
Expand Down
26 changes: 13 additions & 13 deletions backend/src/main/java/de/saxsys/projectiler/Projectiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import java.util.List;
import java.util.logging.Logger;

import de.saxsys.projectiler.crawler.ConnectionException;
import de.saxsys.projectiler.crawler.Crawler;
import de.saxsys.projectiler.crawler.CrawlingException;
import de.saxsys.projectiler.crawler.Credentials;
import de.saxsys.projectiler.crawler.InvalidCredentialsException;
import de.saxsys.projectiler.api.ConnectionException;
import de.saxsys.projectiler.api.ProjectileClientApi;
import de.saxsys.projectiler.api.ProjectileApiException;
import de.saxsys.projectiler.api.Credentials;
import de.saxsys.projectiler.api.InvalidCredentialsException;
import de.saxsys.projectiler.ws.rest.RetrofitClient;

/**
Expand All @@ -20,13 +20,13 @@ public class Projectiler {

private static final Logger LOGGER = Logger.getLogger(Projectiler.class.getSimpleName());
private final UserDataStore dataStore = UserDataStore.getInstance();
private final Crawler crawler;
private final ProjectileClientApi crawler;

public static Projectiler createDefaultProjectiler() {
return new Projectiler(new RetrofitClient(new SystemSettings()));
}

protected Projectiler(final Crawler crawler) {
protected Projectiler(final ProjectileClientApi crawler) {
this.crawler = crawler;
}

Expand Down Expand Up @@ -56,11 +56,11 @@ public Date checkin() {
*
* @param projectName project to clock your time to
* @param comment optional comment
* @throws CrawlingException
* @throws ProjectileApiException
* @throws ConnectionException if connection to Projectile fails
* @throws IllegalStateException if invoked while not being checked in or if work time is less than one minute
*/
public Date checkout(final String projectName, final String comment) throws CrawlingException {
public Date checkout(final String projectName, final String comment) throws ProjectileApiException {
if (!isCheckedIn()) {
throw new IllegalStateException("Must be checked in before checking out.");
}
Expand Down Expand Up @@ -88,9 +88,9 @@ public Date checkout(final String projectName, final String comment) throws Craw
*
* @return list of project names or empty list
* @throws ConnectionException if connection to Projectile fails
* @throws CrawlingException if an error occoures in the crawles
* @throws ProjectileApiException if an error occoures in the crawles
*/
public List<String> getProjectNames() throws ConnectionException, CrawlingException {
public List<String> getProjectNames() throws ConnectionException, ProjectileApiException {
return crawler.getProjectNames(createCredentials());
}

Expand All @@ -101,10 +101,10 @@ public List<String> getProjectNames() throws ConnectionException, CrawlingExcept
* @param password Projectile password
* @throws InvalidCredentialsException if credentials are invalid
* @throws ConnectionException if connection to Projectile fails
* @throws CrawlingException
* @throws ProjectileApiException
*/
public void saveCredentials(final String username, final String password)
throws InvalidCredentialsException, ConnectionException, CrawlingException {
throws InvalidCredentialsException, ConnectionException, ProjectileApiException {
crawler.checkCredentials(new Credentials(username, password));
dataStore.setCredentials(username, password);
dataStore.save();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.saxsys.projectiler;

import de.saxsys.projectiler.crawler.Settings;
import de.saxsys.projectiler.api.Settings;

/**
* Read settings from environment variables.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import javafx.concurrent.Task;
import de.saxsys.projectiler.Projectiler;
import de.saxsys.projectiler.crawler.InvalidCredentialsException;
import de.saxsys.projectiler.api.InvalidCredentialsException;
import de.saxsys.projectiler.misc.Notification;

public class CheckOutTask extends Task<Date> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import javafx.concurrent.Task;
import de.saxsys.projectiler.Projectiler;
import de.saxsys.projectiler.crawler.ConnectionException;
import de.saxsys.projectiler.crawler.InvalidCredentialsException;
import de.saxsys.projectiler.api.ConnectionException;
import de.saxsys.projectiler.api.InvalidCredentialsException;
import de.saxsys.projectiler.misc.Notification;

public class LoginTask extends Task<Boolean> {
Expand Down
Loading

0 comments on commit ed4fe57

Please sign in to comment.