Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eliminated maven warnings by providing plugin version #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
93 changes: 48 additions & 45 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>edu.uoc.elc.lti</groupId>
<artifactId>lti-1.3-core</artifactId>
<version>0.0.2</version>
<packaging>jar</packaging>

<name>lti-1.3-core</name>
<description>Shared interfaces and beans for using in LTI libraries</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.10.1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>edu.uoc.elc.lti</groupId>
<artifactId>lti-1.3-core</artifactId>
<version>0.0.2</version>
<packaging>jar</packaging>

<name>lti-1.3-core</name>
<description>Shared interfaces and beans for using in LTI libraries</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.10.1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
32 changes: 16 additions & 16 deletions src/main/java/edu/uoc/lti/accesstoken/AccessTokenRequest.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package edu.uoc.lti.accesstoken;

import lombok.Builder;
import lombok.Getter;

/**
* @author Created by [email protected]
*/
@Getter
@Builder
public class AccessTokenRequest {
private String grant_type;
private String client_assertion_type;
private String scope;
private String client_assertion;
}
package edu.uoc.lti.accesstoken;
import lombok.Builder;
import lombok.Value;
/**
* @author Created by [email protected]
*/
@Value
@Builder
public class AccessTokenRequest {
private String grant_type;
private String client_assertion_type;
private String scope;
private String client_assertion;
}
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
package edu.uoc.lti.accesstoken;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.stream.Collectors;

public class UrlEncodedFormAccessTokenRequestBuilderImpl implements AccessTokenRequestBuilder {

@Override
public String build(final AccessTokenRequest request) throws IOException {
final Method[] methods = request.getClass().getDeclaredMethods();

return Arrays.stream(methods)
.map(method -> {
try {
if (!method.getName().startsWith("get")) {
return null;
}
final Object value = method.invoke(request, null);
String valueAsString = null;
if (method.getReturnType().getSimpleName().equals("String")) {
valueAsString = (String) value;
}
else if (method.getReturnType().isPrimitive()) {
valueAsString = String.valueOf(value);
}
return valueAsString != null && valueAsString.length() > 0
? method.getName().substring(3, 4).toLowerCase() + method.getName().substring(4) + "=" + URLEncoder.encode(valueAsString, StandardCharsets.UTF_8.toString())
: null;
} catch (IllegalArgumentException | InvocationTargetException | UnsupportedEncodingException
| IllegalAccessException e) {
e.printStackTrace();
}
return null;
})
.filter(value -> value != null)
.collect(Collectors.joining("&"));
}

@Override
public String getContentType() {
return "application/x-www-form-urlencoded";
}

package edu.uoc.lti.accesstoken;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.stream.Collectors;

import lombok.extern.java.Log;

@Log
public class UrlEncodedFormAccessTokenRequestBuilderImpl implements AccessTokenRequestBuilder {

@Override
public String build(final AccessTokenRequest request) throws IOException {
final Method[] methods = request.getClass().getDeclaredMethods();

return Arrays.stream(methods).map(method -> {
try {
if (!method.getName().startsWith("get")) {
return null;
}
final Object value = method.invoke(request, (Object[]) null);
String valueAsString = null;
if (method.getReturnType().getSimpleName().equals("String")) {
valueAsString = (String) value;
} else if (method.getReturnType().isPrimitive()) {
valueAsString = String.valueOf(value);
}
return valueAsString != null && valueAsString.length() > 0
? method.getName().substring(3, 4).toLowerCase() + method.getName().substring(4) + "="
+ URLEncoder.encode(valueAsString, StandardCharsets.UTF_8.toString())
: null;
} catch (IllegalArgumentException | InvocationTargetException | UnsupportedEncodingException
| IllegalAccessException e) {
log.warning("Cannot build UrlEncodedFormAccessTokenRequest. " + e.getClass().getName() + " - "
+ e.getMessage());
}
return null;
}).filter(value -> value != null).collect(Collectors.joining("&"));
}

@Override
public String getContentType() {
return "application/x-www-form-urlencoded";
}

}
1 change: 1 addition & 0 deletions src/main/java/edu/uoc/lti/ags/LineItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/uoc/lti/ags/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Getter;
import lombok.Setter;

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/edu/uoc/lti/ags/Score.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package edu.uoc.lti.ags;

import java.time.Instant;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.time.Instant;

/**
* @author Created by [email protected]
*/
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/edu/uoc/lti/ags/Submission.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package edu.uoc.lti.ags;

import java.time.Instant;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Setter;

import java.time.Instant;
import lombok.Setter;

/**
* @author Created by [email protected]
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/edu/uoc/lti/deeplink/DeepLinkingResponse.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package edu.uoc.lti.deeplink;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

import java.util.List;

import edu.uoc.lti.deeplink.content.Item;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

/**
* @author Created by [email protected]
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/uoc/lti/deeplink/content/DataItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.uoc.lti.deeplink.content;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/edu/uoc/lti/deeplink/content/Duration.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package edu.uoc.lti.deeplink.content;

import java.time.Instant;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Builder;
import lombok.Setter;
import lombok.ToString;

import java.time.Instant;

/**
* @author Created by [email protected]
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/uoc/lti/deeplink/content/FileItem.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package edu.uoc.lti.deeplink.content;

import java.time.Instant;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.time.Instant;

/**
* @author Created by [email protected]
*/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/uoc/lti/deeplink/content/HtmlItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.uoc.lti.deeplink.content;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/uoc/lti/deeplink/content/IFrame.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.uoc.lti.deeplink.content;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/uoc/lti/deeplink/content/Image.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.uoc.lti.deeplink.content;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/uoc/lti/deeplink/content/ImageItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.uoc.lti.deeplink.content;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/edu/uoc/lti/deeplink/content/Item.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package edu.uoc.lti.deeplink.content;

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;

/**
* @author Created by [email protected]
*/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/uoc/lti/deeplink/content/LineItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.uoc.lti.deeplink.content;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
Expand Down
Loading