Skip to content

Commit

Permalink
Complete Mappings for Dropbox API.
Browse files Browse the repository at this point in the history
  • Loading branch information
robdrysdale committed Dec 16, 2011
1 parent 508266d commit 18318b9
Show file tree
Hide file tree
Showing 29 changed files with 1,165 additions and 72 deletions.
19 changes: 15 additions & 4 deletions pom.xml
Expand Up @@ -4,16 +4,16 @@

<groupId>org.springframework.social</groupId>
<artifactId>spring-social-dropbox</artifactId>
<version>1.0</version>
<version>1.0.0.M1</version>
<packaging>jar</packaging>

<name>spring-social-dropbox</name>
<url>http://maven.apache.org</url>
<properties>
<java-version>1.6</java-version>
<org.springframework.social-version>1.0.0.RELEASE</org.springframework.social-version>
<org.springframework-version>3.1.0.M2</org.springframework-version>
<org.springframework.security-version>3.1.0.RC2</org.springframework.security-version>
<org.springframework.social-version>1.0.1.RELEASE</org.springframework.social-version>
<org.springframework-version>3.1.0.RELEASE</org.springframework-version>
<org.springframework.security-version>3.1.0.RELEASE</org.springframework.security-version>
<org.slf4j-version>1.6.1</org.slf4j-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand All @@ -25,6 +25,11 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
Expand All @@ -39,6 +44,12 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${org.springframework.security-version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
127 changes: 127 additions & 0 deletions src/main/java/org/springframework/social/dropbox/api/Dropbox.java
@@ -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);
}

This file was deleted.

@@ -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;
}
}

This file was deleted.

Expand Up @@ -3,9 +3,10 @@
import java.math.BigInteger;

/**
* User: Bryce Fischer
* Date: 5/17/11
* Time: 9:15 AM
*
* Dropbox User Profile
*
* @author Bryce Fischer
*/
public class DropboxUserProfile {
private String country;
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/org/springframework/social/dropbox/api/FileUrl.java
@@ -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 src/main/java/org/springframework/social/dropbox/api/Metadata.java
@@ -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;
}
}

0 comments on commit 18318b9

Please sign in to comment.