Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 71 additions & 85 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -1,85 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.smartsheet.tools</groupId>
<artifactId>smartsheet-org-backup</artifactId>
<name>Smartsheet Org Backup</name>
<version>1.6.1</version>
<description>Backs up the Smartsheet sheets of all users in an organization to a local directory.</description>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer>
<mainClass>com.smartsheet.tools.SmartsheetBackupTool</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>6</source>
<target>6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<formats>
<format>html</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.smartsheet.tools</groupId>
<artifactId>smartsheet-org-backup</artifactId>
<name>Smartsheet Org Backup</name>
<version>1.6.3</version>
<description>Backs up the Smartsheet sheets of all users in an organization to a local directory.</description>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer>
<mainClass>com.smartsheet.tools.SmartsheetBackupTool</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>6</source>
<target>6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

79 changes: 32 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.smartsheet.tools</groupId>
<artifactId>smartsheet-org-backup</artifactId>
<version>1.6.2</version>
<version>1.6.3</version>
<name>Smartsheet Org Backup</name>
<description>Backs up the Smartsheet sheets of all users in an organization to a local directory.</description>

<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
Expand All @@ -24,35 +29,30 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.smartsheet.tools.SmartsheetBackupTool</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.smartsheet.tools.SmartsheetBackupTool</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -75,19 +75,4 @@
</plugins>
</pluginManagement>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<formats>
<format>html</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
</project>
4 changes: 4 additions & 0 deletions smartsheet-backup.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ outputDir=backup/smartsheet-backup
#zipOutputDir=true
#downloadThreads=4
#allDownloadsDoneTimeout=2
#proxyUser=username
#proxyPassword=password
#proxyHost=proxy.domain.local
#proxyPort=8080
17 changes: 17 additions & 0 deletions src/main/java/com/smartsheet/restapi/model/ProxyCredential.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.smartsheet.restapi.model;

public class ProxyCredential {

public String username;
public String password;
public String proxyHost;
public int port;

public ProxyCredential(String username, String password, String proxyHost, int port) {
this.username = username;
this.password = password;
this.proxyHost = proxyHost;
this.port = port == 0 ? 8080 : port;
}

}
46 changes: 36 additions & 10 deletions src/main/java/com/smartsheet/tools/SmartsheetBackupTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
**/
package com.smartsheet.tools;

import static com.smartsheet.utils.FileUtils.deleteFolder;
import static com.smartsheet.utils.FileUtils.zipDirectory;
import com.smartsheet.restapi.model.ProxyCredential;
import com.smartsheet.restapi.service.ErrorContextualizingSmartsheetService;
import com.smartsheet.restapi.service.RestfulSmartsheetService;
import com.smartsheet.restapi.service.RetryingSmartsheetService;
import com.smartsheet.restapi.service.SmartsheetService;
import com.smartsheet.utils.ConfigHolder;
import com.smartsheet.utils.ProgressWatcher;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -28,12 +33,8 @@
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import com.smartsheet.restapi.service.ErrorContextualizingSmartsheetService;
import com.smartsheet.restapi.service.RestfulSmartsheetService;
import com.smartsheet.restapi.service.RetryingSmartsheetService;
import com.smartsheet.restapi.service.SmartsheetService;
import com.smartsheet.utils.ConfigHolder;
import com.smartsheet.utils.ProgressWatcher;
import static com.smartsheet.utils.FileUtils.deleteFolder;
import static com.smartsheet.utils.FileUtils.zipDirectory;

/**
* The main class of the SmartsheetBackupTool utility program.
Expand All @@ -54,6 +55,8 @@ public class SmartsheetBackupTool {
private static final ConfigHolder configHolder = ConfigHolder.getInstance();
public static final String VERSION = "1.3";

public static ProxyCredential proxyCredential = null;

/**
* The entry point of the program which reads properties, instantiates
* services, and backs up the sheets of all active users in an organization
Expand Down Expand Up @@ -85,14 +88,31 @@ public static void main(String[] args) {
int downloadThreads = getOptionalProp(props, "downloadThreads",
DEFAULT_DOWNLOAD_THREADS, 1);

String proxyUsername = getOptionalProp(props, "proxyUser", null);
String proxyPassowrd = getOptionalProp(props, "proxyPassword", null);
String proxyHost = getOptionalProp(props, "proxyHost", null);
int proxyPort;

try {
proxyPort = Integer.parseInt(getOptionalProp(props, "proxyPort", null));
} catch(NumberFormatException e) {
proxyPort = 0;
}

if(proxyUsername != null && proxyPassowrd != null && proxyHost != null) {
proxyCredential = new ProxyCredential(proxyUsername, proxyPassowrd, proxyHost, proxyPort);
}

// 2. instantiate services
SmartsheetService apiService = new ErrorContextualizingSmartsheetService(
// the ErrorContextualizingSmartsheetService wraps the
// RetryingSmartsheetService:
new RetryingSmartsheetService(
// the RetryingSmartsheetService wraps the
// RestfulSmartsheetService:
new RestfulSmartsheetService(accessToken)));
new RestfulSmartsheetService(accessToken)
)
);

ParallelDownloadService parallelDownloadService = new ParallelDownloadService(downloadThreads);

Expand All @@ -102,7 +122,6 @@ public static void main(String[] args) {
SmartsheetBackupService backupService = new SmartsheetBackupService(
apiService, parallelDownloadService);
long startTime = System.currentTimeMillis();

// 3. back up the organization to a local folder
int numberUsers = backupService.backupOrgTo(new File(outputDir));

Expand Down Expand Up @@ -236,6 +255,13 @@ private static int getOptionalProp(Properties props, String propName,
}
}

private static String getOptionalProp(Properties props, String propName, String defaultValue) {
String prop = props.getProperty(propName, defaultValue);
if(prop != null)
return prop;
return defaultValue;
}

private static boolean getOptionalProp(Properties props, String propName,
boolean defaultValue) {
String prop = props.getProperty(propName, String.valueOf(defaultValue));
Expand Down
Loading