Skip to content

Commit

Permalink
i_843 PR Change Requests
Browse files Browse the repository at this point in the history
Make corrections to comments.
Add missing API endpoint for Access endpoint.
Remove extra param contestId for Access endpoint
Use clarAns to determine if answer/announcement is SendToAll.
  • Loading branch information
johnbrvc committed Feb 19, 2025
1 parent dde3f3d commit 745c998
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/edu/csus/ecs/pc2/clics/API202306/AccessService.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
// Copyright (C) 1989-2025 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.clics.API202306;

import javax.inject.Singleton;
Expand All @@ -19,7 +19,7 @@

/**
* WebService to handle "state" REST endpoint as described by the CLICS wiki.
*
*
* @author John Buck
*
*/
Expand All @@ -41,7 +41,7 @@ public AccessService(IInternalContest inModel, IInternalController inController)

/**
* This method returns a representation of the access that the connected user has
*
*
* @return a {@link Response} object containing a JSON String giving the access information for the connected user
*/
@GET
Expand All @@ -50,9 +50,9 @@ public Response getAccess(@Context SecurityContext sc, @PathParam("contestId") S

// check contest id
if(contestId.equals(model.getContestIdentifier()) == true) {
return Response.ok(new CLICSContestAccess(sc, model, controller, contestId).toJSON(), MediaType.APPLICATION_JSON).build();
return Response.ok(new CLICSContestAccess(sc, model, controller).toJSON(), MediaType.APPLICATION_JSON).build();
}
return Response.status(Response.Status.NOT_FOUND).build();
return Response.status(Response.Status.NOT_FOUND).build();
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public String toJSON() {
}

/**
* Create account list from a accounts.yaml like file
* Create account list from a accounts.json like file
*
* @param contest the contest (needed for groups)
* @param yamlfile yaml file to deserialize
Expand All @@ -132,10 +132,10 @@ public String toJSON() {
}

/**
* Create account list from a string containing accounts yaml
* Create account list from a string containing accounts json
*
* @param contest the contest (needed for groups)
* @param yaml yaml to deserialize
* @param json json to deserialize
* @param site the site to create the accounts for
* @return array of accounts to add, or null on error
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public CLICSClarification(IInternalContest model, Clarification clar, Clarificat
}
if (clarAns != null) {
// does the answer go to a team (as opposed to everyone)?
if (!clar.isSendToAll()){
if (!clarAns.isSendToAll()){
// The CLICS 2023-06 model does not fit in with the PC2 concept of directed responses to Groups
// and a list of teams. As such, we'll always return the team that submitted the request, in to_team_id
// since they will get the response (and possibly others).
Expand Down
19 changes: 8 additions & 11 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSContestAccess.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
// Copyright (C) 1989-2025 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.

package edu.csus.ecs.pc2.clics.API202306;

Expand All @@ -17,7 +17,7 @@
import edu.csus.ecs.pc2.services.core.JSONUtilities;

/**
* CLICS Contest State
* CLICS Contest Access
*
* @author John Buck
*
Expand Down Expand Up @@ -52,9 +52,8 @@ public class CLICSContestAccess {
* @param sc security info for user making request
* @param model
* @param controller
* @param contestId
*/
public CLICSContestAccess(SecurityContext sc, IInternalContest model, IInternalController controller, String contestId) {
public CLICSContestAccess(SecurityContext sc, IInternalContest model, IInternalController controller) {
this.controller = controller;

// For each role the connected user has, we enumerate what they can do with each endpoint.
Expand Down Expand Up @@ -95,7 +94,7 @@ public CLICSContestAccess(SecurityContext sc, IInternalContest model, IInternalC
*/
String [] serviceNames = { "Contest", "JudgementType", "Language", "Problem", "Group", "Organization",
"Team", "Person", "Account", "State", "Submission", "Judgement", "Run", "Clarification",
"Scoreboard", "EventFeed", "Award", "Commentary"
"Scoreboard", "EventFeed", "Award", "Commentary", "Webhooks"
};

ArrayList<CLICSEndpoint> epList = new ArrayList<CLICSEndpoint>();
Expand All @@ -108,19 +107,17 @@ public CLICSContestAccess(SecurityContext sc, IInternalContest model, IInternalC
controller.getLog().log(Log.WARNING, "No endpoint access for service " + service);
}
}
if(!epList.isEmpty()) {
endpoints = epList.toArray(new CLICSEndpoint[0]);
}
endpoints = epList.toArray(new CLICSEndpoint[0]);
}

/**
* Create a fully qualified class name for the supplied web service endpoint.
* eg. Group would create: edu.csus.ecs.pc2clics.API202306.GroupService
* eg. Group would create: edu.csus.ecs.pc2.clics.API202306.GroupService
* Then call its getEndpointProperties(SecurityContext) static method to see what properties the
* service supports for the supplied SecurityContext (user).
* Note: If Java reflection makes you queasy, please stop here and just skip reading the code in this method.
*
* @param epList List to add the CLICSEndpointObject to, if one was returned
* @param epList List to add the CLICSEndpointObject to, if one was found
* @param serviceName The service name only (excluding the trailing "Service")
* @param sc User's security context
* @return true if this endpoint is accessible by the user in the SecurityContext
Expand Down Expand Up @@ -161,7 +158,7 @@ public String toJSON() {
ObjectMapper mapper = JSONUtilities.getObjectMapper();
return mapper.writeValueAsString(this);
} catch (Exception e) {
return "Error creating JSON for contest state info " + e.getMessage();
return "Error creating JSON for contest access info " + e.getMessage();
}
}
}

0 comments on commit 745c998

Please sign in to comment.