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
18 changes: 14 additions & 4 deletions src/main/java/pl/zazen/dharmagate/configs/ApplicationConfig.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package pl.zazen.dharmagate.configs;

import com.dropbox.core.DbxException;
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.v2.DbxClientV2;
import com.dropbox.core.v2.users.FullAccount;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -21,8 +23,16 @@ public class ApplicationConfig {
@Bean
@Profile("dev")
public DbxClientV2 dropboxClient() {
DbxRequestConfig config = DbxRequestConfig.newBuilder("dropbox/java-tutorial").build();
return new DbxClientV2(config, ACCESS_TOKEN);
}
DbxRequestConfig config = new DbxRequestConfig("dharmaGate/1.0");
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);

try {
FullAccount account = client.users().getCurrentAccount();
System.out.println(account.getName().getDisplayName());
} catch (DbxException e) {
e.printStackTrace();
}

}
return client;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pl.zazen.dharmagate.documents;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.Validate;
import pl.zazen.dharmagate.documents.Document.Document;
Expand All @@ -8,17 +9,12 @@
import pl.zazen.dharmagate.documents.DocumentInformation.DocumentInformationService;

@Service
@AllArgsConstructor
public class DefaultDocumentService implements DocumentService {

private DocumentInformationService documentInformationService;
private DropboxDocumentRepository dropboxDocumentRepository;

public DefaultDocumentService(DocumentInformationService documentInformationService,
DropboxDocumentRepository dropboxDocumentRepository) {
this.documentInformationService = documentInformationService;
this.dropboxDocumentRepository = dropboxDocumentRepository;
}

@Override
public Document getByHash(String hash) {
Validate.notNull(hash, "id cannot be null");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package pl.zazen.dharmagate.documents.Document;

import lombok.AllArgsConstructor;
import java.io.InputStream;

@AllArgsConstructor
public class DropboxDocument implements Document {

private InputStream inputStream;

private DropboxDocument() {}

public static DropboxDocument fromInputStream(InputStream inputStream) {
DropboxDocument dropboxDocument = new DropboxDocument();
dropboxDocument.inputStream = inputStream;
return dropboxDocument;
return new DropboxDocument(inputStream);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@
import com.dropbox.core.DbxException;
import com.dropbox.core.v2.DbxClientV2;
import com.dropbox.core.v2.files.FileMetadata;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Repository;
import org.thymeleaf.util.Validate;

@Repository
@AllArgsConstructor
public class DropboxDocumentRepository implements DocumentRepository {

private DbxClientV2 dropboxClient;

public DropboxDocumentRepository(DbxClientV2 dropboxClient) {
this.dropboxClient = dropboxClient;
}

@Override
public Document getByPath(String path) {
Validate.notNull(path, "path cannot be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ public class DropboxClientTests {

@Test
public void dbxClientBean_ShouldBeInstantiated() {
assertThat(dbxClient).isNotNull();
try{
assertThat(dbxClient.users().getCurrentAccount().getCountry()).isEqualTo("PL");
}catch (DbxException e){
e.getMessage();
}

//assertThat(dbxClient).isNotNull();

}

@Test
Expand Down