improved ORC certificate import servlet's error messages; registered servlet, also with shiro.ini

Change-Id: I844f375c34e69523d31b19767cf636740d6d6323
This commit is contained in:
Axel Uhl committed 2019-09-23 16:19:41 +02:00
1 parent 35027c6f8f
commit dc86ecf0ea
3 files changed
+34 -14

No files matched your search

@@ -102,14 +102,14 @@
<servlet-name>RCCompetitors</servlet-name>
<url-pattern>/rc/competitors</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>RCCompetitorsAndBoats</servlet-name>
<servlet-class>com.sap.sailing.server.gateway.impl.rc.CompetitorsAndBoatsJsonExportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RCCompetitorsAndBoats</servlet-name>
<url-pattern>/rc/competitorsAndBoats</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>RCCompetitorsAndBoats</servlet-name>
<servlet-class>com.sap.sailing.server.gateway.impl.rc.CompetitorsAndBoatsJsonExportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RCCompetitorsAndBoats</servlet-name>
<url-pattern>/rc/competitorsAndBoats</url-pattern>
</servlet-mapping>
<!-- RACE COMMITTEE END -->
<servlet>
<servlet-name>ExpeditionThroughHttpPostServlet</servlet-name>
@@ -213,6 +213,14 @@
<servlet-name>FileUploadServlet</servlet-name>
<url-pattern>/fileupload</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ORCCertificateImportServlet</servlet-name>
<servlet-class>com.sap.sailing.server.gateway.orc.ORCCertificateImportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ORCCertificateImportServlet</servlet-name>
<url-pattern>/orc-certificate-import</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Jersey REST API</servlet-name>
@@ -72,4 +72,5 @@ bearerTokenOrAnonymous = com.sap.sailing.server.security.BearerTokenOrBasicOrFor
/api/v1/** = bearerTokenOrAnonymous
/api/v2/** = bearerTokenOrAnonymous
/spi/v1/** = bearerTokenOrAnonymous
/rc/** = bearerTokenOrAnonymous
/rc/** = bearerTokenOrAnonymous
/orc-certificate-import = bearerTokenOrAnonymous
@@ -225,15 +225,26 @@ public class ORCCertificateImportServlet extends AbstractFileUploadServlet {
private <LogT extends AbstractLog<LogEventT, VisitorT>, VisitorT, LogEventT extends AbstractLogEvent<VisitorT>> void createCertificateAssignments(
LogT logToAddTo, LogEventConstructor<LogEventT, VisitorT> logEventConstructor,
ORCCertificateSelection certificateSelection, Map<String, ORCCertificate> certificates,
HttpServletResponse resp) {
HttpServletResponse resp) throws IOException {
final TimePoint now = MillisecondsTimePoint.now();
final CompetitorAndBoatStore boatStore = getService().getCompetitorAndBoatStore();
final AbstractLogEventAuthor serverAuthor = getService().getServerAuthor();
for (final Entry<Serializable, String> mapping : certificateSelection.getCertificateIdsForBoatIds()) {
final LogEventT assignment = logEventConstructor.create(
now, now, serverAuthor, UUID.randomUUID(), certificates.get(mapping.getValue()),
boatStore.getExistingBoatById(mapping.getKey()));
logToAddTo.add(assignment);
final Boat boat = boatStore.getExistingBoatById(mapping.getKey());
if (boat == null) {
resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Couldn't find the boat with ID "+mapping.getKey());
} else {
final ORCCertificate certificate = certificates.get(mapping.getValue());
if (certificate == null) {
resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Couldn't find the certificate with ID "+mapping.getValue()+
" in the set of certificates provided: "+certificates.keySet());
} else {
final LogEventT assignment = logEventConstructor.create(
now, now, serverAuthor, UUID.randomUUID(), certificate,
boat);
logToAddTo.add(assignment);
}
}
}
}