Skip to content

Commit b07e649

Browse files
authored
Merge pull request #9 from premkamal13/fix_data_fetch_from_spoj
Change protocol to https to fix SPOJ solutions' fetch failure
2 parents 6c66df4 + 39fd329 commit b07e649

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/com/koldbyte/codebackup/core/TestApp.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ public static void test7() {
114114
}
115115

116116
public static void test8() {
117-
Problem problem = new SpojProblem("http://www.spoj.com/problems/FCTRL/");
117+
Problem problem = new SpojProblem("https://www.spoj.com/problems/FCTRL/");
118118
System.out.println(problem.getProblemStatement());
119119
}
120120

121121
public static void test9() {
122-
User u = new SpojUser("koldbyte", "http://www.spoj.com/users/koldbyte/");
122+
User u = new SpojUser("koldbyte", "https://www.spoj.com/users/koldbyte/");
123123
PluginInterface plugin = new SpojPluginImpl();
124124
List<Submission> list = plugin.getSolvedList(u);
125125
for (Submission s : list) {
@@ -131,8 +131,8 @@ public static void test9() {
131131
}
132132

133133
public static void test10() {
134-
User u = new SpojUser("koldbyte", "http://www.spoj.com/users/koldbyte/");
135-
Problem p = new SpojProblem("http://www.spoj.com/problems/BITMAP/");
134+
User u = new SpojUser("koldbyte", "https://www.spoj.com/users/koldbyte/");
135+
Problem p = new SpojProblem("https://www.spoj.com/problems/BITMAP/");
136136
((SpojUser) u).setUsername("koldbyte");
137137
((SpojUser) u).setPass("thisisrandompass");
138138
Submission s = new SpojSubmission("11808446",

src/com/koldbyte/codebackup/plugins/spoj/SpojPluginImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919

2020
public class SpojPluginImpl implements PluginInterface {
2121

22-
private final String HTTP = "http://";
22+
private final String HTTPS = "https://";
2323
private final String SUBMISSIONLIST = "www.spoj.com/status/:u/signedlist/";
2424

25-
private final String LOGINURL = "http://www.spoj.com/login";
25+
private final String LOGINURL = HTTPS + "www.spoj.com/login";
2626

2727
@Override
2828
public List<Submission> getSolvedList(User user) {
2929
List<Submission> subs = new ArrayList<Submission>();
30-
String url = HTTP + SUBMISSIONLIST.replace(":u", user.getHandle());
30+
String url = HTTPS + SUBMISSIONLIST.replace(":u", user.getHandle());
3131

3232
try {
3333
//TODO: Add login to fetch the spoj signedlist
@@ -100,7 +100,7 @@ public List<Submission> getSolvedList(User user) {
100100
@Override
101101
public List<Submission> getAllSolvedList(User user) {
102102
List<Submission> subs = new ArrayList<Submission>();
103-
String url = HTTP + SUBMISSIONLIST.replace(":u", user.getHandle());
103+
String url = HTTPS + SUBMISSIONLIST.replace(":u", user.getHandle());
104104

105105
try {
106106
//TODO: Add login to fetch the spoj signedlist

src/com/koldbyte/codebackup/plugins/spoj/core/entities/SpojProblem.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
import com.koldbyte.codebackup.core.entities.Problem;
1111

1212
public class SpojProblem extends Problem {
13-
private final String HTTP = "http://";
13+
private final String HTTPS = "https://";
1414
private final String PROBLEMURL = "www.spoj.com/problems/:p/";
1515

1616
@Override
1717
public String fetchProblemStatement() {
1818
String problem = getProblemId();
19-
String url = HTTP + PROBLEMURL.replace(":p", problem);
19+
String url = HTTPS + PROBLEMURL.replace(":p", problem);
2020
/*-
2121
* Spoj Problem Page looks like this
2222
*
@@ -56,7 +56,7 @@ public String getUrl() {
5656
// replace ":p" with the problem id
5757
problemUrl.replace(":p", problemId);
5858

59-
url = HTTP + PROBLEMURL;
59+
url = HTTPS + PROBLEMURL;
6060
this.setUrl(url);
6161
}
6262
return url;
@@ -66,7 +66,7 @@ public String getUrl() {
6666
public String getProblemId() {
6767
if (problemId == null || problemId.isEmpty()) {
6868
String u = getUrl();
69-
u = u.replace(HTTP, "");
69+
u = u.replace(HTTPS, "");
7070
u = u.replace("www.spoj.com/problems/", "");
7171
u = u.replace("/", "");
7272
this.setProblemId(u);

src/com/koldbyte/codebackup/plugins/spoj/core/entities/SpojSubmission.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import com.koldbyte.codebackup.core.entities.User;
1111

1212
public class SpojSubmission extends Submission {
13-
private final String HTTP = "http://";
13+
private final String HTTPS = "https://";
1414
private final String SUBMITTEDURL = "www.spoj.com/files/src/save/:s/";
15-
private final String LOGINURL = "http://www.spoj.com/login";
15+
private final String LOGINURL = HTTPS + "www.spoj.com/login";
1616

1717
@Override
1818
public String fetchSubmittedCode() {
@@ -34,7 +34,7 @@ public String fetchSubmittedCode() {
3434
.method(Connection.Method.POST).execute();
3535

3636
// login done...now use the cookies to whenever u are fetching code
37-
String url = HTTP + SUBMITTEDURL.replace(":s", submissionId);
37+
String url = HTTPS + SUBMITTEDURL.replace(":s", submissionId);
3838
String code = Jsoup.connect(url).ignoreContentType(true)
3939
.cookies(loginForm.cookies()).method(Connection.Method.GET)
4040
.execute().body();
@@ -57,15 +57,15 @@ public String fetchSubmittedCode() {
5757
@Override
5858
public String getSubmissionIdFromUrl() {
5959
String url = getSubmissionUrl();
60-
url = url.replace(HTTP, "");
60+
url = url.replace(HTTPS, "");
6161
url = url.replace("www.spoj.com/files/src/save/", "");
6262
url = url.replace("/", "");
6363
return url;
6464
}
6565

6666
@Override
6767
public String getSubmissionUrlFromId() {
68-
String subId = HTTP + SUBMITTEDURL.replace(":s", getSubmissionId());
68+
String subId = HTTPS + SUBMITTEDURL.replace(":s", getSubmissionId());
6969
return subId;
7070
}
7171

src/com/koldbyte/codebackup/plugins/spoj/core/entities/SpojUser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.koldbyte.codebackup.core.entities.User;
44

55
public class SpojUser extends User {
6-
private final String HTTP = "http://";
6+
private final String HTTPS = "https://";
77
private final String PROFILEURL = "www.spoj.com/users/:u/";
88

99
private String username;
@@ -36,15 +36,15 @@ public SpojUser(String handle, String profileUrl) {
3636
@Override
3737
public String getHandleFromProfileUrl() {
3838
String handle = profileUrl;
39-
handle = handle.replace(HTTP, "");
39+
handle = handle.replace(HTTPS, "");
4040
handle = handle.replace("www.spoj.com/users/", "");
4141
handle = handle.replace("/", "");
4242
return handle;
4343
}
4444

4545
@Override
4646
public String getProfileUrlFromHandle() {
47-
return HTTP + PROFILEURL.replace(":u", this.handle);
47+
return HTTPS + PROFILEURL.replace(":u", this.handle);
4848
}
4949

5050
@Override

0 commit comments

Comments
 (0)