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
25 changes: 25 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Build with Maven
run: mvn -B package --file pom.xml
21 changes: 21 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
Expand Down Expand Up @@ -130,6 +143,14 @@
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
<resources>
<resource>
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/com/clickntap/vimeo/Vimeo.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
Expand All @@ -27,6 +28,7 @@
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.client.CloseableHttpClient;
Expand Down Expand Up @@ -109,7 +111,7 @@ public VimeoResponse addVideoPrivacyDomain(String videoEndpoint, String domain)
}

public VimeoResponse getVideoPrivacyDomains(String videoEndpoint) throws IOException {
return apiRequest(new StringBuffer(videoEndpoint).append("/privacy/domains").toString(), HttpGet.METHOD_NAME, null, null);
return apiRequest(new StringBuffer(videoEndpoint).append("/privacy/domains").toString(), HttpGet.METHOD_NAME, null, null);
}

public VimeoResponse removeVideo(String videoEndpoint) throws IOException {
Expand Down Expand Up @@ -291,8 +293,8 @@ protected VimeoResponse apiRequest(String endpoint, String methodName, Map<Strin
request.addHeader("Accept", "application/vnd.vimeo.*+json;version=3.2");
request.addHeader("Authorization", new StringBuffer(tokenType).append(' ').append(token).toString());
HttpEntity entity = null;
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
if (params != null) {
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
for (String key : params.keySet()) {
postParameters.add(new BasicNameValuePair(key, params.get(key)));
}
Expand All @@ -301,6 +303,21 @@ protected VimeoResponse apiRequest(String endpoint, String methodName, Map<Strin
entity = new InputStreamEntity(inputStream, ContentType.MULTIPART_FORM_DATA);
}
if (entity != null) {
if (request instanceof HttpGet) {
URIBuilder builder;
try {
// rebuild the request
builder = new URIBuilder(url);
builder.setParameters(postParameters);
request = new HttpGet(builder.build());
request.addHeader("Accept", "application/vnd.vimeo.*+json;version=3.2");
request.addHeader("Authorization", new StringBuffer(tokenType).append(' ').append(token).toString());
} catch (URISyntaxException e) {
// this should never happen, but...
throw new IOException("Exception converting url to uri", e);
}

}
if (request instanceof HttpPost) {
((HttpPost) request).setEntity(entity);
} else if (request instanceof HttpPatch) {
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/com/clickntap/vimeo/VimeoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.clickntap.vimeo;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

public class VimeoTest {

@Test
void testJUnit() {
assertTrue(true);
}
}