Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  excluding third party dependencies when creating .jar artifact. issue #45
  Updates in End2End authentication. Using refreshtoken
  moving fetcher logic to ctor as stated per issue # 18. Changes applied to templates
  fixing several Code Inspection warnings for issue #13
  adding better sintaxis to retrieve items from collection without using getByIdXXX
  Added select and filter tests for Lists
  Removed unsupported filter tests for files
  Added filter, select and top tests in Discovery, Exchange and Files
  adding suppress warnings to odatacollectionfetcher
  adding constraints to generic parameters. issue #21
  adding constraint to generic parameters
  Updated End2End App
  updating outloook services with latest changes in code generator
  adding bintray plugin into e2e test app
  Updated End2End. Added general_settings.xml Started adding Tests for Directory & Discovery
  rolling back to gradle wrapper version 1.12 for sample app
  add version headers for issue #36
  add task to create .jar from .aar
  minor changes and clean ups to gradle scripts
  • Loading branch information
Marcos Torres committed Nov 6, 2014
2 parents 604c0bf + 090f397 commit 429f94d
Show file tree
Hide file tree
Showing 76 changed files with 5,580 additions and 3,885 deletions.
2 changes: 1 addition & 1 deletion samples/simple-exchange-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
classpath 'com.android.tools.build:gradle:0.12.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
20 changes: 19 additions & 1 deletion sdk/android-libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,31 @@ uploadArchives {
url: 'https://api.bintray.com/maven/msopentech/Maven/Office-365-SDK-for-Android'
) {
authentication(
userName: 'username',
userName: 'user',
password: 'password'
)
}
}
}

