mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
Merge branch 'master' into bug2659
This commit is contained in:
commit
8fece8f5ca
922 files changed
+28905
-818
No files matched your search
+3
-10
@@ -43,11 +43,9 @@ public class RaceGroupFactory {
|
||||
String name = leaderboard.getName();
|
||||
CourseArea courseArea = leaderboard.getDefaultCourseArea();
|
||||
Regatta regatta = ((RegattaLeaderboard) leaderboard).getRegatta();
|
||||
|
||||
Iterable<SeriesWithRows> series = getSeries(leaderboard);
|
||||
|
||||
return new RaceGroupImpl(name, regatta.getBoatClass(), courseArea, series,
|
||||
regatta.getRegattaConfiguration());
|
||||
return new RaceGroupImpl(name, leaderboard.getDisplayName(), regatta.getBoatClass(), courseArea,
|
||||
series, regatta.getRegattaConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,20 +55,15 @@ public class RaceGroupFactory {
|
||||
*/
|
||||
public RaceGroup convert(FlexibleLeaderboard leaderboard) {
|
||||
String name = leaderboard.getName();
|
||||
|
||||
CourseArea courseArea = leaderboard.getDefaultCourseArea();
|
||||
BoatClass boatClass = null;
|
||||
RegattaConfiguration configuration = null;
|
||||
|
||||
Iterable<SeriesWithRows> series = getSeries(leaderboard);
|
||||
|
||||
return new RaceGroupImpl(name, boatClass, courseArea, series, configuration);
|
||||
return new RaceGroupImpl(name, leaderboard.getDisplayName(), boatClass, courseArea, series, configuration);
|
||||
}
|
||||
|
||||
public Iterable<SeriesWithRows> getSeries(Leaderboard leaderboard) {
|
||||
|
||||
Map<Series, List<RaceColumn>> seriesToRaceColumns = getSeriesToRaceColumns(leaderboard);
|
||||
|
||||
Collection<SeriesWithRows> seriesWithRows = new ArrayList<>();
|
||||
for (Series series : getSeriesIterable(leaderboard, seriesToRaceColumns)) {
|
||||
seriesWithRows.add(new SeriesWithRowsImpl(series.getName(), series.isMedal(), getRows(series,
|
||||
|
||||
+11
-3
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.server.gateway.jaxrs.api;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
@@ -18,6 +20,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.apache.commons.fileupload.util.Streams;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
@@ -117,8 +120,7 @@ public class CompetitorsResource extends AbstractSailingServerResource {
|
||||
@Path("{competitor-id}/team/image")
|
||||
@Produces("application/json;charset=UTF-8")
|
||||
public String setTeamImage(@PathParam("competitor-id") String competitorId, InputStream uploadedInputStream,
|
||||
@HeaderParam("Content-Type") String fileType, @HeaderParam("Content-Length") long sizeInBytes) {
|
||||
|
||||
@HeaderParam("Content-Type") String fileType, @HeaderParam("Content-Length") long sizeInBytes) throws IOException {
|
||||
RacingEventService service = getService();
|
||||
CompetitorStore store = service.getCompetitorStore();
|
||||
Competitor competitor = store.getExistingCompetitorByIdAsString(competitorId);
|
||||
@@ -134,7 +136,13 @@ public class CompetitorsResource extends AbstractSailingServerResource {
|
||||
} else if (fileType.equals("image/png")) {
|
||||
fileExtension = ".png";
|
||||
}
|
||||
|
||||
if (sizeInBytes <= 0) {
|
||||
// size not provided; read the stream and determine length locally:
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
Streams.copy(uploadedInputStream, bos, /* close output stream */ true);
|
||||
sizeInBytes = bos.size();
|
||||
uploadedInputStream = new ByteArrayInputStream(bos.toByteArray());
|
||||
}
|
||||
URI imageUri;
|
||||
try {
|
||||
if (sizeInBytes > 1024 * 1024 * MAX_SIZE_IN_MB) {
|
||||
|
||||
Reference in new issue
Block a user