Skip to content

Commit

Permalink
testmycode#115 All red String urls changed to URI urls
Browse files Browse the repository at this point in the history
  • Loading branch information
nimirum committed Sep 14, 2015
1 parent 4eb5424 commit 7c734c7
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion maven-wrapper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>tmc-checkstyle-runner</artifactId>
<version>2.1.2-SNAPSHOT</version>
<version>2.1.1</version>
<exclusions>
<exclusion>
<groupId>com.puppycrawl.tools</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void bgTaskFailed(Throwable ex) {
public Course call() throws Exception {
logger.info("Downloading course to refresh cache");
currentCourseFuture =
tmcCore.getCourse(currentCourseBeforeUpdate.getDetailsUrlAsUri());
tmcCore.getCourse(currentCourseBeforeUpdate.getDetailsUrl());
return currentCourseFuture.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -175,7 +176,7 @@ private void sendLoggableEvent(Review review) {
private static class ReviewOpened {
public final int id;
public final int submissionId;
public final String url;
public final URI url;
public final boolean markedAsRead;

public ReviewOpened(Review review) {
Expand Down
7 changes: 4 additions & 3 deletions tmc-plugin/src/fi/helsinki/cs/tmc/model/CourseDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -142,13 +143,13 @@ public List<Exercise> getCurrentCourseUnlockableExercises() {
List<Exercise> result = new ArrayList<Exercise>();
Course course = getCurrentCourse();
if (course != null) {
List<String> unlockables = course.getUnlockables();
List<URI> unlockables = course.getUnlockables();
if (unlockables == null) {
unlockables = Collections.emptyList();
}
for (String exerciseName : unlockables) {
for (URI exerciseName : unlockables) {
for (Exercise ex : course.getExercises()) {
if (ex.getName().equals(exerciseName)) {
if (ex.getName().equals(exerciseName.toString())) {
result.add(ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fi.helsinki.cs.tmc.events.TmcEvent;
import fi.helsinki.cs.tmc.events.TmcEventBus;
import fi.helsinki.cs.tmc.events.TmcEventListener;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.TimerTask;
Expand Down Expand Up @@ -120,12 +121,12 @@ private synchronized void initClientIfPossible() {
return;
}

String cometUrl = course.getCometUrl();
URI cometUrl = course.getCometUrl();
if (cometUrl == null) {
return;
}
ClientTransport transport = createWebSocketTransport(cometUrl);
client = new BayeuxClient(cometUrl, transport);
ClientTransport transport = createWebSocketTransport(cometUrl.toString());
client = new BayeuxClient(cometUrl.toString(), transport);
client.getChannel(Channel.META_HANDSHAKE).addListener(handshakeListener);
client.getChannel(Channel.META_DISCONNECT).addListener(disconnectListener);

Expand Down
22 changes: 11 additions & 11 deletions tmc-plugin/src/fi/helsinki/cs/tmc/model/ServerAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public boolean cancel() {

@Deprecated
public CancellableCallable<Course> getFullCourseInfoTask(Course courseStub) {
String url = addApiCallQueryParameters(courseStub.getDetailsUrl());
final CancellableCallable<String> download = createHttpTasks().getForText(url);
URI url = URI.create(addApiCallQueryParameters(courseStub.getDetailsUrl().toString()));
final CancellableCallable<String> download = createHttpTasks().getForText(url.toString());
return new CancellableCallable<Course>() {
@Override
public Course call() throws Exception {
Expand Down Expand Up @@ -177,22 +177,22 @@ public boolean cancel() {
}

private String getUnlockUrl(Course course) {
return addApiCallQueryParameters(course.getUnlockUrl());
return addApiCallQueryParameters(course.getUnlockUrl().toString());
}

public CancellableCallable<byte[]> getDownloadingExerciseZipTask(Exercise exercise) {
String zipUrl = exercise.getDownloadUrl();
return createHttpTasks().getForBinary(zipUrl);
URI zipUrl = exercise.getDownloadUrl();
return createHttpTasks().getForBinary(zipUrl.toString());
}

public CancellableCallable<byte[]> getDownloadingExerciseSolutionZipTask(Exercise exercise) {
String zipUrl = exercise.getSolutionDownloadUrl();
return createHttpTasks().getForBinary(zipUrl);
URI zipUrl = exercise.getSolutionDownloadUrl();
return createHttpTasks().getForBinary(zipUrl.toString());
}

public CancellableCallable<SubmissionResponse> getSubmittingExerciseTask(
final Exercise exercise, final byte[] sourceZip, Map<String, String> extraParams) {
final String submitUrl = addApiCallQueryParameters(exercise.getReturnUrl());
final URI submitUrl = URI.create(addApiCallQueryParameters(exercise.getReturnUrl().toString()));

Map<String, String> params = new LinkedHashMap<String, String>();
params.put("client_time", "" + (System.currentTimeMillis() / 1000L));
Expand All @@ -202,7 +202,7 @@ public CancellableCallable<SubmissionResponse> getSubmittingExerciseTask(
final CancellableCallable<String> upload =
createHttpTasks()
.uploadFileForTextDownload(
submitUrl, params, "submission[file]", sourceZip);
submitUrl.toString(), params, "submission[file]", sourceZip);

return new CancellableCallable<SubmissionResponse>() {
@Override
Expand Down Expand Up @@ -254,8 +254,8 @@ public CancellableCallable<String> getSubmissionFetchTask(String submissionUrl)
}

public CancellableCallable<List<Review>> getDownloadingReviewListTask(Course course) {
String url = addApiCallQueryParameters(course.getReviewsUrl());
final CancellableCallable<String> download = createHttpTasks().getForText(url);
URI url = URI.create(addApiCallQueryParameters(course.getReviewsUrl().toString()));
final CancellableCallable<String> download = createHttpTasks().getForText(url.toString());
return new CancellableCallable<List<Review>>() {
@Override
public List<Review> call() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.openide.util.Exceptions;

import java.io.IOException;
import java.net.URI;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -248,15 +249,15 @@ private String pickDestinationUrl() {
return null;
}

List<String> urls = course.getSpywareUrls();
List<URI> urls = course.getSpywareUrls();
if (urls == null || urls.isEmpty()) {
log.log(
Level.INFO,
"Not sending events because no URL provided by server");
return null;
}

String url = urls.get(random.nextInt(urls.size()));
String url = urls.get(random.nextInt(urls.size())).toString();

return url;
}
Expand Down Expand Up @@ -316,8 +317,8 @@ private void clearAfterSend(List<HttpResult> success) {

private void addCorrectSpywareUrl(
final String url, Optional<Course> currentCourse) {
List<String> spywareUrls = new ArrayList<String>();
String finalUrl = serverAccess.addApiCallQueryParameters(url);
List<URI> spywareUrls = new ArrayList<URI>();
URI finalUrl = URI.create(serverAccess.addApiCallQueryParameters(url));
spywareUrls.add(finalUrl);
currentCourse.get().setSpywareUrls(spywareUrls);
}
Expand Down
1 change: 1 addition & 0 deletions tmc-plugin/src/fi/helsinki/cs/tmc/ui/CodeReviewDialog.form
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
Expand Down
2 changes: 1 addition & 1 deletion tmc-plugin/src/fi/helsinki/cs/tmc/ui/CodeReviewDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private String getPointsAwardedText(Review review) {

private void openInBrowser() {
try {
HtmlBrowser.URLDisplayer.getDefault().showURLExternal(new URL(review.getUrl()));
HtmlBrowser.URLDisplayer.getDefault().showURLExternal(new URL(review.getUrl().toString()));
} catch (MalformedURLException ex) {
log.log(Level.WARNING, "Malformed URL: " + ex.getMessage(), ex);
}
Expand Down

0 comments on commit 7c734c7

Please sign in to comment.