Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
robdrysdale
committed
Dec 16, 2011
1 parent
508266d
commit 18318b9
Showing
29 changed files
with
1,165 additions
and
72 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
127 changes: 127 additions & 0 deletions
127
src/main/java/org/springframework/social/dropbox/api/Dropbox.java
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,127 @@ | ||
package org.springframework.social.dropbox.api; | ||
|
||
import java.util.List; | ||
|
||
|
||
/** | ||
* Dropbox Interface | ||
* | ||
* @author Bryce Fischer | ||
* @author Robert Drysdale | ||
*/ | ||
public interface Dropbox { | ||
/** | ||
* Retrieve Details for a Dropbox's Profile Details | ||
* | ||
* @return Dropbox Users Profile Details | ||
*/ | ||
DropboxUserProfile getUserProfile(); | ||
|
||
/** | ||
* Get Metadata For a File or Directory | ||
* | ||
* @param path | ||
* @return Metadata | ||
*/ | ||
Metadata getItemMetadata(String path); | ||
|
||
/** | ||
* Restore a file to a revision | ||
* Will also restore an deleted file | ||
* | ||
* @param path | ||
* @param rev | ||
* @return Metadata | ||
*/ | ||
Metadata restore(String path, String rev) ; | ||
|
||
/** | ||
* Copy File to new file or directory | ||
* | ||
* @param fromPath | ||
* @param toPath | ||
* @return Metadata | ||
*/ | ||
Metadata copy(String fromPath, String toPath); | ||
|
||
/** | ||
* Create a new folder | ||
* | ||
* @param folder | ||
* @return Metadata | ||
*/ | ||
Metadata createFolder(String folder); | ||
|
||
/** | ||
* Delete a file | ||
* | ||
* @param path | ||
* @return Metadata | ||
*/ | ||
Metadata delete(String path); | ||
|
||
/** | ||
* Move a File | ||
* | ||
* @param fromPath | ||
* @param toPath | ||
* @return Metadata | ||
*/ | ||
Metadata move(String fromPath, String toPath); | ||
|
||
/** | ||
* Get List of Revisions for a File | ||
* @param path | ||
* @return List of Metadata | ||
*/ | ||
List<Metadata> getRevisions(String path); | ||
|
||
/** | ||
* Search for a File | ||
* | ||
* @param path | ||
* @param query | ||
* @return List of Metadata | ||
*/ | ||
List<Metadata> search(String path, String query); | ||
|
||
/** | ||
* Get Thumbnail for a file | ||
* | ||
* @param path | ||
* @return Dropbox File | ||
*/ | ||
DropboxFile getThumbnail(String path); | ||
|
||
/** | ||
* Retrieve a File | ||
* @param path | ||
* @return Dropbox File | ||
*/ | ||
DropboxFile getFile(String path); | ||
|
||
/** | ||
* Get Url for a File that can be streamed as media | ||
* | ||
* @param path | ||
* @return File Url with Expires Date | ||
*/ | ||
FileUrl getMedia(String path); | ||
|
||
/** | ||
* Get Url for a File that can be shared | ||
* | ||
* @param path | ||
* @return File Url with Expires Date | ||
*/ | ||
FileUrl getShare(String path); | ||
|
||
/** | ||
* Push a File to Dropbox | ||
* | ||
* @param path | ||
* @param file | ||
* @return Metadata | ||
*/ | ||
Metadata putFile(String path, byte[] file); | ||
} |
15 changes: 0 additions & 15 deletions
15
src/main/java/org/springframework/social/dropbox/api/DropboxApi.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
src/main/java/org/springframework/social/dropbox/api/DropboxFile.java
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,46 @@ | ||
package org.springframework.social.dropbox.api; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* Dropbox File Details | ||
* | ||
* @author Robert Drysdale | ||
* | ||
*/ | ||
public class DropboxFile implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private final String contentType; | ||
private final long size; | ||
private final InputStream inputStream; | ||
|
||
public DropboxFile(String contentType, long size, InputStream inputStream) { | ||
this.contentType = contentType; | ||
this.size = size; | ||
this.inputStream = inputStream; | ||
} | ||
|
||
public String getContentType() { | ||
return contentType; | ||
} | ||
|
||
public long getSize() { | ||
return size; | ||
} | ||
|
||
public InputStream getInputStream() { | ||
return inputStream; | ||
} | ||
|
||
public byte[] getBytes() throws IOException { | ||
byte[] ret = new byte[(int)size]; | ||
for (int i = 0; i < size; i++) { | ||
ret[i] = (byte)inputStream.read(); | ||
} | ||
|
||
return ret; | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
src/main/java/org/springframework/social/dropbox/api/DropboxItemMetadata.java
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
32 changes: 32 additions & 0 deletions
32
src/main/java/org/springframework/social/dropbox/api/FileUrl.java
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,32 @@ | ||
package org.springframework.social.dropbox.api; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
/** | ||
* File Url that can be shared or streamed as media | ||
* | ||
* @author Robert Drysdale | ||
* | ||
*/ | ||
public class FileUrl implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private final String url; | ||
private final Date expires; | ||
|
||
public FileUrl(String url, Date expires) { | ||
this.url = url; | ||
this.expires = expires; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public Date getExpires() { | ||
return expires; | ||
} | ||
|
||
} |
100 changes: 100 additions & 0 deletions
100
src/main/java/org/springframework/social/dropbox/api/Metadata.java
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,100 @@ | ||
package org.springframework.social.dropbox.api; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
/** | ||
* Metadata which describes a directory or file | ||
* in Dropbox | ||
* | ||
* @author Robert Drysdale | ||
* | ||
*/ | ||
public class Metadata implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
private final String size; | ||
private final int bytes; | ||
private final boolean isDir; | ||
private final boolean isDeleted; | ||
private final String rev; | ||
private final String hash; | ||
private final boolean thumbExists; | ||
private final String icon; | ||
private final Date modified; | ||
private final String root; | ||
private final String path; | ||
private final String mimeType; | ||
private final List<Metadata> contents; | ||
|
||
public Metadata(String size, int bytes, boolean isDir, boolean isDeleted, | ||
String rev, String hash, boolean thumbExists, String icon, | ||
Date modified, String root, String path, String mimeType, List<Metadata> contents) { | ||
super(); | ||
this.size = size; | ||
this.bytes = bytes; | ||
this.isDir = isDir; | ||
this.isDeleted = isDeleted; | ||
this.rev = rev; | ||
this.hash = hash; | ||
this.thumbExists = thumbExists; | ||
this.icon = icon; | ||
this.modified = modified; | ||
this.root = root; | ||
this.path = path; | ||
this.mimeType = mimeType; | ||
this.contents = contents; | ||
} | ||
|
||
public String getSize() { | ||
return size; | ||
} | ||
|
||
public int getBytes() { | ||
return bytes; | ||
} | ||
|
||
public boolean isDir() { | ||
return isDir; | ||
} | ||
|
||
public boolean isDeleted() { | ||
return isDeleted; | ||
} | ||
|
||
public String getRev() { | ||
return rev; | ||
} | ||
|
||
public String getHash() { | ||
return hash; | ||
} | ||
|
||
public boolean isThumbExists() { | ||
return thumbExists; | ||
} | ||
|
||
public String getIcon() { | ||
return icon; | ||
} | ||
|
||
public Date getModified() { | ||
return modified; | ||
} | ||
|
||
public String getRoot() { | ||
return root; | ||
} | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
|
||
public String getMimeType() { | ||
return mimeType; | ||
} | ||
|
||
public List<Metadata> getContents() { | ||
return contents; | ||
} | ||
} |
Oops, something went wrong.