-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Dropbox Controller * Add Dropbox tests * Add Dropbox menu item
- Loading branch information
Showing
7 changed files
with
109 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ out/ | |
.gradletasknamecache | ||
.gradle/ | ||
build/ | ||
|
||
# dropbox credentials | ||
dropbox.json | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,64 @@ | ||
package webapp; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.net.URL; | ||
|
||
/** | ||
* Dropbox API specific | ||
*/ | ||
public class Dropbox { | ||
// retrieve private credentials from Dropbox Developers app | ||
static { | ||
try { | ||
FileReader readCred = new FileReader("dropbox.json"); | ||
JSONObject dropCred = new JSONObject(readCred); | ||
final String key = dropCred.getString("key"); | ||
final String secret = dropCred.getString("secret"); | ||
final String token = dropCred.getString("token"); | ||
private String key; | ||
private String secret; | ||
private String token; | ||
|
||
public Dropbox() { | ||
readSetCredentials(); | ||
} | ||
public Dropbox(String key, String secret) { | ||
this.key = key; | ||
this.secret = secret; | ||
} | ||
public Dropbox(String key, String secret, String token) { | ||
this.key = key; | ||
this.secret = secret; | ||
this.token = token; | ||
} | ||
|
||
private void readSetCredentials() { | ||
try { | ||
URL url = getClass().getResource("/services/dropbox.json"); | ||
FileReader readCred = new FileReader(url.getPath()); | ||
JSONObject dropCred = new JSONObject(url.getPath()); | ||
key = dropCred.getString("key"); | ||
secret = dropCred.getString("secret"); | ||
token = dropCred.getString("token"); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
public String getSecret() { | ||
return secret; | ||
} | ||
public String getToken() { | ||
return token; | ||
} | ||
public void setKey(String key) { | ||
this.key = key; | ||
} | ||
public void setSecret(String secret) { | ||
this.secret = secret; | ||
} | ||
public void setToken(String token) { | ||
this.token = token; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package webapp; | ||
|
||
import com.dropbox.core.DbxException; | ||
import com.dropbox.core.DbxRequestConfig; | ||
import com.dropbox.core.v2.DbxClientV2; | ||
import com.dropbox.core.v2.users.FullAccount; | ||
|
||
/** | ||
* This class controls the Dropbox application logic. | ||
*/ | ||
public class DropboxController { | ||
private static Dropbox dropbox; | ||
private DbxClientV2 client; | ||
private DbxRequestConfig config; | ||
|
||
public DropboxController() { | ||
initialize(); | ||
} | ||
|
||
private void initialize() { | ||
dropbox = new Dropbox(); // uses default json file credentials | ||
config = new DbxRequestConfig("dropbox/IronGate", "en_US"); | ||
client = new DbxClientV2(config, dropbox.getToken()); | ||
} | ||
|
||
public void test() throws DbxException{ | ||
FullAccount account = client.users.getCurrentAccount(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters