8000 Fix svg png same url by vmcj · Pull Request #1115 · icpctools/icpctools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix svg png same url #1115

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

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
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
31 changes: 29 additions & 2 deletions BalloonUtility/BalloonUtility.iml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="PresCore" />
<orderEntry type="module" module-name="ContestModel" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/../ContestModel/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$MODULE_DIR$/../ContestModel/lib" recursive="false" />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
Expand All @@ -21,11 +31,28 @@
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/../ContestModel/lib" />
<root url="jar://$MODULE_DIR$/../SWTLauncher/lib/swt-win32-win32-x86_64.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../SWTLauncher/lib/swt-gtk-linux-x86_64.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../SWTLauncher/lib/swt-cocoa-macosx-x86_64.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$MODULE_DIR$/../ContestModel/lib" recursive="false" />
</library>
</orderEntry>
</component>
Expand Down
10 changes: 10 additions & 0 deletions CDS/CDS.iml
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,15 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/../ContestModel/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$MODULE_DIR$/../ContestModel/lib" recursive="false" />
</library>
</orderEntry>
</component>
</module>
6 changes: 6 additions & 0 deletions CDS/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@ folder and are shown in their Linux form; replace the "/" characters with "\" on
| /bin/server status cds | Displays the current status of the CDS
| /bin/server list | List the servers which WLP knows about

### Sending errors to Sentry

To ship exceptions to sentry for easier debugging:

* Enable the `<ssl id="defaultSSLConfig>` in `server.xml`
* Set the `DSN` in `wlp/usr/servers/cds/{server.env,sentry.properties}` or the command line.

## Accessing CDS Services

Expand Down
3 changes: 2 additions & 1 deletion CDS/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<pathelement location="io.openliberty.jakarta.security.3.0_1.0.93.jar"/>
<pathelement location="WebContent/WEB-INF/lib/openpdf-1.3.27.jar"/>
<pathelement location="${contest.model}/bin"/>
<pathelement location="${contest.model}/lib/sentry-opentelemetry-agent-8.12.0.jar"/>
<pathelement location="${contest.model}/lib/snakeyaml-2.3.jar"/>
</path>
<target name="init">
Expand Down Expand Up @@ -129,4 +130,4 @@
<classpath refid="CDS.classpath"/>
</javac>
</target>
</project>
</project>
4 changes: 4 additions & 0 deletions CDS/config/wlp/cds/sentry.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#dsn=https://fill_with_sentry_dsn@replace.sentry.io/identifier"
# Add data like request headers and IP for users,
# see https://docs.sentry.io/platforms/java/data-management/data-collected/ for more info
send-default-pii=false
1 change: 1 addition & 0 deletions CDS/config/wlp/cds/server.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#SENTRY_DSN="https://fill_with_sentry_dsn@replace.sentry.io/identifier"
1 change: 1 addition & 0 deletions CDS/config/wlp/cds/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<httpSession invalidationTimeout="8h" idReuse="true"/>

<keyStore id="defaultKeyStore" password="{xor}FhwPHAswMDMs" />
<!--<ssl id="defaultSSLConfig" keyStoreRef="defaultKeyStore" trustDefaultCerts="true" />-->

<jndiEntry jndiName="icpc.cds.config" value="${server.config.dir}/config"/>

Expand Down
17 changes: 17 additions & 0 deletions CDS/src/org/icpc/tools/cds/service/ContestRESTService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.icpc.tools.cds.service;

import io.sentry.Sentry;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -63,6 +65,16 @@ static class EndpointInfo {
String id;
}

@Override
public void init() throws ServletException {
super.init();
try {
Sentry.init();
} catch (Exception e) {
Trace.trace(Trace.WARNING, "Sentry init failed,");
}
}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpHelper.setThreadHost(request);
Expand Down Expand Up @@ -128,6 +140,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
contest.getInfo();
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Contest not configured");
Sentry.captureException(e);
}

if (segments.length == 2) {
Expand Down Expand Up @@ -881,6 +894,7 @@ protected JsonObject postSubmission(HttpServletRequest request, HttpServletRespo
rObj = restSource.postSubmission(obj);
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_BAD_GATEWAY, "Error submitting to CCS: " + e.getMessage());
Sentry.captureException(e);
return null;
}
}
Expand Down Expand Up @@ -1030,6 +1044,7 @@ protected void patchAward(HttpServletRequest request, HttpServletResponse respon
restSource.patch(ContestType.AWARD, obj);
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_BAD_GATEWAY, "Error submitting award to CCS: " + e.getMessage());
Sentry.captureException(e);
return;
}
}
Expand Down Expand Up @@ -1062,6 +1077,7 @@ protected void deleteAward(HttpServletRequest request, HttpServletResponse respo
restSource.delete(ContestType.AWARD, id);
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_BAD_GATEWAY, "Error submitting award to CCS: " + e.getMessage());
Sentry.captureException(e);
return;
}
}
Expand Down Expand Up @@ -1108,6 +1124,7 @@ protected JsonObject postContestObject(HttpServletRequest request, HttpServletRe
return restSource.post(type, obj);
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_BAD_GATEWAY, "Error POSTing to CCS: " + e.getMessage());
Sentry.captureException(e);
return null;
}
}
Expand Down
Binary file not shown.
13 changes: 12 additions & 1 deletion ContestModel/src/org/icpc/tools/contest/Trace.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.icpc.tools.contest;