android.libraryVariants.all { variant ->

def task = project.tasks.create "jar${name.capitalize()}", Jar
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
task.from configurations.compile.findAll {

it.getName() != 'android.jar' &&
//manually removing dependencies. .jar consumers will need to fulfill these dependencies
!it.getName().startsWith('guava') &&
!it.getName().startsWith('gson')

}.collect {
it.isDirectory() ? it : zipTree(it)
}
artifacts.add('archives', task);
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
Expand Down
3 changes: 0 additions & 3 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@ allprojects {
repositories {
jcenter()
}
apply plugin: 'idea'
group = 'com.microsoft.services'
version = '0.9.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public ODataMediaEntityFetcher(String urlComponent, ODataExecutable parent, Clas
public ListenableFuture<byte[]> getContent() {
ODataURL url = getResolver().createODataURL();
url.appendPathComponent("$value");
ListenableFuture<byte[]> future = oDataExecute(url, null, HttpVerb.GET);

return future;
return oDataExecute(url, null, HttpVerb.GET);
}

public ListenableFuture<Void> putContent(byte[] content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public ODataMediaEntityFetcher(String urlComponent, ODataExecutable parent, Clas
public ListenableFuture<byte[]> getContent() {
ODataURL url = getResolver().createODataURL();
url.appendPathComponent("$value");
ListenableFuture<byte[]> future = oDataExecute(url, null, HttpVerb.GET);

return future;
return oDataExecute(url, null, HttpVerb.GET);
}

public ListenableFuture<Void> putContent(byte[] content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public ODataMediaEntityFetcher(String urlComponent, ODataExecutable parent, Clas
public ListenableFuture<byte[]> getContent() {
ODataURL url = getResolver().createODataURL();
url.appendPathComponent("$value");
ListenableFuture<byte[]> future = oDataExecute(url, null, HttpVerb.GET, getCustomHeaders());

return future;
return oDataExecute(url, null, HttpVerb.GET, getCustomHeaders());
}

public ListenableFuture<Void> putContent(byte[] content) {
Expand Down
4 changes: 2 additions & 2 deletions sdk/java-libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ bintray {
publicDownloadNumbers = true

version {
name = '0.9.1' //Optional logical version name
name = '0.9.2' //Optional logical version name
desc = 'Office 365 Android SDK'
vcsTag = '0.9.1'
vcsTag = '0.9.2'
}
}
}
4 changes: 3 additions & 1 deletion sdk/list-services/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'com.microsoft.services'
PUBLISH_ARTIFACT_ID = 'list-services'
PUBLISH_VERSION = '0.9.1'
PUBLISH_VERSION = '0.9.2'
}

android {
Expand All @@ -29,3 +29,5 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile group: 'com.google.guava', name: 'guava', version: '18.0'
}

apply from : '../android-libraries.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,36 @@
import com.microsoft.listservices.http.Request;
import com.microsoft.listservices.http.Response;

/**
* The type Office client.
*/
public class OfficeClient {

Credentials mCredentials;
Logger mLogger;

public OfficeClient(Credentials credentials) {
/**
* The M credentials.
*/
Credentials mCredentials;
/**
* The M logger.
*/
Logger mLogger;

/**
* Instantiates a new Office client.
*
* @param credentials the credentials
*/
public OfficeClient(Credentials credentials) {
this(credentials, null);
}

public OfficeClient(Credentials credentials, Logger logger) {
/**
* Instantiates a new Office client.
*
* @param credentials the credentials
* @param logger the logger
*/
public OfficeClient(Credentials credentials, Logger logger) {
if (credentials == null) {
throw new IllegalArgumentException("credentials must not be null");
}
Expand All @@ -49,11 +69,22 @@ public void log(String message, LogLevel level) {
mCredentials = credentials;
}

protected void log(String message, LogLevel level) {
/**
* Log void.
*
* @param message the message
* @param level the level
*/
protected void log(String message, LogLevel level) {
getLogger().log(message, level);
}

protected void log(Throwable error) {
/**
* Log void.
*
* @param error the error
*/
protected void log(Throwable error) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
error.printStackTrace(pw);
Expand All @@ -62,24 +93,39 @@ protected void log(Throwable error) {
getLogger().log(error.toString() + "\nStack Trace: " + stackTrace, LogLevel.Critical);
}

protected Logger getLogger() {
/**
* Gets logger.
*
* @return the logger
*/
protected Logger getLogger() {
return mLogger;
}

protected Credentials getCredentials() {
/**
* Gets credentials.
*
* @return the credentials
*/
protected Credentials getCredentials() {
return mCredentials;
}

protected String generateODataQueryString(Query query) {
/**
* Generate o data query string.
*
* @param query the query
* @return the string
*/
protected String generateODataQueryString(Query query) {
StringBuilder sb = new StringBuilder();
if (query != null) {
query.ensureIdProperty();
sb.append("$filter=");
sb.append(queryEncode(query.toString()));

String rowSetModifiers = query.getRowSetModifiers().trim();
if (rowSetModifiers != "") {

if (!rowSetModifiers.equals("")) {
if (!rowSetModifiers.startsWith("&")) {
sb.append("&");
}
Expand All @@ -90,11 +136,27 @@ protected String generateODataQueryString(Query query) {
return sb.toString();
}

protected ListenableFuture<byte[]> executeRequest(String url, String method) {
/**
* Execute request.
*
* @param url the url
* @param method the method
* @return the listenable future
*/
protected ListenableFuture<byte[]> executeRequest(String url, String method) {
return executeRequest(url, method, null, null);
}

protected ListenableFuture<byte[]> executeRequest(String url, String method, Map<String, String> headers,
/**
* Execute request.
*
* @param url the url
* @param method the method
* @param headers the headers
* @param payload the payload
* @return the listenable future
*/
protected ListenableFuture<byte[]> executeRequest(String url, String method, Map<String, String> headers,
byte[] payload) {
HttpConnection connection = Platform.createHttpConnection();

Expand Down Expand Up @@ -141,11 +203,27 @@ public void onSuccess(Response response) {
return result;
}

protected ListenableFuture<JSONObject> executeRequestJson(String url, String method) {
/**
* Execute request json.
*
* @param url the url
* @param method the method
* @return the listenable future
*/
protected ListenableFuture<JSONObject> executeRequestJson(String url, String method) {
return executeRequestJson(url, method, null, null);
}

protected ListenableFuture<JSONObject> executeRequestJson(String url, String method, Map<String, String> headers,
/**
* Execute request json.
*
* @param url the url
* @param method the method
* @param headers the headers
* @param payload the payload
* @return the listenable future
*/
protected ListenableFuture<JSONObject> executeRequestJson(String url, String method, Map<String, String> headers,
byte[] payload) {

final SettableFuture<JSONObject> result = SettableFuture.create();
Expand All @@ -162,7 +240,7 @@ public void onSuccess(byte[] b) {
String string;
try {
string = new String(b, Constants.UTF8_NAME);
if (string == null || string.length() == 0) {
if (string.length() == 0) {
result.set(null);
} else {
JSONObject json = new JSONObject(string);
Expand All @@ -178,11 +256,22 @@ public void onSuccess(byte[] b) {
return result;
}

public ListenableFuture<List<DiscoveryInformation>> getDiscoveryInfo() {
/**
* Gets discovery info.
*
* @return the discovery info
*/
public ListenableFuture<List<DiscoveryInformation>> getDiscoveryInfo() {
return getDiscoveryInfo("https://api.office.com/discovery/me/services");
}

public ListenableFuture<List<DiscoveryInformation>> getDiscoveryInfo(String discoveryEndpoint) {
/**
* Gets discovery info.
*
* @param discoveryEndpoint the discovery endpoint
* @return the discovery info
*/
public ListenableFuture<List<DiscoveryInformation>> getDiscoveryInfo(String discoveryEndpoint) {
final SettableFuture<List<DiscoveryInformation>> result = SettableFuture.create();
final ListenableFuture<JSONObject> request = executeRequestJson(discoveryEndpoint, "GET");

Expand All @@ -206,7 +295,12 @@ public void onSuccess(JSONObject json) {
return result;
}

protected void prepareRequest(Request request) {
/**
* Prepare request.
*
* @param request the request
*/
protected void prepareRequest(Request request) {
request.addHeader("Accept", "application/json;odata=verbose");
request.addHeader("X-ClientService-ClientTag", "SDK-JAVA");

Expand All @@ -218,13 +312,25 @@ protected void prepareRequest(Request request) {
mCredentials.prepareRequest(request);
}

protected static boolean isValidStatus(int status) {
/**
* Is valid status.
*
* @param status the status
* @return the boolean
*/
protected static boolean isValidStatus(int status) {
return status >= 200 && status <= 299;
}

protected String queryEncode(String query) {
/**
* Query encode.
*
* @param query the query
* @return the string
*/
protected String queryEncode(String query) {

String encoded = null;
String encoded;

try {
encoded = query.replaceAll("\\s", "+");
Expand All @@ -234,8 +340,14 @@ protected String queryEncode(String query) {
return encoded;
}

protected String urlEncode(String str) {
String encoded = null;
/**
* Url encode.
*
* @param str the str
* @return the string
*/
protected String urlEncode(String str) {
String encoded;
try {
encoded = URLEncoder.encode(str, Constants.UTF8_NAME);
} catch (UnsupportedEncodingException e) {
Expand All @@ -247,7 +359,13 @@ protected String urlEncode(String str) {
return encoded;
}

protected String UUIDtoString(UUID id) {
/**
* UUI dto string.
*
* @param id the id
* @return the string
*/
protected String UUIDtoString(UUID id) {
return id.toString().replace("-", "");
}
}
Loading

0 comments on commit 429f94d

Please sign in to comment.