import io.sentry.Sentry;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -201,6 +203,12 @@ public static void init(String name, String filename, String[] args) {
writer.print(s + " ");
writer.println();
}
try {
Sentry.init();
} catch (Exception e) {
// Sentry config might be empty.
}
writer.println("Sentry: " + (Sentry.isEnabled()? "Enabled" : "Disabled"));
writer.println("Log started " + sdf.format(new Date()));
writer.println();
writer.flush();
Expand Down Expand Up @@ -235,8 +243,11 @@ public static void trace(byte type, String s, Throwable t) {
// ignore
}
}
} else
} else {
Sentry.setExtra("trace_debug", s);
Sentry.captureException(t);
previousErrors.add(hash);
}
}
if (type != INFO || writer == null) {
if (type == ERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void writeScoreboard(PrintWriter pw, IContest contest) {
pw.write("\"score\":{");
if (ScoreboardType.PASS_FAIL.equals(scoreboardType)) {
pw.write("\"num_solved\":" + s.getNumSolved() + ",");
if (!isDraftSpec) {
if (isDraftSpec) {
pw.write("\"total_time\":\"" + RelativeTime.format(s.getTime()) + "\"},\n");
} else {
pw.write("\"total_time\":" + ContestUtil.getTime(s.getTime()) + "},\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ private FileReferenceList getFilesWithPattern(FilePattern pattern) {
folder = new File(root, pattern.folder);

FileReferenceList refList = new FileReferenceList();
List<String> urlList = new ArrayList<>();
for (String ext : pattern.extensions) {
File[] files = folder.listFiles(
(dir, name) -> (name.toLowerCase().startsWith(pattern.name) && name.toLowerCase().endsWith("." + ext)));
Expand All @@ -1100,9 +1101,13 @@ private FileReferenceList getFilesWithPattern(FilePattern pattern) {
for (File file : files) {
String diff = file.getName();
diff = diff.substring(pattern.name.length(), diff.length() - ext.length() - 1);
FileReference ref = getMetadata(pattern.url + diff, file);
if (ref != null)
FileReference ref = getMetadata(pattern.url+diff+'.'+ext, file);
if (ref != null) {
if (urlList.contains(ref.href))
Trace.trace(Trace.WARNING, "Found multiple files with same CDS href: " + ref.href + ", " + file);
refList.add(ref);
urlList.add(ref.href);
}
// TODO future: url currently would not be able to handle logo2.svg and logo2.png
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,6 @@ public void removeFromHistory(List<IContestObject> remove) {
IContestObject obj2 = objs[num][arr];
if (obj2 != null && rtc[obj2.getType().ordinal()].contains(obj2.getId())) {
objs[num][arr] = null;
if (!keepHistory)
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void testParseTimeWithoutSeconds() throws Exception {
parseTime("5:00");
}

private int parseTime(String s) throws ParseException {
private long parseTime(String s) throws ParseException {
return RelativeTime.parse(s);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,6 @@ public AnalystContest(IAccount account) {
super(account);
}

@Override
public void add(IContestObject obj) {
if (obj instanceof IDelete) {
addIt(obj);
return;
}

IContestObject.ContestType cType = obj.getType();
switch (cType) {
case RUN: { // TODO - access block for live
IRun run = (IRun) obj;

IJudgement j = getJudgementById(run.getJudgementId());
if (j == null)
return;

if (isJudgementHidden(j))
return;

ISubmission s = getSubmissionById(j.getSubmissionId());
if (s == null)
return;

// hide runs for submissions outside the contest time
long time = s.getContestTime();
if (time < 0 || time >= getDuration())
return;

// hide runs for submissions after freeze
if (getFreezeDuration() != null) {
long freezeTime = getDuration() - getFreezeDuration();
if (s.getContestTime() >= freezeTime && getState().getThawed() == null) {
freeze.add(run);
return;
}
}

addIt(run);
return;
}
default:
super.add(obj);
}
}

@Override
protected IPerson filterPerson(IPerson person) {
Person p = (Person) ((Person) person).clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import org.icpc.tools.contest.model.IAccount;
import org.icpc.tools.contest.model.IContestObject;
import org.icpc.tools.contest.model.IDelete;
import org.icpc.tools.contest.model.IJudgement;
import org.icpc.tools.contest.model.IProblem;
import org.icpc.tools.contest.model.IRun;
import org.icpc.tools.contest.model.ISubmission;
import org.icpc.tools.contest.model.internal.Problem;

Expand Down Expand Up @@ -37,6 +39,37 @@ public void add(IContestObject obj) {
addIt(obj);
return;
}
case RUN: { // TODO - access block for live
IRun run = (IRun) obj;

IJudgement j = getJudgementById(run.getJudgementId());
if (j == null)
return;

if (isJudgementHidden(j))
return;

ISubmission s = getSubmissionById(j.getSubmissionId());
if (s == null)
return;

// hide runs for submissions outside the contest time
long time = s.getContestTime();
if (time < 0 || time >= getDuration())
return;

// hide runs for submissions after freeze
if (getFreezeDuration() != null) {
long freezeTime = getDuration() - getFreezeDuration();
if (s.getContestTime() >= freezeTime && getState().getThawed() == null) {
freeze.add(run);
return;
}
}

addIt(run);
return;
}
default: {
super.add(obj);
}
Expand Down
Loading
0